@webority/biome-config 0.96.0 → 0.99.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 +19 -4
- package/a11y.jsonc +11 -0
- package/biome.jsonc +31 -9
- package/package.json +3 -1
- package/plugins/mobile-grit-is-refreshing.grit +6 -0
- package/plugins/mobile-grit-keyboard-avoiding.grit +9 -0
- package/plugins/mobile-grit-keychain-internet.grit +10 -0
- package/plugins/web-grit-axios-module-config.grit +15 -0
package/README.md
CHANGED
|
@@ -47,16 +47,15 @@ fails every file in the repo at once, drowning any real violation (one repo's le
|
|
|
47
47
|
adopting this version records its existing violations once with
|
|
48
48
|
`biome lint --only=correctness/useExhaustiveDependencies --suppress --reason="<why>"`, so
|
|
49
49
|
every new violation still fails.
|
|
50
|
-
- **`a11y` group: `
|
|
51
|
-
|
|
52
|
-
lowers it in its own `biome.json`; a lint script without that flag lets the findings through.
|
|
50
|
+
- **`a11y` group: off**, because accessibility is a practice and not hygiene. A product turns it on with a second entry in `extends`, `@webority/biome-config/a11y.jsonc`, which sets the group to `error`. See "Accessibility checks (opt-in)".
|
|
51
|
+
- **Stricter rules, all `error`**: `noUnusedImports`, `noUnusedFunctionParameters` (prefix an interface-required parameter with `_`), `useOptionalChain`, `noUselessFragments`, `useTemplate`, `useIterableCallbackReturn`, `noGlobalIsNan`, `noAssignInExpressions`. Each is recorded with its reason in `biome.jsonc`.
|
|
53
52
|
- **`noArrayIndexKey` and `noDuplicateProperties`: `error`** — kept on (catches real dynamic-list bugs); genuine
|
|
54
53
|
static-list exceptions get a documented per-line `biome-ignore`.
|
|
55
54
|
- **`noConsole`** off for `scripts/**` + `logger.js`; CSS/SCSS not linted; the icon
|
|
56
55
|
module's mixed export allowed.
|
|
57
56
|
- **`StyleSheet.absoluteFillObject`** is an error, through the `no-absolute-fill-object` plugin
|
|
58
57
|
(below).
|
|
59
|
-
- **
|
|
58
|
+
- **Ten GritQL plugins** (`mobile-grit-*`, `web-grit-*` and `no-absolute-fill-object`, below) are errors.
|
|
60
59
|
|
|
61
60
|
## Plugins (GritQL)
|
|
62
61
|
|
|
@@ -70,6 +69,10 @@ The config ships lint plugins in `plugins/` and turns them on for every product
|
|
|
70
69
|
| `mobile-grit-index-key` | an inline `keyExtractor={(item, index) => ...}` whose body uses `index` | A key from the index breaks row state on a reorder or an insert. Return the record's stable id. |
|
|
71
70
|
| `mobile-grit-font-scaling-off` | `allowFontScaling={false}` | Turns off text scaling for people who need larger text. Cap a dense row with `maxFontSizeMultiplier`. |
|
|
72
71
|
| `mobile-grit-firebase-default-import` | `import x from "@react-native-firebase/..."` | `@react-native-firebase` 26 has no default export: the import is `undefined` and calling it crashes at launch. Import the modular functions by name. |
|
|
72
|
+
| `mobile-grit-is-refreshing` | `isRefreshing = <value>` (a declaration with a value, or an assignment) | A bare boolean flag races and wedges the client when the refresh throws. Share one refresh promise that every waiter awaits. |
|
|
73
|
+
| `mobile-grit-keyboard-avoiding` | `KeyboardAvoidingView`, `Keyboard.addListener` | Keyboard handling is `react-native-keyboard-controller`: `KeyboardProvider`, `KeyboardAwareScrollView`, `KeyboardStickyView`. |
|
|
74
|
+
| `mobile-grit-keychain-internet` | `setInternetCredentials`, `getInternetCredentials`, `hasInternetCredentials` | A token is a generic password. Use `setGenericPassword`, `getGenericPassword` and `resetGenericPassword`. `resetInternetCredentials` stays allowed for the first-install clean-up. |
|
|
75
|
+
| `web-grit-axios-module-config` | `axios.create({ baseURL: <non-literal> })` or `timeout: <non-literal>` outside a function | Config read at import time cannot be set later. Resolve it at call time in an interceptor. |
|
|
73
76
|
|
|
74
77
|
A plugin finding is an error, so `biome check` and `biome lint` fail on it.
|
|
75
78
|
|
|
@@ -84,6 +87,18 @@ workspace root that runs Biome adds `@webority/biome-config` to its own `devDepe
|
|
|
84
87
|
Product-specific one-offs (a bespoke file that co-exports, etc.) still use a local
|
|
85
88
|
`overrides` entry or a documented inline `biome-ignore` in that product.
|
|
86
89
|
|
|
90
|
+
## Accessibility checks (opt-in)
|
|
91
|
+
|
|
92
|
+
Accessibility rules are a practice a product chooses, so the shared config leaves them off.
|
|
93
|
+
|
|
94
|
+
```jsonc
|
|
95
|
+
{ "extends": ["@webority/biome-config/biome.jsonc", "@webority/biome-config/a11y.jsonc"] }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
With that extension the a11y group is an error, so it fails `biome check` like any other error.
|
|
99
|
+
|
|
100
|
+
An app that turns it on records each deliberate exception with an inline `biome-ignore` and a reason.
|
|
101
|
+
|
|
87
102
|
## Versioning
|
|
88
103
|
|
|
89
104
|
Published from the `webority-ui` monorepo on each release, in lockstep with the other
|
package/a11y.jsonc
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",
|
|
3
|
+
// Opt-in accessibility checks. A product extends this file after biome.jsonc to turn the a11y group on:
|
|
4
|
+
// "extends": ["@webority/biome-config/biome.jsonc", "@webority/biome-config/a11y.jsonc"]
|
|
5
|
+
"root": false,
|
|
6
|
+
"linter": {
|
|
7
|
+
"rules": {
|
|
8
|
+
"a11y": "error"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
package/biome.jsonc
CHANGED
|
@@ -34,27 +34,43 @@
|
|
|
34
34
|
// mobile-grit-index-key: an inline keyExtractor that returns its index argument.
|
|
35
35
|
// mobile-grit-font-scaling-off: allowFontScaling={false}; maxFontSizeMultiplier caps a dense row instead.
|
|
36
36
|
// mobile-grit-firebase-default-import: a default import from @react-native-firebase, which is undefined.
|
|
37
|
+
// mobile-grit-is-refreshing: a bare isRefreshing flag guarding a token refresh; one shared refresh promise replaces it.
|
|
38
|
+
// mobile-grit-keyboard-avoiding: KeyboardAvoidingView and Keyboard.addListener; react-native-keyboard-controller replaces them.
|
|
39
|
+
// mobile-grit-keychain-internet: set, get and has InternetCredentials for a token; the generic password API replaces them.
|
|
40
|
+
// web-grit-axios-module-config: axios.create reading baseURL or timeout from config at module scope; resolve at call time.
|
|
37
41
|
"plugins": [
|
|
38
42
|
"./node_modules/@webority/biome-config/plugins/no-absolute-fill-object.grit",
|
|
39
43
|
"./node_modules/@webority/biome-config/plugins/mobile-grit-alert-alert.grit",
|
|
40
44
|
"./node_modules/@webority/biome-config/plugins/mobile-grit-touchable.grit",
|
|
41
45
|
"./node_modules/@webority/biome-config/plugins/mobile-grit-index-key.grit",
|
|
42
46
|
"./node_modules/@webority/biome-config/plugins/mobile-grit-font-scaling-off.grit",
|
|
43
|
-
"./node_modules/@webority/biome-config/plugins/mobile-grit-firebase-default-import.grit"
|
|
47
|
+
"./node_modules/@webority/biome-config/plugins/mobile-grit-firebase-default-import.grit",
|
|
48
|
+
"./node_modules/@webority/biome-config/plugins/mobile-grit-is-refreshing.grit",
|
|
49
|
+
"./node_modules/@webority/biome-config/plugins/mobile-grit-keyboard-avoiding.grit",
|
|
50
|
+
"./node_modules/@webority/biome-config/plugins/mobile-grit-keychain-internet.grit",
|
|
51
|
+
"./node_modules/@webority/biome-config/plugins/web-grit-axios-module-config.grit"
|
|
44
52
|
],
|
|
45
53
|
"linter": {
|
|
46
54
|
"enabled": true,
|
|
47
55
|
"rules": {
|
|
48
56
|
"preset": "recommended",
|
|
49
|
-
|
|
57
|
+
// Accessibility is a practice, not hygiene (architecture.md principle 46): off by default.
|
|
58
|
+
// A product turns it on by extending @webority/biome-config/a11y.jsonc.
|
|
59
|
+
"a11y": "off",
|
|
50
60
|
"complexity": {
|
|
61
|
+
// CSS is not linted here; styling lives in the shared theme.
|
|
51
62
|
"noImportantStyles": "off",
|
|
52
|
-
|
|
53
|
-
"
|
|
63
|
+
// A long && chain hides a null bug, and the rule has a safe fix.
|
|
64
|
+
"useOptionalChain": "error",
|
|
65
|
+
// Style rule with a safe fix.
|
|
66
|
+
"noUselessFragments": "error"
|
|
54
67
|
},
|
|
55
68
|
"correctness": {
|
|
56
69
|
"noUnusedVariables": "error",
|
|
57
|
-
|
|
70
|
+
// An unused parameter is dead code. Prefix it with an underscore when an interface needs it.
|
|
71
|
+
"noUnusedFunctionParameters": "error",
|
|
72
|
+
// Dead code with a safe fix.
|
|
73
|
+
"noUnusedImports": "error",
|
|
58
74
|
// A reference to something that does not exist is not a style question: it
|
|
59
75
|
// bundles clean, lints clean, and throws ReferenceError on render. A consumer
|
|
60
76
|
// shipped two of these in one day - a constant deleted while a JSX call site
|
|
@@ -69,7 +85,9 @@
|
|
|
69
85
|
"useHookAtTopLevel": "error"
|
|
70
86
|
},
|
|
71
87
|
"style": {
|
|
72
|
-
|
|
88
|
+
// Style rule with a safe fix.
|
|
89
|
+
"useTemplate": "error",
|
|
90
|
+
// CSS is not linted here.
|
|
73
91
|
"noDescendingSpecificity": "off",
|
|
74
92
|
// Cannot tell that a re-exported identifier is a component, so the ordinary
|
|
75
93
|
// export function AppAmount() {}
|
|
@@ -90,9 +108,12 @@
|
|
|
90
108
|
// Valuable on dynamic lists (reorder/reconciliation bugs). Genuine
|
|
91
109
|
// static-list exceptions get a documented per-line biome-ignore.
|
|
92
110
|
"noArrayIndexKey": "error",
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
|
|
111
|
+
// A map callback that returns nothing is a bug.
|
|
112
|
+
"useIterableCallbackReturn": "error",
|
|
113
|
+
// Global isNaN coerces its argument; Number.isNaN does not.
|
|
114
|
+
"noGlobalIsNan": "error",
|
|
115
|
+
// An assignment inside a condition is usually a typo.
|
|
116
|
+
"noAssignInExpressions": "error",
|
|
96
117
|
"noDuplicateProperties": "error",
|
|
97
118
|
// Apps log through the web-core Logger, and a library through its one diagnostics
|
|
98
119
|
// module (devWarn and devError). Any other console call fails lint.
|
|
@@ -118,6 +139,7 @@
|
|
|
118
139
|
"enabled": true,
|
|
119
140
|
"actions": {
|
|
120
141
|
"source": {
|
|
142
|
+
// Ordering imports is churn with no bug class behind it.
|
|
121
143
|
"organizeImports": "off"
|
|
122
144
|
}
|
|
123
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/biome-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.0",
|
|
4
4
|
"description": "Shared Biome lint + format policy for Webority frontend products. Extend it from a product biome.json so every repo inherits one shared ruleset, bumped by version — no per-repo drift.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"biome.jsonc",
|
|
12
|
+
"a11y.jsonc",
|
|
12
13
|
"plugins"
|
|
13
14
|
],
|
|
14
15
|
"exports": {
|
|
15
16
|
"./biome.jsonc": "./biome.jsonc",
|
|
17
|
+
"./a11y.jsonc": "./a11y.jsonc",
|
|
16
18
|
"./plugins/*": "./plugins/*",
|
|
17
19
|
"./package.json": "./package.json"
|
|
18
20
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
language js
|
|
2
|
+
|
|
3
|
+
// react.md → API data: a refresh guarded by a bare boolean flag goes stale when the refresh throws and wedges the client.
|
|
4
|
+
`isRefreshing = $value` as $flag where {
|
|
5
|
+
register_diagnostic(span=$flag, message="A bare isRefreshing flag races and wedges the client when the refresh throws. Share one refresh promise (a module-scoped refreshPromise) that every waiter awaits.", severity="error")
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
language js
|
|
2
|
+
|
|
3
|
+
// react-native.md → Keyboard and forms: react-native-keyboard-controller owns keyboard handling.
|
|
4
|
+
or {
|
|
5
|
+
`KeyboardAvoidingView`,
|
|
6
|
+
`Keyboard.addListener`
|
|
7
|
+
} as $use where {
|
|
8
|
+
register_diagnostic(span=$use, message="KeyboardAvoidingView and Keyboard.addListener are not used in new code. Use react-native-keyboard-controller: KeyboardProvider at the root, KeyboardAwareScrollView for forms, KeyboardStickyView for bottom bars.", severity="error")
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
language js
|
|
2
|
+
|
|
3
|
+
// react-native.md → Tokens are generic passwords, not internet credentials. resetInternetCredentials stays allowed: it clears items on first install.
|
|
4
|
+
or {
|
|
5
|
+
`setInternetCredentials`,
|
|
6
|
+
`getInternetCredentials`,
|
|
7
|
+
`hasInternetCredentials`
|
|
8
|
+
} as $use where {
|
|
9
|
+
register_diagnostic(span=$use, message="A token is a generic password, not an internet credential. Use setGenericPassword, getGenericPassword and resetGenericPassword keyed by service.", severity="error")
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
language js
|
|
2
|
+
|
|
3
|
+
// react-native.md → Config a client captures at module scope can never be set in time.
|
|
4
|
+
`axios.create($options)` as $call where {
|
|
5
|
+
$options <: contains or {
|
|
6
|
+
`baseURL: $value`,
|
|
7
|
+
`timeout: $value`
|
|
8
|
+
},
|
|
9
|
+
$value <: not r"^[\"'`0-9].*",
|
|
10
|
+
$call <: not within or {
|
|
11
|
+
JsFunctionBody(),
|
|
12
|
+
JsArrowFunctionExpression()
|
|
13
|
+
},
|
|
14
|
+
register_diagnostic(span=$call, message="axios.create reads baseURL or timeout from config at import time, before app startup code runs, so a later config change does nothing. Resolve it at call time in an interceptor.", severity="error")
|
|
15
|
+
}
|