Skip to content

feat(lint): lint the shape of every packages/react part - #571

Merged
kianbazza merged 1 commit into
ui-615-run-oxlint-on-packagesreact-next-to-biomefrom
ui-616-lint-the-shape-of-every-part
Sep 29, 2026
Merged

kianbazza merged 1 commit into
ui-615-run-oxlint-on-packagesreact-next-to-biomefrom
ui-616-lint-the-shape-of-every-part

Conversation

@kianbazza

@kianbazza kianbazza commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Four rules and one Biome setting check the shape of every part in packages/react/src. Test files are exempt.

a part file
'use client'                                    ← bazza/use-client (fixable)
export const Item = React.forwardRef(
  function Item(props, forwardedRef) { … }      ← bazza/forward-ref-named
)
export namespace Item {                         ← bazza/part-namespace
  export type State = ItemState                    (State only when the part passes `state` to `useRender`)
  export interface Props extends ItemProps {}
}
                                                ← no `export default` (Biome `noDefaultExport`)

item.data-attrs.ts / *.css-vars.ts
export enum ItemDataAttributes { … }            ← bazza/data-attrs-enum
  • bazza/use-client: .tsx and *-context.ts files start with 'use client'. bun run check:fix adds it.
  • bazza/forward-ref-named: forwardRef wraps either a named function expression or the name of a function declared in the same module. Arrows and imported functions are reported, because parts don't set displayName.
  • bazza/part-namespace: an exported forwardRef part, including memo(forwardRef(…)), exports Props from its namespace. It also exports State when its own render function passes state to useRender. If the rule can't read the render function, it reports that instead of passing.
  • bazza/data-attrs-enum: data-attribute and CSS-variable files export only enums named *DataAttributes / *CssVars, which is all the docs type generator reads. A re-export is accepted only when it comes from another data-attribute file.
  • packages/react/AGENTS.md: the "Component Pattern", "Data Attributes File" and "CSS Variables File" sections now describe each convention. Every rule message points to its section.

Files that break these rules today are allowlisted per rule in .oxlintrc.json:

  • 25 data-attribute files that use as const objects. That is why tables like ComboboxInputDataAttributes render empty on the docs site.
  • 7 files whose exported parts have no namespace (video-player sub-parts, PopupMenuListPrimitive, DataListInner).
  • 3 context modules without 'use client'.

Evidence

  • Before: a new data-attribute file written as export const ItemDataAttributes = { … } as const passed bun run check, and its docs table rendered empty.
    After:
    $ bun run lint:oxlint      # with the allowlists removed
      25 bazza(data-attrs-enum)
      10 bazza(part-namespace)
       3 bazza(use-client)
    
    With the allowlists in place, bun run lint:oxlint exits 0. The allowlists contain exactly the files that break a rule today. forward-ref-named reports nothing in the codebase, including the generic forwardRef(SelectItemImpl) as <…> parts.
  • The tooling/lint tests grow to 46. Each rule has fixtures that must fail and fixtures that must pass, plus a repo-config test that checks the rules apply only to shipped source.

Merge Danger

Door: two-way

Blast Radius: tooling

New parts, context modules and data-attribute files in packages/react/src that don't follow these conventions now fail bun run check and CI. Existing files are unaffected until someone removes them from an allowlist.

Closes UI-616

@kianbazza
kianbazza added this pull request to stack #572 September 29, 2026 13:48
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ui-canary Ready Ready Preview Sep 29, 2026 3:10pm UTC

Request Review

@linear-code

linear-code Bot commented Sep 29, 2026

Copy link
Copy Markdown

UI-616

Adds `bazza/use-client`, `bazza/forward-ref-named`, `bazza/part-namespace` and `bazza/data-attrs-enum`, and turns on Biome `noDefaultExport` for `packages/react/src`. Files that break a rule today are allowlisted per rule. `packages/react/AGENTS.md` documents each convention.
@kianbazza
kianbazza force-pushed the ui-616-lint-the-shape-of-every-part branch from f5b164d to bd463a3 Compare September 29, 2026 15:08
@kianbazza
kianbazza marked this pull request as ready for review September 29, 2026 15:41
@kianbazza
kianbazza merged commit a57f194 into canary Sep 29, 2026
5 of 8 checks passed

This branch was successfully deployed

1 active deployment
Preview – ui-canary — bd463a32 Deployed Sep 29, 2026 by vercel[bot]
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