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

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 +219 -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,52 @@
1
+ import "../../../../chunks/chunk-NZLE2WMY.js";
2
+
3
+ // mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.ts
4
+ var NAME_CASE = /^(?:[a-z0-9]+(?:-[a-z0-9]+)*|[A-Z](?:[A-Za-z0-9]*[a-z][A-Za-z0-9]*|[0-9]*))$/u;
5
+ var ROUTE_SEGMENT = /^(?:\[{1,2}(?:\.\.\.)?[A-Za-z0-9_-]+\]{1,2}|\([A-Za-z0-9_-]+\))/u;
6
+ var LEADING_MARKER = /^[.+$]/u;
7
+ var EDGE_UNDERSCORES = /^_+|_+$/gu;
8
+ var PATH_SEPARATOR = /[\\/]/u;
9
+ var segmentDisposition = (request) => NAME_CASE.test(request.segment) ? "conventional" : "unconventional";
10
+ var extensionsDisposition = (request) => request.extensions.every((segment) => segmentDisposition({ segment }) === "conventional") ? "conventional" : "unconventional";
11
+ var routeDisposition = (request) => {
12
+ const rest = request.name.slice(request.route.length);
13
+ if (rest === "") {
14
+ return "conventional";
15
+ }
16
+ return rest.startsWith(".") ? extensionsDisposition({ extensions: rest.slice(1).split(".") }) : "unconventional";
17
+ };
18
+ var plainDisposition = (request) => {
19
+ const [stem = "", ...extensions] = request.name.split(".");
20
+ return segmentDisposition({ segment: stem.replace(EDGE_UNDERSCORES, "") }) === "conventional" ? extensionsDisposition({ extensions }) : "unconventional";
21
+ };
22
+ var filenameDisposition = (request) => {
23
+ const name = request.basename.replace(LEADING_MARKER, "");
24
+ const route = ROUTE_SEGMENT.exec(name);
25
+ return route === null ? plainDisposition({ name }) : routeDisposition({ name, route: route[0] });
26
+ };
27
+ var filenameCase = {
28
+ meta: {
29
+ type: "suggestion",
30
+ docs: { description: "Require kebab-case or PascalCase file names (CD-7)" },
31
+ schema: [],
32
+ messages: {
33
+ filenameCase: "CD-7: name this file in kebab-case or PascalCase."
34
+ }
35
+ },
36
+ create: (context) => ({
37
+ Program: () => {
38
+ const basename = context.filename.split(PATH_SEPARATOR).at(-1) ?? "";
39
+ if (filenameDisposition({ basename }) === "conventional") {
40
+ return;
41
+ }
42
+ context.report({ loc: { line: 1, column: 0 }, messageId: "filenameCase" });
43
+ }
44
+ })
45
+ };
46
+ var cd7_eslint_plugin_default = {
47
+ meta: { name: "hone-cd7", version: "0.0.0-local" },
48
+ rules: { "filename-case": filenameCase }
49
+ };
50
+ export {
51
+ cd7_eslint_plugin_default as default
52
+ };
@@ -0,0 +1,15 @@
1
+ {
2
+ "version": 1,
3
+ "discipline": "CD-7",
4
+ "mechanism": "eslint",
5
+ "clauses": [
6
+ {
7
+ "clause": "filename-case",
8
+ "settings": {
9
+ "pluginNamespace": "hone-cd7",
10
+ "pluginModule": "cd7/cd7.eslint-plugin.js",
11
+ "rule": "filename-case"
12
+ }
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,43 @@
1
+ # ESLint runner
2
+
3
+ The ESLint runner is Hone's embedded mechanism: each selected clause runs as an ESLint rule inside the team's own ESLint setup. Its `exceptionPath` is `embedded`. Core hands it the selected clauses, the files to check, the repository's tracked paths and the exception records for this mechanism. The runner lints the files with its own configuration to find hits, reports every native channel in the team's setup that weakens a selected rule, and writes and checks the projection `disciplines.eslint.mjs` that carries the records into the team's own run. Its `projectedKinds` is `["config-override"]`, so a record can cover only that kind.
4
+
5
+ The native channels, the exception kind each maps to, and how the projection is adopted and checked are in [the guide](../../../docs/adding-a-discipline-or-mechanism.md#embedded-mechanisms).
6
+
7
+ The check compares the committed projection byte for byte with what the runner would write now. Built core is the installed package: the runner reads the package's `package.json` for its name, and the projection imports each piece inside it by package name, `<name>/mechanisms/eslint/...`, which resolves wherever the package is installed. A `package.json` that cannot be read or names no package is a `tool-failed` failure. Core run from source, as in its own tests, imports each piece by its path relative to the repository root. A piece outside the install, in the repository's own rule set, is always imported by relative path.
8
+
9
+ ## Runtime
10
+
11
+ - From source, Node 22.18.0 or later, which runs the `.ts` modules directly by stripping types. The built package is plain JavaScript.
12
+ - `zod`, for the piece settings, the loaded plugin, ESLint's resolved configuration and the files the runner reads. A dependency of core.
13
+ - `@eslint/plugin-kit`, for parsing inline configuration comments. A dependency of core, pinned at 0.7.3, because a transitive copy does not resolve under strict package managers.
14
+ - The repository's own toolchain, as optional peers: `eslint` `^9.12.0 || ^10.0.0`, and `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin` `^8.56.0`, the first typescript-eslint release whose peer range accepts both ESLint majors. TypeScript is the parser's own peer, so the runner does not check it. The runner loads them once, when it is loaded, and answers every call with `toolchain-unavailable` naming the first that is missing, cannot load or is out of range, or with `toolchain-shadowed` when one resolves from inside the installed core package, before it loads any piece. The suite runs on four lines: ESLint 9.12.0 and 10.0.0 with typescript-eslint 8.56.0, and ESLint 9.39.5 and 10.11.0 with 8.71.2.
15
+
16
+ ## Files
17
+
18
+ - `create-eslint-runner.ts` builds the runner from its ports: file text, module loading, paths and ESLint. It implements `run`, `conform` and `project`.
19
+ - `eslint-toolchain.ts` loads the toolchain for core's own ESLint run by dynamic imports of `eslint`, `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`, so a missing one becomes a named failure. It first asks where each resolves and fails as `toolchain-shadowed` for a copy inside the installed core package, then checks each version against its range, and hands the loaded `ESLint` class to `eslint-instance.ts`, which builds `createEslint` for that version. Core passes only options every supported release accepts: on ESLint 9 it asks for the nearest-to-file configuration lookup with the flag that release names, `unstable_config_lookup_from_file` before 9.30.0 and `v10_config_lookup_from_file` from 9.30.0, and ESLint 10 looks up that way by default. It never passes `applySuppressions`, which ESLint 9 and 10.0.0 refuse and which 10.11.0 accepts with a default of off.
20
+ - `eslint-instance.ts` is the port over a loaded toolchain, and takes only types from `eslint` and `@typescript-eslint/parser`. It builds `createEslint` on the loaded `ESLint` class and maps ESLint's results into the runner's own types. It builds a query instance on the team's own configuration, a governance instance on the runner's configuration only, and `lintSourceCases` for conformance. It also defines the reserved rule `<reservedNamespace>/inline-config`. `reservedNamespace` is the `reservedEslintNamespace` field of `core/values/tool-identity.ts`, currently `hone-core`, Hone's own namespace, distinct from every piece's `hone` and `hone-cd<N>` and independent of the package name; the reserved rule, the governance configuration and the projection's block names all take it from there.
21
+ - `inline-config-parser.ts` is the wrapping factory for `@eslint/plugin-kit`, the only file that imports it.
22
+ - `native-rules.ts` re-exports the ESLint core rules (`eslintCoreRules`) and the typescript-eslint rules (`typescriptEslintRules`) that pieces reuse. It is the only file that imports them, and it imports `eslint/use-at-your-own-risk` and `@typescript-eslint/eslint-plugin` statically, resolved upward from the install like the toolchain.
23
+ - `projection.ts` writes `disciplines.eslint.mjs` and compares it with the file on disk.
24
+ - `package-script-scanner.ts` finds ESLint invocations in tracked `package.json` scripts, and the options and `--suppressions-location` values they carry.
25
+ - `suppressions-scanner.ts` reads suppression entries from `eslint-suppressions.json` files and from files named by `--suppressions-location`.
26
+ - `eslint-piece-settings-schema.ts`, `eslint-plugin-schema.ts`, `eslint-config-schema.ts` and `eslint-file-schemas.ts` hold the schemas for a piece's settings, a loaded plugin module, ESLint's resolved configuration, and `package.json` and suppressions files.
27
+ - `runner.ts` is the runner core loads: the default ports, bound to the toolchain loaded from the install's own resolution.
28
+ - `piece-type-packages.json` lists the packages a piece may import types from, `["eslint"]`. It is not the runtime list above.
29
+ - `test-fixtures/` holds the consumer repositories that `native-exceptions.integration.test.ts` checks on real ESLint.
30
+
31
+ ## Writing a piece
32
+
33
+ An ESLint piece lives at `mechanisms/eslint/<DisciplineId>/` beside its `piece.json`. Each clause's settings are `{ "pluginNamespace", "pluginModule", "rule" }`. `pluginModule` is a `.ts` or `.js` path inside the piece folder whose default export is an ESLint plugin, and `rule` must be a key of its `rules`. The rule id is `<pluginNamespace>/<rule>`.
34
+
35
+ A clause's settings may also carry `options`, a JSON array passed to the rule after its severity. The governance run, the conformance run and the projection all enable the rule as `["error", ...options]`; without `options` the rule gets only the severity.
36
+
37
+ A piece reuses an ESLint core or typescript-eslint rule by re-exporting it from its plugin module through `native-rules.ts`: `eslintCoreRules` for core rules and `typescriptEslintRules` for typescript-eslint rules. A piece does not import `eslint` rules or `@typescript-eslint/eslint-plugin` directly.
38
+
39
+ Both take the rules to read from as `NativeRuleSources`. A piece that wraps native rules exports `createPlugin(sources)` and builds its default export from `defaultNativeRuleSources`, so a test can hand it the rules of another ESLint or typescript-eslint line. In an install the default sources are the copies that resolve from the repository root: the same copies core's own ESLint run loads. When a package in a monorepo lints with its own, different `eslint`, its run wraps the root's rules, not its own.
40
+
41
+ The namespace `reservedNamespace` names (currently `hone-core`) is reserved. Two selected clauses may not share a rule id, or a namespace with different plugin modules. A bad setting, a module that fails to load or does not match its schema, or a missing rule makes the run fail as `piece-invalid`.
42
+
43
+ The rule imports only types from `eslint` and gets everything else from ESLint's rule context. The guide (`docs/adding-a-discipline-or-mechanism.md`) walks through a shipped piece as the example.