diff --git a/docs/architecture/Parser.mdx b/docs/architecture/Parser.mdx index 45d67306e95..212b7dccde6 100644 --- a/docs/architecture/Parser.mdx +++ b/docs/architecture/Parser.mdx @@ -42,7 +42,7 @@ interface ParserOptions { lib?: string[]; moduleResolver?: string; program?: import('typescript').Program; - project?: string | string[] | true; + project?: string[] | true; projectFolderIgnoreList?: string[]; tsconfigRootDir?: string; warnOnUnsupportedTypeScriptVersion?: boolean; @@ -192,7 +192,7 @@ This option allows you to provide a path to your project's `tsconfig.json`. **Th - If `true`, each source file's parse will find the nearest `tsconfig.json` file to that source file. - - This is done by checking that source file's directory for a `tsconfig.json`, then the parent's directory for a `tsconfig.json`, and so on - until one is found or the current working directory is passed. + - This is done by checking that source file's directory tree for the nearest `tsconfig.json`. - 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. diff --git a/docs/linting/Typed_Linting.md b/docs/linting/Typed_Linting.md index 75a6b921a1e..4af1249cb86 100644 --- a/docs/linting/Typed_Linting.md +++ b/docs/linting/Typed_Linting.md @@ -42,7 +42,7 @@ You may see new rules reporting errors based on type information! The `parserOptions.project` option can be turned on with either: - `true`: to always use `tsconfig.json`s nearest to source files -- `string | string[]`: any number of glob paths to match TSConfig files relative to the +- `string[]`: any number of glob paths to match TSConfig files relative to the For example, if you use a specific `tsconfig.eslint.json` for linting, you'd specify: @@ -50,7 +50,7 @@ For example, if you use a specific `tsconfig.eslint.json` for linting, you'd spe module.exports = { // ... parserOptions: { - project: './tsconfig.eslint.json', + project: ['./tsconfig.eslint.json'], }, // ... }; diff --git a/packages/typescript-estree/src/parseSettings/getProjectConfigFiles.ts b/packages/typescript-estree/src/parseSettings/getProjectConfigFiles.ts index 853de7763b1..65ae5d6c61a 100644 --- a/packages/typescript-estree/src/parseSettings/getProjectConfigFiles.ts +++ b/packages/typescript-estree/src/parseSettings/getProjectConfigFiles.ts @@ -6,7 +6,7 @@ import type { ParseSettings } from '.'; const log = debug('typescript-eslint:typescript-estree:getProjectConfigFiles'); -const tsconfigMatchCache = new Map(); +const TSCONFIG_MATCH_CACHE = new Map(); /** * @remarks Only use this for tests! @@ -29,7 +29,7 @@ export function getProjectConfigFiles( project: string | string[] | true | undefined, ): string | string[] | undefined { if (project !== true) { - return project; + return Array.isArray(project) ? project : [project]; } log('Looking for tsconfig.json at or above file: %s', parseSettings.filePath);