@yuu1111/biome-config 1.0.4 → 1.2.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 +24 -2
- package/base.json +1 -1
- package/package.json +28 -16
- package/plugins/no-reexports.grit +16 -0
- package/plugins/no-unsafe-dynamic-discord-message.grit +37 -0
- package/plugins/no-unvalidated-json-cast.grit +19 -0
- package/plugins/require-fetch-abort-signal.grit +16 -0
- package/plugins-core.json +7 -0
- package/plugins-discord.json +10 -0
- package/plugins-network.json +9 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ bun add -D @yuu1111/biome-config
|
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
17
|
-
"$schema": "https://biomejs.dev/schemas/2.4.
|
|
17
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
18
18
|
"extends": ["@yuu1111/biome-config/biome"]
|
|
19
19
|
}
|
|
20
20
|
```
|
|
@@ -25,7 +25,29 @@ CSS/Tailwind support included.
|
|
|
25
25
|
|
|
26
26
|
```json
|
|
27
27
|
{
|
|
28
|
-
"$schema": "https://biomejs.dev/schemas/2.4.
|
|
28
|
+
"$schema": "https://biomejs.dev/schemas/2.4.14/schema.json",
|
|
29
29
|
"extends": ["@yuu1111/biome-config/react"]
|
|
30
30
|
}
|
|
31
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` prohibits re-exports and unchecked JSON type assertions
|
|
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.
|
package/base.json
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
"name": "@yuu1111/biome-config",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Shared Biome configuration",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/yuu1111/configs.git",
|
|
9
|
+
"directory": "packages/biome-config"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
"./biome": "./base.json",
|
|
13
|
+
"./plugins/core": "./plugins-core.json",
|
|
14
|
+
"./plugins/discord": "./plugins-discord.json",
|
|
15
|
+
"./plugins/network": "./plugins-network.json",
|
|
16
|
+
"./react": "./react.json"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"base.json",
|
|
20
|
+
"plugins",
|
|
21
|
+
"plugins-core.json",
|
|
22
|
+
"plugins-discord.json",
|
|
23
|
+
"plugins-network.json",
|
|
24
|
+
"react.json"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"biome",
|
|
28
|
+
"config"
|
|
29
|
+
]
|
|
18
30
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
engine biome(1.0)
|
|
2
|
+
language js(typescript)
|
|
3
|
+
|
|
4
|
+
or {
|
|
5
|
+
JsExport(export_clause=JsExportFromClause()) as $match,
|
|
6
|
+
JsExport(export_clause=JsExportNamedFromClause()) as $match,
|
|
7
|
+
JsExport(export_clause=JsExportNamedClause()) as $match,
|
|
8
|
+
JsExport(export_clause=TsTypeAliasDeclaration(ty=$type)) as $match where {
|
|
9
|
+
$type <: r"^[A-Za-z_$][A-Za-z0-9_$]*$",
|
|
10
|
+
not $type <: r"^(?:any|bigint|boolean|never|null|number|object|string|symbol|undefined|unknown|void)$"
|
|
11
|
+
},
|
|
12
|
+
JsExport(export_clause=JsExportDefaultExpressionClause(expression=JsIdentifierExpression())) as $match,
|
|
13
|
+
JsExport(export_clause=JsVariableDeclarationClause(declaration=JsVariableDeclaration(declarators=$declarators))) as $match where {
|
|
14
|
+
$declarators <: some JsVariableDeclarator(initializer=JsInitializerClause(expression=JsIdentifierExpression()))
|
|
15
|
+
}
|
|
16
|
+
} where { register_diagnostic(span=$match, message="Re-export is prohibited") }
|
|
@@ -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,19 @@
|
|
|
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
|
+
}
|
|
@@ -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
|
+
"extends": ["./plugins-network.json"],
|
|
4
|
+
"plugins": [
|
|
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",
|
|
8
|
+
"./node_modules/@yuu1111/biome-config/plugins/no-unsafe-dynamic-discord-message.grit"
|
|
9
|
+
]
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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-unvalidated-json-cast.grit",
|
|
7
|
+
"./node_modules/@yuu1111/biome-config/plugins/require-fetch-abort-signal.grit"
|
|
8
|
+
]
|
|
9
|
+
}
|