Skip to content

Commit e1b92c0

Browse files
authored
fix: Support name_loc property (#801)
1 parent 14a5734 commit e1b92c0

File tree

6 files changed

+61
-25
lines changed

6 files changed

+61
-25
lines changed

.changeset/wet-carrots-open.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": patch
3+
---
4+
5+
fix: Support `name_loc` property

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"prettier-plugin-svelte": "^3.4.0",
111111
"rimraf": "^6.0.1",
112112
"semver": "^7.7.2",
113-
"svelte": "^5.41.0",
113+
"svelte": "^5.45.4",
114114
"svelte2tsx": "^0.7.45",
115115
"tsx": "^4.20.5",
116116
"typescript": "~5.9.2",

pnpm-lock.yaml

Lines changed: 30 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser/compat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export function getOptionsFromRoot(
3737
return {
3838
type: "SvelteOptions",
3939
name: "svelte:options",
40+
// @ts-expect-error - name_loc is required in Svelte since 5.45.3 but we can not set it.
41+
name_loc: null,
4042
attributes: root.options.attributes,
4143
fragment: {
4244
type: "Fragment",

src/parser/html.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function parseAttribute(state: State): Compiler.Attribute {
8383
return {
8484
type: "Attribute",
8585
name: key,
86+
name_loc: null,
8687
value: true,
8788
start,
8889
end: keyEnd,
@@ -93,6 +94,7 @@ function parseAttribute(state: State): Compiler.Attribute {
9394
return {
9495
type: "Attribute",
9596
name: key,
97+
name_loc: null,
9698
value: true,
9799
start,
98100
end: keyEnd,
@@ -103,6 +105,7 @@ function parseAttribute(state: State): Compiler.Attribute {
103105
return {
104106
type: "Attribute",
105107
name: key,
108+
name_loc: null,
106109
value: [value],
107110
start,
108111
end: state.index,

tests/src/parser/__snapshots__/html.ts.snap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Object {
1313
Object {
1414
"end": 17,
1515
"name": "lang",
16+
"name_loc": null,
1617
"start": 8,
1718
"type": "Attribute",
1819
"value": Array [
@@ -36,6 +37,7 @@ Object {
3637
Object {
3738
"end": 17,
3839
"name": "lang",
40+
"name_loc": null,
3941
"start": 8,
4042
"type": "Attribute",
4143
"value": Array [
@@ -59,6 +61,7 @@ Object {
5961
Object {
6062
"end": 15,
6163
"name": "lang",
64+
"name_loc": null,
6265
"start": 8,
6366
"type": "Attribute",
6467
"value": Array [
@@ -82,6 +85,7 @@ Object {
8285
Object {
8386
"end": 13,
8487
"name": "global",
88+
"name_loc": null,
8589
"start": 7,
8690
"type": "Attribute",
8791
"value": true,
@@ -97,6 +101,7 @@ Object {
97101
Object {
98102
"end": 13,
99103
"name": "global",
104+
"name_loc": null,
100105
"start": 7,
101106
"type": "Attribute",
102107
"value": true,
@@ -112,6 +117,7 @@ Object {
112117
Object {
113118
"end": 4,
114119
"name": "attr",
120+
"name_loc": null,
115121
"start": 0,
116122
"type": "Attribute",
117123
"value": true,
@@ -127,6 +133,7 @@ Object {
127133
Object {
128134
"end": 4,
129135
"name": "attr",
136+
"name_loc": null,
130137
"start": 0,
131138
"type": "Attribute",
132139
"value": true,
@@ -142,6 +149,7 @@ Object {
142149
Object {
143150
"end": 16,
144151
"name": "attr",
152+
"name_loc": null,
145153
"start": 0,
146154
"type": "Attribute",
147155
"value": Array [
@@ -165,6 +173,7 @@ Object {
165173
Object {
166174
"end": 12,
167175
"name": "attr",
176+
"name_loc": null,
168177
"start": 0,
169178
"type": "Attribute",
170179
"value": Array [
@@ -188,6 +197,7 @@ Object {
188197
Object {
189198
"end": 8,
190199
"name": "empty",
200+
"name_loc": null,
191201
"start": 0,
192202
"type": "Attribute",
193203
"value": Array [
@@ -211,6 +221,7 @@ Object {
211221
Object {
212222
"end": 8,
213223
"name": "empty",
224+
"name_loc": null,
214225
"start": 0,
215226
"type": "Attribute",
216227
"value": Array [
@@ -234,6 +245,7 @@ Object {
234245
Object {
235246
"end": 13,
236247
"name": "expr",
248+
"name_loc": null,
237249
"start": 0,
238250
"type": "Attribute",
239251
"value": Array [
@@ -263,6 +275,7 @@ Object {
263275
Object {
264276
"end": 13,
265277
"name": "expr",
278+
"name_loc": null,
266279
"start": 0,
267280
"type": "Attribute",
268281
"value": Array [
@@ -292,6 +305,7 @@ Object {
292305
Object {
293306
"end": 10,
294307
"name": "expr",
308+
"name_loc": null,
295309
"start": 0,
296310
"type": "Attribute",
297311
"value": Array [
@@ -321,6 +335,7 @@ Object {
321335
Object {
322336
"end": 10,
323337
"name": "expr",
338+
"name_loc": null,
324339
"start": 0,
325340
"type": "Attribute",
326341
"value": Array [
@@ -350,6 +365,7 @@ Object {
350365
Object {
351366
"end": 15,
352367
"name": "expr",
368+
"name_loc": null,
353369
"start": 0,
354370
"type": "Attribute",
355371
"value": Array [
@@ -387,6 +403,7 @@ Object {
387403
Object {
388404
"end": 19,
389405
"name": "expr",
406+
"name_loc": null,
390407
"start": 0,
391408
"type": "Attribute",
392409
"value": Array [
@@ -429,6 +446,7 @@ Object {
429446
Object {
430447
"end": 11,
431448
"name": "expr",
449+
"name_loc": null,
432450
"start": 0,
433451
"type": "Attribute",
434452
"value": Array [
@@ -458,6 +476,7 @@ Object {
458476
Object {
459477
"end": 9,
460478
"name": "quote",
479+
"name_loc": null,
461480
"start": 0,
462481
"type": "Attribute",
463482
"value": Array [
@@ -481,6 +500,7 @@ Object {
481500
Object {
482501
"end": 9,
483502
"name": "quote",
503+
"name_loc": null,
484504
"start": 0,
485505
"type": "Attribute",
486506
"value": Array [

0 commit comments

Comments
 (0)