Skip to content

fix!: SLDS 2 linter fixes for legacy classes and hardcoded styles - #3366

Merged
interactivellama merged 9 commits into
fix/v11-event-union-typesfrom
chore/slds-linter
Nov 24, 2026
Merged

interactivellama merged 9 commits into
fix/v11-event-union-typesfrom
chore/slds-linter

Conversation

@interactivellama

Copy link
Copy Markdown
Contributor

Fixes #

Additional description

SLDS 2 (2.264.1) linter findings: legacy classes that SLDS 2 doesn't define, and hardcoded values that should read SLDS 2 styling hooks. Each fix is its own commit:

  • Styling hooks:
    • The radio swatch border and the tooltip line-height read --slds-g-* hooks, with the old values as fallbacks. Rendering is unchanged.
    • Carousel: the panel background uses --slds-g-color-surface-1 instead of white, so it follows the theme's surface color (for example Cosmos dark mode).
    • Tree: the loading skeleton reads its color, spacing, sizing and radius from --slds-g-* hooks, since SLDS 2 has no skeleton blueprint. The "Base with stencil" story now actually renders the skeleton: it passed a prop the example ignored.
  • Alert: uses the SLDS 2 variant classes (slds-alert_warning, slds-alert_error, slds-alert_offline) instead of slds-theme_alert-texture and slds-theme_*. Rendering is unchanged except offline, which now gets the alert component's neutral background.
  • Modal: the prompt header drops slds-theme_alert-texture, which SLDS 2 doesn't define. The ESLint plugin missed this one because the class was inside classNames(), so there's a regression test.
  • Button: iconVariant="global-header" uses slds-global-actions__item-action instead of the undefined slds-global-header__button_icon and slds-global-header__icon classes. Adds a GlobalHeaderIcon story.
  • Tabs:
    • The error icon drops slds-icon-utility-error, which SLDS 2 doesn't define. Adds a WithErrorTab story.
    • Breaking: deletes styles/tabs/tab.css, the opt-in disabled-tab stylesheet from 0.10.x. v11 publishes only dist, so the file no longer shipped, and it overrode SLDS classes. Remove any import of it. SLDS 2 doesn't style disabled tabs, so add your own CSS for .slds-disabled tab items if you need a visual cue.

Story snapshots are updated, and the regression tests are in each commit.


CONTRIBUTOR checklist (do not remove)

Please complete for every pull request.

Green gate — all of these must pass locally (CI runs the same):

  • npm run lint passes with 0 errors and 0 warnings (npm run lint:fix to auto-fix).
  • npm run typecheck is clean (tsc --noEmit).
  • npm test -- --run passes — this runs both Vitest projects (jsdom unit + real-browser browser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots with npm test -- --run -u and review the diff.
  • npm run build succeeds (type-check + Vite library build + .d.ts + entry shims).

Behavior & docs:

  • First-time contributors: sign the CLA (a bot will comment with instructions).
  • Added/updated Vitest + React Testing Library tests for the change (template: components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a *.browser.test.jsx file (the browser project); everything else is jsdom.
  • Reviewed the component's Storybook stories: npm run storybook → http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server).
  • Story/example code uses the component's real prop API (e.g. slots like content / visualPickerFigure, render props like renderItem, icon props, events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check against components/<name>/__examples__.
  • Storybook Accessibility (a11y) panel shows no new violations for the affected stories.
  • If you added or changed a type, remember runtime PropTypes were removed in the TS migration — types are the contract. Ship accurate .d.ts (they're generated by the build); JS consumers rely on them via editor type-acquisition.

REVIEWER checklist (do not remove)

  • CI is green (GitHub Actions CI workflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.
  • Change has adequate test coverage; bug fixes include a regression test.
  • Reviewed the affected Storybook stories and their a11y panels.
  • Rendered markup still conforms to SLDS — check the story HTML snapshot diff (components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).
  • Public API / package surface: if exports changed, the deep-import contract still holds (@salesforce/design-system-react/components/<name> and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change → feat!:/BREAKING CHANGE: and a major version bump.

… line-height

Replace the hardcoded 1px border on the swatch radio label with
var(--slds-g-sizing-border-1, 1px), and the tooltip trigger's line-height 1
with var(--slds-g-font-line-height-1, 1). Both hooks resolve to the same
values in the SLDS 2 (2.264.1) Cosmos and Lightning Blue themes, so
rendering is unchanged.
The carousel panel action hardcoded background-color: white, so it ignored
the theme's surface color (e.g. Cosmos dark mode). Use
var(--slds-g-color-surface-1, white), the hook SLDS 2 itself uses for
.slds-carousel__content, keeping white as the fallback.
SLDS 2 ships no skeleton or stencil blueprint, so the loading bars keep
their inline styles but read the color, spacing, sizing and pill radius
from --slds-g-* global hooks, with the previous values as fallbacks.
The story passed a loadingStencil prop that the example ignores, so it
never showed the skeleton. Use sample data where Nuts is expanded and
loading. The flag is static, not timer-driven, so the story is stable
in visual regression runs.
…y theme classes

Alert always added slds-theme_alert-texture, which SLDS 2 (2.264.1) does not
define, and themed each variant with the slds-theme_* utilities. The SLDS
alert blueprint only uses those on its legacy path; the current markup is
slds-notify slds-notify_alert plus slds-alert_warning, slds-alert_error or
slds-alert_offline, with info as the default. Those classes set the
--slds-c-alert-* hooks the SLDS 2 alert CSS reads.

Rendering is unchanged except offline, which now uses the alert component's
neutral-base-50 background instead of the utility's neutral-base-30.
A prompt Modal added slds-theme_alert-texture to its header, a class
SLDS 2 (2.264.1) does not define, so it did nothing. SLDS 2's prompt
blueprint styles the header through .slds-modal_prompt and the
slds-theme_<prompt> utility, which Modal still applies.

The SLDS React ESLint plugin missed it because the class is added
inside classNames(). Add a regression test.
…t="global-header"

iconVariant="global-header" added slds-global-header__button_icon to the
button and slds-global-header__icon to the SVG. SLDS 2 (2.264.1) defines
neither. Its global header CSS styles action buttons via
slds-global-actions__item-action (icon fill, size, hover/active/focus), and
the blueprint puts that class on every header action button. Use it on the
button and drop the icon class, which has no SLDS 2 equivalent: the size and
fill come from the button and slds-global-actions__item rules.

Add a GlobalHeaderIcon story that renders the button inside the global
header markup, since no story covered this variant.
…icon

A tab with hasError passed containerClassName="slds-icon_container
slds-icon-utility-error" to its error icon. SLDS 2 (2.264.1) does not define
slds-icon-utility-error. The SLDS tabs blueprint renders the error icon as a
plain slds-icon_container around an slds-icon_x-small slds-icon-text-error
SVG, which Icon already produces with colorVariant="error". Keep only
slds-icon_container, and point the test at slds-icon-text-error.

Add a WithErrorTab story, since no story covered hasError.
styles/tabs/tab.css was opt-in CSS for disabled tabs that 0.10.x told
consumers to import from the package. v11 publishes only dist, so the
file no longer ships, and nothing in the repo imports it. It overrode
slds-tabs_*__link and slds-has-focus with a hardcoded color, which the
SLDS linter flags (no-slds-class-overrides).

Also drop the stale comment in the private Tab component that pointed
at it. Rendered markup is unchanged: a disabled tab still gets
slds-disabled and aria-disabled="true".

BREAKING CHANGE: styles/tabs/tab.css is removed. Remove any import of
it; SLDS 2 does not style disabled tabs, so add your own CSS for
.slds-disabled tab items if you need a visual cue.
@interactivellama interactivellama added this to the 11.0.0-rc.1 milestone Nov 23, 2026
@interactivellama
interactivellama merged commit ee626d9 into master Nov 24, 2026
7 checks passed
@interactivellama
interactivellama deleted the chore/slds-linter branch November 24, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants