eslint-plugin-traceability 1.7.1 → 1.8.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.
- package/CHANGELOG.md +82 -0
- package/README.md +72 -32
- package/docs/ci-cd-pipeline.md +224 -0
- package/docs/cli-integration.md +22 -0
- package/docs/code-quality-refactor-opportunities-2025-12-03.md +78 -0
- package/docs/config-presets.md +38 -0
- package/docs/conventional-commits-guide.md +185 -0
- package/docs/custom-rules-development-guide.md +659 -0
- package/docs/decisions/0001-allow-dynamic-require-for-built-plugins.md +26 -0
- package/docs/decisions/001-typescript-for-eslint-plugin.accepted.md +111 -0
- package/docs/decisions/002-jest-for-eslint-testing.accepted.md +137 -0
- package/docs/decisions/003-code-quality-ratcheting-plan.md +48 -0
- package/docs/decisions/004-automated-version-bumping-for-ci-cd.md +196 -0
- package/docs/decisions/005-github-actions-validation-tooling.accepted.md +144 -0
- package/docs/decisions/006-semantic-release-for-automated-publishing.accepted.md +227 -0
- package/docs/decisions/007-github-releases-over-changelog.accepted.md +216 -0
- package/docs/decisions/008-ci-audit-flags.accepted.md +60 -0
- package/docs/decisions/009-security-focused-lint-rules.accepted.md +64 -0
- package/docs/decisions/010-implements-annotation-for-multi-story-requirements.proposed.md +184 -0
- package/docs/decisions/adr-0001-console-usage-for-cli-guards.md +190 -0
- package/docs/decisions/adr-accept-dev-dep-risk-glob.md +40 -0
- package/docs/decisions/adr-commit-branch-tests.md +54 -0
- package/docs/decisions/adr-maintenance-cli-interface.md +140 -0
- package/docs/decisions/adr-pre-push-parity.md +112 -0
- package/docs/decisions/code-quality-ratcheting-plan.md +53 -0
- package/docs/dependency-health.md +238 -0
- package/docs/eslint-9-setup-guide.md +517 -0
- package/docs/eslint-plugin-development-guide.md +487 -0
- package/docs/functionality-coverage-2025-12-03.md +250 -0
- package/docs/jest-testing-guide.md +100 -0
- package/docs/rules/prefer-implements-annotation.md +219 -0
- package/docs/rules/require-branch-annotation.md +71 -0
- package/docs/rules/require-req-annotation.md +203 -0
- package/docs/rules/require-story-annotation.md +159 -0
- package/docs/rules/valid-annotation-format.md +418 -0
- package/docs/rules/valid-req-reference.md +153 -0
- package/docs/rules/valid-story-reference.md +120 -0
- package/docs/security-incidents/2025-11-17-glob-cli-incident.md +45 -0
- package/docs/security-incidents/2025-11-18-brace-expansion-redos.md +45 -0
- package/docs/security-incidents/2025-11-18-bundled-dev-deps-accepted-risk.md +93 -0
- package/docs/security-incidents/2025-11-18-tar-race-condition.md +43 -0
- package/docs/security-incidents/2025-12-03-dependency-health-review.md +58 -0
- package/docs/security-incidents/SECURITY-INCIDENT-2025-11-18-semantic-release-bundled-npm.known-error.md +104 -0
- package/docs/security-incidents/SECURITY-INCIDENT-TEMPLATE.md +37 -0
- package/docs/security-incidents/dependency-override-rationale.md +57 -0
- package/docs/security-incidents/dev-deps-high.json +116 -0
- package/docs/security-incidents/handling-procedure.md +54 -0
- package/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md +92 -0
- package/docs/stories/002.0-DEV-ESLINT-CONFIG.story.md +82 -0
- package/docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md +112 -0
- package/docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md +153 -0
- package/docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md +138 -0
- package/docs/stories/006.0-DEV-FILE-VALIDATION.story.md +144 -0
- package/docs/stories/007.0-DEV-ERROR-REPORTING.story.md +163 -0
- package/docs/stories/008.0-DEV-AUTO-FIX.story.md +150 -0
- package/docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md +117 -0
- package/docs/stories/010.0-DEV-DEEP-VALIDATION.story.md +124 -0
- package/docs/stories/010.1-DEV-CONFIGURABLE-PATTERNS.story.md +149 -0
- package/docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md +216 -0
- package/docs/stories/010.3-DEV-MIGRATE-TO-IMPLEMENTS.story.md +236 -0
- package/docs/stories/developer-story.map.md +120 -0
- package/docs/ts-jest-presets-guide.md +548 -0
- package/lib/src/maintenance/batch.d.ts +5 -0
- package/lib/src/maintenance/batch.js +5 -0
- package/lib/src/maintenance/cli.js +34 -212
- package/lib/src/maintenance/commands.d.ts +32 -0
- package/lib/src/maintenance/commands.js +139 -0
- package/lib/src/maintenance/detect.d.ts +2 -0
- package/lib/src/maintenance/detect.js +4 -0
- package/lib/src/maintenance/flags.d.ts +99 -0
- package/lib/src/maintenance/flags.js +121 -0
- package/lib/src/maintenance/report.d.ts +2 -0
- package/lib/src/maintenance/report.js +2 -0
- package/lib/src/maintenance/update.d.ts +4 -0
- package/lib/src/maintenance/update.js +4 -0
- package/lib/src/rules/helpers/require-story-io.d.ts +3 -0
- package/lib/src/rules/helpers/require-story-io.js +20 -6
- package/lib/src/rules/helpers/valid-annotation-options.js +15 -4
- package/lib/src/rules/helpers/valid-annotation-utils.js +5 -0
- package/lib/src/rules/helpers/valid-story-reference-helpers.d.ts +3 -4
- package/lib/src/utils/reqAnnotationDetection.d.ts +4 -1
- package/lib/src/utils/reqAnnotationDetection.js +43 -15
- package/lib/tests/maintenance/cli.test.js +89 -0
- package/lib/tests/rules/require-req-annotation.test.js +8 -1
- package/lib/tests/rules/require-story-annotation.test.js +9 -4
- package/lib/tests/utils/ts-language-options.d.ts +1 -7
- package/lib/tests/utils/ts-language-options.js +8 -5
- package/package.json +7 -3
- package/user-docs/api-reference.md +507 -0
- package/user-docs/eslint-9-setup-guide.md +639 -0
- package/user-docs/examples.md +74 -0
- package/user-docs/migration-guide.md +158 -0
|
@@ -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.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: "superseded"
|
|
3
|
+
date: 2025-11-17
|
|
4
|
+
decision-makers: [Development Team]
|
|
5
|
+
consulted:
|
|
6
|
+
[
|
|
7
|
+
npm Documentation,
|
|
8
|
+
GitHub Actions Best Practices,
|
|
9
|
+
Semantic Versioning Specification,
|
|
10
|
+
]
|
|
11
|
+
informed: [Project Stakeholders, CI/CD Pipeline Maintainers]
|
|
12
|
+
superseded-by: "006-semantic-release-for-automated-publishing"
|
|
13
|
+
superseded-date: "2025-11-17"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Automated Version Bumping for CI/CD Publishing
|
|
17
|
+
|
|
18
|
+
## Context and Problem Statement
|
|
19
|
+
|
|
20
|
+
The current CI/CD pipeline attempts to publish the package to npm on every push to the main branch, but lacks any mechanism to automatically increment the package version. This causes publish failures when the same version number already exists on npm, as npm does not allow republishing the same version. The pipeline fails with errors like "You cannot publish over the previously published versions" or similar npm publish conflicts.
|
|
21
|
+
|
|
22
|
+
Currently, version bumping requires manual intervention through direct package.json edits, which is error-prone, interrupts the automated delivery flow, and creates a disconnect between the continuous integration process and package publishing. This breaks the principle of continuous delivery and creates friction in the development workflow.
|
|
23
|
+
|
|
24
|
+
## Decision Drivers
|
|
25
|
+
|
|
26
|
+
- Need for reliable automated publishing without manual intervention
|
|
27
|
+
- Prevention of npm publish failures due to version conflicts
|
|
28
|
+
- Alignment with semantic versioning principles for clear change communication
|
|
29
|
+
- Integration with existing CI/CD pipeline and GitHub workflow
|
|
30
|
+
- Maintainability of version history and changelog automation
|
|
31
|
+
- Support for different types of releases (patch, minor, major)
|
|
32
|
+
- Traceability of version changes to specific commits or pull requests
|
|
33
|
+
- Minimal friction for developers while maintaining version discipline
|
|
34
|
+
|
|
35
|
+
## Considered Options
|
|
36
|
+
|
|
37
|
+
- npm version command with automated execution in CI/CD
|
|
38
|
+
- Semantic Release with automated version detection
|
|
39
|
+
- Manual version bumping with CI/CD workflow triggers
|
|
40
|
+
- Version bumping through GitHub Actions with npm version
|
|
41
|
+
|
|
42
|
+
## Decision Outcome
|
|
43
|
+
|
|
44
|
+
Chosen option: "Version Increment Without Git Commits", because it eliminates CI/CD loop complexity, requires no git write permissions, solves the immediate npm publish failures, and provides the simplest implementation while maintaining full automation.
|
|
45
|
+
|
|
46
|
+
### Implementation Strategy
|
|
47
|
+
|
|
48
|
+
The CI/CD pipeline will use in-memory version increments without git write-back:
|
|
49
|
+
|
|
50
|
+
1. **Pre-publish Version Check**: Before attempting to publish, check if the current package.json version already exists on npm using `npm view eslint-plugin-traceability@<version>`
|
|
51
|
+
2. **In-Memory Version Increment**: If the version exists on npm, increment the patch version in the pipeline workspace using `npm version patch --no-git-tag-version`
|
|
52
|
+
3. **Immediate Publish**: Proceed with npm publish using the incremented version without any git operations
|
|
53
|
+
4. **Pipeline Logging**: Log the version increment action for visibility and debugging
|
|
54
|
+
5. **No Git Write-Back**: The incremented version exists only in the pipeline workspace and is never committed back to the repository
|
|
55
|
+
|
|
56
|
+
### Primary Approach Considered
|
|
57
|
+
|
|
58
|
+
**Git Write-Back with Version Commits**: Increment version in pipeline, publish to npm, then commit version changes and create git tags with `[skip ci]` to prevent recursion. This approach was rejected due to complexity concerns including git write permissions, infinite loop prevention, post-publish failure handling, and potential race conditions in concurrent pipeline runs.
|
|
59
|
+
|
|
60
|
+
### Consequences
|
|
61
|
+
|
|
62
|
+
- Good, because prevents all npm publish failures due to version conflicts
|
|
63
|
+
- Good, because maintains fully automated delivery without any manual intervention
|
|
64
|
+
- Good, because eliminates infinite CI/CD loop risks entirely
|
|
65
|
+
- Good, because requires no git write permissions or credentials in CI/CD
|
|
66
|
+
- Good, because uses standard npm tooling that developers understand
|
|
67
|
+
- Good, because simplest possible implementation with minimal failure modes
|
|
68
|
+
- Good, because each pipeline run is completely independent
|
|
69
|
+
- Good, because immediate resolution to publish failures with no complexity overhead
|
|
70
|
+
- Neutral, because package.json version may lag behind published npm version
|
|
71
|
+
- Neutral, because developers can check published version via `npm view eslint-plugin-traceability version`
|
|
72
|
+
- Bad, because does not automatically determine semantic version type (major/minor/patch)
|
|
73
|
+
- Bad, because no automatic git tags or version history created
|
|
74
|
+
|
|
75
|
+
### Confirmation
|
|
76
|
+
|
|
77
|
+
Implementation compliance will be confirmed through:
|
|
78
|
+
|
|
79
|
+
- CI/CD pipeline successfully publishes without version conflicts
|
|
80
|
+
- No npm publish failures due to existing version numbers
|
|
81
|
+
- No git write operations or credentials required in CI/CD
|
|
82
|
+
- No infinite pipeline loops or `[skip ci]` complexity needed
|
|
83
|
+
- Pipeline logs clearly show when version increments occur
|
|
84
|
+
- Published npm versions can be verified via `npm view eslint-plugin-traceability versions`
|
|
85
|
+
- No manual intervention required for routine publishing
|
|
86
|
+
|
|
87
|
+
## Pros and Cons of the Options
|
|
88
|
+
|
|
89
|
+
### Version Increment Without Git Commits
|
|
90
|
+
|
|
91
|
+
In-memory version increments during pipeline execution without any git write-back operations.
|
|
92
|
+
|
|
93
|
+
- Good, because eliminates all CI/CD loop complexity and infinite recursion risks
|
|
94
|
+
- Good, because requires no git write permissions or credentials in CI/CD environment
|
|
95
|
+
- Good, because simplest possible implementation with minimal failure modes
|
|
96
|
+
- Good, because each pipeline run is completely independent with no race conditions
|
|
97
|
+
- Good, because immediate resolution to npm publish failures
|
|
98
|
+
- Good, because uses standard npm version tooling familiar to developers
|
|
99
|
+
- Good, because no complex error handling for git operations required
|
|
100
|
+
- Neutral, because package.json version may not reflect latest published version
|
|
101
|
+
- Neutral, because published version always discoverable via npm registry
|
|
102
|
+
- Bad, because no automatic git tags created for release tracking
|
|
103
|
+
- Bad, because requires manual version management for major/minor releases
|
|
104
|
+
- Bad, because no automated version commit history
|
|
105
|
+
|
|
106
|
+
### Git Write-Back with Version Commits
|
|
107
|
+
|
|
108
|
+
Increment version in pipeline, publish to npm, then commit version changes and create git tags.
|
|
109
|
+
|
|
110
|
+
- Good, because creates proper git tags and version commits automatically
|
|
111
|
+
- Good, because maintains package.json synchronization with published versions
|
|
112
|
+
- Good, because provides complete version history in git repository
|
|
113
|
+
- Good, because allows for automated CHANGELOG.md updates
|
|
114
|
+
- Good, because follows traditional npm ecosystem patterns
|
|
115
|
+
- Neutral, because requires configuration of git credentials in CI/CD
|
|
116
|
+
- Neutral, because creates automated commits with CI skip directives
|
|
117
|
+
- Bad, because requires complex infinite loop prevention with `[skip ci]`
|
|
118
|
+
- Bad, because potential for git write failures after successful npm publish
|
|
119
|
+
- Bad, because introduces race conditions in concurrent pipeline runs
|
|
120
|
+
- Bad, because requires git write permissions and credential management
|
|
121
|
+
- Bad, because adds multiple failure modes beyond the core publish operation
|
|
122
|
+
|
|
123
|
+
### Semantic Release with automated version detection
|
|
124
|
+
|
|
125
|
+
Automated semantic versioning based on commit message analysis and release automation.
|
|
126
|
+
|
|
127
|
+
- Good, because fully automated semantic version determination
|
|
128
|
+
- Good, because analyzes commit messages for version type
|
|
129
|
+
- Good, because comprehensive release note generation
|
|
130
|
+
- Good, because follows semantic versioning specification strictly
|
|
131
|
+
- Good, because popular in open source ecosystem
|
|
132
|
+
- Neutral, because requires standardized commit message format
|
|
133
|
+
- Bad, because adds significant complexity to CI/CD pipeline
|
|
134
|
+
- Bad, because requires team discipline for commit message formatting
|
|
135
|
+
- Bad, because may be overkill for the current project size
|
|
136
|
+
- Bad, because introduces external dependency on semantic-release tool
|
|
137
|
+
- Bad, because harder to override for exceptional cases
|
|
138
|
+
|
|
139
|
+
### Manual version bumping with CI/CD workflow triggers
|
|
140
|
+
|
|
141
|
+
Requiring manual version increments before publishing with workflow validation.
|
|
142
|
+
|
|
143
|
+
- Good, because provides full developer control over versioning
|
|
144
|
+
- Good, because ensures deliberate version decisions
|
|
145
|
+
- Good, because no automated commits or git history noise
|
|
146
|
+
- Good, because simple to understand and implement
|
|
147
|
+
- Neutral, because requires developer discipline for version management
|
|
148
|
+
- Bad, because breaks continuous delivery principle
|
|
149
|
+
- Bad, because requires manual intervention for every release
|
|
150
|
+
- Bad, because prone to human error and forgotten version bumps
|
|
151
|
+
- Bad, because does not solve the original npm publish failure problem
|
|
152
|
+
- Bad, because creates friction in development workflow
|
|
153
|
+
|
|
154
|
+
## More Information
|
|
155
|
+
|
|
156
|
+
This decision addresses the immediate CI/CD publish failures with the simplest possible solution that eliminates complexity while maintaining full automation. The in-memory version increment approach provides immediate relief from npm publish conflicts without introducing git write-back complexity.
|
|
157
|
+
|
|
158
|
+
Key implementation details:
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
- name: Prepare version for publish
|
|
162
|
+
run: |
|
|
163
|
+
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
|
164
|
+
echo "Current package.json version: $CURRENT_VERSION"
|
|
165
|
+
|
|
166
|
+
# Check if this version exists on npm
|
|
167
|
+
if npm view eslint-plugin-traceability@$CURRENT_VERSION version >/dev/null 2>&1; then
|
|
168
|
+
echo "Version $CURRENT_VERSION already exists on npm, incrementing..."
|
|
169
|
+
npm version patch --no-git-tag-version
|
|
170
|
+
NEW_VERSION=$(node -p "require('./package.json').version")
|
|
171
|
+
echo "Bumped version to: $NEW_VERSION"
|
|
172
|
+
else
|
|
173
|
+
echo "Version $CURRENT_VERSION is available, proceeding with publish"
|
|
174
|
+
fi
|
|
175
|
+
|
|
176
|
+
- name: Publish package
|
|
177
|
+
run: npm publish --access public
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Implementation considerations:
|
|
181
|
+
|
|
182
|
+
- No git credentials or write permissions required in CI/CD
|
|
183
|
+
- Version increments are logged for visibility and debugging
|
|
184
|
+
- Each pipeline run operates independently with no side effects
|
|
185
|
+
- Published versions remain discoverable via `npm view eslint-plugin-traceability versions`
|
|
186
|
+
- Manual version bumps for major/minor releases can still be done via git commits
|
|
187
|
+
- Future migration to git write-back approach remains possible if needed
|
|
188
|
+
|
|
189
|
+
This decision should be re-evaluated if:
|
|
190
|
+
|
|
191
|
+
- Package.json/npm version drift becomes problematic for development workflow
|
|
192
|
+
- Automatic git tagging becomes a requirement for release management
|
|
193
|
+
- The team adopts semantic versioning discipline requiring commit message analysis
|
|
194
|
+
- Integration with automated changelog generation becomes necessary
|
|
195
|
+
|
|
196
|
+
The simplicity of this approach allows for easy migration to more complex solutions later while solving the immediate problem with minimal risk and complexity.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: "accepted"
|
|
3
|
+
date: 2025-11-17
|
|
4
|
+
decision-makers: [Development Team]
|
|
5
|
+
consulted:
|
|
6
|
+
[
|
|
7
|
+
GitHub Actions Documentation,
|
|
8
|
+
Super-Linter Community,
|
|
9
|
+
actionlint Documentation,
|
|
10
|
+
]
|
|
11
|
+
informed: [Project Contributors, CI/CD Pipeline Maintainers]
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# GitHub Actions Validation Tooling Selection
|
|
15
|
+
|
|
16
|
+
## Context and Problem Statement
|
|
17
|
+
|
|
18
|
+
The project uses GitHub Actions for CI/CD workflows defined in `.github/workflows/`. To prevent broken GitHub Actions files from being pushed to the repository, we need to implement pre-commit validation for GitHub Actions YAML files. This validation should catch syntax errors, invalid action references, and misconfigured job dependencies before they are committed, as broken workflow files could prevent CI/CD from running at all.
|
|
19
|
+
|
|
20
|
+
## Decision Drivers
|
|
21
|
+
|
|
22
|
+
- Need for pre-commit validation to prevent broken GitHub Actions files from being pushed
|
|
23
|
+
- Performance requirements for fast local development workflows
|
|
24
|
+
- Prevention of workflow files that would break CI/CD execution
|
|
25
|
+
- Integration with existing development tools and pre-commit hooks
|
|
26
|
+
- Maintainability and configuration simplicity
|
|
27
|
+
- Resource efficiency for local development environments
|
|
28
|
+
|
|
29
|
+
## Considered Options
|
|
30
|
+
|
|
31
|
+
- actionlint for pre-commit hooks only
|
|
32
|
+
- actionlint for both pre-commit and CI/CD
|
|
33
|
+
- Super-Linter for pre-commit hooks
|
|
34
|
+
- GitHub's built-in validation only
|
|
35
|
+
|
|
36
|
+
## Decision Outcome
|
|
37
|
+
|
|
38
|
+
Chosen option: "actionlint for pre-commit hooks only", because it prevents broken GitHub Actions files from being pushed while maintaining fast local development workflow. Once files reach CI/CD, if the workflow runs successfully, the files are valid by definition.
|
|
39
|
+
|
|
40
|
+
### Consequences
|
|
41
|
+
|
|
42
|
+
- Good, because actionlint provides fast pre-commit validation without container overhead
|
|
43
|
+
- Good, because prevents broken GitHub Actions files from being pushed
|
|
44
|
+
- Good, because specifically designed for GitHub Actions validation
|
|
45
|
+
- Good, because simple configuration and maintenance
|
|
46
|
+
- Good, because no Docker dependencies for local development
|
|
47
|
+
- Good, because excellent performance for pre-commit hooks
|
|
48
|
+
- Good, because integrates seamlessly with existing Husky-based pre-commit hooks
|
|
49
|
+
- Neutral, because CI/CD validation is unnecessary if workflows execute successfully
|
|
50
|
+
- Bad, because limited to GitHub Actions validation only
|
|
51
|
+
- Bad, because no security vulnerability detection in pre-commit phase
|
|
52
|
+
|
|
53
|
+
### Confirmation
|
|
54
|
+
|
|
55
|
+
Implementation compliance will be confirmed through:
|
|
56
|
+
|
|
57
|
+
- actionlint added to Husky pre-commit hook in `.husky/pre-commit`
|
|
58
|
+
- Pre-commit hook blocks commits with GitHub Actions validation errors
|
|
59
|
+
- actionlint configured to validate files in `.github/workflows/`
|
|
60
|
+
- Documentation updated to explain Husky-based pre-commit validation approach
|
|
61
|
+
|
|
62
|
+
### Implementation Approach
|
|
63
|
+
|
|
64
|
+
actionlint will be integrated into existing Husky-based pre-commit hooks by:
|
|
65
|
+
|
|
66
|
+
- Installing actionlint as a development dependency
|
|
67
|
+
- Adding actionlint validation to `.husky/pre-commit` hook
|
|
68
|
+
- Configuring actionlint to check `.github/workflows/*.yml` files
|
|
69
|
+
- Documenting the validation process for contributors
|
|
70
|
+
|
|
71
|
+
## Pros and Cons of the Options
|
|
72
|
+
|
|
73
|
+
### actionlint for pre-commit hooks only
|
|
74
|
+
|
|
75
|
+
Lightweight, focused pre-commit validation to prevent broken GitHub Actions files.
|
|
76
|
+
|
|
77
|
+
- Good, because fast execution without container overhead
|
|
78
|
+
- Good, because specifically designed for GitHub Actions validation
|
|
79
|
+
- Good, because no Docker dependencies for local development
|
|
80
|
+
- Good, because simple configuration and maintenance
|
|
81
|
+
- Good, because excellent performance for pre-commit hooks
|
|
82
|
+
- Good, because prevents broken workflow files from being pushed
|
|
83
|
+
- Good, because minimal tooling - only runs where validation is needed
|
|
84
|
+
- Neutral, because focused scope reduces complexity
|
|
85
|
+
- Neutral, because CI/CD validation unnecessary if workflows execute successfully
|
|
86
|
+
- Bad, because limited to GitHub Actions validation only
|
|
87
|
+
- Bad, because no security vulnerability detection in pre-commit phase
|
|
88
|
+
|
|
89
|
+
### actionlint for both pre-commit and CI/CD
|
|
90
|
+
|
|
91
|
+
Validation in both development and CI/CD environments.
|
|
92
|
+
|
|
93
|
+
- Good, because fast execution in all environments
|
|
94
|
+
- Good, because specifically designed for GitHub Actions
|
|
95
|
+
- Good, because consistent validation across environments
|
|
96
|
+
- Neutral, because focused scope reduces complexity
|
|
97
|
+
- Bad, because unnecessary duplication - CI/CD execution validates workflow correctness
|
|
98
|
+
- Bad, because adds CI/CD overhead for validation that's already proven by execution
|
|
99
|
+
- Bad, because limited to GitHub Actions validation only
|
|
100
|
+
|
|
101
|
+
### Super-Linter for pre-commit hooks
|
|
102
|
+
|
|
103
|
+
Comprehensive linting solution for pre-commit validation.
|
|
104
|
+
|
|
105
|
+
- Good, because comprehensive validation including security checks
|
|
106
|
+
- Good, because validates multiple file types beyond GitHub Actions
|
|
107
|
+
- Neutral, because well-maintained and widely adopted
|
|
108
|
+
- Bad, because container overhead makes pre-commit hooks slow
|
|
109
|
+
- Bad, because heavy resource usage for simple syntax checking
|
|
110
|
+
- Bad, because Docker dependency required for local development
|
|
111
|
+
- Bad, because not optimized for frequent pre-commit execution
|
|
112
|
+
- Bad, because overkill for the specific problem of preventing broken workflow files
|
|
113
|
+
|
|
114
|
+
### GitHub's built-in validation only
|
|
115
|
+
|
|
116
|
+
Rely solely on GitHub's native workflow validation.
|
|
117
|
+
|
|
118
|
+
- Good, because no additional tooling or configuration required
|
|
119
|
+
- Good, because automatically available in GitHub interface
|
|
120
|
+
- Good, because validated by the same system that executes workflows
|
|
121
|
+
- Neutral, because basic validation is always performed
|
|
122
|
+
- Bad, because no pre-commit validation for early error detection
|
|
123
|
+
- Bad, because broken files can be pushed, preventing CI/CD execution
|
|
124
|
+
- Bad, because errors only discovered after push to repository
|
|
125
|
+
- Bad, because no local development feedback
|
|
126
|
+
|
|
127
|
+
## More Information
|
|
128
|
+
|
|
129
|
+
This decision focuses on solving the specific problem of preventing broken GitHub Actions files from being pushed to the repository. If CI/CD workflows execute successfully, the files are validated by definition - there's no need for redundant validation in the CI/CD pipeline itself.
|
|
130
|
+
|
|
131
|
+
actionlint configuration should be added to the existing Husky pre-commit hook in `.husky/pre-commit`, targeting `.github/workflows/*.yml` files to catch syntax and configuration errors before commit.
|
|
132
|
+
|
|
133
|
+
The decision should be re-evaluated if:
|
|
134
|
+
|
|
135
|
+
- Security vulnerability detection becomes a requirement for pre-commit validation
|
|
136
|
+
- Comprehensive multi-language linting becomes necessary for pre-commit
|
|
137
|
+
- Alternative tools with better GitHub Actions-specific features emerge
|
|
138
|
+
- The problem scope expands beyond preventing broken workflow files
|
|
139
|
+
|
|
140
|
+
Related resources:
|
|
141
|
+
|
|
142
|
+
- [actionlint Documentation](https://github.com/rhymond/actionlint)
|
|
143
|
+
- [GitHub Actions Workflow Syntax](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions)
|
|
144
|
+
- [Husky Documentation](https://typicode.github.io/husky/)
|