@shivaedev/quality 0.18.0 → 0.19.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 (203) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +143 -536
  3. package/biome/declarations.json +0 -45
  4. package/biome/plugins/constant-names.grit +1 -1
  5. package/biome/plugins/effect-fn-functions.grit +1 -1
  6. package/biome/preset.json +16 -9
  7. package/dist/biome/nativeEffectCall.d.ts +4 -0
  8. package/dist/biome/nativeEffectCall.d.ts.map +1 -0
  9. package/dist/biome/nativeEffectCall.js +34 -0
  10. package/dist/biome/nativeEffectCall.js.map +1 -0
  11. package/dist/biome/recognizeDiagnostics.d.ts +3 -0
  12. package/dist/biome/recognizeDiagnostics.d.ts.map +1 -0
  13. package/dist/biome/recognizeDiagnostics.js +58 -0
  14. package/dist/biome/recognizeDiagnostics.js.map +1 -0
  15. package/dist/biome/report.d.ts +10 -0
  16. package/dist/biome/report.d.ts.map +1 -1
  17. package/dist/biome/report.js +23 -5
  18. package/dist/biome/report.js.map +1 -1
  19. package/dist/biome/syntax.d.ts +12 -0
  20. package/dist/biome/syntax.d.ts.map +1 -0
  21. package/dist/biome/syntax.js +29 -0
  22. package/dist/biome/syntax.js.map +1 -0
  23. package/dist/cli/args.d.ts +1 -1
  24. package/dist/cli/args.d.ts.map +1 -1
  25. package/dist/cli/args.js +2 -2
  26. package/dist/cli/baseline.d.ts +1 -1
  27. package/dist/cli/baseline.d.ts.map +1 -1
  28. package/dist/cli/baseline.js.map +1 -1
  29. package/dist/cli/fix.d.ts +6 -6
  30. package/dist/cli/fix.d.ts.map +1 -1
  31. package/dist/cli/fix.js +1 -1
  32. package/dist/cli/fix.js.map +1 -1
  33. package/dist/cli/run-main.d.ts +1 -1
  34. package/dist/cli/run-main.d.ts.map +1 -1
  35. package/dist/cli/run-main.js.map +1 -1
  36. package/dist/config/decode.d.ts +3 -7
  37. package/dist/config/decode.d.ts.map +1 -1
  38. package/dist/config/decode.js +5 -3
  39. package/dist/config/decode.js.map +1 -1
  40. package/dist/config/load.d.ts +0 -2
  41. package/dist/config/load.d.ts.map +1 -1
  42. package/dist/config/load.js +11 -7
  43. package/dist/config/load.js.map +1 -1
  44. package/dist/config/resolve.d.ts.map +1 -1
  45. package/dist/config/resolve.js +8 -12
  46. package/dist/config/resolve.js.map +1 -1
  47. package/dist/config.d.ts +10 -16
  48. package/dist/config.d.ts.map +1 -1
  49. package/dist/config.js.map +1 -1
  50. package/dist/decoded.d.ts +4 -4
  51. package/dist/decoded.d.ts.map +1 -1
  52. package/dist/decoded.js.map +1 -1
  53. package/dist/engine/session.js.map +1 -1
  54. package/dist/engine/violation.d.ts +1 -1
  55. package/dist/engine/violation.d.ts.map +1 -1
  56. package/dist/engine/violation.js.map +1 -1
  57. package/dist/hooks/preCommit.d.ts +2 -2
  58. package/dist/hooks/preCommit.d.ts.map +1 -1
  59. package/dist/hooks/preCommit.js +24 -34
  60. package/dist/hooks/preCommit.js.map +1 -1
  61. package/dist/imports/browserGlobals.d.ts +3 -0
  62. package/dist/imports/browserGlobals.d.ts.map +1 -0
  63. package/dist/imports/browserGlobals.js +125 -0
  64. package/dist/imports/browserGlobals.js.map +1 -0
  65. package/dist/imports/browserNames.d.ts +2 -0
  66. package/dist/imports/browserNames.d.ts.map +1 -0
  67. package/dist/imports/browserNames.js +78 -0
  68. package/dist/imports/browserNames.js.map +1 -0
  69. package/dist/imports/fences/check.d.ts +4 -0
  70. package/dist/imports/fences/check.d.ts.map +1 -0
  71. package/dist/imports/fences/check.js +10 -0
  72. package/dist/imports/fences/check.js.map +1 -0
  73. package/dist/imports/fences/declarations.d.ts +5 -0
  74. package/dist/imports/fences/declarations.d.ts.map +1 -0
  75. package/dist/imports/fences/declarations.js +29 -0
  76. package/dist/imports/fences/declarations.js.map +1 -0
  77. package/dist/imports/fences/discover.d.ts +5 -0
  78. package/dist/imports/fences/discover.d.ts.map +1 -0
  79. package/dist/imports/fences/discover.js +41 -0
  80. package/dist/imports/fences/discover.js.map +1 -0
  81. package/dist/imports/graph.js +2 -2
  82. package/dist/imports/graph.js.map +1 -1
  83. package/dist/imports/projects.js.map +1 -1
  84. package/dist/imports/runtime.d.ts +5 -0
  85. package/dist/imports/runtime.d.ts.map +1 -0
  86. package/dist/imports/runtime.js +32 -0
  87. package/dist/imports/runtime.js.map +1 -0
  88. package/dist/imports/workspace.d.ts +1 -1
  89. package/dist/imports/workspace.d.ts.map +1 -1
  90. package/dist/imports/workspace.js +5 -1
  91. package/dist/imports/workspace.js.map +1 -1
  92. package/dist/inventory/collect.d.ts.map +1 -1
  93. package/dist/inventory/collect.js +8 -1
  94. package/dist/inventory/collect.js.map +1 -1
  95. package/dist/inventory/trackedPaths.d.ts +3 -0
  96. package/dist/inventory/trackedPaths.d.ts.map +1 -0
  97. package/dist/inventory/trackedPaths.js +26 -0
  98. package/dist/inventory/trackedPaths.js.map +1 -0
  99. package/dist/inventory/walk.d.ts +4 -4
  100. package/dist/inventory/walk.d.ts.map +1 -1
  101. package/dist/inventory/walk.js +32 -12
  102. package/dist/inventory/walk.js.map +1 -1
  103. package/dist/rules/built-in.d.ts +2 -3
  104. package/dist/rules/built-in.d.ts.map +1 -1
  105. package/dist/rules/built-in.js +6 -0
  106. package/dist/rules/built-in.js.map +1 -1
  107. package/dist/rules/comments/max-per-file.js +1 -1
  108. package/dist/rules/comments/max-per-file.js.map +1 -1
  109. package/dist/rules/files/folderNames.js +1 -1
  110. package/dist/rules/files/folderNames.js.map +1 -1
  111. package/dist/rules/files/otherNames.d.ts.map +1 -1
  112. package/dist/rules/files/otherNames.js +1 -10
  113. package/dist/rules/files/otherNames.js.map +1 -1
  114. package/dist/rules/imports/bundleInputs.d.ts +7 -0
  115. package/dist/rules/imports/bundleInputs.d.ts.map +1 -0
  116. package/dist/rules/imports/bundleInputs.js +77 -0
  117. package/dist/rules/imports/bundleInputs.js.map +1 -0
  118. package/dist/rules/imports/fences.d.ts +1 -2
  119. package/dist/rules/imports/fences.d.ts.map +1 -1
  120. package/dist/rules/imports/fences.js +4 -14
  121. package/dist/rules/imports/fences.js.map +1 -1
  122. package/dist/rules/imports/manifest.d.ts +2 -0
  123. package/dist/rules/imports/manifest.d.ts.map +1 -0
  124. package/dist/rules/imports/manifest.js +98 -0
  125. package/dist/rules/imports/manifest.js.map +1 -0
  126. package/dist/rules/imports/noTestCode.d.ts +2 -0
  127. package/dist/rules/imports/noTestCode.d.ts.map +1 -0
  128. package/dist/rules/imports/noTestCode.js +17 -0
  129. package/dist/rules/imports/noTestCode.js.map +1 -0
  130. package/dist/rules/imports/runtime.d.ts +2 -0
  131. package/dist/rules/imports/runtime.d.ts.map +1 -0
  132. package/dist/rules/imports/runtime.js +41 -0
  133. package/dist/rules/imports/runtime.js.map +1 -0
  134. package/dist/rules/max-lines.d.ts +0 -1
  135. package/dist/rules/max-lines.d.ts.map +1 -1
  136. package/dist/rules/max-lines.js +3 -10
  137. package/dist/rules/max-lines.js.map +1 -1
  138. package/dist/rules/suppressions/biome-overrides.d.ts.map +1 -1
  139. package/dist/rules/suppressions/biome-overrides.js +21 -4
  140. package/dist/rules/suppressions/biome-overrides.js.map +1 -1
  141. package/dist/rules/suppressions/biomeRecommended.js +2 -2
  142. package/dist/rules/suppressions/biomeRecommended.js.map +1 -1
  143. package/dist/rules/suppressions/no-inline.js +1 -1
  144. package/dist/rules/suppressions/no-inline.js.map +1 -1
  145. package/dist/standard-schema.d.ts +1 -1
  146. package/dist/standard-schema.d.ts.map +1 -1
  147. package/dist/standard-schema.js +10 -2
  148. package/dist/standard-schema.js.map +1 -1
  149. package/dist/vitest.d.ts +1 -3
  150. package/dist/vitest.d.ts.map +1 -1
  151. package/dist/vitest.js +11 -6
  152. package/dist/vitest.js.map +1 -1
  153. package/docs/debt-and-hooks.md +90 -0
  154. package/docs/modules.md +253 -0
  155. package/docs/naming.md +126 -0
  156. package/docs/north-star.md +61 -0
  157. package/docs/roadmap.md +37 -0
  158. package/docs/rules.md +308 -0
  159. package/docs/tooling.md +120 -0
  160. package/package.json +7 -5
  161. package/src/biome/nativeEffectCall.ts +45 -0
  162. package/src/biome/recognizeDiagnostics.ts +67 -0
  163. package/src/biome/report.ts +24 -6
  164. package/src/biome/syntax.ts +36 -0
  165. package/src/cli/args.ts +2 -2
  166. package/src/cli/baseline.ts +3 -3
  167. package/src/cli/fix.ts +13 -13
  168. package/src/cli/run-main.ts +1 -1
  169. package/src/config/decode.ts +7 -3
  170. package/src/config/load.ts +15 -9
  171. package/src/config/resolve.ts +10 -15
  172. package/src/config.ts +8 -15
  173. package/src/decoded.ts +3 -3
  174. package/src/engine/session.ts +3 -3
  175. package/src/engine/violation.ts +2 -2
  176. package/src/hooks/preCommit.ts +30 -39
  177. package/src/imports/browserGlobals.ts +142 -0
  178. package/src/imports/browserNames.ts +80 -0
  179. package/src/imports/fences/check.ts +12 -0
  180. package/src/imports/fences/declarations.ts +38 -0
  181. package/src/imports/fences/discover.ts +37 -0
  182. package/src/imports/graph.ts +2 -2
  183. package/src/imports/projects.ts +2 -2
  184. package/src/imports/runtime.ts +37 -0
  185. package/src/imports/workspace.ts +7 -2
  186. package/src/inventory/collect.ts +8 -1
  187. package/src/inventory/trackedPaths.ts +28 -0
  188. package/src/inventory/walk.ts +65 -36
  189. package/src/rules/built-in.ts +6 -0
  190. package/src/rules/comments/max-per-file.ts +1 -1
  191. package/src/rules/files/folderNames.ts +1 -1
  192. package/src/rules/files/otherNames.ts +1 -10
  193. package/src/rules/imports/bundleInputs.ts +94 -0
  194. package/src/rules/imports/fences.ts +4 -16
  195. package/src/rules/imports/manifest.ts +116 -0
  196. package/src/rules/imports/noTestCode.ts +18 -0
  197. package/src/rules/imports/runtime.ts +43 -0
  198. package/src/rules/max-lines.ts +4 -10
  199. package/src/rules/suppressions/biome-overrides.ts +31 -4
  200. package/src/rules/suppressions/biomeRecommended.ts +2 -2
  201. package/src/rules/suppressions/no-inline.ts +1 -1
  202. package/src/standard-schema.ts +11 -3
  203. package/src/vitest.ts +11 -6
package/docs/rules.md ADDED
@@ -0,0 +1,308 @@
1
+ # Rule reference
2
+
3
+ Use the [README](../README.md) for the gate's mental model and workflow. Quality owns the shared policy; consuming repositories adopt its defaults. This reference gives each built-in rule's scope, findings and accepted options, including the exposed local-rule API. An option being accepted is not a recommendation to tune the shared standard. Supply repository facts, such as generated locations and import boundaries, when a check needs them. The [naming reference](./naming.md) covers names and test layout; [shared tooling](./tooling.md) covers the Biome, Vitest and TypeScript setup.
4
+
5
+ ## File size
6
+
7
+ `structure/max-lines` keeps each module to one job: a source file may have 150 lines and [test code](./naming.md#test-code) 300, counted the way an editor numbers them. Declaration files are exempt. Its options are `source` and `test`: positive integer limits no greater than 150 and 300 respectively. Test code is identified by its conventional name or `test-support` folder; custom test-file patterns are rejected. A file over its limit counts one violation for each line above it: 168 lines under a limit of 150 count 18.
8
+
9
+ ### Comments
10
+
11
+ A comment says why, never what the code already says or what it used to be. Seven rules hold every comment to that:
12
+
13
+ | Rule | Reports | Options |
14
+ | --- | --- | --- |
15
+ | `comments/no-jsdoc` | Every `/** */` block, except a tool pragma the config allows | `allow` |
16
+ | `comments/no-line-reference` | A line number: `file.ts:42`, `file.ts#L42`, `line 42` | none |
17
+ | `comments/no-pr-reference` | A pull request or issue: `#123`, `PR 123`, `MR 123`, `pull request 123`, `merge request 123`, `issue 123`, `ticket 123`, `/pull/123`, `/pulls/123`, `/issues/123`, `/merge_requests/123`, `GH-123` | none |
18
+ | `comments/no-banner` | A banner, divider or region: a line that starts or ends with three or more of `- = * # ~ _ + / \ ─ ━ ═ ┄ ┈`, `#region`, `#endregion` | none |
19
+ | `comments/no-todo` | `TODO`, `FIXME`, `XXX` and `@todo` | none |
20
+ | `comments/no-environment-pragma` | A test environment set by a `@vitest-environment` or `@jest-environment` pragma (and its `-options`); name the file `*.dom.test.ts` instead, see [Vitest projects](./tooling.md#vitest-projects) | none |
21
+ | `comments/max-per-file` | A file with more than `max` comments, 2 by default | `max` (an integer from 0 to 2), `allow` |
22
+
23
+ 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.
24
+
25
+ Write a comment only for what the code cannot show, such as a constraint or a reason. The default limit of two comments is a tripwire against runaway commentary, not a budget to fill.
26
+
27
+ `comments/max-per-file` counts comments this way:
28
+
29
+ - A block comment counts once, however many lines it spans.
30
+ - Line comments that each stand alone on adjacent lines form one run and count once. A blank line, code, a directive, or a comment after code on the same line starts a new one.
31
+ - Allowed tool pragmas and directives are not counted: compiler and linter directives (`@ts-…`, triple-slash directives such as `/// <reference …>`, `biome-ignore…`, `eslint-disable…`, `eslint-enable…`, `oxlint-…`, `stylelint-…`, `deno-lint-ignore…`, `tslint:disable…`, `prettier-ignore`, Flow's `$FlowFixMe`, `$FlowIgnore`, `$FlowExpectedError`, `$FlowIssue` and `@noflow`), bundler annotations (`#__PURE__`, `@__PURE__`, `#__NO_SIDE_EFFECTS__`, `@__NO_SIDE_EFFECTS__`) and coverage hints (`c8 ignore`, `v8 ignore`, `istanbul ignore`). The suppression rules below report the directives that silence a check.
32
+
33
+ A file over the limit counts one violation for each comment above it: 5 comments against a limit of 2 count 3. A finding names the first comment over the limit.
34
+
35
+ A tool pragma is a comment whose every line starts with an allowed tag, such as `/** @jsxImportSource preact */`. `allow` lists the tags and is empty by default, so a pragma counts as a comment until the config allows its tag. Settings that a pragma would repeat in each file belong in the tool's config. `comments/no-jsdoc` and `comments/max-per-file` each take their own list, so give both the same one:
36
+
37
+ ```ts
38
+ const pragmas = ["@jsxImportSource", "@license"];
39
+
40
+ export default defineConfig({
41
+ rules: {
42
+ "comments/no-jsdoc": { options: { allow: pragmas } },
43
+ "comments/max-per-file": { options: { allow: pragmas } },
44
+ },
45
+ });
46
+ ```
47
+
48
+ A repository with existing comments adopts the rules through the baseline, for example `quality baseline write --rule comments/no-jsdoc --rule comments/max-per-file`.
49
+
50
+ ### Suppressions
51
+
52
+ A check that is silenced at one site hides the problem instead of fixing it. Five rules close the escape hatches, and none of them takes registry exceptions: a registry entry that names one fails the gate as stale. A repository with existing suppressions adopts the rules through the baseline.
53
+
54
+ | Rule | Reports | Options |
55
+ | --- | --- | --- |
56
+ | `suppressions/no-inline` | Every comment directive that silences a linter, the compiler or a formatter, except `@ts-expect-error` in a type test | none |
57
+ | `suppressions/no-double-cast` | A cast through `unknown`, `any` or `never`: `x as unknown as T`, `x as any as T`, `x as never as T`, `<T><unknown>x` | none |
58
+ | `suppressions/biome-overrides` | A Biome setting that turns a check off or down, or keeps files out of it, without a declaration, and a declaration that matches no setting | `declared` |
59
+ | `suppressions/biome-recommended` | A rule the installed Biome recommends that the [Biome preset](./tooling.md#biome-preset) neither sets to `error` nor declares | none |
60
+ | `suppressions/no-ignore-deprecations` | `compilerOptions.ignoreDeprecations` in a tsconfig, which silences TypeScript's errors for deprecated options | none |
61
+
62
+ `suppressions/no-inline` reports these directives, wherever a line of a comment starts with one:
63
+
64
+ - Biome: `biome-ignore`, `biome-ignore-all` and `biome-ignore-start`, for lint, assist and format alike. The `biome-ignore-end` that closes a range is not reported again.
65
+ - TypeScript: `@ts-ignore`, `@ts-expect-error` and `@ts-nocheck`. `@ts-check` turns checking on and is allowed.
66
+ - Other linters: `eslint-disable`, `eslint-disable-line`, `eslint-disable-next-line` and inline rule settings such as `/* eslint no-console: "off" */`; the same `-disable` forms of `oxlint` and `stylelint`; `deno-lint-ignore` and `deno-lint-ignore-file`; `tslint:disable…`.
67
+ - Formatters: `prettier-ignore`, since `prettier --check` fails on the code it skips.
68
+ - Flow: `$FlowFixMe`, `$FlowIgnore`, `$FlowExpectedError`, `$FlowIssue` and `@noflow`.
69
+
70
+ Coverage hints (`c8 ignore`, `v8 ignore`, `istanbul ignore`) are allowed: they leave code out of a coverage measure and silence no linter or compiler. The rule reads the TypeScript and JavaScript modules among the sources, declaration files included, and every `.css`, `.scss` and `.less` file among the checked files, whatever `extensions` says. Each finding names the line its comment starts on and has the directive as its subject.
71
+
72
+ `suppressions/no-ignore-deprecations` reads every JSON file in the repository whose `compilerOptions` sets `ignoreDeprecations`, whatever the file is named, so a shared config such as `tsconfig/base.json` counts as much as a `tsconfig.json`. Like `manifests/sorted`, it walks the whole repository, not only the sources, and skips untracked files ignored by git and `node_modules`. Each finding names the line of the setting. Replace the deprecated option it hides, then remove it.
73
+
74
+ #### Type tests
75
+
76
+ A type test proves that an API rejects what its types forbid, and TypeScript asserts a compile error only through `@ts-expect-error`, which fails as soon as the error it expects goes away. So `@ts-expect-error`, and no other directive, is allowed in a type test: a file named `*.typecheck.test.ts`, `*.typecheck.spec.ts` or `typecheck.test.ts` (or `.tsx`). The compiler checks these files; [Vitest projects](./tooling.md#vitest-projects) never run them. `@ts-ignore`, `@ts-nocheck` and every linter and formatter directive stay reported in them. A test that must pass a rejected value at run time, to prove the runtime refuses it too, calls the API through `Reflect.apply` instead of a directive.
77
+
78
+ `suppressions/no-double-cast` finds casts with the TypeScript parser, through parentheses and in either assertion syntax. A single cast is left to the linter, and `as const` is not a cast.
79
+
80
+ #### Declared Biome overrides
81
+
82
+ Consumer declarations cover one lint rule or assist action on explicit file paths, with a reason. Globs, whole checks and rule groups cannot be declared. A `files/includes` declaration must retain `**` and add only negative patterns naming a concrete directory, such as `!**/test-support/generated`. These patterns may start with `**/` and use `*` for an intermediate directory, as in `!**/test-support/*/generated`. Every other segment names a directory without dots except an optional leading dot; the final segment must be a name. File patterns, nested `**` and wildcard suffixes are rejected. Shipped preset declarations describe Quality's internal policy and are not subject to the consumer scope restriction.
83
+
84
+ Quality ships reasons for its own internal Biome exceptions. Extend the shared configuration and use the baseline for debt. `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:
85
+
86
+ | Setting | Detected as |
87
+ | --- | --- |
88
+ | A lint rule at `off`, `warn` or `info`, as a string or a `level` | `lint/<group>/<rule>` |
89
+ | A lint group at `off`, `warn` or `info`, or with `recommended: false` or `preset: "none"` | `lint/<group>` |
90
+ | `linter.rules` with `recommended: false` or `preset: "none"` | `lint/recommended` |
91
+ | A domain at `none` | `lint/domains/<domain>` |
92
+ | `linter.enabled: false` | `lint` |
93
+ | An assist action at `off`, such as `useSortedKeys` or `organizeImports` | `assist/<group>/<action>` |
94
+ | `assist.actions` with `recommended: false` or `preset: "none"` | `assist/recommended` |
95
+ | `assist.enabled: false` | `assist` |
96
+ | `formatter.enabled: false` | `format` |
97
+ | `enabled: false` in a language's `linter`, `assist` or `formatter`, such as `css.linter` | `<language>/lint`, `<language>/assist`, `<language>/format` |
98
+ | An `includes` list in `files`, `linter`, `assist` or `formatter` that excludes a pattern with `!` or lacks `**` | `files/includes`, `lint/includes`, `assist/includes`, `format/includes` |
99
+
100
+ Biome runs assist actions, key sorting among them, as part of `biome check` and reports what they would change, so turning one off is an override. Formatter options such as `indentStyle` or `lineWidth` choose a style, not an exception, and are not overrides. Settings that raise a rule or enable it are not overrides either. Rule options are not read, so an option that loosens a rule, such as a higher complexity limit, is left to review.
101
+
102
+ ```ts
103
+ export default defineConfig({
104
+ rules: {
105
+ "suppressions/biome-overrides": {
106
+ options: {
107
+ declared: [
108
+ {
109
+ rule: "lint/style/noDefaultExport",
110
+ includes: ["scripts/tool.config.ts"],
111
+ reason: "Tools load their config files through the default export.",
112
+ },
113
+ {
114
+ rule: "lint/suspicious/noConsole",
115
+ includes: ["scripts/report.ts"],
116
+ reason: "Scripts report to the terminal they run in.",
117
+ },
118
+ ],
119
+ },
120
+ },
121
+ },
122
+ });
123
+ ```
124
+
125
+ 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). Paths in a nested config are relative to its folder, so a rule scoped to `"src/a.ts"` in `packages/web/biome.json` is declared as `"packages/web/src/a.ts"`. Top-level and globbed rule scopes cannot be declared by consumers. 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.
126
+
127
+ #### Shared presets
128
+
129
+ A config `extends` its entries the way Biome does:
130
+
131
+ - 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.
132
+ - 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.
133
+ - 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.
134
+ - 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.
135
+ - 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.
136
+
137
+ 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:
138
+
139
+ ```json
140
+ [
141
+ {
142
+ "rule": "lint/style/noDefaultExport",
143
+ "includes": ["**/*.config.ts"],
144
+ "reason": "Tools load their config files through the default export."
145
+ }
146
+ ]
147
+ ```
148
+
149
+ 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.
150
+
151
+ #### Recommended Biome rules
152
+
153
+ `suppressions/biome-recommended` holds the [Biome preset](./tooling.md#biome-preset) to every rule Biome recommends, so a Biome upgrade that adds a recommended rule, or recommends one the preset leaves below `error`, fails the gate until the preset takes a position on it. It asks the installed Biome, the one `quality` runs, which rules its `recommended` preset enables, through `biome rage --linter`, so the list is never written down. When the root Biome config extends `@shivaedev/quality/biome`, it reads that preset and its `declarations.json`, resolved from the repository root as under [Shared presets](#shared-presets); a repository that does not extend the preset is left to the `biome` rule, which asks for it. A recommended rule is in order when the preset's `linter.rules` sets it to `error`, directly or through its group's severity, or when a declaration names it, whatever the declaration's `includes`. Every other recommended rule is reported at the preset, one finding per rule: set it to `error` and repair the code it reports.
154
+
155
+ ### Imports
156
+
157
+ Six rules check the imports of the TypeScript and JavaScript modules among the sources. `imports/cycles`, `imports/resolvable`, `imports/manifest`, `imports/no-test-code` and `imports/fences` with declared fences build a graph resolved by the TypeScript compiler. `imports/aliased` checks relative path syntax.
158
+
159
+ | Rule | Reports | Options |
160
+ | --- | --- | --- |
161
+ | `imports/cycles` | Modules that import each other at run time | none |
162
+ | `imports/resolvable` | An import that resolves to nothing | `generated` |
163
+ | `imports/manifest` | A workspace import missing from the importing package’s shipped dependencies, or present only in `devDependencies` in shipped code | none |
164
+ | `imports/fences` | An import that crosses a fence the config declares | `fences` |
165
+ | `imports/aliased` | A relative import that leaves its own folder | none |
166
+ | `imports/no-test-code` | A production module importing a test file or anything under `test-support/` | none |
167
+
168
+ Each graph edge resolves the way the compiler resolves it, with the options of the nearest `tsconfig.json` and the projects it references, under bundler resolution: `paths`, `package.json` `imports` and `exports` and the `source` condition hold, so a workspace package resolves to its source. The graph reads literal specifiers in static and dynamic imports, `export ... from`, `require()`, `require.resolve()`, `import.meta.resolve()` of a bare specifier (a relative one is URL arithmetic that never checks the path), `import()` types, `/// <reference types>`, `/// <reference path>` and JSDoc `@import` tags. Computed specifiers are outside this check.
169
+
170
+ - An import of a stylesheet, an image or JSON resolves to the file, and only when the file exists, whatever declaration describes it. A Node builtin resolves.
171
+ - A runtime import must resolve to code: a declaration file (`.d.ts`, `.d.mts`, `.d.cts`, or an asset declaration such as `.d.css.ts`) satisfies only `import type` and `export type`, however the import reaches it, so a package that has only its `@types` package installed, or an `exports` entry that points at a declaration, is reported.
172
+ - A bare import resolves when a declaration file of the importer's tsconfig project declares the module in a script (`declare module "virtual:*"`). A relative import always needs a real file, `declare module "*"` and patterns with more than one `*` never count, and a `declare module` inside a module is an augmentation, which declares nothing new.
173
+ - A relative import or a `#` package import of a missing file resolves only inside a folder that `generated` names, such as a client a generator writes before the tests run. A `#` import lands where its `imports` entry in `package.json` points once the file exists. Each folder must be ignored by git, or at least every file an import names in it must be, hold no file git tracks but a `.gitkeep` or `.keep` placeholder, lie outside `node_modules` and hold a file that an import names. The import stays an edge to its path, so fences apply to it before the file exists.
174
+ - A module that resolves into `node_modules` or outside the root is external, and its package is the one it resolves into, whatever alias the import uses. A `@types` package counts as the package it describes: `@types/hast` is `hast`, `@types/scope__name` is `@scope/name`.
175
+
176
+ ```ts
177
+ import { defineConfig } from "@shivaedev/quality/config.ts";
178
+
179
+ export default defineConfig({
180
+ rules: { "imports/resolvable": { options: { generated: ["packages/db/src/test-support/generated"] } } },
181
+ });
182
+ ```
183
+
184
+ `imports/cycles` reports each group of modules that import each other at run time once, at the alphabetically first of them, with one loop through the group. Its count is the number of modules in the group. `import type`, `export type`, type references and imports in declaration files are left out; `import { type X }` stays a runtime import. Dynamic `import()` and `require()` count; `require.resolve()` does not. It takes no registry exceptions. Each finding of `imports/resolvable` has the import as its subject.
185
+
186
+ When the sources hold no module at all, the graph-building rules stop the run instead of passing on an empty graph. Point `sources` at the code; do not disable the checks to conceal an empty inventory. `imports/aliased` does not require a graph, and `imports/fences` does nothing when no fences are declared.
187
+
188
+ #### Runtime folders
189
+
190
+ `imports/runtime` adopts a package automatically when it has `src/client/` or `src/server/`, including folders outside `sources`. In an adopted package, code in `src/client/` is browser code, code in `src/server/` is server code, and code anywhere else is shared. A package without either folder retains its existing policies. Existing explicit fences keep running in either case.
191
+
192
+ Client code may not import server code or Node built-ins. Shared code may import neither client nor server code and may neither import Node built-ins nor use browser globals. Client and server code may import shared code. The rule uses the resolved import graph, including type imports, re-exports, dynamic imports and literal `require()` calls; missing file targets still carry their runtime folder. Test files and `test-support/` are outside the shipped runtime policy.
193
+
194
+ Browser-global checks report direct, shorthand and literal `globalThis` property uses, with lexical bindings respected. Property names, comments, strings and type annotations do not count as global value uses. Browser-specific globals come from TypeScript's DOM declarations, excluding the standard web APIs that Node also supplies. Worker browser APIs such as `indexedDB` and `caches` remain browser globals. Portable web APIs such as `URL`, `fetch` and `AbortController` remain available to shared code. This is a static source check, not proof of a deployment's runtime behavior. Each finding has the imported specifier or browser global as its subject. Move runtime-dependent code to its runtime folder or pass a value into shared code.
195
+
196
+ #### Manifest dependencies
197
+
198
+ `imports/manifest` discovers named workspace members from `pnpm-workspace.yaml` or the root manifest's `workspaces`, with no package scope convention or fence configuration. It discovers manifests across the repository, independently of `sources`, skipping files ignored by git and `node_modules`. Selecting only a member's `src` folder still checks its imports of members outside that selection against its own manifest. Each import of another member must appear in the importing member's `dependencies`, `peerDependencies` or `optionalDependencies`. The workspace root uses its own manifest for code outside a member. Self-imports and packages outside the workspace do not need a workspace declaration under this rule.
199
+
200
+ Tests and files under `test-support/` may also use `devDependencies`. Tooling means files under a `script/`, `scripts/` or `tooling/` folder directly below the importing package's root, or a config file directly at that root, named `config.ts`, `vitest.config.ts` or another `*.config.*` with a JavaScript or TypeScript extension. A folder or config file nested under `src/` still counts as shipped code. Source modules explicitly blocked by a null package export may use development dependencies when no runtime module reaches them in the scanned import graph. A more specific public export, an export under another name or an executable entry point keeps its imports in the runtime boundary. The rule follows imports, re-exports and type references through blocked helpers; a blocked public subpath alone cannot hide a runtime dependency.
201
+
202
+ The rule checks type imports as well as value imports. Resolved aliases and relative paths use the target's workspace owner; unresolved bare package names and subpaths still require a declaration. A nested manifest that is not a workspace member does not replace its owner's dependency policy. Malformed dependency objects stop the run. Add the dependency to the correct manifest field or remove the import; the rule does not edit manifests.
203
+
204
+ #### Aliases
205
+
206
+ A relative import names only a file in its own folder, such as `./format.ts`: the folder is one module. Every other import goes through an alias, so moving a file never rewrites a chain of `../`:
207
+
208
+ - the `imports` of the importer's nearest `package.json`, such as `"#lib/*": "./src/lib/*"`, or `"#shared/*": "@demo/shared/*"`, which names another workspace package;
209
+ - the name of another workspace package, as far as its `exports` reach.
210
+
211
+ An import that already goes through a tsconfig `paths` alias is not relative, so the rule leaves it alone.
212
+
213
+ `imports/aliased` reports a relative import that goes up (`../format.ts`) or down into a subfolder (`./parts/deeper.ts`, or `./widgets` for `widgets/index.ts`). It reads literal specifiers in static imports, `export ... from`, side-effect imports, `import()`, `require()`, `import()` types, JSDoc `@import` tags and the paths of `vi.mock`, `vi.doMock`, `vi.unmock`, `vi.doUnmock`, `vi.importActual` and `vi.importMock`, so a mock keeps pointing at the module it replaces. An escaped path, such as `"\x2e\x2e/format.ts"`, counts as the path it spells. Each finding has the import as its subject. Its message names the fix for where the import lands:
214
+
215
+ - inside its own package: import through a `#` alias from the `imports` of the package's `package.json`, and declare one if none fits;
216
+ - inside another workspace package: import it by that package's name, through a path its `exports` lists;
217
+ - inside an installed package under `node_modules`: import that package by its name.
218
+
219
+ The rule only reports; nothing rewrites the import. Whoever writes the import picks the alias, because only they know which conditions their runtimes, bundler and tests use.
220
+
221
+ #### Fences
222
+
223
+ A fence is one prohibition. A package declares stronger promises than its manifest in `quality.fences.config.ts` beside `package.json`. Quality discovers this file at the root and in workspace members without a root-config list, independently of the source inventory:
224
+
225
+ ```ts
226
+ import { external, folders, packages } from "@shivaedev/quality/imports/fences/selectors.ts";
227
+ import { fence } from "@shivaedev/quality/imports/fences/dsl.ts";
228
+
229
+ const fences = [
230
+ fence("ui-never-imports-server")
231
+ .because("The UI ships to browsers.")
232
+ .from(folders("packages/ui/src"))
233
+ .mayNotImport(packages("server"))
234
+ .demonstratedBy({
235
+ illegal: ["packages/ui/src/app.ts", "packages/server/src/db.ts"],
236
+ legal: ["packages/ui/src/app.ts", external("effect")],
237
+ }),
238
+ ];
239
+
240
+ export default fences;
241
+ ```
242
+
243
+ A fence has a name, a reason, the modules it holds (`from`) and one prohibition:
244
+
245
+ - `mayNotImport(target)`: no module it holds imports the target.
246
+ - `mayNotReach(target)`: nothing a module it holds imports, directly or through other modules of the repository, is the target. The finding names the path.
247
+ - `mayImportOnly(...subjects).of(unit)`: the modules it holds import only the named modules or folders directly in a package's `src` folder (or the package folder) or in a folder.
248
+
249
+ Targets are `packages(...)` (workspace packages by name, with or without their scope; a workspace package is a named `package.json` that `pnpm-workspace.yaml` or the root `package.json` `workspaces` includes, with `*`, `**`, `?`, `{a,b}` and `[...]` in its patterns, none of which match a folder whose name starts with `.` unless the pattern spells the dot, and a `packages` list or pattern the gate cannot read stops the run, and it holds every file below it that no deeper workspace package holds), `folders(...)`, `files(...)`, `modules(...)` (external packages by package name, and Node builtins), `scopes(...)` (every external package of a scope), `anyOf(...)`, `workspace` (every workspace package) and `anything`. Each takes `.except(...)`.
250
+
251
+ The DSL does not compile without `demonstratedBy`, and the rule checks the examples against the combined discovered and config-supplied policy: each is a chain of imports from a file of the repository, which may end in `external(name)`. The illegal example must cross this fence and no other; the legal example must cross none. Every name a fence uses must exist: a package, a folder that holds checked files, a checked file, a subject of the unit. Two fences may not share a name, and each needs a reason. A policy that breaks any of this stops the run. Fences count type imports too.
252
+
253
+ Fences guard shipped code, and [test code](./naming.md#test-code) ships nowhere, so a fence never holds it: a test file or a file under `test-support/` may import across every fence. There is no option to check them.
254
+
255
+ A finding has its fence's name as its subject, so a registry entry with that subject excuses one file from one fence.
256
+
257
+ `imports/no-test-code` checks every file edge from a production module to a test file or a file under `test-support/`, including type imports, re-exports and test assets. It rejects missing relative paths under `test-support/` too. Test importers may still import production code and other test code. Move shared code into a production module and import it from both production and tests. The rule takes no registry exceptions.
258
+
259
+ ### Manifests
260
+
261
+ `manifests/sorted` keeps every `package.json` in the repository in the key order of [sort-package-json](https://github.com/keithamus/sort-package-json), a dependency of this package. It walks the whole repository, not only the sources, and skips untracked files ignored by git and `node_modules`. A manifest that is not valid JSON is reported too. `quality fix` sorts the manifests, and the rule takes no registry exceptions.
262
+
263
+ ## Local-rule API
264
+
265
+ The API allows a local rule to receive checked source text and return findings. This is an extension reference, not a step every repository must complete; reusable quality policy belongs in the shared package. This example is the same text-scanning rule exercised by the package's CLI tests:
266
+
267
+ ```ts
268
+ import { defineRule } from "@shivaedev/quality/rule.ts";
269
+
270
+ export const noLog = defineRule({
271
+ check: ({ sources }) =>
272
+ sources
273
+ .filter((file) => file.text.includes("console.log"))
274
+ .map((file) => ({ file: file.path, message: "logs to the console." })),
275
+ description: "Log through the logger.",
276
+ id: "local/no-console-log",
277
+ });
278
+ ```
279
+
280
+ It reports a file whose text contains `console.log`; it does not parse calls or distinguish a string from code. Use a syntax-aware check when the policy needs that distinction. Register it in the config:
281
+
282
+ ```ts
283
+ import { defineConfig } from "@shivaedev/quality/config.ts";
284
+ import { noLog } from "./quality/noLog.ts";
285
+
286
+ export default defineConfig({ local: [noLog], sources: ["src"] });
287
+ ```
288
+
289
+ `check` may return findings directly or asynchronously. For options, provide a [Standard Schema](https://standardschema.dev) validator; the check receives the decoded result. An absent options object is validated as `{}`, so defaults belong in the schema:
290
+
291
+ ```ts
292
+ import { Effect, Schema } from "effect";
293
+ import { defineRule } from "@shivaedev/quality/rule.ts";
294
+
295
+ const Limit = Schema.Struct({
296
+ max: Schema.Int.pipe(Schema.withDecodingDefaultKey(Effect.succeed(2))),
297
+ });
298
+
299
+ export const limited = defineRule({
300
+ check: async ({ files, options }) =>
301
+ files.length > options.max ? [{ file: ".", message: `${files.length} files exceed ${options.max}.` }] : [],
302
+ description: "Keep the repository small.",
303
+ id: "local/max-files",
304
+ options: Schema.toStandardSchemaV1(Limit, { parseOptions: { onExcessProperty: "error" } }),
305
+ });
306
+ ```
307
+
308
+ This is the option-bearing rule the package tests. It defaults to two files and validates a configured `max` before the asynchronous check runs. A rule without an options schema refuses options. Set `registrable: false` when a rule must never be excused by a registry entry.
@@ -0,0 +1,120 @@
1
+ # Shared tooling
2
+
3
+ Quality's shared policy includes Biome and TypeScript configuration and Vitest project helpers alongside the gate. These connect the native tools to one opinionated set of conventions; consumers do not need to choose a rule set for each tool. Use the [README](../README.md) to configure the gate; use this page to wire the tools that check, format, compile and run the repository.
4
+
5
+ ## Biome preset
6
+
7
+ `@shivaedev/quality/biome` supplies the shared Biome configuration. Quality includes and runs Biome; the root `biome.json` extends the shared configuration:
8
+
9
+ ```json
10
+ {
11
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
12
+ "extends": ["@shivaedev/quality/biome"]
13
+ }
14
+ ```
15
+
16
+ The preset sets:
17
+
18
+ - **Formatting:** tabs, a line width of 150, double quotes, semicolons, trailing commas and operators at the start of a wrapped line. An object key keeps its quotes, because a quoted key marks a [foreign name](./naming.md#foreign-names).
19
+ - **Lint:** recommended rules are set to `error` or explained in the preset's declarations. Stricter settings include `noUnsafeTypeAssertion`, `useBlockStatements`, `useNumericSeparators`, `useUnicodeRegex`, `useLiteralKeys`, `noFloatingPromises`, `useExhaustiveDependencies`, `useConsistentTestIt`, `noNonScalableViewport`, function declaration style, interface style, a cognitive complexity limit of 15, `noNestedTernary` and the [naming rules](./naming.md).
20
+ - **Imports:** organized in five groups: Node and Bun builtins, packages, `@shivaedev/*` packages, aliases and relative paths. Biome counts as an alias a specifier that starts with `#`, `@/`, `~`, `$` or `%`; a tsconfig path such as `@app/*` sorts with the packages, and Biome's `noUndeclaredDependencies` takes it for one, so name aliases in a form Biome recognizes.
21
+ - **Assist:** organized imports and checks for sorted keys, attributes, enum members, interface members and properties. The key-sorting check applies to JSON and object literals, but `quality fix` skips its fix. `package.json` is left out of that check because `manifests/sorted` supplies its key order.
22
+ - **Plugins:** GritQL rules that ban ambient time, randomness, `console` and `process.env` for Effect's services, and the naming plugins under [Naming](./naming.md). They load from `./node_modules/@shivaedev/quality/biome/plugins`, so the package must be installed at the repository root.
23
+ - Files ignored by git are skipped.
24
+
25
+ The preset turns off `noUnusedVariables` and `noUnusedFunctionParameters`, because the tsconfig presets report them through TypeScript. It allows default exports in `*.config.*` files, which tools load through the default export, and turns off `useComponentExportOnlyModules` in `*.test.*` and `*.spec.*` files, where tests define their harness components.
26
+
27
+ The preset reports `useSortedClasses` at `error` with its fix enabled for class attributes and calls to `cn`, `clsx` and `cva`. Tailwind output does not depend on the order of classes in an attribute, so sorting is safe.
28
+
29
+ The preset sets `noDelete` to `off` because its fix changed behavior or did not finish on real code. `noUndeclaredClasses` is off because its class resolution does not cover aliases and Tailwind utilities; `noInlineStyles` is off because computed values need inline styles. Quality owns these choices and ships their reasons in `declarations.json`. They do not require consumer declarations. The exposed consumer-declaration API is described under [declared Biome overrides](./rules.md#declared-biome-overrides); use the shared defaults for adoption.
30
+
31
+ The preset keeps the following rules at `error` with their fixes off so the author decides the repair: `noAccessKey`, `noAriaHiddenOnFocusable`, `noAutofocus`, `noInteractiveElementToNoninteractiveRole`, `noNoninteractiveElementToInteractiveRole`, `noNoninteractiveTabindex`, `noRedundantRoles`, `useValidAriaProps`, `useValidAriaRole`, `noImportantStyles`, `noConstAssign`, `noProcessGlobal`, `useJsonImportAttributes`, `noUnusedPrivateClassMembers`, `useExhaustiveDependencies`, `noFloatingPromises`, `noMisusedPromises`, `useExhaustiveSwitchCases`, `noEqualsToNull`, `useConsistentArrayType`, `useConsistentCurlyBraces`, `useConsistentTestIt`, `useRegexpTest`, `useUnicodeRegex`, `noNonNullAssertion`, `useAtIndex`, `noParametersOnlyUsedInRecursion`, `noSkippedTests` and `useNamingConvention`. The fix command also skips `noDuplicateObjectKeys` and `useSortedKeys`. Import `process` from `node:process` in Node code or use the application's Effect service. Write JSON imports with `with { type: "json" }` for Node 24; the fixer leaves both choices to the author.
32
+
33
+ - `useConsistentArrayType`: its fix rewrites locally defined `Array<T>` and `ReadonlyArray<T>` types as built-in arrays; check the type binding before writing shorthand.
34
+ - `useConsistentCurlyBraces`: its fix can replace escaped newlines in JSX strings with literal backslash text; preserve rendered text when removing braces.
35
+ - `noMisusedPromises`: awaiting a promise changes timing, conditional results and rejection handling; make the callback contract accept its promise when the caller awaits it, or handle completion and rejection explicitly.
36
+ - `useExhaustiveSwitchCases`: adding cases that fall through to default conflicts with `noUselessSwitchCase`; write every case with its intended result, preserving a default fallback where needed.
37
+ - `noEqualsToNull`: replacing loose null equality with strict equality loses the `undefined` case; write explicit checks for both `null` and `undefined`.
38
+
39
+ `noSkippedTests` has no automatic fix because enabling a skipped test can change which setup and bodies run; the author must repair the test or remove a claim it cannot prove.
40
+
41
+ The `biome` rule runs `biome check` with the repository's config and reports each finding as `biome/<category>`, such as `biome/lint/style/useBlockStatements`, `biome/assist/source/useSortedKeys`, `biome/format` or `biome/plugin`, so Biome's findings go through the baseline like any other rule's. `quality baseline write --rule biome` takes in every Biome category at once. A finding below `error` is not reported; a consumer exception for an individual rule therefore needs an explicit file scope and a reason. Whole-check, group and blanket-scope declarations are rejected; see [configuration limits](../README.md#configuration-limits). The rule also asks for a root `biome.json` or `biome.jsonc` that extends the preset, and it takes no registry exceptions. A Biome config that Biome cannot load stops the run with Biome's message.
42
+
43
+ `quality fix` sorts the discovered manifests, then runs `biome check --write --unsafe`, with the two skipped fixes above. It then runs Biome's formatter, because a lint fix can leave code unformatted. One fix can make room for another, so it repeats both passes until a round rewrites nothing, at most five rounds. When files still change in the fifth round, it names the changed text files it can discover and exits 2; when those files are outside its inventory, the error gives a verbose Biome command to name them. An unsafe fix can change behavior, such as `==` becoming `===`, so review what it changed.
44
+
45
+ ## Vitest projects
46
+
47
+ `@shivaedev/quality/vitest.ts` sets up the tests of a package by file name, so no test file sets its environment with a pragma. It needs `vitest`, and `happy-dom` for DOM tests. A package's `vitest.config.ts` reads:
48
+
49
+ ```ts
50
+ import { testProjects } from "@shivaedev/quality/vitest.ts";
51
+ import { defineConfig } from "vitest/config";
52
+
53
+ export default defineConfig({ test: testProjects() });
54
+ ```
55
+
56
+ | Project | Files | Environment | Runs |
57
+ | --- | --- | --- | --- |
58
+ | `unit` | `*.test.ts`, `*.spec.ts` and the other test and spec files | Node | By default |
59
+ | `dom` | `*.dom.test.tsx`, `*.dom.spec.tsx` and the other `.dom` files | happy-dom | By default |
60
+ | `slow` | `*.slow.test.ts`, `*.slow.spec.ts` and the other `.slow` files | Node | Only with `vitest run --project slow` |
61
+
62
+ Type tests (`*.typecheck.test.ts`, `*.typecheck.spec.ts` and `typecheck.test.ts`) are in no project: the compiler checks them. A test that is too slow for every run goes into the slow project instead of being skipped.
63
+
64
+ `testProjects()` takes no options. Every conventionally named suite runs in its project regardless of its folder; exclusion options are rejected.
65
+
66
+ ### Inherited tags
67
+
68
+ Vitest gives an inline project only the [tags](https://vitest.dev/guide/test-tags) it declares itself, never those of a config file it `extends`. A test tagged in that file then fails with `cannot apply "<tag>" tag for this test` as soon as a root config runs it. A root config that gathers the projects of several packages, or whose projects extend a shared base config, passes them through `inheritTags`:
69
+
70
+ ```ts
71
+ import { inheritTags } from "@shivaedev/quality/vitest.ts";
72
+ import { defineConfig } from "vitest/config";
73
+
74
+ const bakery = { extends: "./packages/bakery/vitest.config.ts", root: "./packages/bakery", test: { name: "bakery" } };
75
+
76
+ export default defineConfig(async () => ({ test: { projects: await inheritTags([bakery], import.meta.dirname) } }));
77
+ ```
78
+
79
+ `inheritTags(projects, root)` loads the config file of each inline project whose `extends` is a path, resolved against `root`, and adds the tags that file declares to the project's own, so `vitest run --tags-filter=<tag>` works across the workspace. A tag the project declares itself wins over an inherited one of the same name. Config objects and config functions are supported. A project that extends `true`, and a glob or file path, comes back unchanged. The extended files load with Node's own `import`, so each must be a module Node runs without a bundler.
80
+
81
+ ## tsconfig presets
82
+
83
+ Two presets supply a shared strict TypeScript setup for type-checking and package builds.
84
+
85
+ | Preset | Use |
86
+ | --- | --- |
87
+ | `@shivaedev/quality/tsconfig/base.json` | Type-checking with `noEmit`: applications, tests and scripts. |
88
+ | `@shivaedev/quality/tsconfig/package.json` | Building a package: the base plus `declaration`, `declarationMap`, `sourceMap` and `rewriteRelativeImportExtensions`, so relative `.ts` imports are emitted as `.js`. |
89
+
90
+ ```json
91
+ {
92
+ "extends": "@shivaedev/quality/tsconfig/base.json",
93
+ "compilerOptions": {
94
+ "lib": ["ESNext", "DOM"],
95
+ "types": ["node"]
96
+ },
97
+ "include": ["src"]
98
+ }
99
+ ```
100
+
101
+ The base sets:
102
+
103
+ - **Language:** `target` and `lib` are `ESNext`.
104
+ - **Modules:** `module` ESNext, `moduleResolution` bundler, `moduleDetection` force, `verbatimModuleSyntax`, `isolatedModules`, `allowImportingTsExtensions`, `resolveJsonModule`, `noUncheckedSideEffectImports`, `forceConsistentCasingInFileNames` and `libReplacement: false`.
105
+ - **JavaScript:** `allowJs` and `checkJs`, so JavaScript files are type-checked with the TypeScript ones.
106
+ - **Erasable syntax only:** `erasableSyntaxOnly` rejects syntax that type stripping cannot erase, such as parameter properties.
107
+ - **Checks:** `strict`, with `noImplicitAny`, `strictBuiltinIteratorReturn` and `useUnknownInCatchVariables` stated explicitly, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, `noImplicitOverride`, `noImplicitReturns`, `noFallthroughCasesInSwitch`, `noUnusedLocals`, `noUnusedParameters`, `allowUnreachableCode: false` and `allowUnusedLabels: false`.
108
+ - **Compiler settings:** `stableTypeOrdering` and `skipLibCheck`.
109
+
110
+ `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.
111
+
112
+ A package that type-checks its tests with one config and builds `src` with another extends both, the package preset last:
113
+
114
+ ```json
115
+ {
116
+ "extends": ["./tsconfig.json", "@shivaedev/quality/tsconfig/package.json"],
117
+ "compilerOptions": { "outDir": "dist", "rootDir": "src" },
118
+ "include": ["src"]
119
+ }
120
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/quality",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Repository quality gate with typed rules, a baseline of existing debt and a registry of reasoned exceptions",
5
5
  "homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/quality#readme",
6
6
  "bugs": {
@@ -32,7 +32,8 @@
32
32
  "./biome": "./biome/preset.json",
33
33
  "./tsconfig/base.json": "./tsconfig/base.json",
34
34
  "./tsconfig/package.json": "./tsconfig/package.json",
35
- "./package.json": "./package.json"
35
+ "./package.json": "./package.json",
36
+ "./rules/imports/bundleInputs.ts": null
36
37
  },
37
38
  "bin": {
38
39
  "quality": "./dist/cli.js"
@@ -45,13 +46,14 @@
45
46
  "!src/**/*.spec.ts",
46
47
  "!src/**/test-support",
47
48
  "tsconfig",
49
+ "docs",
48
50
  "CHANGELOG.md",
49
51
  "README.md"
50
52
  ],
51
53
  "dependencies": {
52
- "@biomejs/biome": "2.5.14",
54
+ "@biomejs/biome": "2.5.15",
53
55
  "@shivaedev/types": "0.2.0",
54
- "ignore": "7.0.6",
56
+ "ignore": "7.0.12",
55
57
  "sort-package-json": "4.0.0",
56
58
  "typescript": "npm:@typescript/typescript6@6.0.2"
57
59
  },
@@ -59,7 +61,7 @@
59
61
  "@effect/platform-node": "4.0.0-rc.112",
60
62
  "@effect/platform-node-shared": "4.0.0-rc.112",
61
63
  "@effect/vitest": "4.0.0-rc.112",
62
- "@types/node": "24.10.1",
64
+ "@types/node": "24.19.1",
63
65
  "@typescript/native": "npm:typescript@7.0.2",
64
66
  "effect": "4.0.0-rc.112",
65
67
  "vitest": "4.1.11"
@@ -0,0 +1,45 @@
1
+ import ts from "typescript";
2
+ import type { Syntax } from "./syntax.ts";
3
+
4
+ function importedFrom(node: ts.Node, module: string): boolean {
5
+ for (let current: ts.Node | undefined = node; current !== undefined; current = current.parent) {
6
+ if (ts.isImportDeclaration(current)) {
7
+ return !current.importClause?.isTypeOnly && ts.isStringLiteral(current.moduleSpecifier) && current.moduleSpecifier.text === module;
8
+ }
9
+ }
10
+ return false;
11
+ }
12
+
13
+ function effectNamespace(node: ts.Expression, checker: ts.TypeChecker): boolean {
14
+ if (!ts.isIdentifier(node)) {
15
+ return false;
16
+ }
17
+ return (checker.getSymbolAtLocation(node)?.declarations ?? []).some(
18
+ (declaration) =>
19
+ (ts.isImportSpecifier(declaration)
20
+ && !declaration.isTypeOnly
21
+ && (declaration.propertyName ?? declaration.name).text === "Effect"
22
+ && importedFrom(declaration, "effect"))
23
+ || (ts.isNamespaceImport(declaration) && importedFrom(declaration, "effect/Effect")),
24
+ );
25
+ }
26
+
27
+ export function nativeEffectCall(node: ts.Node, name: string, { checker }: Syntax): node is ts.CallExpression {
28
+ if (!ts.isCallExpression(node)) {
29
+ return false;
30
+ }
31
+ const callee = node.expression;
32
+ if (ts.isPropertyAccessExpression(callee)) {
33
+ return callee.name.text === name && effectNamespace(callee.expression, checker);
34
+ }
35
+ return (
36
+ ts.isIdentifier(callee)
37
+ && (checker.getSymbolAtLocation(callee)?.declarations ?? []).some(
38
+ (declaration) =>
39
+ ts.isImportSpecifier(declaration)
40
+ && !declaration.isTypeOnly
41
+ && (declaration.propertyName ?? declaration.name).text === name
42
+ && importedFrom(declaration, "effect/Effect"),
43
+ )
44
+ );
45
+ }
@@ -0,0 +1,67 @@
1
+ import { resolve } from "node:path";
2
+ import ts from "typescript";
3
+ import { nativeEffectCall } from "./nativeEffectCall.ts";
4
+ import type { Diagnostic } from "./report.ts";
5
+ import { nodeAt, offsetOf, type Syntax, syntaxOf } from "./syntax.ts";
6
+
7
+ const RECOGNIZED: ReadonlySet<string> = new Set(["lint/nursery/noComponentHookFactories", "lint/style/noDoneCallback"]);
8
+
9
+ function generatorParameter(node: ts.Node): boolean {
10
+ const parameter = node.parent;
11
+ const callback = parameter.parent;
12
+ return (
13
+ ts.isParameter(parameter)
14
+ && parameter.name === node
15
+ && ts.isFunctionExpression(callback)
16
+ && callback.asteriskToken !== undefined
17
+ && ts.isCallExpression(callback.parent)
18
+ && callback.parent.arguments.includes(callback)
19
+ );
20
+ }
21
+
22
+ function tagHandler(node: ts.Node, syntax: Syntax): boolean {
23
+ const property = node.parent;
24
+ if (!ts.isPropertyAssignment(property) || property.name !== node || !ts.isObjectLiteralExpression(property.parent)) {
25
+ return false;
26
+ }
27
+ const handlers = property.parent;
28
+ const call = handlers.parent;
29
+ return (
30
+ nativeEffectCall(call, "catchTags", syntax)
31
+ && call.arguments.includes(handlers)
32
+ && ts.isArrowFunction(property.initializer)
33
+ && nativeEffectCall(property.initializer.body, "fail", syntax)
34
+ );
35
+ }
36
+
37
+ function misclassified(diagnostic: Diagnostic, syntax: Syntax): boolean {
38
+ const { start, end } = diagnostic.location;
39
+ const from = start === undefined ? undefined : offsetOf(syntax.source, start);
40
+ const to = end === undefined ? undefined : offsetOf(syntax.source, end);
41
+ const node = from === undefined || to === undefined ? undefined : nodeAt(syntax.source, from, to);
42
+ if (node === undefined) {
43
+ return false;
44
+ }
45
+ switch (diagnostic.category) {
46
+ case "lint/style/noDoneCallback":
47
+ return generatorParameter(node);
48
+ case "lint/nursery/noComponentHookFactories":
49
+ return tagHandler(node, syntax);
50
+ default:
51
+ return false;
52
+ }
53
+ }
54
+
55
+ export function recognizeDiagnostics(root: string, diagnostics: readonly Diagnostic[]): readonly Diagnostic[] {
56
+ const sources = new Map<string, Syntax>();
57
+ return diagnostics.filter((diagnostic) => {
58
+ const path = diagnostic.location.path;
59
+ if (!RECOGNIZED.has(diagnostic.category ?? "") || path === undefined) {
60
+ return true;
61
+ }
62
+ const file = resolve(root, path);
63
+ const syntax = sources.get(file) ?? syntaxOf(file);
64
+ sources.set(file, syntax);
65
+ return !misclassified(diagnostic, syntax);
66
+ });
67
+ }