Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for react/display-name on function value assignment #3329

Closed
apbarrero opened this issue Jul 11, 2022 · 3 comments · Fixed by #3331
Closed

False positive for react/display-name on function value assignment #3329

apbarrero opened this issue Jul 11, 2022 · 3 comments · Fixed by #3331

Comments

@apbarrero
Copy link
Contributor

Related to #3289 and reproducible after its fix in 7.30.1.

This code makes the display-name rule to yield the error 'Component definition is missing display name'. So it seems that it is still identifying the assignment of a function value to a variable as a component definition.

let demo = null;
demo = (a) => {
  if (a == null) return null;
  return f(a);
}`,

As opposed to #3289, it is needed both that the demo variable is declared and assigned in two different statements and that the value returned by the function is not a function itself (i.e. not a higher order function).

@ljharb
Copy link
Member

ljharb commented Jul 11, 2022

Why is that needed?

(Either way, this function is a lowercase-named function so it shouldn't be detected as a component)

@apbarrero
Copy link
Contributor Author

@ljharb well, as you said, it shouldn't be detected as a component and it is valid code, so the rule shouldn't claim it as an error.

Why are you asking?

@ljharb
Copy link
Member

ljharb commented Jul 12, 2022

I’m curious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants