fix: strip type-aware parserOptions during key collection#713
Open
xanf wants to merge 1 commit into
Open
Conversation
…e) during key collection When `project: true` is set in parserOptions, the TypeScript parser attempts type-aware linting which requires a valid tsconfig.json context. During the plugin's internal key-collection reparse this context doesn't exist, causing parsing to fail silently and all i18n keys from .vue/.ts files to be lost — making every key appear unused. Fixes intlify#711
|
ota-meshi
reviewed
Feb 28, 2026
| typeof rest.parserOptions === 'object' && | ||
| !Array.isArray(rest.parserOptions) | ||
| ) { | ||
| rest.parserOptions = stripTypeAwareOptions(rest.parserOptions) |
Member
There was a problem hiding this comment.
Why do we need to do this recursively?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #711
When
project: true(orprograms/projectService) is set inparserOptions, the TypeScript parser attempts type-aware linting which requires a validtsconfig.jsonresolution context. During the plugin's internal key-collection reparse (used byno-unused-keysand friends to scan source files for used i18n keys), this context doesn't exist, so parsing fails silently — causing all i18n keys from.vue/.tsfiles to be lost and every locale key to be reported as unused.Changes
lib/utils/parser-config-resolver/parse-by-parser.ts: AddedstripTypeAwareOptions()that removesproject,programs, andprojectServicefromparserOptions(including nestedparserOptionsfor vue-eslint-parser) before the key-collection reparse. These options are only needed for type-checking rules and are irrelevant for AST-based key collection.tests/fixtures/no-unused-keys/invalid/typescript-with-project-true/): Minimal reproduction withproject: truein the flat eslint config.tests/lib/rules/no-unused-keys.ts: Verifies the fixture produces only the expected 3 unused-key errors (not 7+).