Skip to content

Commit

Permalink
[Fix] prefer-exact-props improve performance for Identifier visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
meowtec authored and ljharb committed Jan 27, 2022
1 parent 5a2e453 commit 4c668b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-exact-props.js
Expand Up @@ -120,7 +120,7 @@ module.exports = {
},

Identifier(node) {
if (!utils.getParentStatelessComponent(node)) {
if (!utils.getStatelessComponent(node.parent)) {
return;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/prefer-exact-props.js
Expand Up @@ -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 <div />;
}
`,
features: ['flow'],
},
{
code: `
function Component(props: {| foo : string |}) {
Expand Down

0 comments on commit 4c668b3

Please sign in to comment.