From 3ae69337eeb1f8a4d698f2099bb190c49cc5f8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 31 Mar 2023 13:33:57 +0200 Subject: [PATCH] fix(editor): Curb overeager item access linting (#5865) :zap: Curb overeager item access linting --- .../editor-ui/src/components/CodeNodeEditor/linter.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/editor-ui/src/components/CodeNodeEditor/linter.ts b/packages/editor-ui/src/components/CodeNodeEditor/linter.ts index 96fe8d397..d33a5c895 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/linter.ts +++ b/packages/editor-ui/src/components/CodeNodeEditor/linter.ts @@ -133,7 +133,7 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({ } /** - * Lint for `.item` unavailable in `runOnceForAllItems` mode + * Lint for `.item` unavailable in `$input` in `runOnceForAllItems` mode * * $input.item -> */ @@ -141,13 +141,15 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({ if (this.mode === 'runOnceForAllItems') { type TargetNode = RangeNode & { property: RangeNode }; - const isUnavailableItemAccess = (node: Node) => + const isUnavailableInputItemAccess = (node: Node) => node.type === 'MemberExpression' && node.computed === false && + node.object.type === 'Identifier' && + node.object.name === '$input' && node.property.type === 'Identifier' && node.property.name === 'item'; - walk(ast, isUnavailableItemAccess).forEach((node) => { + walk(ast, isUnavailableInputItemAccess).forEach((node) => { const [start, end] = this.getRange(node.property); lintings.push({