eslint-plugin-traceability 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -5
- package/README.md +28 -29
- package/SECURITY.md +135 -0
- package/lib/src/index.d.ts +6 -35
- package/lib/src/index.js +8 -5
- package/lib/src/maintenance/cli.js +12 -16
- package/lib/src/maintenance/detect.js +28 -1
- package/lib/src/rules/helpers/require-story-io.d.ts +2 -2
- package/lib/src/rules/helpers/require-story-io.js +13 -13
- package/lib/src/rules/helpers/valid-annotation-format-internal.d.ts +2 -2
- package/lib/src/rules/helpers/valid-annotation-format-internal.js +3 -3
- package/lib/src/rules/helpers/valid-annotation-utils.d.ts +5 -0
- package/lib/src/rules/helpers/valid-annotation-utils.js +43 -5
- package/lib/src/rules/helpers/valid-implements-utils.d.ts +11 -11
- package/lib/src/rules/helpers/valid-implements-utils.js +11 -11
- package/lib/src/rules/helpers/valid-story-reference-helpers.js +19 -0
- package/lib/src/rules/prefer-implements-annotation.d.ts +7 -7
- package/lib/src/rules/prefer-implements-annotation.js +21 -21
- package/lib/src/rules/valid-annotation-format.js +50 -24
- package/lib/src/rules/valid-req-reference.js +9 -9
- package/lib/src/utils/annotation-checker.js +3 -1
- package/lib/src/utils/reqAnnotationDetection.d.ts +2 -2
- package/lib/src/utils/reqAnnotationDetection.js +28 -28
- package/lib/tests/config/flat-config-presets-integration.test.d.ts +1 -0
- package/lib/tests/config/flat-config-presets-integration.test.js +75 -0
- package/lib/tests/maintenance/batch.test.js +11 -11
- package/lib/tests/maintenance/cli.test.js +34 -27
- package/lib/tests/maintenance/report.test.js +7 -7
- package/lib/tests/plugin-default-export-and-configs.test.js +0 -2
- package/lib/tests/rules/prefer-implements-annotation.test.js +48 -15
- package/lib/tests/rules/require-branch-annotation.test.js +15 -36
- package/lib/tests/rules/require-req-annotation.test.js +31 -104
- package/lib/tests/rules/require-story-annotation.test.js +3 -3
- package/lib/tests/rules/require-story-io-behavior.test.js +2 -7
- package/lib/tests/rules/require-story-io.edgecases.test.js +2 -7
- package/lib/tests/rules/require-story-visitors-edgecases.test.js +8 -8
- package/lib/tests/rules/valid-annotation-format.test.js +23 -23
- package/lib/tests/rules/valid-req-reference.test.js +9 -9
- package/lib/tests/rules/valid-story-reference.test.js +4 -43
- package/lib/tests/utils/annotation-checker.test.js +2 -6
- package/lib/tests/utils/fsTestHelpers.d.ts +7 -0
- package/lib/tests/utils/fsTestHelpers.js +26 -0
- package/lib/tests/utils/ioTestHelpers.d.ts +7 -0
- package/lib/tests/utils/ioTestHelpers.js +24 -0
- package/lib/tests/utils/temp-dir-helpers.d.ts +14 -0
- package/lib/tests/utils/temp-dir-helpers.js +61 -0
- package/package.json +8 -7
- package/user-docs/api-reference.md +37 -20
- package/user-docs/eslint-9-setup-guide.md +89 -6
- package/user-docs/migration-guide.md +37 -21
- package/docs/ci-cd-pipeline.md +0 -224
- package/docs/cli-integration.md +0 -22
- package/docs/code-quality-refactor-opportunities-2025-12-03.md +0 -78
- package/docs/config-presets.md +0 -38
- package/docs/conventional-commits-guide.md +0 -185
- package/docs/custom-rules-development-guide.md +0 -659
- package/docs/decisions/0001-allow-dynamic-require-for-built-plugins.md +0 -26
- package/docs/decisions/001-typescript-for-eslint-plugin.accepted.md +0 -111
- package/docs/decisions/002-jest-for-eslint-testing.accepted.md +0 -137
- package/docs/decisions/003-code-quality-ratcheting-plan.md +0 -48
- package/docs/decisions/004-automated-version-bumping-for-ci-cd.md +0 -196
- package/docs/decisions/005-github-actions-validation-tooling.accepted.md +0 -144
- package/docs/decisions/006-semantic-release-for-automated-publishing.accepted.md +0 -227
- package/docs/decisions/007-github-releases-over-changelog.accepted.md +0 -216
- package/docs/decisions/008-ci-audit-flags.accepted.md +0 -60
- package/docs/decisions/009-security-focused-lint-rules.accepted.md +0 -64
- package/docs/decisions/010-implements-annotation-for-multi-story-requirements.proposed.md +0 -184
- package/docs/decisions/adr-0001-console-usage-for-cli-guards.md +0 -190
- package/docs/decisions/adr-accept-dev-dep-risk-glob.md +0 -40
- package/docs/decisions/adr-commit-branch-tests.md +0 -54
- package/docs/decisions/adr-maintenance-cli-interface.md +0 -140
- package/docs/decisions/adr-pre-push-parity.md +0 -112
- package/docs/decisions/code-quality-ratcheting-plan.md +0 -53
- package/docs/dependency-health.md +0 -238
- package/docs/eslint-9-setup-guide.md +0 -517
- package/docs/eslint-plugin-development-guide.md +0 -487
- package/docs/functionality-coverage-2025-12-03.md +0 -250
- package/docs/jest-testing-guide.md +0 -100
- package/docs/rules/prefer-implements-annotation.md +0 -219
- package/docs/rules/require-branch-annotation.md +0 -71
- package/docs/rules/require-req-annotation.md +0 -203
- package/docs/rules/require-story-annotation.md +0 -159
- package/docs/rules/valid-annotation-format.md +0 -418
- package/docs/rules/valid-req-reference.md +0 -153
- package/docs/rules/valid-story-reference.md +0 -120
- package/docs/security-incidents/2025-11-17-glob-cli-incident.md +0 -45
- package/docs/security-incidents/2025-11-18-brace-expansion-redos.md +0 -45
- package/docs/security-incidents/2025-11-18-bundled-dev-deps-accepted-risk.md +0 -93
- package/docs/security-incidents/2025-11-18-tar-race-condition.md +0 -43
- package/docs/security-incidents/2025-12-03-dependency-health-review.md +0 -58
- package/docs/security-incidents/SECURITY-INCIDENT-2025-11-18-semantic-release-bundled-npm.known-error.md +0 -104
- package/docs/security-incidents/SECURITY-INCIDENT-TEMPLATE.md +0 -37
- package/docs/security-incidents/dependency-override-rationale.md +0 -57
- package/docs/security-incidents/dev-deps-high.json +0 -116
- package/docs/security-incidents/handling-procedure.md +0 -54
- package/docs/stories/001.0-DEV-PLUGIN-SETUP.story.md +0 -92
- package/docs/stories/002.0-DEV-ESLINT-CONFIG.story.md +0 -82
- package/docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md +0 -112
- package/docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md +0 -153
- package/docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story.md +0 -138
- package/docs/stories/006.0-DEV-FILE-VALIDATION.story.md +0 -144
- package/docs/stories/007.0-DEV-ERROR-REPORTING.story.md +0 -163
- package/docs/stories/008.0-DEV-AUTO-FIX.story.md +0 -150
- package/docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md +0 -117
- package/docs/stories/010.0-DEV-DEEP-VALIDATION.story.md +0 -124
- package/docs/stories/010.1-DEV-CONFIGURABLE-PATTERNS.story.md +0 -149
- package/docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md +0 -216
- package/docs/stories/010.3-DEV-MIGRATE-TO-IMPLEMENTS.story.md +0 -236
- package/docs/stories/developer-story.map.md +0 -120
- package/docs/ts-jest-presets-guide.md +0 -548
package/docs/ci-cd-pipeline.md
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
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`.
|
package/docs/cli-integration.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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.
|
|
@@ -1,78 +0,0 @@
|
|
|
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.
|
package/docs/config-presets.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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.
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# Conventional Commits Guide
|
|
2
|
-
|
|
3
|
-
This project uses [Conventional Commits](https://www.conventionalcommits.org/) to enable automated semantic versioning and changelog generation through semantic-release.
|
|
4
|
-
|
|
5
|
-
## Commit Message Format
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
<type>[optional scope]: <description>
|
|
9
|
-
|
|
10
|
-
[optional body]
|
|
11
|
-
|
|
12
|
-
[optional footer(s)]
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Types and Version Impact
|
|
16
|
-
|
|
17
|
-
### `feat`: New Features (Minor Version)
|
|
18
|
-
|
|
19
|
-
- Adds new functionality
|
|
20
|
-
- Results in a **minor** version increment (e.g., 1.0.0 → 1.1.0)
|
|
21
|
-
|
|
22
|
-
Examples:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
feat: add new validation rule for story references
|
|
26
|
-
feat(rules): implement require-branch-annotation rule
|
|
27
|
-
feat: add CLI integration for batch processing
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### `fix`: Bug Fixes (Patch Version)
|
|
31
|
-
|
|
32
|
-
- Fixes existing functionality
|
|
33
|
-
- Results in a **patch** version increment (e.g., 1.0.0 → 1.0.1)
|
|
34
|
-
|
|
35
|
-
Examples:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
fix: resolve annotation parsing for multiline comments
|
|
39
|
-
fix(validation): handle edge case in reference checking
|
|
40
|
-
fix: prevent false positives in story reference detection
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Breaking Changes (Major Version)
|
|
44
|
-
|
|
45
|
-
- Any commit with `!` after the type or `BREAKING CHANGE:` in footer
|
|
46
|
-
- Results in a **major** version increment (e.g., 1.0.0 → 2.0.0)
|
|
47
|
-
|
|
48
|
-
Examples:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
feat!: change API interface for rule configuration
|
|
52
|
-
fix!: remove deprecated annotation format support
|
|
53
|
-
|
|
54
|
-
feat: add new validation options
|
|
55
|
-
|
|
56
|
-
BREAKING CHANGE: The `allowUnresolved` option has been removed.
|
|
57
|
-
Use `strict: false` instead.
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Other Types (No Version Change)
|
|
61
|
-
|
|
62
|
-
These don't trigger releases but appear in changelog:
|
|
63
|
-
|
|
64
|
-
- `docs`: Documentation changes
|
|
65
|
-
- `style`: Code style changes (formatting, etc.)
|
|
66
|
-
- `refactor`: Code refactoring without functional changes
|
|
67
|
-
- `test`: Adding or updating tests
|
|
68
|
-
- `chore`: Build process, auxiliary tools, or maintenance
|
|
69
|
-
- `perf`: Performance improvements
|
|
70
|
-
- `ci`: CI/CD configuration changes
|
|
71
|
-
|
|
72
|
-
Examples:
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
docs: update README with installation instructions
|
|
76
|
-
test: add unit tests for validation rules
|
|
77
|
-
chore: update dependencies to latest versions
|
|
78
|
-
ci: configure semantic-release for automated publishing
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Scopes (Optional)
|
|
82
|
-
|
|
83
|
-
Use scopes to specify what part of the codebase is affected:
|
|
84
|
-
|
|
85
|
-
- `rules`: ESLint rule implementations
|
|
86
|
-
- `maintenance`: Maintenance scripts and utilities
|
|
87
|
-
- `cli`: Command-line integration tools
|
|
88
|
-
- `config`: Configuration and setup files
|
|
89
|
-
- `deps`: Dependency updates
|
|
90
|
-
|
|
91
|
-
Examples:
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
feat(rules): add valid-annotation-format rule
|
|
95
|
-
fix(maintenance): resolve batch processing memory leak
|
|
96
|
-
docs(config): add ESLint 9 setup guide
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Best Practices
|
|
100
|
-
|
|
101
|
-
### Commit Message Guidelines
|
|
102
|
-
|
|
103
|
-
1. **Use imperative mood**: "add feature" not "added feature"
|
|
104
|
-
2. **Keep subject under 50 characters**: For better git log readability
|
|
105
|
-
3. **Capitalize the subject line**: Start with capital letter
|
|
106
|
-
4. **No period at the end**: Of the subject line
|
|
107
|
-
5. **Explain what and why**: In the body, not how
|
|
108
|
-
|
|
109
|
-
### When to Use Each Type
|
|
110
|
-
|
|
111
|
-
**Use `feat` when:**
|
|
112
|
-
|
|
113
|
-
- Adding new ESLint rules
|
|
114
|
-
- Adding new maintenance utilities
|
|
115
|
-
- Adding new configuration options
|
|
116
|
-
- Adding new CLI commands or features
|
|
117
|
-
|
|
118
|
-
**Use `fix` when:**
|
|
119
|
-
|
|
120
|
-
- Fixing rule logic or false positives/negatives
|
|
121
|
-
- Fixing crashes or runtime errors
|
|
122
|
-
- Fixing configuration issues
|
|
123
|
-
- Fixing documentation errors
|
|
124
|
-
|
|
125
|
-
**Use `refactor` when:**
|
|
126
|
-
|
|
127
|
-
- Improving code structure without changing behavior
|
|
128
|
-
- Renaming variables or functions
|
|
129
|
-
- Extracting common functionality
|
|
130
|
-
- Simplifying complex logic
|
|
131
|
-
|
|
132
|
-
**Use `docs` when:**
|
|
133
|
-
|
|
134
|
-
- Updating README, guides, or API documentation
|
|
135
|
-
- Adding code comments or JSDoc
|
|
136
|
-
- Updating examples or migration guides
|
|
137
|
-
|
|
138
|
-
### Example Workflow
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
# New feature
|
|
142
|
-
git commit -m "feat(rules): add require-story-annotation rule
|
|
143
|
-
|
|
144
|
-
Implements validation to ensure all functions have @story annotations
|
|
145
|
-
linking them to user stories for traceability.
|
|
146
|
-
|
|
147
|
-
Resolves: #123"
|
|
148
|
-
|
|
149
|
-
# Bug fix
|
|
150
|
-
git commit -m "fix: resolve false positive in annotation parsing
|
|
151
|
-
|
|
152
|
-
The regex pattern was incorrectly matching inline comments.
|
|
153
|
-
Updated to only match block comments that start at beginning of line."
|
|
154
|
-
|
|
155
|
-
# Breaking change
|
|
156
|
-
git commit -m "feat!: change rule configuration schema
|
|
157
|
-
|
|
158
|
-
BREAKING CHANGE: Rule options now use 'patterns' instead of 'pattern'.
|
|
159
|
-
Update your ESLint config:
|
|
160
|
-
- Before: { "pattern": "REQ-*" }
|
|
161
|
-
+ After: { "patterns": ["REQ-*"] }"
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Integration with semantic-release
|
|
165
|
-
|
|
166
|
-
semantic-release analyzes commit messages to:
|
|
167
|
-
|
|
168
|
-
1. **Determine version bump**: Based on feat/fix/breaking change types
|
|
169
|
-
2. **Generate changelog**: From commit messages and pull request information
|
|
170
|
-
3. **Create git tags**: For each release
|
|
171
|
-
4. **Publish to npm**: Only when changes warrant a release
|
|
172
|
-
|
|
173
|
-
## Validation
|
|
174
|
-
|
|
175
|
-
Pre-commit hooks will validate your commit messages follow the conventional format. If you need to bypass validation temporarily (not recommended), use:
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
git commit --no-verify -m "your message"
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Resources
|
|
182
|
-
|
|
183
|
-
- [Conventional Commits Specification](https://www.conventionalcommits.org/)
|
|
184
|
-
- [semantic-release Documentation](https://semantic-release.gitbook.io/)
|
|
185
|
-
- [Angular Commit Message Guidelines](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#-commit-message-format)
|