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,158 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
5
- * @req REQ-ANNOTATION-REQUIRED - Verify getNodeName resolves names for diverse AST node shapes
6
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const require_story_utils_1 = require("../../src/rules/helpers/require-story-utils");
10
- describe("Require Story Utils - getNodeName (Story 003.0)", () => {
11
- it("[REQ-ANNOTATION-REQUIRED] returns identifier name for Identifier and JSXIdentifier", () => {
12
- const idNode = { type: "Identifier", name: "foo" };
13
- const jsxIdNode = { type: "JSXIdentifier", name: "Bar" };
14
- expect((0, require_story_utils_1.getNodeName)(idNode)).toBe("foo");
15
- expect((0, require_story_utils_1.getNodeName)(jsxIdNode)).toBe("Bar");
16
- });
17
- it("[REQ-ANNOTATION-REQUIRED] returns null for identifier-like nodes without string name", () => {
18
- const badId = { type: "Identifier", name: 123 };
19
- const badJsxId = { type: "JSXIdentifier", name: null };
20
- expect((0, require_story_utils_1.getNodeName)(badId)).toBeNull();
21
- expect((0, require_story_utils_1.getNodeName)(badJsxId)).toBeNull();
22
- });
23
- it("[REQ-ANNOTATION-REQUIRED] converts simple Literal values into string names", () => {
24
- const stringLit = { type: "Literal", value: "name" };
25
- const numberLit = { type: "Literal", value: 42 };
26
- const boolLit = { type: "Literal", value: true };
27
- const nullLit = { type: "Literal", value: null };
28
- const objLit = { type: "Literal", value: { a: 1 } };
29
- expect((0, require_story_utils_1.getNodeName)(stringLit)).toBe("name");
30
- expect((0, require_story_utils_1.getNodeName)(numberLit)).toBe("42");
31
- expect((0, require_story_utils_1.getNodeName)(boolLit)).toBe("true");
32
- expect((0, require_story_utils_1.getNodeName)(nullLit)).toBeNull();
33
- expect((0, require_story_utils_1.getNodeName)(objLit)).toBeNull();
34
- });
35
- it("[REQ-ANNOTATION-REQUIRED] resolves simple, expression-free TemplateLiteral names", () => {
36
- const tplNode = {
37
- type: "TemplateLiteral",
38
- expressions: [],
39
- quasis: [
40
- { value: { cooked: "hello", raw: "hello" } },
41
- { value: { cooked: "-world", raw: "-world" } },
42
- ],
43
- };
44
- const withExpressions = {
45
- type: "TemplateLiteral",
46
- expressions: [{}],
47
- quasis: [{ value: { cooked: "ignored", raw: "ignored" } }],
48
- };
49
- expect((0, require_story_utils_1.getNodeName)(tplNode)).toBe("hello-world");
50
- expect((0, require_story_utils_1.getNodeName)(withExpressions)).toBeNull();
51
- });
52
- it("[REQ-ANNOTATION-REQUIRED] resolves non-computed member/qualified names and rejects computed", () => {
53
- const memberExpr = {
54
- type: "MemberExpression",
55
- object: { type: "Identifier", name: "obj" },
56
- property: { type: "Identifier", name: "prop" },
57
- computed: false,
58
- };
59
- const computedMember = {
60
- type: "MemberExpression",
61
- object: { type: "Identifier", name: "obj" },
62
- property: { type: "Literal", value: "dynamic" },
63
- computed: true,
64
- };
65
- const tsQualified = {
66
- type: "TSQualifiedName",
67
- left: { type: "Identifier", name: "Ns" },
68
- right: { type: "Identifier", name: "Type" },
69
- };
70
- const jsxMember = {
71
- type: "JSXMemberExpression",
72
- object: { type: "JSXIdentifier", name: "Ns" },
73
- property: { type: "JSXIdentifier", name: "Component" },
74
- };
75
- expect((0, require_story_utils_1.getNodeName)(memberExpr)).toBe("prop");
76
- expect((0, require_story_utils_1.getNodeName)(computedMember)).toBeNull();
77
- expect((0, require_story_utils_1.getNodeName)(tsQualified)).toBe("Type");
78
- expect((0, require_story_utils_1.getNodeName)(jsxMember)).toBe("Component");
79
- });
80
- it("[REQ-ANNOTATION-REQUIRED] extracts names from Property/ObjectProperty keys", () => {
81
- const prop = {
82
- type: "Property",
83
- key: { type: "Identifier", name: "propName" },
84
- };
85
- const objProp = {
86
- type: "ObjectProperty",
87
- key: { type: "Literal", value: "literalKey" },
88
- };
89
- const notProp = { type: "MethodDefinition", key: { name: "method" } };
90
- expect((0, require_story_utils_1.getNodeName)(prop)).toBe("propName");
91
- expect((0, require_story_utils_1.getNodeName)(objProp)).toBe("literalKey");
92
- expect((0, require_story_utils_1.getNodeName)(notProp)).toBe("method");
93
- });
94
- it("[REQ-ANNOTATION-REQUIRED] prefers direct id/key names before deeper inspection", () => {
95
- const funcNode = {
96
- type: "FunctionDeclaration",
97
- id: { type: "Identifier", name: "directName" },
98
- key: { type: "Identifier", name: "ignored" },
99
- };
100
- const keyNode = {
101
- type: "MethodDefinition",
102
- key: { type: "Identifier", name: "keyName" },
103
- };
104
- expect((0, require_story_utils_1.getNodeName)(funcNode)).toBe("directName");
105
- expect((0, require_story_utils_1.getNodeName)(keyNode)).toBe("keyName");
106
- });
107
- it("[REQ-ANNOTATION-REQUIRED] unwraps TSLiteralType and JSXNamespacedName wrappers", () => {
108
- const tsLiteral = {
109
- type: "TSLiteralType",
110
- literal: { type: "Literal", value: "wrapped" },
111
- };
112
- const jsxNamespaced = {
113
- type: "JSXNamespacedName",
114
- name: { type: "JSXIdentifier", name: "NsComponent" },
115
- };
116
- expect((0, require_story_utils_1.getNodeName)(tsLiteral)).toBe("wrapped");
117
- expect((0, require_story_utils_1.getNodeName)(jsxNamespaced)).toBe("NsComponent");
118
- });
119
- it("[REQ-ANNOTATION-REQUIRED] returns null for non-TemplateLiteral nodes passed to templateLiteralToString via getNodeName", () => {
120
- const fakeTemplate = {
121
- type: "Literal",
122
- value: "no-template",
123
- quasis: [{ value: { cooked: "ignored", raw: "ignored" } }],
124
- };
125
- const realTemplateWithExpr = {
126
- type: "TemplateLiteral",
127
- expressions: [{ type: "Identifier", name: "expr" }],
128
- quasis: [{ value: { cooked: "start", raw: "start" } }],
129
- };
130
- expect((0, require_story_utils_1.getNodeName)(fakeTemplate)).toBe("no-template");
131
- expect((0, require_story_utils_1.getNodeName)(realTemplateWithExpr)).toBeNull();
132
- });
133
- it("[REQ-ANNOTATION-REQUIRED] handles nullish and missing .value in TemplateLiteral quasis defensively", () => {
134
- const defensiveTemplate = {
135
- type: "TemplateLiteral",
136
- expressions: [],
137
- quasis: [
138
- null,
139
- { value: null },
140
- { value: { cooked: "part1", raw: "raw1" } },
141
- { value: { raw: "-only-raw" } },
142
- {},
143
- ],
144
- };
145
- expect((0, require_story_utils_1.getNodeName)(defensiveTemplate)).toBe("part1-only-raw");
146
- });
147
- it("[REQ-ANNOTATION-REQUIRED] follows generic .key fallback for other shapes", () => {
148
- const genericWithKey = {
149
- type: "SomeNode",
150
- key: { type: "Identifier", name: "viaKey" },
151
- };
152
- const genericWithoutKey = {
153
- type: "SomeNode",
154
- };
155
- expect((0, require_story_utils_1.getNodeName)(genericWithKey)).toBe("viaKey");
156
- expect((0, require_story_utils_1.getNodeName)(genericWithoutKey)).toBeNull();
157
- });
158
- });
@@ -1,7 +0,0 @@
1
- /**
2
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
3
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @req REQ-VISITORS-BEHAVIOR - Behavior tests for visitors in require-story-visitors.ts
5
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-VISITORS-BEHAVIOR
6
- */
7
- export {};
@@ -1,27 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
5
- * @req REQ-VISITORS-BEHAVIOR - Behavior tests for visitors in require-story-visitors.ts
6
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-VISITORS-BEHAVIOR
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const require_story_visitors_1 = require("../../src/rules/helpers/require-story-visitors");
10
- const makeVisitors = () => {
11
- const fakeContext = { getFilename: () => "file.ts" };
12
- const fakeSource = { getText: () => "" };
13
- const options = { shouldProcessNode: () => true };
14
- return (0, require_story_visitors_1.buildVisitors)(fakeContext, fakeSource, options);
15
- };
16
- describe("Require Story Visitors - behavior (Story 003.0)", () => {
17
- test("build visitors returns handlers for FunctionDeclaration and ArrowFunctionExpression", () => {
18
- const visitors = makeVisitors();
19
- expect(typeof visitors.FunctionDeclaration).toBe("function");
20
- expect(typeof visitors.ArrowFunctionExpression).toBe("function");
21
- });
22
- test("FunctionDeclaration handler uses context.getFilename and doesn't throw when node lacks id", () => {
23
- const visitors = makeVisitors();
24
- const handler = visitors.FunctionDeclaration;
25
- expect(() => handler({})).not.toThrow();
26
- });
27
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,95 +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:
9
- * - docs/stories/020.0-DEV-TEST-ANNOTATION-VALIDATION.story.md
10
- * - docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md
11
- * @supports docs/stories/020.0-DEV-TEST-ANNOTATION-VALIDATION.story.md REQ-TEST-FILE-SUPPORTS REQ-TEST-DESCRIBE-STORY REQ-TEST-IT-REQ-PREFIX REQ-TEST-FRAMEWORK-COMPAT REQ-TEST-PATTERN-DETECT
12
- * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-TEMPLATE REQ-TEST-FIX-PREFIX-FORMAT REQ-TEST-FIX-SAFE REQ-TEST-FIX-PRESERVE REQ-TEST-FIX-PLACEHOLDER REQ-TEST-FIX-NO-INFERENCE
13
- */
14
- const eslint_1 = require("eslint");
15
- const require_test_traceability_1 = __importDefault(require("../../src/rules/require-test-traceability"));
16
- const ruleTester = new eslint_1.RuleTester({
17
- languageOptions: {
18
- parserOptions: { ecmaVersion: 2020, sourceType: "module" },
19
- },
20
- });
21
- describe("require-test-traceability rule (Stories 020.0 and 021.0)", () => {
22
- ruleTester.run("require-test-traceability", require_test_traceability_1.default, {
23
- valid: [
24
- {
25
- // [REQ-TEST-FILE-SUPPORTS] file-level @supports present and describe/test satisfied
26
- code: `/**\n * @supports docs/stories/020.0-DEV-TEST-ANNOTATION-VALIDATION.story.md REQ-TEST-FILE-SUPPORTS\n */\ndescribe('Story 020.0-DEV-TEST-ANNOTATION-VALIDATION', () => { it('[REQ-EXAMPLE] does something', () => {}); });`,
27
- filename: "tests/rules/require-test-traceability.test.ts",
28
- },
29
- {
30
- // [REQ-TEST-FRAMEWORK-COMPAT] mocha style `context` is treated as a test call but only name checks apply
31
- code: `/**\n * @supports docs/stories/020.0-DEV-TEST-ANNOTATION-VALIDATION.story.md REQ-TEST-FRAMEWORK-COMPAT\n */\ncontext('Story 020.0-DEV-TEST-ANNOTATION-VALIDATION', () => {});`,
32
- filename: "tests/some/context.test.ts",
33
- },
34
- {
35
- // Ensure non-test files are ignored (REQ-TEST-PATTERN-DETECT)
36
- code: `/**\n * @supports docs/stories/020.0-DEV-TEST-ANNOTATION-VALIDATION.story.md REQ-TEST-PATTERN-DETECT\n */\ndescribe('Story 020.0-DEV-TEST-ANNOTATION-VALIDATION', () => {});`,
37
- filename: "src/not-a-test-file.ts",
38
- },
39
- {
40
- // [REQ-TEST-FIX-PREFIX-FORMAT] already-correct [REQ-XXX] prefix is left unchanged by auto-fix
41
- code: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\ndescribe('Story 021.0-DEV-TEST-ANNOTATION-AUTO-FIX', () => { it('[REQ-TRACE-123] behaves correctly', () => {}); });`,
42
- filename: "tests/rules/correct-prefix-autofix.test.ts",
43
- },
44
- ],
45
- invalid: [
46
- {
47
- // [REQ-TEST-FIX-TEMPLATE] missing @supports in test file -> insert default placeholder template
48
- code: `describe('Story 020.0-DEV-TEST-ANNOTATION-VALIDATION', () => { it('[REQ-ONE] works', () => {}); });`,
49
- output: `/**\n * @supports docs/stories/XXX.X-STORY-NAME.story.md REQ-XXX-YYY REQ-XXX-ZZZ\n * TODO: Replace the placeholder story path and REQ-IDs with real values for this test file.\n */\ndescribe('Story 020.0-DEV-TEST-ANNOTATION-VALIDATION', () => { it('[REQ-ONE] works', () => {}); });`,
50
- filename: "tests/rules/missing-supports.test.ts",
51
- errors: [{ messageId: "missingFileSupports" }],
52
- },
53
- {
54
- // [REQ-TEST-DESCRIBE-STORY] describe without story phrase still reported (no auto-fix)
55
- code: `/**\n * @supports docs/stories/020.0-DEV-TEST-ANNOTATION-VALIDATION.story.md REQ-TEST-DESCRIBE-STORY\n */\ndescribe('no story reference here', () => {});`,
56
- filename: "tests/rules/bad-describe.test.ts",
57
- errors: [{ messageId: "missingDescribeStory" }],
58
- },
59
- {
60
- // [REQ-TEST-IT-REQ-PREFIX][REQ-TEST-FIX-NO-INFERENCE] test name without any REQ prefix -> error but no auto-fix
61
- code: `/**\n * @supports docs/stories/020.0-DEV-TEST-ANNOTATION-VALIDATION.story.md REQ-TEST-IT-REQ-PREFIX\n */\nit('missing prefix', () => {});`,
62
- filename: "tests/rules/bad-test-name-no-prefix.test.ts",
63
- errors: [{ messageId: "missingReqPrefix" }],
64
- },
65
- {
66
- // [REQ-TEST-FIX-PREFIX-FORMAT] malformed prefix with extra spaces in brackets
67
- code: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('[ REQ-TEST-FIX ] does something', () => {});`,
68
- output: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('[REQ-TEST-FIX] does something', () => {});`,
69
- filename: "tests/rules/malformed-prefix-spacing.test.ts",
70
- errors: [{ messageId: "missingReqPrefix" }],
71
- },
72
- {
73
- // [REQ-TEST-FIX-PREFIX-FORMAT] malformed prefix with underscore delimiter
74
- code: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('[REQ_TEST_FIX] does something', () => {});`,
75
- output: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('[REQ-TEST-FIX] does something', () => {});`,
76
- filename: "tests/rules/malformed-prefix-underscore.test.ts",
77
- errors: [{ messageId: "missingReqPrefix" }],
78
- },
79
- {
80
- // [REQ-TEST-FIX-PREFIX-FORMAT] malformed prefix with lowercase req
81
- code: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('[req-lowercase] bad casing', () => {});`,
82
- output: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('[REQ-LOWERCASE] bad casing', () => {});`,
83
- filename: "tests/rules/malformed-prefix-lowercase.test.ts",
84
- errors: [{ messageId: "missingReqPrefix" }],
85
- },
86
- {
87
- // [REQ-TEST-FIX-PREFIX-FORMAT] malformed prefix using parentheses
88
- code: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('(REQ-PAREN) with parens', () => {});`,
89
- output: `/**\n * @supports docs/stories/021.0-DEV-TEST-ANNOTATION-AUTO-FIX.story.md REQ-TEST-FIX-PREFIX-FORMAT\n */\nit('[REQ-PAREN] with parens', () => {});`,
90
- filename: "tests/rules/malformed-prefix-parens.test.ts",
91
- errors: [{ messageId: "missingReqPrefix" }],
92
- },
93
- ],
94
- });
95
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * Tests for: docs/stories/024.0-DEV-IGNORE-INLINE-CODE-REFS.story.md
3
- * @story docs/stories/024.0-DEV-IGNORE-INLINE-CODE-REFS.story.md
4
- * @req REQ-IGNORE-INLINE-CODE - Strip backtick-wrapped content before annotation detection
5
- * @req REQ-PRESERVE-BOUNDARIES - Replace backtick-wrapped content with spaces to preserve word boundaries
6
- * @req REQ-CENTRALIZED-FILTER - Apply backtick filtering in normalizeCommentLine for all rules
7
- */
8
- export {};
@@ -1,47 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tests for: docs/stories/024.0-DEV-IGNORE-INLINE-CODE-REFS.story.md
4
- * @story docs/stories/024.0-DEV-IGNORE-INLINE-CODE-REFS.story.md
5
- * @req REQ-IGNORE-INLINE-CODE - Strip backtick-wrapped content before annotation detection
6
- * @req REQ-PRESERVE-BOUNDARIES - Replace backtick-wrapped content with spaces to preserve word boundaries
7
- * @req REQ-CENTRALIZED-FILTER - Apply backtick filtering in normalizeCommentLine for all rules
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const globals_1 = require("@jest/globals");
11
- const valid_annotation_format_internal_1 = require("../../src/rules/helpers/valid-annotation-format-internal");
12
- (0, globals_1.describe)("normalizeCommentLine inline code filtering (Story 024.0-DEV-IGNORE-INLINE-CODE-REFS)", () => {
13
- (0, globals_1.it)("[REQ-IGNORE-INLINE-CODE] ignores backtick-wrapped @story in line without real annotations", () => {
14
- const raw = "This rule uses `@story` and other tags";
15
- const normalized = (0, valid_annotation_format_internal_1.normalizeCommentLine)(raw);
16
- (0, globals_1.expect)(normalized).toBe("This rule uses and other tags");
17
- (0, globals_1.expect)(normalized).not.toMatch(/@story|@req|@supports/);
18
- });
19
- (0, globals_1.it)("[REQ-IGNORE-INLINE-CODE] ignores backtick-wrapped @req in line without real annotations", () => {
20
- const raw = "Legacy pattern `@req` should not be treated as annotation";
21
- const normalized = (0, valid_annotation_format_internal_1.normalizeCommentLine)(raw);
22
- (0, globals_1.expect)(normalized).toBe("Legacy pattern should not be treated as annotation");
23
- (0, globals_1.expect)(normalized).not.toMatch(/@story|@req|@supports/);
24
- });
25
- (0, globals_1.it)("[REQ-IGNORE-INLINE-CODE][REQ-PRESERVE-BOUNDARIES] preserves spacing when removing backtick segments", () => {
26
- const raw = "`@story` + `@req` docs";
27
- const normalized = (0, valid_annotation_format_internal_1.normalizeCommentLine)(raw);
28
- (0, globals_1.expect)(normalized).toBe(" + docs");
29
- (0, globals_1.expect)(normalized).not.toMatch(/@story|@req|@supports/);
30
- });
31
- (0, globals_1.it)("[REQ-IGNORE-INLINE-CODE] still detects real @story annotation outside backticks", () => {
32
- const raw = "using `@supports` and real @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md";
33
- const normalized = (0, valid_annotation_format_internal_1.normalizeCommentLine)(raw);
34
- (0, globals_1.expect)(normalized).toBe("@story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md");
35
- });
36
- (0, globals_1.it)("[REQ-IGNORE-INLINE-CODE][REQ-PRESERVE-BOUNDARIES] handles multiple backtick segments on one line", () => {
37
- const raw = "first `@story` and second `@req` markers";
38
- const normalized = (0, valid_annotation_format_internal_1.normalizeCommentLine)(raw);
39
- (0, globals_1.expect)(normalized).toBe("first and second markers");
40
- (0, globals_1.expect)(normalized).not.toMatch(/@story|@req|@supports/);
41
- });
42
- (0, globals_1.it)("[REQ-IGNORE-INLINE-CODE] leaves lines without backticks unchanged apart from existing normalization", () => {
43
- const raw = " * @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md";
44
- const normalized = (0, valid_annotation_format_internal_1.normalizeCommentLine)(raw);
45
- (0, globals_1.expect)(normalized).toBe("@story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md");
46
- });
47
- });
@@ -1 +0,0 @@
1
- export {};