fix(editor): Curb overeager item access linting (#5865)

 Curb overeager item access linting
This commit is contained in:
Iván Ovejero 2023-03-31 13:33:57 +02:00 committed by GitHub
parent e11a30a640
commit 3ae69337ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 -> <removed> * $input.item -> <removed>
*/ */
@ -141,13 +141,15 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({
if (this.mode === 'runOnceForAllItems') { if (this.mode === 'runOnceForAllItems') {
type TargetNode = RangeNode & { property: RangeNode }; type TargetNode = RangeNode & { property: RangeNode };
const isUnavailableItemAccess = (node: Node) => const isUnavailableInputItemAccess = (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' &&
node.property.name === 'item'; node.property.name === 'item';
walk<TargetNode>(ast, isUnavailableItemAccess).forEach((node) => { walk<TargetNode>(ast, isUnavailableInputItemAccess).forEach((node) => {
const [start, end] = this.getRange(node.property); const [start, end] = this.getRange(node.property);
lintings.push({ lintings.push({