fix(preset-wind4): improve regex accuracy#4776
Conversation
✅ Deploy Preview for unocss ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
commit: |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a bug fix in the preset-wind4 package by adding a new raw parsing utility and updating tests to cover additional color key patterns. Key changes include the introduction of new test cases with additional keys, an update to the regex in the parseColor utility to improve numerical parsing, and enhanced logic for merging numeric parts in theme color keys.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/preset-wind4.test.ts | New test cases added to validate additional color keys and their corresponding CSS generation |
| packages-presets/preset-wind4/src/utils/utilities.ts | Updated regex for numerical separation and added fallback logic to merge numeric parts in the theme key |
Comments suppressed due to low confidence (1)
test/preset-wind4.test.ts:283
- [nitpick] The key 'quxx_1' uses an underscore which differs from the kebab-case convention seen in other keys; consider standardizing naming for consistency.
'quxx_1': '#000',
| @@ -159,14 +159,27 @@ export function parseColor(body: string, theme: Theme) { | |||
| } | |||
|
|
|||
| const colors = main | |||
There was a problem hiding this comment.
Consider adding a comment to explain the negative lookahead in this regex, clarifying that it prevents inserting a dash when the digit is immediately followed by a hyphen, underscore, or letter.
| const colors = main | |
| const colors = main | |
| // Add a dash between a letter and a digit, unless the digit is immediately followed by a hyphen, underscore, or letter. |
close #4774