Skip to content

Commit 13cf2a0

Browse files
feat(use_filenaming_convention): add support for $ prefix
This adds support for TanStack routes which use a dollar sign (`$`) prefix
1 parent 6e8a50e commit 13cf2a0

File tree

7 files changed

+55
-3
lines changed

7 files changed

+55
-3
lines changed

crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ declare_lint_rule! {
2424
///
2525
/// The rule supports the following exceptions:
2626
///
27-
/// - The name of the file can start with a dot or a plus sign, be prefixed and suffixed by underscores `_`.
28-
/// For example, `.filename.js`, `+filename.js`, `__filename__.js`, or even `.__filename__.js`.
27+
/// - The name of the file can start with a dot, a plus sign, or a dollar sign, be prefixed and suffixed by underscores `_`.
28+
/// For example, `.filename.js`, `+filename.js`, `$filename.js`, `__filename__.js`, or even `.__filename__.js`.
2929
///
3030
/// The convention of prefixing a filename with a plus sign is used by [Sveltekit](https://kit.svelte.dev/docs/routing#page) and [Vike](https://vike.dev/route).
3131
///
@@ -217,7 +217,9 @@ impl Rule for UseFilenamingConvention {
217217
//
218218
// Support [Sveltekit](https://kit.svelte.dev/docs/routing#page) and
219219
// [Vike](https://vike.dev/route) routing conventions where page name starts with `+`.
220-
let file_name = if matches!(first_char, b'.' | b'+') {
220+
//
221+
// Support filenames starting with `$`.
222+
let file_name = if matches!(first_char, b'.' | b'+' | b'$') {
221223
&file_name[1..]
222224
} else {
223225
file_name
@@ -306,6 +308,8 @@ impl Rule for UseFilenamingConvention {
306308
split.next()?
307309
} else if let Some(stripped_name) = name.strip_prefix('+') {
308310
stripped_name
311+
} else if let Some(stripped_name) = name.strip_prefix('$') {
312+
stripped_name
309313
} else {
310314
name
311315
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* should generate diagnostics */
2+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
source: crates/biome_js_analyze/tests/spec_tests.rs
3+
expression: $INVALID.js
4+
---
5+
# Input
6+
```js
7+
/* should generate diagnostics */
8+
9+
10+
```
11+
12+
# Diagnostics
13+
```
14+
$INVALID.js lint/style/useFilenamingConvention ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
15+
16+
i The filename should be in camelCase or kebab-case or snake_case or equal to the name of an export.
17+
18+
i The filename could be renamed to one of the following names:
19+
$invalid.js
20+
21+
22+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* should not generate diagnostics */
2+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
source: crates/biome_js_analyze/tests/spec_tests.rs
3+
expression: $dollarValid.js
4+
---
5+
# Input
6+
```js
7+
/* should not generate diagnostics */
8+
9+
10+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* should not generate diagnostics */
2+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
source: crates/biome_js_analyze/tests/spec_tests.rs
3+
expression: $dollar_snake.js
4+
---
5+
# Input
6+
```js
7+
/* should not generate diagnostics */
8+
9+
10+
```

0 commit comments

Comments
 (0)