From e66ee13942715f9a3c6d4a57e1c4f0fa5d72e52c Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Fri, 21 Jan 2022 14:15:04 +0900 Subject: [PATCH] Update parser --- package.json | 2 +- src/rules/shorthand-directive.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 2eb5da928..5d2f854a4 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "eslint-utils": "^3.0.0", "postcss": "^8.4.5", "sourcemap-codec": "^1.4.8", - "svelte-eslint-parser": "^0.12.0" + "svelte-eslint-parser": "^0.13.0" }, "peerDependencies": { "eslint": "^7.0.0 || ^8.0.0-0", diff --git a/src/rules/shorthand-directive.ts b/src/rules/shorthand-directive.ts index d9691f29e..f4e761380 100644 --- a/src/rules/shorthand-directive.ts +++ b/src/rules/shorthand-directive.ts @@ -68,11 +68,8 @@ export default createRule("shorthand-directive", { } const expression = node.expression - if (!expression) { - // Invalid ? - return - } if ( + !expression || expression.type !== "Identifier" || node.key.name.name !== expression.name ) { @@ -80,13 +77,13 @@ export default createRule("shorthand-directive", { return } if (always) { - if (node.key.name.range![0] === expression.range![0]) { + if (node.shorthand) { // Use shorthand return } reportForAlways(node) } else { - if (node.key.name.range![1] < expression.range![0]) { + if (!node.shorthand) { // Use longform return }