feat(lint/js): add noExcessiveSelectorClasses#9866
Conversation
🦋 Changeset detectedLatest commit: a136179 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (15)
📒 Files selected for processing (21)
✅ Files skipped from review due to trivial changes (8)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughThis PR introduces a new CSS linter rule Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/rare-schools-raise.md:
- Around line 1-4: The changeset front matter is malformed due to an extra '---'
delimiter; open the .changeset/rare-schools-raise.md file and remove the
redundant second '---' so the YAML front matter is a single start and end
delimiter, then ensure the remaining front matter correctly lists the package
mapping ("@biomejs/biome": patch) and no other stray delimiters or blank
front-matter sections remain.
In `@crates/biome_css_analyze/src/lint/nursery/no_excessive_selector_classes.rs`:
- Around line 138-139: The parameter name _ctx in fn diagnostic(_ctx:
&RuleContext<Self>, state: &Self::State) should be renamed to ctx because it is
used; update the function signature to fn diagnostic(ctx: &RuleContext<Self>,
state: &Self::State) and replace all usages of _ctx within the function body
(e.g., the call to _ctx.options().max_classes()) with ctx to reflect the actual
usage and remove the misleading underscore prefix.
- Line 97: The RuleSource declaration currently uses
RuleSource::Stylelint("selector-max-class").same(); update it to use .inspired()
instead of .same() to reflect the documented semantic ("Inspired by" not "Same
as") and the fact nested selectors are checked instead of being resolved; locate
the occurrence of RuleSource::Stylelint("selector-max-class").same() in the
no_excessive_selector_classes rule and replace .same() with .inspired() (no
other behavior changes required).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: af0d4dd1-949b-446e-8582-9674e9da06d9
⛔ Files ignored due to path filters (10)
crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_configuration/src/generated/linter_options_check.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.nested.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.pseudo.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.css.snapis excluded by!**/*.snapand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (14)
.changeset/rare-schools-raise.mdcrates/biome_css_analyze/src/lint/nursery/no_excessive_selector_classes.rscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.nested.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.nested.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.pseudo.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.pseudo.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.options.jsoncrates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/no_excessive_selector_classes.rs
Merging this PR will not alter performance
Comparing Footnotes
|
ea192ed to
6a7014b
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/src/lint/nursery/no_excessive_selector_classes.rs`:
- Around line 59-61: In the doc comment in no_excessive_selector_classes.rs (the
configured example under the maxClasses: 1 options block) add the code block
flag so the fenced snippet is ```css,use_options instead of just ```css; this
ensures the example is validated with the rule options applied—update the doc
comment near the .foo {} example in the no_excessive_selector_classes
documentation to include use_options.
In
`@crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.css`:
- Around line 1-5: The current test only contains selectors like "div {}", ".foo
{}", "#id[attr]:hover::before {}", and ":nth-child(2n) {}", which also pass when
maxClasses is set, so update the fixture by adding a selector that would violate
a max-classes rule (to assert unconfigured==no-op), for example add a rule such
as ".a .b .c {}" or a concatenated class selector like ".foo.bar.baz {}" to the
test file so the snapshot proves the rule is a no-op when unconfigured.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f9df073d-5014-443d-9ae5-c3d41c6b246f
⛔ Files ignored due to path filters (15)
crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_configuration/src/generated/linter_options_check.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.max2.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.nested.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.pseudo.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.scss.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.max2.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.zero.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.zero.scss.snapis excluded by!**/*.snapand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (22)
.changeset/rare-schools-raise.mdcrates/biome_css_analyze/src/lint/nursery/no_excessive_selector_classes.rscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.max2.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.max2.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.nested.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.nested.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.pseudo.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.pseudo.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.scsscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.max2.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.max2.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.zero.csscrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.zero.options.jsoncrates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.zero.scsscrates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/no_excessive_selector_classes.rs
✅ Files skipped from review due to trivial changes (10)
- .changeset/rare-schools-raise.md
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.zero.css
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.max2.options.json
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.pseudo.options.json
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.max2.options.json
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.options.json
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.nested.options.json
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.zero.options.json
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/valid.zero.options.json
- crates/biome_css_analyze/tests/specs/nursery/noExcessiveSelectorClasses/invalid.options.json
6a7014b to
a136179
Compare
Summary
This PR adds
noExcessiveSelectorClasseswhich is a port of https://stylelint.io/user-guide/rules/selector-max-class/I chose make this rule have no effect when it's enabled and not configured. Should we emit a diagnostic in that case?
generated by gpt 5.4
Test Plan
snapshots
Docs