eslint-plugin-traceability 1.0.6 โ†’ 1.1.1

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.
Files changed (65) hide show
  1. package/.github/workflows/ci-cd.yml +5 -2
  2. package/.releaserc.json +6 -1
  3. package/CHANGELOG.md +3 -2
  4. package/lib/src/index.d.ts +80 -0
  5. package/lib/src/index.js +58 -0
  6. package/lib/src/maintenance/batch.d.ts +16 -0
  7. package/lib/src/maintenance/batch.js +28 -0
  8. package/lib/src/maintenance/detect.d.ts +6 -0
  9. package/lib/src/maintenance/detect.js +69 -0
  10. package/lib/src/maintenance/index.d.ts +14 -0
  11. package/lib/src/maintenance/index.js +22 -0
  12. package/lib/src/maintenance/report.d.ts +7 -0
  13. package/lib/src/maintenance/report.js +17 -0
  14. package/lib/src/maintenance/update.d.ts +6 -0
  15. package/lib/src/maintenance/update.js +67 -0
  16. package/lib/src/maintenance/utils.d.ts +6 -0
  17. package/lib/src/maintenance/utils.js +64 -0
  18. package/lib/src/rules/require-branch-annotation.d.ts +7 -0
  19. package/lib/src/rules/require-branch-annotation.js +111 -0
  20. package/lib/src/rules/require-req-annotation.d.ts +7 -0
  21. package/lib/src/rules/require-req-annotation.js +38 -0
  22. package/lib/src/rules/require-story-annotation.d.ts +7 -0
  23. package/lib/src/rules/require-story-annotation.js +50 -0
  24. package/lib/src/rules/valid-annotation-format.d.ts +10 -0
  25. package/lib/src/rules/valid-annotation-format.js +60 -0
  26. package/lib/src/rules/valid-req-reference.d.ts +3 -0
  27. package/lib/src/rules/valid-req-reference.js +104 -0
  28. package/lib/src/rules/valid-story-reference.d.ts +3 -0
  29. package/lib/src/rules/valid-story-reference.js +168 -0
  30. package/lib/tests/fixtures/stale/example.d.ts +0 -0
  31. package/lib/tests/fixtures/stale/example.js +3 -0
  32. package/lib/tests/fixtures/update/example.d.ts +0 -0
  33. package/lib/tests/fixtures/update/example.js +3 -0
  34. package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
  35. package/lib/tests/fixtures/valid-annotations/example.js +3 -0
  36. package/lib/tests/maintenance/batch.test.d.ts +1 -0
  37. package/lib/tests/maintenance/batch.test.js +79 -0
  38. package/lib/tests/maintenance/detect-isolated.test.d.ts +1 -0
  39. package/lib/tests/maintenance/detect-isolated.test.js +95 -0
  40. package/lib/tests/maintenance/detect.test.d.ts +1 -0
  41. package/lib/tests/maintenance/detect.test.js +23 -0
  42. package/lib/tests/maintenance/report.test.d.ts +1 -0
  43. package/lib/tests/maintenance/report.test.js +67 -0
  44. package/lib/tests/maintenance/update-isolated.test.d.ts +1 -0
  45. package/lib/tests/maintenance/update-isolated.test.js +66 -0
  46. package/lib/tests/maintenance/update.test.d.ts +1 -0
  47. package/lib/tests/maintenance/update.test.js +26 -0
  48. package/lib/tests/plugin-default-export-and-configs.test.d.ts +1 -0
  49. package/lib/tests/plugin-default-export-and-configs.test.js +72 -0
  50. package/lib/tests/plugin-setup.test.d.ts +1 -0
  51. package/lib/tests/plugin-setup.test.js +51 -0
  52. package/lib/tests/rules/require-branch-annotation.test.d.ts +1 -0
  53. package/lib/tests/rules/require-branch-annotation.test.js +253 -0
  54. package/lib/tests/rules/require-req-annotation.test.d.ts +1 -0
  55. package/lib/tests/rules/require-req-annotation.test.js +41 -0
  56. package/lib/tests/rules/require-story-annotation.test.d.ts +1 -0
  57. package/lib/tests/rules/require-story-annotation.test.js +36 -0
  58. package/lib/tests/rules/valid-annotation-format.test.d.ts +1 -0
  59. package/lib/tests/rules/valid-annotation-format.test.js +58 -0
  60. package/lib/tests/rules/valid-req-reference.test.d.ts +1 -0
  61. package/lib/tests/rules/valid-req-reference.test.js +87 -0
  62. package/lib/tests/rules/valid-story-reference.test.d.ts +1 -0
  63. package/lib/tests/rules/valid-story-reference.test.js +69 -0
  64. package/package.json +2 -1
  65. package/scripts/smoke-test.sh +51 -0
@@ -0,0 +1,58 @@
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/005.0-DEV-ANNOTATION-VALIDATION.story.md
8
+ * @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md
9
+ * @req REQ-FORMAT-SPECIFICATION - Verify valid-annotation-format rule enforces annotation format syntax
10
+ */
11
+ const eslint_1 = require("eslint");
12
+ const valid_annotation_format_1 = __importDefault(require("../../src/rules/valid-annotation-format"));
13
+ const ruleTester = new eslint_1.RuleTester({
14
+ languageOptions: { parserOptions: { ecmaVersion: 2020 } },
15
+ });
16
+ describe("Valid Annotation Format Rule (Story 005.0-DEV-ANNOTATION-VALIDATION)", () => {
17
+ ruleTester.run("valid-annotation-format", valid_annotation_format_1.default, {
18
+ valid: [
19
+ {
20
+ name: "[REQ-PATH-FORMAT] valid story annotation format",
21
+ code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md`,
22
+ },
23
+ {
24
+ name: "[REQ-REQ-FORMAT] valid req annotation format",
25
+ code: `// @req REQ-EXAMPLE`,
26
+ },
27
+ {
28
+ name: "[REQ-FORMAT-SPECIFICATION] valid block annotations",
29
+ code: `/**
30
+ * @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md
31
+ * @req REQ-VALID-EXAMPLE
32
+ */`,
33
+ },
34
+ ],
35
+ invalid: [
36
+ {
37
+ name: "[REQ-PATH-FORMAT] missing story path",
38
+ code: `// @story`,
39
+ errors: [{ messageId: "invalidStoryFormat" }],
40
+ },
41
+ {
42
+ name: "[REQ-PATH-FORMAT] invalid story file extension",
43
+ code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story`,
44
+ errors: [{ messageId: "invalidStoryFormat" }],
45
+ },
46
+ {
47
+ name: "[REQ-REQ-FORMAT] missing req id",
48
+ code: `// @req`,
49
+ errors: [{ messageId: "invalidReqFormat" }],
50
+ },
51
+ {
52
+ name: "[REQ-REQ-FORMAT] invalid req id format",
53
+ code: `// @req invalid-format`,
54
+ errors: [{ messageId: "invalidReqFormat" }],
55
+ },
56
+ ],
57
+ });
58
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
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/010.0-DEV-DEEP-VALIDATION.story.md
8
+ * @story docs/stories/010.0-DEV-DEEP-VALIDATION.story.md
9
+ * @req REQ-DEEP-PARSE - Verify valid-req-reference rule enforces existing requirement content
10
+ */
11
+ const eslint_1 = require("eslint");
12
+ const valid_req_reference_1 = __importDefault(require("../../src/rules/valid-req-reference"));
13
+ const ruleTester = new eslint_1.RuleTester({
14
+ languageOptions: { parserOptions: { ecmaVersion: 2020 } },
15
+ });
16
+ describe("Valid Req Reference Rule (Story 010.0-DEV-DEEP-VALIDATION)", () => {
17
+ ruleTester.run("valid-req-reference", valid_req_reference_1.default, {
18
+ valid: [
19
+ {
20
+ name: "[REQ-DEEP-PARSE] valid requirement reference existing in story file",
21
+ code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
22
+ // @req REQ-PLUGIN-STRUCTURE`,
23
+ },
24
+ {
25
+ name: "[REQ-DEEP-BULLET] valid bullet list requirement existing in bullet story fixture",
26
+ code: `// @story tests/fixtures/story_bullet.md
27
+ // @req REQ-BULLET-LIST`,
28
+ },
29
+ ],
30
+ invalid: [
31
+ {
32
+ name: "[REQ-DEEP-MATCH] missing requirement in story file",
33
+ code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
34
+ // @req REQ-NON-EXISTENT`,
35
+ errors: [
36
+ {
37
+ messageId: "reqMissing",
38
+ data: {
39
+ reqId: "REQ-NON-EXISTENT",
40
+ storyPath: "docs/stories/001.0-DEV-PLUGIN-SETUP.story.md",
41
+ },
42
+ },
43
+ ],
44
+ },
45
+ {
46
+ name: "[REQ-DEEP-PARSE] disallow path traversal in story path",
47
+ code: `// @story ../docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
48
+ // @req REQ-PLUGIN-STRUCTURE`,
49
+ errors: [
50
+ {
51
+ messageId: "invalidPath",
52
+ data: {
53
+ storyPath: "../docs/stories/001.0-DEV-PLUGIN-SETUP.story.md",
54
+ },
55
+ },
56
+ ],
57
+ },
58
+ {
59
+ name: "[REQ-DEEP-PARSE] disallow absolute path in story path",
60
+ code: `// @story /absolute/path/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
61
+ // @req REQ-PLUGIN-STRUCTURE`,
62
+ errors: [
63
+ {
64
+ messageId: "invalidPath",
65
+ data: {
66
+ storyPath: "/absolute/path/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md",
67
+ },
68
+ },
69
+ ],
70
+ },
71
+ {
72
+ name: "[REQ-DEEP-BULLET] missing bullet list requirement in bullet story fixture",
73
+ code: `// @story tests/fixtures/story_bullet.md
74
+ // @req REQ-MISSING-BULLET`,
75
+ errors: [
76
+ {
77
+ messageId: "reqMissing",
78
+ data: {
79
+ reqId: "REQ-MISSING-BULLET",
80
+ storyPath: "tests/fixtures/story_bullet.md",
81
+ },
82
+ },
83
+ ],
84
+ },
85
+ ],
86
+ });
87
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
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/006.0-DEV-FILE-VALIDATION.story.md
8
+ * @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md
9
+ * @req REQ-FILE-EXISTENCE - Verify valid-story-reference rule enforces existing .story.md files
10
+ */
11
+ const eslint_1 = require("eslint");
12
+ const valid_story_reference_1 = __importDefault(require("../../src/rules/valid-story-reference"));
13
+ const ruleTester = new eslint_1.RuleTester({
14
+ languageOptions: { parserOptions: { ecmaVersion: 2020 } },
15
+ });
16
+ describe("Valid Story Reference Rule (Story 006.0-DEV-FILE-VALIDATION)", () => {
17
+ ruleTester.run("valid-story-reference", valid_story_reference_1.default, {
18
+ valid: [
19
+ {
20
+ name: "[REQ-FILE-EXISTENCE] valid story file reference",
21
+ code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md`,
22
+ },
23
+ {
24
+ name: "[REQ-EXTENSION] valid .story.md extension",
25
+ code: `// @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md`,
26
+ },
27
+ {
28
+ name: "[REQ-PATH-RESOLUTION] valid relative path with ./ prefix",
29
+ code: `// @story ./docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md`,
30
+ },
31
+ ],
32
+ invalid: [
33
+ {
34
+ name: "[REQ-PATH-RESOLUTION] missing file",
35
+ code: `// @story docs/stories/missing-file.story.md`,
36
+ errors: [
37
+ {
38
+ messageId: "fileMissing",
39
+ data: { path: "docs/stories/missing-file.story.md" },
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ name: "[REQ-EXTENSION] invalid extension",
45
+ code: `// @story docs/stories/001.0-DEV-PLUGIN-SETUP.md`,
46
+ errors: [
47
+ {
48
+ messageId: "invalidExtension",
49
+ data: { path: "docs/stories/001.0-DEV-PLUGIN-SETUP.md" },
50
+ },
51
+ ],
52
+ },
53
+ {
54
+ name: "[REQ-PATH-SECURITY] path traversal",
55
+ code: `// @story ../outside.story.md`,
56
+ errors: [
57
+ { messageId: "invalidPath", data: { path: "../outside.story.md" } },
58
+ ],
59
+ },
60
+ {
61
+ name: "[REQ-ABSOLUTE-PATH] absolute path not allowed",
62
+ code: `// @story /etc/passwd.story.md`,
63
+ errors: [
64
+ { messageId: "invalidPath", data: { path: "/etc/passwd.story.md" } },
65
+ ],
66
+ },
67
+ ],
68
+ });
69
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-traceability",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -16,6 +16,7 @@
16
16
  "format": "prettier --write .",
17
17
  "format:check": "prettier --check .",
18
18
  "duplication": "jscpd src tests --reporters console --threshold 3",
19
+ "smoke-test": "./scripts/smoke-test.sh",
19
20
  "prepare": "husky install"
20
21
  },
21
22
  "lint-staged": {
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo "๐Ÿงช Running smoke test for eslint-plugin-traceability"
5
+ echo ""
6
+
7
+ # Pack the package first
8
+ echo "๐Ÿ“ฆ Packing the package..."
9
+ tarball=$(npm pack 2>&1 | tail -1)
10
+ echo " Created: $tarball"
11
+
12
+ # Create temporary directory
13
+ workdir=$(mktemp -d)
14
+ echo "๐Ÿ“ Created test directory: $workdir"
15
+
16
+ # Cleanup on exit
17
+ cleanup() {
18
+ echo "๐Ÿงน Cleaning up test directory and tarball"
19
+ rm -rf "$workdir"
20
+ rm -f "$tarball"
21
+ }
22
+ trap cleanup EXIT
23
+
24
+ cd "$workdir"
25
+
26
+ # Initialize npm project
27
+ echo "๐Ÿ“ฆ Initializing npm project..."
28
+ npm init -y > /dev/null
29
+
30
+ # Install the packed tarball
31
+ echo "๐Ÿ“ฅ Installing eslint-plugin-traceability from packed tarball..."
32
+ npm install "$OLDPWD/$tarball" > /dev/null
33
+
34
+ # Create ESLint config (CommonJS format)
35
+ echo "โš™๏ธ Creating ESLint config..."
36
+ cat > eslint.config.js << 'EOF'
37
+ const traceability = require('eslint-plugin-traceability');
38
+ module.exports = [
39
+ {
40
+ plugins: { traceability },
41
+ rules: {}
42
+ }
43
+ ];
44
+ EOF
45
+
46
+ # Test the plugin loads
47
+ echo "๐Ÿ” Testing plugin configuration..."
48
+ npx eslint --print-config eslint.config.js > /dev/null
49
+
50
+ echo ""
51
+ echo "โœ… Smoke test passed! Plugin loads successfully."