Skip to content

feat(linter): implement react/no-unsafe#16532

Merged
camc314 merged 23 commits intooxc-project:mainfrom
Kenzo-Wada:feat/react-no-unsafe
Dec 20, 2025
Merged

feat(linter): implement react/no-unsafe#16532
camc314 merged 23 commits intooxc-project:mainfrom
Kenzo-Wada:feat/react-no-unsafe

Conversation

@Kenzo-Wada
Copy link
Contributor

related: #1022

added react/no-unsafe rule to oxlinter!

Copilot AI review requested due to automatic review settings December 5, 2025 08:22
@Kenzo-Wada Kenzo-Wada requested a review from camc314 as a code owner December 5, 2025 08:22
@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Dec 5, 2025
Copy link
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-unsafe linter rule to oxlinter, which identifies and restricts the use of deprecated React lifecycle methods (componentWillMount, componentWillReceiveProps, componentWillUpdate) and their UNSAFE_ prefixed variants. The rule supports version-aware checking based on React settings and includes a configurable checkAliases option.

Key changes:

  • Implements the new react/no-unsafe rule with support for ES5 (createReactClass) and ES6 (class) components
  • Adds React version configuration to settings for version-specific rule behavior
  • Includes comprehensive tests covering various scenarios and component types

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/oxc_linter/src/rules/react/no_unsafe.rs Main rule implementation with logic to detect unsafe lifecycle methods in both class and createReactClass components
crates/oxc_linter/src/snapshots/react_no_unsafe.snap Test snapshot file containing expected diagnostic output for various test cases
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 implementation for the rule runner
crates/oxc_linter/src/config/settings/react.rs Adds version field to React plugin settings for version-specific rule behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 5, 2025

CodSpeed Performance Report

Merging #16532 will not alter performance

Comparing Kenzo-Wada:feat/react-no-unsafe (e99b09a) with main (8d70b59)

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 5, 2025
@Kenzo-Wada Kenzo-Wada force-pushed the feat/react-no-unsafe branch from 7251266 to c2e6852 Compare December 6, 2025 04:52
Copy link
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

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@camchenry
Copy link
Member

You need to run cargo insta and update the snapshots, otherwise the tests will fail, since the settings have changed and need to be updated.

Kenzo-Wada and others added 5 commits December 20, 2025 17:57
Co-authored-by: Cam McHenry <camchenry@users.noreply.github.com>
Signed-off-by: Kenzo Wada <79452224+Kenzo-Wada@users.noreply.github.com>
@github-actions github-actions bot added the A-cli Area - CLI label Dec 20, 2025
@Kenzo-Wada Kenzo-Wada force-pushed the feat/react-no-unsafe branch 2 times, most recently from ae95b04 to 487519d Compare December 20, 2025 09:39
@github-actions github-actions bot added the A-codegen Area - Code Generation label Dec 20, 2025
@camc314 camc314 changed the title feat(linter/plugins): add react/no-unsafe feat(linter): implement react/no-unsafe Dec 20, 2025
Copy link
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 0f63e75 into oxc-project:main Dec 20, 2025
20 checks passed
@Kenzo-Wada Kenzo-Wada deleted the feat/react-no-unsafe branch December 22, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-codegen Area - Code Generation A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants