@yuu1111/biome-config 1.1.1 → 1.3.0
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 +64 -5
- package/base.json +0 -1
- package/package.json +7 -1
- package/plugins/no-incomplete-implementation.grit +24 -0
- package/plugins/no-meaningless-test.grit +37 -0
- package/plugins/no-type-safety-bypass.grit +30 -0
- package/plugins/no-unsafe-dynamic-discord-message.grit +37 -0
- package/plugins/no-useless-abstraction.grit +9 -0
- package/plugins/require-fetch-abort-signal.grit +16 -0
- package/plugins-core.json +10 -0
- package/plugins-discord.json +13 -0
- package/plugins-network.json +12 -0
package/README.md
CHANGED
|
@@ -12,12 +12,9 @@ bun add -D @yuu1111/biome-config
|
|
|
12
12
|
|
|
13
13
|
### Base
|
|
14
14
|
|
|
15
|
-
Includes a plugin that prohibits re-exports. Export declarations must define their
|
|
16
|
-
value or type directly instead of forwarding another declaration.
|
|
17
|
-
|
|
18
15
|
```json
|
|
19
16
|
{
|
|
20
|
-
"$schema": "https://biomejs.dev/schemas/2.4.
|
|
17
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
21
18
|
"extends": ["@yuu1111/biome-config/biome"]
|
|
22
19
|
}
|
|
23
20
|
```
|
|
@@ -28,7 +25,69 @@ CSS/Tailwind support included.
|
|
|
28
25
|
|
|
29
26
|
```json
|
|
30
27
|
{
|
|
31
|
-
"$schema": "https://biomejs.dev/schemas/2.4.
|
|
28
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
32
29
|
"extends": ["@yuu1111/biome-config/react"]
|
|
33
30
|
}
|
|
34
31
|
```
|
|
32
|
+
|
|
33
|
+
### Custom rule presets
|
|
34
|
+
|
|
35
|
+
Custom rules are opt-in. Add one preset after the base or React configuration:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
40
|
+
"extends": [
|
|
41
|
+
"@yuu1111/biome-config/biome",
|
|
42
|
+
"@yuu1111/biome-config/plugins/network"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Choose the most specific preset needed by the project:
|
|
48
|
+
|
|
49
|
+
- `plugins/core` checks re-exports, incomplete implementations, type-safety bypasses, meaningless tests, and pass-through wrappers
|
|
50
|
+
- `plugins/network` includes `core` and requires an `AbortSignal` for `fetch`
|
|
51
|
+
- `plugins/discord` includes `network` and checks dynamic Discord messages for explicit mention handling
|
|
52
|
+
|
|
53
|
+
Do not list parent presets separately. Each child preset includes its parent rules.
|
|
54
|
+
|
|
55
|
+
#### Core rules
|
|
56
|
+
|
|
57
|
+
- `no-reexports` prohibits exports that only forward an imported symbol or module
|
|
58
|
+
- `no-incomplete-implementation` warns about placeholder throws, catch blocks that only log, and rejected promises or caught errors replaced with `null`, `[]`, or `{}`
|
|
59
|
+
- `no-type-safety-bypass` warns about `as unknown as T`, `Record<string, unknown>` assertions, unchecked JSON assertions, static `Reflect.get`, and receiver-free `Reflect.apply`
|
|
60
|
+
- `no-meaningless-test` warns about empty `test` or `it` callbacks and `toBe`, `toEqual`, or `toStrictEqual` comparisons where an identifier or literal is compared with itself
|
|
61
|
+
- `no-useless-abstraction` warns about named single-argument arrow functions that only pass the same argument to another function, including the equivalent async form
|
|
62
|
+
|
|
63
|
+
The rules intentionally stay narrow. A wrapper that validates, transforms, logs, caches, starts a transaction, or performs another operation is not reported as a pass-through wrapper. Tests with setup or assertions are not treated as empty.
|
|
64
|
+
|
|
65
|
+
Examples reported by `plugins/core`:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
throw new Error("Not implemented")
|
|
69
|
+
request.catch(() => null)
|
|
70
|
+
|
|
71
|
+
const user = value as unknown as User
|
|
72
|
+
const parsed = JSON.parse(text) as User
|
|
73
|
+
|
|
74
|
+
test("placeholder", () => {})
|
|
75
|
+
expect(result).toEqual(result)
|
|
76
|
+
|
|
77
|
+
const loadUser = (id) => fetchUser(id)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Suppress an intentional exception with a reason:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// biome-ignore lint/plugin: An optional cache miss is an expected fallback
|
|
84
|
+
cacheRequest.catch(() => null)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Network rule
|
|
88
|
+
|
|
89
|
+
`require-fetch-abort-signal` warns when a `fetch` call omits the `signal` option.
|
|
90
|
+
|
|
91
|
+
#### Discord rule
|
|
92
|
+
|
|
93
|
+
`no-unsafe-dynamic-discord-message` warns when dynamic message content is sent without an explicit `allowedMentions` policy.
|
package/base.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuu1111/biome-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Shared Biome configuration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -10,11 +10,17 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
"./biome": "./base.json",
|
|
13
|
+
"./plugins/core": "./plugins-core.json",
|
|
14
|
+
"./plugins/discord": "./plugins-discord.json",
|
|
15
|
+
"./plugins/network": "./plugins-network.json",
|
|
13
16
|
"./react": "./react.json"
|
|
14
17
|
},
|
|
15
18
|
"files": [
|
|
16
19
|
"base.json",
|
|
17
20
|
"plugins",
|
|
21
|
+
"plugins-core.json",
|
|
22
|
+
"plugins-discord.json",
|
|
23
|
+
"plugins-network.json",
|
|
18
24
|
"react.json"
|
|
19
25
|
],
|
|
20
26
|
"keywords": [
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
JsThrowStatement(argument=JsNewExpression(callee=JsIdentifierExpression())) as $match where {
|
|
6
|
+
$match <: r"(?i).*not[ -]?implemented.*|.*todo.*|.*coming soon.*"
|
|
7
|
+
},
|
|
8
|
+
`$promise.catch(() => null)` as $match,
|
|
9
|
+
`$promise.catch(() => [])` as $match,
|
|
10
|
+
`$promise.catch(() => ({}))` as $match,
|
|
11
|
+
`$promise.catch(($error) => null)` as $match,
|
|
12
|
+
`$promise.catch(($error) => [])` as $match,
|
|
13
|
+
`$promise.catch(($error) => ({}))` as $match,
|
|
14
|
+
`try { $...body } catch ($error) { return null; }` as $match,
|
|
15
|
+
`try { $...body } catch ($error) { return []; }` as $match,
|
|
16
|
+
`try { $...body } catch ($error) { return {}; }` as $match,
|
|
17
|
+
JsCatchClause(body=JsBlockStatement(statements=[
|
|
18
|
+
$statement
|
|
19
|
+
])) as $match where {
|
|
20
|
+
$statement <: r"^console\.(?:debug|error|info|log|warn)\(.*"
|
|
21
|
+
}
|
|
22
|
+
} where {
|
|
23
|
+
register_diagnostic(span=$match, message="Do not leave incomplete implementations or silently replace failures", severity="warn")
|
|
24
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
`$test($name, () => {}, $...)` as $match where { $test <: r"^(?:test|it)$" },
|
|
6
|
+
`$test($name, async () => {}, $...)` as $match where {
|
|
7
|
+
$test <: r"^(?:test|it)$"
|
|
8
|
+
},
|
|
9
|
+
`$test($name, function () {}, $...)` as $match where {
|
|
10
|
+
$test <: r"^(?:test|it)$"
|
|
11
|
+
},
|
|
12
|
+
`$test($name, async function () {}, $...)` as $match where {
|
|
13
|
+
$test <: r"^(?:test|it)$"
|
|
14
|
+
},
|
|
15
|
+
`expect($value).$matcher($value)` as $match where {
|
|
16
|
+
$value <: JsIdentifierExpression(),
|
|
17
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
18
|
+
},
|
|
19
|
+
`expect($value).$matcher($value)` as $match where {
|
|
20
|
+
$value <: JsStringLiteralExpression(),
|
|
21
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
22
|
+
},
|
|
23
|
+
`expect($value).$matcher($value)` as $match where {
|
|
24
|
+
$value <: JsNumberLiteralExpression(),
|
|
25
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
26
|
+
},
|
|
27
|
+
`expect($value).$matcher($value)` as $match where {
|
|
28
|
+
$value <: JsBooleanLiteralExpression(),
|
|
29
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
30
|
+
},
|
|
31
|
+
`expect($value).$matcher($value)` as $match where {
|
|
32
|
+
$value <: JsNullLiteralExpression(),
|
|
33
|
+
$matcher <: r"^(?:toBe|toEqual|toStrictEqual)$"
|
|
34
|
+
}
|
|
35
|
+
} where {
|
|
36
|
+
register_diagnostic(span=$match, message="Remove empty or tautological tests", severity="warn")
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
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="warn")
|
|
7
|
+
},
|
|
8
|
+
`$value as Record<string, unknown>` as $match where {
|
|
9
|
+
register_diagnostic(span=$match, message="Validate the object shape instead of asserting a generic dictionary", severity="warn")
|
|
10
|
+
},
|
|
11
|
+
`JSON.parse($value) as $type` as $match where {
|
|
12
|
+
not $type <: `unknown`,
|
|
13
|
+
register_diagnostic(span=$match, message="Validate parsed JSON before asserting its type", severity="warn")
|
|
14
|
+
},
|
|
15
|
+
`$response.json() as Promise<$type>` as $match where {
|
|
16
|
+
register_diagnostic(span=$match, message="Validate the JSON response before asserting its type", severity="warn")
|
|
17
|
+
},
|
|
18
|
+
`(await $response.json()) as $type` as $match where {
|
|
19
|
+
not $type <: `unknown`,
|
|
20
|
+
register_diagnostic(span=$match, message="Validate the JSON response before asserting its type", severity="warn")
|
|
21
|
+
},
|
|
22
|
+
`Reflect.get($object, $property)` as $match where {
|
|
23
|
+
$property <: JsStringLiteralExpression(),
|
|
24
|
+
register_diagnostic(span=$match, message="Use direct property access when the property name is static", severity="warn")
|
|
25
|
+
},
|
|
26
|
+
`Reflect.apply($function, undefined, $arguments)` as $match where {
|
|
27
|
+
$arguments <: JsArrayExpression(),
|
|
28
|
+
register_diagnostic(span=$match, message="Call the function directly when no receiver is required", severity="warn")
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
`$target.$method($content)` as $match where {
|
|
6
|
+
$method <: r"^(?:reply|send|editReply|followUp|update)$",
|
|
7
|
+
or {
|
|
8
|
+
$content <: JsIdentifierExpression(),
|
|
9
|
+
$content <: JsTemplateExpression()
|
|
10
|
+
},
|
|
11
|
+
register_diagnostic(span=$match, message="Wrap dynamic Discord content in a payload that disables mentions", severity="warn")
|
|
12
|
+
},
|
|
13
|
+
`$target.$method({ $... })` as $match where {
|
|
14
|
+
$method <: r"^(?:reply|send|editReply|followUp|update)$",
|
|
15
|
+
$match <: contains `content: $content`,
|
|
16
|
+
or {
|
|
17
|
+
$content <: JsIdentifierExpression(),
|
|
18
|
+
$content <: JsTemplateExpression()
|
|
19
|
+
},
|
|
20
|
+
not $match <: contains `allowedMentions: $allowedMentions`,
|
|
21
|
+
not $match <: contains JsShorthandPropertyObjectMember(name=$name) where {
|
|
22
|
+
$name <: `allowedMentions`
|
|
23
|
+
},
|
|
24
|
+
register_diagnostic(span=$match, message="Set allowedMentions when sending dynamic Discord content", severity="warn")
|
|
25
|
+
},
|
|
26
|
+
`$target.$method({ $... })` as $match where {
|
|
27
|
+
$method <: r"^(?:reply|send|editReply|followUp|update)$",
|
|
28
|
+
$match <: contains JsShorthandPropertyObjectMember(name=$content) where {
|
|
29
|
+
$content <: `content`
|
|
30
|
+
},
|
|
31
|
+
not $match <: contains `allowedMentions: $allowedMentions`,
|
|
32
|
+
not $match <: contains JsShorthandPropertyObjectMember(name=$name) where {
|
|
33
|
+
$name <: `allowedMentions`
|
|
34
|
+
},
|
|
35
|
+
register_diagnostic(span=$match, message="Set allowedMentions when sending dynamic Discord content", severity="warn")
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
`const $wrapper = ($argument) => $target($argument)` as $match,
|
|
6
|
+
`const $wrapper = async ($argument) => await $target($argument)` as $match
|
|
7
|
+
} where {
|
|
8
|
+
register_diagnostic(span=$match, message="Remove pass-through wrappers that add no behavior", severity="warn")
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
`fetch($url)` as $match where {
|
|
6
|
+
$url <: [$argument],
|
|
7
|
+
register_diagnostic(span=$match, message="Pass an AbortSignal to external fetch calls", severity="warn")
|
|
8
|
+
},
|
|
9
|
+
`fetch($url, { $... })` as $match where {
|
|
10
|
+
not $match <: contains `signal: $signal`,
|
|
11
|
+
not $match <: contains JsShorthandPropertyObjectMember(name=$name) where {
|
|
12
|
+
$name <: `signal`
|
|
13
|
+
},
|
|
14
|
+
register_diagnostic(span=$match, message="Pass an AbortSignal to external fetch calls", severity="warn")
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
3
|
+
"plugins": [
|
|
4
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-reexports.grit",
|
|
5
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-incomplete-implementation.grit",
|
|
6
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-type-safety-bypass.grit",
|
|
7
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-meaningless-test.grit",
|
|
8
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit"
|
|
9
|
+
]
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
3
|
+
"extends": ["./plugins-network.json"],
|
|
4
|
+
"plugins": [
|
|
5
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-reexports.grit",
|
|
6
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-incomplete-implementation.grit",
|
|
7
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-type-safety-bypass.grit",
|
|
8
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-meaningless-test.grit",
|
|
9
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit",
|
|
10
|
+
"./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.grit",
|
|
11
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-unsafe-dynamic-discord-message.grit"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
3
|
+
"extends": ["./plugins-core.json"],
|
|
4
|
+
"plugins": [
|
|
5
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-reexports.grit",
|
|
6
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-incomplete-implementation.grit",
|
|
7
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-type-safety-bypass.grit",
|
|
8
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-meaningless-test.grit",
|
|
9
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit",
|
|
10
|
+
"./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.grit"
|
|
11
|
+
]
|
|
12
|
+
}
|