-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(parser): error when both projectService and project are set
#11333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JoshuaKGoldberg
merged 12 commits into
typescript-eslint:main
from
MariaSolOs:parser-config
Nov 10, 2025
+279
−761
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c2c6ca1
fix(parser): error when both `projectService` and `project` are set
MariaSolOs 4e59034
Merge branch 'main' into parser-config
JoshuaKGoldberg 36ad58e
more env stubbing in semanticInfo.test.ts
JoshuaKGoldberg ee850a0
Consolidated typed testing and env checks with getTypedRuleTester
JoshuaKGoldberg 765e45d
More fixes, for now
JoshuaKGoldberg ce8dc01
Progress
JoshuaKGoldberg 74ee1da
More.
JoshuaKGoldberg 17ab4ee
Move the defaulting logic into createRuleTesterWithTypes
JoshuaKGoldberg e084a3b
Further streamlining
JoshuaKGoldberg c76cc0c
Streamlined inside createRuleTesterWithTypes
JoshuaKGoldberg 8363f90
Fall back to project: true
JoshuaKGoldberg dba0656
Merge branch 'main'
JoshuaKGoldberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,37 @@ | ||
| import type { ParserOptions } from '@typescript-eslint/utils/ts-eslint'; | ||
|
|
||
| import { RuleTester } from '@typescript-eslint/rule-tester'; | ||
| import * as path from 'node:path'; | ||
|
|
||
| export function createRuleTesterWithTypes( | ||
| providedParserOptions: ParserOptions | undefined = {}, | ||
| ): RuleTester { | ||
| const parserOptions = { | ||
| ...providedParserOptions, | ||
| tsconfigRootDir: | ||
| providedParserOptions.tsconfigRootDir ?? getFixturesRootDir(), | ||
| }; | ||
|
|
||
| // If the test has requested a specific project, disable projectService | ||
| // (regardless of whether it's being switched to by TYPESCRIPT_ESLINT_PROJECT_SERVICE) | ||
| if (parserOptions.project) { | ||
| parserOptions.projectService = false; | ||
| } | ||
| // Otherwise, use the project service for types if requested in the env | ||
| else if (process.env.TYPESCRIPT_ESLINT_PROJECT_SERVICE) { | ||
| parserOptions.projectService = true; | ||
| } | ||
| // Finally, default to project: true as the standard (legacy) behavior | ||
| // See: https://github.com/typescript-eslint/typescript-eslint/issues/11676 | ||
| else { | ||
| parserOptions.project = true; | ||
| } | ||
|
Comment on lines
+24
to
+28
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Linking #11676 here so we don't forget: if & when we remove |
||
|
|
||
| return new RuleTester({ | ||
| languageOptions: { parserOptions }, | ||
| }); | ||
| } | ||
|
|
||
| export function getFixturesRootDir(): string { | ||
| return path.join(__dirname, 'fixtures'); | ||
| } | ||
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
14 changes: 2 additions & 12 deletions
14
packages/eslint-plugin/tests/rules/consistent-return.test.ts
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
15 changes: 4 additions & 11 deletions
15
packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts
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
15 changes: 3 additions & 12 deletions
15
packages/eslint-plugin/tests/rules/no-array-delete.test.ts
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
14 changes: 3 additions & 11 deletions
14
packages/eslint-plugin/tests/rules/no-confusing-void-expression.test.ts
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
15 changes: 2 additions & 13 deletions
15
packages/eslint-plugin/tests/rules/no-duplicate-type-constituents.test.ts
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
15 changes: 2 additions & 13 deletions
15
packages/eslint-plugin/tests/rules/no-dynamic-delete.test.ts
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
13 changes: 2 additions & 11 deletions
13
packages/eslint-plugin/tests/rules/no-floating-promises.test.ts
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
13 changes: 3 additions & 10 deletions
13
packages/eslint-plugin/tests/rules/no-for-in-array.test.ts
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is the right way to fix the tests in files that just use the
RuleTester.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good question. Ideally we wouldn't have to do anything in the plugin tests themselves. I'm poking around...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, yes, this is the right way.
Recapping for posterity: it's not apparent from the naming (sigh) but the
TYPESCRIPT_ESLINT_PROJECT_SERVICEenv variable's purpose isn't purely to enableprojectService. It's to switchprojecttoprojectServiceifprojectis enabled. But it doesn't apply whenproject: falseis present.