eslint-plugin-traceability 1.0.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.
Files changed (159) hide show
  1. package/.env.example +6 -0
  2. package/.github/workflows/ci-cd.yml +56 -0
  3. package/.husky/pre-commit +1 -0
  4. package/.husky/pre-push +1 -0
  5. package/.prettierignore +23 -0
  6. package/.prettierrc +4 -0
  7. package/.voder/history.md +164 -0
  8. package/.voder/implementation-progress.md +145 -0
  9. package/.voder/last-action.md +106 -0
  10. package/.voder/plan.md +15 -0
  11. package/.voder/progress-chart.png +0 -0
  12. package/.voder/progress-log-areas.csv +34 -0
  13. package/.voder/progress-log.csv +33 -0
  14. package/.voder/traceability/docs-stories-001.0-DEV-PLUGIN-SETUP.story.xml +17 -0
  15. package/.voder/traceability/docs-stories-002.0-DEV-ESLINT-CONFIG.story.xml +13 -0
  16. package/.voder/traceability/docs-stories-003.0-DEV-FUNCTION-ANNOTATIONS.story.xml +9 -0
  17. package/.voder/traceability/docs-stories-004.0-DEV-BRANCH-ANNOTATIONS.story.xml +9 -0
  18. package/.voder/traceability/docs-stories-005.0-DEV-ANNOTATION-VALIDATION.story.xml +9 -0
  19. package/.voder/traceability/docs-stories-006.0-DEV-FILE-VALIDATION.story.xml +9 -0
  20. package/.voder/traceability/docs-stories-007.0-DEV-ERROR-REPORTING.story.xml +9 -0
  21. package/.voder/traceability/docs-stories-008.0-DEV-AUTO-FIX.story.xml +9 -0
  22. package/.voder/traceability/docs-stories-009.0-DEV-MAINTENANCE-TOOLS.story.xml +16 -0
  23. package/.voder/traceability/docs-stories-010.0-DEV-DEEP-VALIDATION.story.xml +11 -0
  24. package/CHANGELOG.md +31 -0
  25. package/CONTRIBUTING.md +97 -0
  26. package/LICENSE +21 -0
  27. package/README.md +159 -0
  28. package/cli-integration.js +157 -0
  29. package/docs/cli-integration.md +103 -0
  30. package/docs/config-presets.md +38 -0
  31. package/docs/decisions/001-typescript-for-eslint-plugin.accepted.md +111 -0
  32. package/docs/decisions/002-jest-for-eslint-testing.accepted.md +137 -0
  33. package/docs/decisions/003-code-quality-ratcheting-plan.md +48 -0
  34. package/docs/eslint-9-setup-guide.md +517 -0
  35. package/docs/eslint-plugin-development-guide.md +483 -0
  36. package/docs/jest-testing-guide.md +100 -0
  37. package/docs/rules/require-branch-annotation.md +34 -0
  38. package/docs/rules/require-req-annotation.md +39 -0
  39. package/docs/rules/require-story-annotation.md +36 -0
  40. package/docs/rules/valid-annotation-format.md +52 -0
  41. package/docs/rules/valid-req-reference.md +58 -0
  42. package/docs/rules/valid-story-reference.md +47 -0
  43. package/docs/security-incidents/unresolved-vulnerabilities.md +11 -0
  44. package/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md +82 -0
  45. package/docs/stories/002.0-DEV-ESLINT-CONFIG.story.md +82 -0
  46. package/docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md +85 -0
  47. package/docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md +107 -0
  48. package/docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md +119 -0
  49. package/docs/stories/006.0-DEV-FILE-VALIDATION.story.md +127 -0
  50. package/docs/stories/007.0-DEV-ERROR-REPORTING.story.md +89 -0
  51. package/docs/stories/008.0-DEV-AUTO-FIX.story.md +104 -0
  52. package/docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md +104 -0
  53. package/docs/stories/010.0-DEV-DEEP-VALIDATION.story.md +110 -0
  54. package/docs/stories/developer-story.map.md +118 -0
  55. package/eslint.config.js +146 -0
  56. package/jest.config.js +21 -0
  57. package/lib/index.d.ts +26 -0
  58. package/lib/index.js +11 -0
  59. package/lib/src/index.d.ts +80 -0
  60. package/lib/src/index.js +58 -0
  61. package/lib/src/maintenance/batch.d.ts +16 -0
  62. package/lib/src/maintenance/batch.js +28 -0
  63. package/lib/src/maintenance/detect.d.ts +6 -0
  64. package/lib/src/maintenance/detect.js +69 -0
  65. package/lib/src/maintenance/index.d.ts +14 -0
  66. package/lib/src/maintenance/index.js +22 -0
  67. package/lib/src/maintenance/report.d.ts +7 -0
  68. package/lib/src/maintenance/report.js +17 -0
  69. package/lib/src/maintenance/update.d.ts +6 -0
  70. package/lib/src/maintenance/update.js +67 -0
  71. package/lib/src/maintenance/utils.d.ts +6 -0
  72. package/lib/src/maintenance/utils.js +64 -0
  73. package/lib/src/rules/require-branch-annotation.d.ts +7 -0
  74. package/lib/src/rules/require-branch-annotation.js +111 -0
  75. package/lib/src/rules/require-req-annotation.d.ts +7 -0
  76. package/lib/src/rules/require-req-annotation.js +38 -0
  77. package/lib/src/rules/require-story-annotation.d.ts +7 -0
  78. package/lib/src/rules/require-story-annotation.js +50 -0
  79. package/lib/src/rules/valid-annotation-format.d.ts +10 -0
  80. package/lib/src/rules/valid-annotation-format.js +60 -0
  81. package/lib/src/rules/valid-req-reference.d.ts +3 -0
  82. package/lib/src/rules/valid-req-reference.js +104 -0
  83. package/lib/src/rules/valid-story-reference.d.ts +3 -0
  84. package/lib/src/rules/valid-story-reference.js +168 -0
  85. package/lib/tests/basic.test.d.ts +1 -0
  86. package/lib/tests/basic.test.js +51 -0
  87. package/lib/tests/fixtures/stale/example.d.ts +0 -0
  88. package/lib/tests/fixtures/stale/example.js +3 -0
  89. package/lib/tests/fixtures/update/example.d.ts +0 -0
  90. package/lib/tests/fixtures/update/example.js +3 -0
  91. package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
  92. package/lib/tests/fixtures/valid-annotations/example.js +3 -0
  93. package/lib/tests/index.test.d.ts +1 -0
  94. package/lib/tests/index.test.js +68 -0
  95. package/lib/tests/integration/file-validation.test.d.ts +1 -0
  96. package/lib/tests/integration/file-validation.test.js +60 -0
  97. package/lib/tests/integration/plugin-validation.test.d.ts +1 -0
  98. package/lib/tests/integration/plugin-validation.test.js +77 -0
  99. package/lib/tests/maintenance/batch.test.d.ts +1 -0
  100. package/lib/tests/maintenance/batch.test.js +79 -0
  101. package/lib/tests/maintenance/detect-isolated.test.d.ts +1 -0
  102. package/lib/tests/maintenance/detect-isolated.test.js +90 -0
  103. package/lib/tests/maintenance/detect.test.d.ts +1 -0
  104. package/lib/tests/maintenance/detect.test.js +23 -0
  105. package/lib/tests/maintenance/report.test.d.ts +1 -0
  106. package/lib/tests/maintenance/report.test.js +67 -0
  107. package/lib/tests/maintenance/update-isolated.test.d.ts +1 -0
  108. package/lib/tests/maintenance/update-isolated.test.js +66 -0
  109. package/lib/tests/maintenance/update.test.d.ts +1 -0
  110. package/lib/tests/maintenance/update.test.js +26 -0
  111. package/lib/tests/rules/require-branch-annotation.test.d.ts +1 -0
  112. package/lib/tests/rules/require-branch-annotation.test.js +251 -0
  113. package/lib/tests/rules/require-req-annotation.test.d.ts +1 -0
  114. package/lib/tests/rules/require-req-annotation.test.js +41 -0
  115. package/lib/tests/rules/require-story-annotation.test.d.ts +1 -0
  116. package/lib/tests/rules/require-story-annotation.test.js +35 -0
  117. package/lib/tests/rules/valid-annotation-format.test.d.ts +1 -0
  118. package/lib/tests/rules/valid-annotation-format.test.js +58 -0
  119. package/lib/tests/rules/valid-req-reference.test.d.ts +1 -0
  120. package/lib/tests/rules/valid-req-reference.test.js +87 -0
  121. package/lib/tests/rules/valid-story-reference.test.d.ts +1 -0
  122. package/lib/tests/rules/valid-story-reference.test.js +69 -0
  123. package/package.json +67 -0
  124. package/src/index.ts +56 -0
  125. package/src/maintenance/batch.ts +29 -0
  126. package/src/maintenance/detect.ts +42 -0
  127. package/src/maintenance/index.ts +14 -0
  128. package/src/maintenance/report.ts +15 -0
  129. package/src/maintenance/update.ts +40 -0
  130. package/src/maintenance/utils.ts +28 -0
  131. package/src/rules/require-branch-annotation.ts +114 -0
  132. package/src/rules/require-req-annotation.ts +36 -0
  133. package/src/rules/require-story-annotation.ts +52 -0
  134. package/src/rules/valid-annotation-format.ts +62 -0
  135. package/src/rules/valid-req-reference.ts +114 -0
  136. package/src/rules/valid-story-reference.ts +213 -0
  137. package/tests/basic.test.ts +17 -0
  138. package/tests/fixtures/stale/example.ts +2 -0
  139. package/tests/fixtures/story_bullet.md +6 -0
  140. package/tests/fixtures/update/example.ts +2 -0
  141. package/tests/fixtures/valid-annotations/example.ts +2 -0
  142. package/tests/index.test.ts +46 -0
  143. package/tests/integration/file-validation.test.ts +67 -0
  144. package/tests/integration/plugin-validation.test.ts +79 -0
  145. package/tests/maintenance/batch.test.ts +55 -0
  146. package/tests/maintenance/detect-isolated.test.ts +61 -0
  147. package/tests/maintenance/detect.test.ts +19 -0
  148. package/tests/maintenance/report.test.ts +37 -0
  149. package/tests/maintenance/update-isolated.test.ts +39 -0
  150. package/tests/maintenance/update.test.ts +21 -0
  151. package/tests/rules/require-branch-annotation.test.ts +248 -0
  152. package/tests/rules/require-req-annotation.test.ts +38 -0
  153. package/tests/rules/require-story-annotation.test.ts +32 -0
  154. package/tests/rules/valid-annotation-format.test.ts +55 -0
  155. package/tests/rules/valid-req-reference.test.ts +85 -0
  156. package/tests/rules/valid-story-reference.test.ts +66 -0
  157. package/tsconfig.json +15 -0
  158. package/user-docs/api-reference.md +135 -0
  159. package/user-docs/examples.md +73 -0
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/002.0-DEV-ESLINT-CONFIG.story.md</specification>
4
+ <status>PASSED</status>
5
+ <last_validated>2025-11-16T17:05:16.869Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.396Z</last_modified>
7
+ <evidence>- src/index.ts exports `configs.recommended` and `configs.strict` with the required rule presets (REQ-CONFIG-PRESETS)
8
+ - eslint.config.js is written in ESLint v9 flat‐config format and includes sections for JS, TS, common CJS files, and ignores (REQ-FLAT-CONFIG)
9
+ - valid-story-reference rule schema supports `storyDirectories`, `allowAbsolutePaths`, and `requireStoryExtension` options (REQ-CUSTOMIZABLE-PATHS, REQ-RULE-OPTIONS)
10
+ - CI build and linting pass without errors, demonstrating seamless integration (EXECUTION reports 92%, CODE_QUALITY reports lint/test/type-check OK)
11
+ - docs/config-presets.md and docs/eslint-9-setup-guide.md provide clear setup instructions, examples, and troubleshooting (Documentation acceptance)</evidence>
12
+ <notes>All acceptance criteria for story 002.0-DEV-ESLINT-CONFIG have been met: the plugin provides both recommended and strict presets, follows ESLint v9 flat config best practices, allows rule customization, integrates with JS/TS projects, and includes comprehensive documentation and configuration validation.</notes>
13
+ </traceability>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md</specification>
4
+ <status>FAILED</status>
5
+ <last_validated>2025-11-16T17:03:12.326Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.405Z</last_modified>
7
+ <evidence>Inspection of src/rules/require-story-annotation.ts and src/rules/require-req-annotation.ts shows only FunctionDeclaration nodes are handled (no arrow functions, function expressions, or class methods), there is no support for TypeScript‐specific syntax or parser configuration in RuleTester (only default parser used), and neither rule exposes configuration to scope which functions are checked or to prioritize exported functions. Key requirements REQ-FUNCTION-DETECTION (expressions/arrow functions), REQ-CONFIGURABLE-SCOPE, REQ-EXPORT-PRIORITY, and REQ-TYPESCRIPT-SUPPORT are not implemented.</evidence>
8
+ <notes>While basic function‐level detection and error reporting exist for missing @story and @req, the implementation does not satisfy the full breadth of acceptance criteria and technical requirements outlined in the story. Additional work is needed to support all function patterns, configurability, and TypeScript integration.</notes>
9
+ </traceability>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md</specification>
4
+ <status>FAILED</status>
5
+ <last_validated>2025-11-16T17:03:22.383Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.419Z</last_modified>
7
+ <evidence>In src/rules/require-branch-annotation.ts the rule.meta.schema is an empty array (schema: []), and the documentation (docs/rules/require-branch-annotation.md) explicitly states “This rule does not accept any options.” However, the story’s Requirements include REQ-CONFIGURABLE-SCOPE: “Allow configuration of which branch types require annotations.” There is no code to accept or handle any configuration options for branch scopes, nor any tests for that behavior.</evidence>
8
+ <notes>While the core detection, parsing, and error reporting for branch annotations are implemented and well-tested, the required ability to configure which branch types are enforced is missing. The story is therefore not fully satisfied.</notes>
9
+ </traceability>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md</specification>
4
+ <status>PASSED</status>
5
+ <last_validated>2025-11-16T17:03:32.682Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.431Z</last_modified>
7
+ <evidence>The `valid-annotation-format` rule is present in src/rules/valid-annotation-format.ts with appropriate meta, messages, and schema. Tests in tests/rules/valid-annotation-format.test.ts cover valid and invalid @story and @req formats, including block comments and single-line comments, and all tests pass (100% statements, 100% lines, 92.85% branches). Documentation exists at docs/rules/valid-annotation-format.md with examples matching implementation. The rule is exported in src/index.ts and included in both 'recommended' and 'strict' configs. ESLint linting, Jest testing, type checking, and coverage checks all pass.</evidence>
8
+ <notes>The annotation format validation rule fully meets the story’s acceptance criteria: it validates @story and @req syntax, follows ESLint best practices, integrates with other rules, provides clear error messages, handles edge cases (multiline/block comments), and is documented with examples. Tests ensure REQ-FORMAT-SPECIFICATION, REQ-SYNTAX-VALIDATION, REQ-PATH-FORMAT, REQ-REQ-FORMAT, REQ-MULTILINE-SUPPORT, REQ-FLEXIBLE-PARSING, and REQ-ERROR-SPECIFICITY are satisfied.</notes>
9
+ </traceability>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/006.0-DEV-FILE-VALIDATION.story.md</specification>
4
+ <status>PASSED</status>
5
+ <last_validated>2025-11-16T17:03:17.855Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.445Z</last_modified>
7
+ <evidence>Found src/rules/valid-story-reference.ts with full implementation of REQ-FILE-EXISTENCE, REQ-PATH-RESOLUTION, REQ-SECURITY-VALIDATION, REQ-PERFORMANCE-OPTIMIZATION (caching), REQ-PROJECT-BOUNDARY, and REQ-CONFIGURABLE-PATHS, all annotated with @story docs/stories/006.0-DEV-FILE-VALIDATION.story.md. Corresponding tests in tests/rules/valid-story-reference.test.ts cover valid and invalid scenarios (file exists, extension check, path traversal, absolute paths) and reference the story and requirement IDs. package.json scripts include Jest run, and CI reports 100% passing tests and high coverage.</evidence>
8
+ <notes>The valid-story-reference rule meets all acceptance criteria: core functionality, ESLint best practices, integration with format validation, clear error messages, and documented examples. Tests confirm correct behavior across file system scenarios.</notes>
9
+ </traceability>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/007.0-DEV-ERROR-REPORTING.story.md</specification>
4
+ <status>FAILED</status>
5
+ <last_validated>2025-11-16T17:04:41.461Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.454Z</last_modified>
7
+ <evidence>A review of the rule implementations shows that none of the context.report() calls supply “suggest” fixes or instruction text: for example, require-story-annotation only reports messageId “missingStory” with text “Missing @story annotation” and no suggestion on how to add one. None of the rules use ESLint’s suggest API or include actionable guidance (e.g. “Add @story docs/stories/...”) or dynamic context beyond basic identifiers. The docs/rules markdown do not document full error messages or suggestions, and existing unit and CLI tests only assert that errors fire, not that they carry specific, actionable message text or locations beyond the default. </evidence>
8
+ <notes>The 007.0-DEV-ERROR-REPORTING story calls for clear, actionable error messages including suggested fixes, context and consistent formatting. While basic error reporting exists, there is no implementation of suggestion API, no contextual guidance, and no documentation of full message format. Therefore the story is not satisfied.</notes>
9
+ </traceability>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/008.0-DEV-AUTO-FIX.story.md</specification>
4
+ <status>FAILED</status>
5
+ <last_validated>2025-11-16T17:04:59.379Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.465Z</last_modified>
7
+ <evidence>Assessment error: 400 This model's maximum context length is 200000 tokens. However, your messages resulted in 206091 tokens (204696 in the messages, 1395 in the functions). Please reduce the length of the messages or functions.</evidence>
8
+ <notes>Technical error during assessment</notes>
9
+ </traceability>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md</specification>
4
+ <status>PASSED</status>
5
+ <last_validated>2025-11-16T17:05:08.140Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.476Z</last_modified>
7
+ <evidence>- src/maintenance/detect.ts, update.ts, batch.ts, report.ts, utils.ts implement all six REQ-MAINT-* requirements with JSDoc @story and @req annotations.
8
+ - tests/maintenance/detect.test.ts & detect-isolated.test.ts cover REQ-MAINT-DETECT (detectStaleAnnotations).
9
+ - tests/maintenance/update.test.ts & update-isolated.test.ts cover REQ-MAINT-UPDATE (updateAnnotationReferences).
10
+ - tests/maintenance/batch.test.ts cover REQ-MAINT-BATCH and REQ-MAINT-VERIFY (batchUpdateAnnotations, verifyAnnotations).
11
+ - tests/maintenance/report.test.ts covers REQ-MAINT-REPORT (generateMaintenanceReport) and implicitly REQ-MAINT-SAFE.
12
+ - npm test (Jest) runs all tests with 100% passing, maintaining >96% coverage in maintenance code.
13
+ - Code preserves formatting, handles missing directories, nested structures, permission errors, and writes updates safely.
14
+ </evidence>
15
+ <notes>All acceptance criteria for story 009.0-DEV-MAINTENANCE-TOOLS are satisfied: core functionality, quality standards, integration, UX feedback, error handling, and documentation via JSDoc and test coverage. Maintenance tools are fully implemented and validated by tests.</notes>
16
+ </traceability>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <traceability>
3
+ <specification>docs/stories/010.0-DEV-DEEP-VALIDATION.story.md</specification>
4
+ <status>PASSED</status>
5
+ <last_validated>2025-11-16T17:03:50.351Z</last_validated>
6
+ <last_modified>2025-11-16T00:07:54.487Z</last_modified>
7
+ <evidence>- src/rules/valid-req-reference.ts implements deep validation logic with AST comment parsing, path resolution, caching, regex-based requirement extraction, and reports both invalidPath and reqMissing messages.
8
+ - Tests in tests/rules/valid-req-reference.test.ts cover valid references (including bullet-list fixture), missing requirements, path traversal, and absolute paths, all passing under Jest: exit code 0, coverage report included.
9
+ - Documentation in docs/rules/valid-req-reference.md and docs/stories/010.0-DEV-DEEP-VALIDATION.story.md align, and the plugin builds, lints, type-checks, and tests successfully (npm test shows 96%+ statements, 84%+ branches overall).</evidence>
10
+ <notes>The implementation provides the required core functionality for deep requirement content validation: it parses story files, matches @req IDs, handles path errors, caches content, reports clear errors, and is fully tested. All acceptance criteria are satisfied.</notes>
11
+ </traceability>
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [1.0.0] - 2025-11-16
6
+
7
+ ### Changed
8
+
9
+ - Bumped version to 1.0.0 in package.json.
10
+ - Aligned CHANGELOG with package.json version.
11
+
12
+ ## [0.1.0] - 2025-11-16
13
+
14
+ ### Added
15
+
16
+ - Initial release of `eslint-plugin-traceability`:
17
+ - `require-story-annotation`
18
+ - `require-req-annotation`
19
+ - `require-branch-annotation`
20
+ - `valid-annotation-format`
21
+ - `valid-story-reference`
22
+ - `valid-req-reference`
23
+ - Documentation for all rules under `docs/rules`.
24
+ - Configuration presets in `docs/config-presets.md`.
25
+ - Example usage in `README.md`.
26
+ - Pre-commit and pre-push hooks with formatting, linting, and tests.
27
+ - Comprehensive tests covering core validation rules.
28
+
29
+ ### Fixed
30
+
31
+ - N/A
@@ -0,0 +1,97 @@
1
+ # Contributing to eslint-plugin-traceability
2
+
3
+ Thank you for your interest in contributing to `eslint-plugin-traceability`! We welcome bug reports, feature requests, and pull requests. To ensure a smooth process, please follow the guidelines below.
4
+
5
+ ## Reporting Issues
6
+
7
+ If you encounter a bug or have a feature request:
8
+
9
+ 1. Search existing issues to see if the problem or suggestion has already been reported.
10
+ 2. If not, open a new issue on GitHub: [Issue Tracker](https://github.com/voder-ai/eslint-plugin-traceability/issues).
11
+ 3. Provide a clear and descriptive title, steps to reproduce, expected behavior, and any relevant screenshots or logs.
12
+ 4. Specify your environment:
13
+ - `node` version: `node -v`
14
+ - `eslint` version: `npx eslint -v`
15
+ - Operating system and shell.
16
+
17
+ ## Pull Request Process
18
+
19
+ When submitting a pull request (PR):
20
+
21
+ 1. Fork the repository and create a branch for your changes.
22
+ 2. Commit your changes in small, logical increments. Use descriptive commit messages.
23
+ 3. Ensure all tests pass and the project builds successfully.
24
+ 4. Push your branch to GitHub and open a PR against the `main` branch.
25
+ 5. Reference any related issues in your PR description.
26
+ 6. A maintainer will review your changes and may request updates or approve the PR.
27
+
28
+ ## Commit Message Conventions
29
+
30
+ We follow [Conventional Commits](https://www.conventionalcommits.org/) format. Commit messages should be structured as:
31
+
32
+ ```
33
+ tag: short description
34
+
35
+ optional body explaining why the change was made
36
+
37
+ optional footer (e.g., BREAKING CHANGE: ...)
38
+ ```
39
+
40
+ Common commit types:
41
+
42
+ - `feat:` A new feature
43
+ - `fix:` A bug fix
44
+ - `docs:` Documentation only changes
45
+ - `style:` Code style changes (formatting, linting)
46
+ - `refactor:` Code changes that neither fix a bug nor add a feature
47
+ - `perf:` Performance improvements
48
+ - `test:` Adding or updating tests
49
+ - `chore:` Other changes that do not modify src or test files
50
+
51
+ ## Coding Style and Quality Checks
52
+
53
+ We enforce code style and quality using ESLint, Prettier, TypeScript, and other tools. Please run the following commands before submitting your PR:
54
+
55
+ ```bash
56
+ # Build the project and generate types
57
+ npm run build
58
+
59
+ # Run TypeScript type checks
60
+ npm run type-check
61
+
62
+ # Lint code
63
+ npm run lint
64
+
65
+ # Run tests
66
+ npm test
67
+
68
+ # Check formatting (no changes)
69
+ npm run format:check
70
+
71
+ # Check duplication threshold
72
+ npm run duplication
73
+ ```
74
+
75
+ Ensure there are no errors or warnings in the output.
76
+
77
+ ## Developing Locally
78
+
79
+ 1. Clone your fork and install dependencies:
80
+
81
+ ```bash
82
+ git clone https://github.com/<your-username>/eslint-plugin-traceability.git
83
+ cd eslint-plugin-traceability
84
+ npm install
85
+ ```
86
+
87
+ ````
88
+
89
+ 2. Run the tests in watch mode:
90
+
91
+ ```bash
92
+ npm test
93
+ ````
94
+
95
+ 3. Make your changes, and verify that tests and linting continue to pass.
96
+
97
+ Thank you for helping improve `eslint-plugin-traceability`!
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 voder.ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # eslint-plugin-traceability
2
+
3
+ A customizable ESLint plugin that enforces traceability annotations in your code, ensuring each implementation is linked to its requirement or test case.
4
+
5
+ ## Attribution
6
+
7
+ Created autonomously by [voder.ai](https://voder.ai).
8
+
9
+ ## Installation
10
+
11
+ Prerequisites: Node.js v12+ and ESLint v9+.
12
+
13
+ 1. Using npm
14
+ npm install --save-dev eslint-plugin-traceability
15
+ 2. Using Yarn
16
+ yarn add --dev eslint-plugin-traceability
17
+
18
+ For detailed setup with ESLint v9, see docs/eslint-9-setup-guide.md.
19
+
20
+ ## Usage
21
+
22
+ Add the plugin to your ESLint configuration and enable the rules.
23
+
24
+ Example eslint.config.js (ESLint v9 flat config):
25
+
26
+ ```js
27
+ // eslint.config.js
28
+ module.exports = [
29
+ {
30
+ env: {
31
+ es2021: true,
32
+ node: true,
33
+ },
34
+ plugins: { traceability: {} },
35
+ rules: {
36
+ "traceability/require-story-annotation": "error",
37
+ "traceability/require-req-annotation": "error",
38
+ "traceability/require-branch-annotation": "error",
39
+ },
40
+ },
41
+ ];
42
+ ```
43
+
44
+ ### Available Rules
45
+
46
+ - `traceability/require-story-annotation` Enforces presence of `@story` annotations. ([Documentation](docs/rules/require-story-annotation.md))
47
+ - `traceability/require-req-annotation` Enforces presence of `@req` annotations. ([Documentation](docs/rules/require-req-annotation.md))
48
+ - `traceability/require-branch-annotation` Enforces presence of branch annotations. ([Documentation](docs/rules/require-branch-annotation.md))
49
+ - `traceability/valid-annotation-format` Enforces correct format of traceability annotations. ([Documentation](docs/rules/valid-annotation-format.md))
50
+ - `traceability/valid-story-reference` Validates that `@story` references point to existing story files. ([Documentation](docs/rules/valid-story-reference.md))
51
+ - `traceability/valid-req-reference` Validates that `@req` references point to existing requirement IDs. ([Documentation](docs/rules/valid-req-reference.md))
52
+
53
+ For development and contribution guidelines, see docs/eslint-plugin-development-guide.md.
54
+
55
+ ## Quick Start
56
+
57
+ 1. Create a flat ESLint config file (`eslint.config.js`):
58
+
59
+ ```javascript
60
+ // eslint.config.js
61
+ import traceability from "eslint-plugin-traceability";
62
+
63
+ export default [
64
+ // Load the traceability plugin's recommended rule set
65
+ traceability.configs.recommended,
66
+ ];
67
+ ```
68
+
69
+ 2. Annotate your functions or modules:
70
+
71
+ ```js
72
+ /**
73
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
74
+ * @req REQ-ANNOTATION-REQUIRED
75
+ */
76
+ function initAuth() {
77
+ // implementation...
78
+ }
79
+ ```
80
+
81
+ 3. Run ESLint:
82
+
83
+ ```bash
84
+ npx eslint "src/**/*.js"
85
+ ```
86
+
87
+ ## API Reference
88
+
89
+ Detailed API specification and configuration options can be found in the [API Reference](user-docs/api-reference.md).
90
+
91
+ ## Examples
92
+
93
+ Practical usage examples and sample configurations are available in the [Examples](user-docs/examples.md) document.
94
+
95
+ ## Plugin Validation
96
+
97
+ You can validate the plugin by running ESLint CLI with the plugin on a sample file:
98
+
99
+ ```bash
100
+ # Validate missing @story annotation (should report an error)
101
+ npx eslint --no-eslintrc --config eslint.config.js sample.js --rule 'traceability/require-story-annotation:error'
102
+ ```
103
+
104
+ This command runs ESLint with the plugin, pointing at `eslint.config.js` flat config.
105
+
106
+ Replace `sample.js` with your JavaScript or TypeScript file.
107
+
108
+ ## Running Tests
109
+
110
+ You can run tests and quality checks locally using the npm scripts provided:
111
+
112
+ ```bash
113
+ # Run all tests with coverage
114
+ npm test
115
+
116
+ # Run linting with zero tolerance for warnings
117
+ npm run lint -- --max-warnings=0
118
+
119
+ # Check code formatting
120
+ npm run format:check
121
+
122
+ # Check duplication threshold
123
+ npm run duplication
124
+ ```
125
+
126
+ Coverage reports will be generated in the `coverage/` directory.
127
+
128
+ ## CLI Integration
129
+
130
+ The `cli-integration.js` script runs end-to-end CLI integration tests for the plugin, verifying behavior when used via the ESLint CLI.
131
+
132
+ Usage:
133
+
134
+ ```bash
135
+ # Run the CLI integration tests
136
+ node cli-integration.js
137
+ ```
138
+
139
+ This script executes tests that:
140
+
141
+ - Report an error when the `@story` annotation is missing.
142
+ - Do not report an error when the `@story` annotation is present.
143
+
144
+ The CLI integration tests are also executed automatically in CI under the `integration-tests` job.
145
+
146
+ ## Documentation Links
147
+
148
+ - ESLint v9 Setup Guide: docs/eslint-9-setup-guide.md
149
+ - Plugin Development Guide: docs/eslint-plugin-development-guide.md
150
+ - API Reference: user-docs/api-reference.md
151
+ - Examples: user-docs/examples.md
152
+ - Full README: https://github.com/voder-ai/eslint-plugin-traceability#readme
153
+ - Rule: require-story-annotation: docs/rules/require-story-annotation.md
154
+ - Rule: require-req-annotation: docs/rules/require-req-annotation.md
155
+ - Rule: require-branch-annotation: docs/rules/require-branch-annotation.md
156
+ - Contribution guide: https://github.com/voder-ai/eslint-plugin-traceability/blob/main/CONTRIBUTING.md
157
+ - Issue tracker: https://github.com/voder-ai/eslint-plugin-traceability/issues
158
+ - Configuration Presets: docs/config-presets.md
159
+ - Changelog: CHANGELOG.md
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-env node */
3
+ /**
4
+ * CLI integration tests for ESLint Traceability Plugin
5
+ * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
6
+ * @req REQ-PLUGIN-STRUCTURE - Validate plugin registers via CLI
7
+ */
8
+ const { spawnSync } = require("child_process");
9
+ const path = require("path");
10
+ const configPath = path.resolve(__dirname, "eslint.config.js");
11
+
12
+ /**
13
+ * Helper to execute ESLint CLI integration tests for the traceability plugin
14
+ * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
15
+ * @req REQ-PLUGIN-STRUCTURE - Utility for invoking ESLint with flat config in integration tests
16
+ */
17
+ function runEslint(code, rule) {
18
+ const eslintPkgDir = path.dirname(require.resolve("eslint/package.json"));
19
+ const eslintCliPath = path.join(eslintPkgDir, "bin", "eslint.js");
20
+ const args = [
21
+ "--no-config-lookup",
22
+ "--config",
23
+ configPath,
24
+ "--stdin",
25
+ "--stdin-filename",
26
+ "foo.js",
27
+ "--rule",
28
+ "no-unused-vars:off",
29
+ "--rule",
30
+ "no-constant-condition:off",
31
+ "--rule",
32
+ "no-empty:off",
33
+ "--rule",
34
+ "traceability/require-story-annotation:off",
35
+ "--rule",
36
+ "traceability/require-req-annotation:off",
37
+ "--rule",
38
+ "traceability/require-branch-annotation:off",
39
+ "--rule",
40
+ "traceability/valid-annotation-format:off",
41
+ "--rule",
42
+ "traceability/valid-story-reference:off",
43
+ "--rule",
44
+ "traceability/valid-req-reference:off",
45
+ "--rule",
46
+ rule,
47
+ ];
48
+ return spawnSync(process.execPath, [eslintCliPath, ...args], {
49
+ encoding: "utf-8",
50
+ input: code,
51
+ });
52
+ }
53
+
54
+ const tests = [
55
+ {
56
+ name: "reports error when @story annotation is missing",
57
+ code: "function foo() {}",
58
+ rule: "traceability/require-story-annotation:error",
59
+ expectedStatus: 1,
60
+ },
61
+ {
62
+ name: "does not report error when @story annotation is present",
63
+ code: `
64
+ /**
65
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
66
+ */
67
+ function foo() {}
68
+ `,
69
+ rule: "traceability/require-story-annotation:error",
70
+ expectedStatus: 0,
71
+ },
72
+ {
73
+ name: "reports error when requirement reference is missing",
74
+ code: `/**\n * @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md\n * @req REQ-NON-EXISTENT\n */\nfunction foo() {}`,
75
+ rule: "traceability/valid-req-reference:error",
76
+ expectedStatus: 1,
77
+ },
78
+ {
79
+ name: "reports error when requirement reference uses path traversal",
80
+ code: `/**\n * @story ../docs/stories/001.0-DEV-PLUGIN-SETUP.story.md\n * @req REQ-PLUGIN-STRUCTURE\n */\nfunction foo() {}`,
81
+ rule: "traceability/valid-req-reference:error",
82
+ expectedStatus: 1,
83
+ },
84
+ {
85
+ name: "reports error when requirement reference uses absolute path",
86
+ code: `/**\n * @story /absolute/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md\n * @req REQ-PLUGIN-STRUCTURE\n */\nfunction foo() {}`,
87
+ rule: "traceability/valid-req-reference:error",
88
+ expectedStatus: 1,
89
+ },
90
+ {
91
+ name: "reports error when @req annotation is missing",
92
+ code: `/**
93
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
94
+ */\nfunction foo() {}`,
95
+ rule: "traceability/require-req-annotation:error",
96
+ expectedStatus: 1,
97
+ },
98
+ {
99
+ name: "does not report error when @req annotation is present",
100
+ code: `/**
101
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
102
+ * @req REQ-ANNOTATION-REQUIRED
103
+ */\nfunction foo() {}`,
104
+ rule: "traceability/require-req-annotation:error",
105
+ expectedStatus: 0,
106
+ },
107
+ {
108
+ name: "reports error for missing branch annotations",
109
+ code: `if (true) {}`,
110
+ rule: "traceability/require-branch-annotation:error",
111
+ expectedStatus: 1,
112
+ },
113
+ {
114
+ name: "does not report error for branch with annotations",
115
+ code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md\n// @req REQ-BRANCH-DETECTION\nif (true) {}`,
116
+ rule: "traceability/require-branch-annotation:error",
117
+ expectedStatus: 0,
118
+ },
119
+ {
120
+ name: "reports invalid annotation format",
121
+ code: `/**\n * @story invalid/path.txt\n * @req INVALID\n */\nfunction foo() {}`,
122
+ rule: "traceability/valid-annotation-format:error",
123
+ expectedStatus: 1,
124
+ },
125
+ {
126
+ name: "valid annotation format passes",
127
+ code: `/**\n * @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md\n * @req REQ-FORMAT-SPECIFICATION\n */\nfunction foo() {}`,
128
+ rule: "traceability/valid-annotation-format:error",
129
+ expectedStatus: 0,
130
+ },
131
+ {
132
+ name: "reports missing story file reference",
133
+ code: `/**\n * @story docs/stories/nonexistent.story.md\n */\nfunction foo() {}`,
134
+ rule: "traceability/valid-story-reference:error",
135
+ expectedStatus: 1,
136
+ },
137
+ {
138
+ name: "existing story file reference passes",
139
+ code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction foo() {}`,
140
+ rule: "traceability/valid-story-reference:error",
141
+ expectedStatus: 0,
142
+ },
143
+ ];
144
+
145
+ let exitCode = 0;
146
+ tests.forEach(({ name, code, rule, expectedStatus }) => {
147
+ const result = runEslint(code, rule);
148
+ if (result.status !== expectedStatus) {
149
+ console.error(
150
+ `Test "${name}" failed. Expected status ${expectedStatus}, got ${result.status}.`,
151
+ );
152
+ console.error("stdout:", result.stdout);
153
+ exitCode = 1;
154
+ }
155
+ });
156
+
157
+ process.exit(exitCode);