mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(editor): curb item method linting in single-item mode in CodeNodeEditor linter (#4455)
🐛 Curb item method linting
This commit is contained in:
@@ -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<TargetNode>(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 },
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user