eslint-plugin-traceability 1.8.0 → 1.8.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +5 -5
  2. package/README.md +28 -29
  3. package/SECURITY.md +135 -0
  4. package/lib/src/index.d.ts +6 -35
  5. package/lib/src/index.js +8 -5
  6. package/lib/src/maintenance/cli.js +12 -16
  7. package/lib/src/maintenance/detect.js +28 -1
  8. package/lib/src/rules/helpers/require-story-io.d.ts +2 -2
  9. package/lib/src/rules/helpers/require-story-io.js +13 -13
  10. package/lib/src/rules/helpers/valid-annotation-format-internal.d.ts +2 -2
  11. package/lib/src/rules/helpers/valid-annotation-format-internal.js +3 -3
  12. package/lib/src/rules/helpers/valid-annotation-utils.d.ts +5 -0
  13. package/lib/src/rules/helpers/valid-annotation-utils.js +43 -5
  14. package/lib/src/rules/helpers/valid-implements-utils.d.ts +11 -11
  15. package/lib/src/rules/helpers/valid-implements-utils.js +11 -11
  16. package/lib/src/rules/helpers/valid-story-reference-helpers.js +19 -0
  17. package/lib/src/rules/prefer-implements-annotation.d.ts +7 -7
  18. package/lib/src/rules/prefer-implements-annotation.js +21 -21
  19. package/lib/src/rules/valid-annotation-format.js +50 -24
  20. package/lib/src/rules/valid-req-reference.js +9 -9
  21. package/lib/src/utils/annotation-checker.js +3 -1
  22. package/lib/src/utils/reqAnnotationDetection.d.ts +2 -2
  23. package/lib/src/utils/reqAnnotationDetection.js +28 -28
  24. package/lib/tests/config/flat-config-presets-integration.test.d.ts +1 -0
  25. package/lib/tests/config/flat-config-presets-integration.test.js +75 -0
  26. package/lib/tests/maintenance/batch.test.js +11 -11
  27. package/lib/tests/maintenance/cli.test.js +34 -27
  28. package/lib/tests/maintenance/report.test.js +7 -7
  29. package/lib/tests/plugin-default-export-and-configs.test.js +0 -2
  30. package/lib/tests/rules/prefer-implements-annotation.test.js +48 -15
  31. package/lib/tests/rules/require-branch-annotation.test.js +15 -36
  32. package/lib/tests/rules/require-req-annotation.test.js +31 -104
  33. package/lib/tests/rules/require-story-annotation.test.js +3 -3
  34. package/lib/tests/rules/require-story-io-behavior.test.js +2 -7
  35. package/lib/tests/rules/require-story-io.edgecases.test.js +2 -7
  36. package/lib/tests/rules/require-story-visitors-edgecases.test.js +8 -8
  37. package/lib/tests/rules/valid-annotation-format.test.js +23 -23
  38. package/lib/tests/rules/valid-req-reference.test.js +9 -9
  39. package/lib/tests/rules/valid-story-reference.test.js +4 -43
  40. package/lib/tests/utils/annotation-checker.test.js +2 -6
  41. package/lib/tests/utils/fsTestHelpers.d.ts +7 -0
  42. package/lib/tests/utils/fsTestHelpers.js +26 -0
  43. package/lib/tests/utils/ioTestHelpers.d.ts +7 -0
  44. package/lib/tests/utils/ioTestHelpers.js +24 -0
  45. package/lib/tests/utils/temp-dir-helpers.d.ts +14 -0
  46. package/lib/tests/utils/temp-dir-helpers.js +61 -0
  47. package/package.json +8 -7
  48. package/user-docs/api-reference.md +37 -20
  49. package/user-docs/eslint-9-setup-guide.md +89 -6
  50. package/user-docs/migration-guide.md +37 -21
  51. package/docs/ci-cd-pipeline.md +0 -224
  52. package/docs/cli-integration.md +0 -22
  53. package/docs/code-quality-refactor-opportunities-2025-12-03.md +0 -78
  54. package/docs/config-presets.md +0 -38
  55. package/docs/conventional-commits-guide.md +0 -185
  56. package/docs/custom-rules-development-guide.md +0 -659
  57. package/docs/decisions/0001-allow-dynamic-require-for-built-plugins.md +0 -26
  58. package/docs/decisions/001-typescript-for-eslint-plugin.accepted.md +0 -111
  59. package/docs/decisions/002-jest-for-eslint-testing.accepted.md +0 -137
  60. package/docs/decisions/003-code-quality-ratcheting-plan.md +0 -48
  61. package/docs/decisions/004-automated-version-bumping-for-ci-cd.md +0 -196
  62. package/docs/decisions/005-github-actions-validation-tooling.accepted.md +0 -144
  63. package/docs/decisions/006-semantic-release-for-automated-publishing.accepted.md +0 -227
  64. package/docs/decisions/007-github-releases-over-changelog.accepted.md +0 -216
  65. package/docs/decisions/008-ci-audit-flags.accepted.md +0 -60
  66. package/docs/decisions/009-security-focused-lint-rules.accepted.md +0 -64
  67. package/docs/decisions/010-implements-annotation-for-multi-story-requirements.proposed.md +0 -184
  68. package/docs/decisions/adr-0001-console-usage-for-cli-guards.md +0 -190
  69. package/docs/decisions/adr-accept-dev-dep-risk-glob.md +0 -40
  70. package/docs/decisions/adr-commit-branch-tests.md +0 -54
  71. package/docs/decisions/adr-maintenance-cli-interface.md +0 -140
  72. package/docs/decisions/adr-pre-push-parity.md +0 -112
  73. package/docs/decisions/code-quality-ratcheting-plan.md +0 -53
  74. package/docs/dependency-health.md +0 -238
  75. package/docs/eslint-9-setup-guide.md +0 -517
  76. package/docs/eslint-plugin-development-guide.md +0 -487
  77. package/docs/functionality-coverage-2025-12-03.md +0 -250
  78. package/docs/jest-testing-guide.md +0 -100
  79. package/docs/rules/prefer-implements-annotation.md +0 -219
  80. package/docs/rules/require-branch-annotation.md +0 -71
  81. package/docs/rules/require-req-annotation.md +0 -203
  82. package/docs/rules/require-story-annotation.md +0 -159
  83. package/docs/rules/valid-annotation-format.md +0 -418
  84. package/docs/rules/valid-req-reference.md +0 -153
  85. package/docs/rules/valid-story-reference.md +0 -120
  86. package/docs/security-incidents/2025-11-17-glob-cli-incident.md +0 -45
  87. package/docs/security-incidents/2025-11-18-brace-expansion-redos.md +0 -45
  88. package/docs/security-incidents/2025-11-18-bundled-dev-deps-accepted-risk.md +0 -93
  89. package/docs/security-incidents/2025-11-18-tar-race-condition.md +0 -43
  90. package/docs/security-incidents/2025-12-03-dependency-health-review.md +0 -58
  91. package/docs/security-incidents/SECURITY-INCIDENT-2025-11-18-semantic-release-bundled-npm.known-error.md +0 -104
  92. package/docs/security-incidents/SECURITY-INCIDENT-TEMPLATE.md +0 -37
  93. package/docs/security-incidents/dependency-override-rationale.md +0 -57
  94. package/docs/security-incidents/dev-deps-high.json +0 -116
  95. package/docs/security-incidents/handling-procedure.md +0 -54
  96. package/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md +0 -92
  97. package/docs/stories/002.0-DEV-ESLINT-CONFIG.story.md +0 -82
  98. package/docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md +0 -112
  99. package/docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md +0 -153
  100. package/docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md +0 -138
  101. package/docs/stories/006.0-DEV-FILE-VALIDATION.story.md +0 -144
  102. package/docs/stories/007.0-DEV-ERROR-REPORTING.story.md +0 -163
  103. package/docs/stories/008.0-DEV-AUTO-FIX.story.md +0 -150
  104. package/docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md +0 -117
  105. package/docs/stories/010.0-DEV-DEEP-VALIDATION.story.md +0 -124
  106. package/docs/stories/010.1-DEV-CONFIGURABLE-PATTERNS.story.md +0 -149
  107. package/docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md +0 -216
  108. package/docs/stories/010.3-DEV-MIGRATE-TO-IMPLEMENTS.story.md +0 -236
  109. package/docs/stories/developer-story.map.md +0 -120
  110. package/docs/ts-jest-presets-guide.md +0 -548
@@ -1,124 +0,0 @@
1
- # 010.0-DEV-DEEP-VALIDATION: Requirement Content Validation
2
-
3
- ## Release Goal
4
-
5
- **Release 0.1: Core Validation** - Provide essential ESLint rules that enforce @story and @req annotations on functions and code branches, with validation that referenced files exist and contain the referenced requirements.
6
-
7
- This story completes the validation framework by ensuring that @req annotations not only point to existing story files, but that the referenced requirements actually exist within those files. This provides complete end-to-end traceability validation from code annotations to actual requirement content.
8
-
9
- ## How This Story Contributes
10
-
11
- While basic file validation (006.0) ensures story files exist, deep validation goes further to verify that the specific requirements referenced in @req annotations are actually present in the story files. This prevents broken traceability links where annotations point to valid files but non-existent requirements, ensuring the traceability system maintains integrity as requirements evolve.
12
-
13
- This story completes the "Maintain Quality" journey phase and Release 0.1 by providing the most comprehensive validation possible, ensuring annotations remain meaningful and accurate.
14
-
15
- ## User Story
16
-
17
- **Format**: So that I can trust that @req annotations point to actual requirements and not just valid files, as a Developer, I want the ESLint plugin to validate that referenced requirements exist within the target story files.
18
-
19
- **INVEST Criteria Compliance**:
20
-
21
- - **Independent**: Can be developed using existing file validation and annotation parsing logic
22
- - **Negotiable**: The specific requirement matching strategies and formats can be refined during implementation
23
- - **Valuable**: Delivers clear value by ensuring annotation accuracy and preventing broken traceability
24
- - **Estimable**: Scope is well-defined - parse story files to validate requirement existence
25
- - **Small**: Focused on requirement content validation rather than broader file analysis
26
- - **Testable**: Requirement validation can be verified through story file parsing and matching tests
27
-
28
- ## Acceptance Criteria
29
-
30
- - [x] **Core Functionality**: Plugin validates that @req annotations reference requirements that actually exist in the target story files
31
- - [ ] **Quality Standards**: Validation handles various requirement formats and story file structures
32
- - [ ] **Integration**: Works with existing file validation and annotation parsing logic
33
- - [x] **User Experience**: Provides clear error messages when requirements are not found in story files
34
- - [ ] **Error Handling**: Gracefully handles malformed story files, missing sections, or parsing errors
35
- - [ ] **Documentation**: Requirement validation behavior is documented with examples of supported formats
36
-
37
- ## Requirements (Current Implementation or To Be Implemented)
38
-
39
- - **REQ-DEEP-PARSE**: Parse story file content to identify available requirements
40
- - **REQ-DEEP-MATCH**: Match @req annotation references against actual requirements in story files
41
- - **REQ-DEEP-FORMAT**: Support multiple requirement formats (REQ-XXX-YYY, bullet points, numbered lists)
42
- - **REQ-DEEP-SECTION**: Handle requirements in different story file sections (Requirements, Acceptance Criteria, etc.)
43
- - **REQ-DEEP-CACHE**: Cache parsed story file content to avoid re-parsing on every validation
44
- - **REQ-DEEP-ERROR**: Provide specific error messages when requirements are not found in story files
45
-
46
- ## Dependencies
47
-
48
- - 005.0-DEV-ANNOTATION-VALIDATION (deep validation needs annotation format parsing)
49
- - 006.0-DEV-FILE-VALIDATION (deep validation builds on file existence validation)
50
- - 007.0-DEV-ERROR-REPORTING (deep validation needs clear error reporting for requirement mismatches)
51
-
52
- **Dependency Rules**:
53
-
54
- - Story numbers MUST be greater than all dependency story numbers
55
- - Dependencies should be from in-scope stories when possible
56
- - Cross-release dependencies should be clearly justified
57
- - No circular dependencies allowed
58
-
59
- ## Implementation Notes (Optional)
60
-
61
- **Development Resources**:
62
-
63
- - See [Custom ESLint Rules Development Guide](../custom-rules-development-guide.md) for implementation patterns
64
- - Review [The Context Object](../custom-rules-development-guide.md#the-context-object) for accessing file information
65
- - See [Best Practices](../custom-rules-development-guide.md#best-practices) for performance optimization
66
-
67
- **Technical Considerations**:
68
-
69
- - Implement robust markdown parsing to extract requirements from story files
70
- - Support multiple requirement identification patterns (REQ-XXX-YYY, numbered bullets, etc.)
71
- - Consider performance implications of parsing story files during linting
72
- - Provide caching mechanisms to avoid repeated file parsing (cache at plugin level, not per rule execution)
73
- - Use lazy loading - only parse story files when their requirements are referenced
74
- - Store parsed requirement data with file modification timestamps for cache invalidation
75
-
76
- **Key Guide Sections**:
77
-
78
- - [The Context Object](../custom-rules-development-guide.md#the-context-object) - Using context.cwd and context.filename
79
- - [Best Practices](../custom-rules-development-guide.md#best-practices) - Performance and caching strategies
80
- - [Reporting Problems](../custom-rules-development-guide.md#reporting-problems) - Clear error messages for missing requirements
81
-
82
- **Integration Points**:
83
-
84
- - Extend existing file validation logic to include content parsing
85
- - Integrate with annotation parsing to extract requirement references
86
- - Work with error reporting system to provide detailed mismatch information
87
- - Support various story file formats and structures
88
-
89
- **Requirement Identification Strategies**:
90
-
91
- - **Explicit Requirements**: Lines starting with "REQ-" or "\*\*REQ-"
92
- - **Acceptance Criteria**: Checkbox items in acceptance criteria sections
93
- - **Numbered Requirements**: Numbered list items in requirements sections
94
- - **Custom Patterns**: Configurable regex patterns for project-specific formats
95
-
96
- **Content Parsing Approach**:
97
-
98
- - Parse markdown structure to identify sections
99
- - Extract requirement identifiers using multiple strategies
100
- - Build searchable index of requirements per story file
101
- - Cache parsing results with file modification time tracking
102
-
103
- **Performance Considerations**:
104
-
105
- - Parse story files only when @req annotations reference them
106
- - Cache parsed content with file modification timestamps
107
- - Use incremental parsing for large story files
108
- - Provide configuration options to disable deep validation for performance
109
-
110
- **Testing Strategy**:
111
-
112
- - Unit tests for markdown parsing with various story file formats
113
- - Integration tests with real story files and annotation patterns
114
- - Performance tests with large story files and many annotations
115
- - Edge case testing with malformed markdown and unusual requirement formats
116
-
117
- ## Definition of Done
118
-
119
- - [ ] All acceptance criteria met
120
- - [ ] Code reviewed and approved
121
- - [ ] Tests written and passing
122
- - [ ] Documentation updated
123
- - [ ] Deployed to appropriate environment
124
- - [ ] Stakeholder acceptance confirmed
@@ -1,149 +0,0 @@
1
- # 010.1-DEV-CONFIGURABLE-PATTERNS: Configurable Annotation Format Patterns
2
-
3
- ## Release Goal
4
-
5
- _Release 0.1 Enhancement: Enable plugin adoption for projects with established documentation structures and naming conventions_
6
-
7
- This story extends the annotation format validation to support configurable patterns for story paths and requirement identifiers. It removes adoption barriers by allowing projects to customize validation patterns while maintaining format validation integrity.
8
-
9
- ## How This Story Contributes
10
-
11
- This story enhances the "Setup Plugin" journey phase by enabling teams to integrate the plugin without restructuring their existing documentation. It provides configuration flexibility that respects diverse project conventions while maintaining the validation benefits of format checking.
12
-
13
- ## User Story
14
-
15
- **Format**: So that I can use the traceability plugin without restructuring my existing documentation, as a Developer or Team Lead, I want to configure custom patterns for @story paths and @req identifiers that match my project's established conventions.
16
-
17
- **INVEST Criteria Compliance**:
18
-
19
- - **Independent**: Can be developed after core format validation (depends on 005.0)
20
- - **Negotiable**: Pattern configuration approach and validation strictness can be refined
21
- - **Valuable**: Removes adoption barriers for projects with established conventions
22
- - **Estimable**: Scope is clear - add configuration options to existing validation rule
23
- - **Small**: Can be completed within a single iteration/sprint
24
- - **Testable**: Configuration and pattern validation can be thoroughly tested
25
-
26
- ## Acceptance Criteria
27
-
28
- Use checkbox format for clear completion tracking:
29
-
30
- - [x] **Core Functionality**: Add `storyPathPattern` and `requirementIdPattern` options to `valid-annotation-format` rule
31
- - [x] **Backward Compatibility**: Default to current hardcoded patterns when `storyPathPattern` and `requirementIdPattern` options are not configured
32
- - [x] **Pattern Validation**: Validate that custom `storyPathPattern` and `requirementIdPattern` values are valid regular expressions
33
- - [x] **Error Messages**: Support optional `storyPathExample` and `requirementIdExample` strings for better error messages with custom patterns
34
- - [x] **Quality Standards**: Follows ESLint rule schema and configuration best practices for `storyPathPattern`, `requirementIdPattern`, `storyPathExample`, and `requirementIdExample`
35
- - [x] **Integration**: Works seamlessly with existing `valid-story-reference` rule configuration (including `storyDirectories`)
36
- - [x] **Documentation**: Clear examples of custom pattern configuration for different use cases using `storyPathPattern`, `requirementIdPattern`, `storyPathExample`, and `requirementIdExample`
37
-
38
- ## Requirements (Current Implementation or To Be Implemented)
39
-
40
- Document specific technical requirements using the format:
41
-
42
- - **REQ-PATTERN-CONFIG**: Support configuration of custom story path and requirement ID patterns
43
- - **REQ-REGEX-VALIDATION**: Validate that configured patterns are valid regular expressions
44
- - **REQ-BACKWARD-COMPAT**: Maintain current behavior when no custom patterns configured
45
- - **REQ-EXAMPLE-MESSAGES**: Support optional example strings in error messages
46
- - **REQ-SCHEMA-VALIDATION**: Use JSON Schema to validate configuration options
47
- - **REQ-CONSISTENCY**: Align with `storyDirectories` configuration in `valid-story-reference` rule
48
- - **REQ-PATTERN-TESTING**: Provide test utilities for validating custom patterns
49
-
50
- ## Dependencies
51
-
52
- List other stories this story depends on, using numbered story references:
53
-
54
- - 001.0-DEV-PLUGIN-SETUP (requires plugin structure foundation)
55
- - 002.0-DEV-ESLINT-CONFIG (requires configuration system)
56
- - 005.0-DEV-ANNOTATION-VALIDATION (extends format validation patterns)
57
-
58
- **Dependency Rules**:
59
-
60
- - Story numbers MUST be greater than all dependency story numbers
61
- - Dependencies should be from in-scope stories when possible
62
- - Cross-release dependencies should be clearly justified
63
- - No circular dependencies allowed
64
-
65
- ## Implementation Notes (Optional)
66
-
67
- Additional context for developers:
68
-
69
- **Development Resources**:
70
-
71
- - See [Rule Options and Schema](../custom-rules-development-guide.md#rule-options-and-schema) for configuration patterns
72
- - Review existing `valid-story-reference` rule for `storyDirectories` configuration approach
73
- - See [Testing Guide](../jest-testing-guide.md) for configuration testing patterns
74
-
75
- **Implementation Details**:
76
-
77
- - Add schema properties to `valid-annotation-format` rule meta
78
- - Extract hardcoded patterns to configurable options with defaults
79
- - Validate regex patterns at configuration time with clear error messages
80
- - Support both string patterns (converted to regex) and regex patterns
81
- - Coordinate with `storyDirectories` configuration for consistency
82
- - Update error message templates to use configured examples when provided
83
- - Ensure auto-fix behavior respects custom patterns
84
-
85
- **Configuration Schema**:
86
-
87
- ```typescript
88
- interface RuleOptions {
89
- storyPathPattern?: string; // Regex pattern for story paths
90
- requirementIdPattern?: string; // Regex pattern for requirement IDs
91
- storyPathExample?: string; // Example for error messages
92
- requirementIdExample?: string; // Example for error messages
93
- }
94
- ```
95
-
96
- **Use Case Examples**:
97
-
98
- Different directory structure:
99
-
100
- ```javascript
101
- {
102
- "traceability/valid-annotation-format": ["warn", {
103
- "storyPathPattern": "^prompts/[0-9]+\\.[0-9]+-DEV-[\\w-]+\\.md$",
104
- "storyPathExample": "prompts/005.0-DEV-EXAMPLE.md"
105
- }]
106
- }
107
- ```
108
-
109
- Different requirement prefix:
110
-
111
- ```javascript
112
- {
113
- "traceability/valid-annotation-format": ["warn", {
114
- "requirementIdPattern": "^(REQ|SPEC|FR)-[A-Z0-9-]+$",
115
- "requirementIdExample": "SPEC-EXAMPLE or REQ-EXAMPLE"
116
- }]
117
- }
118
- ```
119
-
120
- Custom story file format:
121
-
122
- ```javascript
123
- {
124
- "traceability/valid-annotation-format": ["warn", {
125
- "storyPathPattern": "^specifications/[A-Z]+-[0-9]+\\.markdown$",
126
- "storyPathExample": "specifications/FEAT-123.markdown"
127
- }]
128
- }
129
- ```
130
-
131
- **Edge Cases to Handle**:
132
-
133
- - Invalid regex patterns in configuration
134
- - Empty or whitespace-only patterns
135
- - Patterns that would never match valid annotations
136
- - Interaction with auto-fix behavior
137
- - Error message clarity when using custom examples
138
-
139
- ## Definition of Done
140
-
141
- - [ ] All acceptance criteria met
142
- - [ ] Code reviewed and approved
143
- - [x] Tests written and passing (custom pattern configuration, validation, error messages)
144
- - [x] Documentation updated (configuration examples, migration guide for custom patterns)
145
- - [ ] Schema validation tested with invalid configurations
146
- - [ ] Integration tested with `valid-story-reference` configuration
147
- - [ ] GitHub issue #1 resolved and closed
148
-
149
- ---
@@ -1,216 +0,0 @@
1
- # 010.2-DEV-MULTI-STORY-SUPPORT: Multi-Story Requirements with @implements
2
-
3
- ## Release Goal
4
-
5
- _Release 0.1 Enhancement: Enable traceability validation for integration functions that implement requirements from multiple stories_
6
-
7
- This story introduces the `@implements` annotation to support functions that combine functionality from multiple stories, addressing the limitation where integration code cannot properly reference requirements from different source stories. This removes false-positive linting errors and enables complete traceability for real-world codebases.
8
-
9
- ## How This Story Contributes
10
-
11
- This story enhances the "Write Code" journey phase by enabling proper annotation of integration functions that naturally combine multiple stories. It removes the forced choice between suppressing linting errors or losing traceability information, ensuring validation works correctly for both simple single-story functions and complex multi-story integration code.
12
-
13
- ## User Story
14
-
15
- **Format**: So that I can properly trace integration functions that combine multiple stories without linting errors, as a Developer, I want to use `@implements` annotations that explicitly map requirements to their source stories.
16
-
17
- **INVEST Criteria Compliance**:
18
-
19
- - **Independent**: Can be developed after requirement validation (depends on 010.0)
20
- - **Negotiable**: Annotation format and validation behavior can be refined during implementation
21
- - **Valuable**: Enables traceability validation for integration code (currently blocked by false positives)
22
- - **Estimable**: Scope is clear - add new annotation parser and extend validation logic
23
- - **Small**: Can be completed within a single iteration/sprint
24
- - **Testable**: Multi-story validation can be thoroughly tested with various annotation patterns
25
-
26
- ## Acceptance Criteria
27
-
28
- Use checkbox format for clear completion tracking:
29
-
30
- - [x] **Core Functionality**: Support `@implements story-path REQ-ID1 REQ-ID2 ...` annotation format
31
- - [x] **Validation**: Validate each requirement exists in its specified story file
32
- - [x] **Backward Compatibility**: Existing `@story` + `@req` annotations continue working unchanged
33
- - [x] **Mixed Usage**: Support both annotation styles in same codebase and even same file
34
- - [x] **Error Messages**: Clearly indicate which story was checked when requirement validation fails
35
- - [x] **Requirement Scoping**: Requirement IDs only need to be unique within their story file
36
- - [x] **Quality Standards**: Follows ESLint rule development best practices
37
- - [x] **Documentation**: Clear examples of both annotation styles and migration guidance
38
-
39
- ## Requirements (Current Implementation or To Be Implemented)
40
-
41
- Document specific technical requirements using the format:
42
-
43
- - **REQ-IMPLEMENTS-PARSE**: Parse `@implements` annotation format extracting story path and requirement IDs
44
- - **REQ-IMPLEMENTS-VALIDATE**: Validate each requirement against its specified story file
45
- - **REQ-REQUIRE-ACCEPTS-IMPLEMENTS**: Update `require-story-annotation` and `require-req-annotation` rules to accept `@implements` as satisfying story and requirement annotations
46
- - **REQ-BACKWARD-COMPAT**: Maintain full compatibility with existing `@story` + `@req` annotations
47
- - **REQ-MIXED-SUPPORT**: Support both annotation styles in same function/file
48
- - **REQ-ERROR-CONTEXT**: Include story path in error messages for requirement validation failures
49
- - **REQ-SCOPED-IDS**: Enable requirement ID reuse across different story files
50
- - **REQ-FORMAT-VALIDATION**: Validate `@implements` line format (story path followed by requirement IDs)
51
-
52
- ## Dependencies
53
-
54
- List other stories this story depends on, using numbered story references:
55
-
56
- - 001.0-DEV-PLUGIN-SETUP (requires plugin structure foundation)
57
- - 002.0-DEV-ESLINT-CONFIG (requires configuration system)
58
- - 003.0-DEV-FUNCTION-ANNOTATIONS (extends function annotation validation)
59
- - 005.0-DEV-ANNOTATION-VALIDATION (extends annotation format validation)
60
- - 006.0-DEV-FILE-VALIDATION (uses story file validation)
61
- - 010.0-DEV-DEEP-VALIDATION (uses requirement existence validation)
62
-
63
- **Dependency Rules**:
64
-
65
- - Story numbers MUST be greater than all dependency story numbers
66
- - Dependencies should be from in-scope stories when possible
67
- - Cross-release dependencies should be clearly justified
68
- - No circular dependencies allowed
69
-
70
- ## Implementation Notes (Optional)
71
-
72
- Additional context for developers:
73
-
74
- **Development Resources**:
75
-
76
- - See [Custom ESLint Rules Development Guide](../custom-rules-development-guide.md) for implementation patterns
77
- - Review `valid-req-reference` rule for requirement validation logic
78
- - See [Testing Guide](../jest-testing-guide.md) for multi-scenario testing patterns
79
-
80
- **Implementation Details**:
81
-
82
- - Extend `valid-annotation-format` rule to recognize `@implements` annotations
83
- - Update `require-story-annotation` rule to accept `@implements` as satisfying the story annotation requirement (REQ-REQUIRE-ACCEPTS-IMPLEMENTS)
84
- - Update `require-req-annotation` rule to accept `@implements` as satisfying the requirement annotation (REQ-REQUIRE-ACCEPTS-IMPLEMENTS)
85
- - Extend `valid-req-reference` rule to validate `@implements` requirements
86
- - Parse `@implements` lines: first token is story path, remaining tokens are requirement IDs
87
- - For backward compatibility, existing `@story` + `@req` parsing remains unchanged
88
- - Support mixed usage: function can have both `@story`/`@req` and `@implements` annotations
89
- - Each requirement in `@implements` is validated against its specified story file
90
- - Update error messages to include which story was checked
91
- - Requirement ID format validation applies to both annotation styles
92
-
93
- **Annotation Format**:
94
-
95
- New `@implements` format:
96
-
97
- ```javascript
98
- /**
99
- * Apply age and security filters to rows.
100
- * @implements prompts/003.0-DEV-IDENTIFY-OUTDATED.md REQ-AGE-THRESHOLD REQ-OUTPUT
101
- * @implements prompts/004.0-DEV-FILTER-VULNERABLE-VERSIONS.md REQ-AUDIT-CHECK REQ-SAFE-ONLY
102
- * @param {Array} rows - Array of package data
103
- * @returns {Promise<Object>} Filtered results
104
- */
105
- export async function applyFilters(rows, options) {
106
- ```
107
-
108
- Legacy `@story` + `@req` format (still supported):
109
-
110
- ```javascript
111
- /**
112
- * Calculate age in days since publish date.
113
- * @param {string} publishDate - ISO date string
114
- * @returns {number} Days since publish
115
- * @story prompts/002.0-DEV-FETCH-AVAILABLE-VERSIONS.md
116
- * @req REQ-AGE-CALC
117
- */
118
- export function calculateAgeInDays(publishDate) {
119
- ```
120
-
121
- Mixed usage (both styles in same function):
122
-
123
- ```javascript
124
- /**
125
- * Complex integration function.
126
- * @story prompts/001.0-DEV-PRIMARY-STORY.md
127
- * @req REQ-PRIMARY-FUNCTION
128
- * @implements prompts/002.0-DEV-SECONDARY-STORY.md REQ-INTEGRATION-LOGIC
129
- */
130
- export function complexFunction() {
131
- ```
132
-
133
- **Parsing Logic**:
134
-
135
- ```typescript
136
- // Detect annotation type
137
- function parseImplementsLine(line: string): {
138
- storyPath: string;
139
- reqIds: string[];
140
- } | null {
141
- const trimmed = line.trim();
142
- if (!trimmed.startsWith("@implements")) return null;
143
-
144
- const tokens = trimmed.split(/\s+/).slice(1); // Remove '@implements'
145
- if (tokens.length < 2) return null; // Need story path + at least one requirement
146
-
147
- return {
148
- storyPath: tokens[0],
149
- reqIds: tokens.slice(1),
150
- };
151
- }
152
-
153
- // Validation logic
154
- function validateImplementsAnnotation(opts: {
155
- storyPath: string;
156
- reqIds: string[];
157
- context: any;
158
- reqCache: Map<string, Set<string>>;
159
- }): void {
160
- const { storyPath, reqIds, context, reqCache } = opts;
161
-
162
- // Resolve and load story file requirements
163
- const requirements = loadAndCacheRequirements(storyPath, reqCache);
164
-
165
- // Validate each requirement exists
166
- for (const reqId of reqIds) {
167
- if (!requirements.has(reqId)) {
168
- context.report({
169
- messageId: "reqMissing",
170
- data: { reqId, storyPath },
171
- });
172
- }
173
- }
174
- }
175
- ```
176
-
177
- **Error Message Updates**:
178
-
179
- ```typescript
180
- // Enhanced error messages showing which story was checked
181
- messages: {
182
- reqMissing: "Requirement '{{reqId}}' not found in '{{storyPath}}'",
183
- invalidImplementsFormat: "Invalid @implements format. Expected: @implements <story-path> <REQ-ID> [<REQ-ID>...]",
184
- noRequirementsSpecified: "@implements annotation requires at least one requirement ID after story path"
185
- }
186
- ```
187
-
188
- **Benefits of @implements**:
189
-
190
- 1. **Explicit Story Mapping**: Each requirement clearly states its source story
191
- 2. **Scoped Requirement IDs**: REQ-PARSE can exist in multiple stories without conflict
192
- 3. **Grouped by Story**: All requirements from one story listed together
193
- 4. **Reduced Duplication**: Story path appears once per story, not per requirement
194
- 5. **Migration Friendly**: Can adopt gradually without breaking existing code
195
- 6. **Natural Semantics**: "implements requirements from story" is intuitive
196
-
197
- **Migration Strategy**:
198
-
199
- 1. Both annotation styles work simultaneously (no forced migration)
200
- 2. Single-story code can continue using `@story` + `@req`
201
- 3. Multi-story code should migrate to `@implements` to fix validation
202
- 4. Teams can choose one style for consistency or use both as needed
203
- 5. Auto-fix could offer conversion from `@story`/`@req` to `@implements`
204
-
205
- ## Definition of Done
206
-
207
- - [x] All acceptance criteria met
208
- - [ ] Code reviewed and approved
209
- - [ ] Tests written and passing (single-story, multi-story, mixed usage)
210
- - [x] Documentation updated (`@implements` format, examples, migration guide)
211
- - [ ] Backward compatibility verified with existing test suite
212
- - [ ] Error messages tested for both annotation styles
213
- - [ ] Integration tested with dry-aged-deps codebase
214
- - [ ] ADR 010 referenced and decision documented
215
-
216
- ---