eslint-plugin-traceability 1.0.3 → 1.0.5
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 +41 -35
- package/.husky/pre-commit +1 -1
- package/.husky/pre-push +1 -1
- package/.prettierignore +5 -1
- package/.releaserc.json +15 -0
- package/.voder/history.md +138 -264
- package/.voder/implementation-progress.md +110 -112
- package/.voder/last-action.md +62 -204
- package/.voder/plan.md +10 -10
- package/.voder/progress-chart.png +0 -0
- package/.voder/progress-log-areas.csv +4 -0
- package/.voder/progress-log.csv +4 -0
- package/CHANGELOG.md +20 -1
- package/CONTRIBUTING.md +15 -13
- package/README.md +2 -2
- package/cli-integration.js +61 -115
- package/docs/cli-integration.md +3 -1
- package/docs/conventional-commits-guide.md +185 -0
- package/docs/decisions/004-automated-version-bumping-for-ci-cd.md +3 -1
- package/docs/decisions/005-github-actions-validation-tooling.accepted.md +144 -0
- package/docs/decisions/006-semantic-release-for-automated-publishing.accepted.md +227 -0
- package/eslint.config.js +4 -4
- package/package.json +7 -2
- package/tests/{basic.test.ts → plugin-setup.test.ts} +1 -1
- package/user-docs/migration-guide.md +71 -0
- package/lib/index.d.ts +0 -26
- package/lib/index.js +0 -11
- 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/basic.test.d.ts +0 -1
- package/lib/tests/basic.test.js +0 -51
- 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/index.test.d.ts +0 -1
- package/lib/tests/index.test.js +0 -72
- package/lib/tests/integration/file-validation.test.d.ts +0 -1
- package/lib/tests/integration/file-validation.test.js +0 -71
- package/lib/tests/integration/plugin-validation.test.d.ts +0 -1
- package/lib/tests/integration/plugin-validation.test.js +0 -83
- 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/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
- package/tests/integration/file-validation.test.ts +0 -78
- package/tests/integration/plugin-validation.test.ts +0 -84
- /package/tests/{index.test.ts → plugin-default-export-and-configs.test.ts} +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Maintenance Tools Module
|
|
3
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
4
|
-
* @req REQ-MAINT-DETECT
|
|
5
|
-
* @req REQ-MAINT-UPDATE
|
|
6
|
-
* @req REQ-MAINT-BATCH
|
|
7
|
-
* @req REQ-MAINT-VERIFY
|
|
8
|
-
* @req REQ-MAINT-REPORT
|
|
9
|
-
* @req REQ-MAINT-SAFE
|
|
10
|
-
*/
|
|
11
|
-
export { detectStaleAnnotations } from "./detect";
|
|
12
|
-
export { updateAnnotationReferences } from "./update";
|
|
13
|
-
export { batchUpdateAnnotations, verifyAnnotations } from "./batch";
|
|
14
|
-
export { generateMaintenanceReport } from "./report";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateMaintenanceReport = exports.verifyAnnotations = exports.batchUpdateAnnotations = exports.updateAnnotationReferences = exports.detectStaleAnnotations = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Maintenance Tools Module
|
|
6
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
7
|
-
* @req REQ-MAINT-DETECT
|
|
8
|
-
* @req REQ-MAINT-UPDATE
|
|
9
|
-
* @req REQ-MAINT-BATCH
|
|
10
|
-
* @req REQ-MAINT-VERIFY
|
|
11
|
-
* @req REQ-MAINT-REPORT
|
|
12
|
-
* @req REQ-MAINT-SAFE
|
|
13
|
-
*/
|
|
14
|
-
var detect_1 = require("./detect");
|
|
15
|
-
Object.defineProperty(exports, "detectStaleAnnotations", { enumerable: true, get: function () { return detect_1.detectStaleAnnotations; } });
|
|
16
|
-
var update_1 = require("./update");
|
|
17
|
-
Object.defineProperty(exports, "updateAnnotationReferences", { enumerable: true, get: function () { return update_1.updateAnnotationReferences; } });
|
|
18
|
-
var batch_1 = require("./batch");
|
|
19
|
-
Object.defineProperty(exports, "batchUpdateAnnotations", { enumerable: true, get: function () { return batch_1.batchUpdateAnnotations; } });
|
|
20
|
-
Object.defineProperty(exports, "verifyAnnotations", { enumerable: true, get: function () { return batch_1.verifyAnnotations; } });
|
|
21
|
-
var report_1 = require("./report");
|
|
22
|
-
Object.defineProperty(exports, "generateMaintenanceReport", { enumerable: true, get: function () { return report_1.generateMaintenanceReport; } });
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a report of maintenance operations performed
|
|
3
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
4
|
-
* @req REQ-MAINT-REPORT - Generate maintenance report
|
|
5
|
-
* @req REQ-MAINT-SAFE - Ensure operations are safe and reversible
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateMaintenanceReport(codebasePath: string): string;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateMaintenanceReport = generateMaintenanceReport;
|
|
4
|
-
const detect_1 = require("./detect");
|
|
5
|
-
/**
|
|
6
|
-
* Generate a report of maintenance operations performed
|
|
7
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
8
|
-
* @req REQ-MAINT-REPORT - Generate maintenance report
|
|
9
|
-
* @req REQ-MAINT-SAFE - Ensure operations are safe and reversible
|
|
10
|
-
*/
|
|
11
|
-
function generateMaintenanceReport(codebasePath) {
|
|
12
|
-
const staleAnnotations = (0, detect_1.detectStaleAnnotations)(codebasePath);
|
|
13
|
-
if (staleAnnotations.length === 0) {
|
|
14
|
-
return "";
|
|
15
|
-
}
|
|
16
|
-
return staleAnnotations.join("\n");
|
|
17
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Update annotation references when story files are moved or renamed
|
|
3
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
4
|
-
* @req REQ-MAINT-UPDATE - Update annotation references
|
|
5
|
-
*/
|
|
6
|
-
export declare function updateAnnotationReferences(codebasePath: string, oldPath: string, newPath: string): number;
|
|
@@ -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
|
-
exports.updateAnnotationReferences = updateAnnotationReferences;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const utils_1 = require("./utils");
|
|
39
|
-
/**
|
|
40
|
-
* Update annotation references when story files are moved or renamed
|
|
41
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
42
|
-
* @req REQ-MAINT-UPDATE - Update annotation references
|
|
43
|
-
*/
|
|
44
|
-
function updateAnnotationReferences(codebasePath, oldPath, newPath) {
|
|
45
|
-
if (!fs.existsSync(codebasePath) ||
|
|
46
|
-
!fs.statSync(codebasePath).isDirectory()) {
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
let replacementCount = 0;
|
|
50
|
-
const escapedOldPath = oldPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
51
|
-
const regex = new RegExp(`(@story\\s*)${escapedOldPath}`, "g");
|
|
52
|
-
const files = (0, utils_1.getAllFiles)(codebasePath);
|
|
53
|
-
for (const fullPath of files) {
|
|
54
|
-
const stat = fs.statSync(fullPath);
|
|
55
|
-
if (!stat.isFile())
|
|
56
|
-
continue;
|
|
57
|
-
const content = fs.readFileSync(fullPath, "utf8");
|
|
58
|
-
const newContent = content.replace(regex, (match, p1) => {
|
|
59
|
-
replacementCount++;
|
|
60
|
-
return `${p1}${newPath}`;
|
|
61
|
-
});
|
|
62
|
-
if (newContent !== content) {
|
|
63
|
-
fs.writeFileSync(fullPath, newContent, "utf8");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return replacementCount;
|
|
67
|
-
}
|
|
@@ -1,64 +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
|
-
exports.getAllFiles = getAllFiles;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
/**
|
|
40
|
-
* Recursively retrieve all files in a directory.
|
|
41
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
42
|
-
* @req REQ-MAINT-UTILS - Extract common file traversal logic for maintenance tools
|
|
43
|
-
*/
|
|
44
|
-
function getAllFiles(dir) {
|
|
45
|
-
const fileList = [];
|
|
46
|
-
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {
|
|
47
|
-
return fileList;
|
|
48
|
-
}
|
|
49
|
-
function traverse(currentDir) {
|
|
50
|
-
const entries = fs.readdirSync(currentDir);
|
|
51
|
-
for (const entry of entries) {
|
|
52
|
-
const fullPath = path.join(currentDir, entry);
|
|
53
|
-
const stat = fs.statSync(fullPath);
|
|
54
|
-
if (stat.isDirectory()) {
|
|
55
|
-
traverse(fullPath);
|
|
56
|
-
}
|
|
57
|
-
else if (stat.isFile()) {
|
|
58
|
-
fileList.push(fullPath);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
traverse(dir);
|
|
63
|
-
return fileList;
|
|
64
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rule to enforce @story and @req annotations on significant code branches
|
|
3
|
-
* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
4
|
-
* @req REQ-BRANCH-DETECTION - Detect significant code branches for traceability annotations
|
|
5
|
-
*/
|
|
6
|
-
declare const _default: any;
|
|
7
|
-
export default _default;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Rule to enforce @story and @req annotations on significant code branches
|
|
5
|
-
* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
6
|
-
* @req REQ-BRANCH-DETECTION - Detect significant code branches for traceability annotations
|
|
7
|
-
*/
|
|
8
|
-
exports.default = {
|
|
9
|
-
meta: {
|
|
10
|
-
type: "problem",
|
|
11
|
-
docs: {
|
|
12
|
-
description: "Require @story and @req annotations on code branches",
|
|
13
|
-
recommended: "error",
|
|
14
|
-
},
|
|
15
|
-
fixable: "code",
|
|
16
|
-
messages: {
|
|
17
|
-
missingAnnotation: "Missing {{missing}} annotation on code branch",
|
|
18
|
-
},
|
|
19
|
-
schema: [],
|
|
20
|
-
},
|
|
21
|
-
create(context) {
|
|
22
|
-
const sourceCode = context.getSourceCode();
|
|
23
|
-
/**
|
|
24
|
-
* Helper to check a branch AST node for traceability annotations.
|
|
25
|
-
* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
26
|
-
* @req REQ-BRANCH-DETECTION - Detect significant code branches for traceability annotations
|
|
27
|
-
*/
|
|
28
|
-
function checkBranch(node) {
|
|
29
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
30
|
-
// @req REQ-BRANCH-DETECTION - Skip default switch cases during annotation checks
|
|
31
|
-
// skip default cases in switch
|
|
32
|
-
if (node.type === "SwitchCase" && node.test == null) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// collect comments before node
|
|
36
|
-
let comments = sourceCode.getCommentsBefore(node) || [];
|
|
37
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
38
|
-
// @req REQ-BRANCH-DETECTION - Fallback scanning for SwitchCase when leading comments are absent
|
|
39
|
-
// fallback scanning for SwitchCase if no leading comment nodes
|
|
40
|
-
/* istanbul ignore if */
|
|
41
|
-
if (node.type === "SwitchCase" && comments.length === 0) {
|
|
42
|
-
const lines = sourceCode.lines;
|
|
43
|
-
const startLine = node.loc.start.line;
|
|
44
|
-
let i = startLine - 1;
|
|
45
|
-
const fallbackComments = [];
|
|
46
|
-
while (i > 0) {
|
|
47
|
-
const lineText = lines[i - 1];
|
|
48
|
-
if (/^\s*(\/\/|\/\*)/.test(lineText)) {
|
|
49
|
-
fallbackComments.unshift(lineText.trim());
|
|
50
|
-
i--;
|
|
51
|
-
}
|
|
52
|
-
else if (/^\s*$/.test(lineText)) {
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
comments = fallbackComments.map((text) => ({ value: text }));
|
|
60
|
-
}
|
|
61
|
-
const text = comments.map((c) => c.value).join(" ");
|
|
62
|
-
const missingStory = !/@story\b/.test(text);
|
|
63
|
-
const missingReq = !/@req\b/.test(text);
|
|
64
|
-
if (missingStory) {
|
|
65
|
-
const reportObj = {
|
|
66
|
-
node,
|
|
67
|
-
messageId: "missingAnnotation",
|
|
68
|
-
data: { missing: "@story" },
|
|
69
|
-
};
|
|
70
|
-
if (node.type !== "CatchClause") {
|
|
71
|
-
if (node.type === "SwitchCase") {
|
|
72
|
-
const indent = " ".repeat(node.loc.start.column);
|
|
73
|
-
reportObj.fix = (fixer) => fixer.insertTextBefore(node, `// @story <story-file>.story.md\n${indent}`);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
reportObj.fix = (fixer) => fixer.insertTextBefore(node, `// @story <story-file>.story.md\n`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
context.report(reportObj);
|
|
80
|
-
}
|
|
81
|
-
if (missingReq) {
|
|
82
|
-
const reportObj = {
|
|
83
|
-
node,
|
|
84
|
-
messageId: "missingAnnotation",
|
|
85
|
-
data: { missing: "@req" },
|
|
86
|
-
};
|
|
87
|
-
if (!missingStory && node.type !== "CatchClause") {
|
|
88
|
-
if (node.type === "SwitchCase") {
|
|
89
|
-
const indent = " ".repeat(node.loc.start.column);
|
|
90
|
-
reportObj.fix = (fixer) => fixer.insertTextBefore(node, `// @req <REQ-ID>\n${indent}`);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
reportObj.fix = (fixer) => fixer.insertTextBefore(node, `// @req <REQ-ID>\n`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
context.report(reportObj);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
IfStatement: checkBranch,
|
|
101
|
-
SwitchCase: checkBranch,
|
|
102
|
-
TryStatement: checkBranch,
|
|
103
|
-
CatchClause: checkBranch,
|
|
104
|
-
ForStatement: checkBranch,
|
|
105
|
-
ForOfStatement: checkBranch,
|
|
106
|
-
ForInStatement: checkBranch,
|
|
107
|
-
WhileStatement: checkBranch,
|
|
108
|
-
DoWhileStatement: checkBranch,
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Rule to enforce @req annotation on functions
|
|
5
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
|
-
* @req REQ-ANNOTATION-REQUIRED - Require @req annotation on functions
|
|
7
|
-
*/
|
|
8
|
-
exports.default = {
|
|
9
|
-
meta: {
|
|
10
|
-
type: "problem",
|
|
11
|
-
fixable: "code",
|
|
12
|
-
docs: {
|
|
13
|
-
description: "Require @req annotations on functions",
|
|
14
|
-
recommended: "error",
|
|
15
|
-
},
|
|
16
|
-
messages: {
|
|
17
|
-
missingReq: "Missing @req 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
|
-
if (!jsdoc || !jsdoc.value.includes("@req")) {
|
|
27
|
-
context.report({
|
|
28
|
-
node,
|
|
29
|
-
messageId: "missingReq",
|
|
30
|
-
fix(fixer) {
|
|
31
|
-
return fixer.insertTextBefore(node, "/** @req <REQ-ID> */\n");
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
};
|
|
@@ -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
|
-
};
|