eslint-plugin-react
eslint-plugin-react copied to clipboard
[Fix] `display-name`: avoid false positive when React is shadowed
Fixes #3924
Codecov Report
:x: Patch coverage is 82.53968% with 11 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 97.75%. Comparing base (dd2e968) to head (f6800d3).
:warning: Report is 1 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| lib/rules/display-name.js | 82.53% | 11 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #3926 +/- ##
==========================================
+ Coverage 97.73% 97.75% +0.01%
==========================================
Files 136 136
Lines 9997 10058 +61
Branches 3715 3750 +35
==========================================
+ Hits 9771 9832 +61
Misses 226 226
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Valid Test Cases (4)
| Case | Secenario | Shadowing Patterns Covered |
|---|---|---|
| 1: BlockStatement | All React APIs shadowed within block scope | • Block scope variables • { const memo = ... } • { const React = ... } |
| 2: Function Parameters | Shadowing via function parameters | • Regular parameters: function(memo) • Destructured parameters: function({forwardRef}) |
| 3: Nested Function Scope | Shadowing within nested functions | • Nested function scope • Inner function variables • function inner() { const memo = ... } |
| 4: Mixed Patterns | Multiple shadowing techniques combined | • Variable declaration: const memo = ... • Destructuring: const {forwardRef} = ... • Array destructuring: const [React] = ... |
Invalid Test Cases (3)
| Case | Scenario | Corresponding Valid Case |
|---|---|---|
| 1: BlockStatement Errors | Direct React API usage in block scope | Valid 1 |
| 2: Parameter + Nested Errors | Direct React API usage without parameter/nested shadowing | Valid 2, 3 |
| 3: Mixed Pattern Errors | Direct React API usage without any shadowing | Valid 4 |