@hailstails/hone 1.5.0 → 2.0.0-pre.1

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 (608) hide show
  1. package/ADOPTING.md +237 -166
  2. package/CHANGELOG.md +127 -0
  3. package/MIGRATING.md +130 -47
  4. package/README.md +148 -182
  5. package/chunks/chunk-5HRMJ4O2.js +608 -0
  6. package/chunks/chunk-5U4JMWNV.js +9 -0
  7. package/chunks/{chunk-2O46EB4E.js → chunk-ASUN4AVC.js} +25 -12
  8. package/chunks/chunk-DGOLOS5A.js +9 -0
  9. package/chunks/{chunk-HJA4CX7C.js → chunk-FBZBSDED.js} +1 -1
  10. package/chunks/{chunk-Y2KPZDDV.js → chunk-GNOMK7CR.js} +201 -98
  11. package/chunks/chunk-IX2VZTBO.js +887 -0
  12. package/chunks/{chunk-QWA6OVLC.js → chunk-K2W3D3NB.js} +8 -2
  13. package/chunks/chunk-L7BGRC6D.js +22 -0
  14. package/chunks/chunk-M6SOGWT7.js +82 -0
  15. package/chunks/chunk-MWLBA4B3.js +849 -0
  16. package/chunks/chunk-NRIQD3PI.js +38 -0
  17. package/chunks/chunk-OKLYWD2Z.js +823 -0
  18. package/chunks/{chunk-3HFJHJDO.js → chunk-QP5TLOBY.js} +17 -8
  19. package/chunks/chunk-R75QELTA.js +481 -0
  20. package/chunks/chunk-RANAKCTW.js +31 -0
  21. package/chunks/{chunk-NA5L6PUE.js → chunk-RANIXNWY.js} +1 -2
  22. package/chunks/chunk-RFR3ITBS.js +9 -0
  23. package/chunks/{chunk-Z4UBS7WI.js → chunk-RGSHTPLA.js} +26 -7
  24. package/chunks/{chunk-T32FOWZA.js → chunk-TNY2PASL.js} +14 -18
  25. package/chunks/{chunk-Y4SMWOD2.js → chunk-UJONWHA4.js} +2 -2
  26. package/chunks/{chunk-WF3PPYRR.js → chunk-VYBO2Q65.js} +4 -2
  27. package/chunks/chunk-Z6JHBNDS.js +15 -0
  28. package/chunks/eslint-10-boundary-A4JIQ734.js +14 -0
  29. package/chunks/eslint-9-boundary-CL5DDBHX.js +34 -0
  30. package/docs/adding-a-discipline-or-mechanism.md +21 -19
  31. package/docs/extending.md +5 -5
  32. package/docs/output-contract.md +700 -14
  33. package/docs/why-chain-contract.md +6 -6
  34. package/methods/README.md +2 -2
  35. package/methods/assessment-template.md +1 -1
  36. package/methods/lenses/clean-architecture.md +19 -54
  37. package/methods/lenses/decomposition.md +7 -7
  38. package/methods/lenses/defended-on-intent.md +4 -4
  39. package/methods/lenses/di-discipline.md +8 -8
  40. package/methods/lenses/errors-as-data.md +6 -6
  41. package/methods/lenses/function-first.md +9 -9
  42. package/methods/lenses/naming.md +6 -6
  43. package/methods/lenses/test-discipline.md +8 -8
  44. package/methods/lenses/type-soundness.md +6 -6
  45. package/methods/lenses/zod-boundary.md +9 -9
  46. package/package.json +30 -28
  47. package/rules/README.md +268 -4
  48. package/rules/SPIRIT.md +1 -1
  49. package/rules/cases/a-value-is-one-of-several-kinds-or-states.md +20 -0
  50. package/rules/cases/an-adopter-is-not-handed-our-risk.md +17 -0
  51. package/rules/cases/an-operation-can-fail.md +20 -0
  52. package/rules/cases/builds-the-real-implementations.md +25 -0
  53. package/rules/cases/causes-an-effect.md +26 -0
  54. package/rules/cases/checks-a-value-that-may-be-one-of-several-outcomes.md +20 -0
  55. package/rules/cases/checks-conditions-before-its-work.md +20 -0
  56. package/rules/cases/coordinates-other-units.md +20 -0
  57. package/rules/cases/does-one-job.md +23 -0
  58. package/rules/cases/explains-something-in-prose.md +20 -0
  59. package/rules/cases/gives-a-value-its-type.md +26 -0
  60. package/rules/cases/gives-each-unit-its-test.md +20 -0
  61. package/rules/cases/keeps-state-or-settings-across-calls.md +20 -0
  62. package/rules/cases/makes-a-new-value-from-what-it-has.md +17 -0
  63. package/rules/cases/names-something.md +20 -0
  64. package/rules/cases/needs-the-current-time-a-random-value-a-new-id-or-an-outside-ordering.md +26 -0
  65. package/rules/cases/puts-code-in-a-file-or-folder.md +20 -0
  66. package/rules/cases/reads-data-from-outside.md +23 -0
  67. package/rules/cases/reuses-behaviour-from-another-unit-or-type.md +20 -0
  68. package/rules/cases/sends-data-out-of-the-program.md +20 -0
  69. package/rules/cases/sets-how-strictly-the-checker-works.md +14 -0
  70. package/rules/cases/ships-code-for-others.md +17 -0
  71. package/rules/cases/states-what-the-unit-gives-back-for-one-case-or-several.md +20 -0
  72. package/rules/cases/takes-an-outside-dependency.md +38 -0
  73. package/rules/cases/tests-across-units-or-against-a-real-system.md +20 -0
  74. package/rules/cases/uses-a-system-or-service-outside-the-program.md +29 -0
  75. package/rules/cases/uses-what-a-collaborator-gives-back.md +20 -0
  76. package/rules/cases/writes-basic-logic.md +17 -0
  77. package/rules/cases.md +36 -59
  78. package/rules/numbers.md +121 -121
  79. package/rules/principles/external-behaviour-sits-at-a-boundary.md +12 -0
  80. package/rules/principles/no-hidden-effects.md +17 -0
  81. package/rules/principles/no-leak-across-a-boundary.md +19 -0
  82. package/rules/principles/one-place-decides.md +12 -0
  83. package/rules/principles/our-code-reads-in-the-common-language.md +12 -0
  84. package/rules/principles/outside-risk-is-carried-on-purpose.md +13 -0
  85. package/rules/principles/tests-are-ours.md +12 -0
  86. package/rules/principles/the-type-checker-proves-it.md +12 -0
  87. package/rules/principles.md +50 -46
  88. package/rules/record-kinds/authorised-location.md +26 -0
  89. package/rules/record-kinds/boundary-record.md +9 -0
  90. package/rules/record-kinds/debt.md +23 -0
  91. package/rules/record-kinds/dependency-record.md +9 -0
  92. package/rules/record-kinds/deviation.md +9 -0
  93. package/rules/records.md +17 -30
  94. package/rules/rules/declared-not-asserted.md +16 -0
  95. package/rules/rules/doer-or-orchestrator.md +16 -0
  96. package/rules/rules/failures-are-values.md +15 -0
  97. package/rules/rules/fixed-versions.md +11 -0
  98. package/rules/rules/guard-first.md +14 -0
  99. package/rules/rules/handed-what-it-uses.md +16 -0
  100. package/rules/rules/kinds-are-named.md +16 -0
  101. package/rules/rules/one-reason-per-module.md +18 -0
  102. package/rules/rules/one-word-everywhere.md +19 -0
  103. package/rules/rules/outside-dependencies-justified.md +14 -0
  104. package/rules/rules/outside-dependencies-stay-at-boundaries.md +18 -0
  105. package/rules/rules/ports-declared-inside.md +22 -0
  106. package/rules/rules/shipped-risk-declared.md +11 -0
  107. package/rules/rules/straight-through-tests.md +15 -0
  108. package/rules/rules/tested-where-its-owned.md +20 -0
  109. package/rules/rules/tools-live-in-the-repo.md +11 -0
  110. package/rules/rules/upstream-stays-untouched.md +11 -0
  111. package/rules/rules/written-out-answers.md +17 -0
  112. package/rules/rules.md +117 -81
  113. package/rules/typescript/checks.md +1668 -202
  114. package/rules/typescript/recipes/adapter-per-outside-party.md +18 -0
  115. package/rules/typescript/recipes/assert-to-narrow.md +18 -0
  116. package/rules/typescript/recipes/bounded-context-generic.md +19 -0
  117. package/rules/typescript/recipes/closure-factory.md +20 -0
  118. package/rules/typescript/recipes/companion-test-file.md +18 -0
  119. package/rules/typescript/recipes/composed-orchestrator.md +18 -0
  120. package/rules/typescript/recipes/composition-root.md +18 -0
  121. package/rules/typescript/recipes/copy-never-write-in.md +18 -0
  122. package/rules/typescript/recipes/declared-not-bundled.md +17 -0
  123. package/rules/typescript/recipes/dependency-record.md +20 -0
  124. package/rules/typescript/recipes/domain-vocabulary-list.md +18 -0
  125. package/rules/typescript/recipes/entity-module.md +20 -0
  126. package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +18 -0
  127. package/rules/typescript/recipes/extension-outside-the-vendored-code.md +18 -0
  128. package/rules/typescript/recipes/failure-asserted-as-a-value.md +18 -0
  129. package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +20 -0
  130. package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +18 -0
  131. package/rules/typescript/recipes/functional-iteration.md +18 -0
  132. package/rules/typescript/recipes/guard-clauses.md +18 -0
  133. package/rules/typescript/recipes/integration-test-owns-its-scratch.md +18 -0
  134. package/rules/typescript/recipes/integration-test-suffix.md +18 -0
  135. package/rules/typescript/recipes/iteach-over-typed-rows.md +18 -0
  136. package/rules/typescript/recipes/map-out-at-the-adapter.md +18 -0
  137. package/rules/typescript/recipes/meaning-in-names-not-comments.md +22 -0
  138. package/rules/typescript/recipes/named-exported-type.md +18 -0
  139. package/rules/typescript/recipes/narrow-ports.md +18 -0
  140. package/rules/typescript/recipes/one-argument-object.md +19 -0
  141. package/rules/typescript/recipes/port-in-the-domain.md +19 -0
  142. package/rules/typescript/recipes/ports-in-the-argument.md +18 -0
  143. package/rules/typescript/recipes/repo-scripts-only.md +18 -0
  144. package/rules/typescript/recipes/result-union.md +22 -0
  145. package/rules/typescript/recipes/screaming-folders.md +20 -0
  146. package/rules/typescript/recipes/shared-strict-base-config.md +20 -0
  147. package/rules/typescript/recipes/stub-with-vifn.md +20 -0
  148. package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +18 -0
  149. package/rules/typescript/recipes/whole-words.md +18 -0
  150. package/rules/typescript/recipes/whole-written-out-expectation.md +18 -0
  151. package/rules/typescript/recipes/world-values-through-a-port.md +18 -0
  152. package/rules/typescript/recipes/zod-at-the-producers-adapter.md +19 -0
  153. package/rules/typescript/recipes.md +247 -218
  154. package/rules/typescript/symptoms/absence-standing-for-a-state.md +36 -0
  155. package/rules/typescript/symptoms/adapter-built-outside-the-root.md +30 -0
  156. package/rules/typescript/symptoms/ambient-randomness.md +36 -0
  157. package/rules/typescript/symptoms/answer-set-in-a-hook.md +45 -0
  158. package/rules/typescript/symptoms/authored-class-or-this/class-keyword.md +30 -0
  159. package/rules/typescript/symptoms/authored-class-or-this/static-members-only.md +18 -0
  160. package/rules/typescript/symptoms/authored-class-or-this.md +49 -0
  161. package/rules/typescript/symptoms/behaviour-tested-away-from-its-owner.md +44 -0
  162. package/rules/typescript/symptoms/boolean-in-a-signature/boolean-annotation.md +30 -0
  163. package/rules/typescript/symptoms/boolean-in-a-signature.md +43 -0
  164. package/rules/typescript/symptoms/branch-in-a-test/test-body.md +213 -0
  165. package/rules/typescript/symptoms/branch-in-a-test.md +48 -0
  166. package/rules/typescript/symptoms/bundled-dependency.md +28 -0
  167. package/rules/typescript/symptoms/catch-all-failure-kind.md +37 -0
  168. package/rules/typescript/symptoms/change-spread-across-modules.md +27 -0
  169. package/rules/typescript/symptoms/claimed-type/cast-to-any.md +29 -0
  170. package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +34 -0
  171. package/rules/typescript/symptoms/claimed-type/unlisted-cast-site.md +34 -0
  172. package/rules/typescript/symptoms/claimed-type.md +56 -0
  173. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +144 -0
  174. package/rules/typescript/symptoms/computed-value-in-a-test.md +36 -0
  175. package/rules/typescript/symptoms/coverage-gate.md +27 -0
  176. package/rules/typescript/symptoms/date-used-directly/clock-sources.md +31 -0
  177. package/rules/typescript/symptoms/date-used-directly.md +46 -0
  178. package/rules/typescript/symptoms/default-for-a-required-value.md +45 -0
  179. package/rules/typescript/symptoms/default-on-a-closed-union/default-arm.md +32 -0
  180. package/rules/typescript/symptoms/default-on-a-closed-union.md +32 -0
  181. package/rules/typescript/symptoms/dependency-without-a-record.md +33 -0
  182. package/rules/typescript/symptoms/doer-calling-our-own-unit.md +36 -0
  183. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +32 -0
  184. package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +31 -0
  185. package/rules/typescript/symptoms/double-with-a-body.md +55 -0
  186. package/rules/typescript/symptoms/drawer-path/drawer-names.md +28 -0
  187. package/rules/typescript/symptoms/drawer-path.md +32 -0
  188. package/rules/typescript/symptoms/duplicate-decision.md +36 -0
  189. package/rules/typescript/symptoms/edit-inside-vendored-code.md +33 -0
  190. package/rules/typescript/symptoms/failure-shaped-as-success.md +28 -0
  191. package/rules/typescript/symptoms/floating-version.md +27 -0
  192. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +30 -0
  193. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess.md +33 -0
  194. package/rules/typescript/symptoms/inner-layer-imports-outer.md +33 -0
  195. package/rules/typescript/symptoms/integration-heavy-suite.md +29 -0
  196. package/rules/typescript/symptoms/large-input-for-a-few-fields.md +37 -0
  197. package/rules/typescript/symptoms/library-class-built-in-place.md +42 -0
  198. package/rules/typescript/symptoms/long-function/function-length.md +47 -0
  199. package/rules/typescript/symptoms/long-function.md +75 -0
  200. package/rules/typescript/symptoms/loop-keyword/loop-statement.md +34 -0
  201. package/rules/typescript/symptoms/loop-keyword.md +49 -0
  202. package/rules/typescript/symptoms/machine-touched-in-a-unit-test.md +40 -0
  203. package/rules/typescript/symptoms/many-spellings-of-one-concept.md +29 -0
  204. package/rules/typescript/symptoms/module-level-state.md +30 -0
  205. package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +29 -0
  206. package/rules/typescript/symptoms/module-or-global-patched.md +38 -0
  207. package/rules/typescript/symptoms/name-off-its-casing/filename-case.md +16 -0
  208. package/rules/typescript/symptoms/name-off-its-casing/naming-convention.md +20 -0
  209. package/rules/typescript/symptoms/name-off-its-casing.md +31 -0
  210. package/rules/typescript/symptoms/no-lock-file.md +27 -0
  211. package/rules/typescript/symptoms/orchestrator-that-computes.md +27 -0
  212. package/rules/typescript/symptoms/outside-dependency-vocabulary-for-basic-logic.md +33 -0
  213. package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +44 -0
  214. package/rules/typescript/symptoms/outside-import-past-a-boundary.md +45 -0
  215. package/rules/typescript/symptoms/outside-type-in-a-signature.md +37 -0
  216. package/rules/typescript/symptoms/own-type-guard.md +36 -0
  217. package/rules/typescript/symptoms/port-named-for-a-mechanism.md +34 -0
  218. package/rules/typescript/symptoms/port-outside-the-domain.md +28 -0
  219. package/rules/typescript/symptoms/positional-parameters/parameter-count.md +30 -0
  220. package/rules/typescript/symptoms/positional-parameters.md +43 -0
  221. package/rules/typescript/symptoms/process-global-used-in-place.md +53 -0
  222. package/rules/typescript/symptoms/prose-in-code.md +27 -0
  223. package/rules/typescript/symptoms/rebinding/parameter-reassignment.md +18 -0
  224. package/rules/typescript/symptoms/rebinding/test-body.md +32 -0
  225. package/rules/typescript/symptoms/rebinding.md +36 -0
  226. package/rules/typescript/symptoms/schema-past-its-adapter.md +41 -0
  227. package/rules/typescript/symptoms/shorthand-name/identifier-names.md +29 -0
  228. package/rules/typescript/symptoms/shorthand-name.md +32 -0
  229. package/rules/typescript/symptoms/strictness-weakened/exact-optional-property-types.md +51 -0
  230. package/rules/typescript/symptoms/strictness-weakened/no-fallthrough-cases-in-switch.md +51 -0
  231. package/rules/typescript/symptoms/strictness-weakened/no-implicit-override.md +51 -0
  232. package/rules/typescript/symptoms/strictness-weakened/no-property-access-from-index-signature.md +51 -0
  233. package/rules/{CD-3/CHECKS.md → typescript/symptoms/strictness-weakened/no-unchecked-indexed-access.md} +23 -40
  234. package/rules/typescript/symptoms/strictness-weakened/strict.md +51 -0
  235. package/rules/typescript/symptoms/strictness-weakened/use-unknown-in-catch-variables.md +51 -0
  236. package/rules/typescript/symptoms/strictness-weakened.md +32 -0
  237. package/rules/typescript/symptoms/tangled-function/cognitive-complexity.md +42 -0
  238. package/rules/typescript/symptoms/tangled-function.md +75 -0
  239. package/rules/typescript/symptoms/test-of-the-type-checker.md +24 -0
  240. package/rules/typescript/symptoms/test-switched-off/focused-tests.md +15 -0
  241. package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +15 -0
  242. package/rules/typescript/symptoms/test-switched-off.md +25 -0
  243. package/rules/typescript/symptoms/text-past-its-reader/test-body.md +30 -0
  244. package/rules/typescript/symptoms/text-past-its-reader.md +71 -0
  245. package/rules/typescript/symptoms/throw-between-our-units.md +46 -0
  246. package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +32 -0
  247. package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +39 -0
  248. package/rules/typescript/symptoms/throw-or-catch-in-a-test.md +35 -0
  249. package/rules/typescript/symptoms/thrown-non-error/throw-only-error.md +15 -0
  250. package/rules/typescript/symptoms/thrown-non-error.md +27 -0
  251. package/rules/typescript/symptoms/tool-fetched-at-run-time.md +27 -0
  252. package/rules/typescript/symptoms/tuple-as-data.md +29 -0
  253. package/rules/typescript/symptoms/type-derived-from-code/factory-return-types.md +29 -0
  254. package/rules/typescript/symptoms/type-derived-from-code.md +41 -0
  255. package/rules/typescript/symptoms/types-only-file.md +36 -0
  256. package/rules/typescript/symptoms/unasserted-call.md +29 -0
  257. package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +28 -0
  258. package/rules/typescript/symptoms/unit-without-a-running-test.md +28 -0
  259. package/rules/{CD-5/CHECKS.md → typescript/symptoms/untracked-escape/directive-pointers.md} +12 -25
  260. package/rules/typescript/symptoms/untracked-escape.md +32 -0
  261. package/rules/typescript/symptoms/untyped-value/explicit-any.md +14 -0
  262. package/rules/typescript/symptoms/untyped-value/implicit-any-let.md +14 -0
  263. package/rules/typescript/symptoms/untyped-value.md +36 -0
  264. package/rules/typescript/symptoms/wide-input.md +37 -0
  265. package/rules/typescript/symptoms/wide-port.md +32 -0
  266. package/rules/typescript/symptoms/work-inside-a-condition/else-after-an-exit.md +40 -0
  267. package/rules/typescript/symptoms/work-inside-a-condition.md +41 -0
  268. package/rules/typescript/symptoms/write-into-a-parameter/parameter-mutation.md +33 -0
  269. package/rules/typescript/symptoms/write-into-a-parameter.md +34 -0
  270. package/rules/typescript/symptoms.md +623 -414
  271. package/{core → src/application}/conformance/conformance-testing-types.d.ts +16 -6
  272. package/src/audit.d.ts +20 -0
  273. package/{api → src}/audit.js +6 -5
  274. package/{core/rule-set-reader → src/domain/rule-set}/authored-rule-set-types.d.ts +2 -2
  275. package/{core/values → src/domain/rule-set}/edition-types.d.ts +3 -3
  276. package/{core/values → src/domain/rule-set}/identifier-types.d.ts +2 -2
  277. package/{core/conformance → src/domain/runner}/conformance-types.d.ts +1 -1
  278. package/{core/mechanism-port → src/domain/runner}/piece-failure-types.d.ts +1 -1
  279. package/{core/mechanism-port → src/domain/runner}/runner-module-types.d.ts +4 -4
  280. package/src/domain/runner/runner-result-types.d.ts +88 -0
  281. package/src/eslint-plugin.d.ts +16 -0
  282. package/src/eslint-plugin.js +72 -0
  283. package/src/hone.js +13385 -0
  284. package/src/infrastructure/disciplines-file/version-one-names.json +634 -0
  285. package/src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/class-keyword.examples.json +84 -0
  286. package/{mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js → src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/eslint-plugin.js} +9 -10
  287. package/src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/piece.json +12 -0
  288. package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +24 -0
  289. package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/static-members-only.examples.json +36 -0
  290. package/src/infrastructure/engines/eslint/claimed-type/non-null-assertions/eslint-plugin.js +16 -0
  291. package/src/infrastructure/engines/eslint/claimed-type/non-null-assertions/non-null-assertions.examples.json +48 -0
  292. package/src/infrastructure/engines/eslint/claimed-type/non-null-assertions/piece.json +22 -0
  293. package/src/infrastructure/engines/eslint/long-function/function-length/function-length.examples.json +42 -0
  294. package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +16 -0
  295. package/{mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js → src/infrastructure/engines/eslint/name-off-its-casing/filename-case/eslint-plugin.js} +5 -4
  296. package/src/infrastructure/engines/eslint/name-off-its-casing/filename-case/filename-case.examples.json +60 -0
  297. package/src/infrastructure/engines/eslint/name-off-its-casing/filename-case/piece.json +11 -0
  298. package/src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/eslint-plugin.js +16 -0
  299. package/src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/naming-convention.examples.json +78 -0
  300. package/src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/piece.json +214 -0
  301. package/src/infrastructure/engines/eslint/positional-parameters/parameter-count/eslint-plugin.js +16 -0
  302. package/src/infrastructure/engines/eslint/positional-parameters/parameter-count/parameter-count.examples.json +30 -0
  303. package/src/infrastructure/engines/eslint/positional-parameters/parameter-count/piece.json +18 -0
  304. package/src/infrastructure/engines/eslint/rebinding/parameter-reassignment/eslint-plugin.js +16 -0
  305. package/src/infrastructure/engines/eslint/rebinding/parameter-reassignment/parameter-reassignment.examples.json +30 -0
  306. package/src/infrastructure/engines/eslint/rebinding/parameter-reassignment/piece.json +17 -0
  307. package/{mechanisms → src/infrastructure/engines}/eslint/runner/README.md +5 -5
  308. package/{mechanisms/eslint/runner → src/infrastructure/engines/eslint/runner/pieces}/eslint-piece-settings-types.d.ts +1 -1
  309. package/{mechanisms → src/infrastructure/engines}/eslint/runner/runner.js +2186 -1372
  310. package/{mechanisms/eslint/CD-41 → src/infrastructure/engines/eslint/tangled-function/cognitive-complexity}/README.md +1 -1
  311. package/src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/cognitive-complexity.examples.json +48 -0
  312. package/{mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js → src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/eslint-plugin.js} +58 -14
  313. package/src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/piece.json +12 -0
  314. package/{mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js → src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js} +5 -4
  315. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/focused-tests.examples.json +60 -0
  316. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/piece.json +12 -0
  317. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +16 -0
  318. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +54 -0
  319. package/{mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js → src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/eslint-plugin.js} +5 -4
  320. package/src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/piece.json +12 -0
  321. package/src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/throw-only-error.examples.json +54 -0
  322. package/{mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js → src/infrastructure/engines/eslint/untyped-value/explicit-any/eslint-plugin.js} +14 -9
  323. package/src/infrastructure/engines/eslint/untyped-value/explicit-any/explicit-any.examples.json +36 -0
  324. package/src/infrastructure/engines/eslint/untyped-value/explicit-any/piece.json +12 -0
  325. package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/implicit-any-let.examples.json +48 -0
  326. package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +16 -0
  327. package/src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/else-after-an-exit.examples.json +36 -0
  328. package/{mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js → src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/eslint-plugin.js} +29 -13
  329. package/src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/piece.json +12 -0
  330. package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-keyword.examples.json +84 -0
  331. package/{mechanisms/audit/CD-14 → src/infrastructure/engines/walker/authored-class-or-this/class-keyword}/class-syntax.js +6 -3
  332. package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/piece.json +10 -0
  333. package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-annotation.examples.json +42 -0
  334. package/{mechanisms/audit/CD-43 → src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation}/boolean-signatures.js +14 -6
  335. package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/piece.json +9 -0
  336. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/piece.json +95 -0
  337. package/{mechanisms/audit/CD-27 → src/infrastructure/engines/walker/branch-in-a-test/test-body}/test-body-logic.js +183 -54
  338. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body.examples.json +280 -0
  339. package/{mechanisms/audit/CD-1 → src/infrastructure/engines/walker/claimed-type/cast-to-any}/any-cast.js +7 -4
  340. package/src/infrastructure/engines/walker/claimed-type/cast-to-any/cast-to-any.examples.json +48 -0
  341. package/src/infrastructure/engines/walker/claimed-type/cast-to-any/piece.json +9 -0
  342. package/{mechanisms/audit/CD-2 → src/infrastructure/engines/walker/claimed-type/unlisted-cast-site}/cast-expressions.js +13 -6
  343. package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/piece.json +14 -0
  344. package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/unlisted-cast-site.examples.json +54 -0
  345. package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +18 -0
  346. package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.examples.json +30 -0
  347. package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +36 -0
  348. package/src/infrastructure/engines/walker/date-used-directly/clock-sources/piece.json +9 -0
  349. package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/default-arm.examples.json +36 -0
  350. package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/piece.json +9 -0
  351. package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +54 -0
  352. package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +18 -0
  353. package/{mechanisms/audit/CD-25 → src/infrastructure/engines/walker/double-with-a-body/stub-implementation}/dependency-isolation.js +8 -4
  354. package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/piece.json +9 -0
  355. package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/stub-implementation.examples.json +36 -0
  356. package/{mechanisms/audit/CD-7 → src/infrastructure/engines/walker/drawer-path/drawer-names}/categorical-paths.js +23 -8
  357. package/src/infrastructure/engines/walker/drawer-path/drawer-names/drawer-names.examples.json +42 -0
  358. package/src/infrastructure/engines/walker/drawer-path/drawer-names/piece.json +9 -0
  359. package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/git-spawn-environment.examples.json +36 -0
  360. package/{mechanisms/audit/CD-47 → src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment}/hermetic-git-spawns.js +13 -4
  361. package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/piece.json +9 -0
  362. package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loop-statement.examples.json +48 -0
  363. package/{mechanisms/audit/CD-15 → src/infrastructure/engines/walker/loop-keyword/loop-statement}/loops.js +12 -4
  364. package/src/infrastructure/engines/walker/loop-keyword/loop-statement/piece.json +9 -0
  365. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +36 -0
  366. package/{mechanisms/audit/CD-26 → src/infrastructure/engines/walker/module-or-global-patched/module-mock-call}/module-mocking.js +8 -4
  367. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +9 -0
  368. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +133 -0
  369. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-or-require.examples.json +42 -0
  370. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +14 -0
  371. package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +18 -0
  372. package/{mechanisms/audit/runner → src/infrastructure/engines/walker/runner/pieces}/walker-piece.d.ts +8 -14
  373. package/{mechanisms/audit → src/infrastructure/engines/walker}/runner/runner.js +191 -120
  374. package/{mechanisms/audit/runner → src/infrastructure/engines/walker/runner/toolchain}/typescript-parse.d.ts +1 -0
  375. package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.examples.json +42 -0
  376. package/{mechanisms/audit/CD-6 → src/infrastructure/engines/walker/shorthand-name/identifier-names}/identifier-names.js +32 -15
  377. package/src/infrastructure/engines/walker/shorthand-name/identifier-names/piece.json +9 -0
  378. package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/exact-optional-property-types.examples.json +71 -0
  379. package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +17 -0
  380. package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/no-fallthrough-cases-in-switch.examples.json +71 -0
  381. package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +17 -0
  382. package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/no-implicit-override.examples.json +71 -0
  383. package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +17 -0
  384. package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/no-property-access-from-index-signature.examples.json +71 -0
  385. package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +17 -0
  386. package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/no-unchecked-indexed-access.examples.json +71 -0
  387. package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +17 -0
  388. package/{mechanisms/audit/CD-3 → src/infrastructure/engines/walker/strictness-weakened/strict}/compiler-overrides.js +102 -38
  389. package/src/infrastructure/engines/walker/strictness-weakened/strict/piece.json +13 -0
  390. package/src/infrastructure/engines/walker/strictness-weakened/strict/strict.examples.json +64 -0
  391. package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +17 -0
  392. package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/use-unknown-in-catch-variables.examples.json +71 -0
  393. package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +18 -0
  394. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/piece.json +9 -0
  395. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +36 -0
  396. package/{mechanisms/audit/CD-10 → src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement}/throws-in-tests.js +6 -3
  397. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +18 -0
  398. package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.examples.json +36 -0
  399. package/{mechanisms/audit/CD-7a → src/infrastructure/engines/walker/type-derived-from-code/factory-return-types}/factory-return-types.js +5 -3
  400. package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/piece.json +9 -0
  401. package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/companion-test-file.examples.json +36 -0
  402. package/{mechanisms/audit/CD-23 → src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file}/export-test-sibling.js +7 -4
  403. package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/piece.json +9 -0
  404. package/{mechanisms/audit/CD-5 → src/infrastructure/engines/walker/untracked-escape/directive-pointers}/comments-directives.js +40 -19
  405. package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/directive-pointers.examples.json +96 -0
  406. package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/piece.json +16 -0
  407. package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.examples.json +42 -0
  408. package/{mechanisms/audit/CD-44 → src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation}/parameter-mutation.js +22 -7
  409. package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/piece.json +9 -0
  410. package/src/rule-set.d.ts +4 -0
  411. package/src/testing.d.ts +7 -0
  412. package/src/testing.js +524 -0
  413. package/api/audit.d.ts +0 -20
  414. package/api/rule-set.d.ts +0 -4
  415. package/api/testing.d.ts +0 -5
  416. package/api/testing.js +0 -238
  417. package/chunks/chunk-335ITLPO.js +0 -7
  418. package/chunks/chunk-5U4VTFD5.js +0 -1949
  419. package/chunks/chunk-E6VR3VRV.js +0 -268
  420. package/chunks/chunk-FR4FASVM.js +0 -108
  421. package/chunks/chunk-LDQUT742.js +0 -15
  422. package/chunks/chunk-MXSIQPCV.js +0 -13
  423. package/chunks/chunk-RWQ4UNKY.js +0 -24
  424. package/core/check/tool-command.js +0 -2909
  425. package/core/mechanism-port/runner-result-types.d.ts +0 -19
  426. package/mechanisms/audit/CD-1/piece.json +0 -13
  427. package/mechanisms/audit/CD-10/piece.json +0 -13
  428. package/mechanisms/audit/CD-14/piece.json +0 -13
  429. package/mechanisms/audit/CD-15/piece.json +0 -13
  430. package/mechanisms/audit/CD-17/clock-sources.js +0 -28
  431. package/mechanisms/audit/CD-17/piece.json +0 -13
  432. package/mechanisms/audit/CD-19/import-boundaries.js +0 -99
  433. package/mechanisms/audit/CD-19/piece.json +0 -18
  434. package/mechanisms/audit/CD-2/piece.json +0 -18
  435. package/mechanisms/audit/CD-23/piece.json +0 -13
  436. package/mechanisms/audit/CD-25/piece.json +0 -13
  437. package/mechanisms/audit/CD-26/piece.json +0 -13
  438. package/mechanisms/audit/CD-27/piece.json +0 -17
  439. package/mechanisms/audit/CD-3/piece.json +0 -77
  440. package/mechanisms/audit/CD-43/piece.json +0 -13
  441. package/mechanisms/audit/CD-44/piece.json +0 -13
  442. package/mechanisms/audit/CD-47/piece.json +0 -13
  443. package/mechanisms/audit/CD-5/piece.json +0 -20
  444. package/mechanisms/audit/CD-6/piece.json +0 -13
  445. package/mechanisms/audit/CD-7/piece.json +0 -13
  446. package/mechanisms/audit/CD-7a/piece.json +0 -13
  447. package/mechanisms/audit/CD-8/piece.json +0 -13
  448. package/mechanisms/audit/CD-8/switch-defaults.js +0 -42
  449. package/mechanisms/eslint/CD-1/piece.json +0 -23
  450. package/mechanisms/eslint/CD-10/piece.json +0 -15
  451. package/mechanisms/eslint/CD-14/piece.json +0 -31
  452. package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +0 -15
  453. package/mechanisms/eslint/CD-2/piece.json +0 -25
  454. package/mechanisms/eslint/CD-27/piece.json +0 -23
  455. package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +0 -15
  456. package/mechanisms/eslint/CD-40/piece.json +0 -21
  457. package/mechanisms/eslint/CD-41/piece.json +0 -23
  458. package/mechanisms/eslint/CD-42/piece.json +0 -15
  459. package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +0 -15
  460. package/mechanisms/eslint/CD-44/piece.json +0 -20
  461. package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +0 -15
  462. package/mechanisms/eslint/CD-6/piece.json +0 -217
  463. package/mechanisms/eslint/CD-7/piece.json +0 -15
  464. package/rules/CD-1/CHECKS.md +0 -41
  465. package/rules/CD-1/README.md +0 -15
  466. package/rules/CD-1/discipline.json +0 -195
  467. package/rules/CD-10/CHECKS.md +0 -51
  468. package/rules/CD-10/README.md +0 -15
  469. package/rules/CD-10/discipline.json +0 -133
  470. package/rules/CD-11/CHECKS.md +0 -15
  471. package/rules/CD-11/README.md +0 -15
  472. package/rules/CD-11/discipline.json +0 -12
  473. package/rules/CD-12/CHECKS.md +0 -15
  474. package/rules/CD-12/README.md +0 -15
  475. package/rules/CD-12/discipline.json +0 -12
  476. package/rules/CD-13/CHECKS.md +0 -15
  477. package/rules/CD-13/README.md +0 -15
  478. package/rules/CD-13/discipline.json +0 -12
  479. package/rules/CD-14/CHECKS.md +0 -51
  480. package/rules/CD-14/README.md +0 -15
  481. package/rules/CD-14/discipline.json +0 -173
  482. package/rules/CD-15/CHECKS.md +0 -44
  483. package/rules/CD-15/README.md +0 -15
  484. package/rules/CD-15/discipline.json +0 -73
  485. package/rules/CD-16/CHECKS.md +0 -9
  486. package/rules/CD-16/README.md +0 -15
  487. package/rules/CD-17/CHECKS.md +0 -39
  488. package/rules/CD-17/README.md +0 -15
  489. package/rules/CD-17/discipline.json +0 -51
  490. package/rules/CD-18/CHECKS.md +0 -15
  491. package/rules/CD-18/README.md +0 -15
  492. package/rules/CD-18/discipline.json +0 -12
  493. package/rules/CD-19/CHECKS.md +0 -51
  494. package/rules/CD-19/README.md +0 -15
  495. package/rules/CD-19/discipline.json +0 -63
  496. package/rules/CD-2/CHECKS.md +0 -60
  497. package/rules/CD-2/README.md +0 -15
  498. package/rules/CD-2/discipline.json +0 -151
  499. package/rules/CD-20/CHECKS.md +0 -9
  500. package/rules/CD-20/README.md +0 -15
  501. package/rules/CD-21/CHECKS.md +0 -15
  502. package/rules/CD-21/README.md +0 -15
  503. package/rules/CD-21/discipline.json +0 -12
  504. package/rules/CD-22/CHECKS.md +0 -15
  505. package/rules/CD-22/README.md +0 -15
  506. package/rules/CD-22/discipline.json +0 -12
  507. package/rules/CD-23/CHECKS.md +0 -37
  508. package/rules/CD-23/README.md +0 -15
  509. package/rules/CD-23/discipline.json +0 -57
  510. package/rules/CD-24/CHECKS.md +0 -9
  511. package/rules/CD-24/README.md +0 -15
  512. package/rules/CD-25/CHECKS.md +0 -40
  513. package/rules/CD-25/README.md +0 -15
  514. package/rules/CD-25/discipline.json +0 -57
  515. package/rules/CD-26/CHECKS.md +0 -38
  516. package/rules/CD-26/README.md +0 -15
  517. package/rules/CD-26/discipline.json +0 -57
  518. package/rules/CD-27/CHECKS.md +0 -460
  519. package/rules/CD-27/README.md +0 -15
  520. package/rules/CD-27/discipline.json +0 -437
  521. package/rules/CD-28/CHECKS.md +0 -15
  522. package/rules/CD-28/README.md +0 -15
  523. package/rules/CD-28/discipline.json +0 -12
  524. package/rules/CD-29/CHECKS.md +0 -15
  525. package/rules/CD-29/README.md +0 -15
  526. package/rules/CD-29/discipline.json +0 -12
  527. package/rules/CD-3/README.md +0 -15
  528. package/rules/CD-3/discipline.json +0 -641
  529. package/rules/CD-30/CHECKS.md +0 -15
  530. package/rules/CD-30/README.md +0 -15
  531. package/rules/CD-30/discipline.json +0 -12
  532. package/rules/CD-31/CHECKS.md +0 -15
  533. package/rules/CD-31/README.md +0 -15
  534. package/rules/CD-31/discipline.json +0 -12
  535. package/rules/CD-32/CHECKS.md +0 -15
  536. package/rules/CD-32/README.md +0 -26
  537. package/rules/CD-32/discipline.json +0 -12
  538. package/rules/CD-33/CHECKS.md +0 -15
  539. package/rules/CD-33/README.md +0 -26
  540. package/rules/CD-33/discipline.json +0 -12
  541. package/rules/CD-34/CHECKS.md +0 -15
  542. package/rules/CD-34/README.md +0 -25
  543. package/rules/CD-34/discipline.json +0 -12
  544. package/rules/CD-39/CHECKS.md +0 -15
  545. package/rules/CD-39/README.md +0 -26
  546. package/rules/CD-39/discipline.json +0 -12
  547. package/rules/CD-4/CHECKS.md +0 -15
  548. package/rules/CD-4/README.md +0 -15
  549. package/rules/CD-4/discipline.json +0 -12
  550. package/rules/CD-40/CHECKS.md +0 -41
  551. package/rules/CD-40/README.md +0 -15
  552. package/rules/CD-40/discipline.json +0 -58
  553. package/rules/CD-41/CHECKS.md +0 -66
  554. package/rules/CD-41/README.md +0 -15
  555. package/rules/CD-41/discipline.json +0 -138
  556. package/rules/CD-42/CHECKS.md +0 -49
  557. package/rules/CD-42/README.md +0 -15
  558. package/rules/CD-42/discipline.json +0 -61
  559. package/rules/CD-43/CHECKS.md +0 -39
  560. package/rules/CD-43/README.md +0 -15
  561. package/rules/CD-43/discipline.json +0 -65
  562. package/rules/CD-44/CHECKS.md +0 -50
  563. package/rules/CD-44/README.md +0 -15
  564. package/rules/CD-44/discipline.json +0 -111
  565. package/rules/CD-45/CHECKS.md +0 -15
  566. package/rules/CD-45/README.md +0 -15
  567. package/rules/CD-45/discipline.json +0 -12
  568. package/rules/CD-46/CHECKS.md +0 -9
  569. package/rules/CD-46/README.md +0 -27
  570. package/rules/CD-47/CHECKS.md +0 -39
  571. package/rules/CD-47/README.md +0 -15
  572. package/rules/CD-47/discipline.json +0 -57
  573. package/rules/CD-5/README.md +0 -15
  574. package/rules/CD-5/discipline.json +0 -131
  575. package/rules/CD-6/CHECKS.md +0 -53
  576. package/rules/CD-6/README.md +0 -15
  577. package/rules/CD-6/discipline.json +0 -165
  578. package/rules/CD-7/CHECKS.md +0 -48
  579. package/rules/CD-7/README.md +0 -15
  580. package/rules/CD-7/discipline.json +0 -142
  581. package/rules/CD-7a/CHECKS.md +0 -40
  582. package/rules/CD-7a/README.md +0 -15
  583. package/rules/CD-7a/discipline.json +0 -57
  584. package/rules/CD-8/CHECKS.md +0 -44
  585. package/rules/CD-8/README.md +0 -15
  586. package/rules/CD-8/discipline.json +0 -57
  587. package/rules/CD-9/CHECKS.md +0 -15
  588. package/rules/CD-9/README.md +0 -15
  589. package/rules/CD-9/discipline.json +0 -12
  590. package/rules/typescript/symptoms.json +0 -1005
  591. /package/{core/values → src/domain/finding}/anchor.d.ts +0 -0
  592. /package/{core/values → src/domain/repository}/branded.d.ts +0 -0
  593. /package/{core/values → src/domain/repository}/repo-path-types.d.ts +0 -0
  594. /package/{core/values → src/domain}/result.d.ts +0 -0
  595. /package/{core/values → src/domain/rule-set}/clause-address-types.d.ts +0 -0
  596. /package/{core/values → src/domain/settings/json-values}/json-value.d.ts +0 -0
  597. /package/{mechanisms/eslint/CD-14 → src/infrastructure/engines/eslint/authored-class-or-this/class-keyword}/README.md +0 -0
  598. /package/{mechanisms/eslint/CD-2 → src/infrastructure/engines/eslint/claimed-type/non-null-assertions}/README.md +0 -0
  599. /package/{mechanisms/eslint/CD-7 → src/infrastructure/engines/eslint/name-off-its-casing/filename-case}/README.md +0 -0
  600. /package/{mechanisms/eslint/CD-6 → src/infrastructure/engines/eslint/name-off-its-casing/naming-convention}/README.md +0 -0
  601. /package/{mechanisms/eslint/CD-40 → src/infrastructure/engines/eslint/positional-parameters/parameter-count}/README.md +0 -0
  602. /package/{mechanisms/eslint/CD-44 → src/infrastructure/engines/eslint/rebinding/parameter-reassignment}/README.md +0 -0
  603. /package/{mechanisms/eslint/CD-27 → src/infrastructure/engines/eslint/test-switched-off/focused-tests}/README.md +0 -0
  604. /package/{mechanisms/eslint/CD-10 → src/infrastructure/engines/eslint/thrown-non-error/throw-only-error}/README.md +0 -0
  605. /package/{mechanisms/eslint/CD-1 → src/infrastructure/engines/eslint/untyped-value/explicit-any}/README.md +0 -0
  606. /package/{mechanisms/eslint/CD-42 → src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit}/README.md +0 -0
  607. /package/{mechanisms/audit → src/infrastructure/engines/walker}/runner/README.md +0 -0
  608. /package/{api → src}/rule-set.js +0 -0
@@ -1,219 +1,1685 @@
1
1
  # Checks in TypeScript
2
2
 
3
- A check is how a [symptom](symptoms.md) is found. It is imperfect by design. "We aim for a check to find that. But we assess ways to narrow the margin of error and start with the 80/20 rule and reuse what we have where it is sufficient for first cut of mechanical ways to check what we are looking for."
4
-
5
- So the symptom states exactly what is seen; a check aims at it and states its margin: what it flags that is not the symptom, and what it misses. An existing check that is sufficient for a first cut is reused.
6
-
7
- Correct use at an authorised location is never margin: "it flagging the one allowed location is not a fault. It's what authorised locations are for".
8
-
9
- Today's checks are addressed by clause. [Every CD](../numbers.md#every-mechanical-clause) gives the symptom each mechanical clause sees.
10
-
11
- Outside dependency: what was called a package. An internal package is our own code. Telling an outside dependency from an internal package needs the workspace layout, which is files and config Hone can read.
12
-
13
- **Columns.**
14
- - **Reports:** *seen* (where the symptom is), or *seen → breach* (it could also name the breach, given what follows the arrow).
15
- - **Needs:** syntax, types, graph (imports between files), app (the app's structure), files (config, names, build output), history, person.
16
- - **Today:**
17
- - *reuse:* a clause is enough for a first cut.
18
- - *partial:* a clause sees part of the symptom.
19
- - *review:* only a review clause covers it today.
20
- - *new:* nothing covers it today.
21
- - **Margin:** what it flags that is not the symptom / what it misses. "Review owes" names what only a person sees.
22
- - **Settings traced to:** each threshold or setting, and the rule or recipe sentence behind it. *Nothing* means no sentence says so.
23
-
24
- ## The outside world reached directly
25
-
26
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
27
- |---|---|---|---|---|---|
28
- | Date used directly | seen | syntax | reuse | `Date.now` in comments and strings / `performance.now()` | none |
29
- | Ambient randomness | seen | syntax | new | — / — | none |
30
- | Process global used in place | seen | syntax | review | — / — | none |
31
- | Outside import past a boundary | seen | graph | partial | — / `import()`, `require`, globals | `confinedPackages`, empty by default on purpose: the universe of outside dependencies cannot be listed, and flagging every import would catch internal packages. Telling outside from internal needs the workspace layout, which Hone can read. |
32
- | Outside type in a signature | seen → breach (the adapter that returns it, by types) | types | new | — / — | none |
33
- | Library class built in place | seen | types | review | — / — | none |
34
-
35
- ## Text and schemas past their reader
36
-
37
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
38
- |---|---|---|---|---|---|
39
- | Text past its reader | seen → breach (the port that carries text, by types) | syntax; boundary records | partial (tests only) | — / production sites | the edition: **nothing** |
40
- | Schema past its adapter | seen | graph; boundary records | review | — / — | none |
41
-
42
- ## Claimed or loose types
43
-
44
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
45
- |---|---|---|---|---|---|
46
- | Claimed type | seen → breach (the declaration, by types) | syntax | reuse | — / `any` reached through an outside dependency's types | `as const` allowed: Declared, not asserted |
47
- | Untyped value | seen | syntax | reuse | — / — | none |
48
- | Own type guard | seen | syntax | new | — / — | none |
49
- | Type derived from code | seen | syntax | reuse | text in comments / `Parameters<typeof>`, `typeof` alone | none |
50
- | Strictness weakened | seen | files | reuse (edition 2) | edition 1: a flag set to `true` / edition 1: a base reached by `extends` | flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule** |
51
- | Default on a closed union | seen | types | reuse | a `switch` over an open set / — | none |
52
- | Boolean in a signature | seen | syntax | reuse | a predicate's boolean return / — | none |
53
- | Absence standing for a state | — | person | only review | review owes it | — |
54
- | Default for a required value | seen | types | review | — / — | none |
55
-
56
- ## Failures
57
-
58
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
59
- |---|---|---|---|---|---|
60
- | Throw between our units | seen | syntax; boundary records | review | — / — | authorised locations: "Throwing in specific places allowed is just authorised locations as prose" |
61
- | Thrown non-error | seen | syntax | reuse | — / — | none |
62
- | Failure shaped as success | — | person; syntax for a `catch` that returns | only review | review owes it | — |
63
- | Catch-all failure kind | seen | types | new | — / — | none |
64
-
65
- ## Effects and state
66
-
67
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
68
- |---|---|---|---|---|---|
69
- | Loop keyword | seen | syntax | reuse | — / — | none |
70
- | Write into a parameter | seen | syntax | reuse | — / — | none |
71
- | Rebinding | seen | syntax | reuse | — / a local `let` in production | none |
72
- | Authored class or this | seen | syntax | reuse | — / `this` outside a class | none |
73
- | Module-level state | seen | syntax | new | — / — | none |
74
-
75
- ## Unit shape
76
-
77
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
78
- |---|---|---|---|---|---|
79
- | Long function | seen | syntax | reuse | — / — | 50 lines: where a broad symptom fires. "Line and complexity are symptoms that flag many things." Suite bodies not measured: "A test suite's body is a list of cases, not a coordinator." |
80
- | Tangled function | seen | syntax | reuse | — / — | complexity 15: where a broad symptom fires (as above) |
81
- | Work inside a condition | seen | syntax | partial | — / an `if` nested with no `else` | none |
82
- | Orchestrator that computes | seen | types, graph | review | — / — | none |
83
- | Doer calling our own unit | seen | types, graph | new | — / — | none |
84
- | Positional parameters | seen | syntax for inline callbacks (passed straight to a call); types or the symbol graph for named ones | partial | — / our own functions with exactly two parameters | `max: 2`: a recorded compromise of the check, which cannot tell the two kinds apart. "Positional parameters is 2 because it flags functions designed to be used in native APIs even inline unnamed ones for things like map/reduce. Making 1 untenable."; "The check is not right. Its unable to distinguish." |
85
- | Tuple as data | seen | syntax, types | new | — / — | none |
86
- | Wide input | seen → breach (the input's declaration) | types | new | — / — | none |
87
- | Wide port | seen → breach (the port) | types, graph | new | — / — | none |
88
-
89
- ## Layers and wiring
90
-
91
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
92
- |---|---|---|---|---|---|
93
- | Inner layer imports outer | seen | app (folder-to-layer config), graph | review | — / — | which folder is which layer: the adopter's top-level folder config |
94
- | Port outside the domain | seen | graph, types | review | — / — | none |
95
- | Adapter built outside the root | seen | graph | review | — / — | which module is the root: nothing yet |
96
- | Port named for a mechanism | — | person | only review | review owes it | — |
97
-
98
- ## Tests
99
-
100
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
101
- |---|---|---|---|---|---|
102
- | Double with a body | seen → breach (the port it fills, by types) | syntax; types for hand-written doubles | reuse | — / hand-written doubles | test file is `.test.ts(x)`: Companion test file recipe |
103
- | Module or global patched | seen → breach (the unit that imports the module, by graph) | syntax | partial | — / `vi.stubGlobal`, `process.env` set in a test | as above |
104
- | Branch in a test | seen → breach (the type branched on, by types) | syntax | reuse | unit's own API (edition 1) / — | the edition: backwards compatibility for adopters since the npm release |
105
- | Computed value in a test | seen | syntax | reuse | as above | as above |
106
- | Throw or catch in a test | seen | syntax | reuse | — / `catch` | none |
107
- | Unasserted call | seen | syntax, types | new | — / — | none |
108
- | Answer set in a hook | seen | syntax | partial | — / an answer given by `mockReturnValue`, `mockResolvedValue` or `mockImplementation` in a hook | none |
109
- | Test switched off | seen | syntax | reuse | — / `.todo` | `.todo` not flagged: a miss |
110
- | Unit without a running test | seen | files, graph | reuse | — / an empty or non-running sibling | `__tests__` skipped by default, on purpose (noise; the practice is not adopted). `exclude` is scope. |
111
- | Machine touched in a unit test | seen → breach (the unit with no port) | syntax; the suffix | new | — / — | integration test suffix: recipe ("keep pyramid checkable") |
112
- | Inherited environment in a subprocess | seen | syntax, types | partial | — / `env` built from `process.env` under an accepted name | accepted helper names: **nothing**; `.spec`, `.js`, `.mjs` test files: **nothing** |
113
- | Behaviour tested away from its owner | — | person; graph for candidates | only review | review owes it | — |
114
- | Integration-heavy suite | seen | files (suffix) | review | — / — | the suffix: recipe |
115
- | Coverage gate | seen | files | review | — / — | none |
116
- | Large input for a few fields | — | person (the cast is Claimed type) | only review | review owes it | — |
117
- | Test of the type checker | — | person | only review | review owes it | — |
118
-
119
- ## Names, prose and files
120
-
121
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
122
- |---|---|---|---|---|---|
123
- | Shorthand name | seen | syntax | reuse | — / shorthand not on the list | shorthand and filler list: Whole words recipe |
124
- | Name off its casing | seen | syntax, files | reuse | — / — | Hone's own casing option lists: **nothing**; casing is the adopter's own lint |
125
- | Drawer path | seen | files | reuse | — / a drawer under an ordinary name | drawer names: Screaming folders recipe |
126
- | Types-only file | seen | syntax | new | — / — | port declarations allowed: Entity module recipe |
127
- | Prose in code | seen | syntax | new | — / — | tracked pointer form: [records](../records.md#what-is-not-a-record) |
128
- | Untracked escape | seen | syntax | reuse | — / — | reference form "need a digit": **nothing** |
129
- | Many spellings of one concept | seen | files (the vocabulary list) | new | — / — | the Domain vocabulary list recipe |
130
- | Outside dependency vocabulary for basic logic | seen | graph; workspace layout | new | — / — | which outside dependencies: nothing yet |
131
- | Duplicate decision | — | person; clones surface candidates | only review | review owes the ruling ("reasons to change") | — |
132
- | Change spread across modules | seen | history | new | — / — | none |
133
-
134
- ## Dependencies and versions
135
-
136
- | Check for | Reports | Needs | Today | Margin | Settings traced to |
137
- |---|---|---|---|---|---|
138
- | Floating version | seen | files | new | — / — | Fixed versions |
139
- | No lock file | seen | files | new | — / — | Fixed versions |
140
- | Dependency without a record | seen | files; records | new | — / — | Outside dependencies justified |
141
- | Tool fetched at run time | seen | files | new | — / — | Tools live in the repo |
142
- | Edit inside vendored code | seen | history | new | — / — | which folder is vendored: a boundary record |
143
- | Bundled dependency | seen | build output | new | — / — | Shipped risk declared (proposed, not accepted) |
144
-
145
- ## Findings that point at the breach
146
-
147
- Several symptoms are seen far from their breach. Each finding has two addresses:
148
- - where the symptom is seen;
149
- - the rule or rules the symptom indicates, with the place the breach usually sits.
150
-
151
- | Symptom seen | Where it is seen | Where the breach usually sits | What a check needs to name the breach |
152
- |---|---|---|---|
153
- | Double with a body | the test | the port's width, or a collaborator with two decisions | types: the port the double fills, and its uncalled methods |
154
- | Large input for a few fields | the test (often a cast) | the unit's declared input | types: the parameter's declaration and the fields read |
155
- | Branch in a test | the test | the type of the value branched on | types: the declaring type of the member read |
156
- | Text past its reader (in a test) | the test | the port that carries text | types: the port method the text is fed to |
157
- | Module or global patched | the test | the unit that imports what it should be passed | graph: who imports the mocked module |
158
- | Machine touched in a unit test | the test | the unit with no port | graph: what the unit imports |
159
- | Date used directly | the unit | a doer doing two jobs | person |
160
- | Claimed type | the cast | the declaration it works around | types |
161
-
162
- Until a check can name the breach, a finding names the rules the symptom points at and where the breach usually sits. It never says only "this line".
3
+ ## Authored class or this
4
+
5
+ ### class-keyword
6
+
7
+ - **Misses:** `this` outside a class.
8
+ - **Settings traced to:** none.
9
+
10
+ A class declaration or expression outside ambient code.
11
+
12
+ ## Flags
13
+ - TypeScript source files; declaration files (`.d.ts`) are skipped. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped by the audit mechanism. The ESLint piece lints whatever files the team's ESLint run includes.
14
+ - Any class declaration, class expression, `abstract class`, nested class, or class inside a runtime `namespace`, reported at the `class` keyword.
15
+ - Allowed: `declare class`, classes inside `declare module`, `declare global` or `declare namespace`, and `new Client()` on a class imported from a library.
16
+ - Other generated code can be left out of the audit mechanism's scope with `exclude` in disciplines.json. Hand-written classes are not out of scope.
17
+
18
+ ## Example
19
+ ```ts
20
+ export class Counter {}
21
+ ```
22
+
23
+ ## Fix
24
+ ```ts
25
+ export const createCounter = () => {
26
+ let count = 0;
27
+ return { increment: () => (count += 1) };
28
+ };
29
+ ```
30
+ Return an object of functions from a factory that closes over its state.
31
+
32
+ ### static-members-only
33
+
34
+ - **Misses:** `this` outside a class.
35
+ - **Settings traced to:** none.
36
+
37
+ A class whose members are all static.
38
+
39
+ ## Flags
40
+ - TypeScript source files; declaration files (`.d.ts`) are skipped. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped by the audit mechanism. The ESLint piece lints whatever files the team's ESLint run includes.
41
+
42
+ Needs ESLint adopted through the projection.
43
+ - Under ESLint, this is typescript-eslint's `no-extraneous-class` with `allowConstructorOnly: true`, `allowEmpty: true`, `allowStaticOnly: false` and `allowWithDecorator: true`.
44
+ - It flags a class whose members are all static.
45
+ - Allowed: empty classes, decorated classes and classes that extend another class.
46
+
47
+ ## Boolean in a signature
48
+
49
+ ### boolean-annotation
50
+
51
+ - **Flags beyond the symptom:** a predicate's boolean return.
52
+ - **Settings traced to:** none.
53
+
54
+ A boolean type in a parameter, property signature or return.
55
+
56
+ ## Flags
57
+
58
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
59
+ - A declared type of `boolean`, or `boolean` unioned only with `null` and `undefined`, on a parameter, an interface or type-literal property, a function, method, arrow or accessor return, or a function, call or index signature.
60
+ - Allowed: `true` or `false` literals, `boolean | string`, aliases of boolean, type predicates such as `value is Item`, inferred types, variables and class fields.
61
+ - All boolean signatures are reported, including predicates such as `isReady(): boolean`. Telling evaluative booleans from state is left to review.
62
+
63
+ ## Example
64
+
65
+ ```ts
66
+ const render = (compact: boolean): string => "";
67
+ ```
68
+
69
+ ## Fix
70
+
71
+ ```ts
72
+ const render = (mode: "compact" | "full"): string => "";
73
+ ```
74
+ Name each state in the type.
75
+
76
+ ## Branch in a test
77
+
78
+ ### test-body
79
+
80
+ - **Flags beyond the symptom:** unit's own API (edition 1).
81
+ - **Settings traced to:** the edition: backwards compatibility for adopters since the npm release.
82
+
83
+ `if` statements and ternary expressions in a test file; edition 2 adds short-circuits, optional chaining and `switch`. These run with the other [test-body checks](../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
84
+
85
+ ## Flags
86
+ Edition 1:
87
+ - `if` statements and ternary expressions.
88
+
89
+ Edition 2 also flags:
90
+ - `??`, `||` and `&&`, and their assignment forms `??=`, `||=` and `&&=`.
91
+ - Optional chaining: `a?.b`, `a?.[key]` and `f?.()`.
92
+ - `switch` statements.
93
+
94
+ ## Allowed forms in a test
95
+
96
+ ### Branching with if
97
+ ```ts
98
+ declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
99
+ const parsed = parse("a");
100
+ if (parsed.outcome === "ok") {
101
+ expect(parsed.value).toBe("a");
102
+ }
103
+ ```
104
+ Compare the whole result:
105
+
106
+ ```ts
107
+ declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
108
+ expect(parse("a")).toEqual({ outcome: "ok", value: "a" });
109
+ ```
110
+
111
+ Or write one test per case, or one table:
112
+
113
+ ```ts
114
+ declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
115
+ it.each([
116
+ { text: "a", expected: { outcome: "ok", value: "a" } },
117
+ { text: "", expected: { outcome: "failed" } },
118
+ ])("parses $text", ({ text, expected }) => {
119
+ expect(parse(text)).toEqual(expected);
120
+ });
121
+ ```
122
+
123
+ ### A ternary
124
+ ```ts
125
+ declare const discountFor: (customer: { readonly tier: "premium" | "standard" }) => number;
126
+ const tier = "premium";
127
+ expect(discountFor({ tier })).toBe(tier === "premium" ? 10 : 0);
128
+ ```
129
+ Write the value out, with one table row per case:
130
+
131
+ ```ts
132
+ declare const discountFor: (customer: { readonly tier: "premium" | "standard" }) => number;
133
+ it.each([
134
+ { tier: "premium", expected: 10 },
135
+ { tier: "standard", expected: 0 },
136
+ ] as const)("gives $expected off to a $tier customer", ({ tier, expected }) => {
137
+ expect(discountFor({ tier })).toBe(expected);
138
+ });
139
+ ```
140
+
141
+ ### A short-circuit
142
+ ```ts
143
+ declare const lookup: (id: string) => { readonly name: string } | undefined;
144
+ const found = lookup("a");
145
+ expect(found !== undefined && found.name === "Ada").toBe(true);
146
+ ```
147
+ Write the value a fallback gives. To narrow a value that may be missing, assert it is defined, then read it:
148
+
149
+ ```ts
150
+ declare const lookup: (id: string) => { readonly name: string } | undefined;
151
+ const found = lookup("a");
152
+ assert.isDefined(found);
153
+ expect(found.name).toBe("Ada");
154
+ ```
155
+
156
+ ### An optional chain after an index
157
+ ```ts
158
+ declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
159
+ expect(listTasks()[0]?.id).toBe("a");
160
+ ```
161
+ Compare the whole element:
162
+
163
+ ```ts
164
+ declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
165
+ expect(listTasks()[0]).toMatchObject({ id: "a" });
166
+ ```
167
+
168
+ Or destructure it and assert it is defined before reading it:
169
+
170
+ ```ts
171
+ declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
172
+ const [first] = listTasks();
173
+ assert.isDefined(first);
174
+ expect(first.id).toBe("a");
175
+ ```
176
+
177
+ ### An optional chain on a mock call
178
+ ```ts
179
+ declare const start: (run: (task: { readonly id: string }) => void) => void;
180
+ const run = vi.fn<(task: { readonly id: string }) => void>();
181
+ start(run);
182
+ expect(run.mock.calls[0]?.[0].id).toBe("a");
183
+ ```
184
+ Assert that call by its position:
185
+
186
+ ```ts
187
+ declare const start: (run: (task: { readonly id: string }) => void) => void;
188
+ const run = vi.fn<(task: { readonly id: string }) => void>();
189
+ start(run);
190
+ expect(run).toHaveBeenNthCalledWith(1, expect.objectContaining({ id: "a" }));
191
+ ```
192
+
193
+ Reading `run.mock.lastCall?.[0]` names this section too. Assert the last call:
194
+
195
+ ```ts
196
+ declare const start: (run: (task: { readonly id: string }) => void) => void;
197
+ const run = vi.fn<(task: { readonly id: string }) => void>();
198
+ start(run);
199
+ expect(run).toHaveBeenLastCalledWith({ id: "a" });
200
+ ```
201
+
202
+ ### An optional chain on a mock result
203
+ ```ts
204
+ declare const pricing: { readonly priceOf: (amount: number) => number };
205
+ declare const settle: (prices: { readonly priceOf: (amount: number) => number }) => void;
206
+ const priceOf = vi.spyOn(pricing, "priceOf");
207
+ settle(pricing);
208
+ expect(priceOf.mock.results[0]?.value).toBe(4);
209
+ ```
210
+ Assert what that call returned, by its position:
211
+
212
+ ```ts
213
+ declare const pricing: { readonly priceOf: (amount: number) => number };
214
+ declare const settle: (prices: { readonly priceOf: (amount: number) => number }) => void;
215
+ const priceOf = vi.spyOn(pricing, "priceOf");
216
+ settle(pricing);
217
+ expect(priceOf).toHaveNthReturnedWith(1, 4);
218
+ ```
219
+
220
+ `toHaveLastReturnedWith` asserts what the last call returned.
221
+
222
+ An optional chain on `mock.instances` or `mock.contexts` names [An optional chain after an index](#an-optional-chain-after-an-index).
223
+
224
+ ### An optional chain on a property
225
+ ```ts
226
+ declare const findUser: (id: string) => { readonly name: string } | undefined;
227
+ expect(findUser("a")?.name).toBe("Ada");
228
+ ```
229
+ Compare the whole value:
230
+
231
+ ```ts
232
+ declare const findUser: (id: string) => { readonly name: string } | undefined;
233
+ expect(findUser("a")).toMatchObject({ name: "Ada" });
234
+ ```
235
+
236
+ Or assert it is defined before reading it:
237
+
238
+ ```ts
239
+ declare const findUser: (id: string) => { readonly name: string } | undefined;
240
+ const user = findUser("a");
241
+ assert.isDefined(user);
242
+ expect(user.name).toBe("Ada");
243
+ ```
244
+
245
+ ### An optional call
246
+ ```ts
247
+ declare const observers: { readonly enter?: (node: string) => void };
248
+ observers.enter?.("a");
249
+ ```
250
+ Destructure the function, assert it is defined, then call it:
251
+
252
+ ```ts
253
+ declare const observers: { readonly enter?: (node: string) => void };
254
+ const { enter } = observers;
255
+ assert.isDefined(enter);
256
+ enter("a");
257
+ ```
258
+
259
+ A method that reads `this` loses it once taken off its object, so assert it is defined where it is and call it there:
260
+
261
+ ```ts
262
+ declare const tracker: { readonly entered: readonly string[]; enter?(node: string): void };
263
+ assert.isDefined(tracker.enter);
264
+ tracker.enter("a");
265
+ ```
266
+
267
+ ### A switch
268
+ ```ts
269
+ declare const areaOf: (shape: { readonly kind: "square"; readonly side: number } | { readonly kind: "circle"; readonly radius: number }) => number;
270
+ const shape = { kind: "square", side: 2 } as const;
271
+ switch (shape.kind) {
272
+ case "square":
273
+ expect(areaOf(shape)).toBe(4);
274
+ }
275
+ ```
276
+ Write one test per case, or one table:
277
+
278
+ ```ts
279
+ declare const areaOf: (shape: { readonly kind: "square"; readonly side: number } | { readonly kind: "circle"; readonly radius: number }) => number;
280
+ it.each([
281
+ { shape: { kind: "square", side: 2 } as const, expected: 4 },
282
+ { shape: { kind: "circle", radius: 0 } as const, expected: 0 },
283
+ ])("measures a $shape.kind", ({ shape, expected }) => {
284
+ expect(areaOf(shape)).toBe(expected);
285
+ });
286
+ ```
287
+
288
+ ## Claimed type
289
+
290
+ ### cast-to-any
291
+
292
+ - **Misses:** `any` reached through an outside dependency's types.
293
+ - **Settings traced to:** `as const` allowed: Declared, not asserted.
294
+
295
+ A type assertion whose type contains `any`.
296
+
297
+ ## Flags
298
+ - `.ts` and `.tsx` files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
299
+ - A type assertion (`x as T` or `<T>x`) whose type contains the `any` keyword at any depth: `as any`, `<any>x`, `as Array<any>`, `as Record<string, any>`, `as Map<string, any>` or `as { field: any }`. The check reads the syntax tree, so an `any` elsewhere on the line is not attributed to the cast.
300
+ - This check judges these before [unlisted-cast-site](symptoms/claimed-type/unlisted-cast-site.md) and has no settings; every other assertion is [unlisted-cast-site](symptoms/claimed-type/unlisted-cast-site.md)'s.
301
+ - A bare annotation such as `let value: any` is not flagged by this check; [explicit-any](symptoms/untyped-value/explicit-any.md) covers it.
302
+
303
+ ## Example
304
+ ```ts
305
+ const parsed = JSON.parse(text) as any;
306
+ ```
307
+
308
+ ## Fix
309
+ ```ts
310
+ const order = orderSchema.parse(JSON.parse(text));
311
+ ```
312
+ Give it a concrete type where it enters: parse it once with a schema in the adapter for whoever produced it, checked at runtime.
313
+
314
+ In a test file, edition 2 of [the test-body check](symptoms/text-past-its-reader/test-body.md#serialising-or-parsing-json) flags `JSON.parse`; edition 1, the default, does not.
315
+
316
+ ### non-null-assertions
317
+
318
+ - **Misses:** `any` reached through an outside dependency's types.
319
+ - **Settings traced to:** `as const` allowed: Declared, not asserted.
320
+
321
+ A non-null assertion, `x!`, or a definite assignment assertion, `let x!: T` or `field!: T`.
322
+
323
+ ## Flags
324
+ Needs ESLint adopted through the projection.
325
+ - Under ESLint, this is `no-restricted-syntax` with two selectors, one per form.
326
+ - `TSNonNullExpression` flags every non-null assertion, `x!`, wherever it sits: a read such as `user.name!`, a call such as `totals.get(key)!.toFixed(2)`, an assignment target such as `basket.total! = 0`. It is the same node typescript-eslint's `no-non-null-assertion` reports.
327
+ - `[definite=true]` flags every definite assignment assertion: `let total!: number` and a class field `balance!: number`.
328
+ - Each finding sits on the line where the asserted expression or the declared name starts.
329
+ - Allowed: logical not `!ready`, `!==`, an optional property `total?: number`, `??` fallbacks, and an initialised binding.
330
+ - There are no settings. No `audit` mechanism checks this clause, so a repository without ESLint lists it as `"not-run"`, and review owes it.
331
+
332
+ ## Example
333
+ ```ts
334
+ const user = response as User;
335
+ const name = user.name!;
336
+ ```
337
+
338
+ ## Fix
339
+ ```ts
340
+ const user = userSchema.parse(response);
341
+ const name = user.name;
342
+ ```
343
+ Parse or narrow the value so the type follows from a check rather than from an assertion. For a value that may be absent, handle the absent case with a check or an early return; for a binding assigned later, initialise it where it is declared or make it a `const` built from what it needs.
344
+
345
+ In a test file, [the test-body check](symptoms/branch-in-a-test/test-body.md) flags an `if` check at either edition, and its edition 2 flags the `??` fallback: there, `assert.isDefined` a value that may be missing before reading it, as [the allowed forms](symptoms/branch-in-a-test/test-body.md#a-short-circuit) show.
346
+
347
+ ### unlisted-cast-site
348
+
349
+ - **Misses:** `any` reached through an outside dependency's types.
350
+ - **Settings traced to:** `as const` allowed: Declared, not asserted.
351
+
352
+ A type assertion that is not on the permitted list.
353
+
354
+ ## Flags
355
+ - `.ts` and `.tsx` files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
356
+ - Every `x as T` and `<T>x` assertion except a const assertion, `as const` or `<const>x`. Assertions whose type contains `any` are [cast-to-any](symptoms/claimed-type/cast-to-any.md)'s and are not repeated here.
357
+ - `as unknown` and `<unknown>x` are flagged. Widening never needs an assertion: annotate instead, `const parsed: unknown = JSON.parse(text)`.
358
+ - A cast through `unknown`, such as `raw as unknown as User`, `(<unknown>raw) as User` or one wrapped in `!` or `satisfies`, is flagged with its own message, and so is its `unknown` half. It is the escape hatch that turns any value into any type; check the value's shape at runtime at the boundary instead.
359
+ - `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck` in the `.ts` and `.tsx` files this clause checks are reported as `inline-disable` native exceptions of this clause, where the compiler honours them and whether or not they hide a cast. Directives in `.mts`, `.cts` and JavaScript files are not read. Each is a finding in its file: a debt or an authorised location on the file covers it, and a tracked reference on the comment ([directive-pointers](symptoms/untracked-escape/directive-pointers.md)) does not stand in for the record.
360
+ - Test files, test helpers and scripts are checked like any other source; a test that needs a cast needs a typed stub or a narrower port.
361
+ - There are no settings: a boundary that forces a cast is an exception record, as below.
362
+
363
+ ## Example
364
+ ```ts
365
+ const user = response as User;
366
+ const name = user.name!;
367
+ ```
368
+
369
+ ## Fix
370
+ ```ts
371
+ const user = userSchema.parse(response);
372
+ const name = user.name;
373
+ ```
374
+ Parse or narrow the value so the type follows from a check rather than from an assertion. For a value that may be absent, handle the absent case with a check or an early return; for a binding assigned later, initialise it where it is declared or make it a `const` built from what it needs.
375
+
376
+ When handing a value across a boundary truly forces a cast, such as a library that types its schemas loosely or a database driver that returns unparsed rows, put the cast in the one adapter file at that boundary and record that file as an `authorised-location` with a why-chain. With clean boundaries that is one file and one record; casts scattered across many files are the sign the boundary is missing.
377
+
378
+ ## Computed value in a test
379
+
380
+ ### test-body
381
+
382
+ - **Flags beyond the symptom:** unit's own API (edition 1).
383
+ - **Settings traced to:** the edition: backwards compatibility for adopters since the npm release.
384
+
385
+ Computing and mutating string and array methods in a test file; edition 2 adds computing calls on `Object`, `Array` and `Math`. These run with the other [test-body checks](../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
386
+
387
+ ## Flags
388
+ Edition 1:
389
+ - A method call with a computing or mutating name, wherever it could be the string or array method of that name: `map`, `filter`, `reduce`, `find`, `forEach`, `join`, `slice`, `split`, `replace`, `includes`, `sort`, `trim`, `keys`, `values`, `push`, `pop`, `splice`, `fill` and similar string and array methods.
390
+ - Not flagged: a call with one of those names whose arguments no string or array method of that name accepts, which makes it the unit's own API. Either it passes an object literal where none of them takes an object, such as `paths.join({ segments: ["a", "b"] })`, or it passes more arguments than any of them takes, such as `screen.keys("x", true, true)`.
391
+ - Still flagged, though they look like that:
392
+ - a call whose receiver traces back to a built-in namespace such as `Object` or `Math`, a package or `node:` module (imported, required or loaded with `import()`), or a string or array literal. The trace follows variables declared in the test file, including names destructured from a traced module or namespace, such as `posix` after `const { posix } = path`, and a property read directly off an object literal declared there, such as `deps.path` after `const deps = { path }`;
393
+ - a call that spreads its arguments;
394
+ - an object at a position where a string or array method takes one, such as `rows.includes({ id: "a" })`, `rows.push({ id: "a" })`, `rows.reduce(sum, { total: 0 })`, `rows.find(isA, {})` or `text.split({ [Symbol.split]: splitter })`.
395
+ - What this check cannot know: it reads names and syntax, not types, so it cannot tell what a receiver is.
396
+ - It flags the unit's own method given a variable, such as `repository.find(query)`.
397
+ - It misses a string or array method taken off its receiver before the call.
398
+ - It does not trace a receiver that is a function parameter, an `it.each` row, a value from another module (even a relative module that re-exports a package), a name destructured from an object literal, or a property nested deeper in one, such as `deps.nested.path`; it reads these as the unit's own.
399
+ - It releases a method of another built-in or library type that shares a name, such as a stream's `values` or `reduce`, when that call passes an object or more arguments than the string or array method takes.
400
+ Only a check that reads types knows a receiver's identity, and Hone does not have one yet.
401
+
402
+ Edition 2 also flags:
403
+ - Computing calls on a built-in namespace: `Object.assign`, `Object.fromEntries`, `Array.from` and any `Math` method. `JSON.stringify` and `JSON.parse` are [text-past-its-reader#test-body](symptoms/text-past-its-reader/test-body.md).
404
+
405
+ ## Allowed forms in a test
406
+
407
+ ### A method that picks or tests an element
408
+ ```ts
409
+ declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
410
+ expect(listTasks().find((task) => task.id === "a")).toEqual({ id: "a", status: "open" });
411
+ ```
412
+ Assert on the whole array:
413
+
414
+ ```ts
415
+ declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
416
+ expect(listTasks()).toContainEqual({ id: "a", status: "open" });
417
+ ```
418
+
419
+ ```ts
420
+ declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
421
+ expect(listTasks()).toEqual(expect.arrayContaining([expect.objectContaining({ id: "a" })]));
422
+ ```
423
+
424
+ The check cannot tell the unit's own method with one of these names from an array method when it is given a variable, such as `repository.find(query)`. That is a limit of the check, described under [What the check flags](#flags).
425
+
426
+ ### A method that computes a value
427
+ ```ts
428
+ declare const idsOf: (rows: readonly { readonly id: string }[]) => readonly string[];
429
+ const rows = [{ id: "a1" }, { id: "b2" }];
430
+ expect(idsOf(rows)).toEqual(rows.map((row) => row.id));
431
+ ```
432
+ Write the expected value out:
433
+
434
+ ```ts
435
+ declare const idsOf: (rows: readonly { readonly id: string }[]) => readonly string[];
436
+ expect(idsOf([{ id: "a1" }, { id: "b2" }])).toEqual(["a1", "b2"]);
437
+ ```
438
+
439
+ Or match the part that matters:
440
+
441
+ ```ts
442
+ declare const receiptOf: (order: { readonly total: number }) => { readonly total: number; readonly label: string };
443
+ expect(receiptOf({ total: 30 })).toMatchObject({ label: expect.stringContaining("30") });
444
+ ```
445
+
446
+ ### A method that mutates
447
+ ```ts
448
+ declare const namesOf: (team: string) => readonly string[];
449
+ const expected = ["Ada"];
450
+ expected.push("Grace");
451
+ expect(namesOf("core")).toEqual(expected);
452
+ ```
453
+ Write the finished array out:
454
+
455
+ ```ts
456
+ declare const namesOf: (team: string) => readonly string[];
457
+ expect(namesOf("core")).toEqual(["Ada", "Grace"]);
458
+ ```
459
+
460
+ ### Merging objects
461
+ ```ts
462
+ const base = { method: "POST", path: "/tasks" } as const;
463
+ const request = Object.assign({}, base, { body: "a" });
464
+ expect(request.body).toBe("a");
465
+ ```
466
+ Write the object out, spreading what it copies:
467
+
468
+ ```ts
469
+ const base = { method: "POST", path: "/tasks" } as const;
470
+ const request = { ...base, body: "a" };
471
+ expect(request.body).toBe("a");
472
+ ```
473
+
474
+ A spread copies an `Error`'s own properties into a plain object, which is not an `Error`. To give an `Error` a property, assign it:
475
+
476
+ ```ts
477
+ declare const reasonOf: (error: Error & { readonly code?: string }) => string;
478
+ const missing: Error & { code?: string } = new Error("ENOENT");
479
+ missing.code = "ENOENT";
480
+ expect(reasonOf(missing)).toBe("missing");
481
+ ```
482
+
483
+ ### Building an object from entries
484
+ ```ts
485
+ declare const countsOf: (words: readonly string[]) => Readonly<Record<string, number>>;
486
+ expect(countsOf(["a"])).toEqual(Object.fromEntries([["a", 1]]));
487
+ ```
488
+ Write the object out:
489
+
490
+ ```ts
491
+ declare const countsOf: (words: readonly string[]) => Readonly<Record<string, number>>;
492
+ expect(countsOf(["a"])).toEqual({ a: 1 });
493
+ ```
494
+
495
+ ### Building an array from a length
496
+ ```ts
497
+ declare const pageOf: (rows: readonly { readonly id: number }[]) => readonly { readonly id: number }[];
498
+ expect(pageOf(Array.from({ length: 3 }, (_, index) => ({ id: index })))).toHaveLength(3);
499
+ ```
500
+ Write a short array out:
501
+
502
+ ```ts
503
+ declare const pageOf: (rows: readonly { readonly id: number }[]) => readonly { readonly id: number }[];
504
+ expect(pageOf([{ id: 0 }, { id: 1 }, { id: 2 }])).toHaveLength(3);
505
+ ```
506
+
507
+ An array too long to read written out, such as one row past a page size of 1,000, has no form on this page.
508
+
509
+ ### A Math call
510
+ ```ts
511
+ declare const roundedOf: (amount: number) => number;
512
+ expect(roundedOf(2.5)).toBe(Math.round(2.5));
513
+ ```
514
+ Write the number out:
515
+
516
+ ```ts
517
+ declare const roundedOf: (amount: number) => number;
518
+ expect(roundedOf(2.5)).toBe(3);
519
+ ```
520
+
521
+ ## Date used directly
522
+
523
+ ### clock-sources
524
+
525
+ - **Flags beyond the symptom:** `Date.now` in comments and strings.
526
+ - **Misses:** `performance.now()`.
527
+ - **Settings traced to:** none.
528
+
529
+ `Date.now()` and `new Date`.
530
+
531
+ ## Flags
532
+
533
+ - `.ts` and `.tsx` files, including tests. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped.
534
+ - Any line containing `Date.now()` or `new Date`, one finding per line. Comments and strings are matched too.
535
+ - Other time sources (`performance.now`, timers) are not checked; they are left to review.
536
+ - Other generated code can be left out of the check's scope with `exclude` in disciplines.json. Hand-written code that reads the time is not out of scope; it needs the clock port.
537
+
538
+ ## Example
539
+
540
+ ```ts
541
+ const startedAt = Date.now();
542
+ ```
543
+
544
+ ## Fix
545
+
546
+ ```ts
547
+ const startedAt = clock.now();
548
+ ```
549
+ Accept a clock as a dependency and read time only through it. The one real implementation lives in an adapter.
550
+
551
+ ## Default on a closed union
552
+
553
+ ### default-arm
554
+
555
+ - **Flags beyond the symptom:** a `switch` over an open set.
556
+ - **Settings traced to:** none.
557
+
558
+ A `default:` arm inside a `switch`.
559
+
560
+ ## Flags
561
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
562
+ - A line matching `default:` while inside a `switch (`, tracked line by line by counting braces. One finding per line; comment lines are ignored.
563
+ - Every `default:` is flagged. The check cannot tell whether the switch is over a closed union, so a switch over an open set (a plain string) needs an exception. Other `default:` text inside a switch, such as an object key, is flagged too.
564
+
565
+ ## Example
566
+ ```ts
567
+ switch (event.kind) {
568
+ case "opened": return open();
569
+ default: return ignore();
570
+ }
571
+ ```
572
+
573
+ ## Fix
574
+ ```ts
575
+ switch (event.kind) {
576
+ case "opened": return open();
577
+ case "closed": return ignore();
578
+ }
579
+ ```
580
+ Name each remaining variant so the compiler checks exhaustiveness.
581
+
582
+ ## Double with a body
583
+
584
+ ### logic-in-a-passed-function
585
+
586
+ - **Misses:** hand-written doubles.
587
+ - **Settings traced to:** test file is `.test.ts(x)`: Companion test file recipe.
588
+
589
+ A construct any other test-body check flags, inside a function a test passes on. These run with the other [test-body checks](../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
590
+
591
+ ## Flags
592
+ - A function a test writes as a property or method of an object literal, or gives to `vi.fn` or `mockImplementation`, holding a construct another test-body check flags at the edition that runs.
593
+
594
+ ## Allowed forms in a test
595
+
596
+ ### Logic inside a function the test passes on
597
+ ```ts
598
+ declare const isInstalled: (fileKind: { readonly kindOf: (path: string) => "file" | "missing" }) => "installed" | "missing";
599
+ const installedFiles = ["bin/hone.js"];
600
+ expect(isInstalled({ kindOf: (path) => (installedFiles.includes(path) ? "file" : "missing") })).toBe("installed");
601
+ ```
602
+ A function a test writes as a property or method of an object literal, or gives to `vi.fn` or `mockImplementation`, is passed on: to the unit, to a table row, or to a double. Any flagged construct inside it names this section. Make it a `vi.fn` spy with a written-out return, and write out what it was asked:
603
+
604
+ ```ts
605
+ declare const isInstalled: (fileKind: { readonly kindOf: (path: string) => "file" | "missing" }) => "installed" | "missing";
606
+ const kindOf = vi.fn<(path: string) => "file" | "missing">().mockReturnValue("file");
607
+ expect(isInstalled({ kindOf })).toBe("installed");
608
+ expect(kindOf).toHaveBeenCalledExactlyOnceWith("bin/hone.js");
609
+ ```
610
+
611
+ The recipe is [Stub with vi.fn](recipes/stub-with-vifn.md).
612
+
613
+ ### stub-implementation
614
+
615
+ - **Misses:** hand-written doubles.
616
+ - **Settings traced to:** test file is `.test.ts(x)`: Companion test file recipe.
617
+
618
+ `vi.fn(<implementation>)` and `.mockImplementation(...)`.
619
+
620
+ ## Flags
621
+
622
+ - Test files only: `*.test.ts` and `*.test.tsx`. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
623
+ - A `vi.fn(...)` call with any argument, and any call to a method named `mockImplementation` (on any receiver, with or without arguments).
624
+ - Allowed: `vi.fn()`, `.mockReturnValue(...)`, `.mockResolvedValue(...)`, `.mockReturnValueOnce(...)` and `.mockImplementationOnce(...)`.
625
+ - `.mockImplementationOnce(...)` is not flagged even though it takes an implementation; whether that implementation gives the double behaviour is left to review.
626
+ - The source rule is wider (no real I/O, no real collaborators). Whether a unit is isolated is left to review.
627
+
628
+ ## Example
629
+
630
+ ```ts
631
+ const clock = { now: vi.fn(() => 1) };
632
+ ```
633
+
634
+ ## Fix
635
+
636
+ ```ts
637
+ const clock = { now: vi.fn().mockReturnValue(1) };
638
+ ```
639
+ Return a canned value: that double is a stub. If the double needs logic, the seam is probably too wide.
640
+
641
+ ## Drawer path
642
+
643
+ ### drawer-names
644
+
645
+ - **Misses:** a drawer under an ordinary name.
646
+ - **Settings traced to:** drawer names: Screaming folders recipe.
647
+
648
+ A forbidden file name or folder name in a path.
649
+
650
+ ## Flags
651
+ - `.ts` and `.tsx` files only, judged by path; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
652
+ - File names, exactly and in lower case, with a `.ts` extension: `types.ts interfaces.ts models.ts enums.ts utils.ts util.ts helpers.ts helper.ts common.ts lib.ts misc.ts shared.ts`.
653
+ - Any folder in the path named `utils`, `helpers`, `common`, `lib`, `misc`, `shared`, `scripts`, `values`, `tests`, `test` or `__tests__`. Each file under such a folder is reported once for the folder.
654
+ - Allowed: `account-types.ts`, `Types.ts` and `types.tsx`, which are not exact matches.
655
+
656
+ ## Example
657
+ ```text
658
+ src/helpers.ts
659
+ src/utils/format-price.ts
660
+ ```
661
+
662
+ ## Fix
663
+ ```text
664
+ src/price-formatting.ts
665
+ ```
666
+ Rename the file or folder for what it contains, or split it into files that each hold one thing.
667
+
668
+ ## Inherited environment in a subprocess
669
+
670
+ ### git-spawn-environment
671
+
672
+ - **Misses:** `env` built from `process.env` under an accepted name.
673
+ - **Settings traced to:** accepted helper names: **nothing**; `.spec`, `.js`, `.mjs` test files: **nothing**.
674
+
675
+ A git spawn in a test without a hermetic `env`.
676
+
677
+ ## Flags
678
+
679
+ - Test files: `*.test.ts`, `*.test.tsx`, `*.test.mjs`, `*.test.js`, `*.spec.ts`, `*.spec.mjs`. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped; any other folder can be left out with `exclude` in disciplines.json.
680
+ - A line calling `spawnSync`, `spawn`, `execFileSync`, `execFile`, `execSync`, `exec`, `execa` or `execaSync` with `"git"` (or `'git'`, or a template literal) as the first argument.
681
+ - Allowed when, within that line and the next seven, an `env:` names `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`, and no nearby `env:` uses `process.env`. The environment comes from a unit of ours with its own test, not a test helper.
682
+ - Not detected: a command string such as `execSync("git status")`, a split call, or a non-literal command. Whether the spawn is warranted at all is left to review.
683
+
684
+ ## Example
685
+
686
+ ```ts
687
+ spawnSync("git", ["init"], { cwd: directory });
688
+ ```
689
+
690
+ ## Fix
691
+
692
+ ```ts
693
+ spawnSync("git", ["init"], { cwd: directory, env: hermeticGitEnvironment() });
694
+ ```
695
+ Build the environment without inherited git variables or the user's configuration, and run in a temporary directory.
696
+
697
+ ## Long function
698
+
699
+ ### function-length
700
+
701
+ - **Settings traced to:** 50 lines: where a broad symptom fires. "Line and complexity are symptoms that flag many things." Suite bodies not measured: "A test suite's body is a list of cases, not a coordinator.".
702
+
703
+ A function body longer than 50 lines.
704
+
705
+ ## Flags
706
+
707
+ - The ESLint piece lints whatever files the team's ESLint run includes. It needs ESLint adopted through the projection; see the ESLint piece.
708
+ - Under ESLint, a function body may span at most 50 lines. Blank and comment lines count; lines holding only `{` or `}` do not. Getters and setters are not checked. Reported at the function.
709
+ - A test suite's body is not checked. A suite body is a function passed as an argument to the call that runs a suite:
710
+ - `describe`, `suite`, `fdescribe`, `xdescribe`, `fsuite` or `xsuite`, alone or followed only by the modifiers `each`, `for`, `only`, `skip`, `todo`, `concurrent`, `sequential`, `shuffle`, `skipIf` and `runIf`, such as `describe.each(table)(name, fn)`, `describe.each` with a template table, `describe.only.each(table)(name, fn)` or `describe.skipIf(condition)(name, fn)`;
711
+ - Playwright's `test.describe`, alone or followed only by `only`, `skip`, `fixme`, `serial` and `parallel`, such as `test.describe.serial.only(name, fn)`.
712
+ - A suite nested in a suite is not checked either.
713
+ - Everything else is checked as any function is:
714
+ - each function inside a suite's body: each `it` and `test` callback, each hook and each helper declared there;
715
+ - a function given to `describe.each` as a table entry;
716
+ - a callback on any other member of those names, such as `test.describe.configure(fn)` or `suite.add(name, fn)` on a benchmark suite;
717
+ - mocha's `context`, and any other suite function not listed above.
718
+ - The check matches names, not bindings, so a local function of the repository's own named `describe` or `suite` is treated as a suite when called that way.
719
+
720
+ ## Example
721
+
722
+ ```ts
723
+ const settle = (orders: Order[]) => {
724
+ for (const order of orders) {
725
+ if (order.paid) {
726
+ for (const line of order.lines) {
727
+ if (line.refundable && line.quantity > 0) {
728
+ refund(line);
729
+ }
730
+ }
731
+ }
732
+ }
733
+ };
734
+ ```
735
+
736
+ ## Fix
737
+
738
+ ```ts
739
+ const settle = (orders: Order[]) => orders.filter(isPaid).forEach(refundEligibleLines);
740
+ ```
741
+ Move any computing or branching between calls into a named doer, so the orchestrator only composes calls.
742
+
743
+ ## Loop keyword
744
+
745
+ ### loop-statement
746
+
747
+ - **Settings traced to:** none.
748
+
749
+ `for...of`, `for await`, counted `for` and `while` loops.
750
+
751
+ ## Flags
752
+
753
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
754
+ - Lines matching `for (... of ...)` (with or without `await`), `for (init; test; step)` and `while (`. This includes `do...while`. Each kind is reported once per line.
755
+ - Matching is on raw lines, so loop headers split over several lines are missed and the same text inside a string is flagged. Comment lines are ignored.
756
+ - The source rule names element and counted iteration; the check also flags `while`.
757
+ - Draining an `AsyncIterable` with `for await` is allowed by the rule at declared sites; record it as an `authorised-location`.
758
+
759
+ ## Example
760
+
761
+ ```ts
762
+ for (const order of orders) {
763
+ totals.push(order.total);
764
+ }
765
+ ```
766
+
767
+ ## Fix
768
+
769
+ ```ts
770
+ const totals = orders.map((order) => order.total);
771
+ ```
772
+ Replace a counted loop with `Array.from({ length }, (_, position) => ...)`.
773
+
774
+ In a test file, the [computed-value-in-a-test check](symptoms/computed-value-in-a-test/test-body.md) flags `map` at either edition, and its edition 2 flags `Array.from`: write the values out instead, as [the allowed forms in a test](symptoms/computed-value-in-a-test/test-body.md#allowed-forms-in-a-test) show.
775
+
776
+ ## Module or global patched
777
+
778
+ ### module-mock-call
779
+
780
+ - **Misses:** `vi.stubGlobal`, `process.env` set in a test.
781
+ - **Settings traced to:** test file is `.test.ts(x)`: Companion test file recipe.
782
+
783
+ Calls to `vi.mock`.
784
+
785
+ ## Flags
786
+
787
+ - Test files only: `*.test.ts` and `*.test.tsx`. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
788
+ - Every call spelled `vi.mock(...)`, with or without arguments.
789
+ - Not detected: `vi.doMock`, `jest.mock`, `vitest.mock` and `vi["mock"]`. Those are left to review.
790
+
791
+ ## Example
792
+
793
+ ```ts
794
+ vi.mock("./store.ts");
795
+ ```
796
+
797
+ ## Fix
798
+
799
+ ```ts
800
+ const subject = createSubject({ store: storeStub });
801
+ ```
802
+ Pass the collaborator in as a dependency and hand the test a stub.
803
+
804
+ ## Name off its casing
805
+
806
+ ### filename-case
807
+
808
+ - **Settings traced to:** Hone's own casing option lists: **nothing**; casing is the adopter's own lint.
809
+
810
+ A file name that is not kebab-case or PascalCase.
811
+
812
+ ## Flags
813
+ Needs ESLint adopted through the projection.
814
+ - Under ESLint, the file name before its first dot is checked, after trimming edge `_`: it must be kebab-case or PascalCase. Each later dot segment must be kebab-case, PascalCase or lowercase.
815
+ - One leading `.`, `+` or `$` is ignored.
816
+ - Route names such as `[slug].ts` and `(group).ts` pass.
817
+ - A bad name is reported at line 1.
818
+
819
+ ### naming-convention
820
+
821
+ - **Settings traced to:** Hone's own casing option lists: **nothing**; casing is the adopter's own lint.
822
+
823
+ A name that breaks the naming convention for its kind.
824
+
825
+ ## Flags
826
+ Needs ESLint adopted through the projection.
827
+ - Under ESLint, this is typescript-eslint's `naming-convention` with the option list in the piece's `piece.json`.
828
+ - Enum members are CONSTANT_CASE. `const` bindings are CONSTANT_CASE, camelCase or PascalCase.
829
+ - Object literal properties are camelCase. Type properties are camelCase or PascalCase.
830
+ - Other variables, functions and parameters are camelCase or PascalCase; a leading or trailing `_` or `$` is allowed.
831
+ - Types are PascalCase. Class members are camelCase, and static ones may also be CONSTANT_CASE.
832
+ - Consecutive capitals are allowed (`agentID`, `HTTPServer`).
833
+ - Ignored: names that need quotes, destructured bindings, imports and unused bindings whose name starts with `_`.
834
+ - Not checked, unlike Biome: the local name of a renamed named import (`import { a as b }`) and a `catch` parameter. typescript-eslint has no selector for either; review covers them.
835
+
836
+ ## Outside import past a boundary
837
+
838
+ ### import-or-require
839
+
840
+ - **Misses:** `import()`, `require`, globals.
841
+ - **Settings traced to:** `confinedPackages`, empty by default on purpose: the universe of outside dependencies cannot be listed, and flagging every import would catch internal packages. Telling outside from internal needs the workspace layout, which Hone can read.
842
+
843
+ Imports of the packages the repository confines, and any `node:` import.
844
+
845
+ ## Flags
846
+
847
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
848
+ - A line with `from "<specifier>"` where the specifier is a package listed in the clause's `confinedPackages` setting (see [Settings](#settings)) or a subpath of one: `hono` covers `hono` and `hono/cors`, and `@scope/name` covers `@scope/name` and `@scope/name/client`. A longer name is a different package, so `hono` does not cover `honox` or `hono-extra`. With no packages listed, which is the default, no library import is flagged. Type-only imports and matches inside strings are flagged too.
849
+ - A `node:` specifier in an import, `export ... from`, `import("node:...")`, `import type`, `import x = require(...)` or `require("node:...")`. Unprefixed `fs` is not detected.
850
+ - The source rule covers every third-party dependency; the check covers only the listed packages. The rest is left to review.
163
851
 
164
852
  ## Settings
165
853
 
166
- A setting fails only if it changes what a rule requires. It does not fail when it:
167
- - tunes how early a symptom fires: "Line and complexity are symptoms that flag many things.";
168
- - is scope a codebase chose: "Exclude is any codebases choice to say this is not in scope. It's never bound by any rules."
854
+ List each outside dependency the repository confines to its adapter in `disciplines.json`, then record each adapter file as an `authorised-location`:
855
+
856
+ ```jsonc
857
+ "clauseSettings": {
858
+ "CD-19#import-boundaries": { "confinedPackages": ["winston", "uuid"] }
859
+ }
860
+ ```
861
+
862
+ ## Example
863
+
864
+ With `"confinedPackages": ["uuid"]`, both lines are flagged; with the default, only the first.
865
+
866
+ ```ts
867
+ import { readFileSync } from "node:fs";
868
+ import { v4 } from "uuid";
869
+ ```
870
+
871
+ ## Fix
872
+
873
+ ```ts
874
+ import type { FileReader } from "./file-reader.ts";
875
+ import type { IdGenerator } from "./id-generator.ts";
876
+ ```
877
+ Import your own port and take it in the unit's argument. Only the adapter for that outside party imports the library.
878
+
879
+ ## Positional parameters
880
+
881
+ ### parameter-count
882
+
883
+ - **Misses:** our own functions with exactly two parameters.
884
+ - **Settings traced to:** `max: 2`: a recorded compromise of the check, which cannot tell the two kinds apart. "Positional parameters is 2 because it flags functions designed to be used in native APIs even inline unnamed ones for things like map/reduce. Making 1 untenable."; "The check is not right. Its unable to distinguish.".
885
+
886
+ A function with more than two parameters.
887
+
888
+ ## Flags
889
+
890
+ - The ESLint piece lints whatever files the team's ESLint run includes. It needs ESLint adopted through the projection; see the ESLint piece.
891
+ - Under ESLint, this is typescript-eslint's `max-params` with `{ "max": 2, "countVoidThis": true }`.
892
+ - A function declaration, function expression, arrow function, method or constructor with more than two parameters. A `this` parameter counts.
893
+ - Not flagged by the check: functions with two or fewer parameters. The rule asks for one named object; a function with two parameters is left to review, where the function-first lens treats every authored function with two or more parameters as a candidate.
894
+
895
+ ## Example
896
+
897
+ ```ts
898
+ const createOrder = (customerId: string, items: Item[], currency: string) => ({ customerId, items, currency });
899
+ ```
900
+
901
+ ## Fix
902
+
903
+ ```ts
904
+ const createOrder = ({ customerId, items, currency }: OrderRequest) => ({ customerId, items, currency });
905
+ ```
906
+ Take one object with named fields so each call site reads as a labelled contract.
907
+
908
+ ## Rebinding
909
+
910
+ ### parameter-reassignment
911
+
912
+ - **Misses:** a local `let` in production.
913
+ - **Settings traced to:** none.
914
+
915
+ Assigning to, incrementing or destructuring into a parameter itself.
916
+
917
+ ## Flags
918
+
919
+ Needs ESLint adopted through the projection; see the ESLint piece.
920
+
921
+ - Under ESLint, this is ESLint's `no-param-reassign` with `{ "props": false }`.
922
+ - It flags assigning to a parameter, incrementing or decrementing it, and destructuring-assigning into it.
923
+ - A parameter's fields are not checked here; the audit's [`parameter-mutation`](symptoms/write-into-a-parameter/parameter-mutation.md) clause covers them.
924
+
925
+ ### test-body
926
+
927
+ - **Misses:** a local `let` in production.
928
+ - **Settings traced to:** none.
929
+
930
+ `let` declarations in a test file. These run with the other [test-body checks](../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
931
+
932
+ ## Flags
933
+ Edition 1:
934
+ - `let` declarations.
935
+
936
+ ## Allowed forms in a test
937
+
938
+ ### A let
939
+ ```ts
940
+ declare const record: (store: { readonly save: (text: string) => void }) => void;
941
+ let saved = "";
942
+ record({ save: (text) => { saved = text; } });
943
+ expect(saved).toBe("a");
944
+ ```
945
+ Record the calls with `vi.fn` and assert them:
946
+
947
+ ```ts
948
+ declare const record: (store: { readonly save: (text: string) => void }) => void;
949
+ const save = vi.fn<(text: string) => void>();
950
+ record({ save });
951
+ expect(save).toHaveBeenCalledWith("a");
952
+ ```
953
+
954
+ ## Shorthand name
955
+
956
+ ### identifier-names
957
+
958
+ - **Misses:** shorthand not on the list.
959
+ - **Settings traced to:** shorthand and filler list: Whole words recipe.
960
+
961
+ A binding named from a fixed shorthand or filler list.
962
+
963
+ ## Flags
964
+ - `.ts` and `.tsx` files, including tests; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
965
+ - The declared name of a variable, a parameter, a named function declaration or a destructured binding, when the whole name is exactly one of these (case-sensitive):
966
+ - shorthand: `c op s cb fn tx e ev acc item k v el arr i j n obj val res req tmp temp`
967
+ - filler: `object obj args arguments details extra extras data info params parameters props payload body value result stuff things misc metadata`
968
+ - Allowed: longer names that contain these words (`accountData`), names starting with `_`, property keys and property accesses.
969
+ - Other poor names (`manager`, `handler`, vague nouns) are left to review.
970
+
971
+ ## Example
972
+ ```ts
973
+ const data = await loadAccount(id);
974
+ ```
975
+
976
+ ## Fix
977
+ ```ts
978
+ const account = await loadAccount(id);
979
+ ```
980
+ Name the value for what it is in the domain.
981
+
982
+ ## Strictness weakened
983
+
984
+ ### exact-optional-property-types
985
+
986
+ - **Flags beyond the symptom:** edition 1: a flag set to `true`.
987
+ - **Misses:** edition 1: a base reached by `extends`.
988
+ - **Settings traced to:** flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule**.
989
+
990
+ `exactOptionalPropertyTypes` is set in a `tsconfig.json`; edition 2 adds that it resolves to on.
991
+
992
+ ## Flags
993
+ Each strictness-weakened check has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
994
+
995
+ Edition 1:
996
+ - `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
997
+ - For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
998
+ - Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
999
+
1000
+ Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
1001
+ - The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
1002
+ - `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
1003
+ - The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
1004
+ - A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
1005
+ - The base files are judged through the `tsconfig.json` files that extend them, not on their own.
1006
+ - A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
1007
+
1008
+ ## Settings
1009
+ - `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
1010
+
1011
+ ```jsonc
1012
+ "clauseSettings": {
1013
+ "CD-3#exact-optional-property-types": { "edition": "2" }
1014
+ }
1015
+ ```
1016
+
1017
+ ## Example
1018
+ ```jsonc
1019
+ { "compilerOptions": { "strict": false } }
1020
+ ```
1021
+
1022
+ ## Fix
1023
+ ```jsonc
1024
+ { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
1025
+ ```
1026
+ Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
1027
+
1028
+ ```jsonc
1029
+ { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
1030
+ ```
1031
+
1032
+ ### no-fallthrough-cases-in-switch
1033
+
1034
+ - **Flags beyond the symptom:** edition 1: a flag set to `true`.
1035
+ - **Misses:** edition 1: a base reached by `extends`.
1036
+ - **Settings traced to:** flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule**.
1037
+
1038
+ `noFallthroughCasesInSwitch` is set in a `tsconfig.json`; edition 2 adds that it resolves to on.
1039
+
1040
+ ## Flags
1041
+ Each strictness-weakened check has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
1042
+
1043
+ Edition 1:
1044
+ - `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1045
+ - For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
1046
+ - Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
1047
+
1048
+ Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
1049
+ - The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
1050
+ - `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
1051
+ - The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
1052
+ - A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
1053
+ - The base files are judged through the `tsconfig.json` files that extend them, not on their own.
1054
+ - A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
1055
+
1056
+ ## Settings
1057
+ - `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
1058
+
1059
+ ```jsonc
1060
+ "clauseSettings": {
1061
+ "CD-3#no-fallthrough-cases-in-switch": { "edition": "2" }
1062
+ }
1063
+ ```
1064
+
1065
+ ## Example
1066
+ ```jsonc
1067
+ { "compilerOptions": { "strict": false } }
1068
+ ```
1069
+
1070
+ ## Fix
1071
+ ```jsonc
1072
+ { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
1073
+ ```
1074
+ Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
1075
+
1076
+ ```jsonc
1077
+ { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
1078
+ ```
1079
+
1080
+ ### no-implicit-override
1081
+
1082
+ - **Flags beyond the symptom:** edition 1: a flag set to `true`.
1083
+ - **Misses:** edition 1: a base reached by `extends`.
1084
+ - **Settings traced to:** flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule**.
1085
+
1086
+ `noImplicitOverride` is set in a `tsconfig.json`; edition 2 adds that it resolves to on.
1087
+
1088
+ ## Flags
1089
+ Each strictness-weakened check has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
1090
+
1091
+ Edition 1:
1092
+ - `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1093
+ - For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
1094
+ - Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
1095
+
1096
+ Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
1097
+ - The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
1098
+ - `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
1099
+ - The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
1100
+ - A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
1101
+ - The base files are judged through the `tsconfig.json` files that extend them, not on their own.
1102
+ - A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
1103
+
1104
+ ## Settings
1105
+ - `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
1106
+
1107
+ ```jsonc
1108
+ "clauseSettings": {
1109
+ "CD-3#no-implicit-override": { "edition": "2" }
1110
+ }
1111
+ ```
1112
+
1113
+ ## Example
1114
+ ```jsonc
1115
+ { "compilerOptions": { "strict": false } }
1116
+ ```
1117
+
1118
+ ## Fix
1119
+ ```jsonc
1120
+ { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
1121
+ ```
1122
+ Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
1123
+
1124
+ ```jsonc
1125
+ { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
1126
+ ```
1127
+
1128
+ ### no-property-access-from-index-signature
1129
+
1130
+ - **Flags beyond the symptom:** edition 1: a flag set to `true`.
1131
+ - **Misses:** edition 1: a base reached by `extends`.
1132
+ - **Settings traced to:** flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule**.
1133
+
1134
+ `noPropertyAccessFromIndexSignature` is set in a `tsconfig.json`; edition 2 adds that it resolves to on.
1135
+
1136
+ ## Flags
1137
+ Each strictness-weakened check has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
1138
+
1139
+ Edition 1:
1140
+ - `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1141
+ - For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
1142
+ - Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
1143
+
1144
+ Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
1145
+ - The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
1146
+ - `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
1147
+ - The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
1148
+ - A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
1149
+ - The base files are judged through the `tsconfig.json` files that extend them, not on their own.
1150
+ - A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
1151
+
1152
+ ## Settings
1153
+ - `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
1154
+
1155
+ ```jsonc
1156
+ "clauseSettings": {
1157
+ "CD-3#no-property-access-from-index-signature": { "edition": "2" }
1158
+ }
1159
+ ```
1160
+
1161
+ ## Example
1162
+ ```jsonc
1163
+ { "compilerOptions": { "strict": false } }
1164
+ ```
1165
+
1166
+ ## Fix
1167
+ ```jsonc
1168
+ { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
1169
+ ```
1170
+ Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
1171
+
1172
+ ```jsonc
1173
+ { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
1174
+ ```
1175
+
1176
+ ### no-unchecked-indexed-access
1177
+
1178
+ - **Flags beyond the symptom:** edition 1: a flag set to `true`.
1179
+ - **Misses:** edition 1: a base reached by `extends`.
1180
+ - **Settings traced to:** flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule**.
1181
+
1182
+ `noUncheckedIndexedAccess` is set in a `tsconfig.json`; edition 2 adds that it resolves to on.
1183
+
1184
+ ## Flags
1185
+ Each strictness-weakened check has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
1186
+
1187
+ Edition 1:
1188
+ - `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1189
+ - For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
1190
+ - Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
1191
+
1192
+ Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
1193
+ - The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
1194
+ - `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
1195
+ - The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
1196
+ - A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
1197
+ - The base files are judged through the `tsconfig.json` files that extend them, not on their own.
1198
+ - A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
1199
+
1200
+ ## Settings
1201
+ - `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
1202
+
1203
+ ```jsonc
1204
+ "clauseSettings": {
1205
+ "CD-3#no-unchecked-indexed-access": { "edition": "2" }
1206
+ }
1207
+ ```
1208
+
1209
+ ## Example
1210
+ ```jsonc
1211
+ { "compilerOptions": { "strict": false } }
1212
+ ```
1213
+
1214
+ ## Fix
1215
+ ```jsonc
1216
+ { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
1217
+ ```
1218
+ Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
1219
+
1220
+ ```jsonc
1221
+ { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
1222
+ ```
1223
+
1224
+ ### strict
1225
+
1226
+ - **Flags beyond the symptom:** edition 1: a flag set to `true`.
1227
+ - **Misses:** edition 1: a base reached by `extends`.
1228
+ - **Settings traced to:** flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule**.
1229
+
1230
+ `strict` is set in a `tsconfig.json`; edition 2 adds that it resolves to on.
1231
+
1232
+ ## Flags
1233
+ Each strictness-weakened check has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
1234
+
1235
+ Edition 1:
1236
+ - `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1237
+ - For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
1238
+ - Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
1239
+
1240
+ Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
1241
+ - The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
1242
+ - `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
1243
+ - The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
1244
+ - A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
1245
+ - The base files are judged through the `tsconfig.json` files that extend them, not on their own.
1246
+ - A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
1247
+
1248
+ ## Settings
1249
+ - `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
1250
+
1251
+ ```jsonc
1252
+ "clauseSettings": {
1253
+ "CD-3#strict": { "edition": "2" }
1254
+ }
1255
+ ```
1256
+
1257
+ ## Example
1258
+ ```jsonc
1259
+ { "compilerOptions": { "strict": false } }
1260
+ ```
1261
+
1262
+ ## Fix
1263
+ ```jsonc
1264
+ { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
1265
+ ```
1266
+ Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
1267
+
1268
+ ```jsonc
1269
+ { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
1270
+ ```
1271
+
1272
+ ### use-unknown-in-catch-variables
1273
+
1274
+ - **Flags beyond the symptom:** edition 1: a flag set to `true`.
1275
+ - **Misses:** edition 1: a base reached by `extends`.
1276
+ - **Settings traced to:** flag list: The type checker proves it. Edition 1 flags presence, which is the Shared strict base config recipe: **traced to a recipe, not a rule**.
1277
+
1278
+ `useUnknownInCatchVariables` is set in a `tsconfig.json`; edition 2 adds that it resolves to on.
1279
+
1280
+ ## Flags
1281
+ Each strictness-weakened check has two editions. Edition 1 runs by default. Edition 2 also judges what each `tsconfig.json` inherits, and becomes the default in the next major release; see [Settings](#settings) to run it now.
1282
+
1283
+ Edition 1:
1284
+ - `tsconfig.json` files, named exactly, at any depth. `tsconfig.base.json` and other names are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1285
+ - For each selected clause, the matching option present in that file's `compilerOptions`. Presence is enough: `true` is flagged as well as `false`.
1286
+ - Options in `extends`-ed files are not seen. A file that cannot be parsed, or whose root or `compilerOptions` is not an object, fails the run.
1287
+
1288
+ Edition 2 also flags, for each selected option a `tsconfig.json` does not set itself, an option its resolved configuration leaves off:
1289
+ - The configuration is resolved by the repository's installed TypeScript, as `tsc` would resolve it: every file in the `extends` chain, a relative path, a package such as `@tsconfig/strictest` or a workspace package under `node_modules`, and an array of bases on TypeScript 5.0 or later, later bases winning. An option a base turns on and a later file turns off is off.
1290
+ - `strict` and `useUnknownInCatchVariables` take TypeScript's defaults: TypeScript 6 treats `strict` as on when nothing sets it, and `useUnknownInCatchVariables` follows `strict` unless it is set.
1291
+ - The finding names the file to edit. `= false, inherited from <base>` names each base that turns the option off. `= false, turned off in <file>` names this `tsconfig.json` when its own `"strict": false` turns `useUnknownInCatchVariables` off. `unset here and in <bases>` lists every file in the chain, none of which sets the option; `unset, and this file extends no base` says there is no chain.
1292
+ - A configuration TypeScript cannot resolve, such as a base file that is missing, a package that is not installed, or bases that extend each other, is flagged for each selected option the file does not set as `unknown`, followed by TypeScript's own diagnostic. An `extends` holding `${configDir}` resolves however the installed TypeScript resolves it, and is flagged the same way when TypeScript cannot find it. Fix the chain, and the options are judged.
1293
+ - The base files are judged through the `tsconfig.json` files that extend them, not on their own.
1294
+ - A `tsconfig.json` from which TypeScript would compile no file is not judged on what it resolves to, since its options apply to no file. After resolving the chain, TypeScript has no `files` entry, and no `include` entry that names a path outright or a folder or pattern it would search. Examples: an empty `files` list, its own or inherited, with no `include`, such as the solution-style root with only `references` that `npm create vite` writes; an empty `include`; an `exclude` of every file. Any non-empty `include` that names a file or a folder is still judged, such as `"include": ["vite.config.ts"]` or `["src"]`, and so is a config that sets neither `files` nor `include`, since TypeScript then includes every file. An option a skipped file sets itself is still flagged, as in edition 1. The configs it references are not judged through it; only files named `tsconfig.json` are read.
1295
+
1296
+ ## Settings
1297
+ - `edition`: the edition this clause runs, `"1"` or `"2"`. Without it, the clause runs edition 1, or the latest edition when `checkEditions` in `disciplines.json` is `"latest"`.
1298
+
1299
+ ```jsonc
1300
+ "clauseSettings": {
1301
+ "CD-3#use-unknown-in-catch-variables": { "edition": "2" }
1302
+ }
1303
+ ```
1304
+
1305
+ ## Example
1306
+ ```jsonc
1307
+ { "compilerOptions": { "strict": false } }
1308
+ ```
1309
+
1310
+ ## Fix
1311
+ ```jsonc
1312
+ { "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
1313
+ ```
1314
+ Put the flags in a shared base file that is not named `tsconfig.json`, and leave them out of every `tsconfig.json`. Under edition 1, that the base file turns them on is left to review. Under edition 2 the check reads the base: turn every selected flag on in it.
1315
+
1316
+ ```jsonc
1317
+ { "compilerOptions": { "strict": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "noImplicitOverride": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "useUnknownInCatchVariables": true } }
1318
+ ```
1319
+
1320
+ ## Tangled function
1321
+
1322
+ ### cognitive-complexity
1323
+
1324
+ - **Settings traced to:** complexity 15: where a broad symptom fires (as above).
1325
+
1326
+ A function whose cognitive complexity is above 15.
1327
+
1328
+ ## Flags
1329
+
1330
+ - The ESLint piece lints whatever files the team's ESLint run includes. It needs ESLint adopted through the projection; see the ESLint piece.
1331
+ - Under ESLint, each function's cognitive complexity must be at most 15.
1332
+ - An `if`, `else if`, `switch`, ternary, `catch` and each loop adds 1 plus the current nesting depth.
1333
+ - An `else`, a `finally`, a labelled `break` or `continue`, and each run of the same logical operator add 1.
1334
+ - Nesting deepens inside `if`, loops, `switch`, `catch` and ternaries.
1335
+ - A nested function is scored on its own, starting one level deeper, and its score is not added to its parent.
1336
+ - Reported at the function's name.
1337
+
1338
+ ## Example
1339
+
1340
+ ```ts
1341
+ const settle = (orders: Order[]) => {
1342
+ for (const order of orders) {
1343
+ if (order.paid) {
1344
+ for (const line of order.lines) {
1345
+ if (line.refundable && line.quantity > 0) {
1346
+ refund(line);
1347
+ }
1348
+ }
1349
+ }
1350
+ }
1351
+ };
1352
+ ```
1353
+
1354
+ ## Fix
1355
+
1356
+ ```ts
1357
+ const settle = (orders: Order[]) => orders.filter(isPaid).forEach(refundEligibleLines);
1358
+ ```
1359
+ Move any computing or branching between calls into a named doer, so the orchestrator only composes calls.
1360
+
1361
+ ## Test switched off
1362
+
1363
+ ### focused-tests
1364
+
1365
+ - **Misses:** `.todo`.
1366
+ - **Settings traced to:** `.todo` not flagged: a miss.
1367
+
1368
+ `.only` on a test or suite, or `fdescribe`, `fit`, `ftest`, `fsuite`.
1369
+
1370
+ ## Flags
1371
+ Needs ESLint adopted through the projection.
1372
+ - Under ESLint, this check flags `.only` on a `describe`, `it`, `test` or `suite` chain, including `.only.each` and `test.describe.only`, and the bare names `fdescribe`, `fit`, `ftest` and `fsuite`. It reports at the `only` token.
1373
+ - Not flagged: `.todo`, `.concurrent` and `.each`.
1374
+
1375
+ ### skipped-tests
1376
+
1377
+ - **Misses:** `.todo`.
1378
+ - **Settings traced to:** `.todo` not flagged: a miss.
1379
+
1380
+ `.skip` or `.fixme` on a test or suite, or `xdescribe`, `xit`, `xtest`, `xsuite`.
1381
+
1382
+ ## Flags
1383
+ Needs ESLint adopted through the projection.
1384
+ - Under ESLint, this check flags `.skip` and `.fixme` on those chains, and the bare names `xdescribe`, `xit`, `xtest` and `xsuite`.
1385
+ - Not flagged: `.todo`, `.concurrent` and `.each`.
1386
+
1387
+ ## Text past its reader
1388
+
1389
+ ### test-body
1390
+
1391
+ - **Misses:** production sites.
1392
+ - **Settings traced to:** the edition: backwards compatibility for adopters since the npm release.
1393
+
1394
+ Edition 2: `JSON.stringify` and `JSON.parse` in a test file. These run with the other [test-body checks](../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
1395
+
1396
+ ## Flags
1397
+ Edition 2:
1398
+ - `JSON.stringify` and `JSON.parse`. A finding names [Serialising or parsing JSON](#serialising-or-parsing-json).
1399
+
1400
+ ## Allowed forms in a test
1401
+
1402
+ ### Serialising or parsing JSON
1403
+ ```ts
1404
+ declare const render: (row: { readonly id: string }) => string;
1405
+ expect(JSON.parse(render({ id: "a" }))).toEqual({ id: "a" });
1406
+ ```
1407
+ A finding on `JSON.stringify` or `JSON.parse` names this section. Assert the object the unit gives back, written out:
1408
+
1409
+ ```ts
1410
+ declare const rowOf: (row: { readonly id: string }) => { readonly id: string };
1411
+ expect(rowOf({ id: "a" })).toEqual({ id: "a" });
1412
+ ```
1413
+
1414
+ A unit that gives back only text should hand over an object, leaving the text to the adapter at its edge.
1415
+
1416
+ ## Throw or catch in a test
1417
+
1418
+ ### throw-statement
1419
+
1420
+ - **Misses:** `catch`.
1421
+ - **Settings traced to:** none.
1422
+
1423
+ A `throw` statement in a test file.
1424
+
1425
+ ## Flags
1426
+ - Test files only: `*.test.ts` and `*.test.tsx`. `*.spec.ts` and `.js` tests are not read. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1427
+ - Every `throw` statement, wherever it sits in the file.
1428
+ - Allowed: assertion calls such as `expect(...)`.
1429
+ - The source rule also confines throwing in production code to a closed list of contexts. The check does not look at production files; that part is left to review.
1430
+
1431
+ ## Example
1432
+ ```ts
1433
+ it("loads the account", () => {
1434
+ const result = load("a1");
1435
+ if (result.outcome === "failed") throw new Error("load failed");
1436
+ });
1437
+ ```
1438
+
1439
+ ## Fix
1440
+ ```ts
1441
+ it("loads the account", () => {
1442
+ expect(load("a1")).toEqual({ outcome: "ok", value: account });
1443
+ });
1444
+ ```
1445
+ Assert on the whole result. Branching in tests is also reported by [the branch-in-a-test check](symptoms/branch-in-a-test/test-body.md).
1446
+
1447
+ ### try-block
1448
+
1449
+ - **Misses:** `catch`.
1450
+ - **Settings traced to:** none.
1451
+
1452
+ `try` statements in a test file. These run with the other [test-body checks](../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
1453
+
1454
+ ## Flags
1455
+ Edition 1:
1456
+ - `try` statements.
1457
+
1458
+ ## Allowed forms in a test
1459
+
1460
+ ### A try block
1461
+ ```ts
1462
+ declare const load: (path: string) => string;
1463
+ try {
1464
+ load("missing.json");
1465
+ } catch (error) {
1466
+ expect(error).toBeInstanceOf(Error);
1467
+ }
1468
+ ```
1469
+ Assert the throw:
1470
+
1471
+ ```ts
1472
+ declare const load: (path: string) => string;
1473
+ expect(() => load("missing.json")).toThrow(Error);
1474
+ ```
1475
+
1476
+ ```ts
1477
+ declare const loadLater: (path: string) => Promise<string>;
1478
+ it("refuses a missing file", async () => {
1479
+ await expect(loadLater("missing.json")).rejects.toThrow(Error);
1480
+ });
1481
+ ```
1482
+
1483
+ ## Thrown non-error
1484
+
1485
+ ### throw-only-error
1486
+
1487
+ - **Settings traced to:** none.
1488
+
1489
+ A `throw` of something that is not an error object.
1490
+
1491
+ ## Flags
1492
+ Needs ESLint adopted through the projection.
1493
+ - Under ESLint, a `throw` of a literal, an object literal, a binary expression, a template or tagged template, or `undefined` is flagged. It follows the thrown value through `a ? b : c`, `a || b`, assignment and sequence expressions.
1494
+ - Allowed: `new Error(...)`, identifiers, calls and member access.
1495
+ - This clause applies to every file the ESLint run includes, not only tests.
1496
+
1497
+ ## Type derived from code
1498
+
1499
+ ### factory-return-types
1500
+
1501
+ - **Flags beyond the symptom:** text in comments.
1502
+ - **Misses:** `Parameters<typeof>`, `typeof` alone.
1503
+ - **Settings traced to:** none.
1504
+
1505
+ A line containing `ReturnType<typeof`.
1506
+
1507
+ ## Flags
1508
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1509
+ - Any line matching `ReturnType<typeof`, one finding per line. This includes `Awaited<ReturnType<typeof ...>>` and matches inside strings.
1510
+ - Lines starting with `//`, `/*` or `*` are ignored. A `ReturnType<` and `typeof` split across lines are not seen.
1511
+ - The source rule's carve-out, an external library symbol with no exported return type, is not detected; record it as an exception.
1512
+
1513
+ ## Example
1514
+ ```ts
1515
+ type Client = ReturnType<typeof createClient>;
1516
+ ```
1517
+
1518
+ ## Fix
1519
+ ```ts
1520
+ export type Client = { readonly send: (message: string) => void };
1521
+ const createClient = (): Client => ({ send: () => undefined });
1522
+ ```
1523
+ Declare and export the type, then annotate the factory with it.
1524
+
1525
+ ## Unit without a running test
1526
+
1527
+ ### companion-test-file
1528
+
1529
+ - **Misses:** an empty or non-running sibling.
1530
+ - **Settings traced to:** `__tests__` skipped by default, on purpose (noise; the practice is not adopted). `exclude` is scope.
1531
+
1532
+ A production file with a runtime export and no `.test` sibling.
1533
+
1534
+ ## Flags
1535
+
1536
+ - Production `.ts` and `.tsx` files. Skipped: `*.test.ts(x)`, `.d.ts` and anything under `__tests__`. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped; any other folder or file can be left out with `exclude` in disciplines.json.
1537
+ - A file with a runtime export (`export const`, `function`, `class`, `enum`, `export default`, or `export { name }`) and no `<name>.test.ts` beside it (`<name>.test.tsx` for `.tsx`). The sibling must be in the repository's file list.
1538
+ - Allowed: files with only `export type`, `export interface`, `export declare`, type-only named exports or `export * from`, and files with no exports.
1539
+ - The source rule asks for a test beside every source file; files without runtime exports are left to review.
1540
+
1541
+ ## Example
1542
+
1543
+ ```ts
1544
+ export const price = 1;
1545
+ ```
1546
+ This is `src/price.ts` with no `src/price.test.ts` beside it.
1547
+
1548
+ ## Fix
1549
+
1550
+ Add `src/price.test.ts` next to the file, with at least one test of its behaviour.
1551
+
1552
+ ## Untracked escape
1553
+
1554
+ ### directive-pointers
1555
+
1556
+ - **Settings traced to:** reference form "need a digit": **nothing**.
1557
+
1558
+ TODOs, linter directives and `@ts-expect-error` without a tracker.
1559
+
1560
+ ## Flags
1561
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1562
+ - `// TODO` not followed, after optional spaces, by a tracked reference, for example `// TODO(#42) ...`.
1563
+ - A comment starting with `biome-ignore`, `eslint-disable`, `eslint-enable`, `eslint-disable-line`, `eslint-disable-next-line`, an `oxlint-` equivalent or `eslint <config>`, unless the comment carries a tracked reference.
1564
+ - A TypeScript directive without a tracked reference after it, in each form the compiler honours: `@ts-expect-error` or `@ts-ignore` opening a `//` or `///` comment, or opening the last line of a block comment after any `/` and `*`; and `@ts-nocheck`, in any letter case, opening a `//` or `///` comment among the comments that start the file. As in the compiler, `@ts-ignore` and `@ts-expect-error` are matched as written, so `@ts-ignored` counts and `@Ts-Ignore` does not. Forms the compiler ignores, such as `/* @ts-nocheck */`, a directive above a block comment's closing line, or `////`, are not flagged. `@ts-check` turns checking on and is not flagged.
1565
+ - A tracked reference is a parenthesised token with no spaces that contains a digit, such as `(#42)`, `(PROJ-7)`, `(spec-42)` or `(https://tracker.example/issues/42)`. `()`, `(legacy)` and `(issue 42)` are not tracked references.
1566
+ - TODO is matched on raw lines, so the same text inside a string is flagged too; linter and type directives are read from comments only.
1567
+ - Ordinary explanatory comments and JSDoc are not flagged; keeping them out is left to review.
1568
+
1569
+ ## Settings
1570
+ `trackerPatterns` narrows which tracked references count, for example to your own tracker's format. Each entry is a regular expression, as JavaScript source text, tested against each tracked reference with its parentheses; a reference counts when any entry matches. The test is an unanchored search unless the pattern anchors itself with `^` and `$`. The default, `["^\\(\\S+\\)$"]`, lets every tracked reference count.
1571
+
1572
+ ```jsonc
1573
+ "clauseSettings": {
1574
+ "CD-5#comments-directives": { "trackerPatterns": ["^\\(spec-\\d+\\)$", "^\\(#\\d+\\)$"] }
1575
+ }
1576
+ ```
1577
+
1578
+ The patterns only narrow: a reference must still be a parenthesised token with no spaces that contains a digit, so a pattern such as `.*` cannot make `(legacy)` count. The same measure applies to TODO, where the reference must come right after `TODO`. Each entry must be a non-empty string that compiles as a regular expression; otherwise the check stops with a piece-invalid failure naming the clause and the entry.
1579
+
1580
+ ## Example
1581
+ ```ts
1582
+ // biome-ignore lint/style/noNonNullAssertion: legacy
1583
+ const first = items[0]!;
1584
+ ```
1585
+
1586
+ ## Fix
1587
+ ```ts
1588
+ const first = items[0];
1589
+ ```
1590
+ Remove the need for the directive. If it must stay, add a tracked reference to the work that removes it: `// biome-ignore lint/style/noNonNullAssertion: until items is typed as non-empty (#42)`. The reference satisfies this clause only. A directive that escapes a selected clause, such as an `eslint-disable` naming a selected rule or a `@ts-expect-error` under [unlisted-cast-site](symptoms/claimed-type/unlisted-cast-site.md), still needs a file record on that clause, and that record does not satisfy this clause.
1591
+
1592
+ ## Untyped value
1593
+
1594
+ ### explicit-any
1595
+
1596
+ - **Settings traced to:** none.
1597
+
1598
+ An `any` type anywhere in a type position.
1599
+
1600
+ ## Flags
1601
+ Needs ESLint adopted through the projection.
1602
+ - Under ESLint, this is typescript-eslint's `no-explicit-any` with default options. It flags every `any` type: annotations, type arguments such as `Map<string, any>`, and `as any`.
1603
+ - Allowed: `unknown`, `let total = 0` and `let total: number`.
1604
+
1605
+ ### implicit-any-let
1606
+
1607
+ - **Settings traced to:** none.
1608
+
1609
+ A `let` or `var` with neither a type annotation nor an initialiser.
1610
+
1611
+ ## Flags
1612
+ Needs ESLint adopted through the projection.
1613
+ - Under ESLint, this flags a `let` or `var` declaration in a `.ts` or `.tsx` file that has neither a type annotation nor an initialiser, one report per declaration at its first such binding. Declaration files (`.d.ts`), `const`, and `for-in` and `for-of` heads are not flagged.
1614
+ - Allowed: `unknown`, `let total = 0` and `let total: number`.
1615
+
1616
+ ## Work inside a condition
1617
+
1618
+ ### else-after-an-exit
1619
+
1620
+ - **Misses:** an `if` nested with no `else`.
1621
+ - **Settings traced to:** none.
1622
+
1623
+ An `else` after an `if` branch that always exits.
1624
+
1625
+ ## Flags
1626
+
1627
+ - The ESLint piece lints whatever files the team's ESLint run includes. It needs ESLint adopted through the projection; see the ESLint piece.
1628
+ - Under ESLint, an `else` after an `if` branch that always exits is reported at the `else` keyword.
1629
+ - A branch always exits when it ends in `return`, `throw`, `continue`, or `break` outside a switch. A nested `if` exits when both of its branches do. A `switch` exits when every non-empty case does.
1630
+ - Along an `else if` chain whose earlier branches all exit, every `else` is reported.
1631
+ - Allowed: an `else` after a branch that can fall through.
1632
+
1633
+ ## Example
1634
+
1635
+ ```ts
1636
+ const label = (order: Order) => {
1637
+ if (order.cancelled) {
1638
+ return "cancelled";
1639
+ } else {
1640
+ return "active";
1641
+ }
1642
+ };
1643
+ ```
169
1644
 
170
- A default that quietly narrows a rule, which no codebase chose, still fails.
1645
+ ## Fix
171
1646
 
172
- **Settings that change what a rule requires today:**
1647
+ ```ts
1648
+ const label = (order: Order) => {
1649
+ if (order.cancelled) return "cancelled";
1650
+ return "active";
1651
+ };
1652
+ ```
1653
+ Handle the unhappy path first with an early return and leave the happy path as the final return.
173
1654
 
174
- | Setting | What it changes | Traced to |
175
- |---|---|---|
176
- | Strictness edition 1 flags a flag's presence | requires the recipe's layout, not strictness | a recipe, not a rule. "The older strictness check is probably just a flaw." |
177
- | `.todo` not flagged | a test that does not run passes | a miss. "Todo not flagged is probably just a false negative." |
178
- | Accepted helper names | The subprocess-environment check passes a git spawn when its `env:` option mentions one of three hard-coded identifiers: `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`. It matches the name, not what the value holds, so any variable called `environment` passes. | nothing; a margin of the check (it misses by name) |
179
- | Casing fixed inside Hone | Today file names must be kebab-case or PascalCase, both allowed everywhere, hard-coded. Identifier casing is a fixed option list in Hone's own piece, built on typescript-eslint's naming-convention. The adopter declares neither. | nothing. "Casing should be config from adopter to declare for consistency but requires the folder nuance settings." |
180
- | Tracked-reference form | which TODO counts as tracked | nothing yet |
1655
+ ## Write into a parameter
181
1656
 
182
- **Settings that do not:**
1657
+ ### parameter-mutation
183
1658
 
184
- | Setting | Why |
185
- |---|---|
186
- | 50-line limit, complexity 15 | where two broad symptoms fire; they change no rule |
187
- | `max-params: 2` | a recorded compromise of the check; its miss is margin |
188
- | `exclude` | scope chosen by the codebase |
189
- | Edition defaults | "Edition defaults would be for backwards compatability since we went npm." An existing adopter keeps the behaviour it installed. |
190
- | `confinedPackages` empty by default | "packages is empty because we can't define the universe and if we just said imports at all we would catch internal packages." Seeing every outside dependency needs a way to tell it from an internal package; until then the list is the adopter's to fill. |
191
- | `__tests__` skipped by default | "probably because of noise level and the fact I don't adopt that folder practice deliberately at all." |
192
- | `.spec.ts` not treated as a test file by most checks | "Spec is also just not a naming practice I use." Then: "It honestly should be config for user to declare file naming structure so we can match their conventions." Hone has no such config yet; the Companion test file and Integration test suffix recipes are the convention it reads. |
193
- | Generated folders skipped (`node_modules`, `dist` and the like) | not code of ours |
194
- | Reading `.test.js` and `.test.mjs` in the subprocess-environment check | it widens one check, not narrows a rule |
195
- | Suite-body exemption | "A test suite's body is a list of cases, not a coordinator." |
196
- | Drawer names | Screaming folders |
197
- | Shorthand list | Whole words |
198
- | `as const` | Declared, not asserted |
199
- | Integration suffix | its recipe |
1659
+ - **Settings traced to:** none.
200
1660
 
201
- ## Folder-scoped settings
1661
+ Assignment to, deletion from or in-place methods on a parameter's fields.
202
1662
 
203
- Hone has no folder-scoped settings yet. "glob or folder specific ruleset settings would be useful to smooth those" (React beside a Node server; GraphQL types generated in a boundary folder).
1663
+ ## Flags
204
1664
 
205
- Checks whose convention can differ by folder in one repository:
206
- - **Name off its casing.** Identifier and file-name conventions: a React folder's PascalCase components beside a Node server's kebab-case files.
207
- - **Generated code at a boundary.** Checks that would read an outside generator's output as ours: Shorthand name, Name off its casing, Prose in code, Claimed type, Untyped value, Type derived from code, Unit without a running test.
1665
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
1666
+ - Inside a function declaration, function expression, arrow function or method, where the root name is one of its parameters (including destructured and outer-function parameters):
1667
+ - `parameter.field = value` and `parameter.a[0].b = value`
1668
+ - `delete parameter.field`
1669
+ - `parameter.push(...)`, `pop`, `shift`, `unshift`, `splice`, `sort`, `reverse`, `fill`, `copyWithin`
1670
+ - Not detected: reassigning the parameter, `+=` and `++`, `Map.set`, and mutation through an alias (`const copy = input; copy.x = 1`).
208
1671
 
209
- What a folder-scoped setting does:
210
- - It **smooths** a second convention, by choosing which convention a check measures a folder against.
211
- - It **marks generated code** as an outside party's code at a boundary, under that boundary's record.
1672
+ ## Example
212
1673
 
213
- What it must not be able to do:
214
- - **Switch a rule off for a folder.** That is a record: an authorised location with its why, or debt.
215
- - **Change what a rule means.** For example, a looser line limit, a wider parameter count or a narrower test-file definition for a folder.
1674
+ ```ts
1675
+ const addTotal = (order: Order) => {
1676
+ order.total = 10;
1677
+ };
1678
+ ```
216
1679
 
217
- So a setting never deselects a clause and never carries debt.
1680
+ ## Fix
218
1681
 
219
- `exclude` is different again. It is scope, outside the model. It needs no rule sentence and no record.
1682
+ ```ts
1683
+ const withTotal = (order: Order): Order => ({ ...order, total: 10 });
1684
+ ```
1685
+ Copy before sorting or reversing: `[...items].sort()`.