From 9a6246622fb6813072edb518adce357575768c89 Mon Sep 17 00:00:00 2001 From: Adnan Hashmi Date: Mon, 24 Oct 2022 09:10:36 +0530 Subject: [PATCH 1/2] docs: Mention wide globs performance implications in monorepos docs and parser readme --- docs/linting/typed-linting/MONOREPOS.md | 26 +++++++++++++++++++++++++ packages/parser/README.md | 2 ++ 2 files changed, 28 insertions(+) diff --git a/docs/linting/typed-linting/MONOREPOS.md b/docs/linting/typed-linting/MONOREPOS.md index 1bb057718c6..b39ac9d239a 100644 --- a/docs/linting/typed-linting/MONOREPOS.md +++ b/docs/linting/typed-linting/MONOREPOS.md @@ -62,6 +62,32 @@ module.exports = { }; ``` +### Wide globs in `parserOptions.project` + +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. + +```js title=".eslintrc.js" +module.exports = { + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + ], + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + // Remove this line + project: ['./tsconfig.eslint.json', './**/tsconfig.json'], + // Add this line + project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'], + }, + plugins: ['@typescript-eslint'], + root: true, +}; +``` + +See [Glob pattern in parser's option "project" slows down linting](https://github.com/typescript-eslint/typescript-eslint/issues/2611) for more details. + ### Important note regarding large (> 10) multi-package monorepos We've had reports that for sufficiently large and/or interdependent projects, you may run into OOMs using this approach. diff --git a/packages/parser/README.md b/packages/parser/README.md index efba4854413..b32ed30beab 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -164,6 +164,8 @@ This option allows you to provide a path to your project's `tsconfig.json`. **Th - 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. +- 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). + - 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. - 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: From 34cbe73c690b208f8b0b12072af867c7931afccf Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 24 Oct 2022 15:14:56 -0400 Subject: [PATCH 2/2] Update docs/linting/typed-linting/MONOREPOS.md --- docs/linting/typed-linting/MONOREPOS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/linting/typed-linting/MONOREPOS.md b/docs/linting/typed-linting/MONOREPOS.md index b39ac9d239a..5163e997ec8 100644 --- a/docs/linting/typed-linting/MONOREPOS.md +++ b/docs/linting/typed-linting/MONOREPOS.md @@ -64,7 +64,8 @@ module.exports = { ### Wide globs in `parserOptions.project` -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. +Using wide globs `**` in your `parserOptions.project` may degrade linting performance. +Instead of globs that use `**` to recursively check all folders, prefer paths that use a single `*` at a time. ```js title=".eslintrc.js" module.exports = {