diff --git a/CHANGELOG.md b/CHANGELOG.md index 78857b967a..9b1cbc24c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ### Fixed * [`prop-types`], `propTypes`: add support for exported type inference ([#3163][] @vedadeepta) * [`no-invalid-html-attribute`]: allow 'shortcut icon' on `link` ([#3174][] @Primajin) +* [`prefer-exact-props`] improve performance for `Identifier` visitor ([#3190][] @meowtec) ### Changed * [readme] change [`jsx-runtime`] link from branch to sha ([#3160][] @tatsushitoji) @@ -20,6 +21,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange * [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper) * [Docs] [`display-name`]: improve examples ([#3189][] @golopot) +[#3190]: https://github.com/yannickcr/eslint-plugin-react/pull/3190 [#3189]: https://github.com/yannickcr/eslint-plugin-react/pull/3189 [#3186]: https://github.com/yannickcr/eslint-plugin-react/pull/3186 [#3174]: https://github.com/yannickcr/eslint-plugin-react/pull/3174 diff --git a/lib/rules/prefer-exact-props.js b/lib/rules/prefer-exact-props.js index fb50f1e31f..037fa29914 100644 --- a/lib/rules/prefer-exact-props.js +++ b/lib/rules/prefer-exact-props.js @@ -120,7 +120,7 @@ module.exports = { }, Identifier(node) { - if (!utils.getParentStatelessComponent(node)) { + if (!utils.getStatelessComponent(node.parent)) { return; } diff --git a/tests/lib/rules/prefer-exact-props.js b/tests/lib/rules/prefer-exact-props.js index dc6e8c3e71..03563add80 100644 --- a/tests/lib/rules/prefer-exact-props.js +++ b/tests/lib/rules/prefer-exact-props.js @@ -96,6 +96,18 @@ ruleTester.run('prefer-exact-props', rule, { `, features: ['flow'], }, + { + code: ` + type Props = {| + foo: string + |} + function Component(props: Props) { + let someVar: { foo: string }; + return
; + } + `, + features: ['flow'], + }, { code: ` function Component(props: {| foo : string |}) {