@yuu1111/biome-config 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -9
- package/base.json +6 -0
- package/package.json +1 -1
- package/plugins/no-adapter-import.grit +9 -0
- package/plugins/no-direct-response.grit +20 -0
- package/plugins/no-incomplete-implementation.grit +32 -14
- package/plugins/no-meaningless-test.grit +20 -11
- package/plugins/no-reexports.grit +3 -4
- package/plugins/no-type-safety-bypass.grit +1 -1
- package/react.json +6 -0
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ bun add -D @yuu1111/biome-config
|
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
17
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
17
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
18
18
|
"extends": ["@yuu1111/biome-config/biome"]
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
The base configuration enables the recommended rules, errors on barrel files and re-export-all, and warns about nested ternaries:
|
|
22
|
+
The base configuration enables the recommended rules, errors on barrel files and re-export-all, and warns about nested ternaries, empty block statements, and excessive cognitive complexity:
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
const size = small ? "s" : medium ? "m" : "l"
|
|
@@ -31,7 +31,7 @@ CSS/Tailwind support included.
|
|
|
31
31
|
|
|
32
32
|
```json
|
|
33
33
|
{
|
|
34
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
34
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
35
35
|
"extends": ["@yuu1111/biome-config/react"]
|
|
36
36
|
}
|
|
37
37
|
```
|
|
@@ -42,7 +42,7 @@ Custom rules are opt-in. Add one preset after the base or React configuration:
|
|
|
42
42
|
|
|
43
43
|
```json
|
|
44
44
|
{
|
|
45
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
45
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
46
46
|
"extends": [
|
|
47
47
|
"@yuu1111/biome-config/biome",
|
|
48
48
|
"@yuu1111/biome-config/plugins/network"
|
|
@@ -52,7 +52,7 @@ Custom rules are opt-in. Add one preset after the base or React configuration:
|
|
|
52
52
|
|
|
53
53
|
Choose the most specific preset needed by the project:
|
|
54
54
|
|
|
55
|
-
- `plugins/core` checks
|
|
55
|
+
- `plugins/core` checks forwarding exports, incomplete implementations, type-safety bypasses, unsafe errno assertions, meaningless tests, pass-through wrappers, and ternaries used for side effects
|
|
56
56
|
- `plugins/network` includes `core`, requires an `AbortSignal` for `fetch`, and checks cleanup for manually scheduled abort timeouts
|
|
57
57
|
- `plugins/discord` includes `network` and checks dynamic Discord messages for explicit mention handling
|
|
58
58
|
|
|
@@ -60,11 +60,11 @@ Do not list parent presets separately. Each child preset includes its parent rul
|
|
|
60
60
|
|
|
61
61
|
#### Core rules
|
|
62
62
|
|
|
63
|
-
- `no-reexports`
|
|
64
|
-
- `no-incomplete-implementation`
|
|
65
|
-
- `no-type-safety-bypass`
|
|
63
|
+
- `no-reexports` warns about exports that only forward an existing binding, such as `export type Alias = Imported`, `export default imported`, or `export const wrapped = imported`; the `export ... from` forms are covered by the base barrel-file rules
|
|
64
|
+
- `no-incomplete-implementation` errors on placeholder throws and warns about catch blocks that only log, and rejected promises or caught errors replaced with `null`, `[]`, or `{}`
|
|
65
|
+
- `no-type-safety-bypass` errors on `as unknown as T` and warns about `Record<string, unknown>` assertions, unchecked JSON assertions, static `Reflect.get`, and receiver-free `Reflect.apply`
|
|
66
66
|
- `no-unsafe-errno-assertion` warns when code reads `code` directly through a `NodeJS.ErrnoException` assertion without validating the caught value
|
|
67
|
-
- `no-meaningless-test`
|
|
67
|
+
- `no-meaningless-test` errors on `toBe`, `toEqual`, or `toStrictEqual` comparisons where an identifier or literal is compared with itself, and warns about empty `test` or `it` callbacks
|
|
68
68
|
- `no-useless-abstraction` warns about named single-argument arrow functions that only pass the same argument to another function, including the equivalent async form
|
|
69
69
|
- `no-ternary-statement` warns when a ternary operator is used as a standalone statement, such as `flag ? enable() : disable()`, where an if/else statement is clearer
|
|
70
70
|
|
|
@@ -103,3 +103,46 @@ cacheRequest.catch(() => null)
|
|
|
103
103
|
#### Discord rule
|
|
104
104
|
|
|
105
105
|
`no-unsafe-dynamic-discord-message` warns when dynamic message content is sent without an explicit `allowedMentions` policy.
|
|
106
|
+
|
|
107
|
+
#### Project-scoped rule
|
|
108
|
+
|
|
109
|
+
`no-adapter-import` errors when a module imports a path that contains `integrations/` or `adapters/`. It has no preset because the layer it protects is specific to the project. Declare it in the project's own configuration and narrow it with `includes`:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"plugins": [
|
|
114
|
+
{
|
|
115
|
+
"path": "./node_modules/@yuu1111/biome-config/plugins/no-adapter-import.grit",
|
|
116
|
+
"includes": ["**/src/modules/authorization/**"]
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The plugin runs only on the files that match `includes`, so the same import stays valid in the adapters and in the layers that are allowed to reach them. A plugin pattern is matched against the full file path, so it has to start with `**/` to match a path such as `src/modules/authorization`.
|
|
123
|
+
|
|
124
|
+
Leave the layer that is allowed to reach the integration modules out of the pattern. A module that keeps its own adapter implementations under an `adapters/` directory has to exclude that directory, or the rule reports the adapters themselves:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"includes": [
|
|
129
|
+
"**/src/modules/authorization/**",
|
|
130
|
+
"!**/src/modules/authorization/adapters/**"
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`no-direct-response` errors on `new Response(...)`, `Response.json(...)` and `Response.redirect(...)` inside the scoped layer. Scope it to the layer that has to build every response through the shared helper:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"plugins": [
|
|
140
|
+
{
|
|
141
|
+
"path": "./node_modules/@yuu1111/biome-config/plugins/no-direct-response.grit",
|
|
142
|
+
"includes": ["**/src/worker/routes/**"]
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The helper module itself stays outside the pattern, so it can still construct responses.
|
package/base.json
CHANGED
|
@@ -18,12 +18,18 @@
|
|
|
18
18
|
"enabled": true,
|
|
19
19
|
"rules": {
|
|
20
20
|
"recommended": true,
|
|
21
|
+
"complexity": {
|
|
22
|
+
"noExcessiveCognitiveComplexity": "warn"
|
|
23
|
+
},
|
|
21
24
|
"performance": {
|
|
22
25
|
"noBarrelFile": "error",
|
|
23
26
|
"noReExportAll": "error"
|
|
24
27
|
},
|
|
25
28
|
"style": {
|
|
26
29
|
"noNestedTernary": "warn"
|
|
30
|
+
},
|
|
31
|
+
"suspicious": {
|
|
32
|
+
"noEmptyBlockStatements": "warn"
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
},
|
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
JsImport() as $match where {
|
|
5
|
+
$match <: contains JsModuleSource() as $source where {
|
|
6
|
+
$source <: r".*(?:integrations|adapters)/.*"
|
|
7
|
+
},
|
|
8
|
+
register_diagnostic(span=$match, message="Import the port instead of the adapter module", severity="error")
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
`new Response($...)` as $match where {
|
|
6
|
+
register_diagnostic(span=$match, message="Build the response with the shared response helper", severity="error")
|
|
7
|
+
},
|
|
8
|
+
`Response.json($body)` as $match where {
|
|
9
|
+
register_diagnostic(span=$match, message="Build the response with the shared response helper", severity="error")
|
|
10
|
+
},
|
|
11
|
+
`Response.json($body, $init)` as $match where {
|
|
12
|
+
register_diagnostic(span=$match, message="Build the response with the shared response helper", severity="error")
|
|
13
|
+
},
|
|
14
|
+
`Response.redirect($url)` as $match where {
|
|
15
|
+
register_diagnostic(span=$match, message="Build the response with the shared response helper", severity="error")
|
|
16
|
+
},
|
|
17
|
+
`Response.redirect($url, $status)` as $match where {
|
|
18
|
+
register_diagnostic(span=$match, message="Build the response with the shared response helper", severity="error")
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -3,22 +3,40 @@ language js(typescript)
|
|
|
3
3
|
|
|
4
4
|
or {
|
|
5
5
|
JsThrowStatement(argument=JsNewExpression(callee=JsIdentifierExpression())) as $match where {
|
|
6
|
-
$match <: r"(?i).*not[ -]?implemented.*|.*todo.*|.*coming soon.*"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`$promise.catch(() =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`$promise.catch((
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
$match <: r"(?i).*not[ -]?implemented.*|.*todo.*|.*coming soon.*",
|
|
7
|
+
register_diagnostic(span=$match, message="Remove the placeholder implementation", severity="error")
|
|
8
|
+
},
|
|
9
|
+
`$promise.catch(() => null)` as $match where {
|
|
10
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
11
|
+
},
|
|
12
|
+
`$promise.catch(() => [])` as $match where {
|
|
13
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
14
|
+
},
|
|
15
|
+
`$promise.catch(() => ({}))` as $match where {
|
|
16
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
17
|
+
},
|
|
18
|
+
`$promise.catch(($error) => null)` as $match where {
|
|
19
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
20
|
+
},
|
|
21
|
+
`$promise.catch(($error) => [])` as $match where {
|
|
22
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
23
|
+
},
|
|
24
|
+
`$promise.catch(($error) => ({}))` as $match where {
|
|
25
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
26
|
+
},
|
|
27
|
+
`try { $...body } catch ($error) { return null; }` as $match where {
|
|
28
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
29
|
+
},
|
|
30
|
+
`try { $...body } catch ($error) { return []; }` as $match where {
|
|
31
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
32
|
+
},
|
|
33
|
+
`try { $...body } catch ($error) { return {}; }` as $match where {
|
|
34
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
35
|
+
},
|
|
17
36
|
JsCatchClause(body=JsBlockStatement(statements=[
|
|
18
37
|
$statement
|
|
19
38
|
])) as $match where {
|
|
20
|
-
$statement <: r"^console\.(?:debug|error|info|log|warn)\(.*"
|
|
39
|
+
$statement <: r"^console\.(?:debug|error|info|log|warn)\(.*",
|
|
40
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
21
41
|
}
|
|
22
|
-
} where {
|
|
23
|
-
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
24
42
|
}
|
|
@@ -2,36 +2,45 @@ engine biome(1.0)
|
|
|
2
2
|
language js(typescript)
|
|
3
3
|
|
|
4
4
|
or {
|
|
5
|
-
`$test($name, () => {}, $...)` as $match where {
|
|
5
|
+
`$test($name, () => {}, $...)` as $match where {
|
|
6
|
+
$test <: r"^(?:test|it)$",
|
|
7
|
+
register_diagnostic(span=$match, message="Remove empty tests", severity="warn")
|
|
8
|
+
},
|
|
6
9
|
`$test($name, async () => {}, $...)` as $match where {
|
|
7
|
-
$test <: r"^(?:test|it)$"
|
|
10
|
+
$test <: r"^(?:test|it)$",
|
|
11
|
+
register_diagnostic(span=$match, message="Remove empty tests", severity="warn")
|
|
8
12
|
},
|
|
9
13
|
`$test($name, function () {}, $...)` as $match where {
|
|
10
|
-
$test <: r"^(?:test|it)$"
|
|
14
|
+
$test <: r"^(?:test|it)$",
|
|
15
|
+
register_diagnostic(span=$match, message="Remove empty tests", severity="warn")
|
|
11
16
|
},
|
|
12
17
|
`$test($name, async function () {}, $...)` as $match where {
|
|
13
|
-
$test <: r"^(?:test|it)$"
|
|
18
|
+
$test <: r"^(?:test|it)$",
|
|
19
|
+
register_diagnostic(span=$match, message="Remove empty tests", severity="warn")
|
|
14
20
|
},
|
|
15
21
|
`expect($value).$matcher($value)` as $match where {
|
|
16
22
|
$value <: JsIdentifierExpression(),
|
|
17
|
-
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
23
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$",
|
|
24
|
+
register_diagnostic(span=$match, message="Remove tautological assertions", severity="error")
|
|
18
25
|
},
|
|
19
26
|
`expect($value).$matcher($value)` as $match where {
|
|
20
27
|
$value <: JsStringLiteralExpression(),
|
|
21
|
-
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
28
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$",
|
|
29
|
+
register_diagnostic(span=$match, message="Remove tautological assertions", severity="error")
|
|
22
30
|
},
|
|
23
31
|
`expect($value).$matcher($value)` as $match where {
|
|
24
32
|
$value <: JsNumberLiteralExpression(),
|
|
25
|
-
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
33
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$",
|
|
34
|
+
register_diagnostic(span=$match, message="Remove tautological assertions", severity="error")
|
|
26
35
|
},
|
|
27
36
|
`expect($value).$matcher($value)` as $match where {
|
|
28
37
|
$value <: JsBooleanLiteralExpression(),
|
|
29
|
-
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
38
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$",
|
|
39
|
+
register_diagnostic(span=$match, message="Remove tautological assertions", severity="error")
|
|
30
40
|
},
|
|
31
41
|
`expect($value).$matcher($value)` as $match where {
|
|
32
42
|
$value <: JsNullLiteralExpression(),
|
|
33
|
-
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
43
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$",
|
|
44
|
+
register_diagnostic(span=$match, message="Remove tautological assertions", severity="error")
|
|
34
45
|
}
|
|
35
|
-
} where {
|
|
36
|
-
register_diagnostic(span=$match, message="Remove empty or tautological tests", severity="warn")
|
|
37
46
|
}
|
|
@@ -2,9 +2,6 @@ engine biome(1.0)
|
|
|
2
2
|
language js(typescript)
|
|
3
3
|
|
|
4
4
|
or {
|
|
5
|
-
JsExport(export_clause=JsExportFromClause()) as $match,
|
|
6
|
-
JsExport(export_clause=JsExportNamedFromClause()) as $match,
|
|
7
|
-
JsExport(export_clause=JsExportNamedClause()) as $match,
|
|
8
5
|
JsExport(export_clause=TsTypeAliasDeclaration(ty=$type)) as $match where {
|
|
9
6
|
$type <: r"^[A-Za-z_$][A-Za-z0-9_$]*$",
|
|
10
7
|
not $type <: r"^(?:any|bigint|boolean|never|null|number|object|string|symbol|undefined|unknown|void)$"
|
|
@@ -13,4 +10,6 @@ or {
|
|
|
13
10
|
JsExport(export_clause=JsVariableDeclarationClause(declaration=JsVariableDeclaration(declarators=$declarators))) as $match where {
|
|
14
11
|
$declarators <: some JsVariableDeclarator(initializer=JsInitializerClause(expression=JsIdentifierExpression()))
|
|
15
12
|
}
|
|
16
|
-
} where {
|
|
13
|
+
} where {
|
|
14
|
+
register_diagnostic(span=$match, message="Re-export is prohibited", severity="warn")
|
|
15
|
+
}
|
|
@@ -3,7 +3,7 @@ language js(typescript)
|
|
|
3
3
|
|
|
4
4
|
or {
|
|
5
5
|
`$value as unknown as $type` as $match where {
|
|
6
|
-
register_diagnostic(span=$match, message="Do not bypass type safety with a chained assertion", severity="
|
|
6
|
+
register_diagnostic(span=$match, message="Do not bypass type safety with a chained assertion", severity="error")
|
|
7
7
|
},
|
|
8
8
|
`$value as Record<string, unknown>` as $match where {
|
|
9
9
|
register_diagnostic(span=$match, message="Validate the object shape instead of asserting a generic dictionary", severity="warn")
|
package/react.json
CHANGED
|
@@ -18,12 +18,18 @@
|
|
|
18
18
|
"enabled": true,
|
|
19
19
|
"rules": {
|
|
20
20
|
"recommended": true,
|
|
21
|
+
"complexity": {
|
|
22
|
+
"noExcessiveCognitiveComplexity": "warn"
|
|
23
|
+
},
|
|
21
24
|
"performance": {
|
|
22
25
|
"noBarrelFile": "error",
|
|
23
26
|
"noReExportAll": "error"
|
|
24
27
|
},
|
|
25
28
|
"style": {
|
|
26
29
|
"noNestedTernary": "warn"
|
|
30
|
+
},
|
|
31
|
+
"suspicious": {
|
|
32
|
+
"noEmptyBlockStatements": "warn"
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
},
|