Skip to content

feat(linter): add react/no-redundant-should-component-update rule#16147

Merged
camc314 merged 6 commits intooxc-project:mainfrom
baevm:react/no-redundant-should-component-update
Dec 10, 2025
Merged

feat(linter): add react/no-redundant-should-component-update rule#16147
camc314 merged 6 commits intooxc-project:mainfrom
baevm:react/no-redundant-should-component-update

Conversation

@baevm
Copy link
Copy Markdown
Contributor

@baevm baevm commented Nov 26, 2025

adds react/no-redundant-should-component-update, issue #1022

rule doc
rule source code

@baevm baevm requested a review from camc314 as a code owner November 26, 2025 06:07
Copilot AI review requested due to automatic review settings November 26, 2025 06:07
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Nov 26, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Nov 26, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.PureComponent or PureComponent with shouldComponentUpdate methods
  • 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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 26, 2025

CodSpeed Performance Report

Merging #16147 will not alter performance

Comparing baevm:react/no-redundant-should-component-update (441bf27) with main (200d17b)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 self-assigned this Dec 10, 2025
@camc314 camc314 force-pushed the react/no-redundant-should-component-update branch from dba5c3a to 92a7c28 Compare December 10, 2025 12:35
Copy link
Copy Markdown
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

Thank you!

@camc314 camc314 merged commit e1b1bc3 into oxc-project:main Dec 10, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants