Skip to content

fix: strip type-aware parserOptions during key collection#713

Open
xanf wants to merge 1 commit into
intlify:masterfrom
xanf:fix/strip-project-true-from-parser-options
Open

fix: strip type-aware parserOptions during key collection#713
xanf wants to merge 1 commit into
intlify:masterfrom
xanf:fix/strip-project-true-from-parser-options

Conversation

@xanf
Copy link
Copy Markdown

@xanf xanf commented Feb 26, 2026

Summary

Fixes #711

When project: true (or programs / projectService) is set in parserOptions, the TypeScript parser attempts type-aware linting which requires a valid tsconfig.json resolution context. During the plugin's internal key-collection reparse (used by no-unused-keys and friends to scan source files for used i18n keys), this context doesn't exist, so parsing fails silently — causing all i18n keys from .vue / .ts files to be lost and every locale key to be reported as unused.

Changes

  • lib/utils/parser-config-resolver/parse-by-parser.ts: Added stripTypeAwareOptions() that removes project, programs, and projectService from parserOptions (including nested parserOptions for 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.
  • Test fixture (tests/fixtures/no-unused-keys/invalid/typescript-with-project-true/): Minimal reproduction with project: true in the flat eslint config.
  • Test case in tests/lib/rules/no-unused-keys.ts: Verifies the fixture produces only the expected 3 unused-key errors (not 7+).

…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
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 26, 2026

⚠️ No Changeset found

Latest commit: ec6ac13

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!

typeof rest.parserOptions === 'object' &&
!Array.isArray(rest.parserOptions)
) {
rest.parserOptions = stripTypeAwareOptions(rest.parserOptions)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this recursively?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom parser error with project: true

2 participants