diff --git a/packages/editor-ui/src/components/CodeNodeEditor/linter.ts b/packages/editor-ui/src/components/CodeNodeEditor/linter.ts index 2edf25425fb19..8193c816b5f1f 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/linter.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/linter.ts @@ -215,22 +215,25 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({ const isUnavailableMethodinEachItem = (node: Node) => node.type === 'MemberExpression' && node.computed === false && + node.object.type === 'Identifier' && + node.object.name === '$input' && node.property.type === 'Identifier' && ['first', 'last', 'all', 'itemMatching'].includes(node.property.name); walk(ast, isUnavailableMethodinEachItem).forEach((node) => { const [start, end] = this.getRange(node.property); - const message = [ - `\`.${node.property.name}()\``, - this.$locale.baseText('codeNodeEditor.linter.eachItem.unavailableMethod'), - ].join(' '); + const method = this.getText(node.property); + + if (!method) return; lintings.push({ from: start, to: end, severity: DEFAULT_LINTER_SEVERITY, - message, + message: this.$locale.baseText('codeNodeEditor.linter.eachItem.unavailableMethod', { + interpolate: { method }, + }), }); }); } diff --git a/packages/editor-ui/src/plugins/i18n/locales/en.json b/packages/editor-ui/src/plugins/i18n/locales/en.json index cba1e8c9b47ce..07ace4eb993d0 100644 --- a/packages/editor-ui/src/plugins/i18n/locales/en.json +++ b/packages/editor-ui/src/plugins/i18n/locales/en.json @@ -237,7 +237,7 @@ "codeNodeEditor.linter.eachItem.emptyReturn": "Code doesn't return an object. Please return an object representing the output item", "codeNodeEditor.linter.eachItem.legacyItemAccess": "`item` is not defined. Did you mean `$input.item.json`?", "codeNodeEditor.linter.eachItem.returnArray": "Code doesn't return an object. Array found instead. Please return an object representing the output item", - "codeNodeEditor.linter.eachItem.unavailableMethod": "is only available in the 'Run Once for All Items' mode.", + "codeNodeEditor.linter.eachItem.unavailableMethod": "Method `$input.{method}()` is only available in the 'Run Once for All Items' mode.", "codeNodeEditor.linter.bothModes.syntaxError": "Syntax error", "collectionParameter.choose": "Choose...", "collectionParameter.noProperties": "No properties",