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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# [1.8.0](https://github.com/voder-ai/eslint-plugin-traceability/compare/v1.7.1...v1.8.0) (2025-12-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* accept [@implements](https://github.com/implements) annotations in require rules ([bdf0994](https://github.com/voder-ai/eslint-plugin-traceability/commit/bdf0994f0d0e16bd751fbd89c08c67bddee52c16))
|
|
7
|
+
|
|
8
|
+
# Changelog
|
|
9
|
+
|
|
10
|
+
This project uses automated release management via [semantic-release](https://semantic-release.gitbook.io/).
|
|
11
|
+
|
|
12
|
+
For detailed release notes and changelog information, please see:
|
|
13
|
+
|
|
14
|
+
**[GitHub Releases](https://github.com/voder-ai/eslint-plugin-traceability/releases)**
|
|
15
|
+
|
|
16
|
+
Each release includes:
|
|
17
|
+
- Detailed change descriptions
|
|
18
|
+
- Commit references
|
|
19
|
+
- Breaking changes (if any)
|
|
20
|
+
- Migration notes (when applicable)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Historical Changelog (Prior to Automated Releases)
|
|
25
|
+
|
|
26
|
+
The following entries were maintained manually before the adoption of semantic-release. Current and future releases are documented exclusively on the GitHub Releases page.
|
|
27
|
+
|
|
28
|
+
### [1.0.5] - 2025-11-17
|
|
29
|
+
|
|
30
|
+
**Changed**
|
|
31
|
+
- Lowered maintainability thresholds to 70 lines/function and 300 lines/file in ESLint config.
|
|
32
|
+
- Added override for 'tar' package to mitigate moderate vulnerabilities.
|
|
33
|
+
|
|
34
|
+
### [1.0.4] - 2025-11-17
|
|
35
|
+
|
|
36
|
+
**Fixed**
|
|
37
|
+
- Ensured temporary directories are cleaned up in maintenance tests for detect and update functions.
|
|
38
|
+
- Refactored valid-req-reference rule to reduce function length and added explicit type annotations.
|
|
39
|
+
|
|
40
|
+
### [1.0.3] - 2025-11-17
|
|
41
|
+
|
|
42
|
+
**Added**
|
|
43
|
+
- CLI integration script (`cli-integration.js`) for end-to-end ESLint CLI tests.
|
|
44
|
+
- Migration guide in [`user-docs/migration-guide.md`](user-docs/migration-guide.md).
|
|
45
|
+
|
|
46
|
+
### [1.0.2] - 2025-11-17
|
|
47
|
+
|
|
48
|
+
**Changed**
|
|
49
|
+
- Updated README and docs to reference `cli-integration.js` script.
|
|
50
|
+
- Removed stale references to migration guide in CHANGELOG gradients.
|
|
51
|
+
|
|
52
|
+
### [1.0.1] - 2025-11-17
|
|
53
|
+
|
|
54
|
+
**Added**
|
|
55
|
+
- Detailed API documentation in [`user-docs/api-reference.md`](user-docs/api-reference.md)
|
|
56
|
+
- New usage examples in [`user-docs/examples.md`](user-docs/examples.md)
|
|
57
|
+
|
|
58
|
+
**Changed**
|
|
59
|
+
- Updated `README.md` with advanced usage instructions and migration guide
|
|
60
|
+
- Consolidated CI workflows into a unified GitHub Actions pipeline
|
|
61
|
+
|
|
62
|
+
### [1.0.0] - 2025-11-16
|
|
63
|
+
|
|
64
|
+
**Changed**
|
|
65
|
+
- Bumped version to 1.0.0 in package.json.
|
|
66
|
+
- Aligned CHANGELOG with package.json version.
|
|
67
|
+
|
|
68
|
+
### [0.1.0] - 2025-11-16
|
|
69
|
+
|
|
70
|
+
**Added**
|
|
71
|
+
- Initial release of `eslint-plugin-traceability`:
|
|
72
|
+
- `require-story-annotation`
|
|
73
|
+
- `require-req-annotation`
|
|
74
|
+
- `require-branch-annotation`
|
|
75
|
+
- `valid-annotation-format`
|
|
76
|
+
- `valid-story-reference`
|
|
77
|
+
- `valid-req-reference`
|
|
78
|
+
- Documentation for all rules under `docs/rules`.
|
|
79
|
+
- Configuration presets in `docs/config-presets.md`.
|
|
80
|
+
- Example usage in `README.md`.
|
|
81
|
+
- Pre-commit and pre-push hooks with formatting, linting, and tests.
|
|
82
|
+
- Comprehensive tests covering core validation rules.
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Prerequisites: Node.js >=18.18.0 and ESLint v9+.
|
|
|
15
15
|
2. Using Yarn
|
|
16
16
|
yarn add --dev eslint-plugin-traceability
|
|
17
17
|
|
|
18
|
-
For detailed setup with ESLint v9, see user-docs/eslint-9-setup-guide.md.
|
|
18
|
+
For detailed setup with ESLint v9, see the [ESLint v9 Setup Guide](user-docs/eslint-9-setup-guide.md).
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
@@ -26,24 +26,16 @@ Additional ESLint v9 configuration guidance:
|
|
|
26
26
|
- For detailed configuration examples, see [Common Configuration Patterns](user-docs/eslint-9-setup-guide.md#common-configuration-patterns) in the ESLint 9 Setup Guide.
|
|
27
27
|
- For troubleshooting ESLint flat-config errors, see [Troubleshooting ESLint Configuration](user-docs/eslint-9-setup-guide.md#troubleshooting-eslint-configuration).
|
|
28
28
|
|
|
29
|
-
Example eslint.config.js (ESLint v9 flat config):
|
|
29
|
+
Example `eslint.config.js` (ESLint v9 flat config):
|
|
30
|
+
|
|
31
|
+
This example shows the recommended starting point using the plugin's recommended preset alongside ESLint's recommended config:
|
|
30
32
|
|
|
31
33
|
```js
|
|
32
34
|
// eslint.config.js
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
node: true,
|
|
38
|
-
},
|
|
39
|
-
plugins: { traceability: {} },
|
|
40
|
-
rules: {
|
|
41
|
-
"traceability/require-story-annotation": "error",
|
|
42
|
-
"traceability/require-req-annotation": "error",
|
|
43
|
-
"traceability/require-branch-annotation": "error",
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
];
|
|
35
|
+
import js from "@eslint/js";
|
|
36
|
+
import traceability from "eslint-plugin-traceability";
|
|
37
|
+
|
|
38
|
+
export default [js.configs.recommended, traceability.configs.recommended];
|
|
47
39
|
```
|
|
48
40
|
|
|
49
41
|
### Available Rules
|
|
@@ -56,9 +48,9 @@ module.exports = [
|
|
|
56
48
|
- `traceability/valid-req-reference` Validates that `@req` references point to existing requirement IDs. ([Documentation](docs/rules/valid-req-reference.md))
|
|
57
49
|
- `traceability/prefer-implements-annotation` Recommends migration from legacy `@story`/`@req` annotations to `@implements` (disabled by default). ([Documentation](docs/rules/prefer-implements-annotation.md))
|
|
58
50
|
|
|
59
|
-
Configuration options: For detailed per-rule options (such as scopes, branch types, and story directory settings), see the individual rule docs in `docs/rules/` and the consolidated [API Reference](user-docs/api-reference.md).
|
|
51
|
+
Configuration options: For detailed per-rule options (such as scopes, branch types, and story directory settings), see the individual rule docs in [`docs/rules/`](docs/rules) and the consolidated [API Reference](user-docs/api-reference.md).
|
|
60
52
|
|
|
61
|
-
For development and contribution guidelines, see docs/eslint-plugin-development-guide.md.
|
|
53
|
+
For development and contribution guidelines, see the [ESLint Plugin Development Guide](docs/eslint-plugin-development-guide.md).
|
|
62
54
|
|
|
63
55
|
## Quick Start
|
|
64
56
|
|
|
@@ -78,7 +70,8 @@ export default [
|
|
|
78
70
|
|
|
79
71
|
```js
|
|
80
72
|
/**
|
|
81
|
-
* @story
|
|
73
|
+
* @story stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
74
|
+
* // Point this to your own project's story/requirements file, not to this plugin's internal docs.
|
|
82
75
|
* @req REQ-ANNOTATION-REQUIRED
|
|
83
76
|
*/
|
|
84
77
|
function initAuth() {
|
|
@@ -188,18 +181,65 @@ npm test
|
|
|
188
181
|
|
|
189
182
|
These tests verify end-to-end behavior of the plugin via the ESLint CLI.
|
|
190
183
|
|
|
184
|
+
## Security and Dependency Health
|
|
185
|
+
|
|
186
|
+
### What end users can expect from production dependencies
|
|
187
|
+
|
|
188
|
+
- The published `eslint-plugin-traceability` package is intended to ship **only with production dependencies that have no known high‑severity vulnerabilities** at release time.
|
|
189
|
+
- As part of CI and the local pre‑push hook, we run:
|
|
190
|
+
- `npm audit --omit=dev --audit-level=high` – this checks only the **runtime (prod) dependency graph** and fails if any high‑severity issues are reported.
|
|
191
|
+
- This means:
|
|
192
|
+
- Known high‑severity issues in production dependencies are blocked before a version is released.
|
|
193
|
+
- Dev‑only tooling and CI infrastructure are kept separate from what you install via `npm install eslint-plugin-traceability`.
|
|
194
|
+
|
|
195
|
+
### How `dry-aged-deps` and `npm audit` work together
|
|
196
|
+
|
|
197
|
+
- **Maturity checks via `dry-aged-deps`**
|
|
198
|
+
- We use `dry-aged-deps` (via `npm run deps:maturity` and `npm run safety:deps`) to enforce basic “maturity” constraints on dependency updates.
|
|
199
|
+
- Current policy for adopting new versions:
|
|
200
|
+
- **Minimum age:** new versions are typically required to be **at least 7 days old**, reducing the chance of adopting a just‑released, unvetted version.
|
|
201
|
+
- **No known vulnerabilities:** versions with known vulnerabilities are rejected.
|
|
202
|
+
- **Security scan via `npm audit`**
|
|
203
|
+
- `npm audit --omit=dev --audit-level=high` is run on the **production dependency tree** to catch known high‑severity issues before release.
|
|
204
|
+
- **Combined effect**
|
|
205
|
+
- `dry-aged-deps` controls **which versions** we are willing to upgrade to (age + no‑known‑vulns).
|
|
206
|
+
- `npm audit` validates that the **current, locked set of production dependencies** is free from known high‑severity vulnerabilities.
|
|
207
|
+
- Together, they provide a conservative, security‑focused process for dependency updates that directly affect end users.
|
|
208
|
+
|
|
209
|
+
### Scope of the semantic‑release/npm tooling risk
|
|
210
|
+
|
|
211
|
+
- There is a known, documented risk in the semantic‑release/npm release toolchain related to bundled `npm`/`glob`/`brace-expansion`.
|
|
212
|
+
- This risk:
|
|
213
|
+
- Applies only to the **GitHub Actions release workflow and related dev‑only tooling**.
|
|
214
|
+
- Does **not** modify or run inside consumers’ projects.
|
|
215
|
+
- Does **not** affect the built plugin artifacts published to npm.
|
|
216
|
+
- In other words:
|
|
217
|
+
- The issue is confined to the CI environment that prepares and publishes releases.
|
|
218
|
+
- It **cannot impact** the runtime behavior or dependency graph of the `eslint-plugin-traceability` package you install or use in your own projects.
|
|
219
|
+
|
|
220
|
+
### Optional deeper background
|
|
221
|
+
|
|
222
|
+
For readers who want more context on the dependency and security model (not required to use the plugin):
|
|
223
|
+
|
|
224
|
+
- Dependency health overview: [docs/dependency-health.md](docs/dependency-health.md)
|
|
225
|
+
- Detailed incident note about the semantic‑release/npm toolchain risk:
|
|
226
|
+
[docs/security-incidents/SECURITY-INCIDENT-2025-11-18-semantic-release-bundled-npm.known-error.md](docs/security-incidents/SECURITY-INCIDENT-2025-11-18-semantic-release-bundled-npm.known-error.md)
|
|
227
|
+
|
|
228
|
+
These documents are informational and describe internal processes and known toolchain limitations; they do not change the guarantees described above for end users.
|
|
229
|
+
|
|
191
230
|
## Documentation Links
|
|
192
231
|
|
|
193
|
-
- ESLint v9 Setup Guide: user-docs/eslint-9-setup-guide.md
|
|
194
|
-
- Plugin Development Guide: docs/eslint-plugin-development-guide.md
|
|
195
|
-
- API Reference: user-docs/api-reference.md
|
|
196
|
-
- Examples: user-docs/examples.md
|
|
197
|
-
- Migration Guide: user-docs/migration-guide.md
|
|
198
|
-
- Full README: https://github.com/voder-ai/eslint-plugin-traceability#readme
|
|
199
|
-
- Rule: require-story-annotation: docs/rules/require-story-annotation.md
|
|
200
|
-
- Rule: require-req-annotation: docs/rules/require-req-annotation.md
|
|
201
|
-
- Rule: require-branch-annotation: docs/rules/require-branch-annotation.md
|
|
202
|
-
- Contribution guide: https://github.com/voder-ai/eslint-plugin-traceability/blob/main/CONTRIBUTING.md
|
|
203
|
-
- Issue tracker: https://github.com/voder-ai/eslint-plugin-traceability/issues
|
|
204
|
-
- Configuration Presets: docs/config-presets.md
|
|
205
|
-
- Changelog: CHANGELOG.md
|
|
232
|
+
- ESLint v9 Setup Guide: [user-docs/eslint-9-setup-guide.md](user-docs/eslint-9-setup-guide.md)
|
|
233
|
+
- Plugin Development Guide: [docs/eslint-plugin-development-guide.md](docs/eslint-plugin-development-guide.md)
|
|
234
|
+
- API Reference: [user-docs/api-reference.md](user-docs/api-reference.md)
|
|
235
|
+
- Examples: [user-docs/examples.md](user-docs/examples.md)
|
|
236
|
+
- Migration Guide: [user-docs/migration-guide.md](user-docs/migration-guide.md)
|
|
237
|
+
- Full README: <https://github.com/voder-ai/eslint-plugin-traceability#readme>
|
|
238
|
+
- Rule: require-story-annotation: [docs/rules/require-story-annotation.md](docs/rules/require-story-annotation.md)
|
|
239
|
+
- Rule: require-req-annotation: [docs/rules/require-req-annotation.md](docs/rules/require-req-annotation.md)
|
|
240
|
+
- Rule: require-branch-annotation: [docs/rules/require-branch-annotation.md](docs/rules/require-branch-annotation.md)
|
|
241
|
+
- Contribution guide: <https://github.com/voder-ai/eslint-plugin-traceability/blob/main/CONTRIBUTING.md>
|
|
242
|
+
- Issue tracker: <https://github.com/voder-ai/eslint-plugin-traceability/issues>
|
|
243
|
+
- Configuration Presets: [docs/config-presets.md](docs/config-presets.md)
|
|
244
|
+
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
245
|
+
- Versioning and Releases: This project uses semantic-release for automated versioning. The authoritative list of published versions and release notes is on GitHub Releases: <https://github.com/voder-ai/eslint-plugin-traceability/releases>
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# CI/CD Pipeline and Continuous Deployment
|
|
2
|
+
|
|
3
|
+
This document describes how continuous integration and continuous deployment are implemented for `eslint-plugin-traceability`, and how it relates to our architecture decisions.
|
|
4
|
+
|
|
5
|
+
- Related ADRs:
|
|
6
|
+
- `docs/decisions/006-semantic-release-for-automated-publishing.accepted.md`
|
|
7
|
+
- `docs/decisions/007-github-releases-over-changelog.accepted.md`
|
|
8
|
+
- `docs/decisions/005-github-actions-validation-tooling.accepted.md`
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
We use a **single unified GitHub Actions workflow** to run all quality checks and, on successful main-branch builds, to automatically publish new versions to npm and create GitHub Releases.
|
|
13
|
+
|
|
14
|
+
- Workflow file: `.github/workflows/ci-cd.yml`
|
|
15
|
+
- Workflow name: `CI/CD Pipeline`
|
|
16
|
+
- Triggers:
|
|
17
|
+
- `push` to `main`
|
|
18
|
+
- `pull_request` targeting `main`
|
|
19
|
+
- Nightly `schedule` for dependency health checks
|
|
20
|
+
|
|
21
|
+
There are no tag-based triggers and no manual `workflow_dispatch` jobs for releases. Publishing (when needed) always happens as part of the same workflow run that executes the quality gates.
|
|
22
|
+
|
|
23
|
+
## Jobs
|
|
24
|
+
|
|
25
|
+
### 1. `quality-and-deploy`
|
|
26
|
+
|
|
27
|
+
Runs on:
|
|
28
|
+
|
|
29
|
+
- Every `push` to `main`
|
|
30
|
+
- Every `pull_request` targeting `main`
|
|
31
|
+
|
|
32
|
+
Matrix:
|
|
33
|
+
|
|
34
|
+
- Node `18.x`
|
|
35
|
+
- Node `20.x`
|
|
36
|
+
|
|
37
|
+
Key steps (in order):
|
|
38
|
+
|
|
39
|
+
1. **Checkout & Node setup**
|
|
40
|
+
- `actions/checkout@v4` with full history (needed for semantic-release)
|
|
41
|
+
- `actions/setup-node@v4` with `cache: npm`
|
|
42
|
+
|
|
43
|
+
2. **Script validation**
|
|
44
|
+
- `node scripts/validate-scripts-nonempty.js` ensures all npm scripts referenced by CI exist and are non-empty.
|
|
45
|
+
|
|
46
|
+
3. **Install dependencies**
|
|
47
|
+
- `npm ci`
|
|
48
|
+
|
|
49
|
+
4. **Full quality gate**
|
|
50
|
+
- `npm run ci-verify:full`
|
|
51
|
+
- This script is the canonical definition of our quality gates and is also used by the Husky pre-push hook.
|
|
52
|
+
- It runs, in order:
|
|
53
|
+
- `npm run check:traceability`
|
|
54
|
+
- `npm run safety:deps`
|
|
55
|
+
- `npm run audit:ci`
|
|
56
|
+
- `npm run build`
|
|
57
|
+
- `npm run type-check`
|
|
58
|
+
- `npm run lint-plugin-check`
|
|
59
|
+
- `npm run lint -- --max-warnings=0`
|
|
60
|
+
- `npm run duplication`
|
|
61
|
+
- `npm run test -- --coverage`
|
|
62
|
+
- `npm run format:check`
|
|
63
|
+
- `npm audit --omit=dev --audit-level=high`
|
|
64
|
+
- `npm run audit:dev-high`
|
|
65
|
+
|
|
66
|
+
5. **Secret scanning**
|
|
67
|
+
- Only on Node `20.x` matrix entry: `npm run security:secrets` using secretlint.
|
|
68
|
+
|
|
69
|
+
6. **Artifact upload**
|
|
70
|
+
- Always upload:
|
|
71
|
+
- `ci/dry-aged-deps.json`
|
|
72
|
+
- `ci/npm-audit.json`
|
|
73
|
+
- `scripts/traceability-report.md`
|
|
74
|
+
- `ci/` (Jest and audit artifacts)
|
|
75
|
+
|
|
76
|
+
7. **Automated release (semantic-release)**
|
|
77
|
+
|
|
78
|
+
Conditional step:
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix['node-version'] == '20.x' && success() }}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- Runs `npx semantic-release` with:
|
|
85
|
+
- GitHub authentication via `GITHUB_TOKEN`
|
|
86
|
+
- npm authentication via `NPM_TOKEN`
|
|
87
|
+
- Configuration is in `.releaserc.json` and uses:
|
|
88
|
+
- `@semantic-release/commit-analyzer`
|
|
89
|
+
- `@semantic-release/release-notes-generator`
|
|
90
|
+
- `@semantic-release/changelog` (writes to `CHANGELOG.md` but we treat GitHub Releases as the user-facing source of truth per ADR 007)
|
|
91
|
+
- `@semantic-release/npm` (publishes to npm)
|
|
92
|
+
- `@semantic-release/github` (creates GitHub Releases)
|
|
93
|
+
|
|
94
|
+
Behavior:
|
|
95
|
+
- On each successful push to `main`, semantic-release:
|
|
96
|
+
- Analyzes commits since the last tag using **Conventional Commits** (see `docs/conventional-commits-guide.md`).
|
|
97
|
+
- Decides whether the release is `major`, `minor`, `patch`, or **no release**.
|
|
98
|
+
- If no relevant commits are found, it logs that no new release is needed and exits successfully.
|
|
99
|
+
- If a release is warranted:
|
|
100
|
+
- Publishes a new version to npm.
|
|
101
|
+
- Creates or updates `CHANGELOG.md`.
|
|
102
|
+
- Creates a Git tag and GitHub Release with generated notes.
|
|
103
|
+
|
|
104
|
+
- Safety behavior:
|
|
105
|
+
- If `NPM_TOKEN` is **not set**, the step logs a message and exits 0 with `new_release_published=false`.
|
|
106
|
+
- If semantic-release fails due to invalid npm token (`EINVALIDNPMTOKEN`) or OTP requirement (`EOTP`), the step logs a warning and exits 0, skipping publish but not failing CI.
|
|
107
|
+
- Any other semantic-release error fails the job.
|
|
108
|
+
|
|
109
|
+
8. **Post-deployment smoke test**
|
|
110
|
+
- Runs only when semantic-release reports that a new release was published:
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
if: steps.semantic-release.outputs.new_release_published == 'true'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- Executes:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
chmod +x scripts/smoke-test.sh
|
|
120
|
+
./scripts/smoke-test.sh "${{ steps.semantic-release.outputs.new_release_version }}"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- `scripts/smoke-test.sh`:
|
|
124
|
+
- For a published version: waits for the version to appear on npm, then
|
|
125
|
+
- Creates a temp project.
|
|
126
|
+
- Installs `eslint-plugin-traceability@<version>`.
|
|
127
|
+
- Verifies the plugin loads and the installed version matches.
|
|
128
|
+
- Runs a minimal ESLint config using the plugin to confirm it can be loaded.
|
|
129
|
+
|
|
130
|
+
### 2. `dependency-health`
|
|
131
|
+
|
|
132
|
+
Runs only on the nightly `schedule` event.
|
|
133
|
+
|
|
134
|
+
- Checks out code and installs dependencies.
|
|
135
|
+
- Runs `npm run audit:dev-high` to generate a JSON report of high-severity dev-only vulnerabilities.
|
|
136
|
+
- Does **not** publish or run semantic-release.
|
|
137
|
+
|
|
138
|
+
This job is intentionally isolated from the main quality-and-deploy path and has no effect on releases.
|
|
139
|
+
|
|
140
|
+
## Continuous Deployment Behavior
|
|
141
|
+
|
|
142
|
+
- Every push to `main` triggers the `quality-and-deploy` job on Node 18.x and 20.x.
|
|
143
|
+
- The full quality gate (`ci-verify:full`) must pass on both Node versions.
|
|
144
|
+
- If, and only if, the Node 20.x job on `main` succeeds and `NPM_TOKEN` is available, semantic-release is invoked.
|
|
145
|
+
- semantic-release decides whether a new version is required based on commit messages:
|
|
146
|
+
- `feat` → minor version bump
|
|
147
|
+
- `fix` → patch bump
|
|
148
|
+
- `feat!` or `BREAKING CHANGE:` footer → major bump
|
|
149
|
+
- Other types (`docs`, `chore`, `refactor`, `test`, `ci`, etc.) do **not** trigger a release.
|
|
150
|
+
- When a release is published, the smoke test runs immediately in the same workflow execution.
|
|
151
|
+
|
|
152
|
+
There is no separate “publish only” workflow and no manual tagging step required to release. The pipeline from commit → quality gates → publish → smoke test is fully automated.
|
|
153
|
+
|
|
154
|
+
## Local Workflow and Hooks
|
|
155
|
+
|
|
156
|
+
To keep local development aligned with CI:
|
|
157
|
+
|
|
158
|
+
- **Pre-commit** (`.husky/pre-commit`):
|
|
159
|
+
- Runs `npx lint-staged`, which executes Prettier and ESLint with `--fix` on staged files in `src/` and `tests/`.
|
|
160
|
+
- **Pre-push** (`.husky/pre-push`):
|
|
161
|
+
- Runs `npm run ci-verify:full`.
|
|
162
|
+
- This mirrors the CI quality gate so that most issues are caught before code reaches GitHub.
|
|
163
|
+
- Secret scanning (`npm run security:secrets`) currently runs only in CI on the Node 20.x matrix entry and is not part of the pre-push hook, but it uses the same configuration so results stay consistent between local and CI.
|
|
164
|
+
|
|
165
|
+
Local verification commands:
|
|
166
|
+
|
|
167
|
+
- `npm run ci-verify:full`
|
|
168
|
+
- Runs the same broad, end-to-end quality gate used in CI (build, type-check, linting, duplication checks, full Jest test suite with coverage, audits, and formatting checks).
|
|
169
|
+
- This is the closest approximation to the CI pipeline and is what the pre-push hook enforces.
|
|
170
|
+
|
|
171
|
+
- `npm run ci-verify:fast`
|
|
172
|
+
- Runs a **narrower, targeted subset** of checks focused on the rule and maintenance test suites.
|
|
173
|
+
- Uses Jest with:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
jest --testPathPatterns 'tests/(rules|maintenance)'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
to execute only tests whose paths match `tests/rules` or `tests/maintenance`.
|
|
180
|
+
|
|
181
|
+
- Intended as an **optional, faster pre-flight** command that contributors run manually to iterate quickly on rule changes and core maintenance behavior.
|
|
182
|
+
- Does **not** replace `ci-verify:full` and is **not** used by hooks or CI; it exists purely for faster local feedback.
|
|
183
|
+
|
|
184
|
+
Developers should rely on:
|
|
185
|
+
|
|
186
|
+
- `npm run ci-verify:full` for a full CI-equivalent check (and what will run on push via Husky).
|
|
187
|
+
- `npm run ci-verify` or `npm run ci-verify:fast` for quicker, targeted local feedback loops when working on rules or maintenance logic.
|
|
188
|
+
|
|
189
|
+
## How Semantic Versioning Is Determined
|
|
190
|
+
|
|
191
|
+
semantic-release uses Conventional Commits (see `docs/conventional-commits-guide.md`) to infer version changes:
|
|
192
|
+
|
|
193
|
+
- `feat:` → **minor** version bump.
|
|
194
|
+
- `fix:` → **patch** version bump.
|
|
195
|
+
- `feat!` or `fix!` (or any type with `!`) or a `BREAKING CHANGE:` footer → **major** version bump.
|
|
196
|
+
- Other types (`docs`, `style`, `refactor`, `test`, `chore`, `ci`, `build`, `perf`) → no release.
|
|
197
|
+
|
|
198
|
+
Because releases are determined solely from commit history, it is important that all commits merged to `main` follow the documented Conventional Commits standard.
|
|
199
|
+
|
|
200
|
+
## Supported Runtime and Tooling
|
|
201
|
+
|
|
202
|
+
The pipeline runs against the following Node.js versions:
|
|
203
|
+
|
|
204
|
+
- Node `18.x`
|
|
205
|
+
- Node `20.x`
|
|
206
|
+
|
|
207
|
+
The package itself declares:
|
|
208
|
+
|
|
209
|
+
- `engines.node: ">=18.18.0"`
|
|
210
|
+
- `peerDependencies.eslint: "^9.0.0"`
|
|
211
|
+
|
|
212
|
+
User-facing docs are aligned with these constraints:
|
|
213
|
+
|
|
214
|
+
- README “Prerequisites” section.
|
|
215
|
+
- `user-docs/api-reference.md` "Supported runtime" line.
|
|
216
|
+
|
|
217
|
+
## When Things Go Wrong
|
|
218
|
+
|
|
219
|
+
- If **quality checks fail** (build, tests, lint, type-check, duplication, format, or audits), the workflow fails before any release attempt.
|
|
220
|
+
- If semantic-release encounters a non-token, non-OTP error, the job fails and no release is published.
|
|
221
|
+
- If `NPM_TOKEN` is missing or invalid, or if npm requires an OTP, the workflow succeeds but skips publishing; this is treated as a configuration issue rather than a code failure.
|
|
222
|
+
- If the post-deployment smoke test fails, the job fails even though a package may have been published; this indicates an urgent regression in the published artifact.
|
|
223
|
+
|
|
224
|
+
In all of these cases, the failing run is visible in the `CI/CD Pipeline` workflow on GitHub, and maintainers should fix the underlying issue before merging further changes to `main`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# CLI Integration Guide
|
|
2
|
+
|
|
3
|
+
Story: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
4
|
+
Requirement: REQ-PLUGIN-STRUCTURE - Validate plugin registers via CLI
|
|
5
|
+
|
|
6
|
+
Integration tests for the ESLint CLI plugin are included in the Jest test suite under `tests/integration/cli-integration.test.ts`.
|
|
7
|
+
|
|
8
|
+
## Running CLI Integration Tests
|
|
9
|
+
|
|
10
|
+
To run only the CLI integration tests:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm test -- tests/integration/cli-integration.test.ts
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
To run the full test suite:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm test
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
These tests invoke the ESLint CLI with the plugin configured, verifying that rule errors are reported (or not) as expected when code is passed via `stdin`. Ensure your ESLint flat config (`eslint.config.js`) loads the plugin before running these tests.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Code Quality and Security Refactor Opportunities (2025-12-03)
|
|
2
|
+
|
|
3
|
+
Created autonomously by voder.ai
|
|
4
|
+
|
|
5
|
+
This note captures small, low-risk refactors that can be implemented incrementally to further improve maintainability and security without changing public behavior.
|
|
6
|
+
|
|
7
|
+
## 1. Decompose maintenance CLI implementation
|
|
8
|
+
|
|
9
|
+
**Files:**
|
|
10
|
+
|
|
11
|
+
- `src/maintenance/cli.ts`
|
|
12
|
+
|
|
13
|
+
**Motivation:**
|
|
14
|
+
|
|
15
|
+
- `cli.ts` is one of the larger source files and currently owns argument parsing, flag normalization, subcommand dispatch, and user-facing messaging.
|
|
16
|
+
- While it still passes `max-lines` and `max-lines-per-function` rules, splitting responsibilities would improve navigability.
|
|
17
|
+
|
|
18
|
+
**Potential refactors:**
|
|
19
|
+
|
|
20
|
+
- Extract a dedicated `src/maintenance/flags.ts` module responsible solely for:
|
|
21
|
+
- Defining the `CliFlags` shape and defaults.
|
|
22
|
+
- Implementing `applyFlag` / `parseFlags` behavior and validation.
|
|
23
|
+
- Extract a `src/maintenance/commands.ts` module for the four subcommand handlers:
|
|
24
|
+
- `handleDetect`, `handleVerify`, `handleReport`, `handleUpdate`.
|
|
25
|
+
- Keep `runMaintenanceCli` as a small coordination layer that wires parsed arguments to these handlers.
|
|
26
|
+
|
|
27
|
+
## 2. Narrow helper responsibilities in require-story helpers
|
|
28
|
+
|
|
29
|
+
**Files:**
|
|
30
|
+
|
|
31
|
+
- `src/rules/helpers/require-story-helpers.ts`
|
|
32
|
+
- `src/rules/helpers/require-story-core.ts`
|
|
33
|
+
|
|
34
|
+
**Motivation:**
|
|
35
|
+
|
|
36
|
+
- These helpers concentrate multiple kinds of functionality: AST visitor construction, IO behavior, message construction, and small utility predicates.
|
|
37
|
+
- Individual functions are reasonably sized, but the number of exported helpers makes the files dense.
|
|
38
|
+
|
|
39
|
+
**Potential refactors:**
|
|
40
|
+
|
|
41
|
+
- Introduce a dedicated `src/rules/helpers/require-story-io.ts` (already partially present) as the single place for reading and writing files in tests and rules.
|
|
42
|
+
- Move purely structural helpers (e.g., small predicates, formatting helpers) into a `require-story-utils.ts`-style module so each file focuses on a single axis of responsibility.
|
|
43
|
+
|
|
44
|
+
## 3. Revisit targeted ESLint suppressions
|
|
45
|
+
|
|
46
|
+
**Files:**
|
|
47
|
+
|
|
48
|
+
- `src/rules/helpers/valid-story-reference-helpers.ts` (single `no-unused-vars` suppression on a type-only parameter)
|
|
49
|
+
- `src/rules/helpers/valid-annotation-options.ts` (single `max-params` suppression for a central option-normalization helper)
|
|
50
|
+
- `tests/utils/ts-language-options.ts` (single `no-magic-numbers` suppression to allow ECMA version constants)
|
|
51
|
+
|
|
52
|
+
**Motivation:**
|
|
53
|
+
|
|
54
|
+
- Each suppression is currently justified and localized, but a small refactor could remove them entirely, simplifying the lint configuration.
|
|
55
|
+
|
|
56
|
+
**Potential refactors:**
|
|
57
|
+
|
|
58
|
+
- Replace the suppressed `max-params` helper with an options object parameter so callers pass a single argument while preserving type safety.
|
|
59
|
+
- For the `no-unused-vars` case, explore using a `type`-only import or restructuring the function signature so all parameters are meaningfully consumed.
|
|
60
|
+
- Extract ECMA version numbers into named constants in a small shared test utility module to avoid the need for a `no-magic-numbers` override.
|
|
61
|
+
|
|
62
|
+
## 4. Optional: add slim wrappers for Story/Req detection utilities
|
|
63
|
+
|
|
64
|
+
**Files:**
|
|
65
|
+
|
|
66
|
+
- `src/utils/reqAnnotationDetection.ts`
|
|
67
|
+
- `src/utils/annotation-checker.ts`
|
|
68
|
+
|
|
69
|
+
**Motivation:**
|
|
70
|
+
|
|
71
|
+
- These utilities are well-tested but contain a moderate amount of conditional logic for different AST node types.
|
|
72
|
+
|
|
73
|
+
**Potential refactors:**
|
|
74
|
+
|
|
75
|
+
- Introduce thin, strongly-typed wrapper functions for the most common call sites (e.g., “analyze function declaration for traceability annotations”) that hide some of the configuration detail from rule implementations.
|
|
76
|
+
- This would make rule modules slightly smaller and more declarative, leaving the complex branching in a shared, well-tested location.
|
|
77
|
+
|
|
78
|
+
These refactors should be tackled incrementally, one small change at a time, with existing Jest tests and ESLint rules acting as safety nets to ensure behavior remains unchanged.
|
|
@@ -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 with severities tuned for common usage (most at `error`, with `traceability/valid-annotation-format` at `warn` to reduce noise):
|
|
18
|
+
|
|
19
|
+
- `traceability/require-story-annotation`: `error`
|
|
20
|
+
- `traceability/require-req-annotation`: `error`
|
|
21
|
+
- `traceability/require-branch-annotation`: `error`
|
|
22
|
+
- `traceability/valid-annotation-format`: `warn`
|
|
23
|
+
- `traceability/valid-story-reference`: `error`
|
|
24
|
+
- `traceability/valid-req-reference`: `error`
|
|
25
|
+
|
|
26
|
+
## Strict Preset
|
|
27
|
+
|
|
28
|
+
Use the **strict** preset to enforce the same core rules, with potential future enhancements for stricter policies. Like the recommended preset, it configures `traceability/valid-annotation-format` as a `warn` to avoid excessive noise from format-only issues.
|
|
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.
|