Skip to content

Commit c98a748

Browse files
authored
Support for svelte v3.46 syntax (#91)
1 parent 28ac444 commit c98a748

File tree

8 files changed

+127
-1
lines changed

8 files changed

+127
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"debug": "^4.3.1",
5757
"eslint-utils": "^3.0.0",
5858
"sourcemap-codec": "^1.4.8",
59-
"svelte-eslint-parser": "^0.9.0"
59+
"svelte-eslint-parser": "^0.10.0"
6060
},
6161
"peerDependencies": {
6262
"eslint": "^7.0.0 || ^8.0.0-0",

src/rules/indent-helpers/svelte.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ export function defineVisitor(context: IndentContext): NodeListener {
206206
const closeToken = sourceCode.getLastToken(node)
207207
offsets.setOffsetElementList(node.identifiers, openToken, closeToken, 1)
208208
},
209+
SvelteConstTag(node: AST.SvelteConstTag) {
210+
const openToken = sourceCode.getFirstToken(node)
211+
const constToken = sourceCode.getTokenAfter(openToken)
212+
const declarationToken = sourceCode.getFirstToken(node.declaration)
213+
const closeToken = sourceCode.getLastToken(node)
214+
offsets.setOffsetToken(constToken, 1, openToken)
215+
offsets.setOffsetToken(declarationToken, 1, openToken)
216+
offsets.setOffsetToken(closeToken, 0, openToken)
217+
},
209218
// ----------------------------------------------------------------------
210219
// BLOCKS
211220
// ----------------------------------------------------------------------
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[
2+
{
3+
"message": "Expected indentation of 2 spaces but found 0 spaces.",
4+
"line": 8,
5+
"column": 1
6+
},
7+
{
8+
"message": "Expected indentation of 4 spaces but found 0 spaces.",
9+
"line": 9,
10+
"column": 1
11+
},
12+
{
13+
"message": "Expected indentation of 4 spaces but found 0 spaces.",
14+
"line": 10,
15+
"column": 1
16+
},
17+
{
18+
"message": "Expected indentation of 6 spaces but found 0 spaces.",
19+
"line": 11,
20+
"column": 1
21+
},
22+
{
23+
"message": "Expected indentation of 6 spaces but found 0 spaces.",
24+
"line": 12,
25+
"column": 1
26+
},
27+
{
28+
"message": "Expected indentation of 8 spaces but found 0 spaces.",
29+
"line": 13,
30+
"column": 1
31+
},
32+
{
33+
"message": "Expected indentation of 8 spaces but found 0 spaces.",
34+
"line": 14,
35+
"column": 1
36+
},
37+
{
38+
"message": "Expected indentation of 2 spaces but found 0 spaces.",
39+
"line": 15,
40+
"column": 1
41+
},
42+
{
43+
"message": "Expected indentation of 2 spaces but found 0 spaces.",
44+
"line": 16,
45+
"column": 1
46+
}
47+
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- prettier-ignore -->
2+
<script>
3+
export let boxes;
4+
</script>
5+
6+
<!-- prettier-ignore -->
7+
{#each boxes as box}
8+
{
9+
@const
10+
area
11+
=
12+
box.width
13+
*
14+
box.height
15+
}
16+
{box.width} * {box.height} = {area}
17+
{/each}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- prettier-ignore -->
2+
<script>
3+
export let boxes;
4+
</script>
5+
6+
<!-- prettier-ignore -->
7+
{#each boxes as box}
8+
{
9+
@const
10+
area
11+
=
12+
box.width
13+
*
14+
box.height
15+
}
16+
{box.width} * {box.height} = {area}
17+
{/each}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"message": "Expected indentation of 2 spaces but found 0 spaces.",
4+
"line": 3,
5+
"column": 1
6+
},
7+
{
8+
"message": "Expected indentation of 2 spaces but found 0 spaces.",
9+
"line": 4,
10+
"column": 1
11+
},
12+
{
13+
"message": "Expected indentation of 2 spaces but found 0 spaces.",
14+
"line": 5,
15+
"column": 1
16+
},
17+
{
18+
"message": "Expected indentation of 2 spaces but found 0 spaces.",
19+
"line": 6,
20+
"column": 1
21+
}
22+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- prettier-ignore -->
2+
{
3+
@debug
4+
var1
5+
,
6+
var2
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- prettier-ignore -->
2+
{
3+
@debug
4+
var1
5+
,
6+
var2
7+
}

0 commit comments

Comments
 (0)