build: add stylelint for RTL-unsafe logical CSS properties - #608
Open
akashfer wants to merge 1 commit into
Open
Conversation
GutenbergKit's SCSS was never linted for physical left/right properties, so a direction-specific bug (border-right-color on the toolbar) had to be found by eye. Add stylelint with stylelint-plugin-logical-css, mirroring the setup and ignore list upstream Gutenberg uses in tools/stylelint/config.js, and wire lint:css / lint-css into npm scripts, the Makefile, and CI alongside lint:js / lint-js. Also converts the ~29 existing physical-property declarations the new rule flags to their logical equivalents. Two declarations in the toolbar's scroll-indicator gradients are not a symmetric pair and are left physical with a stylelint-disable, pending separate investigation into their RTL behavior. The base @wordpress/stylelint-config/scss ruleset is otherwise stricter than this codebase's existing conventions; the selector-naming, blank-line, and specificity-ordering rules it would also enable are relaxed the same way upstream's own config relaxes them, to keep this change scoped to the logical-properties rule.
Contributor
|
In terms of infra/tooling ( |
Member
|
@akashfer thank you for exploring this. It may take me a little while to begin review of this, but hopefully I can next week. I'll follow up. |
Author
|
Okay thanks |
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.
Fixes #564
What?
Adds a stylelint setup to GutenbergKit's SCSS, using
stylelint-plugin-logical-cssto flag physical (left/right/padding-left/etc.) properties that should be written as logical properties (inset-inline-start,padding-inline, etc.) for RTL correctness. Converts the ~29 existing violations the new rule flags to their logical equivalents.Why?
GutenbergKit's own SCSS is never processed by
rtlcss, and nothing currently guards against physical-property RTL bugs — one (border-right-colormisplacing the toolbar divider) had to be found by eye during RTL testing. There was no stylelint setup at all: no config, no dependency, nolint:cssscript, no Makefile target.How?
stylelint,stylelint-plugin-logical-css(pinned to^1.2.3, matching the version upstream Gutenberg pins intools/stylelint/config.js— v2 renamed the rule this issue asks for),@wordpress/stylelint-config, andpostcss-scssas dev dependencies..stylelintrc.mjsextending@wordpress/stylelint-config/scssand enablingplugin/use-logical-properties-and-values, reusing upstream'signorelist for properties that don't affect RTL (margin-top,width,overflow-y,border-top, etc.).@wordpress/stylelint-config/scssruleset is otherwise stricter than this codebase's existing conventions (BEM-style double-underscore class names, blank-line formatting, specificity ordering). Relaxed the same rules upstream's own config relaxes for the same reason, to keep this PR scoped to the logical-properties rule rather than a repo-wide style rewrite.lint:css/lint:css:fixnpm scripts and matchinglint-css/lint-css-fixMakefile targets, mirroring the existinglint-jspattern.lint-cssinto the Buildkite pipeline alongsidelint-js, including the release-gatedepends_onlist.left/rightpairs, or single vertical properties likescroll-padding-bottom) to their logical equivalents.::before/::after) are not a symmetric pair — they're the left- and right-scroll affordances, and whether they should flip in RTL needs its own investigation. Left those physical with an inlinestylelint-disable-next-lineand a comment, rather than guessing at a fix.position: absoluteoverridden by a laterposition: fixed !important, two duplicate selector blocks that can merge into one, three0px→0unit cleanups, and a few non-shorthand/named colors).Testing Instructions
npm run lint:css(ormake lint-css) — should pass with no errors.make lint-js/make test-js/make build— included here to confirm the change doesn't affect JS lint, unit tests (227 passing), or the Vite build.src/components/editor-toolbar/style.scss) and the visual editor toolbar/error boundary (src/components/visual-editor/style.scss) in both LTR and RTL (?lang=aror similar).Accessibility Testing Instructions
No UI/behavior changes — this is a build-tooling and CSS-property-name change only; visual output is unchanged (logical properties resolve to the same physical box-model values in LTR, which is this project's current default and only tested direction).