feat: add max-average-specificity rule#86
Merged
bartveneman merged 5 commits intomainfrom Mar 24, 2026
Merged
Conversation
Implements #77. Tracks the specificity of all selectors and reports when the average exceeds the configured [a, b, c] maximum. Added to the recommended config with default value [0, 2.5, 1]. https://claude.ai/code/session_015qh5mN6GXk2cUWQy2JFV7L
Bundle ReportChanges will increase total bundle size by 2.05kB (3.54%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: stylelintPlugin-esmAssets Changed:
Files in
Files in
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
==========================================
+ Coverage 98.11% 98.17% +0.06%
==========================================
Files 30 31 +1
Lines 847 878 +31
Branches 232 238 +6
==========================================
+ Hits 831 862 +31
Misses 13 13
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Follow the same convention as stylelint's own selector-max-specificity rule, which accepts "0,2,0" strings rather than arrays. This avoids needing primaryOptionArray and is more idiomatic stylelint. https://claude.ai/code/session_015qh5mN6GXk2cUWQy2JFV7L
…cificity Uses primaryOptionArray = true so stylelint correctly interprets the tuple as the primary option rather than [primaryOption, secondaryOptions]. https://claude.ai/code/session_015qh5mN6GXk2cUWQy2JFV7L
RuleMessage args must be primitive types; pass specificity as joined strings instead of tuple arrays. https://claude.ai/code/session_015qh5mN6GXk2cUWQy2JFV7L
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.
Closes #77
Summary
projectwallace/max-average-specificitythat tracks the specificity of all selectors and reports when the average exceeds the configured[a, b, c]maximum[0, 2.5, 1]calculateSpecificityandcompareSpecificityfrom@projectwallace/css-analyzerruleFunction.primaryOptionArray = trueso stylelint correctly treats the tuple as the primary option (not[primaryOption, secondaryOptions])[0, 2.5, 1]src/index.tsand documented inREADME.mdper CONTRIBUTING.mdTest plan
invalidOptionWarningshttps://claude.ai/code/session_015qh5mN6GXk2cUWQy2JFV7L