feat(linter): implement react/no-unsafe#16532
Conversation
There was a problem hiding this comment.
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-unsaferule 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 Performance ReportMerging #16532 will not alter performanceComparing Summary
Footnotes
|
7251266 to
c2e6852
Compare
There was a problem hiding this comment.
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.
|
You need to run |
Co-authored-by: Cam McHenry <camchenry@users.noreply.github.com> Signed-off-by: Kenzo Wada <79452224+Kenzo-Wada@users.noreply.github.com>
ae95b04 to
487519d
Compare
related: #1022
added react/no-unsafe rule to oxlinter!