sveltejs/eslint-plugin-svelte

Indentation bug when using `svelte/indent` (`RangeError: Maximum call stack size exceeded`)

Open

#998 opened on Jan 7, 2025

 (8 comments) (0 reactions) (0 assignees)TypeScript (72 forks)auto 404
formattinghelp wanted

Repository metrics

Stars
 (400 stars)
PR merge metrics
 (PR metrics pending)

Description

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.17.0

What version of eslint-plugin-svelte are you using?

2.46.1

What did you do?

import { includeIgnoreFile } from '@eslint/compat';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';
const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));

export default ts.config(
  includeIgnoreFile(gitignorePath),
  ...svelte.configs["flat/recommended"],
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node
      }
    }
  },
  {
    files: ["**/*.svelte"],

    languageOptions: {
      parserOptions: {
        parser: ts.parser
      }
    },
  },
  {
    rules: {
      "svelte/indent": ["error", {
        indent: 4,
        indentScript: false
      }]
    }
  }
);

<script lang="ts">
let {}: { } = $props()

const Blocks: {
    [X in "bar"]: string 
} = {}
</script>

What did you expect to happen?

ESLint should not crash

What actually happened?

Oops! Something went wrong! :(

ESLint: 9.17.0

RangeError: Maximum call stack size exceeded
Occurred while linting /Users/albert/repos/svelte-indent-bug/src/routes/+page.svelte:1
Rule: "svelte/indent"
    at Map.get (<anonymous>)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:173:41)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)
    at OffsetCalculator.getExpectedIndentFromIndex (/Users/albert/repos/svelte-indent-bug/node_modules/eslint-plugin-svelte/lib/rules/indent-helpers/offset-context.js:183:33)

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/AlbertMarashi/svelte-indent-bug

Additional comments

No response

Contributor guide