mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 19:11: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) =>
|
const isUnavailableMethodinEachItem = (node: Node) =>
|
||||||
node.type === 'MemberExpression' &&
|
node.type === 'MemberExpression' &&
|
||||||
node.computed === false &&
|
node.computed === false &&
|
||||||
|
node.object.type === 'Identifier' &&
|
||||||
|
node.object.name === '$input' &&
|
||||||
node.property.type === 'Identifier' &&
|
node.property.type === 'Identifier' &&
|
||||||
['first', 'last', 'all', 'itemMatching'].includes(node.property.name);
|
['first', 'last', 'all', 'itemMatching'].includes(node.property.name);
|
||||||
|
|
||||||
walk<TargetNode>(ast, isUnavailableMethodinEachItem).forEach((node) => {
|
walk<TargetNode>(ast, isUnavailableMethodinEachItem).forEach((node) => {
|
||||||
const [start, end] = this.getRange(node.property);
|
const [start, end] = this.getRange(node.property);
|
||||||
|
|
||||||
const message = [
|
const method = this.getText(node.property);
|
||||||
`\`.${node.property.name}()\``,
|
|
||||||
this.$locale.baseText('codeNodeEditor.linter.eachItem.unavailableMethod'),
|
if (!method) return;
|
||||||
].join(' ');
|
|
||||||
|
|
||||||
lintings.push({
|
lintings.push({
|
||||||
from: start,
|
from: start,
|
||||||
to: end,
|
to: end,
|
||||||
severity: DEFAULT_LINTER_SEVERITY,
|
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.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.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.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",
|
"codeNodeEditor.linter.bothModes.syntaxError": "Syntax error",
|
||||||
"collectionParameter.choose": "Choose...",
|
"collectionParameter.choose": "Choose...",
|
||||||
"collectionParameter.noProperties": "No properties",
|
"collectionParameter.noProperties": "No properties",
|
||||||
|
|||||||
Reference in New Issue
Block a user