@yuu1111/biome-config 1.3.7 → 1.3.9
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.ja.md +150 -0
- package/README.md +54 -9
- package/base.json +6 -0
- package/package.json +2 -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.ja.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
[English](README.md)
|
|
2
|
+
|
|
3
|
+
# @yuu1111/biome-config
|
|
4
|
+
|
|
5
|
+
共有の [Biome](https://biomejs.dev/) 設定
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add -D @yuu1111/biome-config
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Base
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
20
|
+
"extends": ["@yuu1111/biome-config/biome"]
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
base設定はrecommended ruleを有効にし、barrel fileとre-export-allをerror、nested ternary、空block文、過剰なcognitive complexityをwarningにする
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const size = small ? "s" : medium ? "m" : "l"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### React
|
|
31
|
+
|
|
32
|
+
CSS/Tailwind対応を含む
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
37
|
+
"extends": ["@yuu1111/biome-config/react"]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Custom rule presets
|
|
42
|
+
|
|
43
|
+
Custom ruleはopt-in baseまたはReact設定の後ろにpresetを1つ足す
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
48
|
+
"extends": [
|
|
49
|
+
"@yuu1111/biome-config/biome",
|
|
50
|
+
"@yuu1111/biome-config/plugins/network"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Projectに必要な最も具体的なpresetを選ぶ
|
|
56
|
+
|
|
57
|
+
- `plugins/core` はforwarding export、未完成実装、型安全の迂回、安全でないerrno assertion、無意味なtest、pass-through wrapper、副作用目的のternaryを検査する
|
|
58
|
+
- `plugins/network` は `core` を含み、`fetch` に `AbortSignal` を要求し、手動で予約したabort timeoutの後始末を検査する
|
|
59
|
+
- `plugins/discord` は `network` を含み、動的なDiscord messageに明示的なmention処理があるかを検査する
|
|
60
|
+
|
|
61
|
+
親presetを別に並べない 子presetは親のruleを含む
|
|
62
|
+
|
|
63
|
+
#### Core rules
|
|
64
|
+
|
|
65
|
+
- `no-reexports` は既存bindingを転送するだけのexport(`export type Alias = Imported`、`export default imported`、`export const wrapped = imported` など)をwarningにする `export ... from` の形はbaseのbarrel file ruleが担当する
|
|
66
|
+
- `no-incomplete-implementation` はplaceholderのthrowをerror、logだけのcatch、`null`・`[]`・`{}` へ置き換えたrejected promiseとcatchしたerrorをwarningにする
|
|
67
|
+
- `no-type-safety-bypass` は `as unknown as T` をerror、`Record<string, unknown>` のassertion、未検証のJSON assertion、静的な `Reflect.get`、receiver無しの `Reflect.apply` をwarningにする
|
|
68
|
+
- `no-unsafe-errno-assertion` はcatchした値を検証せず `NodeJS.ErrnoException` のassertion経由で `code` を直接読むコードをwarningにする
|
|
69
|
+
- `no-meaningless-test` はidentifierやliteralを自分自身と比較する `toBe`・`toEqual`・`toStrictEqual` をerror、空の `test`・`it` callbackをwarningにする
|
|
70
|
+
- `no-useless-abstraction` は同じ引数を別の関数へ渡すだけの名前付き単一引数arrow functionをwarningにする 同じ形のasync版も含む
|
|
71
|
+
- `no-ternary-statement` は `flag ? enable() : disable()` のような文としてのternaryをwarningにする if/elseの方が明確な箇所が対象
|
|
72
|
+
|
|
73
|
+
ruleは意図的に狭く保つ 検証、変換、log、cache、transaction開始などの処理を行うwrapperはpass-through wrapperとして報告しない 準備やassertionのあるtestは空として扱わない
|
|
74
|
+
|
|
75
|
+
`plugins/core` が報告する例
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
throw new Error("Not implemented")
|
|
79
|
+
request.catch(() => null)
|
|
80
|
+
|
|
81
|
+
const user = value as unknown as User
|
|
82
|
+
const parsed = JSON.parse(text) as User
|
|
83
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
84
|
+
|
|
85
|
+
test("placeholder", () => {})
|
|
86
|
+
expect(result).toEqual(result)
|
|
87
|
+
|
|
88
|
+
const loadUser = (id) => fetchUser(id)
|
|
89
|
+
|
|
90
|
+
flag ? enable() : disable()
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
理由を添えて意図的な例外を抑制する
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
// biome-ignore lint/plugin: An optional cache miss is an expected fallback
|
|
97
|
+
cacheRequest.catch(() => null)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Network rule
|
|
101
|
+
|
|
102
|
+
- `require-fetch-abort-signal` は `fetch` 呼び出しが `signal` optionを省いているとwarningにする
|
|
103
|
+
- `require-abort-timeout-cleanup` は `setTimeout` callbackで `fetch` をabortしていながらそのtimerをclearしない関数をwarningにする
|
|
104
|
+
|
|
105
|
+
#### Discord rule
|
|
106
|
+
|
|
107
|
+
`no-unsafe-dynamic-discord-message` は明示的な `allowedMentions` policy無しで動的なmessage内容を送るとwarningにする
|
|
108
|
+
|
|
109
|
+
#### Project-scoped rule
|
|
110
|
+
|
|
111
|
+
`no-adapter-import` は `integrations/` か `adapters/` を含むpathをmoduleがimportするとerrorにする 保護する層がProject固有のためpresetを持たない Project自身の設定で宣言し、`includes` で絞る
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"plugins": [
|
|
116
|
+
{
|
|
117
|
+
"path": "./node_modules/@yuu1111/biome-config/plugins/no-adapter-import.grit",
|
|
118
|
+
"includes": ["**/src/modules/authorization/**"]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
pluginは `includes` に一致したfileだけで走るため、同じimportはadapter側と統合層へ到達してよい層では有効なままになる pluginのpatternはfileのfull pathと照合されるため、`src/modules/authorization` のようなpathへ一致させるには `**/` から始める必要がある
|
|
125
|
+
|
|
126
|
+
統合moduleへ到達してよい層はpatternから外す 自身のadapter実装を `adapters/` に置くmoduleはそのディレクトリを除外しないと、ruleがadapter自身を報告する
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"includes": [
|
|
131
|
+
"**/src/modules/authorization/**",
|
|
132
|
+
"!**/src/modules/authorization/adapters/**"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`no-direct-response` は対象層での `new Response(...)`、`Response.json(...)`、`Response.redirect(...)` をerrorにする すべてのresponseを共有helper経由で組み立てる層へ絞る
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"plugins": [
|
|
142
|
+
{
|
|
143
|
+
"path": "./node_modules/@yuu1111/biome-config/plugins/no-direct-response.grit",
|
|
144
|
+
"includes": ["**/src/worker/routes/**"]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
helper module自身はpatternの外に置くため、responseを組み立ててよい
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[日本語](README.ja.md)
|
|
2
|
+
|
|
1
3
|
# @yuu1111/biome-config
|
|
2
4
|
|
|
3
5
|
Shared [Biome](https://biomejs.dev/) configuration.
|
|
@@ -14,12 +16,12 @@ bun add -D @yuu1111/biome-config
|
|
|
14
16
|
|
|
15
17
|
```json
|
|
16
18
|
{
|
|
17
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
19
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
18
20
|
"extends": ["@yuu1111/biome-config/biome"]
|
|
19
21
|
}
|
|
20
22
|
```
|
|
21
23
|
|
|
22
|
-
The base configuration enables the recommended rules, errors on barrel files and re-export-all, and warns about nested ternaries:
|
|
24
|
+
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
25
|
|
|
24
26
|
```ts
|
|
25
27
|
const size = small ? "s" : medium ? "m" : "l"
|
|
@@ -31,7 +33,7 @@ CSS/Tailwind support included.
|
|
|
31
33
|
|
|
32
34
|
```json
|
|
33
35
|
{
|
|
34
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
36
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
35
37
|
"extends": ["@yuu1111/biome-config/react"]
|
|
36
38
|
}
|
|
37
39
|
```
|
|
@@ -42,7 +44,7 @@ Custom rules are opt-in. Add one preset after the base or React configuration:
|
|
|
42
44
|
|
|
43
45
|
```json
|
|
44
46
|
{
|
|
45
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
47
|
+
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
|
|
46
48
|
"extends": [
|
|
47
49
|
"@yuu1111/biome-config/biome",
|
|
48
50
|
"@yuu1111/biome-config/plugins/network"
|
|
@@ -52,7 +54,7 @@ Custom rules are opt-in. Add one preset after the base or React configuration:
|
|
|
52
54
|
|
|
53
55
|
Choose the most specific preset needed by the project:
|
|
54
56
|
|
|
55
|
-
- `plugins/core` checks
|
|
57
|
+
- `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
58
|
- `plugins/network` includes `core`, requires an `AbortSignal` for `fetch`, and checks cleanup for manually scheduled abort timeouts
|
|
57
59
|
- `plugins/discord` includes `network` and checks dynamic Discord messages for explicit mention handling
|
|
58
60
|
|
|
@@ -60,11 +62,11 @@ Do not list parent presets separately. Each child preset includes its parent rul
|
|
|
60
62
|
|
|
61
63
|
#### Core rules
|
|
62
64
|
|
|
63
|
-
- `no-reexports`
|
|
64
|
-
- `no-incomplete-implementation`
|
|
65
|
-
- `no-type-safety-bypass`
|
|
65
|
+
- `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
|
|
66
|
+
- `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 `{}`
|
|
67
|
+
- `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
68
|
- `no-unsafe-errno-assertion` warns when code reads `code` directly through a `NodeJS.ErrnoException` assertion without validating the caught value
|
|
67
|
-
- `no-meaningless-test`
|
|
69
|
+
- `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
70
|
- `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
71
|
- `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
72
|
|
|
@@ -103,3 +105,46 @@ cacheRequest.catch(() => null)
|
|
|
103
105
|
#### Discord rule
|
|
104
106
|
|
|
105
107
|
`no-unsafe-dynamic-discord-message` warns when dynamic message content is sent without an explicit `allowedMentions` policy.
|
|
108
|
+
|
|
109
|
+
#### Project-scoped rule
|
|
110
|
+
|
|
111
|
+
`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`:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"plugins": [
|
|
116
|
+
{
|
|
117
|
+
"path": "./node_modules/@yuu1111/biome-config/plugins/no-adapter-import.grit",
|
|
118
|
+
"includes": ["**/src/modules/authorization/**"]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
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`.
|
|
125
|
+
|
|
126
|
+
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:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"includes": [
|
|
131
|
+
"**/src/modules/authorization/**",
|
|
132
|
+
"!**/src/modules/authorization/adapters/**"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`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:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"plugins": [
|
|
142
|
+
{
|
|
143
|
+
"path": "./node_modules/@yuu1111/biome-config/plugins/no-direct-response.grit",
|
|
144
|
+
"includes": ["**/src/worker/routes/**"]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuu1111/biome-config",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "Shared Biome configuration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"./react": "./react.json"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
|
+
"README.ja.md",
|
|
19
20
|
"base.json",
|
|
20
21
|
"plugins",
|
|
21
22
|
"plugins-core.json",
|
|
@@ -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
|
},
|