Skip to content

Commit 4c668b3

Browse files
meowtecljharb
authored andcommitted
[Fix] prefer-exact-props improve performance for Identifier visitor
1 parent 5a2e453 commit 4c668b3

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1212
### Fixed
1313
* [`prop-types`], `propTypes`: add support for exported type inference ([#3163][] @vedadeepta)
1414
* [`no-invalid-html-attribute`]: allow 'shortcut icon' on `link` ([#3174][] @Primajin)
15+
* [`prefer-exact-props`] improve performance for `Identifier` visitor ([#3190][] @meowtec)
1516

1617
### Changed
1718
* [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
2021
* [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper)
2122
* [Docs] [`display-name`]: improve examples ([#3189][] @golopot)
2223

24+
[#3190]: https://github.com/yannickcr/eslint-plugin-react/pull/3190
2325
[#3189]: https://github.com/yannickcr/eslint-plugin-react/pull/3189
2426
[#3186]: https://github.com/yannickcr/eslint-plugin-react/pull/3186
2527
[#3174]: https://github.com/yannickcr/eslint-plugin-react/pull/3174

lib/rules/prefer-exact-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ module.exports = {
120120
},
121121

122122
Identifier(node) {
123-
if (!utils.getParentStatelessComponent(node)) {
123+
if (!utils.getStatelessComponent(node.parent)) {
124124
return;
125125
}
126126

tests/lib/rules/prefer-exact-props.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ ruleTester.run('prefer-exact-props', rule, {
9696
`,
9797
features: ['flow'],
9898
},
99+
{
100+
code: `
101+
type Props = {|
102+
foo: string
103+
|}
104+
function Component(props: Props) {
105+
let someVar: { foo: string };
106+
return <div />;
107+
}
108+
`,
109+
features: ['flow'],
110+
},
99111
{
100112
code: `
101113
function Component(props: {| foo : string |}) {

0 commit comments

Comments
 (0)