Skip to content

Stylelint: Enforce logical CSS properties everywhere with bulk suppressions - #87686

Draft
simison wants to merge 2 commits into
trunkfrom
update/stylelint-logical-css-everywhere
Draft

simison wants to merge 2 commits into
trunkfrom
update/stylelint-logical-css-everywhere

Conversation

@simison

@simison simison commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

What?

Enables the logical CSS Stylelint rules for every stylesheet in the repository, not only CSS modules and routes/. Existing violations are recorded as bulk suppressions so lint keeps passing.

Alternative to #87685, which enables the rules only for DataViews. Suggested in #87685 (comment) and #37411 (comment).

Why?

Physical properties keep landing in stylesheets that aren't CSS modules. I linted the lines added by every trunk commit that touched a stylesheet in the last 6 months (June–November 2026) with this PR's config:

Count
Commits touching a stylesheet (excluding CSS modules and routes/, which are already covered) 839
Commits that added at least one physical property, keyword or 4-value shorthand 73 (~9%)
…excluding lines that were only moved 63
Lines that would have been flagged 145

It's steady at 9–18 commits a month, spread across editor, components, block-editor, block-library and others, and mostly left/right, margin-left/margin-right, padding-left/padding-right and border-left. Recent examples: #86855, #86023, #85288.

Most of these aren't visible RTL bugs today, since non-module package styles get an -rtl.css build. But they add to the migration in #37411, and the convention isn't holding without a lint rule. A few of the flagged lines are physical on purpose (for example #83520 pairs margins with a physical float); those would need an inline disable with a reason.

How?

  • tools/stylelint/config.js:
    • Move logical-css/require-logical-properties, logical-css/require-logical-keywords and declaration-property-max-values from the CSS modules override to the top-level rules.
    • Add vertical-only longhands to the rule's ignore list: border-top-* and border-bottom-* (color, style, width) and scroll-padding-top / scroll-padding-bottom. These sit alongside border-top, scroll-margin-top and the other vertical properties that were already ignored, so the rule still covers the horizontal axis only. In the analysis above, they caused 8 of the 145 flags.
  • tools/stylelint/stylelint-suppressions.json: regenerated with npm run lint:css:update-suppressions. Existing entries for other rules are untouched.

Suppressed today, across 245 files:

Rule Count
logical-css/require-logical-properties 871
declaration-property-max-values 78
logical-css/require-logical-keywords 71

How suppressions behave: counts are per file and rule. If a file goes over its suppressed count, Stylelint reports every violation of that rule in the file, not only the new one. A change that adds one violation and removes another in the same file keeps the count and isn't flagged. When fixing violations, run npm run lint:css:update-suppressions to lower the counts.

Testing Instructions

  1. npm run lint:css passes.
  2. Add .foo { margin-left: 1px; } to a non-module stylesheet, for example packages/edit-site/src/style.scss, and run npm run lint:css. It is flagged with logical-css/require-logical-properties.
  3. Add .foo { border-top-color: #000; } instead. It isn't flagged by the logical CSS rules.

Use of AI Tools

Drafted with Claude Code; reviewed by me.

…ssions

Move the logical-css and declaration-property-max-values rules out of the CSS modules override so they apply to all stylesheets, and record existing violations in the bulk suppressions file.
@simison simison added the [Type] Code Quality Issues or PRs that relate to code quality label Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

📦 Bundle size

Size Change: 0 B

Total Size: 8.73 MB

c9e18c3 Run

border-top/bottom-color/style/width and scroll-padding-top/bottom don't depend on writing direction, like the border-top and scroll-margin-top properties already ignored.
@simison

simison commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Looks like we should extend the ignore list a bit, too:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant