eslint-plugin-traceability 1.23.0 → 1.23.1

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 (246) hide show
  1. package/CHANGELOG.md +9 -3
  2. package/package.json +8 -8
  3. package/lib/tests/cli-error-handling.test.d.ts +0 -1
  4. package/lib/tests/cli-error-handling.test.js +0 -54
  5. package/lib/tests/config/eslint-config-validation.test.d.ts +0 -9
  6. package/lib/tests/config/eslint-config-validation.test.js +0 -101
  7. package/lib/tests/config/flat-config-presets-integration.test.d.ts +0 -1
  8. package/lib/tests/config/flat-config-presets-integration.test.js +0 -76
  9. package/lib/tests/config/require-story-annotation-config.test.d.ts +0 -10
  10. package/lib/tests/config/require-story-annotation-config.test.js +0 -26
  11. package/lib/tests/fixtures/stale/example.d.ts +0 -0
  12. package/lib/tests/fixtures/stale/example.js +0 -4
  13. package/lib/tests/fixtures/update/example.d.ts +0 -0
  14. package/lib/tests/fixtures/update/example.js +0 -4
  15. package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
  16. package/lib/tests/fixtures/valid-annotations/example.js +0 -3
  17. package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.d.ts +0 -1
  18. package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.js +0 -133
  19. package/lib/tests/integration/catch-annotation-prettier.integration.test.d.ts +0 -1
  20. package/lib/tests/integration/catch-annotation-prettier.integration.test.js +0 -121
  21. package/lib/tests/integration/cli-integration.test.d.ts +0 -1
  22. package/lib/tests/integration/cli-integration.test.js +0 -96
  23. package/lib/tests/integration/else-if-annotation-prettier.integration.test.d.ts +0 -1
  24. package/lib/tests/integration/else-if-annotation-prettier.integration.test.js +0 -100
  25. package/lib/tests/integration/no-redundant-annotation.integration.test.d.ts +0 -1
  26. package/lib/tests/integration/no-redundant-annotation.integration.test.js +0 -129
  27. package/lib/tests/integration/prettier-test-helpers.d.ts +0 -9
  28. package/lib/tests/integration/prettier-test-helpers.js +0 -35
  29. package/lib/tests/integration/require-traceability-aliases.integration.test.d.ts +0 -1
  30. package/lib/tests/integration/require-traceability-aliases.integration.test.js +0 -152
  31. package/lib/tests/integration/require-traceability-test-callbacks.integration.test.d.ts +0 -1
  32. package/lib/tests/integration/require-traceability-test-callbacks.integration.test.js +0 -149
  33. package/lib/tests/maintenance/batch.test.d.ts +0 -1
  34. package/lib/tests/maintenance/batch.test.js +0 -80
  35. package/lib/tests/maintenance/cli.test.d.ts +0 -1
  36. package/lib/tests/maintenance/cli.test.js +0 -306
  37. package/lib/tests/maintenance/detect-isolated.test.d.ts +0 -1
  38. package/lib/tests/maintenance/detect-isolated.test.js +0 -187
  39. package/lib/tests/maintenance/detect.test.d.ts +0 -1
  40. package/lib/tests/maintenance/detect.test.js +0 -46
  41. package/lib/tests/maintenance/index.test.d.ts +0 -1
  42. package/lib/tests/maintenance/index.test.js +0 -26
  43. package/lib/tests/maintenance/report.test.d.ts +0 -1
  44. package/lib/tests/maintenance/report.test.js +0 -68
  45. package/lib/tests/maintenance/storyParser.test.d.ts +0 -8
  46. package/lib/tests/maintenance/storyParser.test.js +0 -505
  47. package/lib/tests/maintenance/update-isolated.test.d.ts +0 -1
  48. package/lib/tests/maintenance/update-isolated.test.js +0 -71
  49. package/lib/tests/maintenance/update.test.d.ts +0 -1
  50. package/lib/tests/maintenance/update.test.js +0 -27
  51. package/lib/tests/perf/maintenance-cli-large-workspace.test.d.ts +0 -1
  52. package/lib/tests/perf/maintenance-cli-large-workspace.test.js +0 -229
  53. package/lib/tests/perf/maintenance-large-workspace.test.d.ts +0 -1
  54. package/lib/tests/perf/maintenance-large-workspace.test.js +0 -169
  55. package/lib/tests/perf/require-branch-annotation-large-file.test.d.ts +0 -1
  56. package/lib/tests/perf/require-branch-annotation-large-file.test.js +0 -67
  57. package/lib/tests/perf/valid-annotation-format-large-file.test.d.ts +0 -1
  58. package/lib/tests/perf/valid-annotation-format-large-file.test.js +0 -75
  59. package/lib/tests/plugin-default-export-and-configs.test.d.ts +0 -1
  60. package/lib/tests/plugin-default-export-and-configs.test.js +0 -121
  61. package/lib/tests/plugin-setup-error.test.d.ts +0 -6
  62. package/lib/tests/plugin-setup-error.test.js +0 -38
  63. package/lib/tests/plugin-setup.test.d.ts +0 -1
  64. package/lib/tests/plugin-setup.test.js +0 -63
  65. package/lib/tests/rules/auto-fix-behavior-008.test.d.ts +0 -1
  66. package/lib/tests/rules/auto-fix-behavior-008.test.js +0 -285
  67. package/lib/tests/rules/error-reporting.test.d.ts +0 -1
  68. package/lib/tests/rules/error-reporting.test.js +0 -99
  69. package/lib/tests/rules/no-redundant-annotation.test.d.ts +0 -1
  70. package/lib/tests/rules/no-redundant-annotation.test.js +0 -163
  71. package/lib/tests/rules/prefer-implements-annotation.test.d.ts +0 -1
  72. package/lib/tests/rules/prefer-implements-annotation.test.js +0 -162
  73. package/lib/tests/rules/require-branch-annotation.test.d.ts +0 -1
  74. package/lib/tests/rules/require-branch-annotation.test.js +0 -593
  75. package/lib/tests/rules/require-req-annotation.test.d.ts +0 -1
  76. package/lib/tests/rules/require-req-annotation.test.js +0 -264
  77. package/lib/tests/rules/require-story-annotation.test.d.ts +0 -1
  78. package/lib/tests/rules/require-story-annotation.test.js +0 -376
  79. package/lib/tests/rules/require-story-core-edgecases.test.d.ts +0 -1
  80. package/lib/tests/rules/require-story-core-edgecases.test.js +0 -15
  81. package/lib/tests/rules/require-story-core.autofix.test.d.ts +0 -1
  82. package/lib/tests/rules/require-story-core.autofix.test.js +0 -66
  83. package/lib/tests/rules/require-story-core.test.d.ts +0 -1
  84. package/lib/tests/rules/require-story-core.test.js +0 -65
  85. package/lib/tests/rules/require-story-helpers-edgecases.test.d.ts +0 -7
  86. package/lib/tests/rules/require-story-helpers-edgecases.test.js +0 -80
  87. package/lib/tests/rules/require-story-helpers.test.d.ts +0 -1
  88. package/lib/tests/rules/require-story-helpers.test.js +0 -474
  89. package/lib/tests/rules/require-story-io-behavior.test.d.ts +0 -7
  90. package/lib/tests/rules/require-story-io-behavior.test.js +0 -46
  91. package/lib/tests/rules/require-story-io.edgecases.test.d.ts +0 -7
  92. package/lib/tests/rules/require-story-io.edgecases.test.js +0 -46
  93. package/lib/tests/rules/require-story-utils.test.d.ts +0 -7
  94. package/lib/tests/rules/require-story-utils.test.js +0 -158
  95. package/lib/tests/rules/require-story-visitors-edgecases.test.d.ts +0 -7
  96. package/lib/tests/rules/require-story-visitors-edgecases.test.js +0 -27
  97. package/lib/tests/rules/require-test-traceability.test.d.ts +0 -1
  98. package/lib/tests/rules/require-test-traceability.test.js +0 -95
  99. package/lib/tests/rules/valid-annotation-format-internal.test.d.ts +0 -8
  100. package/lib/tests/rules/valid-annotation-format-internal.test.js +0 -47
  101. package/lib/tests/rules/valid-annotation-format.test.d.ts +0 -1
  102. package/lib/tests/rules/valid-annotation-format.test.js +0 -634
  103. package/lib/tests/rules/valid-req-reference.test.d.ts +0 -1
  104. package/lib/tests/rules/valid-req-reference.test.js +0 -129
  105. package/lib/tests/rules/valid-story-reference.test.d.ts +0 -1
  106. package/lib/tests/rules/valid-story-reference.test.js +0 -413
  107. package/lib/tests/utils/annotation-checker-autofix-behavior.test.d.ts +0 -5
  108. package/lib/tests/utils/annotation-checker-autofix-behavior.test.js +0 -103
  109. package/lib/tests/utils/annotation-checker.test.d.ts +0 -24
  110. package/lib/tests/utils/annotation-checker.test.js +0 -84
  111. package/lib/tests/utils/annotation-scope-analyzer.test.d.ts +0 -1
  112. package/lib/tests/utils/annotation-scope-analyzer.test.js +0 -211
  113. package/lib/tests/utils/branch-annotation-catch-insert-position.test.d.ts +0 -1
  114. package/lib/tests/utils/branch-annotation-catch-insert-position.test.js +0 -69
  115. package/lib/tests/utils/branch-annotation-catch-position.test.d.ts +0 -1
  116. package/lib/tests/utils/branch-annotation-catch-position.test.js +0 -115
  117. package/lib/tests/utils/branch-annotation-else-if-insert-position.test.d.ts +0 -1
  118. package/lib/tests/utils/branch-annotation-else-if-insert-position.test.js +0 -82
  119. package/lib/tests/utils/branch-annotation-else-if-position.test.d.ts +0 -1
  120. package/lib/tests/utils/branch-annotation-else-if-position.test.js +0 -145
  121. package/lib/tests/utils/branch-annotation-helpers.test.d.ts +0 -1
  122. package/lib/tests/utils/branch-annotation-helpers.test.js +0 -462
  123. package/lib/tests/utils/fsTestHelpers.d.ts +0 -7
  124. package/lib/tests/utils/fsTestHelpers.js +0 -26
  125. package/lib/tests/utils/ioTestHelpers.d.ts +0 -7
  126. package/lib/tests/utils/ioTestHelpers.js +0 -24
  127. package/lib/tests/utils/req-annotation-detection.test.d.ts +0 -1
  128. package/lib/tests/utils/req-annotation-detection.test.js +0 -358
  129. package/lib/tests/utils/require-story-core-test-helpers.d.ts +0 -10
  130. package/lib/tests/utils/require-story-core-test-helpers.js +0 -75
  131. package/lib/tests/utils/temp-dir-helpers.d.ts +0 -19
  132. package/lib/tests/utils/temp-dir-helpers.js +0 -62
  133. package/lib/tests/utils/ts-language-options.d.ts +0 -16
  134. package/lib/tests/utils/ts-language-options.js +0 -30
  135. /package/lib/{src/index.d.ts → index.d.ts} +0 -0
  136. /package/lib/{src/index.js → index.js} +0 -0
  137. /package/lib/{src/maintenance → maintenance}/batch.d.ts +0 -0
  138. /package/lib/{src/maintenance → maintenance}/batch.js +0 -0
  139. /package/lib/{src/maintenance → maintenance}/cli.d.ts +0 -0
  140. /package/lib/{src/maintenance → maintenance}/cli.js +0 -0
  141. /package/lib/{src/maintenance → maintenance}/commands.d.ts +0 -0
  142. /package/lib/{src/maintenance → maintenance}/commands.js +0 -0
  143. /package/lib/{src/maintenance → maintenance}/detect.d.ts +0 -0
  144. /package/lib/{src/maintenance → maintenance}/detect.js +0 -0
  145. /package/lib/{src/maintenance → maintenance}/flags.d.ts +0 -0
  146. /package/lib/{src/maintenance → maintenance}/flags.js +0 -0
  147. /package/lib/{src/maintenance → maintenance}/index.d.ts +0 -0
  148. /package/lib/{src/maintenance → maintenance}/index.js +0 -0
  149. /package/lib/{src/maintenance → maintenance}/report.d.ts +0 -0
  150. /package/lib/{src/maintenance → maintenance}/report.js +0 -0
  151. /package/lib/{src/maintenance → maintenance}/storyParser.d.ts +0 -0
  152. /package/lib/{src/maintenance → maintenance}/storyParser.js +0 -0
  153. /package/lib/{src/maintenance → maintenance}/update.d.ts +0 -0
  154. /package/lib/{src/maintenance → maintenance}/update.js +0 -0
  155. /package/lib/{src/maintenance → maintenance}/utils.d.ts +0 -0
  156. /package/lib/{src/maintenance → maintenance}/utils.js +0 -0
  157. /package/lib/{src/rules → rules}/helpers/pattern-validators.d.ts +0 -0
  158. /package/lib/{src/rules → rules}/helpers/pattern-validators.js +0 -0
  159. /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.d.ts +0 -0
  160. /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.js +0 -0
  161. /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.d.ts +0 -0
  162. /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.js +0 -0
  163. /package/lib/{src/rules → rules}/helpers/require-story-core.d.ts +0 -0
  164. /package/lib/{src/rules → rules}/helpers/require-story-core.js +0 -0
  165. /package/lib/{src/rules → rules}/helpers/require-story-helpers.d.ts +0 -0
  166. /package/lib/{src/rules → rules}/helpers/require-story-helpers.js +0 -0
  167. /package/lib/{src/rules → rules}/helpers/require-story-io.d.ts +0 -0
  168. /package/lib/{src/rules → rules}/helpers/require-story-io.js +0 -0
  169. /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.d.ts +0 -0
  170. /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.js +0 -0
  171. /package/lib/{src/rules → rules}/helpers/require-story-node-utils.d.ts +0 -0
  172. /package/lib/{src/rules → rules}/helpers/require-story-node-utils.js +0 -0
  173. /package/lib/{src/rules → rules}/helpers/require-story-utils.d.ts +0 -0
  174. /package/lib/{src/rules → rules}/helpers/require-story-utils.js +0 -0
  175. /package/lib/{src/rules → rules}/helpers/require-story-visitors.d.ts +0 -0
  176. /package/lib/{src/rules → rules}/helpers/require-story-visitors.js +0 -0
  177. /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.d.ts +0 -0
  178. /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.js +0 -0
  179. /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.d.ts +0 -0
  180. /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.js +0 -0
  181. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.d.ts +0 -0
  182. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.js +0 -0
  183. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.d.ts +0 -0
  184. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.js +0 -0
  185. /package/lib/{src/rules → rules}/helpers/valid-annotation-options.d.ts +0 -0
  186. /package/lib/{src/rules → rules}/helpers/valid-annotation-options.js +0 -0
  187. /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.d.ts +0 -0
  188. /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.js +0 -0
  189. /package/lib/{src/rules → rules}/helpers/valid-implements-utils.d.ts +0 -0
  190. /package/lib/{src/rules → rules}/helpers/valid-implements-utils.js +0 -0
  191. /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.d.ts +0 -0
  192. /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.js +0 -0
  193. /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.d.ts +0 -0
  194. /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.js +0 -0
  195. /package/lib/{src/rules → rules}/no-redundant-annotation.d.ts +0 -0
  196. /package/lib/{src/rules → rules}/no-redundant-annotation.js +0 -0
  197. /package/lib/{src/rules → rules}/prefer-implements-annotation.d.ts +0 -0
  198. /package/lib/{src/rules → rules}/prefer-implements-annotation.js +0 -0
  199. /package/lib/{src/rules → rules}/require-branch-annotation.d.ts +0 -0
  200. /package/lib/{src/rules → rules}/require-branch-annotation.js +0 -0
  201. /package/lib/{src/rules → rules}/require-req-annotation.d.ts +0 -0
  202. /package/lib/{src/rules → rules}/require-req-annotation.js +0 -0
  203. /package/lib/{src/rules → rules}/require-story-annotation.d.ts +0 -0
  204. /package/lib/{src/rules → rules}/require-story-annotation.js +0 -0
  205. /package/lib/{src/rules → rules}/require-test-traceability.d.ts +0 -0
  206. /package/lib/{src/rules → rules}/require-test-traceability.js +0 -0
  207. /package/lib/{src/rules → rules}/require-traceability.d.ts +0 -0
  208. /package/lib/{src/rules → rules}/require-traceability.js +0 -0
  209. /package/lib/{src/rules → rules}/valid-annotation-format.d.ts +0 -0
  210. /package/lib/{src/rules → rules}/valid-annotation-format.js +0 -0
  211. /package/lib/{src/rules → rules}/valid-req-reference.d.ts +0 -0
  212. /package/lib/{src/rules → rules}/valid-req-reference.js +0 -0
  213. /package/lib/{src/rules → rules}/valid-story-reference.d.ts +0 -0
  214. /package/lib/{src/rules → rules}/valid-story-reference.js +0 -0
  215. /package/lib/{src/utils → utils}/annotation-checker.d.ts +0 -0
  216. /package/lib/{src/utils → utils}/annotation-checker.js +0 -0
  217. /package/lib/{src/utils → utils}/annotation-scope-analyzer.d.ts +0 -0
  218. /package/lib/{src/utils → utils}/annotation-scope-analyzer.js +0 -0
  219. /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.d.ts +0 -0
  220. /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.js +0 -0
  221. /package/lib/{src/utils → utils}/branch-annotation-helpers.d.ts +0 -0
  222. /package/lib/{src/utils → utils}/branch-annotation-helpers.js +0 -0
  223. /package/lib/{src/utils → utils}/branch-annotation-if-helpers.d.ts +0 -0
  224. /package/lib/{src/utils → utils}/branch-annotation-if-helpers.js +0 -0
  225. /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.d.ts +0 -0
  226. /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.js +0 -0
  227. /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.d.ts +0 -0
  228. /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.js +0 -0
  229. /package/lib/{src/utils → utils}/branch-annotation-report-helpers.d.ts +0 -0
  230. /package/lib/{src/utils → utils}/branch-annotation-report-helpers.js +0 -0
  231. /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.d.ts +0 -0
  232. /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.js +0 -0
  233. /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.d.ts +0 -0
  234. /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.js +0 -0
  235. /package/lib/{src/utils → utils}/branch-validation.d.ts +0 -0
  236. /package/lib/{src/utils → utils}/branch-validation.js +0 -0
  237. /package/lib/{src/utils → utils}/comment-text-helpers.d.ts +0 -0
  238. /package/lib/{src/utils → utils}/comment-text-helpers.js +0 -0
  239. /package/lib/{src/utils → utils}/function-annotation-helpers.d.ts +0 -0
  240. /package/lib/{src/utils → utils}/function-annotation-helpers.js +0 -0
  241. /package/lib/{src/utils → utils}/redundancy-detector.d.ts +0 -0
  242. /package/lib/{src/utils → utils}/redundancy-detector.js +0 -0
  243. /package/lib/{src/utils → utils}/reqAnnotationDetection.d.ts +0 -0
  244. /package/lib/{src/utils → utils}/reqAnnotationDetection.js +0 -0
  245. /package/lib/{src/utils → utils}/storyReferenceUtils.d.ts +0 -0
  246. /package/lib/{src/utils → utils}/storyReferenceUtils.js +0 -0
@@ -1,96 +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 CLI integration of the traceability plugin.
8
- * Validates that the plugin registers correctly and enforces
9
- * traceability-related rules when invoked via the ESLint CLI.
10
- *
11
- * @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-PLUGIN-STRUCTURE
12
- * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
13
- */
14
- /**
15
- * Tests for CLI integration functionality
16
- * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
17
- * @req REQ-PLUGIN-STRUCTURE - Validate plugin registers via CLI
18
- */
19
- const child_process_1 = require("child_process");
20
- const path_1 = __importDefault(require("path"));
21
- describe("CLI Integration (Story 001.0-DEV-PLUGIN-SETUP)", () => {
22
- const eslintPkgDir = path_1.default.dirname(require.resolve("eslint/package.json"));
23
- const eslintCliPath = path_1.default.join(eslintPkgDir, "bin", "eslint.js");
24
- const configPath = path_1.default.resolve(__dirname, "../../eslint.config.js");
25
- const tests = [
26
- {
27
- name: "reports error when @story annotation is missing",
28
- code: "function foo() {}",
29
- rule: "traceability/require-story-annotation:error",
30
- expectedStatus: 1,
31
- },
32
- {
33
- name: "does not report error when @story annotation is present",
34
- code: `/**
35
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
36
- * @req REQ-ANNOTATION-REQUIRED
37
- */
38
- function foo() {}`,
39
- rule: "traceability/require-story-annotation:error",
40
- expectedStatus: 0,
41
- },
42
- {
43
- name: "reports error when @req annotation is missing",
44
- code: "function bar() {}",
45
- rule: "traceability/require-req-annotation:error",
46
- expectedStatus: 1,
47
- },
48
- {
49
- name: "reports error when @story annotation uses path traversal and @req annotation uses path traversal",
50
- code: `/**
51
- * @story ../docs/stories/invalid.story.md
52
- * @req ../docs/requirements/REQ-INVALID.md
53
- */
54
- function bar() {}`,
55
- rule: "traceability/valid-req-reference:error",
56
- expectedStatus: 1,
57
- },
58
- {
59
- name: "reports error when @story annotation uses absolute path and @req annotation uses absolute path",
60
- code: `/**
61
- * @story /absolute/path/to/story.story.md
62
- * @req /etc/passwd
63
- */
64
- function baz() {}`,
65
- rule: "traceability/valid-req-reference:error",
66
- expectedStatus: 1,
67
- },
68
- ];
69
- /**
70
- * Helper to run ESLint CLI with a single rule for integration tests
71
- * @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-PLUGIN-STRUCTURE
72
- */
73
- function runEslint(code, rule) {
74
- const args = [
75
- "--no-config-lookup",
76
- "--config",
77
- configPath,
78
- "--stdin",
79
- "--stdin-filename",
80
- "foo.js",
81
- "--rule",
82
- "no-unused-vars:off",
83
- "--rule",
84
- rule,
85
- ];
86
- const result = (0, child_process_1.spawnSync)(process.execPath, [eslintCliPath, ...args], {
87
- encoding: "utf-8",
88
- input: code,
89
- });
90
- return result;
91
- }
92
- it.each(tests)("[REQ-PLUGIN-STRUCTURE] $name", ({ code, rule, expectedStatus }) => {
93
- const result = runEslint(code, rule);
94
- expect(result.status).toBe(expectedStatus);
95
- });
96
- });
@@ -1,100 +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
- * Prettier integration tests for else-if annotation positions.
9
- * @story docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md
10
- * @supports docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md REQ-PRETTIER-AUTOFIX-ELSE-IF
11
- */
12
- const path_1 = __importDefault(require("path"));
13
- const child_process_1 = require("child_process");
14
- const prettier_test_helpers_1 = require("./prettier-test-helpers");
15
- describe("Else-if annotations with Prettier (Story 026.0-DEV-ELSE-IF-ANNOTATION-POSITION)", () => {
16
- const eslintPkgDir = path_1.default.dirname(require.resolve("eslint/package.json"));
17
- const eslintCliPath = path_1.default.join(eslintPkgDir, "bin", "eslint.js");
18
- const configPath = path_1.default.resolve(__dirname, "../../eslint.config.js");
19
- function runEslintWithRequireBranchAnnotation(code) {
20
- const args = [
21
- "--no-config-lookup",
22
- "--config",
23
- configPath,
24
- "--stdin",
25
- "--stdin-filename",
26
- "else-if.js",
27
- "--rule",
28
- "no-unused-vars:off",
29
- "--rule",
30
- "no-magic-numbers:off",
31
- "--rule",
32
- "no-undef:off",
33
- "--rule",
34
- "no-console:off",
35
- "--rule",
36
- "traceability/require-branch-annotation:error",
37
- ];
38
- return (0, child_process_1.spawnSync)(process.execPath, [eslintCliPath, ...args], {
39
- encoding: "utf-8",
40
- input: code,
41
- });
42
- }
43
- it("[REQ-PRETTIER-COMPATIBILITY-ELSE-IF-BEFORE] accepts code where annotations start before else-if but are moved between condition and body by Prettier", () => {
44
- const original = `
45
- function doA() {
46
- return 1;
47
- }
48
-
49
- function doB() {
50
- return 2;
51
- }
52
-
53
- // @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
54
- // @req REQ-BRANCH-DETECTION
55
- if (aVeryLongConditionThatForcesPrettierToWrapTheElseIfBranch && anotherCondition) {
56
- doA();
57
- }
58
- // @story docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md
59
- // @req REQ-DUAL-POSITION-DETECTION-ELSE-IF
60
- else if (anotherVeryLongConditionThatForcesWrapping && someOtherCondition) {
61
- doB();
62
- }
63
- `;
64
- const formatted = (0, prettier_test_helpers_1.formatWithPrettier)(original);
65
- // Sanity checks: Prettier should keep both the else-if branch and the associated story annotation,
66
- // but the exact layout and comment movement may vary between versions.
67
- expect(formatted).toContain("else if");
68
- expect(formatted).toContain("@story docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md");
69
- const result = runEslintWithRequireBranchAnnotation(formatted);
70
- expect(result.status).toBe(0);
71
- });
72
- it("[REQ-PRETTIER-COMPATIBILITY-ELSE-IF-INSIDE] accepts code where annotations start between condition and body and are preserved by Prettier", () => {
73
- const original = `
74
- function doA() {
75
- return 1;
76
- }
77
-
78
- function doB() {
79
- return 2;
80
- }
81
-
82
- // @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
83
- // @req REQ-BRANCH-DETECTION
84
- if (aVeryLongConditionThatForcesPrettierToWrapTheElseIfBranch && anotherCondition) {
85
- doA();
86
- } else if (
87
- anotherVeryLongConditionThatForcesWrapping && someOtherCondition
88
- ) {
89
- // @story docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md
90
- // @req REQ-DUAL-POSITION-DETECTION-ELSE-IF
91
- doB();
92
- }
93
- `;
94
- const formatted = (0, prettier_test_helpers_1.formatWithPrettier)(original);
95
- // Note: Prettier's exact layout of the else-if and its comments may differ between versions;
96
- // the rule should accept any of the supported annotation positions regardless of formatting.
97
- const result = runEslintWithRequireBranchAnnotation(formatted);
98
- expect(result.status).toBe(0);
99
- });
100
- });
@@ -1,129 +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
- * Integration tests for no-redundant-annotation rule across multiple files
8
- * @supports docs/stories/027.0-DEV-REDUNDANT-ANNOTATION-DETECTION.story.md REQ-REDUNDANCY-PATTERNS REQ-SAFE-REMOVAL REQ-SCOPE-INHERITANCE
9
- */
10
- const use_at_your_own_risk_1 = require("eslint/use-at-your-own-risk");
11
- const index_1 = __importDefault(require("../../src/index"));
12
- async function lintTextWithConfig(text, filename, extraConfig = {}) {
13
- const baseConfig = {
14
- plugins: {
15
- traceability: index_1.default,
16
- },
17
- rules: {},
18
- };
19
- const eslint = new use_at_your_own_risk_1.FlatESLint({
20
- overrideConfig: [baseConfig, extraConfig],
21
- overrideConfigFile: true,
22
- ignore: false,
23
- });
24
- const [result] = await eslint.lintText(text, { filePath: filename });
25
- return result;
26
- }
27
- describe("no-redundant-annotation integration (Story 027.0-DEV-REDUNDANT-ANNOTATION-DETECTION)", () => {
28
- it("[REQ-REDUNDANCY-PATTERNS] cleans up redundant annotations in multiple files while preserving required ones", async () => {
29
- const codeA = `// @story docs/stories/003.0-EXAMPLE.story.md
30
- // @req REQ-INIT
31
- function init() {
32
- // @story docs/stories/003.0-EXAMPLE.story.md
33
- // @req REQ-INIT
34
- const config = loadConfig();
35
- const validator = new Validator(config);
36
- }`;
37
- const codeB = `/**
38
- * @story docs/stories/004.0-EXAMPLE.story.md
39
- * @req REQ-PROCESS
40
- */
41
- function process(value) {
42
- if (value) {
43
- /* @story docs/stories/004.0-EXAMPLE.story.md
44
- * @req REQ-PROCESS
45
- */
46
- return handle(value);
47
- }
48
- }`;
49
- const config = {
50
- rules: {
51
- "traceability/no-redundant-annotation": ["warn"],
52
- },
53
- };
54
- const [resultA, resultB] = await Promise.all([
55
- lintTextWithConfig(codeA, "file-a.js", config),
56
- lintTextWithConfig(codeB, "file-b.js", config),
57
- ]);
58
- expect(resultA.messages.map((m) => m.ruleId)).toContain("traceability/no-redundant-annotation");
59
- expect(resultB.messages.map((m) => m.ruleId)).toContain("traceability/no-redundant-annotation");
60
- const fixerConfig = {
61
- rules: {
62
- "traceability/no-redundant-annotation": ["warn"],
63
- },
64
- fix: true,
65
- };
66
- const eslintFix = new use_at_your_own_risk_1.FlatESLint({
67
- overrideConfig: [
68
- {
69
- plugins: { traceability: index_1.default },
70
- rules: fixerConfig.rules,
71
- },
72
- ],
73
- overrideConfigFile: true,
74
- ignore: false,
75
- fix: true,
76
- });
77
- const [fixedA, fixedB] = await Promise.all([
78
- (async () => {
79
- const [result] = await eslintFix.lintText(codeA, {
80
- filePath: "file-a.js",
81
- });
82
- return result;
83
- })(),
84
- (async () => {
85
- const [result] = await eslintFix.lintText(codeB, {
86
- filePath: "file-b.js",
87
- });
88
- return result;
89
- })(),
90
- ]);
91
- expect(fixedA.output).toContain("// @story docs/stories/003.0-EXAMPLE.story.md");
92
- expect(fixedA.output).toContain("// @req REQ-INIT");
93
- expect(fixedA.output).not.toContain("// @req REQ-INIT\n const config");
94
- expect(fixedB.output).toContain("@story docs/stories/004.0-EXAMPLE.story.md");
95
- expect(fixedB.output).toContain("@req REQ-PROCESS");
96
- expect(fixedB.output).not.toContain("@req REQ-PROCESS\n */\n return");
97
- });
98
- it("[REQ-CATCH-BLOCK-HANDLING] does not report redundant annotations for try/if/else-if/catch pattern from story 027.0 (regression from issue #6)", async () => {
99
- const code = `// @supports prompts/004.0-DEV-FILTER-VULNERABLE-VERSIONS.md
100
- // @req REQ-SAFE-ONLY
101
- async function filterVulnerableVersions(versionInfo, safeVersions) {
102
- try {
103
- // @supports prompts/004.0-DEV-FILTER-VULNERABLE-VERSIONS.md
104
- // @req REQ-SAFE-ONLY
105
- if (!versionInfo) {
106
- return [];
107
- } else if (!safeVersions || safeVersions.length === 0) {
108
- return versionInfo;
109
- }
110
-
111
- // @supports prompts/004.0-DEV-FILTER-VULNERABLE-VERSIONS.md
112
- // @req REQ-SAFE-ONLY
113
- return versionInfo.filter(v => safeVersions.includes(v));
114
- } catch (error) {
115
- // @supports prompts/004.0-DEV-FILTER-VULNERABLE-VERSIONS.md
116
- // @req REQ-SAFE-ONLY
117
- return [];
118
- }
119
- }
120
- `;
121
- const config = {
122
- rules: {
123
- "traceability/no-redundant-annotation": ["warn"],
124
- },
125
- };
126
- const result = await lintTextWithConfig(code, "filter-vulnerable-versions.js", config);
127
- expect(result.messages.filter((m) => m.ruleId === "traceability/no-redundant-annotation").length).toBe(0);
128
- });
129
- });
@@ -1,9 +0,0 @@
1
- interface FormatOptions {
2
- parser?: "babel" | "typescript" | "babel-ts" | "espree" | string;
3
- }
4
- /**
5
- * Format arbitrary source with Prettier using the installed CLI binary.
6
- * Defaults to the TypeScript parser when none is provided.
7
- */
8
- export declare function formatWithPrettier(source: string, options?: FormatOptions): string;
9
- export {};
@@ -1,35 +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
- exports.formatWithPrettier = formatWithPrettier;
7
- /* eslint-disable traceability/valid-annotation-format */
8
- /**
9
- * Shared helpers for Prettier-based integration tests.
10
- * @story docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md
11
- * @story docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md
12
- * @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
13
- * @supports docs/stories/025.0-DEV-CATCH-ANNOTATION-POSITION.story.md REQ-PRETTIER-COMPATIBILITY
14
- * @supports docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md REQ-PRETTIER-AUTOFIX-ELSE-IF
15
- * @supports docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md REQ-PRETTIER-STABLE
16
- */
17
- const path_1 = __importDefault(require("path"));
18
- const child_process_1 = require("child_process");
19
- /**
20
- * Format arbitrary source with Prettier using the installed CLI binary.
21
- * Defaults to the TypeScript parser when none is provided.
22
- */
23
- function formatWithPrettier(source, options = {}) {
24
- const prettierPackageJson = require.resolve("prettier/package.json");
25
- const prettierCliPath = path_1.default.join(path_1.default.dirname(prettierPackageJson), "bin", "prettier.cjs");
26
- const parser = options.parser || "typescript";
27
- const result = (0, child_process_1.spawnSync)(process.execPath, [prettierCliPath, "--parser", parser], {
28
- encoding: "utf-8",
29
- input: source,
30
- });
31
- if (result.status !== 0) {
32
- throw new Error(`Prettier formatting failed: ${result.stderr || result.stdout}`);
33
- }
34
- return result.stdout;
35
- }
@@ -1,152 +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
- /**
37
- * Integration tests for unified require-traceability rule and its legacy aliases.
38
- *
39
- * @supports docs/stories/010.4-DEV-UNIFIED-FUNCTION-RULE-AND-ALIASES.story.md REQ-UNIFIED-ALIAS-ENGINE REQ-SUPPORTS-FIRST-MODEL REQ-PRESETS-CANONICAL-RULE
40
- */
41
- const use_at_your_own_risk_1 = require("eslint/use-at-your-own-risk");
42
- const index_1 = __importStar(require("../../src/index"));
43
- async function lintTextWithConfig(text, filename, extraConfig) {
44
- const baseConfig = {
45
- plugins: {
46
- traceability: index_1.default,
47
- },
48
- };
49
- const eslint = new use_at_your_own_risk_1.FlatESLint({
50
- overrideConfig: [baseConfig, ...extraConfig],
51
- overrideConfigFile: true,
52
- ignore: false,
53
- });
54
- const [result] = await eslint.lintText(text, { filePath: filename });
55
- return result;
56
- }
57
- describe("Unified require-traceability and aliases integration (Story 010.4-DEV-UNIFIED-FUNCTION-RULE-AND-ALIASES)", () => {
58
- const codeMissingAll = "function foo() {}";
59
- const codeWithSupportsOnly = `/**\n * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED\n */\nfunction foo() {}`;
60
- const codeWithStoryAndReq = `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n * @req REQ-ANNOTATION-REQUIRED\n */\nfunction foo() {}`;
61
- async function getDiagnosticsForRule(ruleKey, code) {
62
- const config = [
63
- {
64
- rules: {
65
- [ruleKey]: "error",
66
- },
67
- },
68
- ];
69
- const result = await lintTextWithConfig(code, "example.js", config);
70
- return result.messages.map((m) => ({
71
- ruleId: m.ruleId,
72
- messageId: m.messageId,
73
- }));
74
- }
75
- it("[REQ-UNIFIED-ALIAS-ENGINE] canonical and alias keys all report missing traceability on unannotated function", async () => {
76
- const ruleKeys = [
77
- "traceability/require-traceability",
78
- "traceability/require-story-annotation",
79
- "traceability/require-req-annotation",
80
- ];
81
- const results = await Promise.all(ruleKeys.map((ruleKey) => getDiagnosticsForRule(ruleKey, codeMissingAll)));
82
- results.forEach((messages, index) => {
83
- const ruleKey = ruleKeys[index];
84
- expect(messages.length).toBeGreaterThan(0);
85
- messages.forEach((msg) => {
86
- expect(msg.ruleId).toBe(ruleKey);
87
- });
88
- });
89
- });
90
- it("[REQ-SUPPORTS-FIRST-MODEL] @supports-only annotation satisfies all three rule keys", async () => {
91
- const ruleKeys = [
92
- "traceability/require-traceability",
93
- "traceability/require-story-annotation",
94
- "traceability/require-req-annotation",
95
- ];
96
- const results = await Promise.all(ruleKeys.map((ruleKey) => getDiagnosticsForRule(ruleKey, codeWithSupportsOnly)));
97
- results.forEach((messages) => {
98
- expect(messages).toHaveLength(0);
99
- });
100
- });
101
- it("[REQ-SUPPORTS-FIRST-MODEL] @story + @req annotation satisfies all three rule keys", async () => {
102
- const ruleKeys = [
103
- "traceability/require-traceability",
104
- "traceability/require-story-annotation",
105
- "traceability/require-req-annotation",
106
- ];
107
- const results = await Promise.all(ruleKeys.map((ruleKey) => getDiagnosticsForRule(ruleKey, codeWithStoryAndReq)));
108
- results.forEach((messages) => {
109
- expect(messages).toHaveLength(0);
110
- });
111
- });
112
- it("[REQ-INSIDE-BRACE-PLACEMENT][REQ-ALL-BLOCK-TYPES] unified rule and aliases accept inside-brace annotations when annotationPlacement is 'inside'", async () => {
113
- const codeWithInsideAnnotations = `function foo() {\n // @supports docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md REQ-FN-INSIDE\n return 1;\n}`;
114
- const config = [
115
- {
116
- rules: {
117
- "traceability/require-traceability": "error",
118
- "traceability/require-story-annotation": [
119
- "error",
120
- {
121
- annotationPlacement: "inside",
122
- },
123
- ],
124
- "traceability/require-req-annotation": [
125
- "error",
126
- {
127
- annotationPlacement: "inside",
128
- },
129
- ],
130
- },
131
- },
132
- ];
133
- const result = await lintTextWithConfig(codeWithInsideAnnotations, "example.js", config);
134
- const ruleIds = result.messages.map((m) => m.ruleId);
135
- expect(ruleIds).not.toContain("traceability/require-story-annotation");
136
- expect(ruleIds).not.toContain("traceability/require-req-annotation");
137
- });
138
- it("[REQ-PRESETS-CANONICAL-RULE] recommended preset surfaces unified and legacy diagnostics together for missing annotations", async () => {
139
- const result = await lintTextWithConfig(codeMissingAll, "example.js", index_1.configs.recommended);
140
- const ruleIds = result.messages.map((m) => m.ruleId).sort();
141
- expect(ruleIds).toContain("traceability/require-traceability");
142
- expect(ruleIds).toContain("traceability/require-story-annotation");
143
- expect(ruleIds).toContain("traceability/require-req-annotation");
144
- });
145
- it("[REQ-PRESETS-CANONICAL-RULE] strict preset surfaces unified and legacy diagnostics together for missing annotations", async () => {
146
- const result = await lintTextWithConfig(codeMissingAll, "example.js", index_1.configs.strict);
147
- const ruleIds = result.messages.map((m) => m.ruleId).sort();
148
- expect(ruleIds).toContain("traceability/require-traceability");
149
- expect(ruleIds).toContain("traceability/require-story-annotation");
150
- expect(ruleIds).toContain("traceability/require-req-annotation");
151
- });
152
- });