eslint-plugin-traceability 1.0.4 → 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 +26 -18
- 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
package/lib/src/index.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ESLint Traceability Plugin
|
|
3
|
-
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
4
|
-
* @req REQ-PLUGIN-STRUCTURE - Provide foundational plugin export and registration
|
|
5
|
-
*/
|
|
6
|
-
export declare const rules: {
|
|
7
|
-
"require-story-annotation": any;
|
|
8
|
-
"require-req-annotation": any;
|
|
9
|
-
"require-branch-annotation": any;
|
|
10
|
-
"valid-annotation-format": any;
|
|
11
|
-
"valid-story-reference": import("eslint").Rule.RuleModule;
|
|
12
|
-
"valid-req-reference": import("eslint").Rule.RuleModule;
|
|
13
|
-
};
|
|
14
|
-
export declare const configs: {
|
|
15
|
-
recommended: {
|
|
16
|
-
plugins: {
|
|
17
|
-
traceability: {};
|
|
18
|
-
};
|
|
19
|
-
rules: {
|
|
20
|
-
"traceability/require-story-annotation": string;
|
|
21
|
-
"traceability/require-req-annotation": string;
|
|
22
|
-
"traceability/require-branch-annotation": string;
|
|
23
|
-
"traceability/valid-annotation-format": string;
|
|
24
|
-
"traceability/valid-story-reference": string;
|
|
25
|
-
"traceability/valid-req-reference": string;
|
|
26
|
-
};
|
|
27
|
-
}[];
|
|
28
|
-
strict: {
|
|
29
|
-
plugins: {
|
|
30
|
-
traceability: {};
|
|
31
|
-
};
|
|
32
|
-
rules: {
|
|
33
|
-
"traceability/require-story-annotation": string;
|
|
34
|
-
"traceability/require-req-annotation": string;
|
|
35
|
-
"traceability/require-branch-annotation": string;
|
|
36
|
-
"traceability/valid-annotation-format": string;
|
|
37
|
-
"traceability/valid-story-reference": string;
|
|
38
|
-
"traceability/valid-req-reference": string;
|
|
39
|
-
};
|
|
40
|
-
}[];
|
|
41
|
-
};
|
|
42
|
-
declare const _default: {
|
|
43
|
-
rules: {
|
|
44
|
-
"require-story-annotation": any;
|
|
45
|
-
"require-req-annotation": any;
|
|
46
|
-
"require-branch-annotation": any;
|
|
47
|
-
"valid-annotation-format": any;
|
|
48
|
-
"valid-story-reference": import("eslint").Rule.RuleModule;
|
|
49
|
-
"valid-req-reference": import("eslint").Rule.RuleModule;
|
|
50
|
-
};
|
|
51
|
-
configs: {
|
|
52
|
-
recommended: {
|
|
53
|
-
plugins: {
|
|
54
|
-
traceability: {};
|
|
55
|
-
};
|
|
56
|
-
rules: {
|
|
57
|
-
"traceability/require-story-annotation": string;
|
|
58
|
-
"traceability/require-req-annotation": string;
|
|
59
|
-
"traceability/require-branch-annotation": string;
|
|
60
|
-
"traceability/valid-annotation-format": string;
|
|
61
|
-
"traceability/valid-story-reference": string;
|
|
62
|
-
"traceability/valid-req-reference": string;
|
|
63
|
-
};
|
|
64
|
-
}[];
|
|
65
|
-
strict: {
|
|
66
|
-
plugins: {
|
|
67
|
-
traceability: {};
|
|
68
|
-
};
|
|
69
|
-
rules: {
|
|
70
|
-
"traceability/require-story-annotation": string;
|
|
71
|
-
"traceability/require-req-annotation": string;
|
|
72
|
-
"traceability/require-branch-annotation": string;
|
|
73
|
-
"traceability/valid-annotation-format": string;
|
|
74
|
-
"traceability/valid-story-reference": string;
|
|
75
|
-
"traceability/valid-req-reference": string;
|
|
76
|
-
};
|
|
77
|
-
}[];
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
export default _default;
|
package/lib/src/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ESLint Traceability Plugin
|
|
4
|
-
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
5
|
-
* @req REQ-PLUGIN-STRUCTURE - Provide foundational plugin export and registration
|
|
6
|
-
*/
|
|
7
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.configs = exports.rules = void 0;
|
|
12
|
-
const require_story_annotation_1 = __importDefault(require("./rules/require-story-annotation"));
|
|
13
|
-
const require_req_annotation_1 = __importDefault(require("./rules/require-req-annotation"));
|
|
14
|
-
const require_branch_annotation_1 = __importDefault(require("./rules/require-branch-annotation"));
|
|
15
|
-
const valid_annotation_format_1 = __importDefault(require("./rules/valid-annotation-format"));
|
|
16
|
-
const valid_story_reference_1 = __importDefault(require("./rules/valid-story-reference"));
|
|
17
|
-
const valid_req_reference_1 = __importDefault(require("./rules/valid-req-reference"));
|
|
18
|
-
exports.rules = {
|
|
19
|
-
"require-story-annotation": require_story_annotation_1.default,
|
|
20
|
-
"require-req-annotation": require_req_annotation_1.default,
|
|
21
|
-
"require-branch-annotation": require_branch_annotation_1.default,
|
|
22
|
-
"valid-annotation-format": valid_annotation_format_1.default,
|
|
23
|
-
"valid-story-reference": valid_story_reference_1.default,
|
|
24
|
-
"valid-req-reference": valid_req_reference_1.default,
|
|
25
|
-
};
|
|
26
|
-
exports.configs = {
|
|
27
|
-
recommended: [
|
|
28
|
-
{
|
|
29
|
-
plugins: {
|
|
30
|
-
traceability: {},
|
|
31
|
-
},
|
|
32
|
-
rules: {
|
|
33
|
-
"traceability/require-story-annotation": "error",
|
|
34
|
-
"traceability/require-req-annotation": "error",
|
|
35
|
-
"traceability/require-branch-annotation": "error",
|
|
36
|
-
"traceability/valid-annotation-format": "error",
|
|
37
|
-
"traceability/valid-story-reference": "error",
|
|
38
|
-
"traceability/valid-req-reference": "error",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
strict: [
|
|
43
|
-
{
|
|
44
|
-
plugins: {
|
|
45
|
-
traceability: {},
|
|
46
|
-
},
|
|
47
|
-
rules: {
|
|
48
|
-
"traceability/require-story-annotation": "error",
|
|
49
|
-
"traceability/require-req-annotation": "error",
|
|
50
|
-
"traceability/require-branch-annotation": "error",
|
|
51
|
-
"traceability/valid-annotation-format": "error",
|
|
52
|
-
"traceability/valid-story-reference": "error",
|
|
53
|
-
"traceability/valid-req-reference": "error",
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
};
|
|
58
|
-
exports.default = { rules: exports.rules, configs: exports.configs };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Batch update annotations and verify references
|
|
3
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
4
|
-
* @req REQ-MAINT-BATCH - Perform batch updates
|
|
5
|
-
* @req REQ-MAINT-VERIFY - Verify annotation references
|
|
6
|
-
*/
|
|
7
|
-
export declare function batchUpdateAnnotations(codebasePath: string, mappings: {
|
|
8
|
-
oldPath: string;
|
|
9
|
-
newPath: string;
|
|
10
|
-
}[]): number;
|
|
11
|
-
/**
|
|
12
|
-
* Verify annotation references in codebase after maintenance operations
|
|
13
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
14
|
-
* @req REQ-MAINT-VERIFY - Verify annotation references
|
|
15
|
-
*/
|
|
16
|
-
export declare function verifyAnnotations(codebasePath: string): boolean;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.batchUpdateAnnotations = batchUpdateAnnotations;
|
|
4
|
-
exports.verifyAnnotations = verifyAnnotations;
|
|
5
|
-
const update_1 = require("./update");
|
|
6
|
-
const detect_1 = require("./detect");
|
|
7
|
-
/**
|
|
8
|
-
* Batch update annotations and verify references
|
|
9
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
10
|
-
* @req REQ-MAINT-BATCH - Perform batch updates
|
|
11
|
-
* @req REQ-MAINT-VERIFY - Verify annotation references
|
|
12
|
-
*/
|
|
13
|
-
function batchUpdateAnnotations(codebasePath, mappings) {
|
|
14
|
-
let totalUpdated = 0;
|
|
15
|
-
for (const { oldPath, newPath } of mappings) {
|
|
16
|
-
totalUpdated += (0, update_1.updateAnnotationReferences)(codebasePath, oldPath, newPath);
|
|
17
|
-
}
|
|
18
|
-
return totalUpdated;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Verify annotation references in codebase after maintenance operations
|
|
22
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
23
|
-
* @req REQ-MAINT-VERIFY - Verify annotation references
|
|
24
|
-
*/
|
|
25
|
-
function verifyAnnotations(codebasePath) {
|
|
26
|
-
const staleAnnotations = (0, detect_1.detectStaleAnnotations)(codebasePath);
|
|
27
|
-
return staleAnnotations.length === 0;
|
|
28
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detect stale annotation references that point to moved or deleted story files
|
|
3
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
4
|
-
* @req REQ-MAINT-DETECT - Detect stale annotation references
|
|
5
|
-
*/
|
|
6
|
-
export declare function detectStaleAnnotations(codebasePath: string): string[];
|
|
@@ -1,69 +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.detectStaleAnnotations = detectStaleAnnotations;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const utils_1 = require("./utils");
|
|
40
|
-
/**
|
|
41
|
-
* Detect stale annotation references that point to moved or deleted story files
|
|
42
|
-
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
43
|
-
* @req REQ-MAINT-DETECT - Detect stale annotation references
|
|
44
|
-
*/
|
|
45
|
-
function detectStaleAnnotations(codebasePath) {
|
|
46
|
-
if (!fs.existsSync(codebasePath) ||
|
|
47
|
-
!fs.statSync(codebasePath).isDirectory()) {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
const cwd = process.cwd();
|
|
51
|
-
const baseDir = path.resolve(cwd, codebasePath);
|
|
52
|
-
const stale = new Set();
|
|
53
|
-
const files = (0, utils_1.getAllFiles)(codebasePath);
|
|
54
|
-
for (const file of files) {
|
|
55
|
-
const content = fs.readFileSync(file, "utf8");
|
|
56
|
-
const regex = /@story\s+([^\s]+)/g;
|
|
57
|
-
let match;
|
|
58
|
-
while ((match = regex.exec(content)) !== null) {
|
|
59
|
-
const storyPath = match[1];
|
|
60
|
-
const storyProjectPath = path.resolve(cwd, storyPath);
|
|
61
|
-
const storyCodebasePath = path.resolve(baseDir, storyPath);
|
|
62
|
-
if (!fs.existsSync(storyProjectPath) &&
|
|
63
|
-
!fs.existsSync(storyCodebasePath)) {
|
|
64
|
-
stale.add(storyPath);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return Array.from(stale);
|
|
69
|
-
}
|
|
@@ -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
|
-
};
|