@yuu1111/biome-config 1.2.0 → 1.3.1

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 CHANGED
@@ -46,8 +46,51 @@ Custom rules are opt-in. Add one preset after the base or React configuration:
46
46
 
47
47
  Choose the most specific preset needed by the project:
48
48
 
49
- - `plugins/core` prohibits re-exports and unchecked JSON type assertions
50
- - `plugins/network` includes `core` and requires an `AbortSignal` for `fetch`
49
+ - `plugins/core` checks re-exports, incomplete implementations, type-safety bypasses, unsafe errno assertions, meaningless tests, and pass-through wrappers
50
+ - `plugins/network` includes `core`, requires an `AbortSignal` for `fetch`, and checks cleanup for manually scheduled abort timeouts
51
51
  - `plugins/discord` includes `network` and checks dynamic Discord messages for explicit mention handling
52
52
 
53
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-unsafe-errno-assertion` warns when code reads `code` directly through a `NodeJS.ErrnoException` assertion without validating the caught value
61
+ - `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
62
+ - `no-useless-abstraction` warns about named single-argument arrow functions that only pass the same argument to another function, including the equivalent async form
63
+
64
+ 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.
65
+
66
+ Examples reported by `plugins/core`:
67
+
68
+ ```ts
69
+ throw new Error("Not implemented")
70
+ request.catch(() => null)
71
+
72
+ const user = value as unknown as User
73
+ const parsed = JSON.parse(text) as User
74
+ const code = (error as NodeJS.ErrnoException).code
75
+
76
+ test("placeholder", () => {})
77
+ expect(result).toEqual(result)
78
+
79
+ const loadUser = (id) => fetchUser(id)
80
+ ```
81
+
82
+ Suppress an intentional exception with a reason:
83
+
84
+ ```ts
85
+ // biome-ignore lint/plugin: An optional cache miss is an expected fallback
86
+ cacheRequest.catch(() => null)
87
+ ```
88
+
89
+ #### Network rule
90
+
91
+ - `require-fetch-abort-signal` warns when a `fetch` call omits the `signal` option
92
+ - `require-abort-timeout-cleanup` warns when a function uses a `setTimeout` callback to abort a `fetch` request but does not clear that timer
93
+
94
+ #### Discord rule
95
+
96
+ `no-unsafe-dynamic-discord-message` warns when dynamic message content is sent without an explicit `allowedMentions` policy.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuu1111/biome-config",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Shared Biome configuration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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,9 @@
1
+ engine biome(1.0)
2
+ language js(typescript)
3
+
4
+ or {
5
+ `($value as NodeJS.ErrnoException).code` as $match,
6
+ `($value as NodeJS.ErrnoException)["code"]` as $match
7
+ } where {
8
+ register_diagnostic(span=$match, message="Validate the error shape before reading errno properties", severity="warn")
9
+ }
@@ -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,11 @@
1
+ engine biome(1.0)
2
+ language js(typescript)
3
+
4
+ `const $timer = setTimeout(() => $controller.abort(), $delay)` as $match where {
5
+ $match <: within JsFunctionBody() as $scope ,
6
+ $scope <: contains `fetch($url, { $... })` as $fetch where {
7
+ $fetch <: contains `signal: $controller.signal`
8
+ },
9
+ not $scope <: contains `clearTimeout($timer)`,
10
+ register_diagnostic(span=$match, message="Clear the AbortController timeout after using its signal", severity="warn")
11
+ }
package/plugins-core.json CHANGED
@@ -2,6 +2,10 @@
2
2
  "$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
3
3
  "plugins": [
4
4
  "./node_modules/@yuu1111/biome-config/plugins/no-reexports.grit",
5
- "./node_modules/@yuu1111/biome-config/plugins/no-unvalidated-json-cast.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-unsafe-errno-assertion.grit",
8
+ "./node_modules/@yuu1111/biome-config/plugins/no-meaningless-test.grit",
9
+ "./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit"
6
10
  ]
7
11
  }
@@ -3,8 +3,13 @@
3
3
  "extends": ["./plugins-network.json"],
4
4
  "plugins": [
5
5
  "./node_modules/@yuu1111/biome-config/plugins/no-reexports.grit",
6
- "./node_modules/@yuu1111/biome-config/plugins/no-unvalidated-json-cast.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-unsafe-errno-assertion.grit",
9
+ "./node_modules/@yuu1111/biome-config/plugins/no-meaningless-test.grit",
10
+ "./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit",
7
11
  "./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.grit",
12
+ "./node_modules/@yuu1111/biome-config/plugins/require-abort-timeout-cleanup.grit",
8
13
  "./node_modules/@yuu1111/biome-config/plugins/no-unsafe-dynamic-discord-message.grit"
9
14
  ]
10
15
  }
@@ -3,7 +3,12 @@
3
3
  "extends": ["./plugins-core.json"],
4
4
  "plugins": [
5
5
  "./node_modules/@yuu1111/biome-config/plugins/no-reexports.grit",
6
- "./node_modules/@yuu1111/biome-config/plugins/no-unvalidated-json-cast.grit",
7
- "./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.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-unsafe-errno-assertion.grit",
9
+ "./node_modules/@yuu1111/biome-config/plugins/no-meaningless-test.grit",
10
+ "./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit",
11
+ "./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.grit",
12
+ "./node_modules/@yuu1111/biome-config/plugins/require-abort-timeout-cleanup.grit"
8
13
  ]
9
14
  }
@@ -1,19 +0,0 @@
1
- engine biome(1.0)
2
- language js(typescript)
3
-
4
- or {
5
- `JSON.parse($value) as $type` as $match where {
6
- not $type <: `unknown`,
7
- register_diagnostic(span=$match, message="Validate parsed JSON before asserting its type", severity="warn")
8
- },
9
- `JSON.parse($value) as unknown as $type` as $match where {
10
- register_diagnostic(span=$match, message="Validate parsed JSON before asserting its type", severity="warn")
11
- },
12
- `$response.json() as Promise<$type>` as $match where {
13
- register_diagnostic(span=$match, message="Validate the JSON response before asserting its type", severity="warn")
14
- },
15
- `(await $response.json()) as $type` as $match where {
16
- not $type <: `unknown`,
17
- register_diagnostic(span=$match, message="Validate the JSON response before asserting its type", severity="warn")
18
- }
19
- }