eslint-plugin-traceability 1.1.11 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,85 @@
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 CLI integration functionality
8
+ * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
9
+ * @req REQ-PLUGIN-STRUCTURE - Validate plugin registers via CLI
10
+ */
11
+ const child_process_1 = require("child_process");
12
+ const path_1 = __importDefault(require("path"));
13
+ describe("[docs/stories/001.0-DEV-PLUGIN-SETUP.story.md] CLI Integration (traceability plugin)", () => {
14
+ const eslintPkgDir = path_1.default.dirname(require.resolve("eslint/package.json"));
15
+ const eslintCliPath = path_1.default.join(eslintPkgDir, "bin", "eslint.js");
16
+ const configPath = path_1.default.resolve(__dirname, "../../eslint.config.js");
17
+ const tests = [
18
+ {
19
+ name: "reports error when @story annotation is missing",
20
+ code: "function foo() {}",
21
+ rule: "traceability/require-story-annotation:error",
22
+ expectedStatus: 1,
23
+ },
24
+ {
25
+ name: "does not report error when @story annotation is present",
26
+ code: `/**
27
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
28
+ */
29
+ function foo() {}`,
30
+ rule: "traceability/require-story-annotation:error",
31
+ expectedStatus: 0,
32
+ },
33
+ {
34
+ name: "reports error when @req annotation is missing",
35
+ code: "function bar() {}",
36
+ rule: "traceability/require-req-annotation:error",
37
+ expectedStatus: 1,
38
+ },
39
+ {
40
+ name: "reports error when @story annotation uses path traversal and @req annotation uses path traversal",
41
+ code: `/**
42
+ * @story ../docs/stories/invalid.story.md
43
+ * @req ../docs/requirements/REQ-INVALID.md
44
+ */
45
+ function bar() {}`,
46
+ rule: "traceability/valid-req-reference:error",
47
+ expectedStatus: 1,
48
+ },
49
+ {
50
+ name: "reports error when @story annotation uses absolute path and @req annotation uses absolute path",
51
+ code: `/**
52
+ * @story /absolute/path/to/story.story.md
53
+ * @req /etc/passwd
54
+ */
55
+ function baz() {}`,
56
+ rule: "traceability/valid-req-reference:error",
57
+ expectedStatus: 1,
58
+ },
59
+ ];
60
+ function runEslint(code, rule) {
61
+ const args = [
62
+ "--no-config-lookup",
63
+ "--config",
64
+ configPath,
65
+ "--stdin",
66
+ "--stdin-filename",
67
+ "foo.js",
68
+ "--rule",
69
+ "no-unused-vars:off",
70
+ "--rule",
71
+ rule,
72
+ ];
73
+ const result = (0, child_process_1.spawnSync)(process.execPath, [eslintCliPath, ...args], {
74
+ encoding: "utf-8",
75
+ input: code,
76
+ });
77
+ return result;
78
+ }
79
+ tests.forEach((testCase) => {
80
+ it(`[REQ-PLUGIN-STRUCTURE] ${testCase.name}`, () => {
81
+ const result = runEslint(testCase.code, testCase.rule);
82
+ expect(result.status).toBe(testCase.expectedStatus);
83
+ });
84
+ });
85
+ });
@@ -24,4 +24,22 @@ describe("detectStaleAnnotations (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
24
24
  fs_1.default.rmSync(tmpDir, { recursive: true, force: true });
25
25
  }
26
26
  });
27
+ it("[REQ-MAINT-DETECT] should detect stale annotation references", () => {
28
+ const tmpDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "detect-stale-"));
29
+ try {
30
+ const filePath = path_1.default.join(tmpDir, "file.ts");
31
+ const storyName = "stale.story.md";
32
+ const content = `
33
+ /**
34
+ * @story ${storyName}
35
+ */`;
36
+ fs_1.default.writeFileSync(filePath, content, "utf8");
37
+ const result = (0, detect_1.detectStaleAnnotations)(tmpDir);
38
+ expect(result).toHaveLength(1);
39
+ expect(result).toContain(storyName);
40
+ }
41
+ finally {
42
+ fs_1.default.rmSync(tmpDir, { recursive: true, force: true });
43
+ }
44
+ });
27
45
  });
@@ -63,4 +63,8 @@ function foo() {}
63
63
  fs.rmSync(tmpDir, { recursive: true, force: true });
64
64
  }
65
65
  });
66
+ it("[REQ-MAINT-UPDATE] should return 0 when directory does not exist", () => {
67
+ const count = (0, update_1.updateAnnotationReferences)("non-existent-dir", "old.md", "new.md");
68
+ expect(count).toBe(0);
69
+ });
66
70
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-traceability",
3
- "version": "1.1.11",
3
+ "version": "1.2.0",
4
4
  "description": "A customizable ESLint plugin that enforces traceability annotations in your code, ensuring each implementation is linked to its requirement or test case.",
5
5
  "main": "lib/src/index.js",
6
6
  "types": "lib/src/index.d.ts",
@@ -13,11 +13,10 @@
13
13
  "doc": "docs"
14
14
  },
15
15
  "scripts": {
16
- "prelint": "npm run build",
17
16
  "build": "tsc -p tsconfig.json",
18
17
  "type-check": "tsc --noEmit -p tsconfig.json",
19
18
  "lint": "eslint \"src/**/*.{js,ts}\" \"tests/**/*.{js,ts}\" --max-warnings=0",
20
- "test": "jest --ci --bail && node tests/integration/cli-integration.js",
19
+ "test": "jest --ci --bail",
21
20
  "format": "prettier --write .",
22
21
  "format:check": "prettier --check .",
23
22
  "duplication": "jscpd src tests --reporters console --threshold 3",
@@ -60,7 +59,7 @@
60
59
  "actionlint": "^2.0.6",
61
60
  "eslint": "^9.39.1",
62
61
  "husky": "^9.1.7",
63
- "jest": "^29.7.0",
62
+ "jest": "^30.2.0",
64
63
  "jscpd": "^4.0.5",
65
64
  "lint-staged": "^16.2.6",
66
65
  "prettier": "^3.6.2",