Skip to content

Commit e95e3b2

Browse files
authored
Update parser (#104)
1 parent 5002597 commit e95e3b2

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"eslint-utils": "^3.0.0",
5959
"postcss": "^8.4.5",
6060
"sourcemap-codec": "^1.4.8",
61-
"svelte-eslint-parser": "^0.12.0"
61+
"svelte-eslint-parser": "^0.13.0"
6262
},
6363
"peerDependencies": {
6464
"eslint": "^7.0.0 || ^8.0.0-0",

src/rules/shorthand-directive.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,22 @@ export default createRule("shorthand-directive", {
6868
}
6969

7070
const expression = node.expression
71-
if (!expression) {
72-
// Invalid ?
73-
return
74-
}
7571
if (
72+
!expression ||
7673
expression.type !== "Identifier" ||
7774
node.key.name.name !== expression.name
7875
) {
7976
// Cannot use shorthand
8077
return
8178
}
8279
if (always) {
83-
if (node.key.name.range![0] === expression.range![0]) {
80+
if (node.shorthand) {
8481
// Use shorthand
8582
return
8683
}
8784
reportForAlways(node)
8885
} else {
89-
if (node.key.name.range![1] < expression.range![0]) {
86+
if (!node.shorthand) {
9087
// Use longform
9188
return
9289
}

0 commit comments

Comments
 (0)