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

[react/jsx-curly-brace-presence] False positive on jsx passed to prop #3228

Closed
bhollis opened this issue Feb 28, 2022 · 3 comments
Closed

[react/jsx-curly-brace-presence] False positive on jsx passed to prop #3228

bhollis opened this issue Feb 28, 2022 · 3 comments
Labels

Comments

@bhollis
Copy link

bhollis commented Feb 28, 2022

return (
  <CollapsibleTitle
    extra={<span className="activity-type">{activity.type}</span>}
  />
);
"react/jsx-curly-brace-presence": ["error", "never"],

After upgrading from 7.28.0 to 7.29.2, this highlights that the extra prop should not have curly braces, when it is not possible for them to be omitted.

@ljharb
Copy link
Member

ljharb commented Feb 28, 2022

It is in fact possible for them to be omitted; that's what the propElementValues config (added recently) is for.

however, using just "never" should result in propElementValues being set to "ignore", so you shouldn't see a warning here.

@bhollis
Copy link
Author

bhollis commented Feb 28, 2022

Ah, interesting. It's certainly not allowed by TypeScript.

@ljharb
Copy link
Member

ljharb commented Feb 28, 2022

Yep, the TS eslint parser doesn't support it, but eslint, babel, and the jsx spec do.

to be fair, I only recently learned of its existence, and i think it's horrifying that jsx allows them to be omitted there :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants