Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hyeonbinHur wants to merge7 commits intojsx-eslint:master
base:master
Choose a base branch
Loading
fromhyeonbinHur:issue3924

Conversation

hyeonbinHur
Copy link

Fixes#3924

@codecovCodecov
Copy link

codecovbot commentedMay 22, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is82.53968% with11 lines in your changes missing coverage. Please review.

Project coverage is 97.75%. Comparing base(dd2e968) to head(f6800d3).
Report is 1 commits behind head on master.

Files with missing linesPatch %Lines
lib/rules/display-name.js82.53%11 Missing⚠️
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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@ljharbljharb left a comment

Choose a reason for hiding this comment

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

can't review til style diffs are reverted

Comment on lines 34 to 35
description:
'Disallow missing displayName in a React component definition',
Copy link
Member

Choose a reason for hiding this comment

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

please don't run prettier on projects that don't use it :-) and please revert all unrelated style changes.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, I forgot to disable some style-related settings, which caused unnecessary formatting changes. I’ll remove the unnecessary style edits and commit again soon. Thanks for the review and the feedback!

ljharb reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

My suggestion is to keep those always disabled, and only use eslint to format files.

Choose a reason for hiding this comment

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

@ljharbljharb marked this pull request as draftMay 22, 2025 18:42
Comment on lines 46 to 57
code: `
import React, { memo } from 'react'

const TestComponent = function () {
const memo = (cb) => cb()

const Comp = memo(() => {
return <div>shadowed</div>
})

return Comp
}
Copy link
Member

Choose a reason for hiding this comment

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

can we get every "valid" example with shadowing, also added as an invalid example without the shadowing?

hyeonbinHur reacted with thumbs up emoji
Comment on lines +206 to +208
currentNode.type === 'FunctionDeclaration'
|| currentNode.type === 'FunctionExpression'
|| currentNode.type === 'ArrowFunctionExpression'

Choose a reason for hiding this comment

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

Why only these scopes? For example what aboutBlockStatement:

{  const memo = (cb) => cb()  const forwardRef = (cb) => cb()  const React = { memo, forwardRef }  const BlockReactShadowedMemo = React.memo(() => {    return <div>shadowed</div>  })}

ljharb reacted with thumbs up emoji
Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the review. Let me take a quick look and try to find a better algorithm to cover all test cases.

@hyeonbinHur
Copy link
Author

Valid Test Cases (4)

CaseSecenarioShadowing Patterns Covered
1: BlockStatementAll React APIs shadowed within block scope• Block scope variables
• { const memo = ... }
• { const React = ... }
2: Function ParametersShadowing via function parameters• Regular parameters: function(memo)
• Destructured parameters: function({forwardRef})
3: Nested Function ScopeShadowing within nested functions• Nested function scope
• Inner function variables
• function inner() { const memo = ... }
4: Mixed PatternsMultiple shadowing techniques combined• Variable declaration: const memo = ...
• Destructuring: const {forwardRef} = ...
• Array destructuring: const [React] = ...

Invalid Test Cases (3)

CaseScenarioCorresponding Valid Case
1: BlockStatement ErrorsDirect React API usage in block scopeValid 1
2: Parameter + Nested ErrorsDirect React API usage without parameter/nested shadowingValid 2, 3
3: Mixed Pattern ErrorsDirect React API usage without any shadowingValid 4

@hyeonbinHurhyeonbinHur marked this pull request as ready for reviewMay 26, 2025 18:55
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ljharbljharbljharb requested changes

@morganneymorganneymorganney left review comments

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Bug]: display-name false positive when React is shadowed
3 participants
@hyeonbinHur@ljharb@morganney

[8]ページ先頭

©2009-2025 Movatter.jp