docs: add prop merging ADR and adoption tooling#8248
Conversation
|
joshblack
left a comment
There was a problem hiding this comment.
@copilot add the mergeProps.ts utility from: https://github.com/primer/react/pull/8168/changes#diff-b21bbbcb2674bcbc6f8e205e1c9223efea602c2abea46bb150c1d34b8ee06d07 and include tests for it. Also add an ADR for prop merging conventions for me with this decision. Highlight any scenarios that I should be aware of that aren't included already
Implemented in ba4584c. Added |
|
joshblack
left a comment
There was a problem hiding this comment.
@copilot I want to create an eslint rule for this behavior. To do this, let's:
- Create a local
@primer/eslint-configprivate package inpackages/* - In this, add a rule for the proposed merge props behavior
- This rule should look to see if props are spread on the outermost element and prefer using
mergeProps - This rule should not be enabled by default (eventually we will turn it on)
- Add a new migration report for this rule, reporting on number of places where it is failing that we would need to migrate
|
|
||
| The general rules do not cover every form of composition: | ||
|
|
||
| - **Refs are not composed.** Use `useMergedRefs` when both the component and |
There was a problem hiding this comment.
@copilot add a note that this will change in React 19 with refs passed as props
There was a problem hiding this comment.
Documented the React 19 ref-as-prop behavior and clarified that refs still require separate composition in 01b40e1.
c163b71 to
fc7d2ac
Compare
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>
Ignore pure prop-forwarding wrappers so the adoption report only tracks component roots with props that need intentional merging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 00bfd295-6ed9-4119-8d63-103a0b3c63e8
fc7d2ac to
1bc6f64
Compare
| @@ -0,0 +1,278 @@ | |||
| import {ASTUtils, type TSESLint, type TSESTree} from '@typescript-eslint/utils' | |||
There was a problem hiding this comment.
curious on the decision to create a new package for this rule over adding to https://github.com/primer/eslint-plugin-primer-react 👀
| type EventHandler = (...args: unknown[]) => void | ||
| type ClassValue = Parameters<typeof clsx>[number] | ||
|
|
||
| function mergeProps<A extends object, B extends object = A>(a: A, b: B): Merge<A, B> { |
There was a problem hiding this comment.
would be nice to have docs here at the top explaining functionality/precedence
Closes #
This PR adds ADR-025 and the foundation for adopting one prop-merging convention across Primer React. This entry owns the shared utility, deterministic ESLint rule, migration report, workflow integration, and future refinements to those tools.
Changelog
New
mergePropsutility.Changed
Removed
Rollout strategy
This is internal architecture and migration tooling.
mergePropsis not exported as public API, and component behavior changes will be reviewed in separate batch entries.Testing & Reviewing
Please review the ADR contract, merge semantics, and the boundary used by
primer/prefer-merge-props. In particular, pure forwarding wrappers should not appear in the report, while roots combining authored and consumer props should remain findings.