Skip to content

Commit

Permalink
[Fix] prop-types: props missing in validation when using generic ty…
Browse files Browse the repository at this point in the history
…pes from a namespace import
  • Loading branch information
rbondoc96 authored and ljharb committed Dec 3, 2024
1 parent 66ae4c1 commit b713026
Show file tree
Hide file tree
Showing 3 changed files with 469 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [`no-danger`]: avoid a crash on a nested component name ([#3833][] @ljharb)
* [Fix] types: correct generated type declaration ([#3840][] @ocavue)
* [`no-unknown-property`]: support `precedence` prop in react 19 ([#3829][] @acusti)
* [`prop-types`]: props missing in validation when using generic types from a namespace import ([#3859][] @rbondoc96)

### Changed
* [Tests] [`jsx-no-script-url`]: Improve tests ([#3849][] @radu2147)
* [Docs] fix broken links: [`default-props-match-prop-types`], [`jsx-boolean-value`], [`jsx-curly-brace-presence`], [`jsx-no-bind`], [`no-array-index-key`], [`no-is-mounted`], [`no-render-return-value`], [`require-default-props`] ([#3841][] @bastiendmt)

[#3859]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3859
[#3849]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3849
[#3841]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3841
[#3840]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3840
Expand Down
4 changes: 3 additions & 1 deletion lib/util/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ module.exports = function propTypesInstructions(context, components, utils) {
const defaults = { customValidators: [] };
const configuration = Object.assign({}, defaults, context.options[0] || {});
const customValidators = configuration.customValidators;
const allowedGenericTypes = new Set(['forwardRef', 'ForwardRefRenderFunction', 'VFC', 'VoidFunctionComponent', 'PropsWithChildren', 'SFC', 'StatelessComponent', 'FunctionComponent', 'FC']);
const allowedGenericTypes = new Set(['ComponentProps', 'ComponentPropsWithoutRef', 'forwardRef', 'ForwardRefRenderFunction', 'VFC', 'VoidFunctionComponent', 'PropsWithChildren', 'SFC', 'StatelessComponent', 'FunctionComponent', 'FC']);
const genericTypeParamIndexWherePropsArePresent = {
ComponentProps: 0,
ComponentPropsWithoutRef: 0,
ForwardRefRenderFunction: 1,
forwardRef: 1,
VoidFunctionComponent: 0,
Expand Down
Loading

0 comments on commit b713026

Please sign in to comment.