Skip to content

Bug: [indent] Maximum call stack size exceeded #11455

@IronGeek

Description

@IronGeek

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.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.9.2&fileType=.tsx&code=MYewdgzgLgBAZiEMC8MAUBKFA%2BdAoGGAHmwMOIBMBLANxgHpTzLaGnjG8MBuIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQJYDsATRfAF3TAG1JFpoB7aSAGjACYBdcMAXxB6A&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

const foo = () => (
  <>
    <div />
    <div />
  </>
);

ESLint Config

module.exports = {
  "rules": {
    "indent": ["error", 2]
  }
}

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

Should not resulted in RangeError: Maximum call stack size exceeded

Actual Result

RangeError: Maximum call stack size exceeded
    at Map.get (<anonymous>)
    at s.getFirstTokenOfLine (https://typescript-eslint.io/sandbox/index.js:1:876916)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878206)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878173)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878173)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878173)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878173)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878173)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878173)
    at a.getDesiredIndent (https://typescript-eslint.io/sandbox/index.js:1:878173) 1:1 - 6:3

Additional Info

I know this error happen with @stylistic/indent or the deprecated indent rule.
But the origin of the error seems to be from @typescript-eslint/parser with typescript@5.9.* (it works fine with typescript@5.8.3).

Not sure if it should be fixed here or at ESLint Stylistic, but the ESLint Stylistic thinks this is an upstream issue.
From the ESLint Stylistic issue thread on eslint-stylistic/eslint-stylistic#915 :

@ota-meshi:
It seems that the tokens returned by @typescript-eslint/parser differ depending on the TypeScript version.
In TypeScript 5.8, </> returns three tokens: <, /, and >,
but in TypeScript 5.9, </> returns two tokens: </ and >.
The standard ESLint parser returns three tokens. Therefore, I think this is a problem with @typescript-eslint/parser.


FWIW, I tested the same rule configuration without TypeScript ESLint ESLint with Stylistic and it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions