Add min-selector-uniqueness-ratio and min-declaration-uniqueness-ratio rules#85
Merged
bartveneman merged 4 commits intomainfrom Mar 24, 2026
Merged
Conversation
…o rules Implements #43 and #44. Both rules enforce a minimum ratio of unique selectors/declarations across the stylesheet (0-1 inclusive). Defaults: selectors 0.66, declarations 0.5. Both added to recommended config. https://claude.ai/code/session_01VURzQkGPNVKAvhiRHoNudb
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #85 +/- ##
==========================================
+ Coverage 97.97% 98.11% +0.13%
==========================================
Files 28 30 +2
Lines 792 847 +55
Branches 216 232 +16
==========================================
+ Hits 776 831 +55
Misses 13 13
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Verifies that declarations and selectors inside nested CSS rules and at-rules (e.g. @media, nesting with &) are counted toward the ratio. https://claude.ai/code/session_01VURzQkGPNVKAvhiRHoNudb
Replace array accumulation + Set construction with a counter + Set.add() pattern, avoiding storing all values in a separate array. https://claude.ai/code/session_01VURzQkGPNVKAvhiRHoNudb
Adds per-rule README.md with violation/passing examples and option docs. Updates root README.md manual config example and rules table per CONTRIBUTING.md. https://claude.ai/code/session_01VURzQkGPNVKAvhiRHoNudb
Bundle ReportChanges will increase total bundle size by 3.33kB (6.1%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: stylelintPlugin-esmAssets Changed:
Files in
Files in
|
This was referenced Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two new stylelint rules to the plugin that enforce minimum uniqueness ratios for selectors and declarations in CSS stylesheets.
Key Changes
min-selector-uniqueness-ratio- Enforces a minimum ratio of unique selectors to total selectors. Counts individual selectors in selector lists separately (e.g.,a, bcounts as 2 selectors).min-declaration-uniqueness-ratio- Enforces a minimum ratio of unique declarations to total declarations. Uniqueness is determined by the combination of property and value.Implementation Details
https://claude.ai/code/session_01VURzQkGPNVKAvhiRHoNudb