-
Notifications
You must be signed in to change notification settings - Fork 657
fix(rome_js_analyze): accept const as non camel case #3190
Conversation
✅ Deploy Preview for rometools canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you enable the rule inside rome.json
file? Doing so it will be a better proof that this PR fixes the false positives
crates/rome_js_analyze/src/semantic_analyzers/js/use_camel_case.rs
Outdated
Show resolved
Hide resolved
@@ -34,6 +34,8 @@ console.log({ | |||
let camelCase; | |||
let longCamelCase; | |||
|
|||
const THIS_IS_OK = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix cover cases like const { FOO } = env
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I update the test with more cases.
There is one case we do not deal well.
warning[js/useCamelCase]: Prefer variables names in camel case.
┌─ useCamelCase.js:31:5
│
31 │ let UPPER_CASE = 1;
│ ----------
Safe fix: Rename this symbol to camel case
| @@ -28,7 +28,7 @@
27 27 | let camelCase;
28 28 | let longCamelCase;
29 29 |
30 | - let UPPER_CASE = 1;
30 | + let uPPERCASE = 1;
31 31 | let { UPPER_CASE } = 1;
32 32 | let [ UPPER_CASE ] = 1;
33 33 |
The problem is that it is easy to fix this, but break other acronyms like IS_HTML -> isHtml.
Not sure the best way here.
c93ccde
to
aba5332
Compare
aba5332
to
c939931
Compare
Summary
This PR fixes a false flag of all uppercase const as an invalid non-camel case.
Fixes a lot of issues here: https://github.com/rome/tools/runs/8188485278
Test Plan