@webority/biome-config 0.149.0 → 0.150.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
|
@@ -55,7 +55,9 @@ fails every file in the repo at once, drowning any real violation (one repo's le
|
|
|
55
55
|
module's mixed export allowed.
|
|
56
56
|
- **`StyleSheet.absoluteFillObject`** is an error, through the `no-absolute-fill-object` plugin
|
|
57
57
|
(below).
|
|
58
|
-
- **
|
|
58
|
+
- **Fifteen GritQL plugins** (`mobile-grit-*`, `web-grit-*` and `no-absolute-fill-object`, below) are errors.
|
|
59
|
+
- `**/razor-js/*.ts`: classic page scripts keep `"use strict"`, function declarations and string concatenation; four module-only rules are off.
|
|
60
|
+
- `**/*.md`: Markdown is neither formatted nor linted, because Biome rewrites bare glob paths and a lint fix under `check --write` would rewrite a changelog's released sections.
|
|
59
61
|
|
|
60
62
|
## Plugins (GritQL)
|
|
61
63
|
|
|
@@ -73,7 +75,11 @@ The config ships lint plugins in `plugins/` and turns them on for every product
|
|
|
73
75
|
| `mobile-grit-select-from-result` | an RTK Query `selectFromResult` that returns a non-object value, or that takes `refetch` | RTK Query spreads the result beside `refetch`, so a plain value replaces the hook result. Return `{ name: value }` and destructure; take `refetch` from the hook's own result. |
|
|
74
76
|
| `mobile-grit-keyboard-avoiding` | `KeyboardAvoidingView`, `Keyboard.addListener` | Keyboard handling is `react-native-keyboard-controller`: `KeyboardProvider`, `KeyboardAwareScrollView`, `KeyboardStickyView`. |
|
|
75
77
|
| `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. |
|
|
78
|
+
| `mobile-grit-unchecked-native-call` | A `NativeModules.<module>.<method>(...)` call, or a call on a default import from a `Native<Name>` module, whose result is dropped, voided, or caught by an empty handler, for example `void NativeModules.x.y()` | A failed native call goes unnoticed. Await it and handle the failure, or return it to a caller that does. |
|
|
76
79
|
| `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. |
|
|
80
|
+
| `web-grit-empty-catch` | An empty `catch {}` block, or a promise `.catch(...)` whose handler is empty or returns only `null` or `undefined`, for example `.catch(() => {})` | The catch swallows the error. Handle it, retry it as a classified transient, or log it and rethrow it. A documented best-effort path says why in a `biome-ignore lint/plugin/web-grit-empty-catch` comment. |
|
|
81
|
+
| `web-grit-raw-query-read` | An RTK Query hook result read outside `useDataState`, for example `const { data } = useGetXQuery()` or `api.endpoints.x.useQuery()` | A screen reads a query only as a data state. Write `useDataState(useXQuery(args))` and draw it with AppAsyncBlock (AsyncBlock on phone). |
|
|
82
|
+
| `web-grit-route-lazy-reload` | A `lazy(...)` or `React.lazy(...)` call, or a route `lazy:` property, whose argument is `import(...)` without the reload helper, for example `lazy: () => import(...)` | A tab opened before a deploy breaks on its next navigation. Load a route with `lazy: importWithReload(() => import(...))`, or a component with `lazyWithReload(() => import(...))`, both from `@webority/web-core/router`. |
|
|
77
83
|
|
|
78
84
|
A plugin finding is an error, so `biome check` and `biome lint` fail on it.
|
|
79
85
|
|
package/biome.jsonc
CHANGED
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
// mobile-grit-keychain-internet: set, get and has InternetCredentials for a token; the generic password API replaces them.
|
|
42
42
|
// web-grit-axios-module-config: axios.create reading baseURL or timeout from config at module scope; resolve at call time.
|
|
43
43
|
// web-grit-empty-catch: an empty catch block (a comment alone included) swallows the error.
|
|
44
|
+
// web-grit-raw-query-read: an RTK Query hook result read outside useDataState.
|
|
45
|
+
// web-grit-route-lazy-reload: a route's lazy or a React.lazy that loads a screen without the reload helper.
|
|
44
46
|
// mobile-grit-unchecked-native-call: a NativeModules or codegen spec call whose result is dropped, voided or swallowed.
|
|
45
47
|
"plugins": [
|
|
46
48
|
"./node_modules/@webority/biome-config/plugins/no-absolute-fill-object.grit",
|
|
@@ -55,6 +57,8 @@
|
|
|
55
57
|
"./node_modules/@webority/biome-config/plugins/mobile-grit-keychain-internet.grit",
|
|
56
58
|
"./node_modules/@webority/biome-config/plugins/web-grit-axios-module-config.grit",
|
|
57
59
|
"./node_modules/@webority/biome-config/plugins/web-grit-empty-catch.grit",
|
|
60
|
+
"./node_modules/@webority/biome-config/plugins/web-grit-raw-query-read.grit",
|
|
61
|
+
"./node_modules/@webority/biome-config/plugins/web-grit-route-lazy-reload.grit",
|
|
58
62
|
"./node_modules/@webority/biome-config/plugins/mobile-grit-unchecked-native-call.grit"
|
|
59
63
|
],
|
|
60
64
|
"linter": {
|
|
@@ -96,10 +100,33 @@
|
|
|
96
100
|
// it with void when nothing waits on it: void keeps a rejection unhandled, so it still
|
|
97
101
|
// reaches the page's unhandled-rejection reporting.
|
|
98
102
|
"noFloatingPromises": "error",
|
|
103
|
+
// `+` on an object, symbol, unknown or a number and bigint prints "[object Object]" or throws.
|
|
104
|
+
"noUnsafePlusOperands": "error",
|
|
105
|
+
// A Disposable held without `using` is never disposed.
|
|
106
|
+
"useDisposables": "error",
|
|
99
107
|
// A switch over a union that misses a member is a silent fall-through to the default.
|
|
100
|
-
"useExhaustiveSwitchCases": "error"
|
|
108
|
+
"useExhaustiveSwitchCases": "error",
|
|
109
|
+
// A cast the type already satisfies is noise, and the next change of that type keeps it silently.
|
|
110
|
+
"noUselessTypeAssertion": "error",
|
|
111
|
+
// A cast to a type the value may not hold turns the compiler's check off at that line; narrow or parse instead.
|
|
112
|
+
"noUnsafeTypeAssertion": "error"
|
|
101
113
|
},
|
|
102
114
|
"style": {
|
|
115
|
+
// One HTTP client and one telemetry set-up per portal, both owned by web-core.
|
|
116
|
+
"noRestrictedImports": {
|
|
117
|
+
"level": "error",
|
|
118
|
+
"options": {
|
|
119
|
+
"paths": {
|
|
120
|
+
// The rule cannot tell a type import from a value import, so the four type names a service
|
|
121
|
+
// declares its client with are allowed by name; the default import and every helper stay banned.
|
|
122
|
+
"axios": {
|
|
123
|
+
"message": "Call the API through the shared client: userClient or publicClient from @webority/web-core/api (mobile apps: @webority/mobile-core), and read a failure with extractApiError. The shared client carries the token refresh, retry, trace header and error handling.",
|
|
124
|
+
"allowImportNames": ["AxiosInstance", "AxiosRequestConfig", "AxiosResponse", "AxiosError"]
|
|
125
|
+
},
|
|
126
|
+
"@microsoft/applicationinsights-web": "Send telemetry through the shared logger: call initAppInsights from @webority/web-core/appInsights once at startup, then log with Logger."
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
103
130
|
// A forced non-null hides the case the type says can happen.
|
|
104
131
|
"noNonNullAssertion": "error",
|
|
105
132
|
// Style rule with a safe fix.
|
|
@@ -134,6 +161,12 @@
|
|
|
134
161
|
"noDuplicateProperties": "error",
|
|
135
162
|
// An untyped value switches type checking off for everything it touches.
|
|
136
163
|
"noExplicitAny": "error",
|
|
164
|
+
// The two silent routes to the same `any`: a `let` with no type and no value, and a variable whose type grows by assignment.
|
|
165
|
+
"noImplicitAnyLet": "error",
|
|
166
|
+
"noEvolvingTypes": "error",
|
|
167
|
+
// `!!` and `a?.b!` assert away the very undefined the optional chain admits.
|
|
168
|
+
"noExtraNonNullAssertion": "error",
|
|
169
|
+
"noNonNullAssertedOptionalChain": "error",
|
|
137
170
|
// Apps log through the web-core Logger, and a library through its one diagnostics
|
|
138
171
|
// module (devWarn and devError). Any other console call fails lint.
|
|
139
172
|
"noConsole": "error"
|
|
@@ -166,7 +199,7 @@
|
|
|
166
199
|
"overrides": [
|
|
167
200
|
{
|
|
168
201
|
// Loggers + build/tooling scripts legitimately use console.
|
|
169
|
-
"includes": ["scripts/**", "**/logger.js"],
|
|
202
|
+
"includes": ["scripts/**", "**/logger.js", "**/logger.ts"],
|
|
170
203
|
"linter": {
|
|
171
204
|
"rules": {
|
|
172
205
|
"suspicious": {
|
|
@@ -193,6 +226,29 @@
|
|
|
193
226
|
"linter": {
|
|
194
227
|
"enabled": false
|
|
195
228
|
}
|
|
229
|
+
},
|
|
230
|
+
// A razor-js page script is a classic script, not a module: its "use strict" is live and its function declarations are page globals.
|
|
231
|
+
{
|
|
232
|
+
"includes": ["**/razor-js/*.ts"],
|
|
233
|
+
"linter": {
|
|
234
|
+
"rules": {
|
|
235
|
+
"suspicious": { "noRedundantUseStrict": "off" },
|
|
236
|
+
"complexity": { "useArrowFunction": "off" },
|
|
237
|
+
"correctness": { "noInnerDeclarations": "off" },
|
|
238
|
+
"style": { "useTemplate": "off" }
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
// Markdown stays as written: Biome reads two bare globs on one line (Tables/*.sql and Migrations/*.sql) as one
|
|
243
|
+
// emphasis span and rewrites them, and a lint fix under `check --write` would rewrite released changelog sections.
|
|
244
|
+
{
|
|
245
|
+
"includes": ["**/*.md"],
|
|
246
|
+
"formatter": {
|
|
247
|
+
"enabled": false
|
|
248
|
+
},
|
|
249
|
+
"linter": {
|
|
250
|
+
"enabled": false
|
|
251
|
+
}
|
|
196
252
|
}
|
|
197
253
|
]
|
|
198
254
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/biome-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.150.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": {
|
|
@@ -2,7 +2,31 @@ language js
|
|
|
2
2
|
|
|
3
3
|
// react.md → Failing loud: a catch handles the error, retries it as a classified transient, or logs and rethrows it.
|
|
4
4
|
// A comment alone does not handle it; a documented best-effort path carries `biome-ignore lint/plugin/web-grit-empty-catch: <why>`.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// A promise .catch whose callback is empty or returns only null or undefined swallows the error the same way.
|
|
6
|
+
or {
|
|
7
|
+
JsCatchClause(body=$body) as $catch where {
|
|
8
|
+
$body <: `{}`,
|
|
9
|
+
register_diagnostic(span=$catch, message="This catch swallows the error. Handle it, retry it as a classified transient, or log it and rethrow it. A documented best-effort path says why in a biome-ignore lint/plugin/web-grit-empty-catch comment.", severity="error")
|
|
10
|
+
},
|
|
11
|
+
`$promise.catch($handler)` as $call where {
|
|
12
|
+
$handler <: or {
|
|
13
|
+
`() => {}`,
|
|
14
|
+
`($e) => {}`,
|
|
15
|
+
`async () => {}`,
|
|
16
|
+
`async ($e) => {}`,
|
|
17
|
+
`() => null`,
|
|
18
|
+
`($e) => null`,
|
|
19
|
+
`() => undefined`,
|
|
20
|
+
`($e) => undefined`,
|
|
21
|
+
`() => { return null; }`,
|
|
22
|
+
`($e) => { return null; }`,
|
|
23
|
+
`() => { return undefined; }`,
|
|
24
|
+
`($e) => { return undefined; }`,
|
|
25
|
+
`() => { return; }`,
|
|
26
|
+
`($e) => { return; }`,
|
|
27
|
+
`function () {}`,
|
|
28
|
+
`function ($e) {}`
|
|
29
|
+
},
|
|
30
|
+
register_diagnostic(span=$call, message="This catch swallows the error. Report it, rethrow anything but the one expected failure, or assert it in a test. When another holder of the promise already observes the failure and this line only waits for it to settle, use Promise.allSettled([promise]).", severity="error")
|
|
31
|
+
}
|
|
8
32
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
language js
|
|
2
|
+
|
|
3
|
+
// react.md → API data: a screen reads an RTK Query result only as a DataState.
|
|
4
|
+
// useListQuery and useInfiniteListQuery are web-core list hooks, not generated RTK Query hooks.
|
|
5
|
+
or {
|
|
6
|
+
`$hook($args)` as $call where {
|
|
7
|
+
$hook <: r"^use[A-Z][A-Za-z0-9]*Query$",
|
|
8
|
+
$hook <: not r"^useLazy.*",
|
|
9
|
+
$hook <: not r"^useListQuery$",
|
|
10
|
+
$hook <: not r"^useInfiniteListQuery$"
|
|
11
|
+
},
|
|
12
|
+
`$endpoint.useQuery($args)` as $call,
|
|
13
|
+
`$endpoint.useInfiniteQuery($args)` as $call
|
|
14
|
+
} where {
|
|
15
|
+
$call <: not within or {
|
|
16
|
+
`useDataState($_)`,
|
|
17
|
+
`useDataState($_, $_)`,
|
|
18
|
+
`useInfiniteDataState($_)`
|
|
19
|
+
},
|
|
20
|
+
register_diagnostic(span=$call, message="A query result is read only as a data state. Write useDataState(useXQuery(args)) and draw it with AppAsyncBlock (AsyncBlock on phone), which shows loading, the error with Retry, and empty.", severity="error")
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
language js
|
|
2
|
+
|
|
3
|
+
// react.md: every lazy-loaded screen goes through web-core's reload helper.
|
|
4
|
+
or {
|
|
5
|
+
`lazy: $value` as $prop where {
|
|
6
|
+
$value <: contains `import($_)`,
|
|
7
|
+
$value <: not `importWithReload($_)`,
|
|
8
|
+
register_diagnostic(span=$prop, message="Load the screen through the reload helper: lazy: importWithReload(() => import(...)) on a route, or lazyWithReload(() => import(...)) for a component, both from @webority/web-core/router. Without it a tab opened before a deploy breaks on its next navigation.", severity="error")
|
|
9
|
+
},
|
|
10
|
+
`lazy($arg)` as $call where {
|
|
11
|
+
$arg <: contains `import($_)`,
|
|
12
|
+
register_diagnostic(span=$call, message="Load the screen through the reload helper: lazy: importWithReload(() => import(...)) on a route, or lazyWithReload(() => import(...)) for a component, both from @webority/web-core/router. Without it a tab opened before a deploy breaks on its next navigation.", severity="error")
|
|
13
|
+
},
|
|
14
|
+
`React.lazy($arg)` as $call where {
|
|
15
|
+
$arg <: contains `import($_)`,
|
|
16
|
+
register_diagnostic(span=$call, message="Load the screen through the reload helper: lazy: importWithReload(() => import(...)) on a route, or lazyWithReload(() => import(...)) for a component, both from @webority/web-core/router. Without it a tab opened before a deploy breaks on its next navigation.", severity="error")
|
|
17
|
+
}
|
|
18
|
+
}
|