diff --git a/packages/editor-ui/src/components/CodeNodeEditor/linter.ts b/packages/editor-ui/src/components/CodeNodeEditor/linter.ts index 0660ee2a8c..439aba0215 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/linter.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/linter.ts @@ -30,6 +30,15 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({ } catch (syntaxError) { let line; + try { + const lineAtError = editorView.state.doc.line(syntaxError.lineNumber - 1).text; + + // optional chaining operators currently unsupported by esprima-next + if (['?.', ']?'].some((operator) => lineAtError.includes(operator))) return []; + } catch (_) { + return []; + } + try { line = editorView.state.doc.line(syntaxError.lineNumber); @@ -41,7 +50,7 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({ message: this.$locale.baseText('codeNodeEditor.linter.bothModes.syntaxError'), }, ]; - } catch (error) { + } catch (_) { /** * For invalid (e.g. half-written) n8n syntax, esprima errors with an off-by-one line number for the final line. In future, we should add full linting for n8n syntax before parsing JS. */