Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 useCamelCase for React Components #3117

Closed
1 task done
MichaReiser opened this issue Aug 27, 2022 · 4 comments
Closed
1 task done

🐛 useCamelCase for React Components #3117

MichaReiser opened this issue Aug 27, 2022 · 4 comments
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug

Comments

@MichaReiser
Copy link
Contributor

MichaReiser commented Aug 27, 2022

Environment information

Playground

What happened?

  1. Created a react component named MarkdownRenderer
  2. The useCamelCase rule reported a warning because of the component name
error[[js/useCamelCase](https://rome.tools/docs/lint/rules/useCamelCase/)]: Prefer functions names in camel case.
  ┌─ main.tsx:1:17
  │
1 │ export function MarkdownRenderer({
  │                 ^^^^^^^^^^^^^^^^

Expected result

Custom components must use upper case naming or React renders them as native HTML elements. Thus, applying the suggested fix isn't safe.

How the exact fix should look like is unclear to me. One option could be to not report a diagnostic if the function returns JSX but doing so has the downside that:

  • I get a diagnostic when writing the function signature that only disappears when I wrote the function's body
  • There's no sound way to detect if a function returns JSX

It thus, may mean that we shouldn't enabale the rule by default or, exclude functions.

Related issue typescript-eslint/typescript-eslint#2607

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@MichaReiser MichaReiser added the S-To triage Status: user report of a possible bug that needs to be triaged label Aug 27, 2022
@ematipico ematipico added S-Bug: confirmed Status: report has been confirmed as a valid bug A-Linter Area: linter and removed S-To triage Status: user report of a possible bug that needs to be triaged labels Aug 29, 2022
@MichaReiser
Copy link
Contributor Author

CC: @xunilrj for the work around correctness

@github-actions
Copy link

This issue is stale because it has been open 14 days with no activity.

@ematipico
Copy link
Contributor

@xunilrj is this fixed by any chance?

@xunilrj
Copy link
Contributor

xunilrj commented Sep 16, 2022

Now, functions that are exported or are used in "new expressions" are ok. So yes.
See #3210.

@xunilrj xunilrj closed this as completed Sep 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter S-Bug: confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

3 participants