Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/metal-plants-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed [#7798](https://github.com/biomejs/biome/issues/7798). [useNamingConvention](https://biomejs.dev/linter/rules/use-naming-convention/) no longer panics when it encounters a name that consists of a single dollar sign `$` that doesn't match a custom convention.
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ 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 {
if name == new_name || new_name.is_empty() {
return None;
}
let mut mutation = ctx.root().begin();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const $ = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: invalidSIngleDollarName.js
---
# Input
```js
const $ = 0;

```

# Diagnostics
```
invalidSIngleDollarName.js:1:7 lint/style/useNamingConvention ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i This variable name should be in camelCase or PascalCase or CONSTANT_CASE.

> 1 │ const $ = 0;
│ ^
2 │


```
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"linter": {
"enabled": true,
"rules": {
"style": {
"useNamingConvention": {
"level": "warn",
"options": {
"strictCase": false,
"conventions": [
{
"selector": {
"kind": "variable"
},
"formats": [
"camelCase",
"CONSTANT_CASE",
"PascalCase"
]
}
]
}
}
}
}
}
}