Add six new stylelint rules for CSS metrics analysis#58
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #58 +/- ##
==========================================
+ Coverage 97.46% 97.99% +0.53%
==========================================
Files 18 25 +7
Lines 591 749 +158
Branches 189 210 +21
==========================================
+ Hits 576 734 +158
Misses 12 12
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 10.95kB (28.17%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: stylelintPlugin-esmAssets Changed:
Files in
Files in
|
Replace analyze() calls with direct PostCSS AST walking and @projectwallace/css-parser, matching the pattern used by existing rules: - max-file-size: use root.source.input.css.length - max-comment-size: walkComments + source offsets - max-embedded-content-size: walkDecls + parse_declaration + URL nodes - max-average-declarations-per-rule: walkRules + count decl nodes - max-average-selectors-per-rule: walkRules + parse_selector - max-average-selector-complexity: walkRules + parse_selector + selectorComplexity - max-important-ratio: walkDecls + parse_declaration + is_important https://claude.ai/code/session_01N4LARBRwbeExNaaiACWJT6
Summary
This PR adds six new stylelint rules to the plugin that leverage the
@projectwallace/css-analyzerlibrary to enforce CSS quality metrics and constraints.Key Changes
New Rules Added:
max-file-size: Enforces a maximum file size limit in bytesmax-embedded-content-size: Limits the total size of embedded content (data URIs, etc.)max-comment-size: Restricts the total size of CSS commentsmax-average-selectors-per-rule: Enforces a maximum average number of selectors per rulemax-average-declarations-per-rule: Enforces a maximum average number of declarations per rulemax-average-selector-complexity: Enforces a maximum average selector complexityImplementation Details:
@projectwallace/css-analyzer, compare actual metrics against configured thresholds, and report violationsmax-important-ratiowhich uses < 0)Documentation Updates:
Notable Implementation Details
analyze(root.source!.input.css)https://claude.ai/code/session_01N4LARBRwbeExNaaiACWJT6