fix(lint/style/noDescendingSpecificity): limit the noDescendingSpecificity rule to selectors within the same @layer#7618
fix(lint/style/noDescendingSpecificity): limit the noDescendingSpecificity rule to selectors within the same @layer#7618ryumasai wants to merge 3 commits intobiomejs:mainfrom
noDescendingSpecificity rule to selectors within the same @layer#7618Conversation
🦋 Changeset detectedLatest commit: 7ff777f The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 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 |
…ficity` rule to selectors within the same `@layer`
WalkthroughThis PR makes the style/noDescendingSpecificity lint layer-aware by recording an optional Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (3)crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
crates/biome_*/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.rs📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-09-10T08:05:22.867ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (26)
🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.changeset/puny-needles-eat.md (1)
5-5: Consider adjusting tense for clarity.The changeset mixes "Fixed" (past tense) with "now only compares" (present tense). Per the coding guidelines, describe what you did in past tense and current behaviour in present tense separately for clarity.
Suggested rephrase:
-Fixed [#7533](https://github.com/biomejs/biome/issues/7533): the `noDescendingSpecificity` rule now only compares specificity selectors that belong to the same `@layer`. +Fixed [#7533](https://github.com/biomejs/biome/issues/7533): Updated the `noDescendingSpecificity` rule to compare specificity only for selectors within the same `@layer`. The rule now correctly ignores specificity differences across different layers.Or more concisely:
-Fixed [#7533](https://github.com/biomejs/biome/issues/7533): the `noDescendingSpecificity` rule now only compares specificity selectors that belong to the same `@layer`. +Fixed [#7533](https://github.com/biomejs/biome/issues/7533): Made the `noDescendingSpecificity` rule layer-aware. It now only compares specificity for selectors within the same `@layer`.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
crates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/complex_selector.invalid.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/valid.css.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (5)
.changeset/puny-needles-eat.md(1 hunks)crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs(7 hunks)crates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/complex_selector.invalid.css(1 hunks)crates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/valid.css(1 hunks)crates/biome_css_semantic/src/semantic_model/model.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_css_semantic/src/semantic_model/model.rscrates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/valid.csscrates/biome_css_analyze/src/lint/style/no_descending_specificity.rscrates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/complex_selector.invalid.css
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_css_semantic/src/semantic_model/model.rscrates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/valid.csscrates/biome_css_analyze/src/lint/style/no_descending_specificity.rscrates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/complex_selector.invalid.css
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Format all Rust source files before committing (just f)
Files:
crates/biome_css_semantic/src/semantic_model/model.rscrates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/*.md: In changeset files, only use #### or ##### headers; avoid other header levels
Changeset descriptions should use past tense for what you did (e.g., "Added...")
Describe current Biome behavior in present tense within changesets (e.g., "Biome now supports...")
For bug fixes in changesets, start with a link to the issue (e.g., "Fixed #1234: ...")
When referencing rules or assists in changesets, include links to their documentation pages
Include a minimal code block in the changeset when applicable to demonstrate the change
End every sentence in the changeset description with a period
Files:
.changeset/puny-needles-eat.md
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/valid.csscrates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/complex_selector.invalid.css
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
- GitHub Check: Bench (biome_module_graph)
- GitHub Check: autofix
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_html_parser)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_html_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_package)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Check Dependencies
- GitHub Check: Test Node.js API
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
🔇 Additional comments (9)
crates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/complex_selector.invalid.css (1)
10-18: Good test coverage for within-layer violations.This test case properly exercises the rule's behaviour within a single
@layerblock, ensuring descending specificity is still caught when selectors are in the same layer.crates/biome_css_semantic/src/semantic_model/model.rs (2)
1-5: LGTM.Import correctly adds
AnyCssLayerfor the newlayer()method.
238-245: LGTM.The ancestor walk correctly returns the nearest enclosing
@layerfor a selector. For nested layers, this returns the innermost layer, which aligns with CSS cascade layer semantics.crates/biome_css_analyze/tests/specs/style/noDescendingSpecificity/valid.css (1)
54-72: Excellent test coverage for cross-layer scenarios.These test cases properly verify that selectors with descending specificity across different
@layerblocks are correctly exempted from the rule. The nested@layer threealso exercises nested layer handling.crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs (5)
1-1: LGTM.Import correctly adds
AnyCssLayerfor layer-aware comparison logic.
93-106: LGTM.This example clearly demonstrates the cross-layer exemption, showing that
b ain@layer baseandain@layer specialare correctly treated as independent despite descending specificity.
153-154: LGTM.Data structure correctly extended to track layer context alongside specificity.
177-181: LGTM.Insertion correctly stores layer context alongside range and specificity for subsequent comparisons.
167-180: Could you run the analyzer on/tmp/test_same_layer_name.cssand share whether it flags the descending specificity across the two@layer baseblocks?
noDescendingSpecificity rule to selectors within the same @layernoDescendingSpecificity rule to selectors within the same @layer
CodSpeed Performance ReportMerging #7618 will not alter performanceComparing Summary
|
|
Everything is ready. |
Summary
Closes #7533
The
noDescendingSpecificityrule now only compares specificity selectors that belong to the same@layer.Test Plan
snaptests
Docs
rustdoc and changeset