eslint-plugin-traceability 1.23.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/lib/{src/rules → rules}/require-traceability.js +49 -4
  3. package/package.json +8 -8
  4. package/user-docs/api-reference.md +25 -0
  5. package/lib/tests/cli-error-handling.test.d.ts +0 -1
  6. package/lib/tests/cli-error-handling.test.js +0 -54
  7. package/lib/tests/config/eslint-config-validation.test.d.ts +0 -9
  8. package/lib/tests/config/eslint-config-validation.test.js +0 -101
  9. package/lib/tests/config/flat-config-presets-integration.test.d.ts +0 -1
  10. package/lib/tests/config/flat-config-presets-integration.test.js +0 -76
  11. package/lib/tests/config/require-story-annotation-config.test.d.ts +0 -10
  12. package/lib/tests/config/require-story-annotation-config.test.js +0 -26
  13. package/lib/tests/fixtures/stale/example.d.ts +0 -0
  14. package/lib/tests/fixtures/stale/example.js +0 -4
  15. package/lib/tests/fixtures/update/example.d.ts +0 -0
  16. package/lib/tests/fixtures/update/example.js +0 -4
  17. package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
  18. package/lib/tests/fixtures/valid-annotations/example.js +0 -3
  19. package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.d.ts +0 -1
  20. package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.js +0 -133
  21. package/lib/tests/integration/catch-annotation-prettier.integration.test.d.ts +0 -1
  22. package/lib/tests/integration/catch-annotation-prettier.integration.test.js +0 -121
  23. package/lib/tests/integration/cli-integration.test.d.ts +0 -1
  24. package/lib/tests/integration/cli-integration.test.js +0 -96
  25. package/lib/tests/integration/else-if-annotation-prettier.integration.test.d.ts +0 -1
  26. package/lib/tests/integration/else-if-annotation-prettier.integration.test.js +0 -100
  27. package/lib/tests/integration/no-redundant-annotation.integration.test.d.ts +0 -1
  28. package/lib/tests/integration/no-redundant-annotation.integration.test.js +0 -129
  29. package/lib/tests/integration/prettier-test-helpers.d.ts +0 -9
  30. package/lib/tests/integration/prettier-test-helpers.js +0 -35
  31. package/lib/tests/integration/require-traceability-aliases.integration.test.d.ts +0 -1
  32. package/lib/tests/integration/require-traceability-aliases.integration.test.js +0 -152
  33. package/lib/tests/integration/require-traceability-test-callbacks.integration.test.d.ts +0 -1
  34. package/lib/tests/integration/require-traceability-test-callbacks.integration.test.js +0 -149
  35. package/lib/tests/maintenance/batch.test.d.ts +0 -1
  36. package/lib/tests/maintenance/batch.test.js +0 -80
  37. package/lib/tests/maintenance/cli.test.d.ts +0 -1
  38. package/lib/tests/maintenance/cli.test.js +0 -306
  39. package/lib/tests/maintenance/detect-isolated.test.d.ts +0 -1
  40. package/lib/tests/maintenance/detect-isolated.test.js +0 -187
  41. package/lib/tests/maintenance/detect.test.d.ts +0 -1
  42. package/lib/tests/maintenance/detect.test.js +0 -46
  43. package/lib/tests/maintenance/index.test.d.ts +0 -1
  44. package/lib/tests/maintenance/index.test.js +0 -26
  45. package/lib/tests/maintenance/report.test.d.ts +0 -1
  46. package/lib/tests/maintenance/report.test.js +0 -68
  47. package/lib/tests/maintenance/storyParser.test.d.ts +0 -8
  48. package/lib/tests/maintenance/storyParser.test.js +0 -505
  49. package/lib/tests/maintenance/update-isolated.test.d.ts +0 -1
  50. package/lib/tests/maintenance/update-isolated.test.js +0 -71
  51. package/lib/tests/maintenance/update.test.d.ts +0 -1
  52. package/lib/tests/maintenance/update.test.js +0 -27
  53. package/lib/tests/perf/maintenance-cli-large-workspace.test.d.ts +0 -1
  54. package/lib/tests/perf/maintenance-cli-large-workspace.test.js +0 -229
  55. package/lib/tests/perf/maintenance-large-workspace.test.d.ts +0 -1
  56. package/lib/tests/perf/maintenance-large-workspace.test.js +0 -169
  57. package/lib/tests/perf/require-branch-annotation-large-file.test.d.ts +0 -1
  58. package/lib/tests/perf/require-branch-annotation-large-file.test.js +0 -67
  59. package/lib/tests/perf/valid-annotation-format-large-file.test.d.ts +0 -1
  60. package/lib/tests/perf/valid-annotation-format-large-file.test.js +0 -75
  61. package/lib/tests/plugin-default-export-and-configs.test.d.ts +0 -1
  62. package/lib/tests/plugin-default-export-and-configs.test.js +0 -121
  63. package/lib/tests/plugin-setup-error.test.d.ts +0 -6
  64. package/lib/tests/plugin-setup-error.test.js +0 -38
  65. package/lib/tests/plugin-setup.test.d.ts +0 -1
  66. package/lib/tests/plugin-setup.test.js +0 -63
  67. package/lib/tests/rules/auto-fix-behavior-008.test.d.ts +0 -1
  68. package/lib/tests/rules/auto-fix-behavior-008.test.js +0 -285
  69. package/lib/tests/rules/error-reporting.test.d.ts +0 -1
  70. package/lib/tests/rules/error-reporting.test.js +0 -99
  71. package/lib/tests/rules/no-redundant-annotation.test.d.ts +0 -1
  72. package/lib/tests/rules/no-redundant-annotation.test.js +0 -163
  73. package/lib/tests/rules/prefer-implements-annotation.test.d.ts +0 -1
  74. package/lib/tests/rules/prefer-implements-annotation.test.js +0 -162
  75. package/lib/tests/rules/require-branch-annotation.test.d.ts +0 -1
  76. package/lib/tests/rules/require-branch-annotation.test.js +0 -593
  77. package/lib/tests/rules/require-req-annotation.test.d.ts +0 -1
  78. package/lib/tests/rules/require-req-annotation.test.js +0 -264
  79. package/lib/tests/rules/require-story-annotation.test.d.ts +0 -1
  80. package/lib/tests/rules/require-story-annotation.test.js +0 -376
  81. package/lib/tests/rules/require-story-core-edgecases.test.d.ts +0 -1
  82. package/lib/tests/rules/require-story-core-edgecases.test.js +0 -15
  83. package/lib/tests/rules/require-story-core.autofix.test.d.ts +0 -1
  84. package/lib/tests/rules/require-story-core.autofix.test.js +0 -66
  85. package/lib/tests/rules/require-story-core.test.d.ts +0 -1
  86. package/lib/tests/rules/require-story-core.test.js +0 -65
  87. package/lib/tests/rules/require-story-helpers-edgecases.test.d.ts +0 -7
  88. package/lib/tests/rules/require-story-helpers-edgecases.test.js +0 -80
  89. package/lib/tests/rules/require-story-helpers.test.d.ts +0 -1
  90. package/lib/tests/rules/require-story-helpers.test.js +0 -474
  91. package/lib/tests/rules/require-story-io-behavior.test.d.ts +0 -7
  92. package/lib/tests/rules/require-story-io-behavior.test.js +0 -46
  93. package/lib/tests/rules/require-story-io.edgecases.test.d.ts +0 -7
  94. package/lib/tests/rules/require-story-io.edgecases.test.js +0 -46
  95. package/lib/tests/rules/require-story-utils.test.d.ts +0 -7
  96. package/lib/tests/rules/require-story-utils.test.js +0 -158
  97. package/lib/tests/rules/require-story-visitors-edgecases.test.d.ts +0 -7
  98. package/lib/tests/rules/require-story-visitors-edgecases.test.js +0 -27
  99. package/lib/tests/rules/require-test-traceability.test.d.ts +0 -1
  100. package/lib/tests/rules/require-test-traceability.test.js +0 -95
  101. package/lib/tests/rules/valid-annotation-format-internal.test.d.ts +0 -8
  102. package/lib/tests/rules/valid-annotation-format-internal.test.js +0 -47
  103. package/lib/tests/rules/valid-annotation-format.test.d.ts +0 -1
  104. package/lib/tests/rules/valid-annotation-format.test.js +0 -634
  105. package/lib/tests/rules/valid-req-reference.test.d.ts +0 -1
  106. package/lib/tests/rules/valid-req-reference.test.js +0 -129
  107. package/lib/tests/rules/valid-story-reference.test.d.ts +0 -1
  108. package/lib/tests/rules/valid-story-reference.test.js +0 -413
  109. package/lib/tests/utils/annotation-checker-autofix-behavior.test.d.ts +0 -5
  110. package/lib/tests/utils/annotation-checker-autofix-behavior.test.js +0 -103
  111. package/lib/tests/utils/annotation-checker.test.d.ts +0 -24
  112. package/lib/tests/utils/annotation-checker.test.js +0 -84
  113. package/lib/tests/utils/annotation-scope-analyzer.test.d.ts +0 -1
  114. package/lib/tests/utils/annotation-scope-analyzer.test.js +0 -211
  115. package/lib/tests/utils/branch-annotation-catch-insert-position.test.d.ts +0 -1
  116. package/lib/tests/utils/branch-annotation-catch-insert-position.test.js +0 -69
  117. package/lib/tests/utils/branch-annotation-catch-position.test.d.ts +0 -1
  118. package/lib/tests/utils/branch-annotation-catch-position.test.js +0 -115
  119. package/lib/tests/utils/branch-annotation-else-if-insert-position.test.d.ts +0 -1
  120. package/lib/tests/utils/branch-annotation-else-if-insert-position.test.js +0 -82
  121. package/lib/tests/utils/branch-annotation-else-if-position.test.d.ts +0 -1
  122. package/lib/tests/utils/branch-annotation-else-if-position.test.js +0 -145
  123. package/lib/tests/utils/branch-annotation-helpers.test.d.ts +0 -1
  124. package/lib/tests/utils/branch-annotation-helpers.test.js +0 -462
  125. package/lib/tests/utils/fsTestHelpers.d.ts +0 -7
  126. package/lib/tests/utils/fsTestHelpers.js +0 -26
  127. package/lib/tests/utils/ioTestHelpers.d.ts +0 -7
  128. package/lib/tests/utils/ioTestHelpers.js +0 -24
  129. package/lib/tests/utils/req-annotation-detection.test.d.ts +0 -1
  130. package/lib/tests/utils/req-annotation-detection.test.js +0 -358
  131. package/lib/tests/utils/require-story-core-test-helpers.d.ts +0 -10
  132. package/lib/tests/utils/require-story-core-test-helpers.js +0 -75
  133. package/lib/tests/utils/temp-dir-helpers.d.ts +0 -19
  134. package/lib/tests/utils/temp-dir-helpers.js +0 -62
  135. package/lib/tests/utils/ts-language-options.d.ts +0 -16
  136. package/lib/tests/utils/ts-language-options.js +0 -30
  137. /package/lib/{src/index.d.ts → index.d.ts} +0 -0
  138. /package/lib/{src/index.js → index.js} +0 -0
  139. /package/lib/{src/maintenance → maintenance}/batch.d.ts +0 -0
  140. /package/lib/{src/maintenance → maintenance}/batch.js +0 -0
  141. /package/lib/{src/maintenance → maintenance}/cli.d.ts +0 -0
  142. /package/lib/{src/maintenance → maintenance}/cli.js +0 -0
  143. /package/lib/{src/maintenance → maintenance}/commands.d.ts +0 -0
  144. /package/lib/{src/maintenance → maintenance}/commands.js +0 -0
  145. /package/lib/{src/maintenance → maintenance}/detect.d.ts +0 -0
  146. /package/lib/{src/maintenance → maintenance}/detect.js +0 -0
  147. /package/lib/{src/maintenance → maintenance}/flags.d.ts +0 -0
  148. /package/lib/{src/maintenance → maintenance}/flags.js +0 -0
  149. /package/lib/{src/maintenance → maintenance}/index.d.ts +0 -0
  150. /package/lib/{src/maintenance → maintenance}/index.js +0 -0
  151. /package/lib/{src/maintenance → maintenance}/report.d.ts +0 -0
  152. /package/lib/{src/maintenance → maintenance}/report.js +0 -0
  153. /package/lib/{src/maintenance → maintenance}/storyParser.d.ts +0 -0
  154. /package/lib/{src/maintenance → maintenance}/storyParser.js +0 -0
  155. /package/lib/{src/maintenance → maintenance}/update.d.ts +0 -0
  156. /package/lib/{src/maintenance → maintenance}/update.js +0 -0
  157. /package/lib/{src/maintenance → maintenance}/utils.d.ts +0 -0
  158. /package/lib/{src/maintenance → maintenance}/utils.js +0 -0
  159. /package/lib/{src/rules → rules}/helpers/pattern-validators.d.ts +0 -0
  160. /package/lib/{src/rules → rules}/helpers/pattern-validators.js +0 -0
  161. /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.d.ts +0 -0
  162. /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.js +0 -0
  163. /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.d.ts +0 -0
  164. /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.js +0 -0
  165. /package/lib/{src/rules → rules}/helpers/require-story-core.d.ts +0 -0
  166. /package/lib/{src/rules → rules}/helpers/require-story-core.js +0 -0
  167. /package/lib/{src/rules → rules}/helpers/require-story-helpers.d.ts +0 -0
  168. /package/lib/{src/rules → rules}/helpers/require-story-helpers.js +0 -0
  169. /package/lib/{src/rules → rules}/helpers/require-story-io.d.ts +0 -0
  170. /package/lib/{src/rules → rules}/helpers/require-story-io.js +0 -0
  171. /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.d.ts +0 -0
  172. /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.js +0 -0
  173. /package/lib/{src/rules → rules}/helpers/require-story-node-utils.d.ts +0 -0
  174. /package/lib/{src/rules → rules}/helpers/require-story-node-utils.js +0 -0
  175. /package/lib/{src/rules → rules}/helpers/require-story-utils.d.ts +0 -0
  176. /package/lib/{src/rules → rules}/helpers/require-story-utils.js +0 -0
  177. /package/lib/{src/rules → rules}/helpers/require-story-visitors.d.ts +0 -0
  178. /package/lib/{src/rules → rules}/helpers/require-story-visitors.js +0 -0
  179. /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.d.ts +0 -0
  180. /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.js +0 -0
  181. /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.d.ts +0 -0
  182. /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.js +0 -0
  183. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.d.ts +0 -0
  184. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.js +0 -0
  185. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.d.ts +0 -0
  186. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.js +0 -0
  187. /package/lib/{src/rules → rules}/helpers/valid-annotation-options.d.ts +0 -0
  188. /package/lib/{src/rules → rules}/helpers/valid-annotation-options.js +0 -0
  189. /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.d.ts +0 -0
  190. /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.js +0 -0
  191. /package/lib/{src/rules → rules}/helpers/valid-implements-utils.d.ts +0 -0
  192. /package/lib/{src/rules → rules}/helpers/valid-implements-utils.js +0 -0
  193. /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.d.ts +0 -0
  194. /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.js +0 -0
  195. /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.d.ts +0 -0
  196. /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.js +0 -0
  197. /package/lib/{src/rules → rules}/no-redundant-annotation.d.ts +0 -0
  198. /package/lib/{src/rules → rules}/no-redundant-annotation.js +0 -0
  199. /package/lib/{src/rules → rules}/prefer-implements-annotation.d.ts +0 -0
  200. /package/lib/{src/rules → rules}/prefer-implements-annotation.js +0 -0
  201. /package/lib/{src/rules → rules}/require-branch-annotation.d.ts +0 -0
  202. /package/lib/{src/rules → rules}/require-branch-annotation.js +0 -0
  203. /package/lib/{src/rules → rules}/require-req-annotation.d.ts +0 -0
  204. /package/lib/{src/rules → rules}/require-req-annotation.js +0 -0
  205. /package/lib/{src/rules → rules}/require-story-annotation.d.ts +0 -0
  206. /package/lib/{src/rules → rules}/require-story-annotation.js +0 -0
  207. /package/lib/{src/rules → rules}/require-test-traceability.d.ts +0 -0
  208. /package/lib/{src/rules → rules}/require-test-traceability.js +0 -0
  209. /package/lib/{src/rules → rules}/require-traceability.d.ts +0 -0
  210. /package/lib/{src/rules → rules}/valid-annotation-format.d.ts +0 -0
  211. /package/lib/{src/rules → rules}/valid-annotation-format.js +0 -0
  212. /package/lib/{src/rules → rules}/valid-req-reference.d.ts +0 -0
  213. /package/lib/{src/rules → rules}/valid-req-reference.js +0 -0
  214. /package/lib/{src/rules → rules}/valid-story-reference.d.ts +0 -0
  215. /package/lib/{src/rules → rules}/valid-story-reference.js +0 -0
  216. /package/lib/{src/utils → utils}/annotation-checker.d.ts +0 -0
  217. /package/lib/{src/utils → utils}/annotation-checker.js +0 -0
  218. /package/lib/{src/utils → utils}/annotation-scope-analyzer.d.ts +0 -0
  219. /package/lib/{src/utils → utils}/annotation-scope-analyzer.js +0 -0
  220. /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.d.ts +0 -0
  221. /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.js +0 -0
  222. /package/lib/{src/utils → utils}/branch-annotation-helpers.d.ts +0 -0
  223. /package/lib/{src/utils → utils}/branch-annotation-helpers.js +0 -0
  224. /package/lib/{src/utils → utils}/branch-annotation-if-helpers.d.ts +0 -0
  225. /package/lib/{src/utils → utils}/branch-annotation-if-helpers.js +0 -0
  226. /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.d.ts +0 -0
  227. /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.js +0 -0
  228. /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.d.ts +0 -0
  229. /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.js +0 -0
  230. /package/lib/{src/utils → utils}/branch-annotation-report-helpers.d.ts +0 -0
  231. /package/lib/{src/utils → utils}/branch-annotation-report-helpers.js +0 -0
  232. /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.d.ts +0 -0
  233. /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.js +0 -0
  234. /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.d.ts +0 -0
  235. /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.js +0 -0
  236. /package/lib/{src/utils → utils}/branch-validation.d.ts +0 -0
  237. /package/lib/{src/utils → utils}/branch-validation.js +0 -0
  238. /package/lib/{src/utils → utils}/comment-text-helpers.d.ts +0 -0
  239. /package/lib/{src/utils → utils}/comment-text-helpers.js +0 -0
  240. /package/lib/{src/utils → utils}/function-annotation-helpers.d.ts +0 -0
  241. /package/lib/{src/utils → utils}/function-annotation-helpers.js +0 -0
  242. /package/lib/{src/utils → utils}/redundancy-detector.d.ts +0 -0
  243. /package/lib/{src/utils → utils}/redundancy-detector.js +0 -0
  244. /package/lib/{src/utils → utils}/reqAnnotationDetection.d.ts +0 -0
  245. /package/lib/{src/utils → utils}/reqAnnotationDetection.js +0 -0
  246. /package/lib/{src/utils → utils}/storyReferenceUtils.d.ts +0 -0
  247. /package/lib/{src/utils → utils}/storyReferenceUtils.js +0 -0
@@ -1,24 +0,0 @@
1
- type AnnotationCheckerTestConfig = {
2
- rule: any;
3
- valid: Array<{
4
- name: string;
5
- code: string;
6
- [key: string]: any;
7
- }>;
8
- invalid: Array<{
9
- name: string;
10
- code: string;
11
- errors: any[];
12
- [key: string]: any;
13
- }>;
14
- };
15
- /**
16
- * Shared helper for running tests that exercise the annotation-checker logic
17
- * for TypeScript constructs.
18
- *
19
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
20
- * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript-specific function syntax
21
- * @req REQ-TEST-UTILS-TS-LANG - Shared TS RuleTester language options helper
22
- */
23
- export declare function runAnnotationCheckerTests(ruleName: string, config: AnnotationCheckerTestConfig): void;
24
- export {};
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runAnnotationCheckerTests = runAnnotationCheckerTests;
4
- /**
5
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
6
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
7
- * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript-specific function syntax
8
- * @req REQ-TEST-UTILS-TS-LANG - Shared TS RuleTester language options helper
9
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-TYPESCRIPT-SUPPORT REQ-TEST-UTILS-TS-LANG
10
- */
11
- const eslint_1 = require("eslint");
12
- const annotation_checker_1 = require("../../src/utils/annotation-checker");
13
- const ts_language_options_1 = require("./ts-language-options");
14
- const ruleTester = new eslint_1.RuleTester();
15
- /**
16
- * Shared helper for running tests that exercise the annotation-checker logic
17
- * for TypeScript constructs.
18
- *
19
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
20
- * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript-specific function syntax
21
- * @req REQ-TEST-UTILS-TS-LANG - Shared TS RuleTester language options helper
22
- */
23
- function runAnnotationCheckerTests(ruleName, config) {
24
- const { rule, valid, invalid } = config;
25
- ruleTester.run(ruleName, rule, {
26
- valid: valid.map(ts_language_options_1.withTsLanguageOptions),
27
- invalid: invalid.map(ts_language_options_1.withTsLanguageOptions),
28
- });
29
- }
30
- const rule = {
31
- meta: {
32
- type: "problem",
33
- fixable: "code",
34
- docs: {
35
- description: "Test helper for checking @req annotation",
36
- recommended: "error",
37
- },
38
- messages: { missingReq: "Missing @req annotation" },
39
- schema: [],
40
- },
41
- create(context) {
42
- return {
43
- /**
44
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
45
- * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript-specific function syntax
46
- */
47
- TSDeclareFunction: (node) => (0, annotation_checker_1.checkReqAnnotation)(context, node),
48
- /**
49
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
50
- * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript-specific function syntax
51
- */
52
- TSMethodSignature: (node) => (0, annotation_checker_1.checkReqAnnotation)(context, node),
53
- };
54
- },
55
- };
56
- describe("annotation-checker helper (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", () => {
57
- runAnnotationCheckerTests("annotation-checker", {
58
- rule,
59
- valid: [
60
- {
61
- name: "[REQ-TYPESCRIPT-SUPPORT] valid TSDeclareFunction with @req",
62
- code: `/** @req REQ-TEST */\ndeclare function foo(): void;`,
63
- },
64
- {
65
- name: "[REQ-TYPESCRIPT-SUPPORT] valid TSMethodSignature with @req",
66
- code: `interface I { /** @req REQ-TEST */ method(): void; }`,
67
- },
68
- ],
69
- invalid: [
70
- {
71
- name: "[REQ-TYPESCRIPT-SUPPORT] missing @req on TSDeclareFunction",
72
- code: `declare function foo(): void;`,
73
- output: `/** @req <REQ-ID> */\ndeclare function foo(): void;`,
74
- errors: [{ messageId: "missingReq" }],
75
- },
76
- {
77
- name: "[REQ-TYPESCRIPT-SUPPORT] missing @req on TSMethodSignature",
78
- code: `interface I { method(): void; }`,
79
- output: `interface I { /** @req <REQ-ID> */\nmethod(): void; }`,
80
- errors: [{ messageId: "missingReq" }],
81
- },
82
- ],
83
- });
84
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,211 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const annotation_scope_analyzer_1 = require("../../src/utils/annotation-scope-analyzer");
4
- describe("annotation-scope-analyzer helpers (Story 027.0-DEV-REDUNDANT-ANNOTATION-DETECTION)", () => {
5
- it("[REQ-DUPLICATION-DETECTION] builds stable story/req keys", () => {
6
- const key = (0, annotation_scope_analyzer_1.toStoryReqKey)("docs/stories/001.story.md", "REQ-ONE");
7
- expect(key).toBe("docs/stories/001.story.md|REQ-ONE");
8
- });
9
- it("[REQ-DUPLICATION-DETECTION] normalizes missing story or requirement to empty segments", () => {
10
- const noStory = (0, annotation_scope_analyzer_1.toStoryReqKey)(null, "REQ-ONE");
11
- const noReq = (0, annotation_scope_analyzer_1.toStoryReqKey)("docs/stories/001.story.md", undefined);
12
- expect(noStory).toBe("|REQ-ONE");
13
- expect(noReq).toBe("docs/stories/001.story.md|");
14
- });
15
- it("[REQ-DUPLICATION-DETECTION] extracts pairs from @story/@req sequences", () => {
16
- const text = `// @story docs/stories/001.story.md\n// @req REQ-ONE`;
17
- const pairs = (0, annotation_scope_analyzer_1.extractStoryReqPairsFromText)(text);
18
- expect(Array.from(pairs)).toEqual([
19
- "docs/stories/001.story.md|REQ-ONE",
20
- ]);
21
- });
22
- it("[REQ-DUPLICATION-DETECTION] returns empty set when text has no annotations", () => {
23
- const pairs = (0, annotation_scope_analyzer_1.extractStoryReqPairsFromText)("");
24
- expect(pairs.size).toBe(0);
25
- });
26
- it("[REQ-SCOPE-ANALYSIS] extracts pairs from @supports lines", () => {
27
- const text = `// @supports docs/stories/002.story.md REQ-A REQ-B OTHER`;
28
- const pairs = (0, annotation_scope_analyzer_1.extractStoryReqPairsFromText)(text);
29
- expect(pairs.has("docs/stories/002.story.md|REQ-A")).toBe(true);
30
- expect(pairs.has("docs/stories/002.story.md|REQ-B")).toBe(true);
31
- });
32
- it("[REQ-DUPLICATION-DETECTION] aggregates pairs across comments", () => {
33
- const comments = [
34
- { value: "// @story docs/stories/001.story.md\n// @req REQ-ONE" },
35
- { value: "// @supports docs/stories/002.story.md REQ-TWO" },
36
- ];
37
- const pairs = (0, annotation_scope_analyzer_1.extractStoryReqPairsFromComments)(comments);
38
- expect(pairs.size).toBe(2);
39
- });
40
- it("[REQ-DUPLICATION-DETECTION] returns empty set for empty comments list", () => {
41
- const pairs = (0, annotation_scope_analyzer_1.extractStoryReqPairsFromComments)([]);
42
- expect(pairs.size).toBe(0);
43
- });
44
- it("[REQ-DUPLICATION-DETECTION] determines full coverage correctly", () => {
45
- const parent = new Set([
46
- "story|REQ-ONE",
47
- "story|REQ-TWO",
48
- ]);
49
- const childCovered = new Set(["story|REQ-ONE"]);
50
- const childNotCovered = new Set(["story|REQ-THREE"]);
51
- expect((0, annotation_scope_analyzer_1.arePairsFullyCovered)(childCovered, parent)).toBe(true);
52
- expect((0, annotation_scope_analyzer_1.arePairsFullyCovered)(childNotCovered, parent)).toBe(false);
53
- });
54
- it("[REQ-DUPLICATION-DETECTION] treats empty child or parent as not covered", () => {
55
- const nonEmpty = new Set(["story|REQ-ONE"]);
56
- expect((0, annotation_scope_analyzer_1.arePairsFullyCovered)(new Set(), nonEmpty)).toBe(false);
57
- expect((0, annotation_scope_analyzer_1.arePairsFullyCovered)(nonEmpty, new Set())).toBe(false);
58
- });
59
- it("[REQ-STATEMENT-SIGNIFICANCE] respects alwaysCovered and strictness levels", () => {
60
- const base = {
61
- strictness: "moderate",
62
- allowEmphasisDuplication: false,
63
- maxScopeDepth: 3,
64
- alwaysCovered: ["ReturnStatement"],
65
- };
66
- const branchTypes = ["IfStatement"];
67
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({ type: "ReturnStatement" }, base, branchTypes)).toBe(true);
68
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({ type: "ExpressionStatement" }, base, branchTypes)).toBe(true);
69
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({ type: "IfStatement" }, base, branchTypes)).toBe(false);
70
- });
71
- it("[REQ-CONFIGURABLE-STRICTNESS] treats permissive mode as only honoring alwaysCovered list", () => {
72
- const options = {
73
- strictness: "permissive",
74
- allowEmphasisDuplication: false,
75
- maxScopeDepth: 3,
76
- alwaysCovered: ["ReturnStatement"],
77
- };
78
- const branchTypes = ["IfStatement"];
79
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({ type: "ReturnStatement" }, options, branchTypes)).toBe(true);
80
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({ type: "ExpressionStatement" }, options, branchTypes)).toBe(false);
81
- });
82
- it("[REQ-CONFIGURABLE-STRICTNESS] treats strict mode as allowing any non-branch statement", () => {
83
- const options = {
84
- strictness: "strict",
85
- allowEmphasisDuplication: false,
86
- maxScopeDepth: 3,
87
- alwaysCovered: [],
88
- };
89
- const branchTypes = ["IfStatement"];
90
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({ type: "ExpressionStatement" }, options, branchTypes)).toBe(true);
91
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({ type: "IfStatement" }, options, branchTypes)).toBe(false);
92
- });
93
- it("[REQ-STATEMENT-SIGNIFICANCE] returns false for null or non-node values", () => {
94
- const options = {
95
- strictness: "moderate",
96
- allowEmphasisDuplication: false,
97
- maxScopeDepth: 3,
98
- alwaysCovered: [],
99
- };
100
- const branchTypes = [];
101
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)(null, options, branchTypes)).toBe(false);
102
- expect((0, annotation_scope_analyzer_1.isStatementEligibleForRedundancy)({}, options, branchTypes)).toBe(false);
103
- });
104
- it("[REQ-SAFE-REMOVAL] computes removal range for full-line comment", () => {
105
- const source = `const x = 1;\n// @story docs/stories/001.story.md\nconst y = 2;\n`;
106
- const sourceCode = {
107
- getText() {
108
- return source;
109
- },
110
- };
111
- const start = source.indexOf("// @story");
112
- const end = start + "// @story docs/stories/001.story.md".length;
113
- const comment = { range: [start, end] };
114
- const [removalStart, removalEnd] = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
115
- const removed = source.slice(0, removalStart) + source.slice(removalEnd);
116
- expect(removed).toBe("const x = 1;\nconst y = 2;\n");
117
- });
118
- it("[REQ-SAFE-REMOVAL] computes removal range for full-line comment with Windows newlines", () => {
119
- const source = "const x = 1;\r\n// @story docs/stories/001.story.md\r\nconst y = 2;\r\n";
120
- const sourceCode = {
121
- getText() {
122
- return source;
123
- },
124
- };
125
- const start = source.indexOf("// @story");
126
- const end = start + "// @story docs/stories/001.story.md".length;
127
- const comment = { range: [start, end] };
128
- const [removalStart, removalEnd] = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
129
- const removed = source.slice(0, removalStart) + source.slice(removalEnd);
130
- expect(removed).toBe("const x = 1;\r\nconst y = 2;\r\n");
131
- });
132
- it("[REQ-SAFE-REMOVAL] computes removal range for full-line comment with standalone CR newline", () => {
133
- const source = "const x = 1;\r// @story docs/stories/001.story.md\rconst y = 2;\r";
134
- const sourceCode = {
135
- getText() {
136
- return source;
137
- },
138
- };
139
- const start = source.indexOf("// @story");
140
- const end = start + "// @story docs/stories/001.story.md".length;
141
- const comment = { range: [start, end] };
142
- const [removalStart, removalEnd] = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
143
- const removed = source.slice(0, removalStart) + source.slice(removalEnd);
144
- expect(removed).toBe("const x = 1;\rconst y = 2;\r");
145
- });
146
- it("[REQ-SAFE-REMOVAL] computes removal range for inline comment", () => {
147
- const source = "const x = 1; // @story docs/stories/001.story.md\nconst y = 2;\n";
148
- const sourceCode = {
149
- getText() {
150
- return source;
151
- },
152
- };
153
- const start = source.indexOf("// @story");
154
- const end = start + "// @story docs/stories/001.story.md".length;
155
- const comment = { range: [start, end] };
156
- const [removalStart, removalEnd] = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
157
- const removed = source.slice(0, removalStart) + source.slice(removalEnd);
158
- expect(removed).toBe("const x = 1; \nconst y = 2;\n");
159
- });
160
- it("[REQ-SAFE-REMOVAL] consumes trailing spaces and tabs following a full-line comment", () => {
161
- const source = "const x = 1;\n// @story docs/stories/001.story.md \nconst y = 2;\n";
162
- const sourceCode = {
163
- getText() {
164
- return source;
165
- },
166
- };
167
- const start = source.indexOf("// @story");
168
- const end = start + "// @story docs/stories/001.story.md".length;
169
- const comment = { range: [start, end] };
170
- const [removalStart, removalEnd] = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
171
- const removed = source.slice(0, removalStart) + source.slice(removalEnd);
172
- expect(removed).toBe("const x = 1;\nconst y = 2;\n");
173
- });
174
- it("[REQ-SAFE-REMOVAL] handles full-line comment at end of file without trailing newline", () => {
175
- const source = "const x = 1;\n// @story docs/stories/001.story.md";
176
- const sourceCode = {
177
- getText() {
178
- return source;
179
- },
180
- };
181
- const start = source.indexOf("// @story");
182
- const end = start + "// @story docs/stories/001.story.md".length;
183
- const comment = { range: [start, end] };
184
- const [removalStart, removalEnd] = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
185
- const removed = source.slice(0, removalStart) + source.slice(removalEnd);
186
- expect(removed).toBe("const x = 1;\n");
187
- expect(removalEnd).toBe(source.length);
188
- });
189
- it("[REQ-SAFE-REMOVAL] returns [0, 0] for comments with invalid range length (EXPECTS EXPECTED_RANGE_LENGTH usage)", () => {
190
- const source = "const x = 1;";
191
- const sourceCode = {
192
- getText() {
193
- return source;
194
- },
195
- };
196
- const comment = { range: [0] };
197
- const range = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
198
- expect(range).toEqual([0, 0]);
199
- });
200
- it("[REQ-SAFE-REMOVAL] returns [0, 0] when comment range is not an array", () => {
201
- const source = "const x = 1;";
202
- const sourceCode = {
203
- getText() {
204
- return source;
205
- },
206
- };
207
- const comment = { range: null };
208
- const range = (0, annotation_scope_analyzer_1.getCommentRemovalRange)(comment, sourceCode);
209
- expect(range).toEqual([0, 0]);
210
- });
211
- });
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable traceability/valid-annotation-format */
4
- /**
5
- * Unit tests for CatchClause insert position calculation.
6
- * @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
7
- * @story docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md
8
- * @supports docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md REQ-PRETTIER-AUTOFIX
9
- */
10
- const branch_annotation_helpers_1 = require("../../src/utils/branch-annotation-helpers");
11
- describe("CatchClause insert position (Story 025.0-DEV-CATCH-ANNOTATION-POSITION)", () => {
12
- it("[REQ-PRETTIER-AUTOFIX] inserts annotations at the first statement inside the catch body", () => {
13
- const lines = [
14
- "try {",
15
- " doSomething();",
16
- "}",
17
- "catch (error) {",
18
- " handleError(error);",
19
- "}",
20
- ];
21
- const fixer = {
22
- insertTextBeforeRange: jest.fn((r, t) => ({ r, t })),
23
- };
24
- const context = {
25
- getSourceCode() {
26
- return {
27
- lines,
28
- getCommentsBefore() {
29
- return [];
30
- },
31
- getIndexFromLoc({ line, column }) {
32
- // simple line/column to index mapping for the test: assume each line ends with "\n"
33
- const prefix = lines.slice(0, line - 1).join("\n");
34
- return prefix.length + (line > 1 ? 1 : 0) + column;
35
- },
36
- };
37
- },
38
- report({ fix }) {
39
- // immediately invoke the fixer to exercise the insert position
40
- if (typeof fix === "function") {
41
- fix(fixer);
42
- }
43
- },
44
- };
45
- const node = {
46
- type: "CatchClause",
47
- loc: { start: { line: 4 } },
48
- body: {
49
- type: "BlockStatement",
50
- loc: { start: { line: 4 } },
51
- body: [
52
- {
53
- type: "ExpressionStatement",
54
- loc: { start: { line: 5 } },
55
- },
56
- ],
57
- },
58
- };
59
- const storyFixCountRef = { count: 0 };
60
- (0, branch_annotation_helpers_1.reportMissingAnnotations)(context, node, storyFixCountRef);
61
- expect(fixer.insertTextBeforeRange).toHaveBeenCalledTimes(1);
62
- const [range, text] = fixer.insertTextBeforeRange.mock.calls[0];
63
- // ensure we are inserting before the first statement in the catch body (line 5)
64
- const expectedIndex = context.getSourceCode().getIndexFromLoc({ line: 5, column: 0 });
65
- expect(range).toEqual([expectedIndex, expectedIndex]);
66
- // and that the inserted text is prefixed with the inner indentation from line 5
67
- expect(text.startsWith(" ")).toBe(true);
68
- });
69
- });
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const branch_annotation_helpers_1 = require("../../src/utils/branch-annotation-helpers");
4
- function createMockSourceCode(options) {
5
- const { lines = [], commentsBefore = [], commentsInside = [] } = options;
6
- return {
7
- lines,
8
- getCommentsBefore() {
9
- return commentsBefore;
10
- },
11
- getCommentsInside(node) {
12
- // exercise the code path that passes node.body into getCommentsInside
13
- if (node && node.type === "BlockStatement") {
14
- return commentsInside;
15
- }
16
- return [];
17
- },
18
- };
19
- }
20
- describe("gatherBranchCommentText CatchClause behavior (Story 025.0-DEV-CATCH-ANNOTATION-POSITION)", () => {
21
- it("[REQ-DUAL-POSITION-DETECTION] prefers before-catch annotations when present", () => {
22
- const sourceCode = createMockSourceCode({
23
- commentsBefore: [
24
- { value: "@story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md" },
25
- { value: "@req REQ-BRANCH-DETECTION" },
26
- ],
27
- commentsInside: [
28
- { value: "@story docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md" },
29
- ],
30
- });
31
- const node = {
32
- type: "CatchClause",
33
- loc: { start: { line: 5 } },
34
- body: { type: "BlockStatement" },
35
- };
36
- const text = (0, branch_annotation_helpers_1.gatherBranchCommentText)(sourceCode, node);
37
- expect(text).toContain("@story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md");
38
- expect(text).toContain("@req REQ-BRANCH-DETECTION");
39
- });
40
- it("[REQ-FALLBACK-LOGIC] falls back to inside-catch annotations when before-catch is missing", () => {
41
- const sourceCode = createMockSourceCode({
42
- commentsBefore: [],
43
- commentsInside: [
44
- { value: "@story docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md" },
45
- { value: "@req REQ-CATCH-PATH" },
46
- ],
47
- });
48
- const node = {
49
- type: "CatchClause",
50
- loc: { start: { line: 10 } },
51
- body: { type: "BlockStatement" },
52
- };
53
- const text = (0, branch_annotation_helpers_1.gatherBranchCommentText)(sourceCode, node);
54
- expect(text).toContain("@story docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md");
55
- expect(text).toContain("@req REQ-CATCH-PATH");
56
- });
57
- it("[REQ-FALLBACK-LOGIC] returns before-catch text when getCommentsInside is not available", () => {
58
- const lines = [
59
- "try {",
60
- " doSomething();",
61
- "}",
62
- "catch (error) {",
63
- " // body",
64
- "}",
65
- ];
66
- const sourceCode = {
67
- lines,
68
- getCommentsBefore() {
69
- return [
70
- { value: "@story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md" },
71
- { value: "@req REQ-BRANCH-DETECTION" },
72
- ];
73
- },
74
- // intentionally omit getCommentsInside so that the CatchClause path
75
- // falls back to the before-catch comments.
76
- };
77
- const node = {
78
- type: "CatchClause",
79
- loc: { start: { line: 4 } },
80
- body: { type: "BlockStatement" },
81
- };
82
- const text = (0, branch_annotation_helpers_1.gatherBranchCommentText)(sourceCode, node);
83
- expect(text).toContain("@story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md");
84
- expect(text).toContain("@req REQ-BRANCH-DETECTION");
85
- });
86
- it("[REQ-FALLBACK-LOGIC] collects inside-catch comments using line-based fallback when getCommentsInside is unavailable", () => {
87
- const lines = [
88
- "try {",
89
- " doSomething();",
90
- "} catch (error) {",
91
- " // @story docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md",
92
- " // @req REQ-CATCH-LINE-FALLBACK",
93
- " handleError(error);",
94
- "}",
95
- ];
96
- const sourceCode = {
97
- lines,
98
- getCommentsBefore() {
99
- return [];
100
- },
101
- };
102
- const node = {
103
- type: "CatchClause",
104
- loc: { start: { line: 3 } },
105
- body: {
106
- type: "BlockStatement",
107
- loc: { start: { line: 3 }, end: { line: 7 } },
108
- body: [],
109
- },
110
- };
111
- const text = (0, branch_annotation_helpers_1.gatherBranchCommentText)(sourceCode, node);
112
- expect(text).toContain("@story docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md");
113
- expect(text).toContain("@req REQ-CATCH-LINE-FALLBACK");
114
- });
115
- });
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable traceability/valid-annotation-format */
4
- /**
5
- * Unit tests for else-if insert position calculation.
6
- * @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
7
- * @story docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md
8
- * @supports docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md REQ-PRETTIER-AUTOFIX-ELSE-IF
9
- */
10
- const branch_annotation_helpers_1 = require("../../src/utils/branch-annotation-helpers");
11
- describe("Else-if insert position (Story 026.0-DEV-ELSE-IF-ANNOTATION-POSITION)", () => {
12
- it("[REQ-PRETTIER-AUTOFIX-ELSE-IF] inserts annotations before the else-if line in Prettier-compatible default 'before' mode", () => {
13
- const lines = [
14
- "if (a) {",
15
- " doA();",
16
- "}",
17
- "else if (b) {",
18
- " doB();",
19
- "}",
20
- ];
21
- const fixer = {
22
- insertTextBeforeRange: jest.fn((r, t) => ({
23
- r,
24
- t,
25
- })),
26
- };
27
- const context = {
28
- options: [{ annotationPlacement: "before" }],
29
- getSourceCode() {
30
- return {
31
- lines,
32
- getCommentsBefore() {
33
- return [];
34
- },
35
- getIndexFromLoc({ line, column }) {
36
- // simple line/column to index mapping for the test: assume each line ends with "\n"
37
- const prefix = lines.slice(0, line - 1).join("\n");
38
- return prefix.length + (line > 1 ? 1 : 0) + column;
39
- },
40
- };
41
- },
42
- report({ fix }) {
43
- // immediately invoke the fixer to exercise the insert position
44
- if (typeof fix === "function") {
45
- fix(fixer);
46
- }
47
- },
48
- };
49
- const node = {
50
- type: "IfStatement",
51
- loc: { start: { line: 4 } },
52
- test: { loc: { end: { line: 4 } } },
53
- consequent: {
54
- type: "BlockStatement",
55
- loc: { start: { line: 4 } },
56
- body: [
57
- {
58
- type: "ExpressionStatement",
59
- loc: { start: { line: 5 } },
60
- },
61
- ],
62
- },
63
- };
64
- const parent = {
65
- type: "IfStatement",
66
- alternate: node,
67
- };
68
- node.parent = parent;
69
- const storyFixCountRef = { count: 0 };
70
- (0, branch_annotation_helpers_1.reportMissingAnnotations)(context, node, storyFixCountRef);
71
- expect(fixer.insertTextBeforeRange).toHaveBeenCalledTimes(1);
72
- const [range, text] = fixer.insertTextBeforeRange.mock
73
- .calls[0];
74
- // ensure we are inserting before the else-if line (line 4) when placement is 'before'
75
- const expectedIndex = context
76
- .getSourceCode()
77
- .getIndexFromLoc({ line: 4, column: 0 });
78
- expect(range).toEqual([expectedIndex, expectedIndex]);
79
- // and that the inserted text is prefixed with the base indentation from line 4
80
- expect(text.startsWith("")).toBe(true);
81
- });
82
- });