Skip to content

Commit fcf3f9d

Browse files
docs: Mention wide globs performance implications in monorepos docs and parser README (#5864)
* docs: Mention wide globs performance implications in monorepos docs and parser readme * Update docs/linting/typed-linting/MONOREPOS.md Co-authored-by: Josh Goldberg <[email protected]>
1 parent 8794fd3 commit fcf3f9d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

docs/linting/typed-linting/MONOREPOS.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,33 @@ module.exports = {
6262
};
6363
```
6464

65+
### Wide globs in `parserOptions.project`
66+
67+
Using wide globs `**` in your `parserOptions.project` may degrade linting performance.
68+
Instead of globs that use `**` to recursively check all folders, prefer paths that use a single `*` at a time.
69+
70+
```js title=".eslintrc.js"
71+
module.exports = {
72+
extends: [
73+
'eslint:recommended',
74+
'plugin:@typescript-eslint/recommended',
75+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
76+
],
77+
parser: '@typescript-eslint/parser',
78+
parserOptions: {
79+
tsconfigRootDir: __dirname,
80+
// Remove this line
81+
project: ['./tsconfig.eslint.json', './**/tsconfig.json'],
82+
// Add this line
83+
project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'],
84+
},
85+
plugins: ['@typescript-eslint'],
86+
root: true,
87+
};
88+
```
89+
90+
See [Glob pattern in parser's option "project" slows down linting](https://github.com/typescript-eslint/typescript-eslint/issues/2611) for more details.
91+
6592
### Important note regarding large (> 10) multi-package monorepos
6693

6794
We've had reports that for sufficiently large and/or interdependent projects, you may run into OOMs using this approach.

packages/parser/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ This option allows you to provide a path to your project's `tsconfig.json`. **Th
164164

165165
- If you use project references, TypeScript will not automatically use project references to resolve files. This means that you will have to add each referenced tsconfig to the `project` field either separately, or via a glob.
166166

167+
- Note that using wide globs `**` in your `parserOptions.project` may cause performance implications. Instead of globs that use `**` to recursively check all folders, prefer paths that use a single `*` at a time. For more info see [#2611](https://github.com/typescript-eslint/typescript-eslint/issues/2611).
168+
167169
- TypeScript will ignore files with duplicate filenames in the same folder (for example, `src/file.ts` and `src/file.js`). TypeScript purposely ignore all but one of the files, only keeping the one file with the highest priority extension (the extension priority order (from highest to lowest) is `.ts`, `.tsx`, `.d.ts`, `.js`, `.jsx`). For more info see #955.
168170

169171
- Note that if this setting is specified and `createDefaultProgram` is not, you must only lint files that are included in the projects as defined by the provided `tsconfig.json` files. If your existing configuration does not include all of the files you would like to lint, you can create a separate `tsconfig.eslint.json` as follows:

0 commit comments

Comments
 (0)