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 }