@yuu1111/biome-config 1.1.1 → 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 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.6/schema.json",
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,29 @@ CSS/Tailwind support included.
28
25
 
29
26
  ```json
30
27
  {
31
- "$schema": "https://biomejs.dev/schemas/2.4.6/schema.json",
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` 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
@@ -19,7 +19,6 @@
19
19
  }
20
20
  }
21
21
  },
22
- "plugins": ["./node_modules/@yuu1111/biome-config/plugins/no-reexports.grit"],
23
22
  "javascript": {
24
23
  "formatter": {
25
24
  "quoteStyle": "double"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuu1111/biome-config",
3
- "version": "1.1.1",
3
+ "version": "1.2.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,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,7 @@
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-unvalidated-json-cast.grit"
6
+ ]
7
+ }
@@ -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
+ }