refactor(core, ts-plugin, codegen): move token name validation from check phase to parse phase - #440
Merged
Conversation
…heck phase to parse phase
🦋 Changeset detectedLatest commit: a71b0fb The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
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.
ref: #377
Token name validation (rejecting
__proto__,defaultwhennamedExports: trueis 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:
parseCSSModulenow 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
vp test.examples/1-basicin an editor and add.__proto__ { color: red; }tosrc/a.module.css. The`__proto__` is not allowed as names.error is still reported.🤖 Generated with Claude Code