@hailstails/hone 2.0.0-pre.3 → 2.0.0-pre.4

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 (201) hide show
  1. package/ADOPTING.md +7 -7
  2. package/CHANGELOG.md +70 -0
  3. package/MIGRATING.md +15 -6
  4. package/README.md +12 -13
  5. package/chunks/chunk-3CWFUD5B.js +38 -0
  6. package/chunks/chunk-5AKHEW6V.js +15 -0
  7. package/chunks/chunk-75XWZYNN.js +64 -0
  8. package/chunks/chunk-7FVSZ2VL.js +1304 -0
  9. package/chunks/chunk-A3RL4O5V.js +146 -0
  10. package/chunks/chunk-BIDD2YWP.js +398 -0
  11. package/chunks/{chunk-GNOMK7CR.js → chunk-BKQ3K766.js} +489 -52
  12. package/chunks/{chunk-NRIQD3PI.js → chunk-BRANVR7K.js} +3 -5
  13. package/chunks/chunk-COQMPHWZ.js +37 -0
  14. package/chunks/{chunk-L7BGRC6D.js → chunk-CXM5KBZX.js} +1 -1
  15. package/chunks/chunk-D6645WPB.js +6 -0
  16. package/chunks/chunk-DJMF6JIM.js +42 -0
  17. package/chunks/{chunk-OKLYWD2Z.js → chunk-E4D5WDRX.js} +27 -20
  18. package/chunks/chunk-EBX57Z3V.js +8 -0
  19. package/chunks/chunk-FHVNKG5Q.js +19 -0
  20. package/chunks/chunk-FPIP7JEC.js +191 -0
  21. package/chunks/{chunk-QP5TLOBY.js → chunk-HVZVKZPW.js} +12 -9
  22. package/chunks/chunk-LD766VWU.js +57 -0
  23. package/chunks/chunk-LEFM7OPS.js +41 -0
  24. package/chunks/chunk-LNMDMRGQ.js +51 -0
  25. package/chunks/{chunk-RGSHTPLA.js → chunk-MBEDAFVC.js} +3 -11
  26. package/chunks/chunk-OO5KV7KN.js +17 -0
  27. package/chunks/{chunk-ASUN4AVC.js → chunk-PVSC4SE3.js} +71 -5
  28. package/chunks/chunk-SKDQ3QJD.js +75 -0
  29. package/chunks/chunk-W5OIAUDW.js +18 -0
  30. package/chunks/chunk-X73RZUPO.js +63 -0
  31. package/chunks/chunk-XE2KKWYH.js +45 -0
  32. package/chunks/chunk-YGMO5Z6U.js +432 -0
  33. package/chunks/chunk-YONPKP3C.js +15 -0
  34. package/docs/adding-a-discipline-or-mechanism.md +1 -1
  35. package/docs/extending.md +7 -388
  36. package/package.json +7 -6
  37. package/rules/README.md +2 -2
  38. package/rules/typescript/checks.md +236 -18
  39. package/rules/typescript/symptoms/ambient-randomness/random-call.md +10 -0
  40. package/rules/typescript/symptoms/answer-set-in-a-hook/hook-answer.md +10 -0
  41. package/rules/typescript/symptoms/assertion-outside-a-test/assertion-site.md +10 -0
  42. package/rules/typescript/symptoms/assertion-outside-a-test.md +25 -0
  43. package/rules/typescript/symptoms/built-unit-called-in-place/call-of-a-call.md +10 -0
  44. package/rules/typescript/symptoms/built-unit-called-in-place.md +25 -0
  45. package/rules/typescript/symptoms/code-or-prose-read-as-text/raw-read.md +10 -0
  46. package/rules/typescript/symptoms/code-or-prose-read-as-text.md +31 -0
  47. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +1 -1
  48. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -1
  49. package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +2 -2
  50. package/rules/typescript/symptoms/export-from-a-test-file/test-file-export.md +10 -0
  51. package/rules/typescript/symptoms/export-from-a-test-file.md +33 -0
  52. package/rules/typescript/symptoms/failure-shaped-as-success/empty-catch.md +10 -0
  53. package/rules/typescript/symptoms/floating-version/version-selector.md +10 -0
  54. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
  55. package/rules/typescript/symptoms/many-spellings-of-one-concept/test-call-aliases.md +10 -0
  56. package/rules/typescript/symptoms/many-spellings-of-one-concept.md +3 -2
  57. package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +4 -4
  58. package/rules/typescript/symptoms/no-lock-file/committed-lock-file.md +12 -0
  59. package/rules/typescript/symptoms/process-global-used-in-place/debugger-statement.md +10 -0
  60. package/rules/typescript/symptoms/process-global-used-in-place/direct-global-use.md +14 -0
  61. package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
  62. package/rules/typescript/symptoms/prose-in-code/comment-prose.md +12 -0
  63. package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +3 -6
  64. package/rules/typescript/symptoms/test-switched-off.md +1 -1
  65. package/rules/typescript/symptoms/throw-between-our-units/throw-statement.md +10 -0
  66. package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +1 -1
  67. package/rules/typescript/symptoms/tool-fetched-at-run-time/fetch-command.md +10 -0
  68. package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +10 -0
  69. package/rules/typescript/symptoms/type-declared-in-a-test.md +33 -0
  70. package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +2 -2
  71. package/rules/typescript/symptoms/wide-input/unread-parameter.md +10 -0
  72. package/rules/typescript/symptoms/wide-input.md +3 -2
  73. package/rules/typescript/symptoms.md +183 -121
  74. package/src/application/conformance/conformance-testing-types.d.ts +13 -16
  75. package/src/domain/language-layer/authored-item-types.d.ts +50 -0
  76. package/src/domain/language-layer/catalogue-name.d.ts +5 -0
  77. package/src/domain/language-layer/check-address-text.d.ts +12 -0
  78. package/src/domain/rule-set/authored-rule-set-types.d.ts +31 -32
  79. package/src/domain/rule-set/clause-address-types.d.ts +4 -3
  80. package/src/domain/rule-set/rule-set-name-of.d.ts +10 -0
  81. package/src/domain/runner/check-binding.d.ts +18 -0
  82. package/src/domain/runner/check-observations.d.ts +39 -0
  83. package/src/domain/runner/conformance-types.d.ts +8 -2
  84. package/src/domain/settings/test-files.d.ts +7 -0
  85. package/src/eslint-plugin.js +16 -12
  86. package/src/hone.js +10677 -10754
  87. package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +0 -6
  88. package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +0 -6
  89. package/src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-types.d.ts +2 -0
  90. package/src/infrastructure/engines/eslint/runner/runner.js +945 -1188
  91. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/README.md +0 -3
  92. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js +33 -21
  93. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +11 -4
  94. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +28 -0
  95. package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +0 -2
  96. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js +94 -0
  97. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/piece.json +11 -0
  98. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/unread-parameter.examples.json +48 -0
  99. package/src/infrastructure/engines/walker/ambient-randomness/random-call/ambient-randomness.js +109 -0
  100. package/src/infrastructure/engines/walker/ambient-randomness/random-call/piece.json +9 -0
  101. package/src/infrastructure/engines/walker/ambient-randomness/random-call/random-call.examples.json +48 -0
  102. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answer.examples.json +42 -0
  103. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answers.js +72 -0
  104. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/piece.json +9 -0
  105. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.examples.json +30 -0
  106. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.js +123 -0
  107. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/piece.json +9 -0
  108. package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-syntax.js +3 -3
  109. package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-signatures.js +7 -5
  110. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +169 -98
  111. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.examples.json +24 -0
  112. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.js +34 -0
  113. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/piece.json +9 -0
  114. package/src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.js +6 -4
  115. package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.js +6 -4
  116. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/piece.json +9 -0
  117. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.examples.json +30 -0
  118. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.js +166 -0
  119. package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +0 -10
  120. package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +4 -4
  121. package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +8 -6
  122. package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +0 -10
  123. package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/dependency-isolation.js +9 -14
  124. package/src/infrastructure/engines/walker/drawer-path/drawer-names/categorical-paths.js +4 -4
  125. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/piece.json +9 -0
  126. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.examples.json +30 -0
  127. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.js +31 -0
  128. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.examples.json +18 -0
  129. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.js +32 -0
  130. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/piece.json +9 -0
  131. package/src/infrastructure/engines/walker/floating-version/version-selector/piece.json +9 -0
  132. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.examples.json +54 -0
  133. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.js +75 -0
  134. package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/hermetic-git-spawns.js +8 -17
  135. package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loops.js +8 -6
  136. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/piece.json +9 -0
  137. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.examples.json +36 -0
  138. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.js +67 -0
  139. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +34 -0
  140. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mocking.js +64 -16
  141. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +5 -1
  142. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.examples.json +24 -0
  143. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.js +41 -0
  144. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/piece.json +9 -0
  145. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +18 -16
  146. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +1 -1
  147. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.examples.json +18 -0
  148. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.js +17 -0
  149. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/piece.json +9 -0
  150. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/direct-global-use.examples.json +63 -0
  151. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/piece.json +13 -0
  152. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/process-global-used-in-place.js +126 -0
  153. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/comment-prose.examples.json +42 -0
  154. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/piece.json +16 -0
  155. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/prose-in-code.js +90 -0
  156. package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +0 -10
  157. package/src/infrastructure/engines/walker/runner/pieces/walker-piece.d.ts +7 -5
  158. package/src/infrastructure/engines/walker/runner/runner.js +266 -77
  159. package/src/infrastructure/engines/walker/runner/toolchain/typescript-parse.d.ts +3 -0
  160. package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.js +12 -7
  161. package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +0 -10
  162. package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +0 -10
  163. package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +0 -10
  164. package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +0 -10
  165. package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +0 -10
  166. package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +30 -52
  167. package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +0 -10
  168. package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +0 -10
  169. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/piece.json +9 -0
  170. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throw-statement.examples.json +36 -0
  171. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throws-in-production.js +12 -0
  172. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +6 -6
  173. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throws-in-tests.js +5 -44
  174. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +0 -10
  175. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.examples.json +42 -0
  176. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.js +152 -0
  177. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/piece.json +9 -0
  178. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/piece.json +9 -0
  179. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +24 -0
  180. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +27 -0
  181. package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.js +8 -6
  182. package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/export-test-sibling.js +16 -10
  183. package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/comments-directives.js +18 -64
  184. package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.js +7 -5
  185. package/src/rule-set.d.ts +2 -1
  186. package/src/testing.d.ts +2 -4
  187. package/src/testing.js +104 -317
  188. package/src/{audit.d.ts → walker.d.ts} +13 -8
  189. package/src/walker.js +28 -0
  190. package/chunks/chunk-5HRMJ4O2.js +0 -608
  191. package/chunks/chunk-IX2VZTBO.js +0 -887
  192. package/chunks/chunk-K2W3D3NB.js +0 -17
  193. package/chunks/chunk-M6SOGWT7.js +0 -82
  194. package/chunks/chunk-Q62Y25WS.js +0 -843
  195. package/chunks/chunk-R75QELTA.js +0 -481
  196. package/chunks/chunk-RANAKCTW.js +0 -31
  197. package/chunks/chunk-TNY2PASL.js +0 -38
  198. package/chunks/chunk-UJONWHA4.js +0 -22
  199. package/docs/output-contract.md +0 -1155
  200. package/src/audit.js +0 -18
  201. package/src/domain/runner/runner-module-types.d.ts +0 -15
@@ -2,9 +2,6 @@
2
2
 
3
3
  This piece enforces CD-27's `focused-tests` and `skipped-tests` clauses through ESLint, in the plugin `cd27/cd27.eslint-plugin.ts` under the namespace `hone-cd27`.
4
4
 
5
- - `focused-tests` reports `.only` and the bare `fdescribe`, `fit`, `ftest` and `fsuite`, at the `only` token.
6
- - `skipped-tests` reports `.skip`, `.fixme` and the bare `xdescribe`, `xit`, `xtest` and `xsuite`.
7
-
8
5
  `piece.json` names each clause, the namespace, the plugin module and the rule. It is the only file core reads to find the rules.
9
6
 
10
7
  ## Adopting the rule
@@ -15,6 +15,11 @@ var SKIPPED = {
15
15
  roots: TEST_ROOTS,
16
16
  members: /* @__PURE__ */ new Set(["skip", "fixme"])
17
17
  };
18
+ var CONDITIONAL_AND_TODO = "conditional-and-todo";
19
+ var EXTENDED_SKIPS = {
20
+ ...SKIPPED,
21
+ members: /* @__PURE__ */ new Set([...SKIPPED.members, "todo", "skipIf", "runIf"])
22
+ };
18
23
  var memberName = (request) => {
19
24
  if (request.property?.type === "Identifier") {
20
25
  return request.property.name;
@@ -49,35 +54,42 @@ var modifiedLink = (request) => {
49
54
  const testFunction = links.findIndex((link) => request.modifier.roots.has(link.name));
50
55
  return testFunction === -1 ? void 0 : links.slice(testFunction + 1).find((link) => request.modifier.members.has(link.name));
51
56
  };
52
- var modifierRule = (request) => siteRule({
57
+ var observeModifier = (request) => ({
58
+ calls: (node) => {
59
+ const loc = modifiedLink({ callee: node.callee, modifier: request.modifier })?.node.loc;
60
+ if (loc === void 0 || loc === null) return;
61
+ request.context.report({ loc, messageId: "modifiedTest" });
62
+ }
63
+ });
64
+ var focusedRule = (modifier) => siteRule({
53
65
  meta: {
54
66
  type: "problem",
55
- docs: { description: request.description },
67
+ docs: { description: "Disallow focused tests" },
56
68
  schema: [],
57
- messages: { modifiedTest: request.message }
69
+ messages: { modifiedTest: "remove the focus so every test runs." }
70
+ },
71
+ observe: (context) => observeModifier({ context, modifier })
72
+ });
73
+ var skippedRule = (request) => siteRule({
74
+ meta: {
75
+ type: "problem",
76
+ docs: { description: "Disallow skipped tests" },
77
+ schema: [{ enum: [...request.byOption.keys()] }],
78
+ messages: { modifiedTest: "remove the skip so the test runs, or delete the test." }
58
79
  },
59
- observe: (context) => ({
60
- calls: (node) => {
61
- const loc = modifiedLink({ callee: node.callee, modifier: request.modifier })?.node.loc;
62
- if (loc === void 0 || loc === null) {
63
- return;
64
- }
65
- context.report({ loc, messageId: "modifiedTest" });
66
- }
67
- })
80
+ observe: (context) => {
81
+ const [option] = context.options;
82
+ const selected = typeof option === "string" ? request.byOption.get(option) : void 0;
83
+ return observeModifier({ context, modifier: selected ?? request.defaultModifier });
84
+ }
68
85
  });
69
86
  var eslint_plugin_default = {
70
87
  meta: { name: "hone-cd27", version: "0.0.0-local" },
71
88
  rules: {
72
- "focused-tests": modifierRule({
73
- modifier: FOCUSED,
74
- description: "Disallow focused tests (CD-27)",
75
- message: "CD-27: remove the focus so every test runs."
76
- }),
77
- "skipped-tests": modifierRule({
78
- modifier: SKIPPED,
79
- description: "Disallow skipped tests (CD-27)",
80
- message: "CD-27: remove the skip so the test runs, or delete the test."
89
+ "focused-tests": focusedRule(FOCUSED),
90
+ "skipped-tests": skippedRule({
91
+ defaultModifier: SKIPPED,
92
+ byOption: /* @__PURE__ */ new Map([[CONDITIONAL_AND_TODO, EXTENDED_SKIPS]])
81
93
  })
82
94
  }
83
95
  };
@@ -5,12 +5,19 @@
5
5
  "keyword": "skip"
6
6
  },
7
7
  "settings": {
8
- "pluginNamespace": "hone-cd27",
9
- "pluginModule": "eslint-plugin.js",
10
- "rule": "skipped-tests"
8
+ "rule": "skipped-tests",
9
+ "optionsByEdition": {
10
+ "2": [
11
+ "conditional-and-todo"
12
+ ]
13
+ }
11
14
  },
12
15
  "implementation": {
13
16
  "symptom": "test-switched-off",
14
17
  "check": "focused-tests"
15
- }
18
+ },
19
+ "editions": [
20
+ "1",
21
+ "2"
22
+ ]
16
23
  }
@@ -29,6 +29,20 @@
29
29
  "fileName": "src/sum.test.ts",
30
30
  "source": "ns.describe.skip(\"sum\", () => {});\n",
31
31
  "expectedLines": [1]
32
+ },
33
+ {
34
+ "name": "test.todo deferred",
35
+ "edition": "2",
36
+ "fileName": "src/sum.test.ts",
37
+ "source": "test.todo(\"later\");\n",
38
+ "expectedLines": [1]
39
+ },
40
+ {
41
+ "name": "tests conditional on the machine",
42
+ "edition": "2",
43
+ "fileName": "src/sum.test.ts",
44
+ "source": "it.skipIf(isWindows)(\"runs elsewhere\", () => {});\ndescribe.runIf(hasDatabase)(\"live\", () => {});",
45
+ "expectedLines": [1, 2]
32
46
  }
33
47
  ],
34
48
  "allow": [
@@ -49,6 +63,20 @@
49
63
  "fileName": "src/sum.test.ts",
50
64
  "source": "test.concurrent(\"adds\", () => {});\n",
51
65
  "expectedLines": []
66
+ },
67
+ {
68
+ "name": "edition one keeps conditional modifiers outside the check",
69
+ "edition": "1",
70
+ "fileName": "src/sum.test.ts",
71
+ "source": "it.skipIf(isWindows)(\"runs elsewhere\", () => {});\nit.runIf(hasDatabase)(\"live\", () => {});",
72
+ "expectedLines": []
73
+ },
74
+ {
75
+ "name": "edition two does not report concurrent or table-driven tests",
76
+ "edition": "2",
77
+ "fileName": "src/sum.test.ts",
78
+ "source": "it.concurrent(\"adds\", () => {});\nit.each([1])(\"adds %s\", () => {});",
79
+ "expectedLines": []
52
80
  }
53
81
  ]
54
82
  }
@@ -5,8 +5,6 @@
5
5
  "keyword": "let"
6
6
  },
7
7
  "settings": {
8
- "pluginNamespace": "hone-cd1",
9
- "pluginModule": "eslint-plugin.js",
10
8
  "rule": "implicit-any-let"
11
9
  },
12
10
  "implementation": {
@@ -0,0 +1,94 @@
1
+ import "../../../../../../chunks/chunk-DGOLOS5A.js";
2
+
3
+ // src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.ts
4
+ var valueRead = (request) => {
5
+ const { reference, sourceCode } = request;
6
+ if (!reference.isRead() || reference.isValueReference === false) return false;
7
+ const { identifier } = reference;
8
+ if (identifier.type !== "Identifier") return true;
9
+ const { parent } = identifier;
10
+ if ((parent.type === "UpdateExpression" || parent.type === "AssignmentExpression" && parent.left === identifier) && parent.parent.type === "ExpressionStatement")
11
+ return false;
12
+ return !sourceCode.getAncestors(identifier).some(({ type }) => type === "TSTypeQuery" || type === "TSTypePredicate");
13
+ };
14
+ var bindsWithin = (request) => {
15
+ const identifier = request.identifier.range;
16
+ const parameter = request.parameter.range;
17
+ return identifier[0] >= parameter[0] && identifier[1] <= parameter[1];
18
+ };
19
+ var excludedFromRest = (identifier) => {
20
+ const parent = identifier.parent;
21
+ const entry = parent.type === "AssignmentPattern" && parent.left === identifier ? parent : identifier;
22
+ const containing = entry.parent;
23
+ if (containing.type === "Property" && containing.value === entry) {
24
+ const pattern = containing.parent;
25
+ return pattern.type === "ObjectPattern" && pattern.properties.some((property) => property.type === "RestElement");
26
+ }
27
+ return containing.type === "ArrayPattern" && containing.elements.some((element) => element?.type === "RestElement");
28
+ };
29
+ var bindingKindOf = (parameter) => {
30
+ const binding = parameter.type === "AssignmentPattern" ? parameter.left : parameter;
31
+ return binding.type === "ArrayPattern" || binding.type === "ObjectPattern" ? "destructured" : "slot";
32
+ };
33
+ var parameterBindingsOf = (request) => request.sourceCode.getDeclaredVariables(request.site).flatMap((variable) => {
34
+ if (!variable.defs.some(({ type }) => type === "Parameter")) return [];
35
+ const [identifier] = variable.identifiers;
36
+ if (identifier === void 0 || identifier.name === "this" || excludedFromRest(identifier))
37
+ return [];
38
+ const index = request.site.params.findIndex(
39
+ (parameter2) => bindsWithin({ identifier, parameter: parameter2 })
40
+ );
41
+ const parameter = request.site.params[index];
42
+ return parameter === void 0 || parameter.type === "TSParameterProperty" ? [] : [
43
+ {
44
+ index,
45
+ kind: bindingKindOf(parameter),
46
+ identifier,
47
+ read: variable.references.some(
48
+ (reference) => valueRead({ reference, sourceCode: request.sourceCode })
49
+ )
50
+ }
51
+ ];
52
+ });
53
+ var observeParameters = (request) => {
54
+ const { context, site } = request;
55
+ const parent = site.parent;
56
+ if ((parent.type === "MethodDefinition" || parent.type === "Property") && parent.kind === "set")
57
+ return;
58
+ if (site.type !== "ArrowFunctionExpression" && context.sourceCode.getScope(site).variables.some(
59
+ (variable) => variable.name === "arguments" && variable.defs.length === 0 && variable.references.some((reference) => reference.isRead())
60
+ ))
61
+ return;
62
+ const parameters = parameterBindingsOf({ site, sourceCode: context.sourceCode });
63
+ const lastRead = parameters.reduce(
64
+ (latest, binding) => binding.read ? Math.max(latest, binding.index) : latest,
65
+ site.params.findLastIndex((parameter) => parameter.type === "TSParameterProperty")
66
+ );
67
+ parameters.forEach(({ index, kind, identifier, read }) => {
68
+ if (!read && (kind === "destructured" || index >= lastRead)) {
69
+ context.report({ node: identifier, messageId: "unread", data: { name: identifier.name } });
70
+ }
71
+ });
72
+ };
73
+ var unreadParameter = {
74
+ meta: {
75
+ type: "problem",
76
+ docs: { description: "Find unread function parameters and destructured fields" },
77
+ schema: [],
78
+ messages: {
79
+ unread: "The signature asks callers to supply {{name}}, but the unit never reads it. Callers build input that does not affect the result."
80
+ }
81
+ },
82
+ create: (context) => ({
83
+ FunctionDeclaration: (site) => observeParameters({ context, site }),
84
+ FunctionExpression: (site) => observeParameters({ context, site }),
85
+ ArrowFunctionExpression: (site) => observeParameters({ context, site })
86
+ })
87
+ };
88
+ var eslint_plugin_default = {
89
+ meta: { name: "hone-wide-input", version: "0.0.0-local" },
90
+ rules: { "unread-parameter": unreadParameter }
91
+ };
92
+ export {
93
+ eslint_plugin_default as default
94
+ };
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 2,
3
+ "anchor": {
4
+ "kind": "file"
5
+ },
6
+ "settings": {
7
+ "pluginNamespace": "hone",
8
+ "pluginModule": "eslint-plugin.js",
9
+ "rule": "unread-parameter"
10
+ }
11
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "flag": [
3
+ {
4
+ "name": "a trailing unread parameter with underscore",
5
+ "fileName": "src/order.ts",
6
+ "source": "export const delivery = (order: Order, _options: Options) => order.id;",
7
+ "expectedLines": [1]
8
+ },
9
+ {
10
+ "name": "an unused binding in a destructured input",
11
+ "fileName": "src/order.ts",
12
+ "source": "export const delivery = ({ order, options }: Input) => order.id;",
13
+ "expectedLines": [1]
14
+ }
15
+ ],
16
+ "allow": [
17
+ {
18
+ "name": "a callback position before a read parameter",
19
+ "fileName": "src/order.ts",
20
+ "source": "export const delivery = (error: Error, order: Order) => order.id;",
21
+ "expectedLines": []
22
+ },
23
+ {
24
+ "name": "a binding read from a closure",
25
+ "fileName": "src/order.ts",
26
+ "source": "export const delivery = (order: Order) => () => order.id;",
27
+ "expectedLines": []
28
+ },
29
+ {
30
+ "name": "a signature owns no implementation",
31
+ "fileName": "src/order.ts",
32
+ "source": "export declare function delivery(order: Order): string;",
33
+ "expectedLines": []
34
+ },
35
+ {
36
+ "name": "receiver type and parameter property",
37
+ "fileName": "src/order.ts",
38
+ "source": "function load(this: OrderStore) { return this.order; }\nclass Delivery { constructor(private readonly repo: Repo) {} }",
39
+ "expectedLines": []
40
+ },
41
+ {
42
+ "name": "binding deliberately excluded from the rest object",
43
+ "fileName": "src/order.ts",
44
+ "source": "const omit = ({ order, ...rest }: Input) => rest;",
45
+ "expectedLines": []
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,109 @@
1
+ import {
2
+ builtInImportOf
3
+ } from "../../../../../../chunks/chunk-LNMDMRGQ.js";
4
+ import {
5
+ sourceValueLookupOf
6
+ } from "../../../../../../chunks/chunk-75XWZYNN.js";
7
+ import {
8
+ typeScriptSourceEligibility
9
+ } from "../../../../../../chunks/chunk-COQMPHWZ.js";
10
+ import "../../../../../../chunks/chunk-DGOLOS5A.js";
11
+
12
+ // src/infrastructure/engines/walker/ambient-randomness/random-call/ambient-randomness.ts
13
+ var CRYPTO_RANDOM_METHODS = /* @__PURE__ */ new Set(["randomUUID", "getRandomValues"]);
14
+ var memberOf = ({ syntaxApi, node }) => {
15
+ if (syntaxApi.isPropertyAccessExpression(node)) {
16
+ return { receiver: node.expression, name: node.name.text };
17
+ }
18
+ if (syntaxApi.isElementAccessExpression(node) && syntaxApi.isStringLiteralLike(node.argumentExpression)) {
19
+ return { receiver: node.expression, name: node.argumentExpression.text };
20
+ }
21
+ return void 0;
22
+ };
23
+ var cryptoKindOf = (imported) => {
24
+ if (imported.kind === "module") return "node-module";
25
+ if (imported.kind === "namespace") return "node-namespace";
26
+ if (imported.name === "webcrypto") return "web-crypto";
27
+ return CRYPTO_RANDOM_METHODS.has(imported.name) ? "random-function" : void 0;
28
+ };
29
+ var importedCryptoKindOf = (request) => {
30
+ const { syntaxApi, node, declarationsOf } = request;
31
+ if (!syntaxApi.isIdentifier(node)) return void 0;
32
+ const imported = builtInImportOf({
33
+ syntaxApi,
34
+ identifier: node,
35
+ declarationsOf,
36
+ builtIn: "crypto"
37
+ });
38
+ return imported === void 0 ? void 0 : cryptoKindOf(imported);
39
+ };
40
+ var qualifiedCryptoOf = (request) => {
41
+ const { syntaxApi, declarationsOf, receiver } = request;
42
+ const member = memberOf({ syntaxApi, node: receiver });
43
+ if (member === void 0) return void 0;
44
+ if (member.name === "webcrypto" || member.name === "default") {
45
+ const kind = cryptoReceiverOf({ ...request, receiver: member.receiver });
46
+ if (member.name === "default") return kind === "node-namespace" ? "node-module" : void 0;
47
+ return kind === "node-namespace" || kind === "node-module" ? "web-crypto" : void 0;
48
+ }
49
+ return member.name === "crypto" && syntaxApi.isIdentifier(member.receiver) && (member.receiver.text === "globalThis" || member.receiver.text === "window") && declarationsOf(member.receiver).length === 0 ? "web-crypto" : void 0;
50
+ };
51
+ var cryptoReceiverOf = (request) => {
52
+ const { syntaxApi, declarationsOf, receiver } = request;
53
+ if (!syntaxApi.isIdentifier(receiver)) return qualifiedCryptoOf(request);
54
+ if (receiver.text === "crypto" && declarationsOf(receiver).length === 0) return "web-crypto";
55
+ const kind = importedCryptoKindOf({ ...request, node: receiver });
56
+ return kind === "random-function" ? void 0 : kind;
57
+ };
58
+ var randomCall = (request) => {
59
+ const { syntaxApi, declarationsOf, node } = request;
60
+ if (!syntaxApi.isCallExpression(node)) return void 0;
61
+ const callee = node.expression;
62
+ if (syntaxApi.isIdentifier(callee)) {
63
+ return importedCryptoKindOf({ ...request, node: callee }) === "random-function" ? callee : void 0;
64
+ }
65
+ const member = memberOf({ syntaxApi, node: callee });
66
+ if (member === void 0) return void 0;
67
+ const { receiver, name } = member;
68
+ if (name === "random" && syntaxApi.isIdentifier(receiver) && receiver.text === "Math") {
69
+ return declarationsOf(receiver).length === 0 ? callee : void 0;
70
+ }
71
+ return CRYPTO_RANDOM_METHODS.has(name) && cryptoReceiverOf({ ...request, receiver }) !== void 0 ? callee : void 0;
72
+ };
73
+ var check = {
74
+ prepare: ({ bindings, syntaxApi }) => ({
75
+ outcome: "ok",
76
+ value: {
77
+ prepareFile: ({ file }) => {
78
+ if (typeScriptSourceEligibility({ file }) === "skipped")
79
+ return { outcome: "ok", value: { kind: "skipped" } };
80
+ return {
81
+ outcome: "ok",
82
+ value: {
83
+ kind: "syntax",
84
+ begin: ({ sourceFile, anchorAt }) => {
85
+ const hits = [];
86
+ const declarationsOf = sourceValueLookupOf({ syntaxApi, sourceFile });
87
+ return {
88
+ enter: ({ node }) => {
89
+ const callee = randomCall({ syntaxApi, node, declarationsOf });
90
+ if (callee === void 0) return;
91
+ const anchor = anchorAt({ position: callee.getStart(sourceFile) });
92
+ const snippet = callee.getText(sourceFile).replace(/\r?\n/g, " ");
93
+ hits.push(
94
+ ...bindings.map(({ address }) => ({ check: address, anchor, snippet }))
95
+ );
96
+ },
97
+ finish: () => hits
98
+ };
99
+ }
100
+ }
101
+ };
102
+ },
103
+ finish: () => ({ outcome: "ok", value: [] })
104
+ }
105
+ })
106
+ };
107
+ export {
108
+ check
109
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 2,
3
+ "anchor": {
4
+ "kind": "file"
5
+ },
6
+ "settings": {
7
+ "module": "ambient-randomness.js"
8
+ }
9
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "flag": [
3
+ {
4
+ "name": "ambient random calls",
5
+ "fileName": "src/order.ts",
6
+ "source": "Math.random();\ncrypto.randomUUID();\ncrypto.getRandomValues(bytes);",
7
+ "expectedLines": [1, 2, 3]
8
+ },
9
+ {
10
+ "name": "browser and imported crypto",
11
+ "fileName": "src/order.ts",
12
+ "source": "import { randomUUID as uuid } from 'node:crypto';\nglobalThis.crypto.randomUUID();\nwindow.crypto.getRandomValues(bytes);\nuuid();",
13
+ "expectedLines": [2, 3, 4]
14
+ },
15
+ {
16
+ "name": "static CommonJS import and qualified Web Crypto",
17
+ "fileName": "src/order.cts",
18
+ "source": "import nodeCrypto = require('crypto');\nnodeCrypto.webcrypto.getRandomValues(bytes);\nnodeCrypto.randomUUID();",
19
+ "expectedLines": [2, 3]
20
+ }
21
+ ],
22
+ "allow": [
23
+ {
24
+ "name": "injected randomness",
25
+ "fileName": "src/order.ts",
26
+ "source": "randomness.next();",
27
+ "expectedLines": []
28
+ },
29
+ {
30
+ "name": "injected crypto receiver",
31
+ "fileName": "src/order.ts",
32
+ "source": "const newId = (crypto: Pick<Crypto, \"randomUUID\">) => crypto.randomUUID();",
33
+ "expectedLines": []
34
+ },
35
+ {
36
+ "name": "locally bound crypto and browser receivers",
37
+ "fileName": "src/order.ts",
38
+ "source": "const crypto = ports.crypto;\ncrypto.randomUUID();\nconst draw = (window: Runtime) => window.crypto.getRandomValues(bytes);",
39
+ "expectedLines": []
40
+ },
41
+ {
42
+ "name": "random function alias is outside the syntax check",
43
+ "fileName": "src/order.ts",
44
+ "source": "const next = Math.random;\nnext();",
45
+ "expectedLines": []
46
+ }
47
+ ]
48
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "flag": [
3
+ {
4
+ "name": "stub answer in a hook",
5
+ "fileName": "src/order.test.ts",
6
+ "source": "beforeEach(() => stub.mockReturnValue('order'));",
7
+ "expectedLines": [1]
8
+ },
9
+ {
10
+ "name": "stub created with an implementation in a hook",
11
+ "fileName": "src/order.test.ts",
12
+ "source": "beforeEach(() => { stub = vi.fn(() => 'x'); });",
13
+ "expectedLines": [1]
14
+ },
15
+ {
16
+ "name": "a long answer set across lines inside a hook",
17
+ "fileName": "src/order.test.ts",
18
+ "source": "beforeEach(() => {\n stub.mockReturnValue(\n 'an answer long enough to shorten its source snippet without changing the line',\n );\n});",
19
+ "expectedLines": [2]
20
+ }
21
+ ],
22
+ "allow": [
23
+ {
24
+ "name": "plain reset and test-specific answer",
25
+ "fileName": "src/order.test.ts",
26
+ "source": "afterEach(() => stub.mockReset());\nit('loads', () => { stub.mockReturnValue('order'); });",
27
+ "expectedLines": []
28
+ },
29
+ {
30
+ "name": "stub declaration without an implementation",
31
+ "fileName": "src/order.test.ts",
32
+ "source": "beforeEach(() => { stub = vi.fn(); });",
33
+ "expectedLines": []
34
+ },
35
+ {
36
+ "name": "named callback is outside the syntax check",
37
+ "fileName": "src/order.test.ts",
38
+ "source": "const setup = () => stub.mockReturnValue('order');\nbeforeEach(setup);",
39
+ "expectedLines": []
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,72 @@
1
+ import {
2
+ sourceSnippetOf
3
+ } from "../../../../../../chunks/chunk-5AKHEW6V.js";
4
+ import {
5
+ testFileEligibility
6
+ } from "../../../../../../chunks/chunk-COQMPHWZ.js";
7
+ import "../../../../../../chunks/chunk-DGOLOS5A.js";
8
+
9
+ // src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answers.ts
10
+ var HOOKS = /* @__PURE__ */ new Set(["beforeAll", "beforeEach", "afterEach", "afterAll"]);
11
+ var ANSWER_SETTERS = /* @__PURE__ */ new Set([
12
+ "mockReturnValue",
13
+ "mockReturnValueOnce",
14
+ "mockResolvedValue",
15
+ "mockResolvedValueOnce",
16
+ "mockRejectedValue",
17
+ "mockRejectedValueOnce",
18
+ "mockImplementation",
19
+ "mockImplementationOnce",
20
+ "mockReturnThis"
21
+ ]);
22
+ var enclosingHook = ({ syntaxApi, node }) => {
23
+ if (syntaxApi.isSourceFile(node)) return "outside";
24
+ const parent = node.parent;
25
+ if (syntaxApi.isCallExpression(parent) && parent.arguments[0] === node && syntaxApi.isIdentifier(parent.expression) && HOOKS.has(parent.expression.text))
26
+ return "hook";
27
+ return enclosingHook({ syntaxApi, node: parent });
28
+ };
29
+ var answerSetter = ({ syntaxApi, node }) => {
30
+ if (!syntaxApi.isCallExpression(node) || !syntaxApi.isPropertyAccessExpression(node.expression))
31
+ return void 0;
32
+ const member = node.expression;
33
+ if (ANSWER_SETTERS.has(member.name.text)) return node;
34
+ return member.name.text === "fn" && syntaxApi.isIdentifier(member.expression) && member.expression.text === "vi" && node.arguments.length > 0 ? node : void 0;
35
+ };
36
+ var check = {
37
+ prepare: ({ bindings, repository, syntaxApi }) => ({
38
+ outcome: "ok",
39
+ value: {
40
+ prepareFile: ({ file }) => {
41
+ if (testFileEligibility({ file, testFiles: repository.testFiles }) === "skipped")
42
+ return { outcome: "ok", value: { kind: "skipped" } };
43
+ return {
44
+ outcome: "ok",
45
+ value: {
46
+ kind: "syntax",
47
+ begin: ({ sourceFile, anchorAt }) => {
48
+ const hits = [];
49
+ return {
50
+ enter: ({ node }) => {
51
+ const setter = answerSetter({ syntaxApi, node });
52
+ if (setter === void 0 || enclosingHook({ syntaxApi, node: setter.parent }) !== "hook")
53
+ return;
54
+ const anchor = anchorAt({ position: setter.getStart(sourceFile) });
55
+ const snippet = sourceSnippetOf(setter.getText(sourceFile));
56
+ hits.push(
57
+ ...bindings.map(({ address }) => ({ check: address, anchor, snippet }))
58
+ );
59
+ },
60
+ finish: () => hits
61
+ };
62
+ }
63
+ }
64
+ };
65
+ },
66
+ finish: () => ({ outcome: "ok", value: [] })
67
+ }
68
+ })
69
+ };
70
+ export {
71
+ check
72
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 2,
3
+ "anchor": {
4
+ "kind": "file"
5
+ },
6
+ "settings": {
7
+ "module": "hook-answers.js"
8
+ }
9
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "flag": [
3
+ {
4
+ "name": "assertions in a hook or suite body",
5
+ "fileName": "src/order.test.ts",
6
+ "source": "beforeEach(() => expect(order).toBeDefined());\ndescribe(\"suite\", () => { assert.ok(order); });",
7
+ "expectedLines": [1, 2]
8
+ },
9
+ {
10
+ "name": "Vitest assertion imported into a helper",
11
+ "fileName": "src/helper.ts",
12
+ "source": "import { expect as verify } from \"vitest\";\nverify(order).toBeDefined();",
13
+ "expectedLines": [2]
14
+ }
15
+ ],
16
+ "allow": [
17
+ {
18
+ "name": "assertions within each test case",
19
+ "fileName": "src/order.test.ts",
20
+ "source": "it.each([1])(\"case\", () => { const result = () => expect(order).toBeDefined(); result(); });\nconst type = expect.any(String);",
21
+ "expectedLines": []
22
+ },
23
+ {
24
+ "name": "production assertion unrelated to Vitest",
25
+ "fileName": "src/order.ts",
26
+ "source": "import assert from \"node:assert/strict\";\nassert.ok(order);",
27
+ "expectedLines": []
28
+ }
29
+ ]
30
+ }