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

fix(rome_js_analyzer): Fix false positive diagnostics that useCamelCase caused to private class members #4432

Merged
merged 3 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ output. [#4405](https://github.com/rome/tools/pull/4405)
when there are breaking changes.
- Fix [#4348](https://github.com/rome/tools/issues/4348) that caused [`noNonNullAssertion`](https://docs.rome.tools/lint/rules/nononnullassertion/) to emit incorrect code action
- Fix [#4410](https://github.com/rome/tools/issues/4410) that caused [`useButtonType`](https://docs.rome.tools/lint/rules/usebuttontype/) to miss some cases
- Fix false positive diagnostics that [`useCamelCase`](https://docs.rome.tools/lint/rules/usecamelcase/) caused to default exported components
- Fix false positive diagnostics that [`useCamelCase`](https://docs.rome.tools/lint/rules/usecamelcase/) caused to default exported components
- Fix false positive diagnostics that [`useCamelCase`](https://docs.rome.tools/lint/rules/usecamelcase/) caused to private class members

### Configuration
### Editors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Rule for UseCamelCase {
let is_property = name.parent::<JsPropertyClassMember>().is_some();
if is_property {
let name = name.text();
check_is_camel(&name)
check_is_camel(&name[1..])
} else {
None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function snake_function(snake_case, PascalCase) {}
class PascalCase {
snake_property = 1;
#private_snake_property = 2;
#validPrivateMember = 3;

snake_function() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function snake_function(snake_case, PascalCase) {}
class PascalCase {
snake_property = 1;
#private_snake_property = 2;
#validPrivateMember = 3;

snake_function() {}

Expand Down Expand Up @@ -157,7 +158,7 @@ useCamelCase.js:9:2 lint/nursery/useCamelCase ━━━━━━━━━━━
> 9 │ snake_property = 1;
│ ^^^^^^^^^^^^^^
10 │ #private_snake_property = 2;
11 │
11 │ #validPrivateMember = 3;
```
Expand All @@ -171,101 +172,101 @@ useCamelCase.js:10:2 lint/nursery/useCamelCase ━━━━━━━━━━━
9 │ snake_property = 1;
> 10 │ #private_snake_property = 2;
│ ^^^^^^^^^^^^^^^^^^^^^^^
11 │
12 │ snake_function() {}
11 │ #validPrivateMember = 3;
12 │
```

```
useCamelCase.js:12:2 lint/nursery/useCamelCase ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useCamelCase.js:13:2 lint/nursery/useCamelCase ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Prefer methods names in camel case.
10 │ #private_snake_property = 2;
11
> 12 │ snake_function() {}
11 │ #validPrivateMember = 3;
12
> 13 │ snake_function() {}
│ ^^^^^^^^^^^^^^
13
14 │ get snake_getter() {}
14
15 │ get snake_getter() {}
```

```
useCamelCase.js:14:6 lint/nursery/useCamelCase ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useCamelCase.js:15:6 lint/nursery/useCamelCase ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Prefer methods names in camel case.
12 │ snake_function() {}
13
> 14 │ get snake_getter() {}
13 │ snake_function() {}
14
> 15 │ get snake_getter() {}
│ ^^^^^^^^^^^^
15 │ set snake_setter(v) {
16 │ console.log(v);
16 │ set snake_setter(v) {
17 │ console.log(v);
```

```
useCamelCase.js:15:6 lint/nursery/useCamelCase ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useCamelCase.js:16:6 lint/nursery/useCamelCase ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Prefer methods names in camel case.
14 │ get snake_getter() {}
> 15 │ set snake_setter(v) {
15 │ get snake_getter() {}
> 16 │ set snake_setter(v) {
│ ^^^^^^^^^^^^
16 │ console.log(v);
17 │ }
17 │ console.log(v);
18 │ }
```

```
useCamelCase.js:31:5 lint/nursery/useCamelCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useCamelCase.js:32:5 lint/nursery/useCamelCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Prefer variables names in camel case.
29 │ let longCamelCase;
30
> 31 │ let UPPER_CASE = 1;
30 │ let longCamelCase;
31
> 32 │ let UPPER_CASE = 1;
│ ^^^^^^^^^^
32 │ let { UPPER_CASE } = env;
33 │ let [ UPPER_CASE ] = env;
33 │ let { UPPER_CASE } = env;
34 │ let [ UPPER_CASE ] = env;
i Safe fix: Rename this symbol to camel case
29 29 │ let longCamelCase;
30 30
31 │ - let·UPPER_CASE·=·1;
31 │ + let·uPPERCASE·=·1;
32 32 │ let { UPPER_CASE } = env;
33 33 │ let [ UPPER_CASE ] = env;
30 30 │ let longCamelCase;
31 31
32 │ - let·UPPER_CASE·=·1;
32 │ + let·uPPERCASE·=·1;
33 33 │ let { UPPER_CASE } = env;
34 34 │ let [ UPPER_CASE ] = env;
```

```
useCamelCase.js:45:10 lint/nursery/useCamelCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
useCamelCase.js:46:10 lint/nursery/useCamelCase FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Prefer functions names in camel case.
43 │ export default PascalCaseOkBecauseExport;
44
> 45 │ function PascalCaseNOk() { }
44 │ export default PascalCaseOkBecauseExport;
45
> 46 │ function PascalCaseNOk() { }
│ ^^^^^^^^^^^^^
46 │ console.log(PascalCaseNOk());
47
47 │ console.log(PascalCaseNOk());
48
i Safe fix: Rename this symbol to camel case
43 43 │ export default PascalCaseOkBecauseExport;
44 44
45 │ - function·PascalCaseNOk()·{·}
46 │ - console.log(PascalCaseNOk());
45 │ + function·pascalCaseNOk()·{·}
46 │ + console.log(pascalCaseNOk());
47 47
44 44 │ export default PascalCaseOkBecauseExport;
45 45
46 │ - function·PascalCaseNOk()·{·}
47 │ - console.log(PascalCaseNOk());
46 │ + function·pascalCaseNOk()·{·}
47 │ + console.log(pascalCaseNOk());
48 48
```
Expand Down