feat(linter): add react/no-redundant-should-component-update rule#16147
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
There was a problem hiding this comment.
Pull request overview
This PR adds the react/no-redundant-should-component-update lint rule that detects redundant shouldComponentUpdate method definitions in classes extending React.PureComponent. Since PureComponent already provides a shallow prop and state comparison via shouldComponentUpdate, defining this method explicitly is redundant and defeats the purpose of using PureComponent.
Key changes:
- Implements the rule to detect classes extending
React.PureComponentorPureComponentwithshouldComponentUpdatemethods - Handles both method definitions and arrow function property assignments
- Supports named and anonymous classes, including variable declarators
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crates/oxc_linter/src/rules/react/no_redundant_should_component_update.rs |
New rule implementation with logic to detect redundant shouldComponentUpdate in PureComponent classes |
crates/oxc_linter/src/rules.rs |
Registers the new rule module and adds it to the rules list |
crates/oxc_linter/src/generated/rule_runner_impls.rs |
Auto-generated runner implementation for the new rule |
crates/oxc_linter/src/snapshots/react_no_redundant_should_component_update.snap |
Test snapshot showing expected diagnostic outputs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/oxc_linter/src/rules/react/no_redundant_should_component_update.rs
Show resolved
Hide resolved
crates/oxc_linter/src/rules/react/no_redundant_should_component_update.rs
Show resolved
Hide resolved
CodSpeed Performance ReportMerging #16147 will not alter performanceComparing Summary
Footnotes
|
dba5c3a to
92a7c28
Compare
…6147) adds react/no-redundant-should-component-update, issue #1022 [rule doc](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md) [rule source code](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/no-redundant-should-component-update.js) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Cameron Clark <[email protected]>
…c-project#16147) adds react/no-redundant-should-component-update, issue oxc-project#1022 [rule doc](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md) [rule source code](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/no-redundant-should-component-update.js) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Cameron Clark <[email protected]>
adds react/no-redundant-should-component-update, issue #1022
rule doc
rule source code