Skip to content

Commit

Permalink
Merge branch 'main' into v8
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed May 26, 2024
2 parents c6cbfe3 + d0d68dc commit 989a80c
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"words": [
"Airbnb",
"Airbnb's",
"ambiently",
"allowdefaultprojectforfiles",
"ambiently",
"Armano",
"astexplorer",
"Astro",
Expand Down Expand Up @@ -90,6 +90,7 @@
"falsiness",
"globby",
"IDE's",
"ignoreconditionaltests",
"IIFE",
"IIFEs",
"jameshenry",
Expand All @@ -99,6 +100,7 @@
"lzstring",
"markdownlint",
"metastring",
"multipass",
"necroing",
"nocheck",
"noninteractive",
Expand Down
14 changes: 10 additions & 4 deletions packages/typescript-estree/src/useProgramFromProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ export function useProgramFromProjectService(
defaultProjectMatchedFiles.add(filePathAbsolute);
}
if (defaultProjectMatchedFiles.size > maximumDefaultProjectFileMatchCount) {
const filePrintLimit = 20;
const filesToPrint = Array.from(defaultProjectMatchedFiles).slice(
0,
filePrintLimit,
);
const truncatedFileCount =
defaultProjectMatchedFiles.size - filesToPrint.length;

throw new Error(
`Too many files (>${maximumDefaultProjectFileMatchCount}) have matched the default project.${DEFAULT_PROJECT_FILES_ERROR_EXPLANATION}
Matching files:
${Array.from(defaultProjectMatchedFiles)
.map(file => `- ${file}`)
.join('\n')}
${filesToPrint.map(file => `- ${file}`).join('\n')}
${truncatedFileCount ? `...and ${truncatedFileCount} more files\n` : ''}
If you absolutely need more files included, set parserOptions.EXPERIMENTAL_useProjectService.maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING to a larger value.
`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,58 @@ Matching files:
- b
- ${path.normalize('/repos/repo/path/PascalCaseDirectory/camelCaseFile.ts')}
If you absolutely need more files included, set parserOptions.EXPERIMENTAL_useProjectService.maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING to a larger value.
`);
});

it('truncates the files printed by the maximum allowed files error when they exceed the print limit', () => {
const { service } = createMockProjectService();
const program = { getSourceFile: jest.fn() };

mockGetProgram.mockReturnValueOnce(program);

service.openClientFile.mockReturnValueOnce({});

expect(() =>
useProgramFromProjectService(
createProjectServiceSettings({
allowDefaultProjectForFiles: [mockParseSettings.filePath],
maximumDefaultProjectFileMatchCount: 2,
service,
}),
mockParseSettings,
true,
new Set(Array.from({ length: 100 }, (_, i) => String(i))),
),
).toThrow(`Too many files (>2) have matched the default project.
Having many files run with the default project is known to cause performance issues and slow down linting.
See https://typescript-eslint.io/troubleshooting/#allowdefaultprojectforfiles-glob-too-wide
Matching files:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
...and 81 more files
If you absolutely need more files included, set parserOptions.EXPERIMENTAL_useProjectService.maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING to a larger value.
`);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
authors:
- image_url: https://www.joshuakgoldberg.com/img/josh.jpg
- image_url: /img/team/joshuakgoldberg.jpg
name: Josh Goldberg
title: typescript-eslint Maintainer
url: https://github.com/JoshuaKGoldberg
Expand Down Expand Up @@ -223,6 +223,6 @@ Thanks Joshua! 🤗

## Supporting typescript-eslint

If you enjoyed this blog post and/or or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
Thanks! 💖
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
authors:
- image_url: https://www.joshuakgoldberg.com/img/josh.jpg
- image_url: /img/team/joshuakgoldberg.jpg
name: Josh Goldberg
title: typescript-eslint Maintainer
url: https://github.com/JoshuaKGoldberg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
authors:
- image_url: https://www.joshuakgoldberg.com/img/josh.jpg
- image_url: /img/team/joshuakgoldberg.jpg
name: Josh Goldberg
title: typescript-eslint Maintainer
url: https://github.com/JoshuaKGoldberg
Expand Down Expand Up @@ -186,6 +186,6 @@ See [our Getting Started docs](/getting-started) for more information on linting

## Supporting typescript-eslint

If you enjoyed this blog post and/or or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
Thanks! 💖
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
authors:
- image_url: https://www.joshuakgoldberg.com/img/josh.jpg
- image_url: /img/team/joshuakgoldberg.jpg
name: Josh Goldberg
title: typescript-eslint Maintainer
url: https://github.com/JoshuaKGoldberg
Expand Down Expand Up @@ -377,6 +377,6 @@ See the [v6.0.0 milestone](https://github.com/typescript-eslint/typescript-eslin
## Supporting typescript-eslint
If you enjoyed this blog post and/or or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
Thanks! 💖
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
authors:
- image_url: https://www.joshuakgoldberg.com/img/josh.jpg
- image_url: /img/team/joshuakgoldberg.jpg
name: Josh Goldberg
title: typescript-eslint Maintainer
url: https://github.com/JoshuaKGoldberg
Expand Down Expand Up @@ -702,6 +702,6 @@ See the [v6.0.0 milestone](https://github.com/typescript-eslint/typescript-eslin

## Supporting typescript-eslint

If you enjoyed this blog post and/or or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
Thanks! 💖
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
authors:
- image_url: https://www.joshuakgoldberg.com/img/josh.jpg
- image_url: /img/team/joshuakgoldberg.jpg
name: Josh Goldberg
title: typescript-eslint Maintainer
url: https://github.com/JoshuaKGoldberg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
authors:
- image_url: https://www.joshuakgoldberg.com/img/josh.jpg
- image_url: /img/team/joshuakgoldberg.jpg
name: Josh Goldberg
title: typescript-eslint Maintainer
url: https://github.com/JoshuaKGoldberg
Expand Down
Loading

0 comments on commit 989a80c

Please sign in to comment.