diff --git a/CHANGELOG.md b/CHANGELOG.md index 3188c031a6..91505a7a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange * [`no-array-index-key`]: catch `.toString` and `String()` usage ([#2813][] @RedTn) * [`function-component-definition`]: do not break on dollar signs ([#3207][] @ljharb) * [`prefer-stateless-function`]: avoid a crash inside `doctrine` ([#2596][] @ljharb) +* [`prop-types`]: catch infinite loop ([#2861][] @ljharb) ### Changed * [readme] change [`jsx-runtime`] link from branch to sha ([#3160][] @tatsushitoji) @@ -56,6 +57,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange [#3160]: https://github.com/yannickcr/eslint-plugin-react/pull/3160 [#3133]: https://github.com/yannickcr/eslint-plugin-react/pull/3133 [#2921]: https://github.com/yannickcr/eslint-plugin-react/pull/2921 +[#2861]: https://github.com/yannickcr/eslint-plugin-react/issues/2861 [#2813]: https://github.com/yannickcr/eslint-plugin-react/pull/2813 [#2753]: https://github.com/yannickcr/eslint-plugin-react/pull/2753 [#2614]: https://github.com/yannickcr/eslint-plugin-react/issues/2614 diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 97022028f0..8da9fb9f15 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -1187,7 +1187,11 @@ module.exports = function propTypesInstructions(context, components, utils) { if (!component) { return; } - markPropTypesAsDeclared(component.node, node.parent.right || node.parent); + try { + markPropTypesAsDeclared(component.node, node.parent.right || node.parent); + } catch (e) { + if (e.constructor !== RangeError) { throw e; } + } } }, diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 8ba945d7ef..090e8493ca 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -3753,19 +3753,19 @@ ruleTester.run('prop-types', rule, { value: string, error: string, } - + type Form = { fields: { [string]: Field, }, formError: string, } - + type Props = { bankDetails: Form, onBankDetailsUpdate: any => void, } - + const Provider = (props:Props) => { return