@yuu1111/biome-config 1.2.0 → 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 CHANGED
@@ -46,8 +46,48 @@ 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
49
+ - `plugins/core` checks re-exports, incomplete implementations, type-safety bypasses, meaningless tests, and pass-through wrappers
50
50
  - `plugins/network` includes `core` and requires an `AbortSignal` for `fetch`
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-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuu1111/biome-config",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
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
+ `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
+ }
package/plugins-core.json CHANGED
@@ -2,6 +2,9 @@
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-meaningless-test.grit",
8
+ "./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit"
6
9
  ]
7
10
  }
@@ -3,7 +3,10 @@
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-meaningless-test.grit",
9
+ "./node_modules/@yuu1111/biome-config/plugins/no-useless-abstraction.grit",
7
10
  "./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.grit",
8
11
  "./node_modules/@yuu1111/biome-config/plugins/no-unsafe-dynamic-discord-message.grit"
9
12
  ]
@@ -3,7 +3,10 @@
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",
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",
7
10
  "./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.grit"
8
11
  ]
9
12
  }
@@ -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
- }