Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(biome_css_analyze): implement noIrregularWhitespaceCss #3428

Merged

Conversation

DerTimonius
Copy link
Contributor

@DerTimonius DerTimonius commented Jul 13, 2024

Summary

This PR supercedes #3362 (there were some collisions between the css and the js rule and it was harder to fix than anticipated, so I started over) and implements the no-irregular-whitespace rule from stylelint.

My original implementation only checked for selectors, now this rule checks for complete rule blocks, regardless of type of rule (import rules, container rules, simple rule, you name it).

I was able to reuse most of the logic used in #3333 with some changes.

Test Plan

I tested some different @-rules, used the whitespace in the selector and in the rule itself. I also used all characters that are declared irregular.

closes #3264

@github-actions github-actions bot added A-Project Area: project L-CSS Language: CSS A-Diagnostic Area: diagnostocis labels Jul 13, 2024
Copy link

codspeed-hq bot commented Jul 13, 2024

CodSpeed Performance Report

Merging #3428 will degrade performances by 38.77%

Comparing DerTimonius:feat/no-irregular-whitespace-css (f625d43) with main (74397eb)

Summary

❌ 6 regressions
✅ 98 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main DerTimonius:feat/no-irregular-whitespace-css Change
css_analyzer[bootstrap_18416142857265205439.css] 93.5 ms 125.8 ms -25.73%
css_analyzer[bulma_15117074458139280020.css] 80.8 ms 112.1 ms -27.9%
css_analyzer[foundation_7285025277362245733.css] 62 ms 83.8 ms -26.07%
css_analyzer[pure_9395922602181450299.css] 6.7 ms 8.9 ms -24.61%
css_analyzer[tachyons_9066552643484828443.css] 43.9 ms 71.7 ms -38.77%
react.production.min_3378072959512366797.js[cached] 1.8 ms 2 ms -6.44%

/// ```
///
pub NoIrregularWhitespaceCss {
version: "1.8.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version: "1.8.0",
version: "next",

version: "1.8.0",
name: "noIrregularWhitespaceCss",
language: "css",
recommended: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
recommended: false,
recommended: true,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should recommend it. It's a slow rule, and a niche one.

Comment on lines 63 to 66
//
// Read our guidelines to write great diagnostics:
// https://docs.rs/biome_analyze/latest/biome_analyze/#what-a-rule-should-say-to-the-user
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the comment

/// }
/// ```
///
pub NoIrregularWhitespaceCss {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS isn't necessary. One rule can use the same name in multiple languages in Biome.

Suggested change
pub NoIrregularWhitespaceCss {
pub NoIrregularWhitespace {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when trying to rename this, I run into this issue (which is the reason why I opened a new PR for this):
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, problem. Keep the old name and I will handle that once this rule is merged

Copy link
Contributor

@togami2864 togami2864 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Could you add CHANGELOG and run just gen-lint again?

'\u{c}', '\u{b}', '\u{85}', '\u{feff}', '\u{a0}', '\u{1680}', '\u{180e}', '\u{2000}',
'\u{2001}', '\u{2002}', '\u{2003}', '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}',
'\u{2009}', '\u{200a}', '\u{200b}', '\u{202f}', '\u{205f}', '\u{3000}',
];
Copy link

@Mouvedia Mouvedia Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question

Are \u{2028} and \u{2029} missing?

see
w3c/csswg-drafts#6992
eslint/eslint#2316

@github-actions github-actions bot added the A-Changelog Area: changelog label Jul 15, 2024
@ematipico
Copy link
Member

@DerTimonius are you still interested in this PR?

@DerTimonius
Copy link
Contributor Author

@ematipico yes, I was wondering what is still missing

@ematipico
Copy link
Member

Just fix the conflicts and I'll merge it

@DerTimonius
Copy link
Contributor Author

@ematipico thanks, resolved the conflicts 🙂

@ematipico ematipico merged commit 3229b32 into biomejs:main Aug 1, 2024
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Diagnostic Area: diagnostocis A-Project Area: project L-CSS Language: CSS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📎 Implement stylelint/no-irregular-whitespace
4 participants