-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: "Invalid string length" caused by allowDefaultProjectForFiles warning #9124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you got an example of the config...? |
The config isn't really going to help much I think. The issue is here https://github.com/typescript-eslint/typescript-eslint/pull/8925/files#diff-b089b5bc90fd2a532136946c025806e6daa02b7deda1f704829d736dfdb4b3c8R86-R98. Essentially it you have a project with 10000 linted files and 1000 incorrectly matching the defaultProjectMatchedFiles, then you end up with 10k x warnings with 1000 file paths which ends up making the whole output too large to serialize, at least with the method eslint uses. Something like the following should mitigate the problem. defaultProjectMatchedFiles.add(filePathAbsolute);
if (defaultProjectMatchedFiles.size > maximumDefaultProjectFileMatchCount) {
const matchedFiles = Array.from(defaultProjectMatchedFiles);
const filePrintLimit = 20;
const filesToPrint = matchedFiles.slice(0, filePrintLimit);
const extraFiles = matchedFiles.length - filesToPrint.length;
throw new Error(
`Too many files (>${maximumDefaultProjectFileMatchCount}) have matched the default project.${DEFAULT_PROJECT_FILES_ERROR_EXPLANATION}
Matching files:
${filesToPrint.map((file) => `- ${file}`).join('\n')}
${extraFiles ? `...and ${extraFiles} more files` : ''}
If you absolutely need more files included, set parserOptions.EXPERIMENTAL_useProjectService.maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING to a larger value.
`,
);
} |
Ha, I can reproduce this. typescript-eslint/examples@f55b9e7:
Agreed that it makes sense to truncate the extra files. 👍 thanks for reporting! |
* fix(typescript-estree): truncate number of files printed Address issue with size of error string produced causing serialization failure typescript-eslint#9124. * test(typescript-estree): add additional unit test for project service Additional test for truncated error message.
I've opened a PR #9127 |
…um file error (#9127) fix(typescript-estree): truncate number of files printed * fix(typescript-estree): truncate number of files printed Address issue with size of error string produced causing serialization failure #9124. * test(typescript-estree): add additional unit test for project service Additional test for truncated error message. Co-authored-by: auvred <[email protected]>
Before You File a Bug Report Please Confirm You Have Done The Following...
Relevant Package
typescript-estree
Playground Link
No response
Repro Code
Can't provide a minimal sample as it requires a large code base
ESLint Config
No response
tsconfig
No response
Expected Result
Warnings but no error
Actual Result
Additional Info
We have not correctly configured
EXPERIMENTAL_useProjectServicea.llowDefaultProjectForFiles
. But because so many files match, and it produces so many instances of the warning, the result no longer serializes and eslint crashes.The warning should probably truncate the message like:
Versions
@typescript-eslint/eslint-plugin
7.9.0
@typescript-eslint/parser
7.9.0
@typescript-eslint/rule-tester
7.9.0
@typescript-eslint/scope-manager
7.9.0
@typescript-eslint/typescript-estree
7.9.0
@typescript-eslint/type-utils
7.9.0
@typescript-eslint/utils
7.9.0
TypeScript
5.4.3
ESLint
8.57.0
node
20.11.1
The text was updated successfully, but these errors were encountered: