eslint-plugin-react icon indicating copy to clipboard operation
eslint-plugin-react copied to clipboard

[Fix] `display-name`: avoid false positive when React is shadowed

Open hyeonbinHur opened this issue 6 months ago • 2 comments

Fixes #3924

hyeonbinHur avatar May 22 '25 17:05 hyeonbinHur

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.

codecov[bot] avatar May 22 '25 18:05 codecov[bot]

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

hyeonbinHur avatar May 26 '25 10:05 hyeonbinHur