Repository navigation
fix: accept fr units in the CSS snippet linter - #597
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
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.
Summary
The CSS snippet editor shows a lint error on valid grid code like
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr). The CSSLint version bundled with WordPress (1.0.4) does not know thefrunit, so it reports "Unexpected token '1fr'" or "Expected RBRACE". This change wraps the CSS lint helper so CSSLint seespxin place offr. The saved code is not touched.Fixes #380
Changes
src/js/entries/editor.ts
Before:
The
lint/csshelper registered by WordPress ran CSSLint on the raw editor text.After:
Why:
frandpxhave the same length, so line and column of any real error stay the same. The lint options and the editor instance are passed through as they are. If the WordPress helper is missing, nothing changes.tests/e2e/css-lint-fr-units.spec.ts
New Playwright test. It first adds broken CSS and waits for an error mark, so we know the linter ran. Then it adds
frgrid code and expects no error marks.Testing
Test 1: Reported case
.a { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }.Result: no lint error.
Test 2: Other fr forms
repeat(3, 1fr),.5fr 2.25FRandgrid-template: "a b" 1fr / 1fr 2fr;in a CSS snippet.Result: no lint error.
Test 3: Real errors still work
1frand a missing closing brace.Result: one error on the missing brace line, with the same line and column as before.
.a { width: 10foo; }.Result: still flagged.
Test 4: No regressions
fr.Result: saved code still has
fr.Note:
frin a place where CSS does not allow it (for examplewidth: 1fr) is no longer flagged. Before this change it was only flagged by the same parse error that valid grid code got. Other CSSLint gaps (named grid lines,gap, custom properties) are out of scope here.