Repository navigation
fix: stop CSS lint errors for the fr unit and custom properties - #639
Merged
imantsk merged 1 commit intoNov 27, 2026
Conversation
WordPress ships CSSLint 1.0.5, whose parser predates the fr unit and custom properties. Lint a copy of the code where 1fr becomes 1px and --name becomes -xname (same positions), and drop var() value warnings from known-properties. Fixes codesnippetspro#380, codesnippetspro#171, codesnippetspro#143.
imantsk
merged commit Nov 27, 2026
127fc71
into
codesnippetspro:release/v4.1.2/core
23 of 24 checks passed
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 #380, #171 and #143.
CSS snippets show lint errors for valid CSS. WordPress ships CSSLint 1.0.5, and its parser predates the
frunit and custom properties:grid-template-columns: 1fr 2frgives "Unexpected token '1fr'".--main-color: #fffgives "Expected RBRACE".color: var(--main-color)gives "Expected () but found 'var(--main-color)'".What I changed:
src/js/utils/cssLint.tsruns CSSLint on a copy of the code where1frbecomes1pxand--namebecomes-xname. Both rewrites keep every character position, so the markers stay on the right line and column. CSSLint reads-xnameas a vendor-prefixed property and does not validate it.known-propertieswarnings for a value that usesvar()are dropped, because CSSLint cannot resolve a variable.src/js/entries/editor.tsregisters this as the CodeMirrorcsslint helper, in place of the one from the WordPress CodeMirror bundle. It takes the same options, so the CSSLint ruleset from the WordPress settings still applies.Real problems are still reported: an unknown property such as
colrand a missing closing brace.Tests:
tests/e2e/css-lint.spec.tscalls the registered helper on the Add Snippet screen for thefrunit, custom properties withvar(), and two real errors. I checked the same cases against CSSLint 1.0.5 in Node: without the change the first two cases give the errors above, with the change they give none, and the real errors stay. I could not run the wp-env suite on this machine. ESLint andtscpass on the changed files. The spec passes the CSSLint ruleset fromwp.codeEditor.defaultSettings, as the editor does.