eslint-plugin-traceability 1.0.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.
- package/.env.example +6 -0
- package/.github/workflows/ci-cd.yml +56 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/.prettierignore +23 -0
- package/.prettierrc +4 -0
- package/.voder/history.md +164 -0
- package/.voder/implementation-progress.md +145 -0
- package/.voder/last-action.md +106 -0
- package/.voder/plan.md +15 -0
- package/.voder/progress-chart.png +0 -0
- package/.voder/progress-log-areas.csv +34 -0
- package/.voder/progress-log.csv +33 -0
- package/.voder/traceability/docs-stories-001.0-DEV-PLUGIN-SETUP.story.xml +17 -0
- package/.voder/traceability/docs-stories-002.0-DEV-ESLINT-CONFIG.story.xml +13 -0
- package/.voder/traceability/docs-stories-003.0-DEV-FUNCTION-ANNOTATIONS.story.xml +9 -0
- package/.voder/traceability/docs-stories-004.0-DEV-BRANCH-ANNOTATIONS.story.xml +9 -0
- package/.voder/traceability/docs-stories-005.0-DEV-ANNOTATION-VALIDATION.story.xml +9 -0
- package/.voder/traceability/docs-stories-006.0-DEV-FILE-VALIDATION.story.xml +9 -0
- package/.voder/traceability/docs-stories-007.0-DEV-ERROR-REPORTING.story.xml +9 -0
- package/.voder/traceability/docs-stories-008.0-DEV-AUTO-FIX.story.xml +9 -0
- package/.voder/traceability/docs-stories-009.0-DEV-MAINTENANCE-TOOLS.story.xml +16 -0
- package/.voder/traceability/docs-stories-010.0-DEV-DEEP-VALIDATION.story.xml +11 -0
- package/CHANGELOG.md +31 -0
- package/CONTRIBUTING.md +97 -0
- package/LICENSE +21 -0
- package/README.md +159 -0
- package/cli-integration.js +157 -0
- package/docs/cli-integration.md +103 -0
- package/docs/config-presets.md +38 -0
- package/docs/decisions/001-typescript-for-eslint-plugin.accepted.md +111 -0
- package/docs/decisions/002-jest-for-eslint-testing.accepted.md +137 -0
- package/docs/decisions/003-code-quality-ratcheting-plan.md +48 -0
- package/docs/eslint-9-setup-guide.md +517 -0
- package/docs/eslint-plugin-development-guide.md +483 -0
- package/docs/jest-testing-guide.md +100 -0
- package/docs/rules/require-branch-annotation.md +34 -0
- package/docs/rules/require-req-annotation.md +39 -0
- package/docs/rules/require-story-annotation.md +36 -0
- package/docs/rules/valid-annotation-format.md +52 -0
- package/docs/rules/valid-req-reference.md +58 -0
- package/docs/rules/valid-story-reference.md +47 -0
- package/docs/security-incidents/unresolved-vulnerabilities.md +11 -0
- package/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md +82 -0
- package/docs/stories/002.0-DEV-ESLINT-CONFIG.story.md +82 -0
- package/docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md +85 -0
- package/docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md +107 -0
- package/docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md +119 -0
- package/docs/stories/006.0-DEV-FILE-VALIDATION.story.md +127 -0
- package/docs/stories/007.0-DEV-ERROR-REPORTING.story.md +89 -0
- package/docs/stories/008.0-DEV-AUTO-FIX.story.md +104 -0
- package/docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md +104 -0
- package/docs/stories/010.0-DEV-DEEP-VALIDATION.story.md +110 -0
- package/docs/stories/developer-story.map.md +118 -0
- package/eslint.config.js +146 -0
- package/jest.config.js +21 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +11 -0
- package/lib/src/index.d.ts +80 -0
- package/lib/src/index.js +58 -0
- package/lib/src/maintenance/batch.d.ts +16 -0
- package/lib/src/maintenance/batch.js +28 -0
- package/lib/src/maintenance/detect.d.ts +6 -0
- package/lib/src/maintenance/detect.js +69 -0
- package/lib/src/maintenance/index.d.ts +14 -0
- package/lib/src/maintenance/index.js +22 -0
- package/lib/src/maintenance/report.d.ts +7 -0
- package/lib/src/maintenance/report.js +17 -0
- package/lib/src/maintenance/update.d.ts +6 -0
- package/lib/src/maintenance/update.js +67 -0
- package/lib/src/maintenance/utils.d.ts +6 -0
- package/lib/src/maintenance/utils.js +64 -0
- package/lib/src/rules/require-branch-annotation.d.ts +7 -0
- package/lib/src/rules/require-branch-annotation.js +111 -0
- package/lib/src/rules/require-req-annotation.d.ts +7 -0
- package/lib/src/rules/require-req-annotation.js +38 -0
- package/lib/src/rules/require-story-annotation.d.ts +7 -0
- package/lib/src/rules/require-story-annotation.js +50 -0
- package/lib/src/rules/valid-annotation-format.d.ts +10 -0
- package/lib/src/rules/valid-annotation-format.js +60 -0
- package/lib/src/rules/valid-req-reference.d.ts +3 -0
- package/lib/src/rules/valid-req-reference.js +104 -0
- package/lib/src/rules/valid-story-reference.d.ts +3 -0
- package/lib/src/rules/valid-story-reference.js +168 -0
- package/lib/tests/basic.test.d.ts +1 -0
- package/lib/tests/basic.test.js +51 -0
- package/lib/tests/fixtures/stale/example.d.ts +0 -0
- package/lib/tests/fixtures/stale/example.js +3 -0
- package/lib/tests/fixtures/update/example.d.ts +0 -0
- package/lib/tests/fixtures/update/example.js +3 -0
- package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
- package/lib/tests/fixtures/valid-annotations/example.js +3 -0
- package/lib/tests/index.test.d.ts +1 -0
- package/lib/tests/index.test.js +68 -0
- package/lib/tests/integration/file-validation.test.d.ts +1 -0
- package/lib/tests/integration/file-validation.test.js +60 -0
- package/lib/tests/integration/plugin-validation.test.d.ts +1 -0
- package/lib/tests/integration/plugin-validation.test.js +77 -0
- package/lib/tests/maintenance/batch.test.d.ts +1 -0
- package/lib/tests/maintenance/batch.test.js +79 -0
- package/lib/tests/maintenance/detect-isolated.test.d.ts +1 -0
- package/lib/tests/maintenance/detect-isolated.test.js +90 -0
- package/lib/tests/maintenance/detect.test.d.ts +1 -0
- package/lib/tests/maintenance/detect.test.js +23 -0
- package/lib/tests/maintenance/report.test.d.ts +1 -0
- package/lib/tests/maintenance/report.test.js +67 -0
- package/lib/tests/maintenance/update-isolated.test.d.ts +1 -0
- package/lib/tests/maintenance/update-isolated.test.js +66 -0
- package/lib/tests/maintenance/update.test.d.ts +1 -0
- package/lib/tests/maintenance/update.test.js +26 -0
- package/lib/tests/rules/require-branch-annotation.test.d.ts +1 -0
- package/lib/tests/rules/require-branch-annotation.test.js +251 -0
- package/lib/tests/rules/require-req-annotation.test.d.ts +1 -0
- package/lib/tests/rules/require-req-annotation.test.js +41 -0
- package/lib/tests/rules/require-story-annotation.test.d.ts +1 -0
- package/lib/tests/rules/require-story-annotation.test.js +35 -0
- package/lib/tests/rules/valid-annotation-format.test.d.ts +1 -0
- package/lib/tests/rules/valid-annotation-format.test.js +58 -0
- package/lib/tests/rules/valid-req-reference.test.d.ts +1 -0
- package/lib/tests/rules/valid-req-reference.test.js +87 -0
- package/lib/tests/rules/valid-story-reference.test.d.ts +1 -0
- package/lib/tests/rules/valid-story-reference.test.js +69 -0
- package/package.json +67 -0
- package/src/index.ts +56 -0
- package/src/maintenance/batch.ts +29 -0
- package/src/maintenance/detect.ts +42 -0
- package/src/maintenance/index.ts +14 -0
- package/src/maintenance/report.ts +15 -0
- package/src/maintenance/update.ts +40 -0
- package/src/maintenance/utils.ts +28 -0
- package/src/rules/require-branch-annotation.ts +114 -0
- package/src/rules/require-req-annotation.ts +36 -0
- package/src/rules/require-story-annotation.ts +52 -0
- package/src/rules/valid-annotation-format.ts +62 -0
- package/src/rules/valid-req-reference.ts +114 -0
- package/src/rules/valid-story-reference.ts +213 -0
- package/tests/basic.test.ts +17 -0
- package/tests/fixtures/stale/example.ts +2 -0
- package/tests/fixtures/story_bullet.md +6 -0
- package/tests/fixtures/update/example.ts +2 -0
- package/tests/fixtures/valid-annotations/example.ts +2 -0
- package/tests/index.test.ts +46 -0
- package/tests/integration/file-validation.test.ts +67 -0
- package/tests/integration/plugin-validation.test.ts +79 -0
- package/tests/maintenance/batch.test.ts +55 -0
- package/tests/maintenance/detect-isolated.test.ts +61 -0
- package/tests/maintenance/detect.test.ts +19 -0
- package/tests/maintenance/report.test.ts +37 -0
- package/tests/maintenance/update-isolated.test.ts +39 -0
- package/tests/maintenance/update.test.ts +21 -0
- package/tests/rules/require-branch-annotation.test.ts +248 -0
- package/tests/rules/require-req-annotation.test.ts +38 -0
- package/tests/rules/require-story-annotation.test.ts +32 -0
- package/tests/rules/valid-annotation-format.test.ts +55 -0
- package/tests/rules/valid-req-reference.test.ts +85 -0
- package/tests/rules/valid-story-reference.test.ts +66 -0
- package/tsconfig.json +15 -0
- package/user-docs/api-reference.md +135 -0
- package/user-docs/examples.md +73 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,251 @@
|
|
|
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
|
+
// Tests for: docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
7
|
+
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
8
|
+
// @req REQ-BRANCH-DETECTION - Verify require-branch-annotation rule enforces branch annotations
|
|
9
|
+
const eslint_1 = require("eslint");
|
|
10
|
+
const require_branch_annotation_1 = __importDefault(require("../../src/rules/require-branch-annotation"));
|
|
11
|
+
const ruleTester = new eslint_1.RuleTester({
|
|
12
|
+
languageOptions: { parserOptions: { ecmaVersion: 2020 } },
|
|
13
|
+
});
|
|
14
|
+
describe("Require Branch Annotation Rule (Story 004.0-DEV-BRANCH-ANNOTATIONS)", () => {
|
|
15
|
+
ruleTester.run("require-branch-annotation", require_branch_annotation_1.default, {
|
|
16
|
+
valid: [
|
|
17
|
+
{
|
|
18
|
+
name: "[REQ-BRANCH-DETECTION] valid fallback scanning comment detection",
|
|
19
|
+
code: `switch (value) {
|
|
20
|
+
|
|
21
|
+
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
22
|
+
// @req REQ-BRANCH-DETECTION
|
|
23
|
+
case 'z':
|
|
24
|
+
break;
|
|
25
|
+
}`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "[REQ-BRANCH-DETECTION] valid if-statement with annotations",
|
|
29
|
+
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
30
|
+
// @req REQ-BRANCH-DETECTION
|
|
31
|
+
if (condition) {}`,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "[REQ-BRANCH-DETECTION] valid for loop with block comment annotations",
|
|
35
|
+
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
36
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
37
|
+
for (let i = 0; i < 10; i++) {}`,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "[REQ-BRANCH-DETECTION] valid switch-case with annotations",
|
|
41
|
+
code: `switch (value) {
|
|
42
|
+
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
43
|
+
// @req REQ-BRANCH-DETECTION
|
|
44
|
+
case 'a':
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
break;
|
|
48
|
+
}`,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "[REQ-BRANCH-DETECTION] valid try-finally with annotations",
|
|
52
|
+
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
53
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
54
|
+
try {
|
|
55
|
+
doSomething();
|
|
56
|
+
} finally {
|
|
57
|
+
cleanUp();
|
|
58
|
+
}`,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "[REQ-BRANCH-DETECTION] valid catch with annotations",
|
|
62
|
+
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
63
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
64
|
+
try {
|
|
65
|
+
doSomething();
|
|
66
|
+
}
|
|
67
|
+
/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
68
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
69
|
+
catch (error) {
|
|
70
|
+
handleError(error);
|
|
71
|
+
}`,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "[REQ-BRANCH-DETECTION] valid do-while loop with annotations",
|
|
75
|
+
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
76
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
77
|
+
do {
|
|
78
|
+
process();
|
|
79
|
+
} while (condition);`,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "[REQ-BRANCH-DETECTION] valid for-of loop with annotations",
|
|
83
|
+
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
84
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
85
|
+
for (const item of items) {
|
|
86
|
+
process(item);
|
|
87
|
+
}`,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "[REQ-BRANCH-DETECTION] valid for-in loop with annotations",
|
|
91
|
+
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
92
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
93
|
+
for (const key in object) {
|
|
94
|
+
console.log(key);
|
|
95
|
+
}`,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "[REQ-BRANCH-DETECTION] valid while loop with annotations",
|
|
99
|
+
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
100
|
+
/* @req REQ-BRANCH-DETECTION */
|
|
101
|
+
while (condition) {
|
|
102
|
+
iterate();
|
|
103
|
+
}`,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "[REQ-BRANCH-DETECTION] valid switch-case with inline annotation",
|
|
107
|
+
code: `switch (value) {
|
|
108
|
+
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
109
|
+
// @req REQ-BRANCH-DETECTION
|
|
110
|
+
case 'a':
|
|
111
|
+
break;
|
|
112
|
+
}`,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "[REQ-BRANCH-DETECTION] valid default case without annotations",
|
|
116
|
+
code: `switch (value) {
|
|
117
|
+
default:
|
|
118
|
+
doSomething();
|
|
119
|
+
}`,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
invalid: [
|
|
123
|
+
{
|
|
124
|
+
name: "[REQ-BRANCH-DETECTION] missing annotations on if-statement",
|
|
125
|
+
code: `if (condition) {}`,
|
|
126
|
+
output: `// @story <story-file>.story.md
|
|
127
|
+
if (condition) {}`,
|
|
128
|
+
errors: [
|
|
129
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
130
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "[REQ-BRANCH-DETECTION] missing @req on for loop when only story present",
|
|
135
|
+
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
136
|
+
for (let i = 0; i < 5; i++) {}`,
|
|
137
|
+
output: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
138
|
+
// @req <REQ-ID>
|
|
139
|
+
for (let i = 0; i < 5; i++) {}`,
|
|
140
|
+
errors: [{ messageId: "missingAnnotation", data: { missing: "@req" } }],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "[REQ-BRANCH-DETECTION] missing @story on while loop when only req present",
|
|
144
|
+
code: `// @req REQ-BRANCH-DETECTION
|
|
145
|
+
while (true) {}`,
|
|
146
|
+
output: `// @req REQ-BRANCH-DETECTION
|
|
147
|
+
// @story <story-file>.story.md
|
|
148
|
+
while (true) {}`,
|
|
149
|
+
errors: [
|
|
150
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "[REQ-BRANCH-DETECTION] missing annotations on switch-case",
|
|
155
|
+
code: `switch (value) {
|
|
156
|
+
case 'a':
|
|
157
|
+
break;
|
|
158
|
+
}`,
|
|
159
|
+
output: `switch (value) {
|
|
160
|
+
// @story <story-file>.story.md
|
|
161
|
+
case 'a':
|
|
162
|
+
break;
|
|
163
|
+
}`,
|
|
164
|
+
errors: [
|
|
165
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
166
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "[REQ-BRANCH-DETECTION] missing annotations on do-while loop",
|
|
171
|
+
code: `do {
|
|
172
|
+
action();
|
|
173
|
+
} while (condition);`,
|
|
174
|
+
output: `// @story <story-file>.story.md
|
|
175
|
+
do {
|
|
176
|
+
action();
|
|
177
|
+
} while (condition);`,
|
|
178
|
+
errors: [
|
|
179
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
180
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "[REQ-BRANCH-DETECTION] missing annotations on for-of loop",
|
|
185
|
+
code: `for (const item of items) {
|
|
186
|
+
process(item);
|
|
187
|
+
}`,
|
|
188
|
+
output: `// @story <story-file>.story.md
|
|
189
|
+
for (const item of items) {
|
|
190
|
+
process(item);
|
|
191
|
+
}`,
|
|
192
|
+
errors: [
|
|
193
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
194
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "[REQ-BRANCH-DETECTION] missing annotations on for-in loop",
|
|
199
|
+
code: `for (const key in object) {
|
|
200
|
+
console.log(key);
|
|
201
|
+
}`,
|
|
202
|
+
output: `// @story <story-file>.story.md
|
|
203
|
+
for (const key in object) {
|
|
204
|
+
console.log(key);
|
|
205
|
+
}`,
|
|
206
|
+
errors: [
|
|
207
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
208
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "[REQ-BRANCH-DETECTION] missing annotations on try-catch blocks",
|
|
213
|
+
code: `try {
|
|
214
|
+
doSomething();
|
|
215
|
+
} catch (error) {
|
|
216
|
+
handleError(error);
|
|
217
|
+
}`,
|
|
218
|
+
output: `// @story <story-file>.story.md
|
|
219
|
+
try {
|
|
220
|
+
doSomething();
|
|
221
|
+
} catch (error) {
|
|
222
|
+
handleError(error);
|
|
223
|
+
}`,
|
|
224
|
+
errors: [
|
|
225
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
226
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
227
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
228
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "[REQ-BRANCH-DETECTION] missing annotations on switch-case with blank line",
|
|
233
|
+
code: `switch (value) {
|
|
234
|
+
|
|
235
|
+
case 'a':
|
|
236
|
+
break;
|
|
237
|
+
}`,
|
|
238
|
+
output: `switch (value) {
|
|
239
|
+
|
|
240
|
+
// @story <story-file>.story.md
|
|
241
|
+
case 'a':
|
|
242
|
+
break;
|
|
243
|
+
}`,
|
|
244
|
+
errors: [
|
|
245
|
+
{ messageId: "missingAnnotation", data: { missing: "@story" } },
|
|
246
|
+
{ messageId: "missingAnnotation", data: { missing: "@req" } },
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
});
|
|
251
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
*/
|
|
10
|
+
const eslint_1 = require("eslint");
|
|
11
|
+
const require_story_annotation_1 = __importDefault(require("../../src/rules/require-story-annotation"));
|
|
12
|
+
const ruleTester = new eslint_1.RuleTester();
|
|
13
|
+
describe("Require Story Annotation Rule (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", () => {
|
|
14
|
+
ruleTester.run("require-story-annotation", require_story_annotation_1.default, {
|
|
15
|
+
valid: [
|
|
16
|
+
{
|
|
17
|
+
name: "[REQ-ANNOTATION-REQUIRED] valid with JSDoc @story annotation",
|
|
18
|
+
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction foo() {}`,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "[REQ-ANNOTATION-REQUIRED] valid with line comment @story annotation",
|
|
22
|
+
code: `// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
23
|
+
function foo() {}`,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
invalid: [
|
|
27
|
+
{
|
|
28
|
+
name: "[REQ-ANNOTATION-REQUIRED] missing @story annotation on function",
|
|
29
|
+
code: `function bar() {}`,
|
|
30
|
+
output: `/** @story <story-file>.story.md */\nfunction bar() {}`,
|
|
31
|
+
errors: [{ messageId: "missingStory" }],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
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/005.0-DEV-ANNOTATION-VALIDATION.story.md
|
|
8
|
+
* @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md
|
|
9
|
+
* @req REQ-FORMAT-SPECIFICATION - Verify valid-annotation-format rule enforces annotation format syntax
|
|
10
|
+
*/
|
|
11
|
+
const eslint_1 = require("eslint");
|
|
12
|
+
const valid_annotation_format_1 = __importDefault(require("../../src/rules/valid-annotation-format"));
|
|
13
|
+
const ruleTester = new eslint_1.RuleTester({
|
|
14
|
+
languageOptions: { parserOptions: { ecmaVersion: 2020 } },
|
|
15
|
+
});
|
|
16
|
+
describe("Valid Annotation Format Rule (Story 005.0-DEV-ANNOTATION-VALIDATION)", () => {
|
|
17
|
+
ruleTester.run("valid-annotation-format", valid_annotation_format_1.default, {
|
|
18
|
+
valid: [
|
|
19
|
+
{
|
|
20
|
+
name: "[REQ-PATH-FORMAT] valid story annotation format",
|
|
21
|
+
code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "[REQ-REQ-FORMAT] valid req annotation format",
|
|
25
|
+
code: `// @req REQ-EXAMPLE`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "[REQ-FORMAT-SPECIFICATION] valid block annotations",
|
|
29
|
+
code: `/**
|
|
30
|
+
* @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md
|
|
31
|
+
* @req REQ-VALID-EXAMPLE
|
|
32
|
+
*/`,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
invalid: [
|
|
36
|
+
{
|
|
37
|
+
name: "[REQ-PATH-FORMAT] missing story path",
|
|
38
|
+
code: `// @story`,
|
|
39
|
+
errors: [{ messageId: "invalidStoryFormat" }],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "[REQ-PATH-FORMAT] invalid story file extension",
|
|
43
|
+
code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story`,
|
|
44
|
+
errors: [{ messageId: "invalidStoryFormat" }],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "[REQ-REQ-FORMAT] missing req id",
|
|
48
|
+
code: `// @req`,
|
|
49
|
+
errors: [{ messageId: "invalidReqFormat" }],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "[REQ-REQ-FORMAT] invalid req id format",
|
|
53
|
+
code: `// @req invalid-format`,
|
|
54
|
+
errors: [{ messageId: "invalidReqFormat" }],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
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/010.0-DEV-DEEP-VALIDATION.story.md
|
|
8
|
+
* @story docs/stories/010.0-DEV-DEEP-VALIDATION.story.md
|
|
9
|
+
* @req REQ-DEEP-PARSE - Verify valid-req-reference rule enforces existing requirement content
|
|
10
|
+
*/
|
|
11
|
+
const eslint_1 = require("eslint");
|
|
12
|
+
const valid_req_reference_1 = __importDefault(require("../../src/rules/valid-req-reference"));
|
|
13
|
+
const ruleTester = new eslint_1.RuleTester({
|
|
14
|
+
languageOptions: { parserOptions: { ecmaVersion: 2020 } },
|
|
15
|
+
});
|
|
16
|
+
describe("Valid Req Reference Rule (Story 010.0-DEV-DEEP-VALIDATION)", () => {
|
|
17
|
+
ruleTester.run("valid-req-reference", valid_req_reference_1.default, {
|
|
18
|
+
valid: [
|
|
19
|
+
{
|
|
20
|
+
name: "[REQ-DEEP-PARSE] valid requirement reference existing in story file",
|
|
21
|
+
code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
22
|
+
// @req REQ-PLUGIN-STRUCTURE`,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "[REQ-DEEP-BULLET] valid bullet list requirement existing in bullet story fixture",
|
|
26
|
+
code: `// @story tests/fixtures/story_bullet.md
|
|
27
|
+
// @req REQ-BULLET-LIST`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
invalid: [
|
|
31
|
+
{
|
|
32
|
+
name: "[REQ-DEEP-MATCH] missing requirement in story file",
|
|
33
|
+
code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
34
|
+
// @req REQ-NON-EXISTENT`,
|
|
35
|
+
errors: [
|
|
36
|
+
{
|
|
37
|
+
messageId: "reqMissing",
|
|
38
|
+
data: {
|
|
39
|
+
reqId: "REQ-NON-EXISTENT",
|
|
40
|
+
storyPath: "docs/stories/001.0-DEV-PLUGIN-SETUP.story.md",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "[REQ-DEEP-PARSE] disallow path traversal in story path",
|
|
47
|
+
code: `// @story ../docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
48
|
+
// @req REQ-PLUGIN-STRUCTURE`,
|
|
49
|
+
errors: [
|
|
50
|
+
{
|
|
51
|
+
messageId: "invalidPath",
|
|
52
|
+
data: {
|
|
53
|
+
storyPath: "../docs/stories/001.0-DEV-PLUGIN-SETUP.story.md",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "[REQ-DEEP-PARSE] disallow absolute path in story path",
|
|
60
|
+
code: `// @story /absolute/path/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
61
|
+
// @req REQ-PLUGIN-STRUCTURE`,
|
|
62
|
+
errors: [
|
|
63
|
+
{
|
|
64
|
+
messageId: "invalidPath",
|
|
65
|
+
data: {
|
|
66
|
+
storyPath: "/absolute/path/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "[REQ-DEEP-BULLET] missing bullet list requirement in bullet story fixture",
|
|
73
|
+
code: `// @story tests/fixtures/story_bullet.md
|
|
74
|
+
// @req REQ-MISSING-BULLET`,
|
|
75
|
+
errors: [
|
|
76
|
+
{
|
|
77
|
+
messageId: "reqMissing",
|
|
78
|
+
data: {
|
|
79
|
+
reqId: "REQ-MISSING-BULLET",
|
|
80
|
+
storyPath: "tests/fixtures/story_bullet.md",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
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/006.0-DEV-FILE-VALIDATION.story.md
|
|
8
|
+
* @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md
|
|
9
|
+
* @req REQ-FILE-EXISTENCE - Verify valid-story-reference rule enforces existing .story.md files
|
|
10
|
+
*/
|
|
11
|
+
const eslint_1 = require("eslint");
|
|
12
|
+
const valid_story_reference_1 = __importDefault(require("../../src/rules/valid-story-reference"));
|
|
13
|
+
const ruleTester = new eslint_1.RuleTester({
|
|
14
|
+
languageOptions: { parserOptions: { ecmaVersion: 2020 } },
|
|
15
|
+
});
|
|
16
|
+
describe("Valid Story Reference Rule (Story 006.0-DEV-FILE-VALIDATION)", () => {
|
|
17
|
+
ruleTester.run("valid-story-reference", valid_story_reference_1.default, {
|
|
18
|
+
valid: [
|
|
19
|
+
{
|
|
20
|
+
name: "[REQ-FILE-EXISTENCE] valid story file reference",
|
|
21
|
+
code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "[REQ-EXTENSION] valid .story.md extension",
|
|
25
|
+
code: `// @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "[REQ-PATH-RESOLUTION] valid relative path with ./ prefix",
|
|
29
|
+
code: `// @story ./docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md`,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
invalid: [
|
|
33
|
+
{
|
|
34
|
+
name: "[REQ-PATH-RESOLUTION] missing file",
|
|
35
|
+
code: `// @story docs/stories/missing-file.story.md`,
|
|
36
|
+
errors: [
|
|
37
|
+
{
|
|
38
|
+
messageId: "fileMissing",
|
|
39
|
+
data: { path: "docs/stories/missing-file.story.md" },
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "[REQ-EXTENSION] invalid extension",
|
|
45
|
+
code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.md`,
|
|
46
|
+
errors: [
|
|
47
|
+
{
|
|
48
|
+
messageId: "invalidExtension",
|
|
49
|
+
data: { path: "docs/stories/001.0-DEV-PLUGIN-SETUP.md" },
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "[REQ-PATH-SECURITY] path traversal",
|
|
55
|
+
code: `// @story ../outside.story.md`,
|
|
56
|
+
errors: [
|
|
57
|
+
{ messageId: "invalidPath", data: { path: "../outside.story.md" } },
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "[REQ-ABSOLUTE-PATH] absolute path not allowed",
|
|
62
|
+
code: `// @story /etc/passwd.story.md`,
|
|
63
|
+
errors: [
|
|
64
|
+
{ messageId: "invalidPath", data: { path: "/etc/passwd.story.md" } },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-traceability",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"directories": {
|
|
8
|
+
"doc": "docs"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prelint": "npm run build",
|
|
12
|
+
"build": "tsc -p tsconfig.json",
|
|
13
|
+
"type-check": "tsc --noEmit -p tsconfig.json",
|
|
14
|
+
"lint": "eslint \"src/**/*.{js,ts}\" \"tests/**/*.{js,ts}\" --max-warnings=0",
|
|
15
|
+
"test": "jest --ci --bail --coverage",
|
|
16
|
+
"format": "prettier --write .",
|
|
17
|
+
"format:check": "prettier --check .",
|
|
18
|
+
"duplication": "jscpd src tests --reporters console --threshold 3",
|
|
19
|
+
"prepare": "husky install"
|
|
20
|
+
},
|
|
21
|
+
"lint-staged": {
|
|
22
|
+
"src/**/*.{js,jsx,ts,tsx,json,md}": [
|
|
23
|
+
"prettier --write",
|
|
24
|
+
"eslint --fix"
|
|
25
|
+
],
|
|
26
|
+
"tests/**/*.{js,jsx,ts,tsx,json,md}": [
|
|
27
|
+
"prettier --write",
|
|
28
|
+
"eslint --fix"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/voder-ai/eslint-plugin-traceability.git"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [],
|
|
36
|
+
"author": "",
|
|
37
|
+
"license": "ISC",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/voder-ai/eslint-plugin-traceability/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/voder-ai/eslint-plugin-traceability#readme",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.39.1",
|
|
44
|
+
"@types/eslint": "^9.6.1",
|
|
45
|
+
"@types/jest": "^30.0.0",
|
|
46
|
+
"@types/node": "^24.10.1",
|
|
47
|
+
"@typescript-eslint/parser": "^8.46.4",
|
|
48
|
+
"@typescript-eslint/utils": "^8.46.4",
|
|
49
|
+
"eslint": "^9.39.1",
|
|
50
|
+
"husky": "^9.1.7",
|
|
51
|
+
"jest": "^30.2.0",
|
|
52
|
+
"jscpd": "^4.0.5",
|
|
53
|
+
"lint-staged": "^16.2.6",
|
|
54
|
+
"prettier": "^3.6.2",
|
|
55
|
+
"ts-jest": "^29.4.5",
|
|
56
|
+
"typescript": "^5.9.3"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"eslint": "^9.0.0"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=14"
|
|
63
|
+
},
|
|
64
|
+
"overrides": {
|
|
65
|
+
"js-yaml": ">=4.1.1"
|
|
66
|
+
}
|
|
67
|
+
}
|