eslint-plugin-traceability 1.0.4 → 1.0.6

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 (69) hide show
  1. package/.github/workflows/ci-cd.yml +36 -20
  2. package/.husky/pre-commit +1 -1
  3. package/.releaserc.json +15 -0
  4. package/CHANGELOG.md +8 -1
  5. package/CONTRIBUTING.md +15 -13
  6. package/docs/conventional-commits-guide.md +185 -0
  7. package/docs/decisions/004-automated-version-bumping-for-ci-cd.md +3 -1
  8. package/docs/decisions/006-semantic-release-for-automated-publishing.accepted.md +227 -0
  9. package/package.json +7 -2
  10. package/lib/src/index.d.ts +0 -80
  11. package/lib/src/index.js +0 -58
  12. package/lib/src/maintenance/batch.d.ts +0 -16
  13. package/lib/src/maintenance/batch.js +0 -28
  14. package/lib/src/maintenance/detect.d.ts +0 -6
  15. package/lib/src/maintenance/detect.js +0 -69
  16. package/lib/src/maintenance/index.d.ts +0 -14
  17. package/lib/src/maintenance/index.js +0 -22
  18. package/lib/src/maintenance/report.d.ts +0 -7
  19. package/lib/src/maintenance/report.js +0 -17
  20. package/lib/src/maintenance/update.d.ts +0 -6
  21. package/lib/src/maintenance/update.js +0 -67
  22. package/lib/src/maintenance/utils.d.ts +0 -6
  23. package/lib/src/maintenance/utils.js +0 -64
  24. package/lib/src/rules/require-branch-annotation.d.ts +0 -7
  25. package/lib/src/rules/require-branch-annotation.js +0 -111
  26. package/lib/src/rules/require-req-annotation.d.ts +0 -7
  27. package/lib/src/rules/require-req-annotation.js +0 -38
  28. package/lib/src/rules/require-story-annotation.d.ts +0 -7
  29. package/lib/src/rules/require-story-annotation.js +0 -50
  30. package/lib/src/rules/valid-annotation-format.d.ts +0 -10
  31. package/lib/src/rules/valid-annotation-format.js +0 -60
  32. package/lib/src/rules/valid-req-reference.d.ts +0 -3
  33. package/lib/src/rules/valid-req-reference.js +0 -104
  34. package/lib/src/rules/valid-story-reference.d.ts +0 -3
  35. package/lib/src/rules/valid-story-reference.js +0 -168
  36. package/lib/tests/fixtures/stale/example.d.ts +0 -0
  37. package/lib/tests/fixtures/stale/example.js +0 -3
  38. package/lib/tests/fixtures/update/example.d.ts +0 -0
  39. package/lib/tests/fixtures/update/example.js +0 -3
  40. package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
  41. package/lib/tests/fixtures/valid-annotations/example.js +0 -3
  42. package/lib/tests/maintenance/batch.test.d.ts +0 -1
  43. package/lib/tests/maintenance/batch.test.js +0 -79
  44. package/lib/tests/maintenance/detect-isolated.test.d.ts +0 -1
  45. package/lib/tests/maintenance/detect-isolated.test.js +0 -95
  46. package/lib/tests/maintenance/detect.test.d.ts +0 -1
  47. package/lib/tests/maintenance/detect.test.js +0 -23
  48. package/lib/tests/maintenance/report.test.d.ts +0 -1
  49. package/lib/tests/maintenance/report.test.js +0 -67
  50. package/lib/tests/maintenance/update-isolated.test.d.ts +0 -1
  51. package/lib/tests/maintenance/update-isolated.test.js +0 -66
  52. package/lib/tests/maintenance/update.test.d.ts +0 -1
  53. package/lib/tests/maintenance/update.test.js +0 -26
  54. package/lib/tests/plugin-default-export-and-configs.test.d.ts +0 -1
  55. package/lib/tests/plugin-default-export-and-configs.test.js +0 -72
  56. package/lib/tests/plugin-setup.test.d.ts +0 -1
  57. package/lib/tests/plugin-setup.test.js +0 -51
  58. package/lib/tests/rules/require-branch-annotation.test.d.ts +0 -1
  59. package/lib/tests/rules/require-branch-annotation.test.js +0 -253
  60. package/lib/tests/rules/require-req-annotation.test.d.ts +0 -1
  61. package/lib/tests/rules/require-req-annotation.test.js +0 -41
  62. package/lib/tests/rules/require-story-annotation.test.d.ts +0 -1
  63. package/lib/tests/rules/require-story-annotation.test.js +0 -36
  64. package/lib/tests/rules/valid-annotation-format.test.d.ts +0 -1
  65. package/lib/tests/rules/valid-annotation-format.test.js +0 -58
  66. package/lib/tests/rules/valid-req-reference.test.d.ts +0 -1
  67. package/lib/tests/rules/valid-req-reference.test.js +0 -87
  68. package/lib/tests/rules/valid-story-reference.test.d.ts +0 -1
  69. package/lib/tests/rules/valid-story-reference.test.js +0 -69
@@ -1,67 +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
- * Tests for: docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
38
- * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
39
- * @req REQ-MAINT-REPORT - Generate maintenance report
40
- * @req REQ-MAINT-SAFE - Ensure operations are safe and reversible
41
- */
42
- const fs = __importStar(require("fs"));
43
- const path = __importStar(require("path"));
44
- const os = __importStar(require("os"));
45
- const report_1 = require("../../src/maintenance/report");
46
- describe("generateMaintenanceReport (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
47
- let tmpDir;
48
- beforeAll(() => {
49
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "report-test-"));
50
- });
51
- afterAll(() => {
52
- fs.rmSync(tmpDir, { recursive: true, force: true });
53
- });
54
- it("[REQ-MAINT-REPORT] should return empty string when no operations", () => {
55
- const report = (0, report_1.generateMaintenanceReport)(tmpDir);
56
- expect(report).toBe("");
57
- });
58
- it("[REQ-MAINT-REPORT] should report stale story annotation", () => {
59
- const filePath = path.join(tmpDir, "stub.md");
60
- const content = `/**
61
- * @story non-existent.md
62
- */`;
63
- fs.writeFileSync(filePath, content);
64
- const report = (0, report_1.generateMaintenanceReport)(tmpDir);
65
- expect(report).toContain("non-existent.md");
66
- });
67
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,66 +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
- * Tests for: docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
38
- * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
39
- * @req REQ-MAINT-UPDATE - Update annotation references
40
- */
41
- const fs = __importStar(require("fs"));
42
- const path = __importStar(require("path"));
43
- const os = __importStar(require("os"));
44
- const update_1 = require("../../src/maintenance/update");
45
- describe("updateAnnotationReferences isolated (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
46
- it("[REQ-MAINT-UPDATE] updates @story annotations in files", () => {
47
- // Create a temporary directory for testing
48
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "tmp-"));
49
- const filePath = path.join(tmpDir, "file.ts");
50
- const originalContent = `
51
- /**
52
- * @story old.path.md
53
- */
54
- function foo() {}
55
- `;
56
- fs.writeFileSync(filePath, originalContent, "utf8");
57
- // Run the function under test
58
- const count = (0, update_1.updateAnnotationReferences)(tmpDir, "old.path.md", "new.path.md");
59
- expect(count).toBe(1);
60
- // Verify the file content was updated
61
- const updatedContent = fs.readFileSync(filePath, "utf8");
62
- expect(updatedContent).toContain("@story new.path.md");
63
- // Cleanup temporary directory
64
- fs.rmSync(tmpDir, { recursive: true, force: true });
65
- });
66
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +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/009.0-DEV-MAINTENANCE-TOOLS.story.md
8
- * @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
9
- * @req REQ-MAINT-UPDATE - Update annotation references
10
- */
11
- const fs_1 = __importDefault(require("fs"));
12
- const os_1 = __importDefault(require("os"));
13
- const path_1 = __importDefault(require("path"));
14
- const update_1 = require("../../src/maintenance/update");
15
- describe("updateAnnotationReferences (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
16
- it("[REQ-MAINT-UPDATE] should return 0 when no updates made", () => {
17
- const tmpDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "update-test-"));
18
- try {
19
- const count = (0, update_1.updateAnnotationReferences)(tmpDir, "old.md", "new.md");
20
- expect(count).toBe(0);
21
- }
22
- finally {
23
- fs_1.default.rmSync(tmpDir, { recursive: true, force: true });
24
- }
25
- });
26
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,72 +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
- * Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
38
- * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
39
- * @req REQ-PLUGIN-STRUCTURE - Validate plugin default export and configs in src/index.ts
40
- */
41
- const index_1 = __importStar(require("../src/index"));
42
- describe("Plugin Default Export and Configs (Story 001.0-DEV-PLUGIN-SETUP)", () => {
43
- it("[REQ-PLUGIN-STRUCTURE] default export includes rules and configs", () => {
44
- expect(index_1.default.rules).toBe(index_1.rules);
45
- expect(index_1.default.configs).toBe(index_1.configs);
46
- });
47
- it("[REQ-PLUGIN-STRUCTURE] rules object has correct rule names", () => {
48
- // Arrange: expected rule names in insertion order
49
- const expected = [
50
- "require-story-annotation",
51
- "require-req-annotation",
52
- "require-branch-annotation",
53
- "valid-annotation-format",
54
- "valid-story-reference",
55
- "valid-req-reference",
56
- ];
57
- // Act: get actual rule names from plugin
58
- const actual = Object.keys(index_1.rules);
59
- // Assert: actual matches expected
60
- expect(actual).toEqual(expected);
61
- });
62
- it("[REQ-RULE-REGISTRY] configs.recommended contains correct rule configuration", () => {
63
- const recommendedRules = index_1.configs.recommended[0].rules;
64
- expect(recommendedRules).toHaveProperty("traceability/require-story-annotation", "error");
65
- expect(recommendedRules).toHaveProperty("traceability/require-req-annotation", "error");
66
- expect(recommendedRules).toHaveProperty("traceability/require-branch-annotation", "error");
67
- });
68
- it("[REQ-CONFIG-SYSTEM] configs.strict contains same rules as recommended", () => {
69
- const strictRules = index_1.configs.strict[0].rules;
70
- expect(strictRules).toEqual(index_1.configs.recommended[0].rules);
71
- });
72
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +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
- * Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
38
- * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
39
- * @req REQ-PLUGIN-STRUCTURE - plugin exports rules and configs
40
- */
41
- const index_1 = __importStar(require("../src/index"));
42
- describe("Traceability ESLint Plugin (Story 001.0-DEV-PLUGIN-SETUP)", () => {
43
- it("[REQ-PLUGIN-STRUCTURE] plugin exports rules and configs", () => {
44
- expect(index_1.rules).toBeDefined();
45
- expect(index_1.configs).toBeDefined();
46
- expect(typeof index_1.rules).toBe("object");
47
- expect(typeof index_1.configs).toBe("object");
48
- expect(index_1.default.rules).toBe(index_1.rules);
49
- expect(index_1.default.configs).toBe(index_1.configs);
50
- });
51
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,253 +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/004.0-DEV-BRANCH-ANNOTATIONS.story.md
8
- * @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
9
- * @req REQ-BRANCH-DETECTION - Verify require-branch-annotation rule enforces branch annotations
10
- */
11
- const eslint_1 = require("eslint");
12
- const require_branch_annotation_1 = __importDefault(require("../../src/rules/require-branch-annotation"));
13
- const ruleTester = new eslint_1.RuleTester({
14
- languageOptions: { parserOptions: { ecmaVersion: 2020 } },
15
- });
16
- describe("Require Branch Annotation Rule (Story 004.0-DEV-BRANCH-ANNOTATIONS)", () => {
17
- ruleTester.run("require-branch-annotation", require_branch_annotation_1.default, {
18
- valid: [
19
- {
20
- name: "[REQ-BRANCH-DETECTION] valid fallback scanning comment detection",
21
- code: `switch (value) {
22
-
23
- // @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
24
- // @req REQ-BRANCH-DETECTION
25
- case 'z':
26
- break;
27
- }`,
28
- },
29
- {
30
- name: "[REQ-BRANCH-DETECTION] valid if-statement with annotations",
31
- code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
32
- // @req REQ-BRANCH-DETECTION
33
- if (condition) {}`,
34
- },
35
- {
36
- name: "[REQ-BRANCH-DETECTION] valid for loop with block comment annotations",
37
- code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
38
- /* @req REQ-BRANCH-DETECTION */
39
- for (let i = 0; i < 10; i++) {}`,
40
- },
41
- {
42
- name: "[REQ-BRANCH-DETECTION] valid switch-case with annotations",
43
- code: `switch (value) {
44
- // @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
45
- // @req REQ-BRANCH-DETECTION
46
- case 'a':
47
- break;
48
- default:
49
- break;
50
- }`,
51
- },
52
- {
53
- name: "[REQ-BRANCH-DETECTION] valid try-finally with annotations",
54
- code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
55
- /* @req REQ-BRANCH-DETECTION */
56
- try {
57
- doSomething();
58
- } finally {
59
- cleanUp();
60
- }`,
61
- },
62
- {
63
- name: "[REQ-BRANCH-DETECTION] valid catch with annotations",
64
- code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
65
- /* @req REQ-BRANCH-DETECTION */
66
- try {
67
- doSomething();
68
- }
69
- /* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
70
- /* @req REQ-BRANCH-DETECTION */
71
- catch (error) {
72
- handleError(error);
73
- }`,
74
- },
75
- {
76
- name: "[REQ-BRANCH-DETECTION] valid do-while loop with annotations",
77
- code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
78
- /* @req REQ-BRANCH-DETECTION */
79
- do {
80
- process();
81
- } while (condition);`,
82
- },
83
- {
84
- name: "[REQ-BRANCH-DETECTION] valid for-of loop with annotations",
85
- code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
86
- /* @req REQ-BRANCH-DETECTION */
87
- for (const item of items) {
88
- process(item);
89
- }`,
90
- },
91
- {
92
- name: "[REQ-BRANCH-DETECTION] valid for-in loop with annotations",
93
- code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
94
- /* @req REQ-BRANCH-DETECTION */
95
- for (const key in object) {
96
- console.log(key);
97
- }`,
98
- },
99
- {
100
- name: "[REQ-BRANCH-DETECTION] valid while loop with annotations",
101
- code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
102
- /* @req REQ-BRANCH-DETECTION */
103
- while (condition) {
104
- iterate();
105
- }`,
106
- },
107
- {
108
- name: "[REQ-BRANCH-DETECTION] valid switch-case with inline annotation",
109
- code: `switch (value) {
110
- // @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
111
- // @req REQ-BRANCH-DETECTION
112
- case 'a':
113
- break;
114
- }`,
115
- },
116
- {
117
- name: "[REQ-BRANCH-DETECTION] valid default case without annotations",
118
- code: `switch (value) {
119
- default:
120
- doSomething();
121
- }`,
122
- },
123
- ],
124
- invalid: [
125
- {
126
- name: "[REQ-BRANCH-DETECTION] missing annotations on if-statement",
127
- code: `if (condition) {}`,
128
- output: `// @story <story-file>.story.md
129
- if (condition) {}`,
130
- errors: [
131
- { messageId: "missingAnnotation", data: { missing: "@story" } },
132
- { messageId: "missingAnnotation", data: { missing: "@req" } },
133
- ],
134
- },
135
- {
136
- name: "[REQ-BRANCH-DETECTION] missing @req on for loop when only story present",
137
- code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
138
- for (let i = 0; i < 5; i++) {}`,
139
- output: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
140
- // @req <REQ-ID>
141
- for (let i = 0; i < 5; i++) {}`,
142
- errors: [{ messageId: "missingAnnotation", data: { missing: "@req" } }],
143
- },
144
- {
145
- name: "[REQ-BRANCH-DETECTION] missing @story on while loop when only req present",
146
- code: `// @req REQ-BRANCH-DETECTION
147
- while (true) {}`,
148
- output: `// @req REQ-BRANCH-DETECTION
149
- // @story <story-file>.story.md
150
- while (true) {}`,
151
- errors: [
152
- { messageId: "missingAnnotation", data: { missing: "@story" } },
153
- ],
154
- },
155
- {
156
- name: "[REQ-BRANCH-DETECTION] missing annotations on switch-case",
157
- code: `switch (value) {
158
- case 'a':
159
- break;
160
- }`,
161
- output: `switch (value) {
162
- // @story <story-file>.story.md
163
- case 'a':
164
- break;
165
- }`,
166
- errors: [
167
- { messageId: "missingAnnotation", data: { missing: "@story" } },
168
- { messageId: "missingAnnotation", data: { missing: "@req" } },
169
- ],
170
- },
171
- {
172
- name: "[REQ-BRANCH-DETECTION] missing annotations on do-while loop",
173
- code: `do {
174
- action();
175
- } while (condition);`,
176
- output: `// @story <story-file>.story.md
177
- do {
178
- action();
179
- } while (condition);`,
180
- errors: [
181
- { messageId: "missingAnnotation", data: { missing: "@story" } },
182
- { messageId: "missingAnnotation", data: { missing: "@req" } },
183
- ],
184
- },
185
- {
186
- name: "[REQ-BRANCH-DETECTION] missing annotations on for-of loop",
187
- code: `for (const item of items) {
188
- process(item);
189
- }`,
190
- output: `// @story <story-file>.story.md
191
- for (const item of items) {
192
- process(item);
193
- }`,
194
- errors: [
195
- { messageId: "missingAnnotation", data: { missing: "@story" } },
196
- { messageId: "missingAnnotation", data: { missing: "@req" } },
197
- ],
198
- },
199
- {
200
- name: "[REQ-BRANCH-DETECTION] missing annotations on for-in loop",
201
- code: `for (const key in object) {
202
- console.log(key);
203
- }`,
204
- output: `// @story <story-file>.story.md
205
- for (const key in object) {
206
- console.log(key);
207
- }`,
208
- errors: [
209
- { messageId: "missingAnnotation", data: { missing: "@story" } },
210
- { messageId: "missingAnnotation", data: { missing: "@req" } },
211
- ],
212
- },
213
- {
214
- name: "[REQ-BRANCH-DETECTION] missing annotations on try-catch blocks",
215
- code: `try {
216
- doSomething();
217
- } catch (error) {
218
- handleError(error);
219
- }`,
220
- output: `// @story <story-file>.story.md
221
- try {
222
- doSomething();
223
- } catch (error) {
224
- handleError(error);
225
- }`,
226
- errors: [
227
- { messageId: "missingAnnotation", data: { missing: "@story" } },
228
- { messageId: "missingAnnotation", data: { missing: "@req" } },
229
- { messageId: "missingAnnotation", data: { missing: "@story" } },
230
- { messageId: "missingAnnotation", data: { missing: "@req" } },
231
- ],
232
- },
233
- {
234
- name: "[REQ-BRANCH-DETECTION] missing annotations on switch-case with blank line",
235
- code: `switch (value) {
236
-
237
- case 'a':
238
- break;
239
- }`,
240
- output: `switch (value) {
241
-
242
- // @story <story-file>.story.md
243
- case 'a':
244
- break;
245
- }`,
246
- errors: [
247
- { messageId: "missingAnnotation", data: { missing: "@story" } },
248
- { messageId: "missingAnnotation", data: { missing: "@req" } },
249
- ],
250
- },
251
- ],
252
- });
253
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,41 +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/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
8
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
9
- * @req REQ-ANNOTATION-REQUIRED - Verify require-req-annotation rule enforces @req on functions
10
- */
11
- const eslint_1 = require("eslint");
12
- const require_req_annotation_1 = __importDefault(require("../../src/rules/require-req-annotation"));
13
- const ruleTester = new eslint_1.RuleTester();
14
- describe("Require Req Annotation Rule (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", () => {
15
- ruleTester.run("require-req-annotation", require_req_annotation_1.default, {
16
- valid: [
17
- {
18
- name: "[REQ-ANNOTATION-REQUIRED] valid with only @req annotation",
19
- code: `/**\n * @req REQ-EXAMPLE\n */\nfunction foo() {}`,
20
- },
21
- {
22
- name: "[REQ-ANNOTATION-REQUIRED] valid with @story and @req annotations",
23
- code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n * @req REQ-EXAMPLE\n */\nfunction bar() {}`,
24
- },
25
- ],
26
- invalid: [
27
- {
28
- name: "[REQ-ANNOTATION-REQUIRED] missing @req on function without JSDoc",
29
- code: `function baz() {}`,
30
- output: `/** @req <REQ-ID> */\nfunction baz() {}`,
31
- errors: [{ messageId: "missingReq" }],
32
- },
33
- {
34
- name: "[REQ-ANNOTATION-REQUIRED] missing @req on function with only @story annotation",
35
- code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction qux() {}`,
36
- output: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\n/** @req <REQ-ID> */\nfunction qux() {}`,
37
- errors: [{ messageId: "missingReq" }],
38
- },
39
- ],
40
- });
41
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,36 +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/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
8
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
9
- * @req REQ-ANNOTATION-REQUIRED - Verify require-story-annotation rule enforces @story annotation on functions
10
- */
11
- const eslint_1 = require("eslint");
12
- const require_story_annotation_1 = __importDefault(require("../../src/rules/require-story-annotation"));
13
- const ruleTester = new eslint_1.RuleTester();
14
- describe("Require Story Annotation Rule (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", () => {
15
- ruleTester.run("require-story-annotation", require_story_annotation_1.default, {
16
- valid: [
17
- {
18
- name: "[REQ-ANNOTATION-REQUIRED] valid with JSDoc @story annotation",
19
- code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction foo() {}`,
20
- },
21
- {
22
- name: "[REQ-ANNOTATION-REQUIRED] valid with line comment @story annotation",
23
- code: `// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
24
- function foo() {}`,
25
- },
26
- ],
27
- invalid: [
28
- {
29
- name: "[REQ-ANNOTATION-REQUIRED] missing @story annotation on function",
30
- code: `function bar() {}`,
31
- output: `/** @story <story-file>.story.md */\nfunction bar() {}`,
32
- errors: [{ messageId: "missingStory" }],
33
- },
34
- ],
35
- });
36
- });
@@ -1 +0,0 @@
1
- export {};