Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"debug": "^4.3.1",
"eslint-utils": "^3.0.0",
"sourcemap-codec": "^1.4.8",
"svelte-eslint-parser": "^0.9.0"
"svelte-eslint-parser": "^0.10.0"
},
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0-0",
Expand Down
9 changes: 9 additions & 0 deletions src/rules/indent-helpers/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ export function defineVisitor(context: IndentContext): NodeListener {
const closeToken = sourceCode.getLastToken(node)
offsets.setOffsetElementList(node.identifiers, openToken, closeToken, 1)
},
SvelteConstTag(node: AST.SvelteConstTag) {
const openToken = sourceCode.getFirstToken(node)
const constToken = sourceCode.getTokenAfter(openToken)
const declarationToken = sourceCode.getFirstToken(node.declaration)
const closeToken = sourceCode.getLastToken(node)
offsets.setOffsetToken(constToken, 1, openToken)
offsets.setOffsetToken(declarationToken, 1, openToken)
offsets.setOffsetToken(closeToken, 0, openToken)
},
// ----------------------------------------------------------------------
// BLOCKS
// ----------------------------------------------------------------------
Expand Down
47 changes: 47 additions & 0 deletions tests/fixtures/rules/indent/invalid/const-tag01-errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 8,
"column": 1
},
{
"message": "Expected indentation of 4 spaces but found 0 spaces.",
"line": 9,
"column": 1
},
{
"message": "Expected indentation of 4 spaces but found 0 spaces.",
"line": 10,
"column": 1
},
{
"message": "Expected indentation of 6 spaces but found 0 spaces.",
"line": 11,
"column": 1
},
{
"message": "Expected indentation of 6 spaces but found 0 spaces.",
"line": 12,
"column": 1
},
{
"message": "Expected indentation of 8 spaces but found 0 spaces.",
"line": 13,
"column": 1
},
{
"message": "Expected indentation of 8 spaces but found 0 spaces.",
"line": 14,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 15,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 16,
"column": 1
}
]
17 changes: 17 additions & 0 deletions tests/fixtures/rules/indent/invalid/const-tag01-input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- prettier-ignore -->
<script>
export let boxes;
</script>

<!-- prettier-ignore -->
{#each boxes as box}
{
@const
area
=
box.width
*
box.height
}
{box.width} * {box.height} = {area}
{/each}
17 changes: 17 additions & 0 deletions tests/fixtures/rules/indent/invalid/const-tag01-output.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- prettier-ignore -->
<script>
export let boxes;
</script>

<!-- prettier-ignore -->
{#each boxes as box}
{
@const
area
=
box.width
*
box.height
}
{box.width} * {box.height} = {area}
{/each}
22 changes: 22 additions & 0 deletions tests/fixtures/rules/indent/invalid/deubg-tag01-errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 3,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 4,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 5,
"column": 1
},
{
"message": "Expected indentation of 2 spaces but found 0 spaces.",
"line": 6,
"column": 1
}
]
7 changes: 7 additions & 0 deletions tests/fixtures/rules/indent/invalid/deubg-tag01-input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- prettier-ignore -->
{
@debug
var1
,
var2
}
7 changes: 7 additions & 0 deletions tests/fixtures/rules/indent/invalid/deubg-tag01-output.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- prettier-ignore -->
{
@debug
var1
,
var2
}