Skip to content

feat!: remove utilities and private folders from the package exports - #3328

Closed
interactivellama wants to merge 59 commits into
feat/v11-llm-4-deprecated-lintfrom
feat/block-private-exports
Closed

interactivellama wants to merge 59 commits into
feat/v11-llm-4-deprecated-lintfrom
feat/block-private-exports

Conversation

@interactivellama

Copy link
Copy Markdown
Contributor

Part of the v11 merge train, stack 1 "clean CI": ci-warnings → react-hooks-refs → deprecated-dom-apis → deprecated-prop lint (#3311) → private exports.

Additional description

This makes the exports map match the public API: internals under utilities/ and components/**/private/ stop being importable, and every type that public props refer to becomes nameable from a public entry point.

  • feat: export the types used in public prop signatures (TriggerRender, ChildrenOf, IconCategory, the Combobox option types, CarouselItemProps, SplitViewListItem, the PageHeader legacy subcomponent props). Shared types move out of private/ into public types.ts files. The root barrel becomes components/index.ts so it can export types; the drifted hand-written components/index.d.ts and components/settings.d.ts are removed.
  • feat!: remove utilities/* and components/**/private/* from exports. private folders and check-props modules map to null, so import/require throw ERR_PACKAGE_PATH_NOT_EXPORTED and TypeScript can't resolve them. The build stops emitting utility entries and shims, and build:types prunes internal .d.ts files no public declaration imports (scripts/prune-internal-types.ts).
  • Tests: check-package-exports asserts against the built package that every internal module fails to resolve (types under bundler and node16, import and require; runtime import()/require()), and that every type in a public signature is declared in a public file and exported by name.
  • Docs: a BREAKING CHANGELOG entry with the 0.10.x deep imports most likely in use and how to migrate; codebase-overview states the public-surface rule and adds entry points to the breaking-change taxonomy.

It sits at the top of this stack so its exported type list matches the final signatures after deprecated-dom-apis (onKeyDown, React 19 event types, RefObject), and it passes #3311's no-deprecated = error.

Breaking: @salesforce/design-system-react/utilities/*, …/components/*/private/* and the check-props modules no longer resolve. They were never public API, but they were reachable.

Commits
  • feat: export the types used in public prop signatures
  • feat!: remove utilities and private folders from the package exports
  • test: assert internals are not entry points and prop types are public
  • docs: record that utilities and private folders are not entry points

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 (npm run lint:fix to auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.
  • 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.

@interactivellama
interactivellama force-pushed the feat/v11-llm-4-deprecated-lint branch from d141e7a to b0bf46f Compare November 17, 2026 02:10
`build.lib.formats` duplicated the `rollupOptions.output` array, so Vite
ignored it and warned on every build. The emitted dist/ files are
byte-identical without it. `jsxBracketSameLine` was removed in Prettier 3.
Fixtures rendered controlled components (ColorPicker, DatePicker, Slider,
ButtonStateful, Tree, Checkbox, SimpleDataTable) without their required
change handler, so every render logged an "is required by" error. Input and
ColorPicker fixtures also passed both label and assistiveText.label.

Fixtures now pass a no-op handler. Tests that cover the missing-handler or
both-labels path keep that input and silence the expected error with a spy.
General tests used APIs deprecated in v11 (ProgressIndicator completedSteps
and errorSteps, Tooltip children as trigger, Tree onClick/onExpandClick and
node.selected, Radio onRenderVisualPicker), so they logged deprecation
warnings that hid real ones. They now use the replacement APIs.

Tests that exercise a deprecated path on purpose (Combobox inline-listbox
multiple and action item onClick, Checkbox onRequestFocus, the
ProgressIndicator arrays) keep it and silence or assert the warning with a
spy. Removal tests for defaultValue and singleInputDisabled restored their
spy before the follow-up render, which warned again from the component's
fresh check-props instance; the spy now covers that render.

No props are removed: these were all deprecated in v11 and stay through 11.x.
ProgressIndicator path tests focused and clicked stages outside act(); the
focus handler moves the roving tab stop, a state update, so React warned.
They now run inside act().

Carousel and VerticalNavigation click tests clicked real links without
preventing the default action, which jsdom cannot perform and reports as
"navigation to another Document" being unimplemented. Their handlers now
call preventDefault, as the neighbouring tests already do.
Root cause: `ButtonProps.responsive` is declared but was never
destructured, so it reached `<button>` through `restProps` and React
warned about a non-boolean attribute. 0.10.x declared the prop and never
applied it; the v11 rewrite started leaking it to the DOM.

Button now destructures it. It stays a documented no-op, not deprecated.
Root cause: Button always defaulted `type` to `button`, and browsers ignore
`formAction` on a `type="button"` button, so a Button given `formAction`
without an explicit `type` did nothing on click and React warned.

When `formAction` is set and `type` is not, `type` now defaults to `submit`.
An explicit `type` still wins, and without `formAction` the default stays
`button`.

Behaviour change for consumers: a Button with `formAction` and no `type`
now submits its form, as `formAction` implies.
Root cause: `SimpleDataTableInteractiveElement` injects `onOpen` and
`onClose` into every element it wraps, so a wrapped `MenuDropdown` can turn
table keyboard navigation off while it is open. Button spread unknown props
onto `<button>`, so a wrapped Button rendered them and React warned about
an unknown `onOpen` event handler.

Button now destructures them, as it already does for `triggerClassName`.
The wrapper is unchanged, so MenuDropdown cells keep their open/close
tracking. Checkbox never spread its rest props onto the DOM; a regression
test covers both.
Drops unused variables, parameters and imports, removes initial values that
were always overwritten (no-useless-assignment), removes console.log calls
from test handlers, and associates the Panel story's labels with their
selects. Also deletes the unused `handleClickOutside` callbacks in Combobox
and Popover; click-outside is handled by Dialog.

No behaviour change. The Panel story snapshot gains the label `for` and
select `id`.
Behaviour fixes:
- tree: branch treeitems now set aria-selected, as leaf items already
  did. Branches were announced with no selection state.
- simple-data-table: the row's memoized cells depend on
  tableContext.isGrid, so the select cell's gridcell role follows
  keyboardNavigation instead of keeping the role from the first render.
- pill-container: the reset effect lists resetActiveSelectedOption,
  which is defined before it.
- filter: handleChange lists setPopoverIsOpen (a stable setter).

Accepted with a reason: the mount-only check-props and app-element
checks in modal and tooltip, and the src jsx-a11y sites whose markup
follows SLDS (anchors as tabs, options and heading links; click
handlers whose keyboard path lives on the focusable element or the
listbox). Each disable names its reason.

Lint-only cleanups: the unused combobox wrapper ref and its no-op
click-outside hook (the menu closes on input blur; popover handles
its own click-outside), the combobox non-null assertion, and the
empty SimpleDataTableSelection interface.

Docs and examples: placeholder href="#" anchors get fragment targets.
Story snapshots updated.
Lint is at 35 warnings, all from the React Compiler rule set
(react-hooks/refs and set-state-in-effect). They are carried past
11.0 GA. The lint script now fails above 35, so the count can only go
down. Recorded in ROADMAP.md.
These four files predate the prettier config and still used spaces. The
next two commits touch them, and lint-staged reformats a whole file when
it is staged, so format them on their own first to keep those diffs
readable.
Every warn-once helper in utilities/warning, plus the ColorPicker and
DatePicker missing-value checks, now keeps its warned keys in a map
from warned-registry. resetWarnings() clears them all, and both
Vitest setup files call it after each test. In an app nothing calls
it, so each message still prints once per page load.

Tests no longer need vi.resetModules() and a dynamic import to see a
warning. Two tests that only passed because an earlier test had used
the warn-once slot now assert what they meant: the checkbox test looks
for React's controlled/uncontrolled message only, and the progress
indicator test compares call counts across the re-render.
vitest.console-guard.ts, loaded by both setup files, fails any test
that writes to console.error or console.warn. A test that expects a
warning spies on the console itself, which bypasses the guard.
console.log is not guarded.

The guard caught one more source: the combobox renderMenuItem tests
open the menu at mount, and floating-ui's async positioning updated
SLDSDialog after the test ended (an act warning). They now use
menuPosition="relative", as the other open-state tests do.

`vite build` now fails on any warning: Vite's own warnings through a
throwing logger (build command only, so dev and Storybook keep the
default), and bundler warnings through onwarn.
Storybook's react-docgen-typescript plugin parses every *.tsx file
except stories. The Tree docs' sample data, __docs__/dynamic-hashmap.tsx,
is outside the TypeScript project (tsconfig excludes __docs__), so the
plugin warned that it was skipping it. Since the build now fails on any
warning, storybook build stopped there.

The file has no JSX, so it is now dynamic-hashmap.ts, which docgen
does not parse.
Root cause: `build-storybook` loads vite.config.ts with `command: 'build'`,
so the warning-to-error logger from 27b8582 also applied to Storybook. On
the Chromatic runner, Rolldown's PLUGIN_TIMINGS hint ("Your build spent 79%
... inside plugin hooks") is logged through that logger and failed the
build. The hint depends on runner speed, which is why it doesn't reproduce
locally.

Use the throwing logger only when Storybook is not the caller (Storybook
sets STORYBOOK=true before loading the config). Also turn off
`checks.pluginTimings` for the library build, so a slow CI machine can't
fail it with the same hint.
Root cause: four warn-once helpers set their flag to a value unrelated to
whether they warned.

- `is-trigger-tabbable` set it to `false`, so the warning repeated on every
  render.
- `if-one-then-both-required-property`, `only-one-of-properties` and
  `one-of-required-property` set it to `!!selectedProps`, which is always
  true. A valid first render used up the warning, so a later invalid one
  never warned.

Each now sets the flag from its own check, as `required-property` does.
Vite and Rollup warnings are printed again instead of thrown. Failing the
build on any warning made `npm run build`, and Storybook through the shared
config, depend on warnings outside the repo's control: Rolldown's
PLUGIN_TIMINGS hint failed Chromatic on a slow runner.

This reverts the throwing logger and `onwarn` from 27b8582 and the
Storybook carve-out from the previous commit. The redundant
`lib.formats` stays removed, so the build is still warning-free today.
Tests: the console guard now records unexpected console.error and
console.warn output on each test instead of throwing. A new Vitest
reporter (scripts/vitest-console-reporter.ts) lists it after every run
and, on GitHub Actions, annotates each test file and adds a table to the
job summary. The run fails once the total is over `maxWarnings`, which
starts at 0, so today's behaviour is unchanged.

Lint: a formatter (scripts/eslint-github-formatter.cjs) keeps the
stylish output and, on GitHub Actions, annotates each problem on its line
and lists them all in the job summary, since GitHub shows only the first
10 annotations per step. `--max-warnings=35` still decides failure.
React Compiler rules report the same location once per use of the value, so
one ColorPicker line produced 9 identical annotations and filled GitHub's 10
visible annotations. Annotate each location and rule once, with a count. The
job summary still lists every problem, and --max-warnings still counts them.
ColorPicker, Combobox, DatePicker and Tooltip kept their generated id
in useRef(generateId()) and read .current during render, which the
react-hooks/refs rule reports. The id now lives in
useState(generateId): it is still created once per mount and stays
stable, and generateId no longer runs on every render.

generateId is kept rather than useId because Tooltip puts the id in a
CSS selector, and useId output is not a valid CSS identifier.
getAnchoredNubbinStyles called triggerRef.current.getBoundingClientRect()
during render. The trigger is now measured in a layout effect when an
anchored-nubbin tooltip opens or its align changes, and the size is
kept in state. The effect runs before paint, so the nubbin is placed
on open with no visible jump. A trigger that resizes while the tooltip
stays open keeps its offset until the next open.

The new test stubs the trigger at 40x20 and checks the bottom-aligned
nubbin sits at 20px/20px. It passes before and after the change; it
pins the positioning that jsdom's zero-size layout never exercised.
The refs rule follows ref reads through functions called during
render, so Combobox and Tooltip still reported after the id change:

- Combobox built input onChange handlers with withInputOnChange(...)
  in each sub-render. They are now two memoized handlers:
  handleInnerInputChange, and handleInnerInputChangeWhileUnselected for
  the single-selection variants that ignore typing once an option is
  selected.
- Combobox called getCustomPopoverProps(body) in renderPopover and
  read the merged props' id. The props are now memoized as
  customPopoverProps, and the popover id comes from the popover prop.
- Tooltip passed the trigger props (and their handlers) to
  renderTrigger from its own render. The trigger slot now renders
  through a small TooltipTrigger component.

Rendered output and handler behaviour are unchanged.
handleCloseRef was assigned during render so the open-dropdown
registration could call the latest handleClose. It now uses
useLatestRef, which updates the ref in an insertion effect. Its only
reader is another dropdown's open handler, which runs after commit.
Prettier output only: wrap the keyboardNavigate declaration and drop the trailing blank lines.
…gger

componentContext captured triggerRef.current in a useMemo, so the
value was frozen when the memo ran: null on the first render, and only
refreshed when handleClick changed identity. keyboardNavigate's
"Enter/Down on the closed trigger also clicks it" branch therefore ran
or not depending on timing. Pressing Enter on a closed trigger called
onClick 0 times the first time; the second time it called onClick
once and onRequestOpen twice, because handleClick's stale getIsOpen
opened the menu again after toggleOpen had.

componentContext now exposes getTrigger(), read at keydown time, and
its handleClick only reports onClick: toggleOpen has already opened
the menu. Each keyboard open from the trigger now reports onClick,
onRequestOpen and onOpen exactly once. 0.10.x (componentContext was
the component instance, so the trigger was always current) also
called onClick once, but went through handleOpen twice.

The new test presses Enter on the closed trigger over two open/close
rounds and fails without this change.
… width in state

The width measured on mount was kept only in initialStageWidthRef and
read during render for the item width. It is now state, set in the
mount effect next to stageWidth, so both updates batch into one
render.

That change made the effect that copied the panel offset into
translateX state report set-state-in-effect. translateX is now derived
during render from the width and currentPanel, which also drops a
render per panel change. Until the stage is measured it keeps the old
off-screen value (-1000000), so first paint is unchanged.
Portal kept its container node in portalNodeRef next to an isMounted
flag, and render read the ref to call createPortal. The attached node
is now state: the mount effect sets it where it used to set isMounted,
and render portals into it. The effects still use the ref. It is the
same single extra render as before, and under StrictMode the double
mount still removes the first node before creating the second.

The setState in the mount effect still reports set-state-in-effect;
the next commit documents why it stays.
The portal node has to be appended to its parent before the children
mount, because Dialog measures its target in its own effects and child
effects run before parent effects. Creating the node in render would
put a DOM side effect in render, and creating it later would mount
the children into a detached node. This is the "sync with an external
system" case the rule allows but cannot detect, so it gets an inline
disable with the reason, as docs/codebase-overview.md asks.
…ch Radios

The swatch toggle passed checked to each Radio inside a RadioGroup. The
group's value already sets checked, and RadioGroup only warns about
checked when it has no value, so nothing changes at runtime; this
removes the deprecated use so the source passes no-deprecated.
…ntainerStyle

style lands on the same container, so the markup is unchanged and the
development warning is gone.
local/no-deprecated (eslint-rules/no-deprecated.mjs) wraps
@typescript-eslint/no-deprecated and skips only symbols declared under
the same components/<name>/ or utilities/<name>/ directory as the file
using them: a component honoring its own deprecated prop during the
11.x RC. Another component's deprecated prop, or a deprecated React or
DOM API, is an error. It covers components/, utilities/ and types/;
tests, examples and stories are configured separately.

This exempts a kind of use rather than a per-file count, which ESLint's
bulk suppressions would have done, letting a new deprecated use hide
behind a removed one. The four components that forward their own
deprecated onKeyPress to React's deprecated onKeyPress carry an inline
disable until 11.0 removes the prop.
@interactivellama
interactivellama force-pushed the feat/v11-llm-4-deprecated-lint branch from b0bf46f to ea214ae Compare November 17, 2026 02:47
@interactivellama
interactivellama force-pushed the feat/block-private-exports branch from fb348f9 to 6643027 Compare November 17, 2026 02:47
On CI, linting the fixtures crashed inside TypeScript
(getLocalModuleSpecifier -> normalizeSlashes(undefined)): with bundler
resolution and neither paths nor baseUrl, TypeScript 6 has no base
directory when it computes a module specifier. The repo tsconfig sets
paths, so only the fixture project hit it.
CI sets CI=true, which makes typescript-eslint infer a single CLI run.
That mode isn't meant for several ESLint instances in one process: on
the second lint, TypeScript crashed resolving the fixture's import
(getLocalModuleSpecifier -> normalizeSlashes(undefined)). Opt out with
disallowAutomaticSingleRunInference, and drop the fixture paths entry
from the previous commit, which didn't help. Reproduces locally with
CI=true.
…alog

internalHandleClick called handleClick(event) with no event in scope,
so it read the deprecated global window.event, and it compared the
trigger through ReactDOM.findDOMNode, which React 19 removed. Popover
attaches the handler only to the open dialog and this branch runs only
when closed, so it was unreachable and nothing changes at runtime; it
now takes the event and compares the trigger element directly.
The JavaScript block turns off type information, so local/no-deprecated
saw nothing in .js/.jsx source. Give it the project back. The one false
positive, the createElement feature check in execution-environment,
carries an inline disable.
Skip computed object keys, which name a value rather than a property, and
get parser services through ESLintUtils so a file outside the project fails
with the upstream message.
tseslint.config is deprecated in favor of ESLint's own defineConfig.
Every type that a public component's props refer to is now declared in a
public file and can be named from a public entry point, so consumers don't
need a deep import into `utilities/` or a `private/` folder:

- `TriggerRender` moves to `types/common` and is exported from the root,
  `components/tooltip` and `components/menu-dropdown`.
- `ChildrenOf` and `IconCategory` are exported from the root, and
  `IconCategory` from `components/icon`.
- The combobox option types move from `private/menu` to a new
  `components/combobox/types.ts`. `components/combobox` now also exports
  `ComboboxOptionIcon`, `ComboboxOptionLabelRenderer`,
  `ComboboxActionOptionFields` and `ComboboxMenuRenderMenuItemData` (renamed
  from the private `MenuRenderMenuItemData`).
- `CarouselItemProps` moves to `components/carousel/types.ts`,
  `SplitViewListItem` to `components/split-view/types.ts`, and the props of
  page-header's legacy `Info`, `Title`, `DetailRow` and `DetailBlock` exports
  to `components/page-header/types.ts`. They are exported from
  `components/carousel`, `split-view/listbox` and `components/page-header`.
  The private implementation files import them from there.

The root barrel becomes `components/index.ts` so it can export types. Its
shipped declarations were already generated from `index.js`; the unused
hand-written `components/index.d.ts` (which had drifted from it) and the
ambient `components/settings.d.ts` are removed.
The `exports` map no longer publishes internals:

- `./utilities/*` is removed.
- Every `components/**/private` folder and everything under it, and every
  `check-props` module, map to `null`, so `import` and `require` throw
  `ERR_PACKAGE_PATH_NOT_EXPORTED` and TypeScript can't resolve them. Each
  `private` folder is listed explicitly: Node picks the pattern with the
  longest prefix, so a `./components/*/private/*` wildcard would lose to
  `./components/*`.

The build follows suit. `utilities/*/index` is no longer a Vite entry, the
entry shims are generated only for `components/` and skip `private/` folders,
and `build:types` prunes every internal `.d.ts` that no public declaration
imports (`scripts/prune-internal-types.ts`). Eight stay because public
declarations import them by relative path for value exports or class state
(`utilities/constants`, `utilities/log`, page-header's legacy subcomponents,
split-view's list-item HOC and simple-data-table's mode); they are not in
`exports`, so they are not entry points.

BREAKING CHANGE: `@salesforce/design-system-react/utilities/*` and
`@salesforce/design-system-react/components/*/private/*` (and the
`check-props` modules) no longer resolve. They were never public API. Copy
the helper you need, or use the platform equivalent (`event.key` instead of
`utilities/key-code`). This includes the `utilities/hooks` hooks
(`useClickOutside`, `useControllableState`, `useLatestRef`), which are
internal.
`check-package-exports` no longer treats `utilities/<name>` as an entry point
and adds two checks against the built package:

- Negative: every module under `utilities/`, every module and folder under a
  `private/` folder in `components/`, and every `check-props` module must
  fail to resolve for types (`bundler` and `node16`, `import` and `require`
  conditions), and `import()`/`require()` must throw
  `ERR_PACKAGE_PATH_NOT_EXPORTED`.
- Type surface: every type a public value export's signature refers to, and
  every type-only export of a public entry point, must be declared in a
  public file, not under `utilities/` or a `private/` folder. A shared type
  declared in `types/` must also be exported by name from a public entry
  point.
- CHANGELOG: a BREAKING entry for the `exports` change, with the 0.10.x
  deep imports most likely in use and how to migrate; the `utilities/hooks`
  hooks are no longer listed as added public API; the newly exported prop
  types are listed under Added.
- codebase-overview: state the public-surface rule next to the folder
  structure, add entry points to the breaking-change taxonomy, and note that
  `exports` now enforces the `private/` boundary for consumers.
- CONTRIBUTING: the root barrel is `components/index.ts`, with generated
  types.
@interactivellama
interactivellama force-pushed the feat/block-private-exports branch from 6643027 to 9081d41 Compare November 17, 2026 07:42
@interactivellama
interactivellama force-pushed the feat/v11-llm-4-deprecated-lint branch from 43ba51b to b0ab35e Compare November 17, 2026 08:39
@interactivellama
interactivellama force-pushed the feat/v11-llm-4-deprecated-lint branch from b0ab35e to 44fd7f2 Compare November 17, 2026 17:47
@interactivellama
interactivellama removed this pull request from stack #3324 November 17, 2026 17:47
@interactivellama
interactivellama force-pushed the feat/v11-llm-4-deprecated-lint branch 2 times, most recently from 56db94e to 1b9f716 Compare November 17, 2026 22:45
@interactivellama

Copy link
Copy Markdown
Contributor Author

Closing: all four commits landed in #3333 (rc-breaking), reworked onto #3317. Rebasing this branch onto #3311 leaves no commits of its own (type exports = 2b425e8, exports removal = 8313874, entry-point test = 53b619f, docs = 8172551).

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.

1 participant