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,103 @@
1
+ # CLI Integration Script Documentation
2
+
3
+ This document provides detailed information about the `cli-integration.js` script, which runs end-to-end CLI integration tests for the `eslint-plugin-traceability` plugin.
4
+
5
+ Story: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
6
+ Requirement: REQ-PLUGIN-STRUCTURE - Validate plugin registers via CLI
7
+
8
+ ## Overview
9
+
10
+ The `cli-integration.js` script automates tests that invoke the ESLint CLI with the plugin configured, verifying that rule errors are reported (or not) as expected when code is passed via `stdin`.
11
+
12
+ It uses Node.js `child_process.spawnSync` to:
13
+
14
+ - Disable default ESLint config resolution
15
+ - Load the plugin via `eslint.config.js` flat config
16
+ - Pass code and rule settings via `--stdin` and `--rule` flags
17
+
18
+ ## Tests Implemented
19
+
20
+ The script defines an array of test scenarios, each with:
21
+
22
+ - **name**: A descriptive test name
23
+ - **code**: A string containing JavaScript code to lint
24
+ - **rule**: An ESLint rule override specifying severity
25
+ - **expectedStatus**: The expected exit code (0 or 1)
26
+
27
+ Current test scenarios:
28
+
29
+ 1. `reports error when @story annotation is missing`
30
+ - Code: `function foo() {}`
31
+ - Rule: `traceability/require-story-annotation:error`
32
+ - Expected exit code: 1 (error reported)
33
+
34
+ 2. `does not report error when @story annotation is present`
35
+
36
+ ```js
37
+ /**
38
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
39
+ */
40
+ function foo() {}
41
+ ```
42
+
43
+ - Rule: `traceability/require-story-annotation:error`
44
+ - Expected exit code: 0 (no error)
45
+
46
+ 3. `reports error when @req annotation is missing`
47
+ - Code: `function bar() {}`
48
+ - Rule: `traceability/valid-req-reference:error`
49
+ - Expected exit code: 1 (error reported)
50
+
51
+ 4. `reports error when @req annotation uses path traversal`
52
+
53
+ ```js
54
+ /**
55
+ * @req ../docs/requirements/REQ-INVALID.md
56
+ */
57
+ function bar() {}
58
+ ```
59
+
60
+ - Rule: `traceability/valid-req-reference:error`
61
+ - Expected exit code: 1 (error reported)
62
+
63
+ 5. `reports error when @req annotation uses absolute path`
64
+
65
+ ```js
66
+ /**
67
+ * @req /etc/passwd
68
+ */
69
+ function baz() {}
70
+ ```
71
+
72
+ - Rule: `traceability/valid-req-reference:error`
73
+ - Expected exit code: 1 (error reported)
74
+
75
+ ## Usage
76
+
77
+ ```bash
78
+ # Run CLI integration tests
79
+ node cli-integration.js
80
+ ```
81
+
82
+ ## Integration into CI
83
+
84
+ The CI workflow (`.github/workflows/ci.yml`) includes a separate `integration-tests` job that runs:
85
+
86
+ ```yaml
87
+ jobs:
88
+ integration-tests:
89
+ needs: quality-checks
90
+ run: node cli-integration.js
91
+ ```
92
+
93
+ This ensures that CLI-level behavior is verified on all supported Node.js versions.
94
+
95
+ ## Extending Tests
96
+
97
+ To add new CLI integration scenarios:
98
+
99
+ 1. Open `cli-integration.js`.
100
+ 2. Append a new object to the `tests` array with the desired `name`, `code`, `rule`, and `expectedStatus`.
101
+ 3. Run `node cli-integration.js` locally to verify.
102
+
103
+ Ensure that any new scenarios have clear test names and cover distinct rule behaviors.
@@ -0,0 +1,38 @@
1
+ # Configuration Presets
2
+
3
+ This document describes the built-in configuration presets provided by the `eslint-plugin-traceability` plugin.
4
+
5
+ ## Recommended Preset
6
+
7
+ Use the **recommended** preset to enable the core traceability rule set with default settings.
8
+
9
+ ```javascript
10
+ // eslint.config.js
11
+ import js from "@eslint/js";
12
+ import traceability from "eslint-plugin-traceability";
13
+
14
+ export default [js.configs.recommended, traceability.configs.recommended];
15
+ ```
16
+
17
+ This preset enables the following rules at the `error` level:
18
+
19
+ - `traceability/require-story-annotation`
20
+ - `traceability/require-req-annotation`
21
+ - `traceability/require-branch-annotation`
22
+ - `traceability/valid-annotation-format`
23
+ - `traceability/valid-story-reference`
24
+ - `traceability/valid-req-reference`
25
+
26
+ ## Strict Preset
27
+
28
+ Use the **strict** preset to enforce the same core rules, with potential future enhancements for stricter policies.
29
+
30
+ ```javascript
31
+ // eslint.config.js
32
+ import js from "@eslint/js";
33
+ import traceability from "eslint-plugin-traceability";
34
+
35
+ export default [js.configs.recommended, traceability.configs.strict];
36
+ ```
37
+
38
+ The **strict** preset currently mirrors the **recommended** rules, but may include additional constraints in future plugin versions.
@@ -0,0 +1,111 @@
1
+ ---
2
+ status: "accepted"
3
+ date: 2025-11-15
4
+ decision-makers: [Development Team]
5
+ consulted: [ESLint Community Best Practices, TypeScript ESLint Documentation]
6
+ informed: [Project Stakeholders, Future Contributors]
7
+ ---
8
+
9
+ # Use TypeScript for ESLint Plugin Development
10
+
11
+ ## Context and Problem Statement
12
+
13
+ When developing an ESLint plugin that validates code traceability annotations (@story and @req comments), we need to choose the implementation language. The plugin will perform complex Abstract Syntax Tree (AST) manipulation to analyze JavaScript/TypeScript code and validate annotation compliance. The choice between JavaScript and TypeScript affects development experience, maintainability, error prevention, and integration with the broader ESLint ecosystem.
14
+
15
+ ## Decision Drivers
16
+
17
+ - Need for type safety when working with complex AST structures and ESLint Rule API
18
+ - Developer experience and IDE support for plugin development
19
+ - Integration with modern ESLint tooling and TypeScript ecosystem
20
+ - Error prevention during AST manipulation and rule configuration
21
+ - Long-term maintainability of the plugin codebase
22
+ - Alignment with ESLint plugin development best practices
23
+ - Support for advanced TypeScript-aware parsing when needed
24
+
25
+ ## Considered Options
26
+
27
+ - TypeScript with full type definitions
28
+ - JavaScript with JSDoc type annotations
29
+ - Plain JavaScript without type annotations
30
+
31
+ ## Decision Outcome
32
+
33
+ Chosen option: "TypeScript with full type definitions", because it provides the strongest type safety for complex AST manipulation, offers the best developer experience through IDE integration, aligns with modern ESLint plugin development practices, and enables seamless integration with @typescript-eslint utilities.
34
+
35
+ ### Consequences
36
+
37
+ - Good, because TypeScript prevents runtime errors from malformed AST access patterns
38
+ - Good, because IDE autocompletion and IntelliSense improve development velocity
39
+ - Good, because type definitions serve as living documentation for rule APIs
40
+ - Good, because integration with @typescript-eslint/utils provides advanced parsing capabilities
41
+ - Good, because refactoring becomes safer as the plugin grows in complexity
42
+ - Good, because follows established patterns in the ESLint ecosystem
43
+ - Bad, because requires additional build step for TypeScript compilation
44
+ - Bad, because slightly increases initial setup complexity
45
+ - Bad, because may have learning curve for developers unfamiliar with TypeScript
46
+
47
+ ### Confirmation
48
+
49
+ Implementation compliance will be confirmed through:
50
+
51
+ - TypeScript compilation passes without errors in CI/CD pipeline
52
+ - All plugin source files use .ts extension
53
+ - package.json includes TypeScript as development dependency
54
+ - tsconfig.json configured for ESLint plugin development
55
+ - Use of @typescript-eslint/utils for AST manipulation where appropriate
56
+ - Type definitions for all rule configurations and options
57
+
58
+ ## Pros and Cons of the Options
59
+
60
+ ### TypeScript with full type definitions
61
+
62
+ TypeScript provides compile-time type checking, excellent IDE support, and strong integration with ESLint tooling ecosystem.
63
+
64
+ - Good, because prevents common AST manipulation errors at compile time
65
+ - Good, because provides excellent IDE autocompletion for ESLint Rule API
66
+ - Good, because enables type-safe rule configuration and options validation
67
+ - Good, because integrates seamlessly with @typescript-eslint/utils
68
+ - Good, because self-documents code through type annotations
69
+ - Good, because supports advanced refactoring capabilities
70
+ - Good, because aligns with modern ESLint plugin development practices
71
+ - Neutral, because requires TypeScript knowledge from contributors
72
+ - Bad, because adds compilation step to development workflow
73
+ - Bad, because increases initial project setup complexity
74
+
75
+ ### JavaScript with JSDoc type annotations
76
+
77
+ JavaScript with JSDoc comments provides some type hints while maintaining simpler build process.
78
+
79
+ - Good, because no additional build step required
80
+ - Good, because familiar to JavaScript-only developers
81
+ - Good, because provides basic type hints through comments
82
+ - Neutral, because some IDE support for JSDoc types
83
+ - Bad, because no compile-time error checking
84
+ - Bad, because JSDoc types are not enforced or validated
85
+ - Bad, because limited integration with @typescript-eslint type definitions
86
+ - Bad, because refactoring support is significantly weaker
87
+ - Bad, because AST manipulation errors only discovered at runtime
88
+
89
+ ### Plain JavaScript without type annotations
90
+
91
+ Pure JavaScript implementation with no type system support.
92
+
93
+ - Good, because simplest possible setup
94
+ - Good, because no build step required
95
+ - Good, because no TypeScript learning curve
96
+ - Bad, because no type safety for complex AST manipulation
97
+ - Bad, because no IDE autocompletion for ESLint APIs
98
+ - Bad, because all errors discovered at runtime during testing
99
+ - Bad, because difficult to maintain as complexity grows
100
+ - Bad, because no integration benefits with TypeScript ecosystem
101
+ - Bad, because poor refactoring support
102
+
103
+ ## More Information
104
+
105
+ This decision aligns with REQ-TYPESCRIPT in story 001.0-DEV-PLUGIN-SETUP. The implementation should use @typescript-eslint/utils for AST parsing utilities and follow TypeScript ESLint plugin development patterns. The decision should be re-evaluated if TypeScript compilation becomes a significant bottleneck or if the team expertise changes significantly.
106
+
107
+ Related resources:
108
+
109
+ - [ESLint Plugin Development Guide](https://eslint.org/docs/latest/extend/plugins)
110
+ - [@typescript-eslint/utils Documentation](https://typescript-eslint.io/packages/utils/)
111
+ - [TypeScript ESLint Plugin Examples](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/src/rules)
@@ -0,0 +1,137 @@
1
+ ---
2
+ status: "accepted"
3
+ date: 2025-11-15
4
+ decision-makers: [Development Team]
5
+ consulted:
6
+ [
7
+ ESLint Community Best Practices,
8
+ Jest Documentation,
9
+ Vitest Documentation,
10
+ TypeScript ESLint Testing Patterns,
11
+ ]
12
+ informed: [Project Stakeholders, Future Contributors]
13
+ ---
14
+
15
+ # Use Jest for ESLint Plugin Testing
16
+
17
+ ## Context and Problem Statement
18
+
19
+ When developing an ESLint plugin in TypeScript that outputs CommonJS modules, we need to choose a testing framework for validating ESLint rules. The plugin will use ESLint's RuleTester for rule validation and needs to test complex AST manipulation logic. The choice of testing framework affects development experience, compatibility with ESLint tooling, and alignment with ecosystem practices, particularly given the CommonJS output requirement and ESLint-specific testing patterns.
20
+
21
+ ## Decision Drivers
22
+
23
+ - Compatibility with ESLint's RuleTester and rule testing patterns
24
+ - Support for CommonJS module testing (plugin output format)
25
+ - Integration with TypeScript source code testing
26
+ - Alignment with ESLint plugin development ecosystem practices
27
+ - Developer experience for writing and debugging tests
28
+ - Performance and reliability of test execution
29
+ - Support for ESLint-specific testing utilities and patterns
30
+ - Community adoption and long-term maintenance
31
+
32
+ ## Considered Options
33
+
34
+ - Jest with TypeScript support
35
+ - Vitest with CommonJS configuration
36
+ - Node.js built-in test runner with TypeScript
37
+
38
+ ## Decision Outcome
39
+
40
+ Chosen option: "Jest with TypeScript support", because it provides native CommonJS support essential for ESLint plugin testing, seamless integration with ESLint's RuleTester, follows established patterns in the ESLint ecosystem, and offers superior tooling for ESLint rule development without requiring complex configuration workarounds.
41
+
42
+ ### Consequences
43
+
44
+ - Good, because Jest works natively with CommonJS modules (no configuration needed)
45
+ - Good, because ESLint's RuleTester integrates seamlessly with Jest
46
+ - Good, because follows patterns used by @typescript-eslint and most ESLint plugins
47
+ - Good, because excellent TypeScript support through ts-jest
48
+ - Good, because mature ecosystem with extensive ESLint testing examples
49
+ - Good, because built-in mocking capabilities useful for file system operations
50
+ - Good, because snapshot testing can validate error message formats
51
+ - Bad, because Jest is slightly heavier than newer alternatives
52
+ - Bad, because not as fast as Vitest for some use cases
53
+ - Neutral, because requires ts-jest dependency for TypeScript support
54
+
55
+ ### Confirmation
56
+
57
+ Implementation compliance will be confirmed through:
58
+
59
+ - Jest configuration properly set up with ts-jest transformer
60
+ - ESLint RuleTester tests run successfully without module resolution errors
61
+ - All tests pass in CI/CD pipeline using Jest
62
+ - package.json scripts include Jest-based testing commands
63
+ - Test files use Jest APIs and follow Jest patterns
64
+ - TypeScript source files can be tested directly without compilation issues
65
+
66
+ ## Pros and Cons of the Options
67
+
68
+ ### Jest with TypeScript support
69
+
70
+ Jest is the most widely used testing framework in the ESLint ecosystem with mature TypeScript integration.
71
+
72
+ - Good, because native CommonJS support without configuration
73
+ - Good, because ESLint's RuleTester designed to work with Jest
74
+ - Good, because extensive use in @typescript-eslint project provides proven patterns
75
+ - Good, because excellent TypeScript support via ts-jest
76
+ - Good, because mature snapshot testing for validating rule outputs
77
+ - Good, because built-in mocking for testing file system operations
78
+ - Good, because extensive community knowledge and examples
79
+ - Good, because comprehensive assertion library and testing utilities
80
+ - Neutral, because larger bundle size than alternatives
81
+ - Neutral, because slower startup than Vitest
82
+ - Bad, because not as modern as newer testing frameworks
83
+
84
+ ### Vitest with CommonJS configuration
85
+
86
+ Vitest is a modern testing framework built on Vite with fast execution but requires configuration for CommonJS.
87
+
88
+ - Good, because very fast test execution and hot reloading
89
+ - Good, because modern API and excellent DX
90
+ - Good, because good TypeScript support out of the box
91
+ - Good, because lighter weight than Jest
92
+ - Neutral, because growing but smaller community than Jest
93
+ - Bad, because requires complex configuration for CommonJS compatibility
94
+ - Bad, because ESLint RuleTester integration not well-documented
95
+ - Bad, because fewer examples in ESLint plugin development
96
+ - Bad, because potential issues with CommonJS module transformation
97
+ - Bad, because ESM-first design conflicts with CommonJS requirement
98
+
99
+ ### Node.js built-in test runner with TypeScript
100
+
101
+ Node.js native test runner provides minimal testing without external dependencies.
102
+
103
+ - Good, because no external testing dependencies
104
+ - Good, because fast startup and execution
105
+ - Good, because growing support in Node.js ecosystem
106
+ - Neutral, because basic feature set may be sufficient for simple tests
107
+ - Bad, because no built-in TypeScript support (requires compilation)
108
+ - Bad, because no established patterns for ESLint rule testing
109
+ - Bad, because limited assertion library (requires additional dependencies)
110
+ - Bad, because no built-in mocking capabilities
111
+ - Bad, because minimal tooling and IDE integration
112
+ - Bad, because ESLint RuleTester compatibility unknown
113
+
114
+ ## More Information
115
+
116
+ This decision supports REQ-TEST-SETUP in story 001.0-DEV-PLUGIN-SETUP. The implementation should use ts-jest for TypeScript compilation and follow patterns established by @typescript-eslint project. ESLint's RuleTester should be the primary tool for rule validation testing.
117
+
118
+ Key implementation considerations:
119
+
120
+ - Use ts-jest transformer for TypeScript source testing
121
+ - Configure Jest to handle both source TypeScript and compiled CommonJS
122
+ - Follow ESLint RuleTester patterns for rule validation
123
+ - Include snapshot testing for error message validation
124
+ - Set up proper mocking for file system operations
125
+
126
+ This decision should be re-evaluated if:
127
+
128
+ - ESLint ecosystem moves away from Jest as standard
129
+ - CommonJS requirement changes for ESLint plugins
130
+ - Vitest significantly improves CommonJS support
131
+ - Team expertise with Jest becomes insufficient
132
+
133
+ Related resources:
134
+
135
+ - [ESLint RuleTester Documentation](https://eslint.org/docs/latest/integrate/nodejs-api#ruletester)
136
+ - [@typescript-eslint Testing Patterns](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/tests)
137
+ - [Jest with TypeScript Guide](https://jestjs.io/docs/getting-started#using-typescript)
@@ -0,0 +1,48 @@
1
+ ---
2
+ status: "accepted"
3
+ date: 2025-11-16
4
+ decision-makers: [Development Team]
5
+ consulted: [Implementation Plan, ESLint Documentation]
6
+ informed: [All Contributors]
7
+ ---
8
+
9
+ # 003-Code Quality Ratcheting Plan
10
+
11
+ ## Context and Decision Drivers
12
+
13
+ The project currently enforces maintainability through ESLint `max-lines-per-function` and `max-lines` rules with thresholds set to 200 lines/function and 1000 lines/file. These loose thresholds present technical debt and allow overly large functions and files, which can hinder readability, maintainability, and increase complexity over time.
14
+
15
+ ## Considered Options
16
+
17
+ 1. Adopt strict industry-standard thresholds immediately (e.g., 100 lines/function, 500 lines/file).
18
+ 2. Maintain the current loose thresholds indefinitely.
19
+ 3. Implement an incremental ratcheting plan to gradually reduce thresholds over multiple sprints.
20
+
21
+ ## Decision Outcome
22
+
23
+ We will implement option 3: an incremental ratcheting plan to gradually reduce the ESLint thresholds:
24
+
25
+ - **Sprint 0 (Now)**: Reduce `max-lines-per-function` to 150 and `max-lines` to 800.
26
+ - **Sprint 2 (Completed 2025-11-16)**: Reduce `max-lines-per-function` to 120 and `max-lines` to 600.
27
+ - **Sprint 4**: Reduce `max-lines-per-function` to 100 and `max-lines` to 500.
28
+
29
+ Automation:
30
+
31
+ - Update the ESLint configuration to enforce the new thresholds immediately.
32
+ - Configure the CI pipeline to fail on any new violations of these rules.
33
+ - Document the ratcheting schedule in this ADR and revisit the plan at each milestone.
34
+
35
+ ## Consequences
36
+
37
+ - Ensures maintainability improves in manageable increments, reducing developer overhead per sprint.
38
+ - Provides clear visibility into the schedule and expectations for code size reductions.
39
+ - Allows refactoring efforts to be planned and executed incrementally, avoiding large-scale rewrites.
40
+ - Guarantees continuous improvement by automating enforcement in CI.
41
+
42
+ ## Future Review
43
+
44
+ At the end of each milestone sprint, the team will:
45
+
46
+ - Review existing violations.
47
+ - Refactor code to comply with the new thresholds.
48
+ - Update this ADR if any adjustments to the schedule are required.