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.
- package/.github/workflows/ci-cd.yml +36 -20
- package/.husky/pre-commit +1 -1
- package/.releaserc.json +15 -0
- package/CHANGELOG.md +8 -1
- package/CONTRIBUTING.md +15 -13
- package/docs/conventional-commits-guide.md +185 -0
- package/docs/decisions/004-automated-version-bumping-for-ci-cd.md +3 -1
- package/docs/decisions/006-semantic-release-for-automated-publishing.accepted.md +227 -0
- package/package.json +7 -2
- package/lib/src/index.d.ts +0 -80
- package/lib/src/index.js +0 -58
- package/lib/src/maintenance/batch.d.ts +0 -16
- package/lib/src/maintenance/batch.js +0 -28
- package/lib/src/maintenance/detect.d.ts +0 -6
- package/lib/src/maintenance/detect.js +0 -69
- package/lib/src/maintenance/index.d.ts +0 -14
- package/lib/src/maintenance/index.js +0 -22
- package/lib/src/maintenance/report.d.ts +0 -7
- package/lib/src/maintenance/report.js +0 -17
- package/lib/src/maintenance/update.d.ts +0 -6
- package/lib/src/maintenance/update.js +0 -67
- package/lib/src/maintenance/utils.d.ts +0 -6
- package/lib/src/maintenance/utils.js +0 -64
- package/lib/src/rules/require-branch-annotation.d.ts +0 -7
- package/lib/src/rules/require-branch-annotation.js +0 -111
- package/lib/src/rules/require-req-annotation.d.ts +0 -7
- package/lib/src/rules/require-req-annotation.js +0 -38
- package/lib/src/rules/require-story-annotation.d.ts +0 -7
- package/lib/src/rules/require-story-annotation.js +0 -50
- package/lib/src/rules/valid-annotation-format.d.ts +0 -10
- package/lib/src/rules/valid-annotation-format.js +0 -60
- package/lib/src/rules/valid-req-reference.d.ts +0 -3
- package/lib/src/rules/valid-req-reference.js +0 -104
- package/lib/src/rules/valid-story-reference.d.ts +0 -3
- package/lib/src/rules/valid-story-reference.js +0 -168
- package/lib/tests/fixtures/stale/example.d.ts +0 -0
- package/lib/tests/fixtures/stale/example.js +0 -3
- package/lib/tests/fixtures/update/example.d.ts +0 -0
- package/lib/tests/fixtures/update/example.js +0 -3
- package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
- package/lib/tests/fixtures/valid-annotations/example.js +0 -3
- package/lib/tests/maintenance/batch.test.d.ts +0 -1
- package/lib/tests/maintenance/batch.test.js +0 -79
- package/lib/tests/maintenance/detect-isolated.test.d.ts +0 -1
- package/lib/tests/maintenance/detect-isolated.test.js +0 -95
- package/lib/tests/maintenance/detect.test.d.ts +0 -1
- package/lib/tests/maintenance/detect.test.js +0 -23
- package/lib/tests/maintenance/report.test.d.ts +0 -1
- package/lib/tests/maintenance/report.test.js +0 -67
- package/lib/tests/maintenance/update-isolated.test.d.ts +0 -1
- package/lib/tests/maintenance/update-isolated.test.js +0 -66
- package/lib/tests/maintenance/update.test.d.ts +0 -1
- package/lib/tests/maintenance/update.test.js +0 -26
- package/lib/tests/plugin-default-export-and-configs.test.d.ts +0 -1
- package/lib/tests/plugin-default-export-and-configs.test.js +0 -72
- package/lib/tests/plugin-setup.test.d.ts +0 -1
- package/lib/tests/plugin-setup.test.js +0 -51
- package/lib/tests/rules/require-branch-annotation.test.d.ts +0 -1
- package/lib/tests/rules/require-branch-annotation.test.js +0 -253
- package/lib/tests/rules/require-req-annotation.test.d.ts +0 -1
- package/lib/tests/rules/require-req-annotation.test.js +0 -41
- package/lib/tests/rules/require-story-annotation.test.d.ts +0 -1
- package/lib/tests/rules/require-story-annotation.test.js +0 -36
- package/lib/tests/rules/valid-annotation-format.test.d.ts +0 -1
- package/lib/tests/rules/valid-annotation-format.test.js +0 -58
- package/lib/tests/rules/valid-req-reference.test.d.ts +0 -1
- package/lib/tests/rules/valid-req-reference.test.js +0 -87
- package/lib/tests/rules/valid-story-reference.test.d.ts +0 -1
- package/lib/tests/rules/valid-story-reference.test.js +0 -69
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Rule to enforce @story annotation on functions
|
|
5
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
|
-
* @req REQ-ANNOTATION-REQUIRED - Require @story annotation on functions
|
|
7
|
-
*/
|
|
8
|
-
exports.default = {
|
|
9
|
-
meta: {
|
|
10
|
-
type: "problem",
|
|
11
|
-
docs: {
|
|
12
|
-
description: "Require @story annotations on functions",
|
|
13
|
-
recommended: "error",
|
|
14
|
-
},
|
|
15
|
-
fixable: "code",
|
|
16
|
-
messages: {
|
|
17
|
-
missingStory: "Missing @story annotation",
|
|
18
|
-
},
|
|
19
|
-
schema: [],
|
|
20
|
-
},
|
|
21
|
-
create(context) {
|
|
22
|
-
const sourceCode = context.getSourceCode();
|
|
23
|
-
return {
|
|
24
|
-
FunctionDeclaration(node) {
|
|
25
|
-
const jsdoc = sourceCode.getJSDocComment(node);
|
|
26
|
-
let hasStory = false;
|
|
27
|
-
// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
28
|
-
// @req REQ-JSDOC-PARSING - Detect JSDoc @story annotation presence
|
|
29
|
-
if (jsdoc && jsdoc.value.includes("@story")) {
|
|
30
|
-
hasStory = true;
|
|
31
|
-
// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
32
|
-
// @req REQ-JSDOC-PARSING - Fallback to loading comments before node for @story annotation detection
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const commentsBefore = sourceCode.getCommentsBefore(node) || [];
|
|
36
|
-
hasStory = commentsBefore.some((comment) => comment.value.includes("@story"));
|
|
37
|
-
}
|
|
38
|
-
if (!hasStory) {
|
|
39
|
-
context.report({
|
|
40
|
-
node,
|
|
41
|
-
messageId: "missingStory",
|
|
42
|
-
fix(fixer) {
|
|
43
|
-
return fixer.insertTextBefore(node, "/** @story <story-file>.story.md */\n");
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rule to validate @story and @req annotation format and syntax
|
|
3
|
-
* @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md
|
|
4
|
-
* @req REQ-FORMAT-SPECIFICATION - Define clear format rules for @story and @req annotations
|
|
5
|
-
* @req REQ-SYNTAX-VALIDATION - Validate annotation syntax matches specification
|
|
6
|
-
* @req REQ-PATH-FORMAT - Validate @story paths follow expected patterns
|
|
7
|
-
* @req REQ-REQ-FORMAT - Validate @req identifiers follow expected patterns
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: any;
|
|
10
|
-
export default _default;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Rule to validate @story and @req annotation format and syntax
|
|
5
|
-
* @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md
|
|
6
|
-
* @req REQ-FORMAT-SPECIFICATION - Define clear format rules for @story and @req annotations
|
|
7
|
-
* @req REQ-SYNTAX-VALIDATION - Validate annotation syntax matches specification
|
|
8
|
-
* @req REQ-PATH-FORMAT - Validate @story paths follow expected patterns
|
|
9
|
-
* @req REQ-REQ-FORMAT - Validate @req identifiers follow expected patterns
|
|
10
|
-
*/
|
|
11
|
-
exports.default = {
|
|
12
|
-
meta: {
|
|
13
|
-
type: "problem",
|
|
14
|
-
docs: {
|
|
15
|
-
description: "Validate format and syntax of @story and @req annotations",
|
|
16
|
-
recommended: "error",
|
|
17
|
-
},
|
|
18
|
-
messages: {
|
|
19
|
-
invalidStoryFormat: "Invalid @story annotation format",
|
|
20
|
-
invalidReqFormat: "Invalid @req annotation format",
|
|
21
|
-
},
|
|
22
|
-
schema: [],
|
|
23
|
-
},
|
|
24
|
-
create(context) {
|
|
25
|
-
const sourceCode = context.getSourceCode();
|
|
26
|
-
return {
|
|
27
|
-
Program() {
|
|
28
|
-
const comments = sourceCode.getAllComments() || [];
|
|
29
|
-
comments.forEach((comment) => {
|
|
30
|
-
const lines = comment.value
|
|
31
|
-
.split(/\r?\n/)
|
|
32
|
-
.map((l) => l.replace(/^[^@]*/, "").trim());
|
|
33
|
-
lines.forEach((line) => {
|
|
34
|
-
if (line.startsWith("@story")) {
|
|
35
|
-
const parts = line.split(/\s+/);
|
|
36
|
-
const storyPath = parts[1];
|
|
37
|
-
if (!storyPath ||
|
|
38
|
-
!/^docs\/stories\/[0-9]+\.[0-9]+-DEV-[\w-]+\.story\.md$/.test(storyPath)) {
|
|
39
|
-
context.report({
|
|
40
|
-
node: comment,
|
|
41
|
-
messageId: "invalidStoryFormat",
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (line.startsWith("@req")) {
|
|
46
|
-
const parts = line.split(/\s+/);
|
|
47
|
-
const reqId = parts[1];
|
|
48
|
-
if (!reqId || !/^REQ-[A-Z0-9-]+$/.test(reqId)) {
|
|
49
|
-
context.report({
|
|
50
|
-
node: comment,
|
|
51
|
-
messageId: "invalidReqFormat",
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
};
|
|
@@ -1,104 +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-env node */
|
|
7
|
-
/**
|
|
8
|
-
* Rule to validate @req annotation references refer to existing requirements in story files
|
|
9
|
-
* @story docs/stories/010.0-DEV-DEEP-VALIDATION.story.md
|
|
10
|
-
* @req REQ-DEEP-PARSE - Parse story files to extract requirement identifiers
|
|
11
|
-
* @req REQ-DEEP-MATCH - Validate @req references against story file content
|
|
12
|
-
* @req REQ-DEEP-CACHE - Cache parsed story content for performance
|
|
13
|
-
* @req REQ-DEEP-PATH - Protect against path traversal in story paths
|
|
14
|
-
*/
|
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
exports.default = {
|
|
18
|
-
meta: {
|
|
19
|
-
type: "problem",
|
|
20
|
-
docs: {
|
|
21
|
-
description: "Validate that @req annotations reference existing requirements in referenced story files",
|
|
22
|
-
recommended: "error",
|
|
23
|
-
},
|
|
24
|
-
messages: {
|
|
25
|
-
reqMissing: "Requirement '{{reqId}}' not found in '{{storyPath}}'",
|
|
26
|
-
invalidPath: "Invalid story path '{{storyPath}}'",
|
|
27
|
-
},
|
|
28
|
-
schema: [],
|
|
29
|
-
},
|
|
30
|
-
create(context) {
|
|
31
|
-
const sourceCode = context.getSourceCode();
|
|
32
|
-
const cwd = process.cwd();
|
|
33
|
-
// Cache for resolved story file paths to parsed set of requirement IDs
|
|
34
|
-
const reqCache = new Map();
|
|
35
|
-
let rawStoryPath = null;
|
|
36
|
-
return {
|
|
37
|
-
Program() {
|
|
38
|
-
const comments = sourceCode.getAllComments() || [];
|
|
39
|
-
comments.forEach((comment) => {
|
|
40
|
-
const rawLines = comment.value.split(/\r?\n/);
|
|
41
|
-
const lines = rawLines.map((rawLine) => rawLine.trim().replace(/^\*+\s*/, ""));
|
|
42
|
-
lines.forEach((line) => {
|
|
43
|
-
if (line.startsWith("@story")) {
|
|
44
|
-
const parts = line.split(/\s+/);
|
|
45
|
-
rawStoryPath = parts[1] || null;
|
|
46
|
-
}
|
|
47
|
-
if (line.startsWith("@req")) {
|
|
48
|
-
const parts = line.split(/\s+/);
|
|
49
|
-
const reqId = parts[1];
|
|
50
|
-
if (!reqId || !rawStoryPath) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// Protect against path traversal and absolute paths
|
|
54
|
-
if (rawStoryPath.includes("..") ||
|
|
55
|
-
path_1.default.isAbsolute(rawStoryPath)) {
|
|
56
|
-
context.report({
|
|
57
|
-
node: comment,
|
|
58
|
-
messageId: "invalidPath",
|
|
59
|
-
data: { storyPath: rawStoryPath },
|
|
60
|
-
});
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const resolvedStoryPath = path_1.default.resolve(cwd, rawStoryPath);
|
|
64
|
-
if (!resolvedStoryPath.startsWith(cwd + path_1.default.sep) &&
|
|
65
|
-
resolvedStoryPath !== cwd) {
|
|
66
|
-
context.report({
|
|
67
|
-
node: comment,
|
|
68
|
-
messageId: "invalidPath",
|
|
69
|
-
data: { storyPath: rawStoryPath },
|
|
70
|
-
});
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// Load and parse story file if not cached
|
|
74
|
-
if (!reqCache.has(resolvedStoryPath)) {
|
|
75
|
-
try {
|
|
76
|
-
const content = fs_1.default.readFileSync(resolvedStoryPath, "utf8");
|
|
77
|
-
const found = new Set();
|
|
78
|
-
const regex = /REQ-[A-Z0-9-]+/g;
|
|
79
|
-
let match;
|
|
80
|
-
while ((match = regex.exec(content)) !== null) {
|
|
81
|
-
found.add(match[0]);
|
|
82
|
-
}
|
|
83
|
-
reqCache.set(resolvedStoryPath, found);
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
// Unable to read file, treat as no requirements
|
|
87
|
-
reqCache.set(resolvedStoryPath, new Set());
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const reqSet = reqCache.get(resolvedStoryPath);
|
|
91
|
-
if (!reqSet.has(reqId)) {
|
|
92
|
-
context.report({
|
|
93
|
-
node: comment,
|
|
94
|
-
messageId: "reqMissing",
|
|
95
|
-
data: { reqId, storyPath: rawStoryPath },
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
},
|
|
104
|
-
};
|
|
@@ -1,168 +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-env node */
|
|
7
|
-
/**
|
|
8
|
-
* Rule to validate @story annotation references refer to existing story files
|
|
9
|
-
* @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md
|
|
10
|
-
* @req REQ-FILE-EXISTENCE - Validate that story file paths reference existing files
|
|
11
|
-
* @req REQ-PATH-RESOLUTION - Resolve relative paths correctly and enforce configuration
|
|
12
|
-
* @req REQ-SECURITY-VALIDATION - Prevent path traversal and absolute path usage
|
|
13
|
-
*/
|
|
14
|
-
const fs_1 = __importDefault(require("fs"));
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const defaultStoryDirs = ["docs/stories", "stories"];
|
|
17
|
-
const fileExistCache = new Map();
|
|
18
|
-
/**
|
|
19
|
-
* Build possible file paths for a given storyPath.
|
|
20
|
-
* @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md
|
|
21
|
-
* @req REQ-PATH-RESOLUTION - Resolve relative paths correctly and enforce configuration
|
|
22
|
-
*/
|
|
23
|
-
function buildCandidates(storyPath, cwd, storyDirs) {
|
|
24
|
-
const candidates = [];
|
|
25
|
-
if (storyPath.startsWith("./") || storyPath.startsWith("../")) {
|
|
26
|
-
candidates.push(path_1.default.resolve(cwd, storyPath));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
candidates.push(path_1.default.resolve(cwd, storyPath));
|
|
30
|
-
for (const dir of storyDirs) {
|
|
31
|
-
candidates.push(path_1.default.resolve(cwd, dir, path_1.default.basename(storyPath)));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return candidates;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Check if any of the candidate files exist.
|
|
38
|
-
* @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md
|
|
39
|
-
* @req REQ-FILE-EXISTENCE - Validate that story file paths reference existing files
|
|
40
|
-
*/
|
|
41
|
-
function existsAny(paths) {
|
|
42
|
-
for (const candidate of paths) {
|
|
43
|
-
let ok = fileExistCache.get(candidate);
|
|
44
|
-
if (ok === undefined) {
|
|
45
|
-
ok = fs_1.default.existsSync(candidate) && fs_1.default.statSync(candidate).isFile();
|
|
46
|
-
fileExistCache.set(candidate, ok);
|
|
47
|
-
}
|
|
48
|
-
if (ok) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Validate a single @story annotation line.
|
|
56
|
-
* @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md
|
|
57
|
-
* @req REQ-FILE-EXISTENCE - Validate that story file paths reference existing files
|
|
58
|
-
* @req REQ-PATH-RESOLUTION - Resolve relative paths correctly and enforce configuration
|
|
59
|
-
* @req REQ-SECURITY-VALIDATION - Prevent path traversal and absolute path usage
|
|
60
|
-
*/
|
|
61
|
-
function validateStoryPath(line, commentNode, context, cwd, storyDirs, allowAbsolute, requireExt) {
|
|
62
|
-
const parts = line.split(/\s+/);
|
|
63
|
-
const storyPath = parts[1];
|
|
64
|
-
if (!storyPath) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
// Absolute path check
|
|
68
|
-
if (path_1.default.isAbsolute(storyPath)) {
|
|
69
|
-
if (!allowAbsolute) {
|
|
70
|
-
context.report({
|
|
71
|
-
node: commentNode,
|
|
72
|
-
messageId: "invalidPath",
|
|
73
|
-
data: { path: storyPath },
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
// Path traversal prevention
|
|
79
|
-
if (storyPath.includes("..")) {
|
|
80
|
-
const normalized = path_1.default.normalize(storyPath);
|
|
81
|
-
const full = path_1.default.resolve(cwd, normalized);
|
|
82
|
-
if (!full.startsWith(cwd + path_1.default.sep)) {
|
|
83
|
-
context.report({
|
|
84
|
-
node: commentNode,
|
|
85
|
-
messageId: "invalidPath",
|
|
86
|
-
data: { path: storyPath },
|
|
87
|
-
});
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// Extension check
|
|
92
|
-
if (requireExt && !storyPath.endsWith(".story.md")) {
|
|
93
|
-
context.report({
|
|
94
|
-
node: commentNode,
|
|
95
|
-
messageId: "invalidExtension",
|
|
96
|
-
data: { path: storyPath },
|
|
97
|
-
});
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// Build candidate paths and check existence
|
|
101
|
-
const candidates = buildCandidates(storyPath, cwd, storyDirs);
|
|
102
|
-
if (!existsAny(candidates)) {
|
|
103
|
-
context.report({
|
|
104
|
-
node: commentNode,
|
|
105
|
-
messageId: "fileMissing",
|
|
106
|
-
data: { path: storyPath },
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Handle a single comment node by processing its lines.
|
|
112
|
-
* @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md
|
|
113
|
-
* @req REQ-ANNOTATION-VALIDATION - Ensure each annotation line is parsed
|
|
114
|
-
*/
|
|
115
|
-
function handleComment(commentNode, context, sourceCode, cwd, storyDirs, allowAbsolute, requireExt) {
|
|
116
|
-
const lines = commentNode.value
|
|
117
|
-
.split(/\r?\n/)
|
|
118
|
-
.map((l) => l.replace(/^[^@]*/, "").trim());
|
|
119
|
-
for (const line of lines) {
|
|
120
|
-
if (line.startsWith("@story")) {
|
|
121
|
-
validateStoryPath(line, commentNode, context, cwd, storyDirs, allowAbsolute, requireExt);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.default = {
|
|
126
|
-
meta: {
|
|
127
|
-
type: "problem",
|
|
128
|
-
docs: {
|
|
129
|
-
description: "Validate that @story annotations reference existing .story.md files",
|
|
130
|
-
recommended: "error",
|
|
131
|
-
},
|
|
132
|
-
messages: {
|
|
133
|
-
fileMissing: "Story file '{{path}}' not found",
|
|
134
|
-
invalidExtension: "Invalid story file extension for '{{path}}', expected '.story.md'",
|
|
135
|
-
invalidPath: "Invalid story path '{{path}}'",
|
|
136
|
-
},
|
|
137
|
-
schema: [
|
|
138
|
-
{
|
|
139
|
-
type: "object",
|
|
140
|
-
properties: {
|
|
141
|
-
storyDirectories: {
|
|
142
|
-
type: "array",
|
|
143
|
-
items: { type: "string" },
|
|
144
|
-
},
|
|
145
|
-
allowAbsolutePaths: { type: "boolean" },
|
|
146
|
-
requireStoryExtension: { type: "boolean" },
|
|
147
|
-
},
|
|
148
|
-
additionalProperties: false,
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
},
|
|
152
|
-
create(context) {
|
|
153
|
-
const sourceCode = context.getSourceCode();
|
|
154
|
-
const cwd = process.cwd();
|
|
155
|
-
const opts = context.options[0];
|
|
156
|
-
const storyDirs = opts?.storyDirectories || defaultStoryDirs;
|
|
157
|
-
const allowAbsolute = opts?.allowAbsolutePaths || false;
|
|
158
|
-
const requireExt = opts?.requireStoryExtension !== false;
|
|
159
|
-
return {
|
|
160
|
-
Program() {
|
|
161
|
-
const comments = sourceCode.getAllComments() || [];
|
|
162
|
-
for (const comment of comments) {
|
|
163
|
-
handleComment(comment, context, sourceCode, cwd, storyDirs, allowAbsolute, requireExt);
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
},
|
|
168
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +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-BATCH - Perform batch updates
|
|
40
|
-
* @req REQ-MAINT-VERIFY - Verify annotation references
|
|
41
|
-
*/
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
const os = __importStar(require("os"));
|
|
45
|
-
const batch_1 = require("../../src/maintenance/batch");
|
|
46
|
-
describe("batchUpdateAnnotations (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
|
|
47
|
-
let tmpDir;
|
|
48
|
-
beforeAll(() => {
|
|
49
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "batch-test-"));
|
|
50
|
-
});
|
|
51
|
-
afterAll(() => {
|
|
52
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
53
|
-
});
|
|
54
|
-
it("[REQ-MAINT-BATCH] should return 0 when no mappings applied", () => {
|
|
55
|
-
const count = (0, batch_1.batchUpdateAnnotations)(tmpDir, []);
|
|
56
|
-
expect(count).toBe(0);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe("verifyAnnotations (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
|
|
60
|
-
let tmpDir;
|
|
61
|
-
beforeAll(() => {
|
|
62
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "verify-test-"));
|
|
63
|
-
const tsContent = `
|
|
64
|
-
/**
|
|
65
|
-
* Tests for: my-story.story.md
|
|
66
|
-
* @story my-story.story.md
|
|
67
|
-
*/
|
|
68
|
-
`;
|
|
69
|
-
fs.writeFileSync(path.join(tmpDir, "test.ts"), tsContent);
|
|
70
|
-
fs.writeFileSync(path.join(tmpDir, "my-story.story.md"), "# Dummy Story");
|
|
71
|
-
});
|
|
72
|
-
afterAll(() => {
|
|
73
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
74
|
-
});
|
|
75
|
-
it("[REQ-MAINT-VERIFY] should return true when annotations are valid", () => {
|
|
76
|
-
const valid = (0, batch_1.verifyAnnotations)(tmpDir);
|
|
77
|
-
expect(valid).toBe(true);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,95 +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-DETECT - Detect stale annotation references
|
|
40
|
-
*/
|
|
41
|
-
const fs = __importStar(require("fs"));
|
|
42
|
-
const path = __importStar(require("path"));
|
|
43
|
-
const os = __importStar(require("os"));
|
|
44
|
-
const detect_1 = require("../../src/maintenance/detect");
|
|
45
|
-
describe("detectStaleAnnotations isolated (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
|
|
46
|
-
it("[REQ-MAINT-DETECT] returns empty array when directory does not exist", () => {
|
|
47
|
-
const result = (0, detect_1.detectStaleAnnotations)("non-existent-dir");
|
|
48
|
-
expect(result).toEqual([]);
|
|
49
|
-
});
|
|
50
|
-
it("[REQ-MAINT-DETECT] detects stale annotations in nested directories", () => {
|
|
51
|
-
// Arrange
|
|
52
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "tmp-nested-"));
|
|
53
|
-
const nestedDir = path.join(tmpDir, "nested");
|
|
54
|
-
fs.mkdirSync(nestedDir);
|
|
55
|
-
const filePath1 = path.join(tmpDir, "file1.ts");
|
|
56
|
-
const filePath2 = path.join(nestedDir, "file2.ts");
|
|
57
|
-
const content1 = `
|
|
58
|
-
/**
|
|
59
|
-
* @story stale1.story.md
|
|
60
|
-
*/
|
|
61
|
-
`;
|
|
62
|
-
fs.writeFileSync(filePath1, content1, "utf8");
|
|
63
|
-
const content2 = `
|
|
64
|
-
/**
|
|
65
|
-
* @story stale2.story.md
|
|
66
|
-
*/
|
|
67
|
-
`;
|
|
68
|
-
fs.writeFileSync(filePath2, content2, "utf8");
|
|
69
|
-
// Act
|
|
70
|
-
const result = (0, detect_1.detectStaleAnnotations)(tmpDir);
|
|
71
|
-
// Assert
|
|
72
|
-
expect(result).toHaveLength(2);
|
|
73
|
-
expect(result).toContain("stale1.story.md");
|
|
74
|
-
expect(result).toContain("stale2.story.md");
|
|
75
|
-
});
|
|
76
|
-
it("[REQ-MAINT-DETECT] throws error on permission denied", () => {
|
|
77
|
-
const tmpDir2 = fs.mkdtempSync(path.join(os.tmpdir(), "tmp-perm-"));
|
|
78
|
-
const dir = path.join(tmpDir2, "subdir");
|
|
79
|
-
fs.mkdirSync(dir);
|
|
80
|
-
const filePath = path.join(dir, "file.ts");
|
|
81
|
-
const content = `
|
|
82
|
-
/**
|
|
83
|
-
* @story none.story.md
|
|
84
|
-
*/
|
|
85
|
-
`;
|
|
86
|
-
fs.writeFileSync(filePath, content, "utf8");
|
|
87
|
-
// Remove read permission
|
|
88
|
-
fs.chmodSync(dir, 0o000);
|
|
89
|
-
expect(() => (0, detect_1.detectStaleAnnotations)(tmpDir2)).toThrow();
|
|
90
|
-
// Restore permissions
|
|
91
|
-
fs.chmodSync(dir, 0o700);
|
|
92
|
-
// Cleanup temporary directory
|
|
93
|
-
fs.rmSync(tmpDir2, { recursive: true, force: true });
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +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-DETECT - Detect stale annotation references
|
|
10
|
-
*/
|
|
11
|
-
const fs_1 = __importDefault(require("fs"));
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const os_1 = __importDefault(require("os"));
|
|
14
|
-
const detect_1 = require("../../src/maintenance/detect");
|
|
15
|
-
describe("detectStaleAnnotations (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
|
|
16
|
-
it("[REQ-MAINT-DETECT] should return empty array when no stale annotations", () => {
|
|
17
|
-
const tmpDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "detect-test-"));
|
|
18
|
-
// No annotation files are created in tmpDir to simulate no stale annotations
|
|
19
|
-
const result = (0, detect_1.detectStaleAnnotations)(tmpDir);
|
|
20
|
-
expect(result).toEqual([]);
|
|
21
|
-
fs_1.default.rmSync(tmpDir, { recursive: true, force: true });
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|