-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
Hello, prefer-readonly-parameter-types
rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything.
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
// .eslintrc.js
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/prefer-readonly-parameter-types": "error",
},
};
// tsconfig.json
{
"compilerOptions": {
"target": "es6",
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"forceConsistentCasingInFileNames": true,
"lib": ["esnext", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
},
"include": ["./index.ts"]
}
Use case is not identical with crash report from oaf-project/oaf-react-final-form
below but it's enough to reproduce the issue.
This is as minimal as I could narrow the issue down.
Valid typescript according to TS playgound.
type MyType = string | readonly MyType[];
function filterEmpty<A extends MyType[]>(a: A): MyType[] {
return a.filter((value) => {
return Array.isArray(value) && value.length > 0;
});
}
Expected Result
ESLint should not crash.
Actual Result
RangeError: Maximum call stack size exceeded
Occurred while linting /workspaces/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/oaf-project/oaf-react-final-form/src/validation/index.ts:125
at /workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:109:66
at Array.every (<anonymous>)
at isTypeReadonlyRecurser (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:109:55)
at /workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:36:43
at Array.some (<anonymous>)
at checkTypeArguments (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:36:27)
at isTypeReadonlyArrayOrTuple (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:48:16)
at isTypeReadonlyRecurser (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:123:29)
at /workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:109:66
at Array.every (<anonymous>)
Additional Info
Crash reports from real projects
Rule: prefer-readonly-parameter-types
- Message:
Maximum call stack size exceeded Occurred while linting /workspaces/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/oaf-project/oaf-react-final-form/src/validation/index.ts:125
- Path:
oaf-project/oaf-react-final-form/src/validation/index.ts
- Link
RangeError: Maximum call stack size exceeded
Occurred while linting /workspaces/eslint-remote-tester/ci/node_modules/eslint-remote-tester/.cache-eslint-remote-tester/oaf-project/oaf-react-final-form/src/validation/index.ts:125
at /workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:109:66
at Array.every (<anonymous>)
at isTypeReadonlyRecurser (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:109:55)
at /workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:36:43
at Array.some (<anonymous>)
at checkTypeArguments (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:36:27)
at isTypeReadonlyArrayOrTuple (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:48:16)
at isTypeReadonlyRecurser (/workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:123:29)
at /workspaces/eslint-remote-tester/ci/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:109:66
at Array.every (<anonymous>)
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.23.0 |
@typescript-eslint/parser |
4.23.0 |
TypeScript |
4.2.4 |
ESLint |
7.26.0 |
node |
v14.15.1 |
JoshuaKGoldberg
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin