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,144 +0,0 @@
1
- # 006.0-DEV-FILE-VALIDATION: Story File Reference 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_
6
-
7
- This story implements validation logic that verifies @story annotations reference actual story files that exist in the project and have the correct .story.md extension. It completes the core file reference validation needed to ensure traceability annotations point to valid, accessible story files.
8
-
9
- ## How This Story Contributes
10
-
11
- This story completes the "Validate Annotations" journey phase by ensuring @story references point to actual files that exist and follow the required naming convention. It prevents broken traceability links and enables confident requirement validation, bridging the gap between code annotations and their corresponding story documentation.
12
-
13
- ## User Story
14
-
15
- **Format**: So that I can ensure my @story annotations reference valid story files, as a Developer, I want validation that checks @story file paths exist, are accessible, and follow the .story.md naming convention.
16
-
17
- **INVEST Criteria Compliance**:
18
-
19
- - **Independent**: Can be developed after annotation format validation (depends on 001.0-005.0)
20
- - **Negotiable**: File validation strictness and path resolution can be refined during implementation
21
- - **Valuable**: Delivers confidence that traceability links point to valid documentation
22
- - **Estimable**: Scope is clear - file system validation with defined path requirements
23
- - **Small**: Can be completed within a single iteration/sprint
24
- - **Testable**: File validation can be tested with various file system scenarios
25
-
26
- ## Acceptance Criteria
27
-
28
- Use checkbox format for clear completion tracking:
29
-
30
- - [x] **Core Functionality**: Validates @story file paths reference existing .story.md files
31
- - [x] **Quality Standards**: Follows ESLint development best practices and handles file system operations safely
32
- - [x] **Integration**: Works with annotations validated by format validation (005.0)
33
- - [x] **User Experience**: Clear error messages indicate which files are missing or invalid
34
- - [x] **Error Handling**: Gracefully handles file system permissions, network drives, and edge cases
35
- - [x] **Documentation**: File validation specification with path resolution rules and examples
36
-
37
- ## Requirements (Current Implementation or To Be Implemented)
38
-
39
- Document specific technical requirements using the format:
40
-
41
- - **REQ-FILE-EXISTENCE**: Verify @story file paths reference existing files
42
- - **REQ-ERROR-HANDLING**: Gracefully handles filesystem and path validation errors and provides clear diagnostics
43
- - **REQ-ANNOTATION-VALIDATION**: Parse and validate @story annotation lines so that file paths can be extracted reliably for validation
44
- - **REQ-PATH-RESOLUTION**: Resolve relative paths from project root or current file location
45
- - **REQ-SECURITY-VALIDATION**: Prevent path traversal attacks and access to restricted directories
46
- - **REQ-PERFORMANCE-OPTIMIZATION**: Efficient file system access with caching for repeated checks
47
- - **REQ-PROJECT-BOUNDARY**: Validate files are within project boundaries
48
- - **REQ-CONFIGURABLE-PATHS**: Support configurable story file directories and search 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
- - 003.0-DEV-FUNCTION-ANNOTATIONS (uses annotations detected by function validation)
57
- - 004.0-DEV-BRANCH-ANNOTATIONS (uses annotations detected by branch validation)
58
- - 005.0-DEV-ANNOTATION-VALIDATION (requires properly formatted annotations)
59
-
60
- **Dependency Rules**:
61
-
62
- - Story numbers MUST be greater than all dependency story numbers
63
- - Dependencies should be from in-scope stories when possible
64
- - Cross-release dependencies should be clearly justified
65
- - No circular dependencies allowed
66
-
67
- ## Implementation Notes (Optional)
68
-
69
- Additional context for developers:
70
-
71
- **Development Resources**:
72
-
73
- - See [Custom ESLint Rules Development Guide](../custom-rules-development-guide.md) for implementation patterns
74
- - Review [The Context Object](../custom-rules-development-guide.md#the-context-object) for accessing cwd and filename
75
- - See [Best Practices](../custom-rules-development-guide.md#best-practices) for performance optimization
76
-
77
- **Implementation Details**:
78
-
79
- - Use Node.js fs/promises for async file system operations (note: ESLint rules are synchronous, cache during plugin initialization)
80
- - Implement path resolution relative to project root using `context.cwd` (where package.json/eslint.config.js exists); the rule now prefers `context.cwd` when available and falls back to `process.cwd` as a safe default.
81
- - Support configurable story directories (e.g., docs/stories/, stories/, etc.) via rule options
82
- - Resolved story paths discovered via absolute references or via `storyDirectories` must still reside within the project root; any existing file resolved outside the project is reported as an `invalidPath` error.
83
- - Cache file existence checks during single linting run for performance
84
- - Implement security checks to prevent path traversal (../) outside project
85
- - Handle various file system scenarios (case sensitivity, symbolic links, network drives)
86
- - Provide helpful error messages with suggestions for fixing path issues
87
-
88
- **Key Guide Sections**:
89
-
90
- - [The Context Object](../custom-rules-development-guide.md#the-context-object) - Using context.cwd for path resolution
91
- - [Reporting Problems](../custom-rules-development-guide.md#reporting-problems) - Providing helpful error messages
92
- - [Best Practices](../custom-rules-development-guide.md#best-practices) - Caching for performance
93
-
94
- **Path Resolution Examples:**
95
-
96
- Valid story file references:
97
-
98
- ```javascript
99
- // @story docs/stories/001.0-DEV-EXAMPLE.story.md
100
- // @story stories/feature.story.md
101
- // @story ./local-story.story.md
102
- ```
103
-
104
- Invalid references that should trigger validation errors:
105
-
106
- ```javascript
107
- // @story ../outside-project.story.md (path traversal)
108
- // @story docs/stories/missing.story.md (file doesn't exist)
109
- // @story docs/stories/wrong-extension.md (wrong extension)
110
- // @story /absolute/path.story.md (absolute path not allowed)
111
- ```
112
-
113
- **Configuration Integration:**
114
-
115
- ```javascript
116
- // eslint.config.js
117
- export default [
118
- {
119
- plugins: { traceability },
120
- rules: {
121
- "traceability/valid-story-reference": [
122
- "error",
123
- {
124
- storyDirectories: ["docs/stories", "stories"],
125
- allowAbsolutePaths: false,
126
- requireStoryExtension: true,
127
- },
128
- ],
129
- },
130
- },
131
- ];
132
- ```
133
-
134
- ## Definition of Done
135
-
136
- - [x] All acceptance criteria met
137
- - [ ] Code reviewed and approved
138
- - [x] Tests written and passing (file system scenarios, path resolution, security)
139
- - [x] Documentation updated (file validation rules and configuration options)
140
- - [ ] Performance tested with large numbers of story files
141
- - [x] Security reviewed for path traversal and access control
142
- - [x] Ready for error reporting enhancement (007.0-DEV-ERROR-REPORTING)
143
-
144
- ---
@@ -1,163 +0,0 @@
1
- # 007.0-DEV-ERROR-REPORTING: Clear Error Messages for Annotation Violations
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 ensures developers receive clear, actionable feedback when traceability violations are detected, enabling quick resolution of annotation issues and supporting the overall goal of reliable traceability enforcement.
8
-
9
- ## How This Story Contributes
10
-
11
- Clear error messages are critical for developer adoption and productivity. When annotation validation fails, developers need to understand exactly what's wrong and how to fix it. This story transforms technical validation failures into helpful guidance, reducing friction in maintaining traceability annotations and ensuring developers can quickly resolve issues without extensive debugging.
12
-
13
- This story enables successful completion of the "Fix Issues" journey phase by providing the foundation for all error communication in the plugin.
14
-
15
- ## User Story
16
-
17
- **Format**: So that I can quickly understand and fix traceability violations without wasting time debugging, as a Developer, I want the ESLint plugin to provide clear, specific error messages that explain what's wrong and suggest how to fix annotation issues.
18
-
19
- **INVEST Criteria Compliance**:
20
-
21
- - **Independent**: Can be developed using the validation logic from previous stories without blocking dependencies
22
- - **Negotiable**: Error message formats and content can be refined based on developer feedback during implementation
23
- - **Valuable**: Delivers clear value by reducing time spent debugging annotation issues
24
- - **Estimable**: Scope is well-defined - enhance existing validation rules with improved messaging
25
- - **Small**: Focused on message enhancement rather than new validation logic
26
- - **Testable**: Error messages can be verified through unit tests and developer feedback
27
-
28
- ## Acceptance Criteria
29
-
30
- - [x] **Core Functionality**: All validation rules provide specific, actionable error messages instead of generic failures
31
- - [x] **Quality Standards**: Error messages follow ESLint best practices for clarity and consistency
32
- - [x] **Integration**: Error messages work properly with existing validation rules and ESLint reporting
33
- - [x] **User Experience**: Messages clearly identify the problem, location, and suggested fix
34
- - [x] **Error Handling**: Gracefully handles edge cases where error context is incomplete
35
- - [x] **Documentation**: Error message formats are documented for consistency across rules
36
-
37
- ## Requirements (Implemented & Verified)
38
-
39
- All of the following requirements are implemented in the current ruleset and verified by automated tests and manual review:
40
-
41
- - **REQ-ERROR-SPECIFIC**: Each validation failure provides specific details about what annotation is missing or invalid. Verified across:
42
- - `traceability/require-story-annotation`
43
- - `traceability/require-req-annotation`
44
- - `traceability/require-branch-annotation`
45
- - `traceability/valid-annotation-format`
46
- - `traceability/valid-story-reference`
47
- - `traceability/valid-req-reference`
48
- - **REQ-ERROR-LOCATION**: Error messages include precise location information (function name, line number, file path) via ESLint’s standard location reporting and message data fields (e.g., `functionName`, `filePath`).
49
- - **REQ-ERROR-SUGGESTION**: Messages suggest concrete steps to fix the issue (e.g., "Add @story annotation" or "Fix file path"), including ESLint suggestions where implemented (notably in `traceability/require-story-annotation`).
50
- - **REQ-ERROR-CONTEXT**: Error messages include relevant context (expected annotation format, available story files) via `details`, `reqId`, `storyId`, and `storyPath` placeholders where applicable.
51
- - **REQ-ERROR-CONSISTENCY**: All plugin rules now conform to the shared error message conventions defined in this story, using common patterns and placeholders via `meta.messages` and shared `messageId` values where appropriate.
52
- - **REQ-ERROR-SEVERITY**: Error severity levels are appropriate (error for missing annotations, warning for format issues) and aligned with ESLint’s `severity` configuration and rule defaults.
53
-
54
- ## Error Message Conventions
55
-
56
- Cross-rule error messages follow these shared patterns for consistency and clarity:
57
-
58
- - **Function-related errors**
59
- - Use `{{functionName}}` to identify the affected function or method.
60
- - Typical pattern:
61
- - `"Function '{{functionName}}' is missing a required @story annotation."`
62
- - `"Function '{{functionName}}' has an invalid @req annotation: {{details}}."`
63
-
64
- - **Branch-related errors**
65
- - Use a generic `missingAnnotation`-style message with a `{{missing}}` placeholder to describe what is absent.
66
- - Typical pattern:
67
- - `"Branch is missing required annotation: {{missing}}."`
68
-
69
- - **Format / validation details**
70
- - Use a `{{details}}` placeholder for human-readable validation output, such as expected formats or concrete problems.
71
- - Typical pattern:
72
- - `"Invalid annotation format: {{details}}."`
73
-
74
- - **File / reference errors**
75
- - Use `{{filePath}}` (and when applicable, `{{storyId}}` / `{{reqId}}`) to indicate problematic references.
76
- - Typical pattern:
77
- - `"Referenced story file '{{filePath}}' could not be found."`
78
- - `"Requirement '{{reqId}}' was not found in '{{filePath}}'."`
79
-
80
- - **Severity conventions**
81
- - **Errors** (`severity: 2`):
82
- - Missing required annotations (e.g., missing `@story` or `@req`).
83
- - Missing or unresolved referenced files or requirement IDs.
84
- - **Warnings** (`severity: 1`):
85
- - Annotation format or style issues that do not break traceability, e.g., spacing, optional fields, or non-critical structure problems.
86
-
87
- All rules expose these messages through `meta.messages` with `messageId` values that are reused where appropriate, ensuring consistent wording and behavior across function, branch, and file validation rules.
88
-
89
- ## Dependencies
90
-
91
- - 003.0-DEV-FUNCTION-ANNOTATIONS (error reporting needs function annotation validation logic)
92
- - 004.0-DEV-BRANCH-ANNOTATIONS (error reporting needs branch annotation validation logic)
93
- - 005.0-DEV-ANNOTATION-VALIDATION (error reporting needs annotation format validation results)
94
- - 006.0-DEV-FILE-VALIDATION (error reporting needs file validation results)
95
-
96
- **Dependency Rules**:
97
-
98
- - Story numbers MUST be greater than all dependency story numbers
99
- - Dependencies should be from in-scope stories when possible
100
- - Cross-release dependencies should be clearly justified
101
- - No circular dependencies allowed
102
-
103
- ## Implementation Notes (Optional)
104
-
105
- **Development Resources**:
106
-
107
- - See [Custom ESLint Rules Development Guide](../custom-rules-development-guide.md) for error reporting patterns
108
- - Review [Reporting Problems](../custom-rules-development-guide.md#reporting-problems) for context.report() usage
109
- - See [Providing Suggestions](../custom-rules-development-guide.md#providing-suggestions) for suggestion API
110
-
111
- A dedicated error-reporting test suite exists at `tests/rules/error-reporting.test.ts`, which verifies that the implemented rules conform to the shared error message conventions and produce the expected messages and suggestions (including for `traceability/require-story-annotation`).
112
-
113
- **Current Rule Implementations**
114
-
115
- - `traceability/require-story-annotation`
116
- - Uses `meta.messages.missingStory` with pattern `Function '{{name}}' must have an explicit @story annotation. Add a JSDoc or line comment with @story that points to the implementing story file (for example, docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md).` and provides ESLint suggestions via `suggest` in `context.report()`.
117
- - `traceability/require-req-annotation`
118
- - Uses `meta.messages.missingReq` with pattern `Function '{{name}}' is missing a required @req annotation. Add a JSDoc or line comment with @req (for example, '@req REQ-EXAMPLE') ...` and reports the function name via both `name` and `functionName` data fields.
119
- - `traceability/require-branch-annotation`
120
- - Uses `meta.messages.missingAnnotation` with pattern `Branch is missing required annotation: {{missing}}.` for branch-level errors.
121
- - `traceability/valid-annotation-format`
122
- - Uses `meta.messages.invalidStoryFormat` and `meta.messages.invalidReqFormat` with pattern `Invalid annotation format: {{details}}.` where `details` contains the more specific validation message (missing path, invalid ID, etc.).
123
- - `traceability/valid-story-reference`
124
- - Uses `meta.messages.fileMissing`, `invalidExtension`, `invalidPath`, and `fileAccessError` to distinguish missing files from filesystem errors and invalid paths.
125
- - `traceability/valid-req-reference`
126
- - Uses `meta.messages.reqMissing` and `invalidPath` to report missing requirement IDs and unsafe story paths, including both `reqId` and `storyPath` in the message data.
127
-
128
- **Technical Considerations**:
129
-
130
- - Use ESLint's context.report() method for consistent error reporting
131
- - Implement error message templates in meta.messages using messageIds (recommended approach)
132
- - Use data placeholders for dynamic error information (e.g., `{{functionName}}`, `{{filePath}}`)
133
- - Consider internationalization support for error messages
134
- - Include suggestions using ESLint's suggest API where appropriate for manual fixes
135
-
136
- **Key Guide Sections**:
137
-
138
- - [Reporting Problems](../custom-rules-development-guide.md#reporting-problems) - Complete guide to context.report() and messageIds
139
- - [Providing Suggestions](../custom-rules-development-guide.md#providing-suggestions) - Using hasSuggestions and suggest array
140
-
141
- **Integration Points**:
142
-
143
- - Enhance existing validation rules from stories 003.0-006.0
144
- - Integrate with ESLint's built-in error reporting and formatting
145
- - Ensure compatibility with different ESLint output formats (stylish, json, etc.)
146
-
147
- **Testing Strategy**:
148
-
149
- - Unit tests for each error message scenario
150
- - Integration tests with various code patterns
151
- - Manual testing with developers for message clarity
152
- - Verify error messages work in different IDEs and editors
153
-
154
- ## Definition of Done
155
-
156
- - [x] All acceptance criteria met
157
- - [x] Code reviewed and approved
158
- - [x] Tests written and passing
159
- - [x] Documentation updated
160
- - [x] Deployed to appropriate environment
161
- - [x] Stakeholder acceptance confirmed
162
-
163
- All requirements in this story are now verified by automated tests that match the implemented rules and error message templates.
@@ -1,150 +0,0 @@
1
- # 008.0-DEV-AUTO-FIX: Simple Auto-Fixes for Annotation Issues
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 enables developers to automatically fix common annotation issues through ESLint's auto-fix functionality, reducing manual effort and accelerating the adoption of traceability practices by making compliance as frictionless as possible.
8
-
9
- ## How This Story Contributes
10
-
11
- Auto-fix capabilities transform the "Fix Issues" experience from manual correction to automated resolution for common problems. This dramatically reduces the friction of maintaining traceability annotations, especially when introducing the plugin to existing codebases with many annotation violations. By providing safe, automated fixes, this story enables teams to quickly achieve compliance and focus on higher-value activities.
12
-
13
- This story completes the core "Fix Issues" journey phase by providing both clear error messages (007.0) and automated resolution capabilities.
14
-
15
- ## User Story
16
-
17
- **Format**: So that I can quickly resolve common annotation issues without manual editing, as a Developer, I want the ESLint plugin to automatically fix standard annotation violations when I run ESLint with the --fix option.
18
-
19
- **INVEST Criteria Compliance**:
20
-
21
- - **Independent**: Can be developed using existing validation logic and error reporting from previous stories
22
- - **Negotiable**: The set of auto-fixable issues and fix strategies can be refined during implementation
23
- - **Valuable**: Delivers clear value by reducing manual work and speeding up compliance
24
- - **Estimable**: Scope is well-defined - implement ESLint auto-fix for specific validation rules
25
- - **Small**: Focused on a subset of fixable issues rather than all possible violations
26
- - **Testable**: Auto-fixes can be verified through before/after code comparisons
27
-
28
- ## Acceptance Criteria
29
-
30
- - [x] **Core Functionality**: ESLint --fix automatically resolves common annotation violations
31
- - Implemented for missing `@story` on functions/methods via `require-story-annotation` and safe `@story` path suffix normalization via `valid-annotation-format`, both verified by dedicated tests (including `tests/rules/auto-fix-behavior-008.test.ts`)
32
- - [x] **Quality Standards**: Auto-fixes are safe and preserve code functionality and formatting
33
- - Implemented for function/method `@story` auto-insertion and simple path suffix normalization with conservative, non-destructive edits
34
- - [x] **Integration**: Auto-fix works properly with existing validation rules and ESLint toolchain
35
- - Implemented and integrated for function/method `@story` validation and basic `.story`/`.md` path suffix normalization in existing rules
36
- - [x] **User Experience**: Fixes are applied consistently and predictably across different code patterns
37
- - Implemented for supported function/method patterns and simple path suffix normalization, with consistent before/after behavior validated by tests
38
- - [x] **Error Handling**: Gracefully handles edge cases where auto-fix cannot be applied safely
39
- - Implemented so unfixable or ambiguous cases report validation errors without attempting a fix, focusing only on clearly safe scenarios
40
- - [x] **Documentation**: Auto-fix capabilities are documented with examples of fixable issues
41
- - Implemented documentation in `user-docs/api-reference.md` for `traceability/require-story-annotation` and `traceability/valid-annotation-format`, including what `--fix` does for each rule and the safety constraints on applied fixes
42
-
43
- ## Requirements (Current Implementation or To Be Implemented)
44
-
45
- - **REQ-AUTOFIX-MISSING**: Automatically add missing @story annotations to functions and methods using a simple built-in template via the `require-story-annotation` rule
46
- - Implemented for function and method annotations in this story; behavior is covered by `require-story-annotation` and verified by dedicated auto-fix tests in `tests/rules/auto-fix-behavior-008.test.ts`. The template content and formatting are currently fixed but designed for future configurability, implemented via the rule and helper functions in `src/rules/helpers/require-story-helpers.ts` and `src/rules/helpers/require-story-core.ts`.
47
- - **REQ-AUTOFIX-FORMAT**: Fix common annotation format issues (spacing, syntax, casing) for simple, clearly identifiable cases via the `valid-annotation-format` rule
48
- - Implemented for simple `@story` path suffix normalization where the correct suffix (e.g., `.story.md`) can be inferred safely. Behavior is implemented via the `getFixedStoryPath` helper and the `reportInvalidStoryFormatWithFix` helper in `src/rules/valid-annotation-format.ts`, providing safe `.story`/`.md` suffix adjustments and verified by dedicated auto-fix tests in `tests/rules/auto-fix-behavior-008.test.ts`.
49
- - **REQ-AUTOFIX-SAFE**: Only apply fixes that are guaranteed to be safe and non-destructive
50
- - Implemented for:
51
- - Adding missing `@story` annotations above functions and methods using a conservative placeholder template (`require-story-annotation`)
52
- - Correcting simple, unambiguous story path suffix issues limited to `.story`/`.md` suffix normalization (`valid-annotation-format`)
53
- - More complex or ambiguous fixes (e.g., changing directories, inferring new story names, or altering runtime code) remain explicitly out of scope for this iteration.
54
- - **REQ-AUTOFIX-PRESERVE**: Preserve existing code formatting, indentation, and comment structure
55
- - Implemented for current fixes by:
56
- - Inserting new `@story` comments immediately above the relevant function/method without reformatting surrounding code or altering existing comments
57
- - Applying minimal text changes to append or correct only the `.story`/`.md` suffixes on existing path strings, preserving surrounding formatting, whitespace, and string content
58
- - Broader formatting or structural adjustments remain out of scope to avoid unintended changes.
59
- - **REQ-AUTOFIX-TEMPLATE**: Use configurable annotation templates for consistent formatting
60
- - Not yet implemented; current behavior uses a simple, built-in placeholder template for missing `@story` annotations on functions and methods. Template configurability is planned as a future enhancement.
61
- - **REQ-AUTOFIX-SELECTIVE**: Allow developers to choose which types of fixes to enable/disable
62
- - Not yet implemented; selective enable/disable of specific fix behaviors (e.g., missing-annotation vs. path-format fixes) remains future work.
63
-
64
- ## Dependencies
65
-
66
- - 003.0-DEV-FUNCTION-ANNOTATIONS (auto-fix needs to understand function annotation requirements)
67
- - 004.0-DEV-BRANCH-ANNOTATIONS (auto-fix needs to understand branch annotation requirements)
68
- - 005.0-DEV-ANNOTATION-VALIDATION (auto-fix needs validation logic to identify fixable issues)
69
- - 007.0-DEV-ERROR-REPORTING (auto-fix should integrate with error reporting for unfixable issues)
70
-
71
- **Dependency Rules**:
72
-
73
- - Story numbers MUST be greater than all dependency story numbers
74
- - Dependencies should be from in-scope stories when possible
75
- - Cross-release dependencies should be clearly justified
76
- - No circular dependencies allowed
77
-
78
- ## Implementation Notes (Optional)
79
-
80
- **Development Resources**:
81
-
82
- - See [Custom ESLint Rules Development Guide](../custom-rules-development-guide.md) for fix implementation patterns
83
- - Review [Applying Fixes](../custom-rules-development-guide.md#applying-fixes) for comprehensive fixer API documentation
84
- - See [Best Practices](../custom-rules-development-guide.md#best-practices) for safe fix guidelines
85
-
86
- **Technical Considerations**:
87
-
88
- - Use ESLint's fix API to provide automated corrections
89
- - Implement fixer functions in context.report() using fix(fixer) callback
90
- - Set meta.fixable to "code" or "whitespace" (required for fixable rules)
91
- - Use fixer methods: insertTextBefore(), insertTextAfter(), replaceText(), etc.
92
- - Consider code formatting preservation using AST manipulation
93
- - Provide configuration options for auto-fix behavior
94
- - NOTE: Template configurability and selective enable/disable of fix types are not yet implemented; current behavior uses a simple, built-in placeholder template for missing `@story` on functions and methods, and always applies safe, simple path suffix fixes when `valid-annotation-format` is enabled and run with `--fix`.
95
- - Follow fix best practices: don't change runtime behavior, make minimal changes, ensure fixes are safe
96
-
97
- **Current Auto-Fix Capabilities (This Iteration)**:
98
-
99
- - Adding missing `@story` annotations to functions and methods with a basic placeholder template placed immediately above the function/method, implemented via the `require-story-annotation` rule
100
- - Fixing simple story path suffix issues (e.g., adding `.story.md` when clearly missing) and other minimal, safe format corrections related to `@story` path suffixes, implemented via the `valid-annotation-format` rule
101
-
102
- **Planned / Future Enhancements**:
103
-
104
- - Configurable annotation templates for different project conventions
105
- - Selective enable/disable for specific auto-fix behaviors (e.g., path fixes vs. missing-annotation fixes) beyond standard ESLint rule-level enable/disable
106
- - Broader pattern coverage for functions and branches while maintaining safety guarantees
107
-
108
- **Key Guide Sections**:
109
-
110
- - [Applying Fixes](../custom-rules-development-guide.md#applying-fixes) - Complete fixer API reference and examples
111
- - [Best Practices](../custom-rules-development-guide.md#best-practices) - Fix safety and performance guidelines
112
-
113
- **Integration Points**:
114
-
115
- - Enhance existing validation rules with fix capabilities
116
- - Integrate with ESLint's --fix command line option
117
- - Ensure compatibility with IDE auto-fix on save features
118
- - Work with existing code formatters (Prettier, etc.)
119
-
120
- **Safe Auto-Fix Scenarios**:
121
-
122
- - Adding missing @story annotations with placeholder content for functions and methods (`require-story-annotation`)
123
- - Fixing simple, unambiguous story path suffix issues (e.g., missing `.story.md`) and related minor format fixes for @story paths (`valid-annotation-format`)
124
- - Fixing annotation comment syntax (@story vs // @story) where safe and unambiguous through `valid-annotation-format`
125
- - Correcting annotation format spacing and structure in simple, well-understood cases
126
- - Standardizing annotation placement (before function vs inline) for supported function/method patterns
127
-
128
- **Non-Auto-Fixable Scenarios** (require manual intervention):
129
-
130
- - Choosing appropriate story file references
131
- - Adding specific requirement annotations
132
- - Resolving file path issues that require developer knowledge
133
- - Complex formatting conflicts with existing code style
134
-
135
- **Testing Strategy**:
136
-
137
- - Unit tests for each auto-fix scenario with before/after comparisons
138
- - Currently focused on missing-function/method-`@story` and simple path suffix issues, with dedicated coverage in `tests/rules/auto-fix-behavior-008.test.ts` alongside existing rule-specific tests
139
- - Integration tests with various code patterns and existing formatting
140
- - Edge case testing for complex code structures
141
- - Manual testing with real codebases to verify safety and effectiveness
142
-
143
- ## Definition of Done
144
-
145
- - [ ] All acceptance criteria met
146
- - [ ] Code reviewed and approved
147
- - [ ] Tests written and passing
148
- - [ ] Documentation updated
149
- - [ ] Deployed to appropriate environment
150
- - [ ] Stakeholder acceptance confirmed
@@ -1,117 +0,0 @@
1
- # 009.0-DEV-MAINTENANCE-TOOLS: Update Helpers for Annotation Maintenance
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 provides developers with helper tools and utilities to maintain traceability annotations as their codebase evolves, ensuring annotations remain accurate and up-to-date when story files are moved, renamed, or restructured.
8
-
9
- ## How This Story Contributes
10
-
11
- As codebases grow and evolve, maintaining traceability annotations becomes an ongoing challenge. This story bridges the gap between initial compliance (achieved through validation and auto-fix) and long-term maintainability. By providing tools to update annotations when story files change, this story ensures that traceability systems remain valuable over time rather than becoming maintenance burdens.
12
-
13
- This story initiates the "Maintain Quality" journey phase by providing foundational tools for ongoing annotation maintenance.
14
-
15
- ## User Story
16
-
17
- **Format**: So that I can keep annotations accurate when story files are moved or renamed without manually hunting through code, as a Developer, I want helper tools that can batch update annotation references and detect when annotations become stale.
18
-
19
- **INVEST Criteria Compliance**:
20
-
21
- - **Independent**: Can be developed using existing validation logic and file system operations
22
- - **Negotiable**: The specific maintenance tools and their interfaces can be refined during implementation
23
- - **Valuable**: Delivers clear value by reducing manual maintenance work as projects evolve
24
- - **Estimable**: Scope is well-defined - implement specific maintenance utilities
25
- - **Small**: Focused on core maintenance scenarios rather than comprehensive project management
26
- - **Testable**: Maintenance operations can be verified through before/after file comparisons
27
-
28
- ## Acceptance Criteria
29
-
30
- - [ ] **Core Functionality**: Tools can detect and update annotation references when story files are moved or renamed
31
- - [ ] **Quality Standards**: Maintenance operations preserve code functionality and formatting
32
- - [ ] **Integration**: Tools work with existing project structure and ESLint configuration
33
- - [ ] **User Experience**: Maintenance operations provide clear feedback about what was changed
34
- - [ ] **Error Handling**: Gracefully handles edge cases like circular references or missing files
35
- - [ ] **Documentation**: Maintenance tools are documented with usage examples and best practices
36
-
37
- ## Requirements (Current Implementation or To Be Implemented)
38
-
39
- - **REQ-MAINT-DETECT**: Detect stale annotation references that point to moved or deleted story files
40
- - **REQ-MAINT-UPDATE**: Update annotation references when story files are moved or renamed
41
- - **REQ-MAINT-BATCH**: Perform batch updates across multiple files and annotations
42
- - **REQ-MAINT-VERIFY**: Verify annotation references are still valid after maintenance operations
43
- - **REQ-MAINT-REPORT**: Generate reports showing what annotations were updated and why
44
- - **REQ-MAINT-SAFE**: Ensure maintenance operations are reversible and don't break existing functionality
45
-
46
- ## Dependencies
47
-
48
- - 005.0-DEV-ANNOTATION-VALIDATION (maintenance tools need to understand annotation format)
49
- - 006.0-DEV-FILE-VALIDATION (maintenance tools need file existence validation logic)
50
- - 007.0-DEV-ERROR-REPORTING (maintenance tools should use consistent error reporting)
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 rule implementation patterns
64
- - While this story focuses on CLI tools rather than ESLint rules, the guide's patterns for accessing source code and AST manipulation are applicable
65
- - Review [Accessing Source Code](../custom-rules-development-guide.md#accessing-source-code) for parsing and modifying annotations
66
-
67
- **Technical Considerations**:
68
-
69
- - Implement CLI tools for common maintenance operations
70
- - Use file system watching to detect when story files are moved or renamed
71
- - Provide programmatic APIs for integration with project tooling
72
- - Leverage ESLint's SourceCode API patterns for finding and updating annotations
73
- - Consider integration with Git hooks for automatic maintenance
74
- - Use AST manipulation for safe code updates (similar to auto-fix but in standalone tools)
75
-
76
- **Key Guide Sections**:
77
-
78
- - [Accessing Source Code](../custom-rules-development-guide.md#accessing-source-code) - Techniques for finding annotations in code
79
- - [Applying Fixes](../custom-rules-development-guide.md#applying-fixes) - Patterns for code modification
80
-
81
- **Integration Points**:
82
-
83
- - Work with existing ESLint plugin infrastructure
84
- - Integrate with project build and development workflows
85
- - Provide hooks for custom maintenance automation
86
- - Support various project structures and story file organization
87
-
88
- **Common Maintenance Scenarios**:
89
-
90
- - Story files moved to new directories (reorganization)
91
- - Story files renamed for consistency or clarity
92
- - Story files deleted (need to flag dependent annotations)
93
- - Bulk updates when story numbering scheme changes
94
- - Project restructuring that affects story file paths
95
-
96
- **Maintenance Tool Types**:
97
-
98
- - **Detection Tools**: Scan codebase for stale or invalid annotation references
99
- - **Update Tools**: Batch update annotations to reflect file system changes
100
- - **Verification Tools**: Validate that all annotations still point to valid story files
101
- - **Migration Tools**: Help migrate from old annotation formats to new ones
102
-
103
- **Testing Strategy**:
104
-
105
- - Unit tests for each maintenance operation with various file scenarios
106
- - Integration tests with real project structures and story file layouts
107
- - Performance tests for large codebases with many annotations
108
- - Manual testing with common maintenance workflows
109
-
110
- ## Definition of Done
111
-
112
- - [ ] All acceptance criteria met
113
- - [ ] Code reviewed and approved
114
- - [ ] Tests written and passing
115
- - [ ] Documentation updated
116
- - [ ] Deployed to appropriate environment
117
- - [ ] Stakeholder acceptance confirmed