@shivaedev/quality 0.3.1 → 0.4.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +69 -2
  3. package/dist/rules/suppressions/biome/configs.d.ts +21 -10
  4. package/dist/rules/suppressions/biome/configs.d.ts.map +1 -1
  5. package/dist/rules/suppressions/biome/configs.js +57 -21
  6. package/dist/rules/suppressions/biome/configs.js.map +1 -1
  7. package/dist/rules/suppressions/biome/declarations.d.ts +18 -0
  8. package/dist/rules/suppressions/biome/declarations.d.ts.map +1 -0
  9. package/dist/rules/suppressions/biome/declarations.js +20 -0
  10. package/dist/rules/suppressions/biome/declarations.js.map +1 -0
  11. package/dist/rules/suppressions/biome/resolve.d.ts +3 -0
  12. package/dist/rules/suppressions/biome/resolve.d.ts.map +1 -0
  13. package/dist/rules/suppressions/biome/resolve.js +70 -0
  14. package/dist/rules/suppressions/biome/resolve.js.map +1 -0
  15. package/dist/rules/suppressions/biome/weakenings.d.ts +3 -3
  16. package/dist/rules/suppressions/biome/weakenings.d.ts.map +1 -1
  17. package/dist/rules/suppressions/biome/weakenings.js +41 -33
  18. package/dist/rules/suppressions/biome/weakenings.js.map +1 -1
  19. package/dist/rules/suppressions/biome-overrides.d.ts.map +1 -1
  20. package/dist/rules/suppressions/biome-overrides.js +31 -23
  21. package/dist/rules/suppressions/biome-overrides.js.map +1 -1
  22. package/package.json +5 -3
  23. package/src/rules/suppressions/biome/configs.ts +97 -28
  24. package/src/rules/suppressions/biome/declarations.ts +37 -0
  25. package/src/rules/suppressions/biome/resolve.ts +86 -0
  26. package/src/rules/suppressions/biome/weakenings.ts +54 -37
  27. package/src/rules/suppressions/biome-overrides.ts +40 -31
  28. package/tsconfig/base.json +35 -0
  29. package/tsconfig/package.json +10 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 - 2026-10-03
4
+
5
+ ### Added
6
+
7
+ - `suppressions/biome-overrides` follows `extends` entries that name a package,
8
+ such as a shared Biome preset, resolved from the root's `node_modules` through
9
+ `exports` (the `biome` and `default` conditions and `*` patterns), `main` or a
10
+ file inside the package, as Biome resolves them. A non-relative entry that
11
+ names a file at the repository root is read as that file. The weakenings a
12
+ preset makes count as declared when a `declarations.json` beside the preset
13
+ declares them; any other preset weakening is reported at the `extends` line.
14
+ A repository declaration that repeats one the preset ships is reported, and so
15
+ is an `extends` entry that cannot be resolved or read.
16
+ - Add tsconfig presets for TypeScript 7. `@shivaedev/quality/tsconfig/base.json` is for type-checking with `noEmit`. `@shivaedev/quality/tsconfig/package.json` is the base plus declaration output, declaration and source maps, and relative `.ts` imports rewritten to `.js`, for building a package. The base sets `target` and `lib` to ESNext with bundler resolution; type-checks JavaScript with `allowJs` and `checkJs`; turns on `strict` (stating `noImplicitAny` and `strictBuiltinIteratorReturn` explicitly), `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, `noImplicitOverride`, `noImplicitReturns`, `noFallthroughCasesInSwitch`, `noUnusedLocals`, `noUnusedParameters`, `verbatimModuleSyntax`, `isolatedModules`, `erasableSyntaxOnly`, `noUncheckedSideEffectImports` and `forceConsistentCasingInFileNames`; and rejects unreachable code and unused labels. Dot access to index signatures stays allowed.
17
+
18
+ ### Changed
19
+
20
+ - `suppressions/biome-overrides` merges a config with the configs it extends the
21
+ way Biome does: a later setting of a rule, a group, `recommended` or `enabled`
22
+ replaces an earlier one, so a weakening that the extending config sets back to
23
+ `error` is no longer reported, while `overrides` and every `includes` list are
24
+ appended. The `extends` of an extended config are no longer followed, since
25
+ Biome does not apply them.
26
+
3
27
  ## 0.3.1 - 2026-10-03
4
28
 
5
29
  ### Changed
package/README.md CHANGED
@@ -74,6 +74,8 @@ A comment says why, never what the code already says or what it used to be. Six
74
74
 
75
75
  The rules find comments with the TypeScript parser, so text inside strings, template literals, regular expressions and JSX never counts as a comment. They read the TypeScript and JavaScript modules among the sources and skip declaration files and the directives listed below. Each finding names the line its comment starts on.
76
76
 
77
+ The default is no comments at all: a comment states only what the code cannot show, such as a constraint or a reason, and never narrates the code. The limit of `comments/max-per-file` is a crude tripwire against runaway comments, not a budget to fill, so a file that reaches it means something went wrong.
78
+
77
79
  `comments/max-per-file` counts comments this way:
78
80
 
79
81
  - A block comment counts once, however many lines it spans.
@@ -145,7 +147,7 @@ export default defineConfig({
145
147
 
146
148
  #### Declared Biome overrides
147
149
 
148
- A scope that truly cannot follow a lint rule keeps its exception in the Biome config, and the quality config declares it with a reason. `suppressions/biome-overrides` reads `biome.json` or `biome.jsonc` at the root, every nested `biome.json` and `biome.jsonc` among the checked files, and the local files a config `extends` (an entry that starts with `.`). These settings count as overrides, at the top level and in every `overrides` entry:
150
+ A scope that truly cannot follow a lint rule keeps its exception in the Biome config, and the quality config declares it with a reason. `suppressions/biome-overrides` reads `biome.json` or `biome.jsonc` at the root, every nested `biome.json` and `biome.jsonc` among the checked files, and the configs each of them `extends`, resolved the way Biome resolves them (see [Shared presets](#shared-presets)). These settings count as overrides, at the top level and in every `overrides` entry:
149
151
 
150
152
  | Setting | Declared as |
151
153
  | --- | --- |
@@ -188,6 +190,30 @@ export default defineConfig({
188
190
 
189
191
  A declaration covers a setting when its `rule` and its `includes` match the setting's exactly, in any order. An `includes` list that keeps files out is declared as the whole list, so every pattern added to it needs the declaration to change too. A setting at the top level of the root config has the scope `["**"]`, and an `overrides` entry has its own `includes` (`["**"]` when it has none). Patterns in a nested config are relative to its folder, so they are declared with the folder in front: `"src/**"` in `packages/web/biome.json` is declared as `"packages/web/src/**"`, and its top level as `"packages/web/**"`. A setting without a declaration is reported at its line in the Biome config; a declaration that no setting matches is reported against the root config, so the list cannot outlive the overrides it explains.
190
192
 
193
+ #### Shared presets
194
+
195
+ A config `extends` its entries the way Biome does:
196
+
197
+ - An entry that starts with `./` or `../` is a file next to the config. Any other entry is first a file at the repository root, then a package in the root's `node_modules`, resolved through its `exports` (with the `biome` and `default` conditions, and `*` patterns), then its `main`, then a file inside it. A package may also name itself through the repository's own `package.json` `exports`. `"//"` in a nested config extends the root config, which is read on its own.
198
+ - Biome reads only the entries of the config it loads: the `extends` of an extended config are not followed, so they are not read here either.
199
+ - The extended configs apply from left to right and the config itself last. A later setting of a rule, a group, `recommended` or `enabled` replaces an earlier one, so a preset's weakening that the repository sets back to `error` is no override. A group set as a whole (`"suspicious": "error"`) replaces the settings of its rules; a rule set inside a group the preset turned off leaves the rest of the group off.
200
+ - Lists are appended, not replaced: `overrides`, `plugins` and every `includes` list, `files.includes` among them. A repository's `files.includes` adds to the preset's, so each list is declared by whoever wrote it.
201
+ - Patterns in an extended config resolve against the repository root, or against the folder of a nested config that extends it, as patterns in the config itself do.
202
+
203
+ A package that ships a preset declares the weakenings the preset makes in a `declarations.json` beside the preset file, as an array of the same `{ rule, includes, reason }` entries the `declared` option takes. Its `includes` are written relative to the repository that extends the preset. Those weakenings count as declared, so the repository adds nothing for them:
204
+
205
+ ```json
206
+ [
207
+ {
208
+ "rule": "lint/style/noDefaultExport",
209
+ "includes": ["**/*.config.ts"],
210
+ "reason": "Tools load their config files through the default export."
211
+ }
212
+ ]
213
+ ```
214
+
215
+ A weakening the preset makes without such a declaration is reported at the line of the repository's `extends` entry, and the repository's own declaration covers it. A weakening the repository adds beyond the preset needs its own declaration, and a repository declaration that repeats one the preset ships is reported until it is removed. A preset entry that cannot be resolved or read, or whose `declarations.json` is invalid, is reported at the `extends` entry as well.
216
+
191
217
  ### Local rules
192
218
 
193
219
  ```ts
@@ -303,6 +329,47 @@ quality baseline migrate [--config <file>] [--from <file>]
303
329
  | 1 | Failed: an uncovered error-level violation, a baselined file that got worse, a stale registry entry, a baseline entry for a rule that is off or unknown, or a baseline that grew against the merge base. |
304
330
  | 2 | Could not run: no or invalid config, an invalid baseline or registry, a baseline left in the earlier format, a missing source, a rule that threw, git history the check cannot read, or a usage error. |
305
331
 
332
+ ## tsconfig presets
333
+
334
+ Two presets hold one strict, current TypeScript setup for every repository. They target TypeScript 7.
335
+
336
+ | Preset | Use |
337
+ | --- | --- |
338
+ | `@shivaedev/quality/tsconfig/base.json` | Type-checking with `noEmit`: applications, tests and scripts. |
339
+ | `@shivaedev/quality/tsconfig/package.json` | Building a package: the base plus `declaration`, `declarationMap`, `sourceMap` and `rewriteRelativeImportExtensions`, so relative `.ts` imports are emitted as `.js`. |
340
+
341
+ ```json
342
+ {
343
+ "extends": "@shivaedev/quality/tsconfig/base.json",
344
+ "compilerOptions": {
345
+ "lib": ["ESNext", "DOM"],
346
+ "types": ["node"]
347
+ },
348
+ "include": ["src", "test"]
349
+ }
350
+ ```
351
+
352
+ The base sets:
353
+
354
+ - **Language:** `target` and `lib` ESNext, so the newest syntax is emitted as written and the newest built-ins are typed.
355
+ - **Modules:** `module` ESNext, `moduleResolution` bundler, `moduleDetection` force, `verbatimModuleSyntax`, `isolatedModules`, `allowImportingTsExtensions`, `resolveJsonModule`, `noUncheckedSideEffectImports`, `forceConsistentCasingInFileNames` and `libReplacement: false`.
356
+ - **JavaScript:** `allowJs` and `checkJs`, so JavaScript files are type-checked with the TypeScript ones.
357
+ - **Erasable syntax only:** `erasableSyntaxOnly` rejects syntax that type stripping cannot erase, such as parameter properties.
358
+ - **Checks:** `strict`, with `noImplicitAny`, `strictBuiltinIteratorReturn` and `useUnknownInCatchVariables` stated explicitly, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, `noImplicitOverride`, `noImplicitReturns`, `noFallthroughCasesInSwitch`, `noUnusedLocals`, `noUnusedParameters`, `allowUnreachableCode: false` and `allowUnusedLabels: false`.
359
+ - **Compilers:** `stableTypeOrdering`, so a TypeScript 6 build orders types the way TypeScript 7 does, and `skipLibCheck`.
360
+
361
+ `noPropertyAccessFromIndexSignature` stays off, so a map-like key is read with dot access, and `isolatedDeclarations` stays off, so exported values keep their inferred types. `types`, `jsx`, `paths`, `include` and the output directories belong to each project. A project that needs more built-ins, such as the DOM, sets `lib` itself and keeps `ESNext` in it.
362
+
363
+ A package that type-checks its tests with one config and builds `src` with another extends both, the package preset last:
364
+
365
+ ```json
366
+ {
367
+ "extends": ["./tsconfig.json", "@shivaedev/quality/tsconfig/package.json"],
368
+ "compilerOptions": { "outDir": "dist", "rootDir": "src" },
369
+ "include": ["src"]
370
+ }
371
+ ```
372
+
306
373
  ## Validation
307
374
 
308
- `pnpm ready` checks formatting, both TypeScript compilers, the rules, config, discovery, registry, baseline and report behavior, the command line against seeded repositories and git histories, and an installed tarball consumer that type-checks a config and runs the `quality` bin through a baseline cycle.
375
+ `pnpm ready` checks formatting, TypeScript 7, the rules, config, discovery, registry, baseline and report behavior, the command line against seeded repositories and git histories, an installed tarball consumer that type-checks a config and runs the `quality` bin through a baseline cycle, and installed consumers that extend each tsconfig preset, type-check a fixture with an expected error for each check the base turns on, and run the package preset's build output.
@@ -1,14 +1,25 @@
1
- import type { RuleInputs } from "../../../rule.ts";
1
+ import type { Finding, RuleInputs } from "../../../rule.ts";
2
+ import { type Declaration } from "./declarations.ts";
2
3
  import { type Json } from "./json.ts";
3
- export type Config = {
4
- readonly _tag: "Config";
4
+ export interface Preset {
5
+ readonly specifier: string;
6
+ readonly file: string;
7
+ readonly line: number;
8
+ readonly declared: ReadonlyArray<Declaration>;
9
+ }
10
+ export interface Layer {
5
11
  readonly path: string;
6
- readonly base: string;
7
12
  readonly json: Json;
8
- } | {
9
- readonly _tag: "Unreadable";
10
- readonly path: string;
11
- readonly reason: string;
12
- };
13
- export declare const biomeConfigs: ({ files, readText }: RuleInputs) => Promise<ReadonlyArray<Config>>;
13
+ readonly preset: Preset | undefined;
14
+ }
15
+ export interface Chain {
16
+ readonly base: string;
17
+ readonly layers: ReadonlyArray<Layer>;
18
+ }
19
+ export interface BiomeConfigs {
20
+ readonly root: string;
21
+ readonly chains: ReadonlyArray<Chain>;
22
+ readonly problems: ReadonlyArray<Finding>;
23
+ }
24
+ export declare const biomeConfigs: ({ files, readText }: RuleInputs) => Promise<BiomeConfigs>;
14
25
  //# sourceMappingURL=configs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/configs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAW,KAAK,IAAI,EAA8B,MAAM,WAAW,CAAC;AAE3E,MAAM,MAAM,MAAM,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAC9F;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAoCnF,eAAO,MAAM,YAAY,GAAU,qBAAqB,UAAU,KAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAOjG,CAAC"}
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/configs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAsC,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAW,KAAK,IAAI,EAA2C,MAAM,WAAW,CAAC;AAGxF,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CACtC;AA8ED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,YAAY,GAAU,qBAAqB,UAAU,KAAG,OAAO,CAAC,YAAY,CAYxF,CAAC"}
@@ -1,39 +1,75 @@
1
1
  import { posix } from "node:path";
2
+ import { decodeShipped, PRESET_DECLARATIONS } from "./declarations.js";
2
3
  import { itemsOf, member, parseJsonc, textOf } from "./json.js";
4
+ import { resolvePackage } from "./resolve.js";
3
5
  const ROOT_CONFIGS = ["biome.json", "biome.jsonc"];
4
6
  const NESTED = /(?:^|\/)biome\.jsonc?$/;
7
+ const RELATIVE = /^\.\.?(?:\/|$)/;
5
8
  const directoryOf = (path) => (posix.dirname(path) === "." ? "" : posix.dirname(path));
6
- const localExtends = (path, json) => {
7
- const node = member(json, "extends");
8
- const entries = node?._tag === "Array" ? itemsOf(node).flatMap((item) => textOf(item) ?? []) : [textOf(node) ?? ""];
9
- return entries.filter((entry) => entry.startsWith(".")).map((entry) => posix.join(posix.dirname(path), entry));
10
- };
11
- const load = async (readText, path, base, seen) => {
12
- if (seen.has(path)) {
13
- return [];
14
- }
15
- seen.add(path);
9
+ const read = async (readText, path) => {
16
10
  const text = await readText(path);
17
- if (text === undefined) {
18
- return [{ _tag: "Unreadable", path, reason: "the file does not exist" }];
11
+ return text === undefined ? { _tag: "Unreadable", reason: "the file does not exist" } : parseJsonc(path, text);
12
+ };
13
+ const problem = (file, message, line) => ({ layers: [], problems: [{ file, line, message }] });
14
+ const local = async (readText, path) => {
15
+ const parsed = await read(readText, path);
16
+ return parsed._tag === "Parsed"
17
+ ? { layers: [{ json: parsed.json, path, preset: undefined }], problems: [] }
18
+ : problem(path, `Cannot read this Biome config: ${parsed.reason}.`);
19
+ };
20
+ const fromPackage = async (readText, from, entry, specifier) => {
21
+ const target = await resolvePackage(readText, specifier);
22
+ if (target === undefined) {
23
+ return problem(from, `Cannot resolve the Biome config "${specifier}" from node_modules.`, entry.line);
19
24
  }
20
- const parsed = parseJsonc(path, text);
25
+ const parsed = await read(readText, target);
21
26
  if (parsed._tag === "Unreadable") {
22
- return [{ _tag: "Unreadable", path, reason: parsed.reason }];
27
+ return problem(from, `Cannot read the Biome config "${specifier}" at ${target}: ${parsed.reason}.`, entry.line);
28
+ }
29
+ const shipped = posix.join(posix.dirname(target), PRESET_DECLARATIONS);
30
+ const declared = await decodeShipped(await readText(shipped));
31
+ if (declared._tag === "Invalid") {
32
+ return problem(from, `Cannot read the declarations shipped with "${specifier}" at ${shipped}: ${declared.issues.join("; ")}.`, entry.line);
33
+ }
34
+ const preset = { declared: declared.value, file: from, line: entry.line, specifier };
35
+ return { layers: [{ json: parsed.json, path: target, preset }], problems: [] };
36
+ };
37
+ const extended = async (readText, from, entry) => {
38
+ const specifier = textOf(entry);
39
+ if (specifier === undefined || specifier === "//") {
40
+ return { layers: [], problems: [] };
41
+ }
42
+ if (RELATIVE.test(specifier)) {
43
+ return local(readText, posix.join(posix.dirname(from), specifier));
44
+ }
45
+ const relative = posix.normalize(specifier);
46
+ return (await readText(relative)) === undefined ? fromPackage(readText, from, entry, specifier) : local(readText, relative);
47
+ };
48
+ const extendsOf = (json) => itemsOf(member(json, "extends"));
49
+ const chainOf = async (readText, path) => {
50
+ const own = await local(readText, path);
51
+ const [layer] = own.layers;
52
+ if (layer === undefined) {
53
+ return own;
23
54
  }
24
- const extended = await Promise.all(localExtends(path, parsed.json).map((target) => load(readText, target, base, seen)));
25
- return [{ _tag: "Config", base, json: parsed.json, path }, ...extended.flat()];
55
+ const parents = await Promise.all(extendsOf(layer.json).map((entry) => extended(readText, path, entry)));
56
+ return { layers: [...parents.flatMap((parent) => parent.layers), layer], problems: parents.flatMap((parent) => parent.problems) };
26
57
  };
27
58
  const rootConfig = async (readText) => {
28
59
  const present = await Promise.all(ROOT_CONFIGS.map(async (path) => ((await readText(path)) === undefined ? [] : [path])));
29
60
  return present.flat()[0];
30
61
  };
31
62
  export const biomeConfigs = async ({ files, readText }) => {
32
- const seen = new Set();
33
63
  const root = await rootConfig(readText);
34
- const nested = files.filter((path) => NESTED.test(path) && path !== root);
35
- const roots = root === undefined ? [] : await load(readText, root, "", seen);
36
- const below = await Promise.all(nested.map((path) => load(readText, path, directoryOf(path), seen)));
37
- return [...roots, ...below.flat()];
64
+ const rootChain = root === undefined ? { layers: [], problems: [] } : await chainOf(readText, root);
65
+ const loaded = new Set(rootChain.layers.map((layer) => layer.path));
66
+ const nested = files.filter((path) => NESTED.test(path) && path !== root && !loaded.has(path));
67
+ const below = await Promise.all(nested.map(async (path) => ({ base: directoryOf(path), ...(await chainOf(readText, path)) })));
68
+ const all = [{ base: "", ...rootChain }, ...below];
69
+ return {
70
+ chains: all.filter((chain) => chain.layers.length > 0).map(({ base, layers }) => ({ base, layers })),
71
+ problems: all.flatMap((chain) => chain.problems),
72
+ root: root ?? "biome.json",
73
+ };
38
74
  };
39
75
  //# sourceMappingURL=configs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configs.js","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,OAAO,EAAa,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAM3E,MAAM,YAAY,GAA0B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ptyString;
5
+ readonly includes: Schema.NonEmptyArray<Schema.NonEmptyString>;
6
+ readonly reason: Schema.String;
7
+ }>;
8
+ export type Declaration = typeof Declaration.Type;
9
+ export declare const PRESET_DECLARATIONS = "declarations.json";
10
+ export declare const decodeShipped: (text: string | undefined) => Promise<Decoded<ReadonlyArray<Declaration>>>;
11
+ export interface Scoped {
12
+ readonly rule: string;
13
+ readonly includes: ReadonlyArray<string>;
14
+ }
15
+ export declare const matches: (declaration: Scoped, weakening: Scoped) => boolean;
16
+ export declare const scoped: (base: string, glob: string) => string;
17
+ export declare const scopeText: (includes: ReadonlyArray<string>) => string;
18
+ //# sourceMappingURL=declarations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAE/D,eAAO,MAAM,WAAW;;;;EAItB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAElD,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAMvD,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CACL,CAAC;AAEhG,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACzC;AAKD,eAAO,MAAM,OAAO,GAAI,aAAa,MAAM,EAAE,WAAW,MAAM,KAAG,OAC0B,CAAC;AAE5F,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAGnD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,UAAU,aAAa,CAAC,MAAM,CAAC,KAAG,MAAwD,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Schema } from "effect";
2
+ import { decodeWith } from "../../../decoded.js";
3
+ export const Declaration = Schema.Struct({
4
+ rule: Schema.NonEmptyString,
5
+ includes: Schema.NonEmptyArray(Schema.NonEmptyString),
6
+ reason: Schema.String.check(Schema.isPattern(/\S/, { expected: "a reason that says why the scope needs the rule weakened" })),
7
+ });
8
+ export const PRESET_DECLARATIONS = "declarations.json";
9
+ const shipped = Schema.toStandardSchemaV1(Schema.fromJsonString(Schema.Array(Declaration)), {
10
+ parseOptions: { errors: "all", onExcessProperty: "error" },
11
+ });
12
+ export const decodeShipped = (text) => text === undefined ? Promise.resolve({ _tag: "Valid", value: [] }) : decodeWith(shipped, text);
13
+ const sameScope = (left, right) => new Set(left).size === new Set(right).size && left.every((glob) => right.includes(glob));
14
+ export const matches = (declaration, weakening) => declaration.rule === weakening.rule && sameScope(declaration.includes, weakening.includes);
15
+ export const scoped = (base, glob) => {
16
+ const [, negation = "", path = glob] = /^(!*)(.*)$/.exec(glob) ?? [];
17
+ return base === "" ? glob : `${negation}${base}/${path}`;
18
+ };
19
+ export const scopeText = (includes) => includes.map((glob) => `"${glob}"`).join(", ");
20
+ //# sourceMappingURL=declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC;IACrD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,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,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACrE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAA+B,EAAU,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RuleInputs } from "../../../rule.ts";
2
+ export declare const resolvePackage: (readText: RuleInputs["readText"], specifier: string) => Promise<string | undefined>;
3
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAsEnD,eAAO,MAAM,cAAc,GAAU,UAAU,UAAU,CAAC,UAAU,CAAC,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAYpH,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { posix } from "node:path";
2
+ import { Schema } from "effect";
3
+ import { decodeWith } from "../../../decoded.js";
4
+ const Manifest = Schema.Struct({
5
+ name: Schema.optionalKey(Schema.String),
6
+ main: Schema.optionalKey(Schema.String),
7
+ exports: Schema.optionalKey(Schema.Unknown),
8
+ });
9
+ const manifestSchema = Schema.toStandardSchemaV1(Schema.fromJsonString(Manifest));
10
+ const CONDITIONS = new Set(["biome", "default"]);
11
+ const SPECIFIER = /^((?:@[^/]+\/)?[^/]+)(?:\/(.+))?$/;
12
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
13
+ const targetOf = (value, star) => {
14
+ if (typeof value === "string") {
15
+ return star === undefined ? value : value.replaceAll("*", star);
16
+ }
17
+ if (Array.isArray(value)) {
18
+ return value.map((item) => targetOf(item, star)).find((target) => target !== undefined);
19
+ }
20
+ const condition = isRecord(value) ? Object.keys(value).find((key) => CONDITIONS.has(key)) : undefined;
21
+ return isRecord(value) && condition !== undefined ? targetOf(value[condition], star) : undefined;
22
+ };
23
+ const bySpecificity = (left, right) => right.indexOf("*") - left.indexOf("*") || right.length - left.length;
24
+ const patternTarget = (exports, key) => {
25
+ const pattern = Object.keys(exports)
26
+ .filter((candidate) => candidate.split("*").length === 2)
27
+ .sort(bySpecificity)
28
+ .find((candidate) => {
29
+ const [prefix = "", suffix = ""] = candidate.split("*");
30
+ return key.startsWith(prefix) && key !== prefix && key.endsWith(suffix) && key.length >= candidate.length;
31
+ });
32
+ const [prefix = "", suffix = ""] = pattern?.split("*") ?? [];
33
+ return pattern === undefined ? undefined : targetOf(exports[pattern], key.slice(prefix.length, key.length - suffix.length));
34
+ };
35
+ const exported = (exports, subpath) => {
36
+ const key = subpath === "" ? "." : `./${subpath}`;
37
+ if (!isRecord(exports)) {
38
+ return targetOf(exports, undefined);
39
+ }
40
+ return Object.hasOwn(exports, key) ? targetOf(exports[key], undefined) : (patternTarget(exports, key) ?? targetOf(exports, undefined));
41
+ };
42
+ const inPackage = (directory, target) => target?.startsWith("./") === true ? posix.join(directory, target) : undefined;
43
+ const manifestAt = async (readText, path) => {
44
+ const text = await readText(path);
45
+ const decoded = text === undefined ? undefined : await decodeWith(manifestSchema, text);
46
+ return decoded?._tag === "Valid" ? decoded.value : undefined;
47
+ };
48
+ const fromDependency = (directory, manifest, subpath) => {
49
+ if (manifest.exports !== undefined) {
50
+ return inPackage(directory, exported(manifest.exports, subpath));
51
+ }
52
+ if (subpath === "" && manifest.main !== undefined) {
53
+ return posix.join(directory, manifest.main);
54
+ }
55
+ return subpath === "" ? undefined : posix.join(directory, subpath);
56
+ };
57
+ export const resolvePackage = async (readText, specifier) => {
58
+ const [, name, subpath = ""] = SPECIFIER.exec(specifier) ?? [];
59
+ if (name === undefined) {
60
+ return undefined;
61
+ }
62
+ const own = await manifestAt(readText, "package.json");
63
+ if (own?.name === name && own.exports !== undefined && subpath !== "") {
64
+ return inPackage("", exported(own.exports, subpath));
65
+ }
66
+ const directory = posix.join("node_modules", name);
67
+ const manifest = await manifestAt(readText, posix.join(directory, "package.json"));
68
+ return manifest === undefined ? undefined : fromDependency(directory, manifest, subpath);
69
+ };
70
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;CAC3C,CAAC,CAAC;AAIH,MAAM,cAAc,GAAG,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;AAElF,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAEtE,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAEtD,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,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IACD,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,QAAgC,EAAE,SAAiB,EAA+B,EAAE;IACxH,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAC/D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACvD,IAAI,GAAG,EAAE,IAAI,KAAK,IAAI,IAAI,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACvE,OAAO,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IACnF,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1F,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
- import { type Json } from "./json.ts";
1
+ import type { Chain, Layer } from "./configs.ts";
2
2
  export interface Weakening {
3
3
  readonly rule: string;
4
4
  readonly includes: ReadonlyArray<string>;
5
- readonly file: string;
6
5
  readonly line: number;
6
+ readonly layer: Layer;
7
7
  }
8
- export declare const weakeningsOf: (config: Json, file: string, base: string) => ReadonlyArray<Weakening>;
8
+ export declare const weakeningsOf: ({ base, layers }: Chain) => ReadonlyArray<Weakening>;
9
9
  //# sourceMappingURL=weakenings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"weakenings.d.ts","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/weakenings.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,IAAI,EAAkB,MAAM,WAAW,CAAC;AAEnF,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAwFD,eAAO,MAAM,YAAY,GAAI,QAAQ,IAAI,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,aAAa,CAAC,SAAS,CAM9F,CAAC"}
1
+ {"version":3,"file":"weakenings.d.ts","sourceRoot":"","sources":["../../../../src/rules/suppressions/biome/weakenings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIjD,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACtB;AA4GD,eAAO,MAAM,YAAY,GAAI,kBAAkB,KAAK,KAAG,aAAa,CAAC,SAAS,CACU,CAAC"}
@@ -1,34 +1,38 @@
1
+ import { scoped } from "./declarations.js";
1
2
  import { entriesOf, isFalse, itemsOf, member, textOf } from "./json.js";
2
3
  const LINT_WEAK = new Set(["off", "warn", "info"]);
3
4
  const ASSIST_WEAK = new Set(["off"]);
4
5
  const PRESETS = new Set(["recommended", "preset"]);
5
6
  const levelOf = (node) => textOf(node) ?? textOf(member(node, "level"));
6
- const at = (rule, node) => (node === undefined ? [] : [{ line: node.line, rule }]);
7
- const disabled = (rule, section) => isFalse(member(section, "enabled")) ? at(rule, member(section, "enabled")) : [];
8
- const withoutDefaults = (rule, set) => [
9
- ...(isFalse(member(set, "recommended")) ? at(rule, member(set, "recommended")) : []),
10
- ...(textOf(member(set, "preset")) === "none" ? at(rule, member(set, "preset")) : []),
7
+ const at = (rule, node, weak, wholeGroup = false) => node === undefined ? [] : [{ line: node.line, rule, weak, wholeGroup }];
8
+ const enabled = (rule, section) => at(rule, member(section, "enabled"), isFalse(member(section, "enabled")));
9
+ const defaults = (rule, set) => [
10
+ ...at(rule, member(set, "recommended"), isFalse(member(set, "recommended"))),
11
+ ...at(rule, member(set, "preset"), textOf(member(set, "preset")) === "none"),
11
12
  ];
13
+ const ruleSettings = (group, weak, rules) => entriesOf(rules)
14
+ .filter(([rule]) => !PRESETS.has(rule))
15
+ .flatMap(([rule, setting]) => {
16
+ const level = levelOf(setting);
17
+ return level === undefined ? [] : at(`${group}/${rule}`, setting, weak.has(level));
18
+ });
12
19
  const groupSettings = (prefix, weak, groups) => entriesOf(groups)
13
20
  .filter(([group]) => !PRESETS.has(group))
14
- .flatMap(([group, rules]) => [
15
- ...(weak.has(textOf(rules) ?? "") ? at(`${prefix}/${group}`, rules) : []),
16
- ...withoutDefaults(`${prefix}/${group}`, rules),
17
- ...entriesOf(rules)
18
- .filter(([rule, setting]) => !PRESETS.has(rule) && weak.has(levelOf(setting) ?? ""))
19
- .flatMap(([rule, setting]) => at(`${prefix}/${group}/${rule}`, setting)),
20
- ]);
21
+ .flatMap(([group, rules]) => {
22
+ const severity = textOf(rules);
23
+ return severity === undefined
24
+ ? [...defaults(`${prefix}/${group}`, rules), ...ruleSettings(`${prefix}/${group}`, weak, rules)]
25
+ : at(`${prefix}/${group}`, rules, weak.has(severity), true);
26
+ });
21
27
  const linter = (section) => [
22
- ...disabled("lint", section),
23
- ...withoutDefaults("lint/recommended", member(section, "rules")),
28
+ ...enabled("lint", section),
29
+ ...defaults("lint/recommended", member(section, "rules")),
24
30
  ...groupSettings("lint", LINT_WEAK, member(section, "rules")),
25
- ...entriesOf(member(section, "domains"))
26
- .filter(([, value]) => textOf(value) === "none")
27
- .flatMap(([domain, value]) => at(`lint/domains/${domain}`, value)),
31
+ ...entriesOf(member(section, "domains")).flatMap(([domain, value]) => at(`lint/domains/${domain}`, value, textOf(value) === "none")),
28
32
  ];
29
33
  const assist = (section) => [
30
- ...disabled("assist", section),
31
- ...withoutDefaults("assist/recommended", member(section, "actions")),
34
+ ...enabled("assist", section),
35
+ ...defaults("assist/recommended", member(section, "actions")),
32
36
  ...groupSettings("assist", ASSIST_WEAK, member(section, "actions")),
33
37
  ];
34
38
  const LANGUAGES = ["javascript", "json", "css", "graphql", "grit", "html"];
@@ -38,31 +42,35 @@ const TOOLS = [
38
42
  ["formatter", "format"],
39
43
  ];
40
44
  const SCOPED_SECTIONS = [["files", "files"], ...TOOLS];
41
- const scopeSettings = (scope) => [
45
+ const settingsOf = (scope) => [
42
46
  ...linter(member(scope, "linter")),
43
47
  ...assist(member(scope, "assist")),
44
- ...disabled("format", member(scope, "formatter")),
45
- ...LANGUAGES.flatMap((language) => TOOLS.flatMap(([key, name]) => disabled(`${language}/${name}`, member(member(scope, language), key)))),
48
+ ...enabled("format", member(scope, "formatter")),
49
+ ...LANGUAGES.flatMap((language) => TOOLS.flatMap(([key, name]) => enabled(`${language}/${name}`, member(member(scope, language), key)))),
46
50
  ];
47
- const scoped = (base, glob) => {
48
- const [, negation = "", path = glob] = /^(!*)(.*)$/.exec(glob) ?? [];
49
- return base === "" ? glob : `${negation}${base}/${path}`;
50
- };
51
+ const replaces = (later, earlier) => later.rule === earlier.rule || (later.wholeGroup && earlier.rule.startsWith(`${later.rule}/`));
51
52
  const includesOf = (override) => {
52
53
  const includes = itemsOf(member(override, "includes")).flatMap((item) => textOf(item) ?? []);
53
54
  return includes.length === 0 ? ["**"] : includes;
54
55
  };
55
56
  const narrowsScope = (globs) => globs.length > 0 && (globs.some((glob) => glob.startsWith("!")) || !globs.includes("**"));
56
- const narrowings = (config, file, base) => SCOPED_SECTIONS.flatMap(([key, name]) => {
57
+ const narrowings = (config, base) => SCOPED_SECTIONS.flatMap(([key, name]) => {
57
58
  const list = member(member(config, key), "includes");
58
59
  const globs = itemsOf(list).flatMap((item) => textOf(item) ?? []);
59
60
  return list === undefined || !narrowsScope(globs)
60
61
  ? []
61
- : [{ file, includes: globs.map((glob) => scoped(base, glob)), line: list.line, rule: `${name}/includes` }];
62
+ : [{ includes: globs.map((glob) => scoped(base, glob)), line: list.line, rule: `${name}/includes` }];
62
63
  });
63
- export const weakeningsOf = (config, file, base) => [
64
- ...narrowings(config, file, base),
65
- ...scopeSettings(config).map((setting) => ({ ...setting, file, includes: [scoped(base, "**")] })),
66
- ...itemsOf(member(config, "overrides")).flatMap((override) => scopeSettings(override).map((setting) => ({ ...setting, file, includes: includesOf(override).map((glob) => scoped(base, glob)) }))),
67
- ];
64
+ const layerWeakenings = (layer, later, base) => {
65
+ const overriding = later.flatMap((next) => settingsOf(next.json));
66
+ const top = settingsOf(layer.json).filter((setting) => setting.weak && !overriding.some((next) => replaces(next, setting)));
67
+ return [
68
+ ...narrowings(layer.json, base),
69
+ ...top.map(({ line, rule }) => ({ includes: [scoped(base, "**")], line, rule })),
70
+ ...itemsOf(member(layer.json, "overrides")).flatMap((override) => settingsOf(override)
71
+ .filter((setting) => setting.weak)
72
+ .map(({ line, rule }) => ({ includes: includesOf(override).map((glob) => scoped(base, glob)), line, rule }))),
73
+ ].map((weakening) => ({ ...weakening, layer }));
74
+ };
75
+ export const weakeningsOf = ({ base, layers }) => layers.flatMap((layer, index) => layerWeakenings(layer, layers.slice(index + 1), base));
68
76
  //# sourceMappingURL=weakenings.js.map