You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
@@ -335,17 +335,21 @@ The behavior of `parserOptions.projectService` can be customized by setting it t
parserOptions: {
projectService: {
allowDefaultProject: ['*.js'],
defaultProject: 'tsconfig.json',
},
},
};
```
:::tip
See [Troubleshooting & FAQs > Typed Linting > Project Service Issues](../troubleshooting/typed-linting/index.mdx#project-service-issues) for help using these options.
:::
##### `allowDefaultProject`
> Default `[]` _(none)_
Globs of files to allow running with the default project compiler options despite not being matched by the project service.
It takes in an array of string paths that will be resolved relative to the [`tsconfigRootDir`](#tsconfigrootdir).
When set, [`projectService.defaultProject`](#defaultproject) must be set as well.
This is intended to produce type information for config files such as `eslint.config.js` that aren't included in their sibling `tsconfig.json`.
Every file with type information retrieved from the default project incurs a non-trivial performance overhead to linting.
Expand All
@@ -358,10 +362,12 @@ There are several restrictions on this option to prevent it from being overused:
##### `defaultProject`
> Default `'tsconfig.json'`
Path to a TSConfig to use instead of TypeScript's default project configuration.
It takes in a string path that will be resolved relative to the [`tsconfigRootDir`](#tsconfigrootdir).
This is required to specify which TSConfig file on disk will be used for [`projectService.allowDefaultProject`](#allowdefaultproject).
`projectService.defaultProject` only impacts the "out-of-project" files included by [`allowDefaultProject`](#allowdefaultproject).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others.Learn more.
parse.project-true.test.ts never really needed to be tested with the project service on anyway. Otherwise:
Could not read project service default project 'tsconfig.json': error TS5012: Cannot read file 'tsconfig.json': ENOENT: no such file or directory, open '/Users/josh/repos/typescript-eslint/packages/typescript-estree/tests/fixtures/projectTrue/tsconfig.json'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others.Learn more.
Without this absolute checking:
A fatal parsing error occurred: Parsing error: Could not read project service default project 'tsconfig.json': error TS5012: Cannot read file '/home/runner/work/typescript-eslint/typescript-eslint/packages/eslint-plugin-internal/tests/fixtures/tsconfig.build.json': ENOENT: no such file or directory, open '/home/runner/work/typescript-eslint/typescript-eslint/packages/eslint-plugin-internal/tests/fixtures/tsconfig.build.json'.
Thattsconfig.build.json comes frompackages/typescript-estree/tsconfig.json. The test was reading with cwdpackages/typescript-estree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
throw new Error('tsconfig.json(1,1): error TS1234: Oh no!');
});
expect(() =>
createProjectService(
{
allowDefaultProject: ['file.js'],
},
undefined,
undefined,
),
).toThrow(
/Could not read project service default project 'tsconfig.json': .+ error TS1234: Oh no!/,
);
});
it('throws an error with a relative path when options.defaultProject is set to a relative path and getParsedConfigFile throws a diagnostic error', () => {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
if (process.env.TYPESCRIPT_ESLINT_PROJECT_SERVICE !== 'true') {
it('throws an error when a parent project does not exist', () => {
expect(() =>
parser.parseAndGenerateServices('const a = true', {
...config,
filePath: join(PROJECT_DIR, 'notIncluded.ts'),
}),
).toThrow(
/project was set to `true` but couldn't find any tsconfig.json relative to '.+[/\\]tests[/\\]fixtures[/\\]projectTrue[/\\]notIncluded.ts' within '.+[/\\]tests[/\\]fixtures[/\\]projectTrue'./,
);
});
}
it('throws an error when a parent project does not exist', () => {
expect(() =>
parser.parseAndGenerateServices('const a = true', {
...config,
filePath: join(PROJECT_DIR, 'notIncluded.ts'),
}),
).toThrow(
/project was set to `true` but couldn't find any tsconfig.json relative to '.+[/\\]tests[/\\]fixtures[/\\]projectTrue[/\\]notIncluded.ts' within '.+[/\\]tests[/\\]fixtures[/\\]projectTrue'./,
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.