[eslint-plugin] Skip single-value flex in valid-shorthands - #1670
Merged
mellyeliu merged 1 commit intoMay 18, 2026
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
henryqdineen
requested review from
mellyeliu,
nmn and
vincentriemer
as code owners
May 17, 2026 02:01
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
mellyeliu
approved these changes
May 18, 2026
Contributor
|
Thanks for fixing this. We never upgraded the linter due to this restriction. |
2 tasks
This branch was previously deployed
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.
What changed / motivation ?
Single-value
flexusages (flex: 1,flex: 'auto',flex: 'none') are incorrectly flagged as errors byvalid-shorthands, with an autofix that expands them toflexGrow/flexShrink/flexBasis. This is inconsistent with the rule's stated purpose — enforcing single-value shorthands and longhands over multi-value shorthands — and inconsistent with how every other property in the rule behaves (border: 'none',margin: '8px'are both allowed).The root cause is the same as the gap issue fixed in #1668: the
flexshorthand alias expands even single values (e.g.flex: 1→flexGrow/flexShrink/flexBasis). Unlike other shorthands where a single value passes through unchanged,flex: 1expands to different values, so the existing same-key same-value check doesn't catch it. The post-transformer approach used in #1668 for gap doesn't work here either — gap's two output values happen to equal the original input, but flex's three output values don't.This PR adds an
isSingleTokenutility tosplitShorthands.jsthat checks whether a CSS value is a single top-level token before calling the transformer. It correctly handlesvar(),calc(), and!important. Multi-valueflex(flex: '1 0 auto',flex: '1 0') still correctly flags and expands.Linked PR/Issues
Follow-up to #1537, #1668.
Additional Context
6 single-value
flextest cases moved frominvalidtovalid. All 546 tests pass.Pre-flight checklist
Contribution Guidelines