Skip to content

fix(noUselessEscapeInString): correctly flag chars#9420

Merged
ematipico merged 1 commit intomainfrom
fix/css-fix-parser
Mar 9, 2026
Merged

fix(noUselessEscapeInString): correctly flag chars#9420
ematipico merged 1 commit intomainfrom
fix/css-fix-parser

Conversation

@ematipico
Copy link
Copy Markdown
Member

Summary

Closes #9385

Test Plan

Added a test and updated the current ones

Docs

N/A

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: 3abcf8a

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

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc 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

@ematipico ematipico requested review from a team March 9, 2026 16:58
@github-actions github-actions Bot added A-Linter Area: linter L-CSS Language: CSS and super languages labels Mar 9, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 9, 2026

Walkthrough

This patch fixes the noUselessEscapeInString rule in the CSS linter, which was incorrectly flagging valid CSS hexadecimal escape sequences as useless. The rule now correctly recognises hex digits (0–9, a–f, A–F) as valid escape sequences within CSS strings. Core logic has been updated to include these hex values alongside existing valid escapes, whilst test cases have been updated to reflect the corrected behaviour. This resolves false positives when using Unicode escapes in CSS content properties, particularly for icon fonts.

Suggested labels

A-Linter, L-CSS

Suggested reviewers

  • denbezrukov
  • siketyan
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix(noUselessEscapeInString): correctly flag chars' is somewhat vague and incomplete—'correctly flag chars' lacks clarity about which characters or what the actual fix accomplishes. Consider a more descriptive title like 'fix(noUselessEscapeInString): preserve valid CSS hex escapes' to clearly indicate the fix handles hex escapes in CSS strings.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description mentions closing issue #9385 and describes adding/updating tests, which aligns with the changeset focused on fixing Unicode escape handling in CSS content properties.
Linked Issues check ✅ Passed The PR addresses the core requirement from #9385 by modifying noUselessEscapeInString to accept valid CSS hex escapes (0-9, a-f, A-F), preventing false positives on sequences like \e7bb used in icon fonts.
Out of Scope Changes check ✅ Passed All changes are scoped to the noUselessEscapeInString rule and its tests; no unrelated modifications to other linting rules or unrelated features.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/css-fix-parser

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/valid.css (1)

10-12: Consider one uppercase or digit-led fixture too.

This proves the lowercase path, but the matcher now also allows 0-9 and A-F. Adding one \31 or \E7BB example would keep those branches from quietly wandering off later.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/valid.css`
around lines 10 - 12, Add an additional test fixture to cover the digit-led or
uppercase hex-escape branches: alongside the existing .icon-file:before {
content: "\e7bb"; } add another rule using either a digit-led escape (e.g.,
content: "\31";) or an uppercase hex escape (e.g., content: "\E7BB";) so the
matcher is exercised for `0-9` and `A-F` paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/invalid.css`:
- Line 4: The test CSS contains inline comments without inner whitespace around
the comment text (the line with content: /*before*/ "useless \z" /*after*/),
which trips stylelint's comment-whitespace-inside; update the test string to add
spaces inside those comments (e.g., change /*before*/ to /* before */ and
/*after*/ to /* after */) so it conforms to comment-whitespace-inside, then
refresh the snapshot; if the test intentionally ignores inner spacing,
alternatively update the test's expected snapshot to match the exact current
spacing.

---

Nitpick comments:
In
`@crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/valid.css`:
- Around line 10-12: Add an additional test fixture to cover the digit-led or
uppercase hex-escape branches: alongside the existing .icon-file:before {
content: "\e7bb"; } add another rule using either a digit-led escape (e.g.,
content: "\31";) or an uppercase hex escape (e.g., content: "\E7BB";) so the
matcher is exercised for `0-9` and `A-F` paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87b103bd-b52b-425d-b702-72157a9ec55a

📥 Commits

Reviewing files that changed from the base of the PR and between 744fe78 and 3abcf8a.

⛔ Files ignored due to path filters (2)
  • crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/invalid.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/valid.css.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/fix-css-unicode-escape-in-string.md
  • crates/biome_css_analyze/src/lint/suspicious/no_useless_escape_in_string.rs
  • crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/invalid.css
  • crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/valid.css


.a::after {
content: /*before*/ "useless \a" /*after*/
content: /*before*/ "useless \z" /*after*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stylelint will trip on the inline comments.

Line 4 violates comment-whitespace-inside because of /*before*/ and /*after*/. If the exact spacing is not part of the range test, add the inner spaces and refresh the snapshot.

🧰 Tools
🪛 Stylelint (17.4.0)

[error] 4-4: Expected whitespace after "/*" (comment-whitespace-inside)

(comment-whitespace-inside)


[error] 4-4: Expected whitespace before "*/" (comment-whitespace-inside)

(comment-whitespace-inside)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@crates/biome_css_analyze/tests/specs/suspicious/noUselessEscapeInString/invalid.css`
at line 4, The test CSS contains inline comments without inner whitespace around
the comment text (the line with content: /*before*/ "useless \z" /*after*/),
which trips stylelint's comment-whitespace-inside; update the test string to add
spaces inside those comments (e.g., change /*before*/ to /* before */ and
/*after*/ to /* after */) so it conforms to comment-whitespace-inside, then
refresh the snapshot; if the test intentionally ignores inner spacing,
alternatively update the test's expected snapshot to match the exact current
spacing.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 9, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks
⏩ 187 skipped benchmarks1


Comparing fix/css-fix-parser (3abcf8a) with main (744fe78)2

Open in CodSpeed

Footnotes

  1. 187 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (5978824) during the generation of this report, so 744fe78 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ematipico ematipico merged commit a1c46af into main Mar 9, 2026
18 checks passed
@ematipico ematipico deleted the fix/css-fix-parser branch March 9, 2026 18:09
@github-actions github-actions Bot mentioned this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-CSS Language: CSS and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📝CSS linter removes unicode escape in content property (iconfont broken)

2 participants