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,6 +0,0 @@
1
- /**
2
- * Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
3
- * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
4
- * @req REQ-ERROR-HANDLING - Gracefully handles plugin loading errors and missing dependencies
5
- * @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-ERROR-HANDLING
6
- */
@@ -1,38 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
4
- * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
5
- * @req REQ-ERROR-HANDLING - Gracefully handles plugin loading errors and missing dependencies
6
- * @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-ERROR-HANDLING
7
- */
8
- describe("Traceability ESLint Plugin Error Handling (Story 001.0-DEV-PLUGIN-SETUP)", () => {
9
- beforeEach(() => {
10
- jest.resetModules();
11
- jest.spyOn(console, "error").mockImplementation(() => { });
12
- // Mock a rule module to simulate load failure
13
- jest.mock("../src/rules/require-branch-annotation", () => {
14
- throw new Error("Test load error");
15
- });
16
- });
17
- afterEach(() => {
18
- console.error.mockRestore();
19
- });
20
- it("[REQ-ERROR-HANDLING] should report error loading rule and provide placeholder rule", () => {
21
- const plugin = require("../src/index");
22
- // Expect console.error to have been called for the missing rule
23
- expect(console.error).toHaveBeenCalledWith(expect.stringContaining('Failed to load rule "require-branch-annotation": Test load error'));
24
- // Placeholder rule should exist
25
- const placeholderRule = plugin.rules["require-branch-annotation"];
26
- expect(placeholderRule).toBeDefined();
27
- // meta.docs.description should reflect load failure
28
- expect(placeholderRule.meta.docs.description).toContain("Failed to load rule 'require-branch-annotation'");
29
- // Placeholder rule create should report an error message
30
- const fakeContext = { report: jest.fn() };
31
- const visitor = placeholderRule.create(fakeContext);
32
- visitor.Program({ type: "Program" });
33
- expect(fakeContext.report).toHaveBeenCalledWith({
34
- node: { type: "Program" },
35
- message: expect.stringContaining('Error loading rule "require-branch-annotation": Test load error'),
36
- });
37
- });
38
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- /* eslint-disable traceability/valid-annotation-format */
37
- /**
38
- * Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
39
- * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
40
- * @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-PLUGIN-STRUCTURE REQ-NPM-PACKAGE
41
- */
42
- const index_1 = __importStar(require("../src/index"));
43
- describe("Traceability ESLint Plugin (Story 001.0-DEV-PLUGIN-SETUP)", () => {
44
- it("[REQ-PLUGIN-STRUCTURE] plugin exports rules and configs", () => {
45
- expect(index_1.rules).toBeDefined();
46
- expect(index_1.configs).toBeDefined();
47
- expect(typeof index_1.rules).toBe("object");
48
- expect(typeof index_1.configs).toBe("object");
49
- expect(index_1.default.rules).toBe(index_1.rules);
50
- expect(index_1.default.configs).toBe(index_1.configs);
51
- });
52
- it("[REQ-PLUGIN-STRUCTURE][REQ-NPM-PACKAGE] plugin exposes meta with name, namespace, and version", () => {
53
- // Arrange
54
- const pkg = require("../package.json");
55
- // Act
56
- const meta = index_1.default.meta;
57
- // Assert
58
- expect(meta).toBeDefined();
59
- expect(meta.name).toBe(pkg.name);
60
- expect(meta.version).toBe(pkg.version);
61
- expect(meta.namespace).toBe("traceability");
62
- });
63
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,285 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /**
7
- * Tests for: docs/stories/008.0-DEV-AUTO-FIX.story.md
8
- * @story docs/stories/008.0-DEV-AUTO-FIX.story.md
9
- * @req REQ-AUTOFIX-MISSING - Verify ESLint --fix automatically adds missing @story annotations to functions
10
- * @req REQ-AUTOFIX-FORMAT - Verify ESLint --fix corrects simple annotation format issues for @story annotations
11
- * @req REQ-AUTOFIX-IDEMPOTENT - Verify ESLint --fix is idempotent and produces no changes on subsequent runs
12
- * @req REQ-AUTOFIX-SINGLE-APPLICATION - Verify ESLint --fix does not apply the same fix multiple times or create duplicate annotations
13
- * @supports docs/stories/008.0-DEV-AUTO-FIX.story.md REQ-AUTOFIX-MISSING REQ-AUTOFIX-FORMAT REQ-AUTOFIX-IDEMPOTENT REQ-AUTOFIX-SINGLE-APPLICATION
14
- */
15
- const eslint_1 = require("eslint");
16
- const require_story_annotation_1 = __importDefault(require("../../src/rules/require-story-annotation"));
17
- const valid_annotation_format_1 = __importDefault(require("../../src/rules/valid-annotation-format"));
18
- const functionRuleTester = new eslint_1.RuleTester({
19
- languageOptions: {
20
- parserOptions: { ecmaVersion: 2020, sourceType: "module" },
21
- },
22
- });
23
- const formatRuleTester = new eslint_1.RuleTester({
24
- languageOptions: { parserOptions: { ecmaVersion: 2020 } },
25
- });
26
- describe("Auto-fix behavior (Story 008.0-DEV-AUTO-FIX)", () => {
27
- describe("[REQ-AUTOFIX-MISSING] require-story-annotation auto-fix", () => {
28
- functionRuleTester.run("require-story-annotation --fix", require_story_annotation_1.default, {
29
- valid: [
30
- {
31
- name: "[REQ-AUTOFIX-MISSING] already annotated function is unchanged",
32
- code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction alreadyAnnotated() {}`,
33
- },
34
- {
35
- name: "[REQ-AUTOFIX-MISSING] already annotated class method is unchanged",
36
- code: `class A {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
37
- },
38
- ],
39
- invalid: [
40
- {
41
- name: "[REQ-AUTOFIX-MISSING] adds @story before function declaration when missing",
42
- code: `function autoFixMe() {}`,
43
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction autoFixMe() {}`,
44
- errors: [
45
- {
46
- messageId: "missingStory",
47
- suggestions: [
48
- {
49
- desc: "Add traceability annotation for function 'autoFixMe' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
50
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction autoFixMe() {}`,
51
- },
52
- ],
53
- },
54
- ],
55
- },
56
- {
57
- name: "[REQ-AUTOFIX-MISSING] adds @story before function expression when missing",
58
- code: `const fnExpr = function() {};`,
59
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nconst fnExpr = function() {};`,
60
- errors: [
61
- {
62
- messageId: "missingStory",
63
- suggestions: [
64
- {
65
- desc: "Add traceability annotation for function 'fnExpr' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
66
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nconst fnExpr = function() {};`,
67
- },
68
- ],
69
- },
70
- ],
71
- },
72
- {
73
- name: "[REQ-AUTOFIX-MISSING] adds @story before class method when missing",
74
- code: `class C {\n method() {}\n}`,
75
- output: `class C {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
76
- errors: [
77
- {
78
- messageId: "missingStory",
79
- suggestions: [
80
- {
81
- desc: "Add traceability annotation for function 'method' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
82
- output: `class C {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
83
- },
84
- ],
85
- },
86
- ],
87
- },
88
- {
89
- name: "[REQ-AUTOFIX-MISSING] adds @story before TS declare function when missing",
90
- code: `declare function tsDecl(): void;`,
91
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ndeclare function tsDecl(): void;`,
92
- languageOptions: {
93
- parser: require("@typescript-eslint/parser"),
94
- parserOptions: { ecmaVersion: 2020, sourceType: "module" },
95
- },
96
- errors: [
97
- {
98
- messageId: "missingStory",
99
- suggestions: [
100
- {
101
- desc: "Add traceability annotation for function 'tsDecl' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
102
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ndeclare function tsDecl(): void;`,
103
- },
104
- ],
105
- },
106
- ],
107
- },
108
- {
109
- name: "[REQ-AUTOFIX-MISSING] adds @story before TS method signature when missing",
110
- code: `interface D {\n method(): void;\n}`,
111
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ninterface D {\n method(): void;\n}`,
112
- languageOptions: {
113
- parser: require("@typescript-eslint/parser"),
114
- parserOptions: { ecmaVersion: 2020, sourceType: "module" },
115
- },
116
- errors: [
117
- {
118
- messageId: "missingStory",
119
- suggestions: [
120
- {
121
- desc: "Add traceability annotation for function 'method' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
122
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ninterface D {\n method(): void;\n}`,
123
- },
124
- ],
125
- },
126
- ],
127
- },
128
- {
129
- name: "[REQ-AUTOFIX-TEMPLATE] uses configured templates for functions and methods",
130
- code: `function fn() {}\nclass C { method() {} }`,
131
- output: `/** @story CUSTOM-FN */\nfunction fn() {}\nclass C { /** @story CUSTOM-METHOD */\n method() {} }`,
132
- options: [
133
- {
134
- annotationTemplate: "/** @story CUSTOM-FN */",
135
- methodAnnotationTemplate: "/** @story CUSTOM-METHOD */",
136
- },
137
- ],
138
- errors: 2,
139
- },
140
- {
141
- name: "[REQ-AUTOFIX-SELECTIVE] does not insert annotations when autoFix is false",
142
- code: `function fnNoFix() {}`,
143
- output: null,
144
- options: [
145
- {
146
- autoFix: false,
147
- },
148
- ],
149
- errors: 1,
150
- },
151
- ],
152
- });
153
- });
154
- describe("[REQ-AUTOFIX-FORMAT] valid-annotation-format auto-fix", () => {
155
- formatRuleTester.run("valid-annotation-format --fix simple @story extension issues", valid_annotation_format_1.default, {
156
- valid: [
157
- {
158
- name: "[REQ-AUTOFIX-FORMAT] already-correct story path is unchanged",
159
- code: `// @story docs/stories/005.0-DEV-EXAMPLE.story.md`,
160
- },
161
- ],
162
- invalid: [
163
- {
164
- name: "[REQ-AUTOFIX-FORMAT] adds .md extension for .story path",
165
- code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story`,
166
- output: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md`,
167
- errors: [
168
- {
169
- messageId: "invalidStoryFormat",
170
- },
171
- ],
172
- },
173
- {
174
- name: "[REQ-AUTOFIX-FORMAT] adds .story.md extension when missing entirely",
175
- code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION`,
176
- output: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md`,
177
- errors: [
178
- {
179
- messageId: "invalidStoryFormat",
180
- },
181
- ],
182
- },
183
- {
184
- name: "[REQ-AUTOFIX-SELECTIVE] does not apply suffix fix when autoFix is false",
185
- code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story`,
186
- output: null,
187
- options: [
188
- {
189
- autoFix: false,
190
- },
191
- ],
192
- errors: [
193
- {
194
- messageId: "invalidStoryFormat",
195
- },
196
- ],
197
- },
198
- ],
199
- });
200
- });
201
- describe("[REQ-AUTOFIX-IDEMPOTENT] and [REQ-AUTOFIX-SINGLE-APPLICATION] require-story-annotation", () => {
202
- functionRuleTester.run("require-story-annotation --fix idempotent behavior", require_story_annotation_1.default, {
203
- valid: [
204
- {
205
- name: "[REQ-AUTOFIX-IDEMPOTENT] second run on already fixed function produces no changes",
206
- code: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction fixedOnce() {}`,
207
- },
208
- {
209
- name: "[REQ-AUTOFIX-SINGLE-APPLICATION] already annotated code does not receive duplicate annotations",
210
- code: `class E {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
211
- },
212
- ],
213
- invalid: [
214
- {
215
- name: "[REQ-AUTOFIX-IDEMPOTENT] first run adds annotation; subsequent run is a no-op for function declarations",
216
- code: `function needsFixOnce() {}`,
217
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction needsFixOnce() {}`,
218
- errors: [
219
- {
220
- messageId: "missingStory",
221
- suggestions: [
222
- {
223
- desc: "Add traceability annotation for function 'needsFixOnce' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
224
- output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction needsFixOnce() {}`,
225
- },
226
- ],
227
- },
228
- ],
229
- },
230
- {
231
- name: "[REQ-AUTOFIX-SINGLE-APPLICATION] does not duplicate annotations for class methods on subsequent runs",
232
- code: `class F {\n method() {}\n}`,
233
- output: `class F {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
234
- errors: [
235
- {
236
- messageId: "missingStory",
237
- suggestions: [
238
- {
239
- desc: "Add traceability annotation for function 'method' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
240
- output: `class F {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
241
- },
242
- ],
243
- },
244
- ],
245
- },
246
- ],
247
- });
248
- });
249
- describe("[REQ-AUTOFIX-IDEMPOTENT] and [REQ-AUTOFIX-SINGLE-APPLICATION] valid-annotation-format", () => {
250
- formatRuleTester.run("valid-annotation-format --fix idempotent behavior", valid_annotation_format_1.default, {
251
- valid: [
252
- {
253
- name: "[REQ-AUTOFIX-IDEMPOTENT] second run after suffix normalization produces no changes",
254
- code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md`,
255
- },
256
- {
257
- name: "[REQ-AUTOFIX-SINGLE-APPLICATION] already-correct suffix is not altered or extended again",
258
- code: `// @story docs/stories/005.0-DEV-EXAMPLE.story.md`,
259
- },
260
- ],
261
- invalid: [
262
- {
263
- name: "[REQ-AUTOFIX-IDEMPOTENT] adds .story.md once; subsequent run sees no further change",
264
- code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION`,
265
- output: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md`,
266
- errors: [
267
- {
268
- messageId: "invalidStoryFormat",
269
- },
270
- ],
271
- },
272
- {
273
- name: "[REQ-AUTOFIX-SINGLE-APPLICATION] converts .story to .story.md only once and does not double-append",
274
- code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story`,
275
- output: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md`,
276
- errors: [
277
- {
278
- messageId: "invalidStoryFormat",
279
- },
280
- ],
281
- },
282
- ],
283
- });
284
- });
285
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,99 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable traceability/valid-annotation-format */
7
- /**
8
- * Tests for: docs/stories/007.0-DEV-ERROR-REPORTING.story.md
9
- * @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
10
- * @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-SPECIFIC REQ-ERROR-SUGGESTION REQ-ERROR-CONTEXT REQ-ERROR-LOCATION
11
- * @req REQ-ERROR-SPECIFIC - Specific details about what annotation is missing or invalid
12
- * @req REQ-ERROR-SUGGESTION - Suggest concrete steps to fix the issue
13
- * @req REQ-ERROR-CONTEXT - Include relevant context in error messages
14
- * @req REQ-ERROR-LOCATION - Include precise location information in error messages
15
- */
16
- const eslint_1 = require("eslint");
17
- const require_story_annotation_1 = __importDefault(require("../../src/rules/require-story-annotation"));
18
- const ruleTester = new eslint_1.RuleTester({
19
- languageOptions: {
20
- parserOptions: { ecmaVersion: 2020, sourceType: "module" },
21
- },
22
- });
23
- describe("Error Reporting Enhancements for require-story-annotation (Story 007.0-DEV-ERROR-REPORTING)", () => {
24
- describe("valid cases", () => {
25
- ruleTester.run("require-story-annotation", require_story_annotation_1.default, {
26
- valid: [
27
- {
28
- name: "[007.0-DEV-ERROR-REPORTING] valid with existing annotation",
29
- code: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */ function foo() {}`,
30
- },
31
- ],
32
- invalid: [],
33
- });
34
- });
35
- describe("REQ-ERROR-SPECIFIC - missing @story annotation should report specific details and suggestion", () => {
36
- it("reports specific message, data, and suggestions for function 'bar'", () => {
37
- const code = "function bar() {}";
38
- const reported = [];
39
- const context = {
40
- id: "require-story-annotation",
41
- options: [],
42
- report: (descriptor) => {
43
- reported.push(descriptor);
44
- },
45
- getFilename: () => "test.js",
46
- getSourceCode: () => ({
47
- text: code,
48
- getText: () => code,
49
- ast: {
50
- type: "Program",
51
- body: [],
52
- sourceType: "module",
53
- },
54
- }),
55
- };
56
- const listeners = require_story_annotation_1.default.create(context);
57
- // Minimal synthetic AST nodes for the visitors
58
- const programNode = {
59
- type: "Program",
60
- body: [
61
- {
62
- type: "FunctionDeclaration",
63
- id: { type: "Identifier", name: "bar" },
64
- params: [],
65
- body: {
66
- type: "BlockStatement",
67
- body: [],
68
- },
69
- },
70
- ],
71
- sourceType: "module",
72
- };
73
- const functionNode = programNode.body[0];
74
- // Invoke visitors if they exist
75
- if (typeof listeners.Program === "function") {
76
- listeners.Program(programNode);
77
- }
78
- if (typeof listeners.FunctionDeclaration === "function") {
79
- listeners.FunctionDeclaration(functionNode);
80
- }
81
- expect(reported.length).toBe(1);
82
- const error = reported[0];
83
- // Message template should be defined and contain the {{name}} placeholder
84
- const template = require_story_annotation_1.default.meta?.messages?.missingStory;
85
- expect(typeof template).toBe("string");
86
- expect(template.length).toBeGreaterThan(0);
87
- expect(template.includes("{{name}}")).toBe(true);
88
- // Ensure messageId and data wiring is correct
89
- expect(error.messageId).toBe("missingStory");
90
- expect(error.data).toEqual({ name: "bar", functionName: "bar" });
91
- // Suggestions
92
- expect(Array.isArray(error.suggest)).toBe(true);
93
- expect(error.suggest.length).toBeGreaterThanOrEqual(1);
94
- const suggestion = error.suggest[0];
95
- expect(suggestion.desc).toBe("Add traceability annotation for function 'bar' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */");
96
- expect(suggestion.fix).toBeDefined();
97
- });
98
- });
99
- });
@@ -1 +0,0 @@
1
- export {};