perf: replace Wallace css parser/walker with PostCSS native APIs where possible#90
Merged
bartveneman merged 1 commit intomainfrom Mar 25, 2026
Merged
Conversation
- max-important-ratio: use PostCSS declaration.important instead of
calling parse_declaration() on every declaration; removes the
css-parser import entirely from this rule
- max-average-declarations-per-rule: replace root.toString() + full
css-parser re-parse with root.walkRules() + rule.each(); removes
all three css-parser imports (parse, walk, node constants)
- max-selector-complexity: replace root.toString() + css-parser
re-parse + manual walk with root.walkRules(), matching the pattern
already used by max-average-selector-complexity; removes parse,
walk, and STYLE_RULE imports
- no-unused-layers: replace root.toString() + css-parser re-parse with
root.walkAtRules('layer'); also replaces the inline allowlist pattern
matching with the existing isAllowed() utility; stores the PostCSS
AtRule node directly instead of a manual {line, column} position
https://claude.ai/code/session_01VsxyyE2S6uMjaSkPKRej5u
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
- Coverage 98.25% 98.20% -0.05%
==========================================
Files 33 33
Lines 917 893 -24
Branches 243 230 -13
==========================================
- Hits 901 877 -24
Misses 13 13
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will decrease total bundle size by 1.43kB (-2.27%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: stylelintPlugin-esmAssets Changed:
Files in
|
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
Refactored multiple stylelint rules to use PostCSS native APIs instead of the
@projectwallace/css-parserlibrary, simplifying the codebase and improving maintainability.Key Changes
root.walkAtRules('layer'), simplified position tracking by using AtRule nodes directly, and extracted allowlist logic toisAllowed()utility functionroot.walkRules()for iterating style rules, removed manual line offset calculationsroot.walkRules()andrule.each()for traversing declarations, simplified node type checkingdeclaration.importantproperty instead of parsing declaration source textImplementation Details
@projectwallace/css-parsermodules:parse,walk,nodesconstantsroot.source?.start?.line) by using PostCSS node objects directly for reportinghttps://claude.ai/code/session_01VsxyyE2S6uMjaSkPKRej5u