Skip to content

Commit

Permalink
feat(editor-ui): Replace lezer with esprima in client linter (#4192)
Browse files Browse the repository at this point in the history
* 🔥 Remove addition from misresolved conflict

* ⚡ Replace `lezer` with `esprima` in client linter

* ⚡ Add missing key

* 📦 Update `package-lock.json`

* ⚡ Match dependencies

* 📦 Update `package-lock.json`

* 📦 Re-update `package-lock.json`
  • Loading branch information
ivov authored Sep 26, 2022
1 parent 9631fc3 commit 55ef5b4
Show file tree
Hide file tree
Showing 8 changed files with 42,560 additions and 54,092 deletions.
96,079 changes: 42,183 additions & 53,896 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,18 @@ export function normalizeItems(
executionData = executionData.json ? [executionData] : [{ json: executionData as IDataObject }];
}

const SUPPORTED_ITEM_KEYS = new Set(['json', 'binary', 'error', 'pairedItem', 'index']);

for (const item of executionData) {
Object.keys(item).forEach((key) => {
if (SUPPORTED_ITEM_KEYS.has(key)) return;

throw new Error(
`Unknown top-level key: ${key}. Did you mean to set this property at item.json?`,
);
});
}

if (executionData.every((item) => typeof item === 'object' && 'json' in item))
return executionData;

Expand Down
2 changes: 2 additions & 0 deletions packages/editor-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@fortawesome/vue-fontawesome": "^2.0.2",
"axios": "^0.21.1",
"dateformat": "^3.0.3",
"esprima": "^4.0.1",
"fast-json-stable-stringify": "^2.1.0",
"file-saver": "^2.0.2",
"flatted": "^3.2.4",
Expand Down Expand Up @@ -77,6 +78,7 @@
"@intlify/vue-i18n-loader": "^1.1.0",
"@n8n_io/eslint-config": "",
"@types/dateformat": "^3.0.0",
"@types/esprima": "^4.0.3",
"@types/express": "^4.17.6",
"@types/file-saver": "^2.0.1",
"@types/jest": "^27.4.0",
Expand Down
10 changes: 10 additions & 0 deletions packages/editor-ui/src/components/CodeNodeEditor/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { STICKY_NODE_TYPE } from "@/constants";
import type { Diagnostic } from "@codemirror/lint";

export const ALL_ITEMS_PLACEHOLDER = `
// Loop over input items and add a new field
Expand Down Expand Up @@ -28,3 +29,12 @@ export const AUTOCOMPLETABLE_BUILT_IN_MODULES = [
'readline', 'url', 'util',
'zlib',
];

export const DEFAULT_LINTER_SEVERITY: Diagnostic['severity'] = 'error';

export const DEFAULT_LINTER_DELAY_IN_MS = 300;

/**
* Offset to account for script wrapper when finding location in source text.
*/
export const OFFSET_FOR_SCRIPT_WRAPPER = 35;
Loading

0 comments on commit 55ef5b4

Please sign in to comment.