Repository navigation
Conversation
`maxTypes` counted the `from`, `to` and percentage selectors of an
`@keyframes` rule, because css-tree parses them as `TypeSelector` nodes
even though they name no element. A file whose only keyframes therefore
failed with `{ maxTypes: 0 }`:
4:2 Exceeded maximum type selector. Only 0 allowed.
8:2 Exceeded maximum type selector. Only 0 allowed.
Track whether the selector sits inside a keyframes rule and skip those,
the same way `no-duplicate-keyframe-selectors` tracks that depth (the
language's AST exposes no parent links).
Fixes eslint#582
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe ChangesKeyframe type-selector counting
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change excludes keyframe step type selectors while continuing to check ordinary selectors afterward. No actionable issue is established, so the PR appears mergeable subject to normal project checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
The referenced issue is neither accepted nor assigned to you. |
What does this change?
css/selector-complexitycounted thefrom,toand percentage selectors of an@keyframesrule towardmaxTypes, because css-tree parses them asTypeSelectornodes even though they name no element. A stylesheet whose only "type selectors" were keyframe selectors therefore failed with{ maxTypes: 0 }:The fix tracks whether the selector sits inside a keyframes rule and skips those. It uses the same technique as the existing
no-duplicate-keyframe-selectorsrule, because@eslint/css's language exposes no parent links on AST nodes (I first tried walkingnode.parentand confirmed the property isundefined).Vendor-prefixed keyframes rules are handled by the same regex that rule uses.
Fixes #582
Testing
Three cases added to
tests/rules/selector-complexity.test.js:@keyframes fade { from {...} to {...} }with{ maxTypes: 0 }— the reported repro.@keyframes slide { 0% {...} 100% {...} }with{ maxTypes: 0 }— percentage selectors.@keyframesfollowed by a.foorule, and@keyframesfollowed bydiv spanwith{ maxTypes: 1 }which must still report — proving the flag is cleared on the way out, not just set.Verified
validcases fail onmainwith exactly the reported messages (Should have no errors but had 2: ... Exceeded maximum type selector) and pass with the fix — confirmed by stashing the rule and re-running.npx mocha "tests/**/*.test.js": 1236 passing, 0 failing (was 1233 before, +3 from this change).npm run build(which also runs the rule-docs regeneration) exits 0.npm run lint(the repo's own eslint) andprettier --checkare clean.Not verified
Docs
Added a short note plus example to
docs/rules/selector-complexity.mdunder the existingmaxTypessection. The rule description and options are unchanged.Summary by CodeRabbit
Bug Fixes
from,to, and percentages no longer count toward the type-selector limit. Type selectors outside keyframes continue to be checked as before.Documentation
maxTypessetting.