Skip to content

Improve non-JS identifier error message: Phase 2#222

Merged
mizdra merged 5 commits into
mainfrom
refactor
Aug 6, 2025
Merged

Improve non-JS identifier error message: Phase 2#222
mizdra merged 5 commits into
mainfrom
refactor

Conversation

@mizdra
Copy link
Copy Markdown
Owner

@mizdra mizdra commented Aug 4, 2025

follow-up: #220

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Aug 4, 2025

🦋 Changeset detected

Latest commit: 1000693

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

This PR includes changesets to release 5 packages
Name Type
@css-modules-kit/core Minor
@css-modules-kit/codegen Patch
@css-modules-kit/ts-plugin Patch
@css-modules-kit/stylelint-plugin Patch
@css-modules-kit/eslint-plugin 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 added the Type: Feature New Feature label Aug 4, 2025
@mizdra mizdra changed the title Improve non-JS identifier error message Refactor "Improve non-JS identifier error message" Aug 4, 2025
@mizdra mizdra changed the title Refactor "Improve non-JS identifier error message" Improve non-JS identifier error message Aug 4, 2025
@mizdra mizdra changed the title Improve non-JS identifier error message Improve non-JS identifier error message: Phase 2 Aug 4, 2025
@mizdra mizdra force-pushed the refactor branch 3 times, most recently from 3bc0ab5 to 8b557be Compare August 4, 2025 16:26
@mizdra mizdra marked this pull request as ready for review August 6, 2025 12:45
@mizdra mizdra requested a review from Copilot August 6, 2025 12:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error handling for non-JavaScript identifiers by moving validation from individual parsers to a centralized location. The validation now happens during semantic checking and type definition generation, providing better error messages and preventing invalid identifiers from being processed.

  • Moves non-JS identifier validation from individual parsers (rule, keyframe, at-value) to the checker and DTS creator
  • Updates error message from "non-JavaScript identifier" to "invalid names as JavaScript identifiers"
  • Consolidates validation logic using a new isValidAsJSIdentifier utility function

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/util.ts Adds isValidAsJSIdentifier utility function to centralize validation logic
packages/core/src/checker.ts Implements validation checks for local tokens and imported values with improved error messages
packages/core/src/dts-creator.ts Filters out invalid identifiers during type definition generation
packages/core/src/parser/*.ts Removes individual validation logic from parsers
packages/ts-plugin/e2e/feature/*.test.ts Updates tests to reflect validation moved from syntactic to semantic phase
packages/core/src/parser/*.test.ts Removes test cases that are no longer applicable

Comment thread packages/core/src/checker.ts
@mizdra mizdra merged commit 15dcba8 into main Aug 6, 2025
10 checks passed
@mizdra mizdra deleted the refactor branch August 6, 2025 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants