@hailstails/hone 0.0.0-stage → 0.1.0-pre.2

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 (186) hide show
  1. package/ADOPTING.md +314 -0
  2. package/LICENSE +17 -0
  3. package/MIGRATING.md +238 -0
  4. package/README.md +216 -2
  5. package/THIRD-PARTY-NOTICES.md +354 -0
  6. package/chunks/chunk-233U4FBA.js +42 -0
  7. package/chunks/chunk-7ZJZZBSS.js +14909 -0
  8. package/chunks/chunk-HBY4ZWSP.js +79 -0
  9. package/chunks/chunk-HJA4CX7C.js +24 -0
  10. package/chunks/chunk-NZLE2WMY.js +35 -0
  11. package/chunks/chunk-QWA6OVLC.js +11 -0
  12. package/chunks/chunk-TRCB27ET.js +202 -0
  13. package/core/check/tool-command.js +2305 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +195 -0
  15. package/docs/why-chain-contract.md +78 -0
  16. package/mechanisms/audit/CD-1/any-cast.js +81 -0
  17. package/mechanisms/audit/CD-1/piece.json +13 -0
  18. package/mechanisms/audit/CD-10/piece.json +13 -0
  19. package/mechanisms/audit/CD-10/throws-in-tests.js +49 -0
  20. package/mechanisms/audit/CD-14/class-syntax.js +70 -0
  21. package/mechanisms/audit/CD-14/piece.json +13 -0
  22. package/mechanisms/audit/CD-15/loops.js +40 -0
  23. package/mechanisms/audit/CD-15/piece.json +13 -0
  24. package/mechanisms/audit/CD-17/clock-sources.js +29 -0
  25. package/mechanisms/audit/CD-17/piece.json +13 -0
  26. package/mechanisms/audit/CD-19/import-boundaries.js +80 -0
  27. package/mechanisms/audit/CD-19/piece.json +13 -0
  28. package/mechanisms/audit/CD-2/cast-expressions.js +81 -0
  29. package/mechanisms/audit/CD-2/piece.json +13 -0
  30. package/mechanisms/audit/CD-23/export-test-sibling.js +56 -0
  31. package/mechanisms/audit/CD-23/piece.json +13 -0
  32. package/mechanisms/audit/CD-25/dependency-isolation.js +53 -0
  33. package/mechanisms/audit/CD-25/piece.json +13 -0
  34. package/mechanisms/audit/CD-26/module-mocking.js +51 -0
  35. package/mechanisms/audit/CD-26/piece.json +13 -0
  36. package/mechanisms/audit/CD-27/piece.json +13 -0
  37. package/mechanisms/audit/CD-27/test-body-logic.js +107 -0
  38. package/mechanisms/audit/CD-3/compiler-overrides.js +955 -0
  39. package/mechanisms/audit/CD-3/piece.json +49 -0
  40. package/mechanisms/audit/CD-43/boolean-signatures.js +55 -0
  41. package/mechanisms/audit/CD-43/piece.json +13 -0
  42. package/mechanisms/audit/CD-44/parameter-mutation.js +92 -0
  43. package/mechanisms/audit/CD-44/piece.json +13 -0
  44. package/mechanisms/audit/CD-47/hermetic-git-spawns.js +44 -0
  45. package/mechanisms/audit/CD-47/piece.json +13 -0
  46. package/mechanisms/audit/CD-5/comments-directives.js +73 -0
  47. package/mechanisms/audit/CD-5/piece.json +13 -0
  48. package/mechanisms/audit/CD-6/identifier-names.js +132 -0
  49. package/mechanisms/audit/CD-6/piece.json +13 -0
  50. package/mechanisms/audit/CD-7/categorical-paths.js +55 -0
  51. package/mechanisms/audit/CD-7/piece.json +13 -0
  52. package/mechanisms/audit/CD-7a/factory-return-types.js +42 -0
  53. package/mechanisms/audit/CD-7a/piece.json +13 -0
  54. package/mechanisms/audit/CD-8/piece.json +13 -0
  55. package/mechanisms/audit/CD-8/switch-defaults.js +43 -0
  56. package/mechanisms/audit/runner/README.md +38 -0
  57. package/mechanisms/audit/runner/runner.js +546 -0
  58. package/mechanisms/eslint/CD-1/README.md +12 -0
  59. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +50 -0
  60. package/mechanisms/eslint/CD-1/piece.json +23 -0
  61. package/mechanisms/eslint/CD-10/README.md +9 -0
  62. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +55 -0
  63. package/mechanisms/eslint/CD-10/piece.json +15 -0
  64. package/mechanisms/eslint/CD-14/README.md +11 -0
  65. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +88 -0
  66. package/mechanisms/eslint/CD-14/piece.json +31 -0
  67. package/mechanisms/eslint/CD-27/README.md +12 -0
  68. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +83 -0
  69. package/mechanisms/eslint/CD-27/piece.json +23 -0
  70. package/mechanisms/eslint/CD-40/README.md +7 -0
  71. package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +16 -0
  72. package/mechanisms/eslint/CD-40/piece.json +21 -0
  73. package/mechanisms/eslint/CD-41/README.md +12 -0
  74. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +228 -0
  75. package/mechanisms/eslint/CD-41/piece.json +23 -0
  76. package/mechanisms/eslint/CD-42/README.md +9 -0
  77. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +75 -0
  78. package/mechanisms/eslint/CD-42/piece.json +15 -0
  79. package/mechanisms/eslint/CD-44/README.md +7 -0
  80. package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +16 -0
  81. package/mechanisms/eslint/CD-44/piece.json +20 -0
  82. package/mechanisms/eslint/CD-6/README.md +9 -0
  83. package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +16 -0
  84. package/mechanisms/eslint/CD-6/piece.json +217 -0
  85. package/mechanisms/eslint/CD-7/README.md +9 -0
  86. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +52 -0
  87. package/mechanisms/eslint/CD-7/piece.json +15 -0
  88. package/mechanisms/eslint/runner/README.md +43 -0
  89. package/mechanisms/eslint/runner/runner.js +4248 -0
  90. package/methods/README.md +18 -0
  91. package/methods/lenses/clean-architecture.md +167 -0
  92. package/methods/lenses/decomposition.md +159 -0
  93. package/methods/lenses/defended-on-intent.md +178 -0
  94. package/methods/lenses/di-discipline.md +156 -0
  95. package/methods/lenses/errors-as-data.md +88 -0
  96. package/methods/lenses/function-first.md +193 -0
  97. package/methods/lenses/naming.md +127 -0
  98. package/methods/lenses/test-discipline.md +166 -0
  99. package/methods/lenses/type-soundness.md +135 -0
  100. package/methods/lenses/zod-boundary.md +158 -0
  101. package/package.json +65 -4
  102. package/rules/CD-1/README.md +43 -0
  103. package/rules/CD-1/discipline.json +185 -0
  104. package/rules/CD-10/README.md +55 -0
  105. package/rules/CD-10/discipline.json +133 -0
  106. package/rules/CD-11/README.md +19 -0
  107. package/rules/CD-11/discipline.json +12 -0
  108. package/rules/CD-12/README.md +19 -0
  109. package/rules/CD-12/discipline.json +12 -0
  110. package/rules/CD-13/README.md +19 -0
  111. package/rules/CD-13/discipline.json +12 -0
  112. package/rules/CD-14/README.md +54 -0
  113. package/rules/CD-14/discipline.json +173 -0
  114. package/rules/CD-15/README.md +48 -0
  115. package/rules/CD-15/discipline.json +73 -0
  116. package/rules/CD-16/README.md +17 -0
  117. package/rules/CD-17/README.md +42 -0
  118. package/rules/CD-17/discipline.json +51 -0
  119. package/rules/CD-18/README.md +19 -0
  120. package/rules/CD-18/discipline.json +12 -0
  121. package/rules/CD-19/README.md +45 -0
  122. package/rules/CD-19/discipline.json +65 -0
  123. package/rules/CD-2/README.md +43 -0
  124. package/rules/CD-2/discipline.json +65 -0
  125. package/rules/CD-20/README.md +17 -0
  126. package/rules/CD-21/README.md +19 -0
  127. package/rules/CD-21/discipline.json +12 -0
  128. package/rules/CD-22/README.md +19 -0
  129. package/rules/CD-22/discipline.json +12 -0
  130. package/rules/CD-23/README.md +41 -0
  131. package/rules/CD-23/discipline.json +57 -0
  132. package/rules/CD-24/README.md +17 -0
  133. package/rules/CD-25/README.md +43 -0
  134. package/rules/CD-25/discipline.json +57 -0
  135. package/rules/CD-26/README.md +42 -0
  136. package/rules/CD-26/discipline.json +57 -0
  137. package/rules/CD-27/README.md +51 -0
  138. package/rules/CD-27/discipline.json +233 -0
  139. package/rules/CD-28/README.md +19 -0
  140. package/rules/CD-28/discipline.json +12 -0
  141. package/rules/CD-29/README.md +19 -0
  142. package/rules/CD-29/discipline.json +12 -0
  143. package/rules/CD-3/README.md +48 -0
  144. package/rules/CD-3/discipline.json +363 -0
  145. package/rules/CD-30/README.md +19 -0
  146. package/rules/CD-30/discipline.json +12 -0
  147. package/rules/CD-31/README.md +19 -0
  148. package/rules/CD-31/discipline.json +12 -0
  149. package/rules/CD-32/README.md +19 -0
  150. package/rules/CD-32/discipline.json +12 -0
  151. package/rules/CD-33/README.md +19 -0
  152. package/rules/CD-33/discipline.json +12 -0
  153. package/rules/CD-34/README.md +19 -0
  154. package/rules/CD-34/discipline.json +12 -0
  155. package/rules/CD-39/README.md +19 -0
  156. package/rules/CD-39/discipline.json +12 -0
  157. package/rules/CD-4/README.md +19 -0
  158. package/rules/CD-4/discipline.json +12 -0
  159. package/rules/CD-40/README.md +45 -0
  160. package/rules/CD-40/discipline.json +58 -0
  161. package/rules/CD-41/README.md +60 -0
  162. package/rules/CD-41/discipline.json +124 -0
  163. package/rules/CD-42/README.md +53 -0
  164. package/rules/CD-42/discipline.json +61 -0
  165. package/rules/CD-43/README.md +43 -0
  166. package/rules/CD-43/discipline.json +65 -0
  167. package/rules/CD-44/README.md +54 -0
  168. package/rules/CD-44/discipline.json +111 -0
  169. package/rules/CD-45/README.md +19 -0
  170. package/rules/CD-45/discipline.json +12 -0
  171. package/rules/CD-46/README.md +13 -0
  172. package/rules/CD-47/README.md +47 -0
  173. package/rules/CD-47/discipline.json +57 -0
  174. package/rules/CD-5/README.md +46 -0
  175. package/rules/CD-5/discipline.json +65 -0
  176. package/rules/CD-6/README.md +57 -0
  177. package/rules/CD-6/discipline.json +165 -0
  178. package/rules/CD-7/README.md +52 -0
  179. package/rules/CD-7/discipline.json +142 -0
  180. package/rules/CD-7a/README.md +44 -0
  181. package/rules/CD-7a/discipline.json +57 -0
  182. package/rules/CD-8/README.md +48 -0
  183. package/rules/CD-8/discipline.json +57 -0
  184. package/rules/CD-9/README.md +19 -0
  185. package/rules/CD-9/discipline.json +12 -0
  186. package/rules/README.md +52 -0
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-45",
4
+ "clauses": [
5
+ {
6
+ "kind": "judgement",
7
+ "id": "parse-once",
8
+ "summary": "validation runs once at the boundary and its types do not leak inward",
9
+ "enforcedBy": "review"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,13 @@
1
+ # CD-46: Touching a carved-out file revokes its carve-out — leave it clean
2
+
3
+ ## Rule
4
+
5
+ A suppression or exemption is inherited debt held at rest, not a standing licence: it buys "leave this file alone", nothing more. The moment a change edits an exempt file, that file forfeits its exemption — the change must bring the whole file into compliance for the exempted rule (the new lines and the pre-existing ones the exemption was masking) and remove the exemption entry, in the same change. There is no partial credit and no extracting the touched code into a clean helper while the exempt file stays dirty. If full compliance is out of scope, the move is to not touch the file. This rule governs how every other exemption decays and can never itself be exempted.
6
+
7
+ The sections below describe how the rule is checked.
8
+
9
+ Review lens: none. A reviewer applies the rule text directly.
10
+
11
+ ## How it is checked
12
+
13
+ This discipline has no clauses to select: the check applies it to every file carve-out. Run the check with `--base-revision`, and a `file-carve-out` record whose file changed since that revision is forfeited, so its findings come back and the run fails until the file is clean and the record is removed. Without `--base-revision`, any file carve-out makes the report list `forfeiture-unmeasured` and the run fails. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
@@ -0,0 +1,47 @@
1
+ # CD-47: Tests are hermetic — no real side effects on anything real
2
+
3
+ ## Rule
4
+
5
+ A test may not touch its environment or cause any real side effect on anything real. "Anything real" is everything the test did not itself create and does not itself dispose: the developer's repository, their user configuration and home directory, any network or live service, shared filesystem paths, the system clock, and the ambient process environment.
6
+
7
+ A test fakes the real subsystem. Spawning it is permitted in exactly one closed case: the subsystem's own observable behaviour is the assertion's subject and no fake can stand in for it. Setup, realism and convenience never qualify; state which assertion cannot be written against a fake, and if that sentence cannot be written, the test does not qualify. A qualifying test brings its own instance in a location it created and removes it afterwards; it never borrows the machine's.
8
+
9
+ Real git is the mechanically checked class: a test that spawns a real `git` subprocess passes an explicit hermetic environment at that call site, and never inherits the ambient one.
10
+
11
+ The sections below describe what the audit check covers.
12
+
13
+ ## Clauses
14
+
15
+ | Clause | Mechanism | Checks |
16
+ | --- | --- | --- |
17
+ | `CD-47#hermetic-git-spawns` | audit | a git spawn in a test without a hermetic `env` |
18
+
19
+ Review lens: [test-discipline](../../methods/lenses/test-discipline.md). The lens reviews the whole rule, including what no check flags.
20
+
21
+ ## What the check flags
22
+ - 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.
23
+ - A line calling `spawnSync`, `spawn`, `execFileSync`, `execFile`, `execSync`, `exec`, `execa` or `execaSync` with `"git"` (or `'git'`, or a template literal) as the first argument.
24
+ - Allowed when, within that line and the next seven, an `env:` names `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`, and no nearby `env:` uses `process.env`. The helper is yours to provide.
25
+ - 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.
26
+
27
+ ## Example violation
28
+ ```ts
29
+ spawnSync("git", ["init"], { cwd: directory });
30
+ ```
31
+
32
+ ## How to fix
33
+ ```ts
34
+ spawnSync("git", ["init"], { cwd: directory, env: hermeticGitEnvironment() });
35
+ ```
36
+ Build the environment without inherited git variables or the user's configuration, and run in a temporary directory.
37
+
38
+ ## Exceptions
39
+ Record exemptions only in `discipline-exceptions.json` at the repository root; core reads no other allowance file. Use `authorised-location` when a test file legitimately builds its environment another way. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
40
+
41
+ ```json
42
+ { "version": 1, "exceptions": [
43
+ { "kind": "authorised-location", "clause": "CD-47#hermetic-git-spawns", "file": "test/git-fixture.test.ts", "reason": "..." }
44
+ ] }
45
+ ```
46
+
47
+ Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -0,0 +1,57 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-47",
4
+ "clauses": [
5
+ {
6
+ "kind": "mechanical",
7
+ "id": "hermetic-git-spawns",
8
+ "summary": "Tests are hermetic — no real side effects on anything real",
9
+ "mechanisms": [
10
+ "audit"
11
+ ],
12
+ "anchor": {
13
+ "kind": "file"
14
+ },
15
+ "cases": {
16
+ "flag": [
17
+ {
18
+ "name": "spawnSync git without env",
19
+ "fileName": "init.test.ts",
20
+ "source": "spawnSync(\"git\", [\"init\"], { cwd: directory });\n",
21
+ "expectedLines": [
22
+ 1
23
+ ]
24
+ },
25
+ {
26
+ "name": "execSync git in a js test",
27
+ "fileName": "run.test.js",
28
+ "source": "execSync(\"git\", []);\n",
29
+ "expectedLines": [
30
+ 1
31
+ ]
32
+ }
33
+ ],
34
+ "allow": [
35
+ {
36
+ "name": "spawn with hermetic env",
37
+ "fileName": "hermetic.test.mjs",
38
+ "source": "spawn(\"git\", [], { env: hermeticGitEnvironment() });\n",
39
+ "expectedLines": []
40
+ },
41
+ {
42
+ "name": "non-git command",
43
+ "fileName": "other.test.ts",
44
+ "source": "spawnSync(\"node\", [\"--version\"], { cwd: directory });\n",
45
+ "expectedLines": []
46
+ },
47
+ {
48
+ "name": "git spawn in a production file",
49
+ "fileName": "helper.ts",
50
+ "source": "spawnSync(\"git\", [\"init\"], { cwd: directory });\n",
51
+ "expectedLines": []
52
+ }
53
+ ]
54
+ }
55
+ }
56
+ ]
57
+ }
@@ -0,0 +1,46 @@
1
+ # CD-5: No comments, no JSDoc
2
+
3
+ ## Rule
4
+
5
+ Code is self-documenting: the names, types, and schemas carry the meaning. A prose comment is almost always there to excuse an unclear name or a convoluted expression — so the fix is to clarify the code, not annotate it. The only permitted annotations are machine-meaningful directives that carry a tracked reference; explanatory comments and doc-comments are not.
6
+
7
+ The sections below describe what the audit check covers.
8
+
9
+ ## Clauses
10
+
11
+ | Clause | Mechanism | Checks |
12
+ | --- | --- | --- |
13
+ | `CD-5#comments-directives` | audit | TODOs, linter directives and `@ts-expect-error` without a tracker |
14
+
15
+ Review lens: [naming](../../methods/lenses/naming.md). The lens reviews the whole rule, including what no check flags.
16
+
17
+ ## What the check flags
18
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
19
+ - `// TODO` not followed by `(`. Any parenthesised text is accepted, for example `// TODO(spec-42) ...`.
20
+ - 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 contains `(spec-<number>)`.
21
+ - `// @ts-expect-error` on a line without `(spec-<number>)`.
22
+ - TODO and `@ts-expect-error` are matched on raw lines, so the same text inside a string is flagged too.
23
+ - Ordinary explanatory comments and JSDoc are not flagged; keeping them out is left to review.
24
+
25
+ ## Example violation
26
+ ```ts
27
+ // biome-ignore lint/style/noNonNullAssertion: legacy
28
+ const first = items[0]!;
29
+ ```
30
+
31
+ ## How to fix
32
+ ```ts
33
+ const first = items[0];
34
+ ```
35
+ Remove the need for the directive. If it must stay, add the tracker: `// biome-ignore lint/style/noNonNullAssertion: legacy (spec-42)`.
36
+
37
+ ## Exceptions
38
+ Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file legitimately carries untracked directives, such as generated code. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
39
+
40
+ ```json
41
+ { "version": 1, "exceptions": [
42
+ { "kind": "authorised-location", "clause": "CD-5#comments-directives", "file": "src/generated/schema.ts", "reason": "..." }
43
+ ] }
44
+ ```
45
+
46
+ Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -0,0 +1,65 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-5",
4
+ "clauses": [
5
+ {
6
+ "kind": "mechanical",
7
+ "id": "comments-directives",
8
+ "summary": "No comments, no JSDoc",
9
+ "mechanisms": [
10
+ "audit"
11
+ ],
12
+ "anchor": {
13
+ "kind": "file"
14
+ },
15
+ "cases": {
16
+ "flag": [
17
+ {
18
+ "name": "todo without tracker",
19
+ "fileName": "bare-todo.ts",
20
+ "source": "// TODO: rename this for clarity\nexport const someValue = 1;\n",
21
+ "expectedLines": [
22
+ 1
23
+ ]
24
+ },
25
+ {
26
+ "name": "biome-ignore without tracker",
27
+ "fileName": "bare-biome-ignore.ts",
28
+ "source": "export const portNumber = (): number => {\n // biome-ignore lint/style/noMagicNumbers: literal port\n return 8080;\n};\n",
29
+ "expectedLines": [
30
+ 2
31
+ ]
32
+ },
33
+ {
34
+ "name": "ts-expect-error without tracker",
35
+ "fileName": "expect-error.ts",
36
+ "source": "// @ts-expect-error\nexport const broken: number = \"text\";\n",
37
+ "expectedLines": [
38
+ 1
39
+ ]
40
+ }
41
+ ],
42
+ "allow": [
43
+ {
44
+ "name": "todo with spec tracker",
45
+ "fileName": "tracked-todo.ts",
46
+ "source": "// TODO(spec-42) rename this\nexport const someValue = 1;\n",
47
+ "expectedLines": []
48
+ },
49
+ {
50
+ "name": "biome-ignore with spec tracker",
51
+ "fileName": "tracked-ignore.ts",
52
+ "source": "// biome-ignore lint/style/noMagicNumbers: literal port (spec-7)\nexport const portNumber = 8080;\n",
53
+ "expectedLines": []
54
+ },
55
+ {
56
+ "name": "ordinary comment is left to review",
57
+ "fileName": "plain.ts",
58
+ "source": "// Ordinary prose remains outside this detector.\nexport type ProfileName = string;\n",
59
+ "expectedLines": []
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ ]
65
+ }
@@ -0,0 +1,57 @@
1
+ # CD-6: Meaningful names always — no shorthand, no filler words
2
+
3
+ ## Rule
4
+
5
+ A name states the concept the value represents, not its shape or its category. Shorthand (single letters, truncations) and filler words (data, info, value, result, manager, handler) force the reader to reconstruct meaning the name should have carried — at every scope, including callback parameters and destructures. The name is the documentation.
6
+
7
+ The sections below describe what the audit and ESLint checks cover.
8
+
9
+ ## Clauses
10
+
11
+ | Clause | Mechanism | Checks |
12
+ | --- | --- | --- |
13
+ | `CD-6#identifier-names` | audit | a binding named from a fixed shorthand or filler list |
14
+ | `CD-6#naming-convention` | eslint | a name that breaks the naming convention for its kind |
15
+
16
+ Review lens: [naming](../../methods/lenses/naming.md). The lens reviews the whole rule, including what no check flags.
17
+
18
+ ## What the check flags
19
+ - `.ts` and `.tsx` files, including tests; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
20
+ - 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):
21
+ - shorthand: `c op s cb fn tx e ev acc item k v el arr i j n obj val res req tmp temp`
22
+ - filler: `object obj args arguments details extra extras data info params parameters props payload body value result stuff things misc metadata`
23
+ - Allowed: longer names that contain these words (`accountData`), names starting with `_`, property keys and property accesses.
24
+ - Other poor names (`manager`, `handler`, vague nouns) are left to review.
25
+
26
+ ## What the ESLint check flags
27
+ Needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-6/README.md).
28
+ - `hone-cd6/naming-convention` is typescript-eslint's `naming-convention` with the option list in the piece's `piece.json`.
29
+ - Enum members are CONSTANT_CASE. `const` bindings are CONSTANT_CASE, camelCase or PascalCase.
30
+ - Object literal properties are camelCase. Type properties are camelCase or PascalCase.
31
+ - Other variables, functions and parameters are camelCase or PascalCase; a leading or trailing `_` or `$` is allowed.
32
+ - Types are PascalCase. Class members are camelCase, and static ones may also be CONSTANT_CASE.
33
+ - Consecutive capitals are allowed (`agentID`, `HTTPServer`).
34
+ - Ignored: names that need quotes, destructured bindings, imports and unused bindings whose name starts with `_`.
35
+ - 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.
36
+
37
+ ## Example violation
38
+ ```ts
39
+ const data = await loadAccount(id);
40
+ ```
41
+
42
+ ## How to fix
43
+ ```ts
44
+ const account = await loadAccount(id);
45
+ ```
46
+ Name the value for what it is in the domain.
47
+
48
+ ## Exceptions
49
+ Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file must keep a name fixed by an external contract. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
50
+
51
+ ```json
52
+ { "version": 1, "exceptions": [
53
+ { "kind": "authorised-location", "clause": "CD-6#identifier-names", "file": "src/adapters/legacy-feed.ts", "reason": "..." }
54
+ ] }
55
+ ```
56
+
57
+ Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -0,0 +1,165 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-6",
4
+ "clauses": [
5
+ {
6
+ "kind": "mechanical",
7
+ "id": "identifier-names",
8
+ "summary": "Meaningful names always — no shorthand, no filler words",
9
+ "mechanisms": [
10
+ "audit"
11
+ ],
12
+ "anchor": {
13
+ "kind": "file"
14
+ },
15
+ "cases": {
16
+ "flag": [
17
+ {
18
+ "name": "shorthand parameter",
19
+ "fileName": "bad-shorthand.ts",
20
+ "source": "export const handleRequest = (req: { readonly path: string }): string => {\n return req.path;\n};\n",
21
+ "expectedLines": [
22
+ 1
23
+ ]
24
+ },
25
+ {
26
+ "name": "filler variable",
27
+ "fileName": "filler.ts",
28
+ "source": "declare const loadAccount: () => string;\nexport const data = loadAccount();\n",
29
+ "expectedLines": [
30
+ 2
31
+ ]
32
+ },
33
+ {
34
+ "name": "destructured filler binding",
35
+ "fileName": "bad-destructure.ts",
36
+ "source": "export const summariseIncident = (report: { readonly body: string }): string => {\n const { body } = report;\n return body;\n};\n",
37
+ "expectedLines": [
38
+ 2
39
+ ]
40
+ }
41
+ ],
42
+ "allow": [
43
+ {
44
+ "name": "domain compound names",
45
+ "fileName": "domain-names.ts",
46
+ "source": "export const accountData = { greeting: \"hello\" };\nexport const renderGreeting = (incomingRequest: { readonly userName: string }): string => `Hello, ${incomingRequest.userName}`;\n",
47
+ "expectedLines": []
48
+ },
49
+ {
50
+ "name": "underscore-prefixed name",
51
+ "fileName": "unused.ts",
52
+ "source": "export const ignore = (_item: string): number => 1;\n",
53
+ "expectedLines": []
54
+ },
55
+ {
56
+ "name": "property key named data",
57
+ "fileName": "key.ts",
58
+ "source": "export const response = { data: 1 };\nexport const total = response.data;\n",
59
+ "expectedLines": []
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "kind": "mechanical",
66
+ "id": "naming-convention",
67
+ "summary": "Meaningful names always — no shorthand, no filler words",
68
+ "mechanisms": [
69
+ "eslint"
70
+ ],
71
+ "anchor": {
72
+ "kind": "keyword",
73
+ "keyword": "identifier"
74
+ },
75
+ "cases": {
76
+ "flag": [
77
+ {
78
+ "name": "snake_case function",
79
+ "fileName": "src/load.ts",
80
+ "source": "export function load_profile(): void {}\n",
81
+ "expectedLines": [
82
+ 1
83
+ ]
84
+ },
85
+ {
86
+ "name": "PascalCase enum member",
87
+ "fileName": "src/colour.ts",
88
+ "source": "export enum Colour {\n Red,\n}\n",
89
+ "expectedLines": [
90
+ 2
91
+ ]
92
+ },
93
+ {
94
+ "name": "snake_case object property",
95
+ "fileName": "src/settings.ts",
96
+ "source": "export const settings = { max_size: 1 };\n",
97
+ "expectedLines": [
98
+ 1
99
+ ]
100
+ },
101
+ {
102
+ "name": "lower-case type alias",
103
+ "fileName": "src/profile.ts",
104
+ "source": "export type profile = string;\n",
105
+ "expectedLines": [
106
+ 1
107
+ ]
108
+ },
109
+ {
110
+ "name": "snake_case let binding",
111
+ "fileName": "src/count.ts",
112
+ "source": "let item_count = 0;\nexport { item_count };\n",
113
+ "expectedLines": [
114
+ 1
115
+ ]
116
+ }
117
+ ],
118
+ "allow": [
119
+ {
120
+ "name": "CONSTANT_CASE const",
121
+ "fileName": "src/limits.ts",
122
+ "source": "export const MAX_SIZE = 10;\n",
123
+ "expectedLines": []
124
+ },
125
+ {
126
+ "name": "camelCase function",
127
+ "fileName": "src/load.ts",
128
+ "source": "export function loadProfile(): void {}\n",
129
+ "expectedLines": []
130
+ },
131
+ {
132
+ "name": "CONSTANT_CASE enum member",
133
+ "fileName": "src/colour.ts",
134
+ "source": "export enum Colour {\n RED,\n}\n",
135
+ "expectedLines": []
136
+ },
137
+ {
138
+ "name": "PascalCase type with camelCase property",
139
+ "fileName": "src/profile.ts",
140
+ "source": "export type Profile = { readonly displayName: string };\n",
141
+ "expectedLines": []
142
+ },
143
+ {
144
+ "name": "quoted property that is not an identifier",
145
+ "fileName": "src/headers.ts",
146
+ "source": "export const headers = { \"content-type\": \"json\" };\n",
147
+ "expectedLines": []
148
+ },
149
+ {
150
+ "name": "consecutive capitals in camelCase",
151
+ "fileName": "src/agent.ts",
152
+ "source": "export const agentID = \"a\";\n",
153
+ "expectedLines": []
154
+ },
155
+ {
156
+ "name": "unused underscore parameter",
157
+ "fileName": "src/ignore.ts",
158
+ "source": "export const ignore = (_unused_value: string): void => {};\n",
159
+ "expectedLines": []
160
+ }
161
+ ]
162
+ }
163
+ }
164
+ ]
165
+ }
@@ -0,0 +1,52 @@
1
+ # CD-7: No categorical filenames or folder names
2
+
3
+ ## Rule
4
+
5
+ A file or folder is named for the abstraction it holds, not for a category of things. A junk-drawer name (utils, helpers, common, shared, types, misc) signals a missing primitive: the code inside wants a real home named for what it does. Category names accrete unrelated code because anything can be justified into them.
6
+
7
+ The sections below describe what the audit and ESLint checks cover.
8
+
9
+ ## Clauses
10
+
11
+ | Clause | Mechanism | Checks |
12
+ | --- | --- | --- |
13
+ | `CD-7#categorical-paths` | audit | a forbidden file name or folder name in a path |
14
+ | `CD-7#filename-case` | eslint | a file name that is not kebab-case or PascalCase |
15
+
16
+ Review lens: [naming](../../methods/lenses/naming.md). The lens reviews the whole rule, including what no check flags.
17
+
18
+ ## What the check flags
19
+ - `.ts` and `.tsx` files only, judged by path; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
20
+ - 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`.
21
+ - Any folder in the path named `utils`, `helpers`, `common`, `lib`, `misc` or `shared`. Each file under such a folder is reported once for the folder.
22
+ - Allowed: `account-types.ts`, `Types.ts` and `types.tsx`, which are not exact matches.
23
+
24
+ ## What the ESLint check flags
25
+ Needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-7/README.md).
26
+ - `hone-cd7/filename-case` checks the file name before its first dot, after trimming edge `_`: it must be kebab-case or PascalCase. Each later dot segment must be kebab-case, PascalCase or lowercase.
27
+ - One leading `.`, `+` or `$` is ignored.
28
+ - Route names such as `[slug].ts` and `(group).ts` pass.
29
+ - A bad name is reported at line 1.
30
+
31
+ ## Example violation
32
+ ```text
33
+ src/helpers.ts
34
+ src/utils/format-price.ts
35
+ ```
36
+
37
+ ## How to fix
38
+ ```text
39
+ src/price-formatting.ts
40
+ ```
41
+ Rename the file or folder for what it contains, or split it into files that each hold one thing.
42
+
43
+ ## Exceptions
44
+ Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a path name is fixed by a framework or external convention. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
45
+
46
+ ```json
47
+ { "version": 1, "exceptions": [
48
+ { "kind": "authorised-location", "clause": "CD-7#categorical-paths", "file": "src/shared/index.ts", "reason": "..." }
49
+ ] }
50
+ ```
51
+
52
+ Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -0,0 +1,142 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-7",
4
+ "clauses": [
5
+ {
6
+ "kind": "mechanical",
7
+ "id": "categorical-paths",
8
+ "summary": "No categorical filenames or folder names",
9
+ "mechanisms": [
10
+ "audit"
11
+ ],
12
+ "anchor": {
13
+ "kind": "file"
14
+ },
15
+ "cases": {
16
+ "flag": [
17
+ {
18
+ "name": "categorical file name",
19
+ "fileName": "src/utils.ts",
20
+ "source": "export type ProfileName = string;\n",
21
+ "expectedLines": [
22
+ 1
23
+ ]
24
+ },
25
+ {
26
+ "name": "types file",
27
+ "fileName": "src/types.ts",
28
+ "source": "export type ProfileName = string;\n",
29
+ "expectedLines": [
30
+ 1
31
+ ]
32
+ },
33
+ {
34
+ "name": "file under a categorical folder",
35
+ "fileName": "src/helpers/format-price.ts",
36
+ "source": "export const formatPrice = (): string => \"\";\n",
37
+ "expectedLines": [
38
+ 1
39
+ ]
40
+ }
41
+ ],
42
+ "allow": [
43
+ {
44
+ "name": "hyphenated name containing types",
45
+ "fileName": "src/account-types.ts",
46
+ "source": "export type ProfileName = string;\n",
47
+ "expectedLines": []
48
+ },
49
+ {
50
+ "name": "capitalised name is not an exact match",
51
+ "fileName": "src/Types.ts",
52
+ "source": "export type ProfileName = string;\n",
53
+ "expectedLines": []
54
+ },
55
+ {
56
+ "name": "tsx extension is not an exact match",
57
+ "fileName": "src/types.tsx",
58
+ "source": "export type ProfileName = string;\n",
59
+ "expectedLines": []
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "kind": "mechanical",
66
+ "id": "filename-case",
67
+ "summary": "No categorical filenames or folder names",
68
+ "mechanisms": [
69
+ "eslint"
70
+ ],
71
+ "anchor": {
72
+ "kind": "file"
73
+ },
74
+ "cases": {
75
+ "flag": [
76
+ {
77
+ "name": "camelCase file name",
78
+ "fileName": "src/userProfile.ts",
79
+ "source": "export const value = 1;\n",
80
+ "expectedLines": [
81
+ 1
82
+ ]
83
+ },
84
+ {
85
+ "name": "snake_case file name",
86
+ "fileName": "src/user_profile.ts",
87
+ "source": "export const value = 1;\n",
88
+ "expectedLines": [
89
+ 1
90
+ ]
91
+ },
92
+ {
93
+ "name": "all-capitals file name",
94
+ "fileName": "src/README.ts",
95
+ "source": "export const value = 1;\n",
96
+ "expectedLines": [
97
+ 1
98
+ ]
99
+ }
100
+ ],
101
+ "allow": [
102
+ {
103
+ "name": "kebab-case file name",
104
+ "fileName": "src/user-profile.ts",
105
+ "source": "export const value = 1;\n",
106
+ "expectedLines": []
107
+ },
108
+ {
109
+ "name": "PascalCase file name",
110
+ "fileName": "src/UserProfile.tsx",
111
+ "source": "export const value = 1;\n",
112
+ "expectedLines": []
113
+ },
114
+ {
115
+ "name": "kebab-case test file",
116
+ "fileName": "src/user-profile.test.ts",
117
+ "source": "export const value = 1;\n",
118
+ "expectedLines": []
119
+ },
120
+ {
121
+ "name": "consecutive capitals in PascalCase",
122
+ "fileName": "src/HTTPServer.ts",
123
+ "source": "export const value = 1;\n",
124
+ "expectedLines": []
125
+ },
126
+ {
127
+ "name": "route segment",
128
+ "fileName": "src/[slug].ts",
129
+ "source": "export const value = 1;\n",
130
+ "expectedLines": []
131
+ },
132
+ {
133
+ "name": "lower-case index",
134
+ "fileName": "src/index.ts",
135
+ "source": "export const value = 1;\n",
136
+ "expectedLines": []
137
+ }
138
+ ]
139
+ }
140
+ }
141
+ ]
142
+ }