Skip to content

Commit c21b54c

Browse files
authored
fix: incorrect location for { #await expr then v } with spaces (#438)
1 parent 3dfc12e commit c21b54c

File tree

6 files changed

+17165
-2
lines changed

6 files changed

+17165
-2
lines changed

.changeset/tasty-ants-ring.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": patch
3+
---
4+
5+
fix: incorrect location for `{ #await expr then v }` with spaces

src/parser/converts/block.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export function convertAwaitBlock(
286286
(awaitBlock as SvelteAwaitBlockAwaitThen).kind = "await-then";
287287
}
288288

289-
const thenStart = awaitBlock.pending ? node.then.start : node.start;
289+
const thenStart = awaitBlock.pending ? node.then.start : nodeStart;
290290
const thenBlock: SvelteAwaitThenBlock = {
291291
type: "SvelteAwaitThenBlock",
292292
awaitThen,
@@ -374,7 +374,7 @@ export function convertAwaitBlock(
374374
(awaitBlock as SvelteAwaitBlockAwaitCatch).kind = "await-catch";
375375
}
376376
const catchStart =
377-
awaitBlock.pending || awaitBlock.then ? node.catch.start : node.start;
377+
awaitBlock.pending || awaitBlock.then ? node.catch.start : nodeStart;
378378
const catchBlock = {
379379
type: "SvelteAwaitCatchBlock",
380380
awaitCatch,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<script>
2+
const foo = 'foo';
3+
let text = '';
4+
let value = '';
5+
let input;
6+
const myClass = 'my-class';
7+
const id = 'id';
8+
const attrs = {};
9+
const bar = '<div></div>';
10+
const o1 = 1,
11+
o2 = 2;
12+
const expression = true;
13+
const list = [];
14+
</script>
15+
16+
<!-- prettier-ignore -->
17+
<div>
18+
{ foo }
19+
<input bind:value={ text } this={ input } class="foo { myClass }" />
20+
<input bind:value { id } />
21+
<input { ...attrs } />
22+
{ @html bar }
23+
{ @debug o1 }
24+
{ @debug o1, o2 }
25+
26+
{ #if expression }...{ /if }
27+
{ #if expression }...{ :else if expression }...{ /if }
28+
{ #if expression }...{ :else }...{ /if }
29+
{ #if expression }{ :else }{ /if }
30+
31+
{ #each list as item }...{ /each }
32+
{ #each list as item, index }...{ /each }
33+
{ #each list as item (item.key) }...{ /each }
34+
{ #each list as item, index (item.key) }...{ /each }
35+
{ #each list as item }...{ :else }...{ /each }
36+
37+
{ #await expression }...{ :then name }...{ :catch name }...{ /await }
38+
{ #await expression }...{ :then name }...{ /await }
39+
{ #await expression then name }...{ /await }
40+
{ #await expression catch name }...{ /await }
41+
{ #await expression then }...{ /await }
42+
{ #await expression catch }...{ /await }
43+
{ #await expression }...{ :then}...{ :catch}...{ /await }
44+
45+
{ #key expression }...{ /key }
46+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[
2+
{
3+
"ruleId": "no-unused-vars",
4+
"code": "item",
5+
"line": 31,
6+
"column": 17
7+
},
8+
{
9+
"ruleId": "no-unused-vars",
10+
"code": "item",
11+
"line": 32,
12+
"column": 17
13+
},
14+
{
15+
"ruleId": "no-unused-vars",
16+
"code": "index",
17+
"line": 32,
18+
"column": 23
19+
},
20+
{
21+
"ruleId": "no-unused-vars",
22+
"code": "index",
23+
"line": 34,
24+
"column": 23
25+
},
26+
{
27+
"ruleId": "no-unused-vars",
28+
"code": "item",
29+
"line": 35,
30+
"column": 17
31+
},
32+
{
33+
"ruleId": "no-unused-vars",
34+
"code": "name",
35+
"line": 37,
36+
"column": 33
37+
},
38+
{
39+
"ruleId": "no-unused-vars",
40+
"code": "name",
41+
"line": 37,
42+
"column": 51
43+
},
44+
{
45+
"ruleId": "no-unused-vars",
46+
"code": "name",
47+
"line": 38,
48+
"column": 33
49+
},
50+
{
51+
"ruleId": "no-unused-vars",
52+
"code": "name",
53+
"line": 39,
54+
"column": 26
55+
},
56+
{
57+
"ruleId": "no-unused-vars",
58+
"code": "name",
59+
"line": 40,
60+
"column": 27
61+
}
62+
]

0 commit comments

Comments
 (0)