Skip to content

refactor(core, ts-plugin, codegen): move token name validation from check phase to parse phase - #440

Merged
mizdra merged 1 commit into
mainfrom
refactor-move-token-name-validation-to-parser
Aug 11, 2026
Merged

refactor(core, ts-plugin, codegen): move token name validation from check phase to parse phase#440
mizdra merged 1 commit into
mainfrom
refactor-move-token-name-validation-to-parser

Conversation

@mizdra

@mizdra mizdra commented Aug 11, 2026

Copy link
Copy Markdown
Owner

ref: #377

Token name validation (rejecting __proto__, default when namedExports: true is set, and names containing backslashes) was implemented in the check phase, alongside checks that require resolving other files, such as verifying that an imported token actually exists.

However, this validation only inspects names extracted from a single file and does not depend on any other file, so it is not a semantic check. This PR reclassifies it as a syntactic one: parseCSSModule now validates token names and reports violations as parse diagnostics. The messages and positions of the reported diagnostics are unchanged.

As a supplementary note, this is also groundwork for supporting TypeScript 7's content mappers (microsoft/typescript-go#4712): a content mapper reports diagnostics when parsing a file, so validations that need no cross-file information must run in the parse phase.

How to verify

  • Run vp test.
  • Open examples/1-basic in an editor and add .__proto__ { color: red; } to src/a.module.css. The `__proto__` is not allowed as names. error is still reported.

🤖 Generated with Claude Code

@mizdra mizdra added the Type: Refactoring A code change that neither fixes a bug nor adds a feature label Aug 11, 2026
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a71b0fb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@css-modules-kit/core Patch
@css-modules-kit/ts-plugin Patch
@css-modules-kit/codegen Patch
@css-modules-kit/eslint-plugin Patch
@css-modules-kit/stylelint-plugin Patch
css-modules-kit-vscode Patch

Not sure what this means? Click here to learn what changesets are.

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

@mizdra
mizdra marked this pull request as ready for review August 11, 2026 06:08
@mizdra
mizdra merged commit cc5b46c into main Aug 11, 2026
16 checks passed
@mizdra
mizdra deleted the refactor-move-token-name-validation-to-parser branch August 11, 2026 06:08
@github-actions github-actions Bot mentioned this pull request Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Refactoring A code change that neither fixes a bug nor adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant