eslint-plugin-traceability 1.0.0 → 1.0.2
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 +42 -5
- package/.voder/history.md +170 -140
- package/.voder/implementation-progress.md +113 -112
- package/.voder/last-action.md +118 -85
- package/.voder/plan.md +7 -10
- package/.voder/progress-chart.png +0 -0
- package/.voder/progress-log-areas.csv +1 -0
- package/.voder/progress-log.csv +1 -0
- package/CHANGELOG.md +10 -3
- package/docs/decisions/004-automated-version-bumping-for-ci-cd.md +165 -0
- package/lib/tests/basic.test.js +1 -1
- package/lib/tests/index.test.js +5 -1
- package/lib/tests/integration/file-validation.test.js +16 -5
- package/lib/tests/integration/plugin-validation.test.js +64 -58
- package/lib/tests/maintenance/detect-isolated.test.js +6 -1
- package/lib/tests/rules/require-branch-annotation.test.js +5 -3
- package/lib/tests/rules/require-story-annotation.test.js +1 -0
- package/package.json +1 -1
- package/tests/basic.test.ts +1 -1
- package/tests/index.test.ts +5 -1
- package/tests/integration/file-validation.test.ts +16 -5
- package/tests/integration/plugin-validation.test.ts +68 -63
- package/tests/maintenance/detect-isolated.test.ts +7 -3
- package/tests/rules/require-branch-annotation.test.ts +5 -3
- package/tests/rules/require-story-annotation.test.ts +1 -0
|
@@ -7,73 +7,78 @@
|
|
|
7
7
|
import { spawnSync, SpawnSyncReturns } from "child_process";
|
|
8
8
|
import path from "path";
|
|
9
9
|
|
|
10
|
+
// Ensure ESLint CLI uses built plugin
|
|
10
11
|
const eslintBin = path.resolve(__dirname, "../../node_modules/.bin/eslint");
|
|
11
12
|
const configPath = path.resolve(__dirname, "../../eslint.config.js");
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
describe("ESLint CLI Integration (Story 001.0-DEV-PLUGIN-SETUP)", () => {
|
|
15
|
+
/**
|
|
16
|
+
* Helper to run ESLint CLI with the traceability plugin and custom rule
|
|
17
|
+
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
18
|
+
* @req REQ-PLUGIN-STRUCTURE - Invoke ESLint CLI for integration testing
|
|
19
|
+
*/
|
|
20
|
+
function runEslint(code: string, rule: string): SpawnSyncReturns<string> {
|
|
21
|
+
const args = [
|
|
22
|
+
"--no-config-lookup",
|
|
23
|
+
"--config",
|
|
24
|
+
configPath,
|
|
25
|
+
"--stdin",
|
|
26
|
+
"--stdin-filename",
|
|
27
|
+
"foo.js",
|
|
28
|
+
"--rule",
|
|
29
|
+
"no-unused-vars:off",
|
|
30
|
+
"--rule",
|
|
31
|
+
rule,
|
|
32
|
+
];
|
|
33
|
+
return spawnSync("node", [eslintBin, ...args], {
|
|
34
|
+
encoding: "utf-8",
|
|
35
|
+
input: code,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
it("[REQ-PLUGIN-STRUCTURE] reports error when @story annotation is missing", () => {
|
|
40
|
+
// Arrange
|
|
41
|
+
const code = "function foo() {}";
|
|
42
|
+
const rule = "traceability/require-story-annotation:error";
|
|
43
|
+
// Act
|
|
44
|
+
const result = runEslint(code, rule);
|
|
45
|
+
// Assert
|
|
46
|
+
expect(result.status).toBe(1);
|
|
47
|
+
expect(result.stdout).toMatch(/require-story-annotation/);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("[REQ-PLUGIN-STRUCTURE] does not report error when @story annotation is present", () => {
|
|
51
|
+
// Arrange
|
|
52
|
+
const code = `/**
|
|
53
|
+
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
54
|
+
*/
|
|
55
|
+
function foo() {}`;
|
|
56
|
+
const rule = "traceability/require-story-annotation:error";
|
|
57
|
+
// Act
|
|
58
|
+
const result = runEslint(code, rule);
|
|
59
|
+
// Assert
|
|
60
|
+
expect(result.status).toBe(0);
|
|
30
61
|
});
|
|
31
|
-
}
|
|
32
62
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
code: `
|
|
44
|
-
/**
|
|
45
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
46
|
-
*/
|
|
47
|
-
function foo() {}
|
|
48
|
-
`,
|
|
49
|
-
rule: "traceability/require-story-annotation:error",
|
|
50
|
-
expectedStatus: 0,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: "Require Req Annotation CLI (Story 003.0-DEV-FUNCTION-ANNOTATIONS)",
|
|
54
|
-
code: "function foo() {}",
|
|
55
|
-
rule: "traceability/require-req-annotation:error",
|
|
56
|
-
expectedStatus: 1,
|
|
57
|
-
stdoutRegex: /require-req-annotation/,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "Require Branch Annotation CLI (Story 004.0-DEV-BRANCH-ANNOTATIONS)",
|
|
61
|
-
code: "if (condition) {}",
|
|
62
|
-
rule: "traceability/require-branch-annotation:error",
|
|
63
|
-
expectedStatus: 1,
|
|
64
|
-
stdoutRegex: /require-branch-annotation/,
|
|
65
|
-
},
|
|
66
|
-
];
|
|
63
|
+
it("[REQ-REQ-CLI] reports error when @req annotation is missing", () => {
|
|
64
|
+
// Arrange
|
|
65
|
+
const code = "function foo() {}";
|
|
66
|
+
const rule = "traceability/require-req-annotation:error";
|
|
67
|
+
// Act
|
|
68
|
+
const result = runEslint(code, rule);
|
|
69
|
+
// Assert
|
|
70
|
+
expect(result.status).toBe(1);
|
|
71
|
+
expect(result.stdout).toMatch(/require-req-annotation/);
|
|
72
|
+
});
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
);
|
|
74
|
+
it("[REQ-BRANCH-CLI] reports error when branch annotations missing", () => {
|
|
75
|
+
// Arrange
|
|
76
|
+
const code = "if (true) {}";
|
|
77
|
+
const rule = "traceability/require-branch-annotation:error";
|
|
78
|
+
// Act
|
|
79
|
+
const result = runEslint(code, rule);
|
|
80
|
+
// Assert
|
|
81
|
+
expect(result.status).toBe(1);
|
|
82
|
+
expect(result.stdout).toMatch(/require-branch-annotation/);
|
|
83
|
+
});
|
|
79
84
|
});
|
|
@@ -15,6 +15,7 @@ describe("detectStaleAnnotations isolated (Story 009.0-DEV-MAINTENANCE-TOOLS)",
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it("[REQ-MAINT-DETECT] detects stale annotations in nested directories", () => {
|
|
18
|
+
// Arrange
|
|
18
19
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "tmp-nested-"));
|
|
19
20
|
const nestedDir = path.join(tmpDir, "nested");
|
|
20
21
|
fs.mkdirSync(nestedDir);
|
|
@@ -33,10 +34,13 @@ describe("detectStaleAnnotations isolated (Story 009.0-DEV-MAINTENANCE-TOOLS)",
|
|
|
33
34
|
`;
|
|
34
35
|
fs.writeFileSync(filePath2, content2, "utf8");
|
|
35
36
|
|
|
37
|
+
// Act
|
|
36
38
|
const result = detectStaleAnnotations(tmpDir);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
39
|
+
|
|
40
|
+
// Assert
|
|
41
|
+
expect(result).toHaveLength(2);
|
|
42
|
+
expect(result).toContain("stale1.story.md");
|
|
43
|
+
expect(result).toContain("stale2.story.md");
|
|
40
44
|
});
|
|
41
45
|
|
|
42
46
|
it("[REQ-MAINT-DETECT] throws error on permission denied", () => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tests for: docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
3
|
+
* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
4
|
+
* @req REQ-BRANCH-DETECTION - Verify require-branch-annotation rule enforces branch annotations
|
|
5
|
+
*/
|
|
4
6
|
import { RuleTester } from "eslint";
|
|
5
7
|
import rule from "../../src/rules/require-branch-annotation";
|
|
6
8
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
3
3
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
|
+
* @req REQ-ANNOTATION-REQUIRED - Verify require-story-annotation rule enforces @story annotation on functions
|
|
4
5
|
*/
|
|
5
6
|
import { RuleTester } from "eslint";
|
|
6
7
|
import rule from "../../src/rules/require-story-annotation";
|