Skip to content

Stylelint: Another round of cleanup #43247

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

Open
wants to merge 14 commits into
base: trunk
Choose a base branch
from

Conversation

tbradsha
Copy link
Contributor

This PR addresses the following rules:

  • property-no-unknown
  • declaration-property-unit-allowed-list
  • scss/comment-no-empty
  • no-duplicate-selectors
  • scss/at-extend-no-missing-placeholder
  • selector-id-pattern

Proposed changes:

property-no-unknown

Rule: https://stylelint.io/user-guide/rules/property-no-unknown/
Violations: 4

Three of the violations were due to CSS Modules :export usage in projects/js-packages/components/components/layout/col/style.module.scss, and one was due to a valid shadow-color React Native property. The rule was enabled with those exceptions.

declaration-property-unit-allowed-list

Rule: https://stylelint.io/user-guide/rules/declaration-property-unit-allowed-list/
Violations: 75

WPCS wants unit-less or px line-height values (source). Due to behavioral differences in inheritance between unit and unit-less values, this doesn't have an automatic fix. I changed these in CRM, VaultPress, and packages/forms after verifying no breakage, and the rest I comment-ignored, as testing each change is not worth the time and it's more important we prevent future violations. I also removed one line that browsers ignored due to a typo (45676de).

scss/comment-no-empty

Rule: https://stylelint.io/user-guide/rules/scss/comment-no-empty/
Violations: 75

Nearly all of these were multiple lines of // comments, with a "blank" comment for spacing. I simplified them or swapped them out for /** ... */ style comments. I also added projects/packages/jetpack-mu-wpcom/src/features/custom-css/custom-css/css/blank.css to .stylelintignore (bb6c05d), since presumably it's as-is for a reason.

no-duplicate-selectors

Rule: https://stylelint.io/user-guide/rules/no-duplicate-selectors/
Violations: 141

This one has the most controversial changes. In a few cases there were duplicates in the same selector list or two selectors right near each other that were easily collapsed. In many cases it involved combining selectors across tens or hundreds of lines of code, so theoretically some of the changes could affect cascade order. Given that most instances had multiple levels of specificity or a quite specific class name, I'm not too worried in the end, and a click through of some of the plugins showed no issues.

scss/at-extend-no-missing-placeholder

Rule: https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-extend-no-missing-placeholder/README.md
Violations: 13

Instead of @extend .some-class, this rule wants @extend %some-placeholder. In CRM, the classes weren't used, so they were just switched out. For the rest I wasn't sure, so I just switched to them to placeholders and created a class with the original name that extends the placeholder. I verified no change to the compiled CSS for the Inspect plugin.

selector-id-pattern

Rule: https://stylelint.io/user-guide/rules/selector-id-pattern/
Violations: 408

This one I kept disabled. We don't have the luxury of ensuring our selectors conform to a specific pattern given that our code extends various repos and languages.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Go to '..'

@tbradsha tbradsha added [Status] Needs Review This PR is ready for review. [Type] Janitorial labels Apr 25, 2025
@tbradsha tbradsha requested a review from a team April 25, 2025 18:54
@tbradsha tbradsha self-assigned this Apr 25, 2025
Copy link
Contributor

github-actions bot commented Apr 25, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the fix/stylelint/round_x_of_cleanup branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/stylelint/round_x_of_cleanup
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/stylelint/round_x_of_cleanup

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [mu wpcom Feature] Verbum Comments Verbum, a better comment experience, app developed in the mu-wpcom plugin [mu wpcom Feature] Wpcom Admin Bar [mu wpcom Feature] Wpcom Hotfixes [Package] Account Protection [Package] Ad aka WordAds [Package] Backup [Package] Classic Theme Helper [Package] Forms [Package] Jetpack mu wpcom WordPress.com Features [Package] Jitm [Package] Masterbar [Package] My Jetpack [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] VideoPress [Plugin] Automattic For Agencies Client [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Debug Helper Debug Tools plugin [Plugin] Inspect [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] VaultPress [Plugin] Wpcomsh Admin Page React-powered dashboard under the Jetpack menu RNA labels Apr 25, 2025
Copy link
Contributor

github-actions bot commented Apr 25, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 6, 2025
    • Code freeze: May 5, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Debug Helper plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Vaultpress plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Boost plugin:

  • Next scheduled release: April 30, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Protect plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Inspect plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Automattic For agencies client plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

For the rest I wasn't sure, so I just switched to them to placeholders and created a class with the original name that extends the placeholder.

Looking at the docs suggests you might be able to do like this:

.foobar, %foobar {
    // Some stuff
}

.baz {
    @extends %foobar
    // more stuff
}

instead of having to do like

%foobar {
    // Some stuff
}

.foobar {
    @extends %foobar
}

.baz {
    @extends %foobar
    // more stuff
}

As for the rest of the comments, most are ignorable if you disagree.

Comment on lines 45 to +46
font-weight: 600;
// stylelint-disable-next-line declaration-property-unit-allowed-list -- this should be changed to a unitless value: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/#values
Copy link
Contributor

Choose a reason for hiding this comment

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

What's up with the excessive indent here?

Suggested change
font-weight: 600;
// stylelint-disable-next-line declaration-property-unit-allowed-list -- this should be changed to a unitless value: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/#values
font-weight: 600;
// stylelint-disable-next-line declaration-property-unit-allowed-list -- this should be changed to a unitless value: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/#values

@@ -15,6 +15,7 @@

#wpadminbar{
background: $masterbar-background !important;
box-shadow: inset 0 -1px 0 $masterbar-background; // Calypso --color-masterbar-background
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe keep the comment from below?

Suggested change
box-shadow: inset 0 -1px 0 $masterbar-background; // Calypso --color-masterbar-background
// Nav Unification - Masterbar - border below the Masterbar
box-shadow: inset 0 -1px 0 $masterbar-background; // Calypso --color-masterbar-background

@@ -345,12 +347,6 @@
color:var(--wp-admin-theme-color)
}

/** Add new site button **/
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit iffy on this one. While the #adminmenu can be combined with the above, logically it seems lines 348–392 may belong to a "Add new site button" feature and we're losing indication of that with this change.

Comment on lines +46 to +48
button {
color: var(--jp-gray-0);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Mismatched indent.

Suggested change
button {
color: var(--jp-gray-0);
}
button {
color: var(--jp-gray-0);
}

Comment on lines +1 to +8
/**
* These styles are copied directly from @wordpress/interface
* in order to remove our dependency on this experimental package.
*
* TODO: Replace these styles with our own styles.
*
* complementary-area-header
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Semantically this seems like it should be more like this

Suggested change
/**
* These styles are copied directly from @wordpress/interface
* in order to remove our dependency on this experimental package.
*
* TODO: Replace these styles with our own styles.
*
* complementary-area-header
*/
/**
* These styles are copied directly from @wordpress/interface
* in order to remove our dependency on this experimental package.
*
* TODO: Replace these styles with our own styles.
*/
// complementary-area-header

@@ -132,10 +133,6 @@ body.presentation-wrapper-fullscreen-parent {
opacity: 0.8;
}

.presentation-wrapper-fullscreen .nav-fullscreen-button {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sectioning again.

@@ -7,7 +7,7 @@
transition: all .1s ease-in-out;
}

.jp-button {
%jp-button {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will have the same problem as the boost one above.

@@ -59,12 +59,6 @@
};
}

.footer nav {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sections again

Copy link
Contributor

Choose a reason for hiding this comment

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

Sectioning again

@@ -72,7 +72,7 @@
cursor: pointer;
}

.remove {
%remove {
Copy link
Contributor

Choose a reason for hiding this comment

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

This one probably has breakage too, like the boost thing below.

@kraftbj kraftbj added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [Block] Ad [Block] AI Assistant [Block] Contact Form Form block (also see Contact Form label) [Block] Donations [Block] Goodreads [Block] Image Compare [Block] Like [Block] Map [Block] Pay With Paypal aka Simple Payments [Block] Related Posts [Block] Slideshow [Block] Star Rating [CRM] MailPoet Module [CRM] Portal Module [CRM] WooSync Module [Extension] Social Previews Social Preview block editor plugin [Feature] Carousel A fullscreen modal appearing when clicking on an image in a gallery or tiled gallery. [Feature] Contact Form [Feature] Extra Sidebar Widgets [Feature] Infinite Scroll [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [Feature] Publicize Now Jetpack Social, auto-sharing [Feature] Sharing Post sharing, sharing buttons [Feature] Shortcodes / Embeds [Feature] Theme Tools [Feature] Widget Visibility [JS Package] AI Client [JS Package] Components [JS Package] Connection [JS Package] Licensing [JS Package] Publicize Components [mu wpcom Feature] Verbum Comments Verbum, a better comment experience, app developed in the mu-wpcom plugin [mu wpcom Feature] Wpcom Admin Bar [mu wpcom Feature] Wpcom Hotfixes [Package] Account Protection [Package] Ad aka WordAds [Package] Backup [Package] Classic Theme Helper [Package] Forms [Package] Jetpack mu wpcom WordPress.com Features [Package] Jitm [Package] Masterbar [Package] My Jetpack [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] VideoPress [Plugin] Automattic For Agencies Client [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Debug Helper Debug Tools plugin [Plugin] Inspect [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] VaultPress [Plugin] Wpcomsh RNA [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants