perf(lint): optimize noIrregularWhitespace rule#9111
Conversation
🦋 Changeset detectedLatest commit: 7e83a65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance
Comparing Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 WalkthroughRefactors the noIrregularWhitespace lints for CSS and JavaScript. Introduces a central is_irregular_whitespace(char) helper, removes the previous static character set, and adds early-return checks to skip work when no irregular characters are present. CSS handling now accepts a CssSyntaxNode and iterates tokens via syntax.descendants_tokens(Direction::Next); JS processing consolidates leading and trailing trivia scanning. No public API changes. Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
Verify each finding against the current code and only fix it if needed.
In @.changeset/new-dolls-flow.md:
- Line 5: Fix the typo in the changeset line that reads "Sightly improved
performance of
[`noIrregularWhitespace`](https://biomejs.dev/linter/rules/no-irregular-whitespace/)..."
by changing "Sightly" to "Slightly" so the sentence correctly starts "Slightly
improved performance of `noIrregularWhitespace`...".
1aba52a to
ab0d96b
Compare
|
I don't think the rule is slow per se, I believe it's slow because it must look at all the spaces inside a document |
|
Just curious @Jayllyz, you mentioned you tested in debug mode. Did you try in release mode? Debug mode makes biome significantly slower. |
Summary
I noticed using the rule profiler (really useful thanks) that this rule was the slowest for me. The initial goal here was to speed up the rule for non-matching files. The performance gain isn't huge, but I think its still worth it, around 10% from what i've tested in debug mode
Test Plan
Unit test + manual test on my repos.
Docs