Repository navigation
fix(core): a shorthand never follows its own longhand in one style merge - #12316
josephfarina wants to merge 3 commits into
Conversation
…rge, with a lint rule
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested. The new rule and the List, Stepper, PowerSearch and DiffViewer edits work: the rule finds the five sites on main, it finds none on this branch, and the component tests pass. Two claims need to match what the change does:
SideNavHeading.tsx:95-96shrinks a collapsed SideNav heading that has an icon but noheadingHreformenufrom 40px to 32px and moves its icon 4px to the centre, in Storybook and in the published CSS alike, which the description calls no visible change and the changeset leaves out, so either keep the old rendering or announce the centring and get it decided.- The changeset says three components "now look the same in Storybook and in the published CSS" (line 5), but at the base the ordered List with dividers, the vertical on-track Stepper and the PowerSearch sheet trigger with tokens already rendered pixel-identical in both builds, so reword the release note and the description to say that only computed values change.
Two optional notes are inline: the rule's local constants are matched by name across the whole file, and the README's "the later style wins" does not hold in Storybook for paddingInline after its own longhands.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims:
- Storybook compiles StyleX with application-order: verified (Storybook main and Vite configs).
- The published build uses property-specificity: verified (Core's Babel config sets no option; StyleX 0.19.1 defaults to it).
- A shorthand before its longhand resolves the same in both builds: verified.
- A shorthand after its longhand resolves differently: partly false; for
paddingInlineafter its own longhands, the longhand wins in both builds. - Three components looked different in Storybook and in the published CSS: false; computed values differed, but frames match at the base.
- After the change each listed state has one computed value in both builds: verified.
- An ordered List with dividers keeps its number-to-text gap: verified; the published gap was already 8px.
- The Stepper connector can shrink: misleading; flex-shrink is now 1 everywhere, but its zero basis leaves its size unchanged.
- The PowerSearch sheet trigger with tokens has no padding: verified for computed values; the button is empty, so nothing changes on screen.
- The SideNavHeading site did not diverge: verified.
- The SideNavHeading site has no visible change: false; the collapsed icon-only heading narrows and its icon moves 4px.
- The DiffViewer marker style never applied and its removal changes nothing: verified from the StyleX expansion and the same pattern measured on SideNavHeading.
- The rule reads same-file styles, dynamic styles and local constants, and ignores opposite branches: verified (test cases and code).
- The rule reports nothing on this branch and five sites on
main: verified. - The rule test passes, and a seeded bad case fails it: verified.
- The component tests pass: verified (22 files, 823 tests).
- Splitting base shorthands would break callers: not checked (describes an alternative this change does not ship).
- All page templates are unchanged: not checked.
- Fixture screenshots match apart from the listed values: partly false; the collapsed SideNav heading frame changes.
- No new visual representation is hidden under the fix label: false (SideNavHeading).
- Public text carries no internal context: verified.
- The new lint rule flags the pattern: verified.
Files:
.changeset/shorthand-after-longhand.md: release-note claims (both findings).eslint.config.js: clear.internal/eslint-plugin-astryx/README.md: optional wording note.internal/eslint-plugin-astryx/index.js: clear.internal/eslint-plugin-astryx/no-shorthand-longhand-merge.js: optional scope note.internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjs: clear.packages/core/src/List/List.tsx: clear.packages/core/src/PowerSearch/PowerSearch.tsx: clear.packages/core/src/SideNav/SideNavHeading.tsx: unannounced visible change (first finding).packages/core/src/Stepper/Step.tsx: clear.packages/lab/src/DiffViewer/DiffViewer.tsx: clear.
| VariableDeclarator(node) { | ||
| if (node.id.type !== 'Identifier' || !node.init) return; | ||
| if (!isStylexCall(node.init, 'create')) { | ||
| locals.set(node.id.name, node.init); |
There was a problem hiding this comment.
Optional: locals is keyed by name for the whole file. Two components in one file that each declare, say, const side = … resolve to whichever is declared last. Resolving the identifier through its scope (context.sourceCode.getScope(node)) keeps each merge to its own constant.
…note and rule docs say computed values
There was a problem hiding this comment.
Approved pending CI: the CI run on this head found no room under the CI ceiling ("CI is full"), so its jobs need a re-run before merge.
Both earlier change requests are fixed: the collapsed SideNavHeading with only an icon keeps its 40px box and icon position in Storybook and in the published resolution, and the changeset now says that only computed values change. The rule reports the five sites on main and none on this branch, and the List, Stepper, SideNav, PowerSearch and DiffViewer tests pass.
Two optional notes: the new comment at SideNavHeading.tsx:97 could keep only its reason (inline), and the rule still matches local constants by name across the whole file (the open thread on its line 261).
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
Claims:
- The release note's three styles now set longhands instead of a later shorthand: verified (
List.tsx:286,Step.tsx:839-843,PowerSearch.tsx:262-267). - Each of those states had two computed values and now has one: verified (List column gap 0px/8px to 8px/8px, Stepper flex-shrink 1/0 to 1/1, PowerSearch inline padding 0px/4px to 0px/0px).
- Nothing changes on screen in either build: verified (base and head frames pixel-identical in both resolutions).
- A new lint rule flags the pattern: verified (rule test; five findings on
main, none on this branch). - The three states differed in computed style between Storybook and the published CSS, as the table gives: verified.
- They rendered the same in both builds at the base: verified.
- Storybook compiles with application-order: verified (Storybook main and Vite configs).
- The published build uses property-specificity: verified (Core's Babel config sets no option; StyleX 0.19.1 defaults to it).
- A shorthand before its longhand resolves the same in both builds: verified.
- A shorthand after its longhand resolves differently: verified, with the exception the description names (an inline-padding shorthand after its own longhands applies in neither build).
- The later style now sets the same properties, so it wins in every build, matching what Storybook showed: verified (for List, the base list style sets the gap shorthand and the divider style now sets the row gap).
- The List column gap between number and text stays: verified (8px in both builds; an unordered divided list now computes a 2px column gap that its one-column layout does not use).
- The plain collapsed SideNav heading keeps its 40px width and icon position, and the other collapsed forms are unchanged: verified (fixture in both builds, base and head).
- The DiffViewer marker style never applied and removing it changes nothing: verified (StyleX expansion and the same pattern measured on SideNavHeading).
- The rule is an error in strict lint and a warning in recommended lint: verified (plugin index).
- The rule reads same-file styles, dynamic styles and local constants, and two branches of one conditional never merge: verified (tests and code).
- The rule reports nothing on this branch across core, lab, charts and richtext, and five sites on
main: verified. - The rule test passes, and seeding a bad case fails it: verified.
- The component tests pass: verified (22 files, 823 tests).
- Splitting base shorthands into longhands would break callers: verified in mechanism (an in-package caller such as Markdown, which passes its own styles to List, shares the component's layer, where a longhand beats a shorthand); the 8px figure was not reproduced, since the alternative is not shipped.
- Fixture screenshots match before and after at desktop and phone widths, light and dark, in both builds: verified (1280px and 390px, light and dark, base and head frames pixel-identical in both resolutions).
- No page template moves: verified from the styles (each computed change is inert in its own layout, and no template overrides a divided List's layout); the templates were not rendered.
- No new public API, visual representation, default or interaction is hidden under the fix label: verified (API surface unchanged; frames identical).
- Public text carries no internal context: verified.
Files:
.changeset/shorthand-after-longhand.md: clear.eslint.config.js: clear.internal/eslint-plugin-astryx/README.md: clear.internal/eslint-plugin-astryx/index.js: clear.internal/eslint-plugin-astryx/no-shorthand-longhand-merge.js: optional note (local constants matched by name across the file).internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjs: clear.packages/core/src/List/List.tsx: clear.packages/core/src/PowerSearch/PowerSearch.tsx: clear.packages/core/src/SideNav/SideNavHeading.tsx: optional comment wording note.packages/core/src/Stepper/Step.tsx: clear.packages/lab/src/DiffViewer/DiffViewer.tsx: clear.
| justifyContent: 'center', | ||
| paddingInline: 0, | ||
| }, | ||
| // The plain collapsed heading keeps root's inline padding and only centres. |
There was a problem hiding this comment.
Optional: this comment restates what rootCollapsedCentered sets and leaves out why the padding has to stay. A version that keeps only the reason: // Keep root's inline padding. Without it, the plain heading narrows and its icon moves.
There was a problem hiding this comment.
Approved pending CI: the CI run on this head found no room under the CI ceiling ("CI is full"), so its jobs need a re-run before merge.
The only new commit reformats the rule file with Prettier, and its code is unchanged. The rule still reports the five sites on main and none on this branch, the List, Stepper, SideNav, PowerSearch and DiffViewer tests pass, and those components render the same before and after, in Storybook and in the published CSS.
Two optional notes stay open: the comment at SideNavHeading.tsx:97 could keep only its reason, and the rule matches local constants by name across the whole file (its line 284).
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
Claims:
- The release note's three styles now set longhands instead of a later shorthand: verified (
List.tsx:286,Step.tsx:840-842,PowerSearch.tsx:266-267). - Each of those states had two computed values and now has one: verified (List column gap 0px/8px to 8px/8px, Stepper flex-shrink 1/0 to 1/1, PowerSearch inline padding 0px/4px to 0px/0px).
- Nothing changes on screen in either build: verified (base and head frames pixel-identical in both resolutions).
- A new lint rule flags the pattern: verified (rule test; five findings on
main, none on this branch). - The three states differed in computed style between Storybook and the published CSS as the table gives, and rendered the same at the base: verified.
- Storybook compiles with application-order and the published build uses property-specificity: verified (Storybook main and Vite configs; Core's Babel config sets no option, and StyleX 0.19.1 defaults to property-specificity).
- A shorthand before its longhand resolves the same in both builds, and one after it does not: verified, with the exception the description names (an inline-padding shorthand after its own longhands applies in neither build).
- The later style now sets the same properties, so it wins in every build and matches what Storybook showed: verified.
- The List column gap between number and text stays: verified (8px in both builds; an unordered divided list now computes a 2px column gap that its one-column layout does not use).
- The plain collapsed SideNav heading keeps its 40px width and icon position, and the other collapsed forms are unchanged: verified (fixture in both builds, base and head).
- The DiffViewer marker style never applied, so removing it changes nothing: verified (StyleX's expansion of the inline-padding shorthand; the same pattern measured on SideNavHeading).
- The rule is an error in strict lint and a warning in recommended lint: verified (plugin index; the root config adds it for Lab and charts).
- The rule reads same-file styles, dynamic styles and local constants, and two branches of one conditional never merge: verified (tests and code).
- The rule reports nothing on this branch across core, lab, charts and richtext, and five sites on
main: verified. - The rule test passes, and seeding a bad case into its valid list fails it: verified.
- The List, Stepper, SideNav, PowerSearch and DiffViewer tests pass: verified (22 files, 823 tests).
- Splitting base shorthands into longhands would break callers: verified in mechanism; the 8px figure was not reproduced, since that alternative is not shipped.
- The same tree built twice with only the resolution differing gives the before and after values listed: verified.
- Fixture screenshots match before and after in both builds: verified at 1280px in light; 390px and dark were verified at the previous revision, and the component code is unchanged since.
- No page template moves: verified from the styles; the templates were not rendered.
- No new public API, visual representation, default or interaction is hidden under the fix label: verified (API surface unchanged; frames identical).
- Public text carries no internal context: verified.
Files:
.changeset/shorthand-after-longhand.md: clear.eslint.config.js: clear.internal/eslint-plugin-astryx/README.md: clear.internal/eslint-plugin-astryx/index.js: clear.internal/eslint-plugin-astryx/no-shorthand-longhand-merge.js: optional note (local constants matched by name across the file); the new commit only reformats it.internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjs: clear.packages/core/src/List/List.tsx: clear.packages/core/src/PowerSearch/PowerSearch.tsx: clear.packages/core/src/SideNav/SideNavHeading.tsx: optional comment wording note.packages/core/src/Stepper/Step.tsx: clear.packages/lab/src/DiffViewer/DiffViewer.tsx: clear.
- #12252 docs(cli): agent docs name the prop names that differ from other libraries Author: Joey Farina <[email protected]> - #12154 fix(core): a numeric typography weight builds through an extended base's adaptation rules Author: Joey <[email protected]> - #12092 fix(cli): theme build reads the Core it builds with for variant declarations, and names the build command alone Author: Joey Farina <[email protected]> - #12316 fix(core): a shorthand never follows its own longhand in one style merge Author: josephfarina <[email protected]> - #12357 fix(core): a Table stays the scroll region when a host scrolls every table's parent Author: Joey Farina <[email protected]> - #12349 fix(core): end a mouse drag a sandboxed frame never saw released Author: josephfarina <[email protected]> - #12425 fix(cli): use a stored doc parse only with the zod release that made it Author: Joey <[email protected]> - #12396 fix(AppShell): with the standard width points, a server-rendered shell hides its inline side nav on a phone before its script runs Author: Joey <[email protected]> - #12438 fix(charts): end dots draw whole and a thinned axis keeps its last label Author: Joey Farina <[email protected]> - #12448 fix(cli): upgrade outside a project names the project, not --from Author: Joey Farina <[email protected]> - #12459 fix(templates): the dashboard scorecard fits a phone screen Author: Joey Farina <[email protected]> - #12428 fix(core): Field labels draw in a bolder face than their description Author: Joey Farina <[email protected]> - #12435 fix(theme-matcha): dark menus, popovers and muted fills take the theme's deep gray neutral Author: Joey <[email protected]> - #12432 fix(templates): dashboard chart labels show whole instead of clipped by the chart edge Author: Joey Farina <[email protected]> - #12441 fix(cli): mark icon-set generated calls pure so apps drop unused icons Author: Joey Farina <[email protected]> - #12472 fix(MetadataListItem): a value breaks only a word longer than its line Author: Joey <[email protected]>
|
Landed in #12718. |
User impact
Three component states had a different computed style in Storybook and in the published CSS. On screen they rendered the same in both builds at the base, so this is about computed values, not pixels:
ListwithhasDividers: column gap between number and textStepper,indicatorPosition="on-track": flexible connectorflex-shrinkPowerSearchbottom-sheet trigger with tokens: inline paddingEach one is a style merge where a later style sets a shorthand (
gap,flex,padding) after an earlier style sets one of its longhands (columnGap,flexShrink,paddingInline).Problem and solution fit
styleResolution: 'application-order', where the later style wins. The published build usesproperty-specificity, where a longhand beats a shorthand whatever the order. A shorthand placed before its longhand resolves the same way under both. A shorthand placed after its longhand does not.Expected behavior and authority
A component paints the same in every supported build of its CSS. Each state above now has one value under both resolutions.
Smallest restoration
ListwithDividers:gap: 0→rowGap: 0. The column gap between number and text stays.StepperotSegFlexV:flex: 1→flexGrow: 1, flexShrink: 1, flexBasis: '0%'.PowerSearchtriggerWithTokens:padding: 0→paddingBlock: 0, paddingInline: 0.SideNavHeading: the plain collapsed heading (an icon, no link or menu) mergedrootwithrootCollapsed, whosepaddingInline: 0came afterroot's longhands and so applied in neither build. That merge now usesrootCollapsedCentered(justifyContent: 'center'only), so the heading keeps its 40px width and icon position exactly as before. The otherrootCollapsedmerges are unchanged.DiffViewer: removesmarkerSlim(paddingInline: 0after the marker's longhands). It never applied in either build (measured: the marker keeps 4px/8px in both), so removing it changes nothing.@astryx/no-shorthand-longhand-merge(strict: error, recommended: warn), flags a shorthand after one of its own longhands in onestylex.props()call orxstylearray. It reads same-filestylex.create()styles, dynamic styles, and local constants that pick a style. Two branches of one conditional never count as a merge. It reports nothing on this branch across core, lab, charts and richtext. On main it reports the five sites above.Not changed: splitting base shorthands into longhands everywhere. Measured, that breaks callers: a caller's
xstyleshorthand then loses to the component's new longhand in the published CSS. That moved Markdown list indents by 8px in two page templates.Evidence
styleResolutiondiffering. Computed values before → after:vitestfor List, Stepper, SideNav, PowerSearch and DiffViewer passes.Scope
Components: List, Stepper, PowerSearch, SideNav, DiffViewer (lab); lint plugin
Testing
node internal/eslint-plugin-astryx/no-shorthand-longhand-merge.test.mjseslintwith the rule overpackages/{core,lab,charts,richtext}/src: 0 findings (5 on main).vitest run packages/core/src/{List,Stepper,SideNav} packages/core/src/PowerSearch/PowerSearch.test.tsx packages/lab/src/DiffViewerstyleResolutionoptions, before and after.