Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] fix prefer-exact-props and improve performance #3190

Merged
merged 1 commit into from Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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