From fcf3f9da6595f8cda843e8adbfdf466c52dd7d08 Mon Sep 17 00:00:00 2001 From: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com> Date: Wed, 26 Oct 2022 05:05:35 +0530 Subject: [PATCH] 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 --- docs/linting/typed-linting/MONOREPOS.md | 27 +++++++++++++++++++++++++ packages/parser/README.md | 2 ++ 2 files changed, 29 insertions(+) diff --git a/docs/linting/typed-linting/MONOREPOS.md b/docs/linting/typed-linting/MONOREPOS.md index 1bb057718c6..5163e997ec8 100644 --- a/docs/linting/typed-linting/MONOREPOS.md +++ b/docs/linting/typed-linting/MONOREPOS.md @@ -62,6 +62,33 @@ module.exports = { }; ``` +### Wide globs in `parserOptions.project` + +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 = { + 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: