@sarj/eslint-plugin 9.7.0 → 9.8.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 +39 -3
- package/dist/index.cjs +692 -504
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +683 -496
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,11 +12,47 @@ import sarj from "@sarj/eslint-plugin";
|
|
|
12
12
|
export default [...sarj.configs.recommended];
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
57 rules. Each source under `src/rules/` states one concise claim and links to
|
|
16
16
|
its paired tests. The definition and named test cases are the complete rule
|
|
17
17
|
specification, and `meta.docs.url` points directly to those executable examples.
|
|
18
18
|
|
|
19
|
-
Presets: `recommended` (warn-first), `strict` (every
|
|
19
|
+
Presets: `recommended` (warn-first), `strict` (every general-profile rule at its declared strict severity), `style-guide` (formatting/naming subset). Application-only rules are exported through `applicationOnlyRules` and configured by the application profile. The two-sentence comment rule warns; its three-sentence companion errors.
|
|
20
|
+
|
|
21
|
+
## New in 9.8.0 — application library policy adapters
|
|
22
|
+
|
|
23
|
+
`no-restricted-library-load` extends a configured dependency policy to runtime
|
|
24
|
+
loading forms that ESLint's `no-restricted-imports` does not cover: literal
|
|
25
|
+
`import()`, unshadowed `require()` / `require.resolve()`, and TypeScript
|
|
26
|
+
`import x = require(...)`. It matches a package and all of its subpaths, but
|
|
27
|
+
deliberately ignores computed names and shadowed local `require` functions.
|
|
28
|
+
|
|
29
|
+
`prefer-native-random-uuid` reports resolved, zero-argument UUID v4 calls from
|
|
30
|
+
the `uuid` package and suggests `globalThis.crypto.randomUUID()`. The suggestion
|
|
31
|
+
changes only the call; import cleanup remains explicit. Other UUID versions,
|
|
32
|
+
custom-randomness arguments, re-exports, and function references are untouched.
|
|
33
|
+
|
|
34
|
+
Neither rule is in the general presets. The application profile configures them
|
|
35
|
+
for its Node 22+ runtime contract and supplies catalog entries to the loader
|
|
36
|
+
rule:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
rules: {
|
|
40
|
+
"@sarj/no-restricted-library-load": [
|
|
41
|
+
"error",
|
|
42
|
+
{
|
|
43
|
+
libraries: [
|
|
44
|
+
{
|
|
45
|
+
id: "LIB101",
|
|
46
|
+
module: "axios",
|
|
47
|
+
replacement: "Ky",
|
|
48
|
+
note: "The APIs are not drop-in equivalents.",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
"@sarj/prefer-native-random-uuid": "error",
|
|
54
|
+
}
|
|
55
|
+
```
|
|
20
56
|
|
|
21
57
|
## Renamed in 7.0.0, aliases deleted in 9.0.0 (breaking)
|
|
22
58
|
|
|
@@ -138,7 +174,7 @@ Both distilled from two years of PR-review comments across ~1,065 PRs.
|
|
|
138
174
|
| `prefer-zod-infer` | An `interface`/`type` that restates a Zod schema declared in the same module instead of deriving it with `z.infer`. Options: `ignoreTypeNames`, `requireIdenticalShape` (default `true`). | warn / error |
|
|
139
175
|
| `prefer-module-level-constant` | A literal-only `const` collection (array, object, `Set`, `Map`, `Object.freeze`) or non-global regex declared inside a function body, never mutated and never escaping — hoist it to module scope. Options: `minElements` (default 3), `checkRegex`, `ignoreTestFiles`. | warn / error |
|
|
140
176
|
| `prefer-module-level-schema` | A Zod schema built inside a function body that closes over nothing the function owns — hoist it to module scope instead of rebuilding it per call, per request, per render. Silent when it references a parameter, local, type parameter, local type, or `this` (that is a schema FACTORY), when it is already memoized, and inside `z.lazy`. Options: `factories` (default: the object-like composites), `minProperties` (default 1), `ignoreTestFiles`. | warn / error |
|
|
141
|
-
| `prefer-non-nullable-collection` |
|
|
177
|
+
| `prefer-non-nullable-collection` | A required array property or direct alias explicitly combined with `null`/`undefined`, creating two equivalent empty states. Optional API fields are excluded because omission can be meaningful. | warn / error |
|
|
142
178
|
|
|
143
179
|
## Options
|
|
144
180
|
|