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

[Perf] component detection: improve performance by avoiding traversing parents unnecessarily #3459

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

golopot
Copy link
Contributor

@golopot golopot commented Oct 11, 2022

This change makes an eslint . with plugin:react/all enabled run about 13% faster.

Comment on lines 464 to 465
return <Text>{this.props.foo}</Text>;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be reported because React.createClass is not the correct pragma here. So there should be no component detected thus no report.

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #3459 (bf59919) into master (c56cc56) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3459      +/-   ##
==========================================
- Coverage   97.58%   97.54%   -0.05%     
==========================================
  Files         127      127              
  Lines        9068     9066       -2     
  Branches     3308     3307       -1     
==========================================
- Hits         8849     8843       -6     
- Misses        219      223       +4     
Impacted Files Coverage Δ
lib/util/Components.js 95.66% <100.00%> (-0.85%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -871,7 +877,7 @@ function componentRule(rule, context) {
return;
}

node = utils.getParentComponent();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to find parent components here.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit, thanks

@ljharb ljharb force-pushed the perf-no-getParent branch from d6ece7f to bf59919 Compare October 11, 2022 21:51
@ljharb ljharb added the hacktoberfest-accepted If you're interested in a free shirt, this PR counts towards it. label Oct 11, 2022
@ljharb ljharb merged commit bf59919 into jsx-eslint:master Oct 11, 2022
ljharb pushed a commit to ljharb/eslint-plugin-react that referenced this pull request Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted If you're interested in a free shirt, this PR counts towards it.
Development

Successfully merging this pull request may close these issues.

2 participants