Repository: sveltejs/eslint-plugin-svelte
Pull request #856 (2024-09-15 18:23:16)

chore: Avoid using deprecated FlatConfig eslint type
This type has been deprecated in eslint, see https://github.com/eslint/eslint/blob/71f37c5bf04afb704232d312cc6c72c957d1c14e/lib/types/index.d.ts#L1306

changeset-bot[bot]: ###  🦋  Changeset detected

Latest commit: 5cdc41dc7a7845d9a9689b997daf4139be38fac1

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name                 | Type  |
| -------------------- | ----- |
| eslint-plugin-svelte | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/KuSh/eslint-plugin-svelte/new/main?filename=.changeset/itchy-phones-bathe.md&value=---%0A%22eslint-plugin-svelte%22%3A%20patch%0A%22docs%22%3A%20patch%0A---%0A%0Achore%3A%20Avoid%20using%20deprecated%20FlatConfig%20eslint%20type%0A)



Patch:
diff --git a/.changeset/warm-eyes-boil.md b/.changeset/warm-eyes-boil.md
new file mode 100644
index 0000000..13adee5
--- /dev/null
+++ b/.changeset/warm-eyes-boil.md
@@ -0,0 +1,5 @@
+---
+'eslint-plugin-svelte': patch
+---
+
+chore: Avoid using deprecated FlatConfig eslint type
diff --git a/docs-svelte-kit/eslint.config.mjs b/docs-svelte-kit/eslint.config.mjs
index 5e336f6..87b510a 100644
--- a/docs-svelte-kit/eslint.config.mjs
+++ b/docs-svelte-kit/eslint.config.mjs
@@ -2,7 +2,7 @@ import * as myPlugin from '@ota-meshi/eslint-plugin';
 import globals from 'globals';
 
 /**
- * @type {import('eslint').Linter.FlatConfig[]}
+ * @type {import('eslint').Linter.Config[]}
  */
 const config = [
 	{
diff --git a/docs-svelte-kit/package.json b/docs-svelte-kit/package.json
index 23890dd..4a8998d 100644
--- a/docs-svelte-kit/package.json
+++ b/docs-svelte-kit/package.json
@@ -36,7 +36,7 @@
     "assert": "^2.1.0",
     "cross-spawn": "^7.0.3",
     "env-cmd": "^10.1.0",
-    "esbuild": "^0.23.0",
+    "esbuild": "^0.24.0",
     "escape-html": "^1.0.3",
     "eslint-plugin-svelte": "workspace:^",
     "eslint-scope": "^8.0.1",
diff --git a/docs-svelte-kit/src/lib/eslint/scripts/linter.js b/docs-svelte-kit/src/lib/eslint/scripts/linter.js
index 01dd446..6f8d920 100644
--- a/docs-svelte-kit/src/lib/eslint/scripts/linter.js
+++ b/docs-svelte-kit/src/lib/eslint/scripts/linter.js
@@ -125,7 +125,7 @@ export function getRule(ruleId) {
 }
 
 /**
- * @returns {import('eslint').Linter.FlatConfig[]}
+ * @returns {import('eslint').Linter.Config[]}
  */
 export function createLinterConfig() {
 	return [
diff --git a/packages/eslint-plugin-svelte/CHANGELOG.md b/packages/eslint-plugin-svelte/CHANGELOG.md
index 4c23cdd..24e92c6 100644
--- a/packages/eslint-plugin-svelte/CHANGELOG.md
+++ b/packages/eslint-plugin-svelte/CHANGELOG.md
@@ -1,5 +1,11 @@
 # eslint-plugin-svelte
 
+## 2.44.1
+
+### Patch Changes
+
+- [#864](https://github.com/sveltejs/eslint-plugin-svelte/pull/864) [`580e48a`](https://github.com/sveltejs/eslint-plugin-svelte/commit/580e48ae0edcfd2cb5dd51863130a9c08b24829e) Thanks [@mikededo](https://github.com/mikededo)! - fix(svelte/indent): ensure proper snippet indent
+
 ## 2.44.0
 
 ### Minor Changes
diff --git a/packages/eslint-plugin-svelte/eslint.config.mjs b/packages/eslint-plugin-svelte/eslint.config.mjs
index bd24893..a85da94 100644
--- a/packages/eslint-plugin-svelte/eslint.config.mjs
+++ b/packages/eslint-plugin-svelte/eslint.config.mjs
@@ -2,7 +2,7 @@ import * as myPlugin from '@ota-meshi/eslint-plugin';
 import * as tseslint from 'typescript-eslint';
 
 /**
- * @type {import('eslint').Linter.FlatConfig[]}
+ * @type {import('eslint').Linter.Config[]}
  */
 const config = [
 	{
diff --git a/packages/eslint-plugin-svelte/package.json b/packages/eslint-plugin-svelte/package.json
index a189adc..0e30290 100644
--- a/packages/eslint-plugin-svelte/package.json
+++ b/packages/eslint-plugin-svelte/package.json
@@ -1,6 +1,6 @@
 {
   "name": "eslint-plugin-svelte",
-  "version": "2.44.0",
+  "version": "2.44.1",
   "description": "ESLint plugin for Svelte using AST",
   "repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git",
   "homepage": "https://sveltejs.github.io/eslint-plugin-svelte",
@@ -85,7 +85,7 @@
     "@types/stylus": "^0.48.42",
     "acorn": "^8.12.1",
     "assert": "^2.1.0",
-    "esbuild": "^0.23.1",
+    "esbuild": "^0.24.0",
     "esbuild-register": "^3.6.0",
     "eslint-scope": "^8.0.2",
     "eslint-typegen": "^0.3.2",
@@ -98,7 +98,7 @@
     "sass": "^1.78.0",
     "source-map-js": "^1.2.1",
     "stylus": "^0.63.0",
-    "svelte": "5.0.0-next.246",
+    "svelte": "5.0.0-next.249",
     "svelte-i18n": "^4.0.0",
     "type-coverage": "^2.29.1",
     "yaml": "^2.5.1"
diff --git a/packages/eslint-plugin-svelte/src/configs/flat/all.ts b/packages/eslint-plugin-svelte/src/configs/flat/all.ts
index da7addd..8f179ed 100644
--- a/packages/eslint-plugin-svelte/src/configs/flat/all.ts
+++ b/packages/eslint-plugin-svelte/src/configs/flat/all.ts
@@ -1,7 +1,7 @@
 import type { Linter } from 'eslint';
 import { rules } from '../../utils/rules';
 import base from './base';
-const config: Linter.FlatConfig[] = [
+const config: Linter.Config[] = [
 	...base,
 	{
 		name: 'svelte:all:rules',
diff --git a/packages/eslint-plugin-svelte/src/meta.ts b/packages/eslint-plugin-svelte/src/meta.ts
index 789ad94..cd2d4e6 100644
--- a/packages/eslint-plugin-svelte/src/meta.ts
+++ b/packages/eslint-plugin-svelte/src/meta.ts
@@ -2,4 +2,4 @@
 // This file has been automatically generated,
 // in order to update its content execute "pnpm run update"
 export const name = 'eslint-plugin-svelte';
-export const version = '2.44.0';
+export const version = '2.44.1';
diff --git a/packages/eslint-plugin-svelte/src/rules/indent-helpers/svelte.ts b/packages/eslint-plugin-svelte/src/rules/indent-helpers/svelte.ts
index f84e74d..29f9a75 100644
--- a/packages/eslint-plugin-svelte/src/rules/indent-helpers/svelte.ts
+++ b/packages/eslint-plugin-svelte/src/rules/indent-helpers/svelte.ts
@@ -457,15 +457,12 @@ export function defineVisitor(context: IndentContext): NodeListener {
 				offsets.setOffsetToken(token, 1, openToken);
 			}
 
-			const [openCloseTagToken, endAwaitToken, closeCloseTagToken] = sourceCode.getLastTokens(
-				node,
-				{
-					count: 3,
-					includeComments: false
-				}
-			);
+			const [openCloseTagToken, endKeyToken, closeCloseTagToken] = sourceCode.getLastTokens(node, {
+				count: 3,
+				includeComments: false
+			});
 			offsets.setOffsetToken(openCloseTagToken, 0, openToken);
-			offsets.setOffsetToken(endAwaitToken, 1, openCloseTagToken);
+			offsets.setOffsetToken(endKeyToken, 1, openCloseTagToken);
 			offsets.setOffsetToken(closeCloseTagToken, 0, openCloseTagToken);
 		},
 		SvelteSnippetBlock(node: AST.SvelteSnippetBlock) {
@@ -474,8 +471,8 @@ export function defineVisitor(context: IndentContext): NodeListener {
 				includeComments: false
 			});
 			offsets.setOffsetToken(snippetToken, 1, openToken);
-			const id = getFirstAndLastTokens(sourceCode, node.id);
-			offsets.setOffsetToken(id.firstToken, 1, snippetToken);
+			const snippetName = sourceCode.getTokenAfter(snippetToken)!;
+			offsets.setOffsetToken(snippetName, 1, snippetToken);
 
 			const leftParenToken = sourceCode.getTokenBefore(
 				node.params[0] || sourceCode.getLastToken(node),
@@ -492,8 +489,27 @@ export function defineVisitor(context: IndentContext): NodeListener {
 					includeComments: false
 				}
 			)!;
-			offsets.setOffsetToken(leftParenToken, 1, id.firstToken);
+			offsets.setOffsetToken(leftParenToken, 1, snippetName);
 			offsets.setOffsetElementList(node.params, leftParenToken, rightParenToken, 1);
+
+			const closeOpenTagToken = sourceCode.getTokenAfter(rightParenToken)!;
+			offsets.setOffsetToken(closeOpenTagToken, 0, openToken);
+
+			for (const child of node.children) {
+				const token = sourceCode.getFirstToken(child, {
+					includeComments: false,
+					filter: isNotWhitespace
+				});
+				offsets.setOffsetToken(token, 1, openToken);
+			}
+
+			const [openCloseTagToken, endSnippetToken, closeCloseTagToken] = sourceCode.getLastTokens(
+				node,
+				{ count: 3, includeComments: false }
+			);
+			offsets.setOffsetToken(openCloseTagToken, 0, openToken);
+			offsets.setOffsetToken(endSnippetToken, 1, openCloseTagToken);
+			offsets.setOffsetToken(closeCloseTagToken, 0, openCloseTagToken);
 		},
 		// ----------------------------------------------------------------------
 		// COMMENTS


Test patch:
diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-errors.yaml b/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-errors.yaml
index 0e010e0..ac83cef 100644
--- a/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-errors.yaml
+++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-errors.yaml
@@ -38,3 +38,63 @@
   line: 15
   column: 1
   suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 18
+  column: 1
+  suggestions: null
+- message: Expected indentation of 4 spaces but found 0 spaces.
+  line: 19
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 20
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 22
+  column: 1
+  suggestions: null
+- message: Expected indentation of 4 spaces but found 2 spaces.
+  line: 23
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 24
+  column: 1
+  suggestions: null
+- message: Expected indentation of 4 spaces but found 0 spaces.
+  line: 25
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 26
+  column: 1
+  suggestions: null
+- message: Expected indentation of 4 spaces but found 0 spaces.
+  line: 27
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 28
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 31
+  column: 1
+  suggestions: null
+- message: Expected indentation of 4 spaces but found 0 spaces.
+  line: 32
+  column: 1
+  suggestions: null
+- message: Expected indentation of 4 spaces but found 0 spaces.
+  line: 34
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 36
+  column: 1
+  suggestions: null
+- message: Expected indentation of 2 spaces but found 0 spaces.
+  line: 38
+  column: 1
+  suggestions: null
diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-input.svelte b/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-input.svelte
index e86807d..6bec73e 100644
--- a/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-input.svelte
+++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-input.svelte
@@ -14,3 +14,26 @@ a
 }
 )
 }
+<div>
+{#snippet example()}
+<div></div>
+{/snippet}
+
+{
+  #snippet example_2()
+}
+<div></div>
+{
+/snippet
+}
+</div>
+{
+#snippet example_3
+(
+
+)
+}
+<div></div>
+{
+/snippet
+}
diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-output.svelte b/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-output.svelte
index e07895e..221a81d 100644
--- a/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-output.svelte
+++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/indent/invalid/snippets01-output.svelte
@@ -14,3 +14,26 @@
     }
   )
 }
+<div>
+  {#snippet example()}
+    <div></div>
+  {/snippet}
+
+  {
+    #snippet example_2()
+  }
+    <div></div>
+  {
+    /snippet
+  }
+</div>
+{
+  #snippet example_3
+    (
+
+    )
+}
+  <div></div>
+{
+  /snippet
+}