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

fix(useNamingConvention): don't suggest empty fixes #3565

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ our [guidelines for writing a good changelog entry](https:/biomejs/b

- [useNamingConvention](https://biomejs.dev/linter/rules/use-naming-convention/) now accepts applying custom convention on abstract classes. Contributed by @Conaclos

- [useNamingConvention](https://biomejs.dev/linter/rules/use-naming-convention/) no longer suggests an empty fix when a name doesn't match strict Pascal case ([#3561](https:/biomejs/biome/issues/3561)).

Previously the following code led `useNamingConvention` to suggest an empty fix.
The rule no longer provides a fix for this case.

```ts
type AAb = any
```

Contributed by @Conaclos

### Parser

#### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,9 @@ impl Rule for UseNamingConvention {
new_name.push_str(&name[..(name_range.start as _)]);
new_name.push_str(&new_name_part);
new_name.push_str(&name[(name_range.end as _)..]);
if name == new_name {
return None;
}
let mut mutation = ctx.root().begin();
let renamed = mutation.rename_any_renamable_node(model, &renamable, &new_name[..]);
if renamed {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface VNode {
hello: 'world'
}
type AAb = any
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: invalidStrictPascalCase.ts
---
# Input
```ts
interface VNode {
hello: 'world'
}
type AAb = any
```

# Diagnostics
```
invalidStrictPascalCase.ts:1:11 lint/style/useNamingConvention ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Two consecutive uppercase characters are not allowed in PascalCase because strictCase is set to `true`.

> 1 │ interface VNode {
│ ^^^^^
2 │ hello: 'world'
3 │ }

i If you want to use consecutive uppercase characters in PascalCase, then set the strictCase option to `false`.
See the rule options for more details.


```

```
invalidStrictPascalCase.ts:4:6 lint/style/useNamingConvention ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Two consecutive uppercase characters are not allowed in PascalCase because strictCase is set to `true`.

2 │ hello: 'world'
3 │ }
> 4 │ type AAb = any
│ ^^^

i If you want to use consecutive uppercase characters in PascalCase, then set the strictCase option to `false`.
See the rule options for more details.


```
Loading