Skip to content

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

@AlbertMarashi

Description

@AlbertMarashi

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?

Configuration
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy