eslint-plugin-traceability 1.11.0 → 1.11.1
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 +3 -4
- package/README.md +2 -2
- package/lib/src/maintenance/flags.js +111 -25
- package/lib/src/rules/helpers/require-story-core.d.ts +59 -0
- package/lib/src/rules/helpers/require-story-core.js +91 -1
- package/lib/src/rules/helpers/require-story-helpers.d.ts +2 -47
- package/lib/src/rules/helpers/require-story-helpers.js +135 -126
- package/lib/src/rules/helpers/require-story-io.js +51 -31
- package/lib/src/rules/helpers/valid-annotation-options.d.ts +3 -0
- package/lib/src/rules/helpers/valid-annotation-options.js +64 -21
- package/lib/src/utils/annotation-checker.js +31 -7
- package/lib/src/utils/reqAnnotationDetection.js +36 -22
- package/lib/tests/cli-error-handling.test.js +1 -0
- package/lib/tests/config/eslint-config-validation.test.d.ts +8 -0
- package/lib/tests/config/eslint-config-validation.test.js +8 -0
- package/lib/tests/config/flat-config-presets-integration.test.js +1 -3
- package/lib/tests/config/require-story-annotation-config.test.d.ts +9 -0
- package/lib/tests/config/require-story-annotation-config.test.js +9 -0
- package/lib/tests/integration/cli-integration.test.js +9 -1
- package/lib/tests/maintenance/batch.test.js +1 -0
- package/lib/tests/maintenance/cli.test.js +1 -0
- package/lib/tests/maintenance/detect-isolated.test.js +1 -0
- package/lib/tests/maintenance/detect.test.js +1 -0
- package/lib/tests/maintenance/index.test.js +1 -0
- package/lib/tests/maintenance/report.test.js +1 -0
- package/lib/tests/maintenance/update-isolated.test.js +1 -0
- package/lib/tests/maintenance/update.test.js +1 -0
- package/lib/tests/plugin-default-export-and-configs.test.js +2 -0
- package/lib/tests/plugin-setup-error.test.d.ts +1 -0
- package/lib/tests/plugin-setup-error.test.js +1 -0
- package/lib/tests/plugin-setup.test.js +1 -1
- package/lib/tests/rules/auto-fix-behavior-008.test.js +16 -0
- package/lib/tests/rules/error-reporting.test.js +1 -0
- package/lib/tests/rules/prefer-implements-annotation.test.js +8 -0
- package/lib/tests/rules/require-branch-annotation.test.js +2 -0
- package/lib/tests/rules/require-story-core-edgecases.test.js +1 -0
- package/lib/tests/rules/require-story-core.autofix.test.js +1 -0
- package/lib/tests/rules/require-story-core.test.js +1 -0
- package/lib/tests/rules/require-story-helpers-edgecases.test.d.ts +1 -0
- package/lib/tests/rules/require-story-helpers-edgecases.test.js +1 -0
- package/lib/tests/rules/require-story-helpers.test.js +4 -3
- package/lib/tests/rules/require-story-io-behavior.test.d.ts +1 -0
- package/lib/tests/rules/require-story-io-behavior.test.js +1 -0
- package/lib/tests/rules/require-story-io.edgecases.test.d.ts +1 -0
- package/lib/tests/rules/require-story-io.edgecases.test.js +1 -0
- package/lib/tests/rules/require-story-visitors-edgecases.test.d.ts +1 -0
- package/lib/tests/rules/require-story-visitors-edgecases.test.js +1 -0
- package/lib/tests/rules/valid-story-reference.test.js +2 -0
- package/lib/tests/utils/annotation-checker.test.js +2 -1
- package/lib/tests/utils/branch-annotation-helpers.test.js +2 -1
- package/package.json +1 -1
- package/user-docs/api-reference.md +117 -10
- package/user-docs/examples.md +2 -3
- package/user-docs/migration-guide.md +36 -3
|
@@ -86,19 +86,19 @@ if (error) {
|
|
|
86
86
|
|
|
87
87
|
### traceability/valid-annotation-format
|
|
88
88
|
|
|
89
|
-
Description: Validates that all traceability annotations (`@story`, `@req`) follow the correct JSDoc or inline comment format. When run with `--fix`, the rule limits changes to safe `@story` path suffix normalization only—for example, adding `.md` when the path ends with `.story`, or adding `.story.md` when the base path has no extension—using targeted replacements implemented in the `getFixedStoryPath` and `reportInvalidStoryFormatWithFix` helpers. It does not change directories, infer new story names, or modify any surrounding comment text or whitespace, in line with Story 008.0
|
|
89
|
+
Description: Validates that all traceability annotations (`@story`, `@req`) follow the correct JSDoc or inline comment format. When run with `--fix`, the rule limits changes to safe `@story` path suffix normalization only—for example, adding `.md` when the path ends with `.story`, or adding `.story.md` when the base path has no extension—using targeted replacements implemented in the `getFixedStoryPath` and `reportInvalidStoryFormatWithFix` helpers. It does not change directories, infer new story names, or modify any surrounding comment text or whitespace, in line with Story 008.0. Selective disabling of this suffix-normalization auto-fix behavior is available via the `autoFix` option, which defaults to `true` for backward compatibility.
|
|
90
90
|
|
|
91
91
|
Options:
|
|
92
92
|
|
|
93
93
|
This rule accepts an optional configuration object. The primary configuration shape is **nested**:
|
|
94
94
|
|
|
95
95
|
- `story` (object, optional) – Configuration for `@story` values.
|
|
96
|
-
- `pattern` (string, optional) – A JavaScript regular expression **source** (without leading and trailing `/`) that all `@story` values must match. If provided, the rule validates each `@story` against this pattern in addition to its built‑in structural checks. By default, the plugin uses a pattern equivalent to `^docs/stories
|
|
97
|
-
- `example` (string, optional) – A short example `@story` path shown in error messages when `story.pattern` is configured. The built-in default example is `"docs/stories/
|
|
96
|
+
- `pattern` (string, optional) – A JavaScript regular expression **source** (without leading and trailing `/`) that all `@story` values must match. If provided, the rule validates each `@story` against this pattern in addition to its built‑in structural checks. By default, the plugin uses a pattern equivalent to `^docs/stories/[0-9]+\.[0-9]+-DEV-[\w-]+\.story\.md$`, which matches typical project conventions such as `docs/stories/005.0-DEV-EXAMPLE.story.md`; you can override this to match however your own project organizes story files.
|
|
97
|
+
- `example` (string, optional) – A short example `@story` path shown in error messages when `story.pattern` is configured. The built-in default example is `"docs/stories/005.0-DEV-EXAMPLE.story.md"`, intended as a generic illustration of a project story file, and does not refer to this plugin’s internal documentation.
|
|
98
98
|
- `req` (object, optional) – Configuration for `@req` values.
|
|
99
|
-
- `pattern` (string, optional) – A JavaScript regular expression **source** (without leading and trailing `/`) that all `@req` values must match. If provided, the rule validates each `@req` identifier against this pattern. Defaults to the value returned by `getDefaultReqPattern()`, which is equivalent to `^REQ-[A-Z0-
|
|
100
|
-
- `example` (string, optional) – A short example requirement ID shown in error messages when `req.pattern` is configured. Defaults to the value returned by `getDefaultReqExample()`, `"REQ-
|
|
101
|
-
- `autoFix` (boolean, optional) – When set to `false`, disables all automatic suffix-normalization fixes while keeping validation and error messages intact. When omitted or `true`, the rule continues to apply safe suffix-only auto-fixes in `--fix` mode.
|
|
99
|
+
- `pattern` (string, optional) – A JavaScript regular expression **source** (without leading and trailing `/`) that all `@req` values must match. If provided, the rule validates each `@req` identifier against this pattern. Defaults to the value returned by `getDefaultReqPattern()`, which is equivalent to `^REQ-[A-Z0-9-]+$`, matching IDs such as `REQ-USER-AUTH` or `REQ-1234`.
|
|
100
|
+
- `example` (string, optional) – A short example requirement ID shown in error messages when `req.pattern` is configured. Defaults to the value returned by `getDefaultReqExample()`, `"REQ-EXAMPLE"`. This value is used **only** for guidance and does not affect validation.
|
|
101
|
+
- `autoFix` (boolean, optional) – When set to `false`, disables all automatic suffix-normalization fixes while keeping validation and error messages intact. When omitted or `true`, the rule continues to apply safe `@story` suffix-only auto-fixes in `--fix` mode.
|
|
102
102
|
|
|
103
103
|
For backward compatibility, the rule also supports **flat shorthand** fields that map directly to the nested properties:
|
|
104
104
|
|
|
@@ -113,6 +113,8 @@ Behavior notes:
|
|
|
113
113
|
- When options are omitted, the rule behaves exactly as in earlier versions, relying on its built‑in defaults and path‑suffix normalization logic only.
|
|
114
114
|
- The pattern checks are additional validation; they do not change the existing auto‑fix behavior, which remains limited to safe `@story` suffix normalization described above.
|
|
115
115
|
|
|
116
|
+
You can customize these validations to match your own naming conventions by overriding `story.pattern`/`storyPathPattern` and `req.pattern`/`requirementIdPattern`. This is useful when you store stories outside `docs/stories`, avoid `DEV` in filenames, or use a different requirement ID scheme instead of the default `REQ-...` format. Any custom values must still be valid JavaScript regular expression **sources** (without surrounding `/` characters).
|
|
117
|
+
|
|
116
118
|
#### Migration and mixed usage
|
|
117
119
|
|
|
118
120
|
The `valid-annotation-format` rule is intentionally **backward compatible** with existing code that only uses `@story` and `@req`. You can:
|
|
@@ -210,16 +212,18 @@ The rule accepts an optional configuration object:
|
|
|
210
212
|
- `testFilePatterns` (string[], optional) – **Path-substring patterns** used to identify test files. For each file, the rule normalizes the file path to use forward slashes and then checks whether it contains at least one of the configured pattern strings. This is intentionally simpler than full glob matching and avoids adding extra runtime dependencies. Defaults to `["/tests/", "/test/", "/__tests__", ".test.", ".spec."]`. For most projects, these defaults behave like "any file under a `tests` or `test` directory, or any file whose name includes `.test.` or `.spec.`". If you prefer a different layout, supply custom substrings that uniquely identify your test files.
|
|
211
213
|
- `requireDescribeStory` (boolean, optional) – When `true` (default), requires that each top-level `describe` block include a story reference somewhere in its description text (for example, a path such as `docs/stories/010.0-PAYMENTS.story.md` or a shorter project-specific alias that your team uses consistently).
|
|
212
214
|
- `requireTestReqPrefix` (boolean, optional) – When `true` (default), requires each `it`/`test` block name to begin with a requirement identifier in square brackets, such as `[REQ-PAYMENTS-REFUND]`. The exact `REQ-` pattern is shared with the `valid-annotation-format` rule’s requirement ID checks.
|
|
213
|
-
- `describePattern` (string, optional) – A JavaScript regular expression **source** (without leading and trailing `/`) that the `describe` description text must match when `requireDescribeStory` is enabled. This lets you enforce a project-specific format such as requiring a canonical story path or a `STORY-` style identifier in the `describe` string. If omitted,
|
|
215
|
+
- `describePattern` (string, optional) – A JavaScript regular expression **source** (without leading and trailing `/`) that the `describe` description text must match when `requireDescribeStory` is enabled. This lets you enforce a project-specific format such as requiring a canonical story path or a `STORY-` style identifier in the `describe` string. If omitted, the default is equivalent to `"Story [0-9]+\\.[0-9]+-"`, which expects the description to include a story label such as `"Story 021.0-DEV-TEST-TRACEABILITY"`. You can override this to instead require full story paths or whatever story-labeling convention your project prefers.
|
|
214
216
|
- `autoFixTestTemplate` (boolean, optional) – When `true` (default), allows the rule’s `--fix` mode to insert a file-level `@supports` placeholder template at the top of test files that are missing it. The template is intentionally non-semantic and includes TODO-style guidance so humans can later replace it with a real story path and requirement IDs; disabling this option prevents the rule from inserting the template automatically.
|
|
215
217
|
- `autoFixTestPrefixFormat` (boolean, optional) – When `true` (default), enables safe normalization of malformed `[REQ-XXX]` prefixes in `it`/`test` names during `--fix`. The rule only rewrites prefixes that already contain a recognizable requirement identifier and limits changes to formatting concerns (spacing, square brackets vs. parentheses, underscore and dash usage, and letter casing) without fabricating new IDs or guessing requirement names.
|
|
216
218
|
- `testSupportsTemplate` (string, optional) – Overrides the default file-level `@supports` placeholder template used when `autoFixTestTemplate` is enabled. This string should be a complete JSDoc-style block (for example, including `/**`, `*`, and `*/`) that encodes your project’s preferred TODO guidance or placeholder story path; it is inserted verbatim at the top of matching test files that lack a `@supports` annotation, and is never interpreted or expanded by the rule.
|
|
217
219
|
|
|
220
|
+
You can tune these options to fit your own testing and naming conventions: adjust `testFilePatterns` to match your project’s test layout (including monorepos or non-standard folders), override `describePattern` if you prefer full `docs/stories/...` paths or a different story-labeling scheme in `describe` strings, and change `requireTestReqPrefix` and `autoFixTestPrefixFormat` if you want to relax, enforce, or customize the `[REQ-...]` prefix requirements for test names.
|
|
221
|
+
|
|
218
222
|
Behavior notes:
|
|
219
223
|
|
|
220
224
|
- The rule only analyzes files whose normalized paths contain at least one of the `testFilePatterns` substrings.
|
|
221
225
|
- File-level `@supports` annotations are typically placed in a JSDoc block at the top of the file; the rule checks that at least one `@supports` tag is present and that it includes a story/requirement reference (for example, `@supports docs/stories/010.0-PAYMENTS.story.md#REQ-PAYMENTS-REFUND`).
|
|
222
|
-
- Top-level `describe` calls (such as `describe("
|
|
226
|
+
- Top-level `describe` calls (such as `describe("Story 010.0-DEV-PAYMENTS", ...)`) are inspected when `requireDescribeStory` is `true`. Their first argument must be a string literal that satisfies `describePattern`.
|
|
223
227
|
- Test cases declared via `it(...)` or `test(...)` must use a string literal name beginning with a requirement prefix like `[REQ-PAYMENTS-REFUND]` when `requireTestReqPrefix` is `true`.
|
|
224
228
|
|
|
225
229
|
Default Severity: `error`
|
|
@@ -242,6 +246,110 @@ describe("Refunds flow docs/stories/010.0-PAYMENTS.story.md", () => {
|
|
|
242
246
|
});
|
|
243
247
|
```
|
|
244
248
|
|
|
249
|
+
### traceability/prefer-implements-annotation
|
|
250
|
+
|
|
251
|
+
Description: An optional, opt-in migration helper that encourages converting legacy single‑story `@story` + `@req` JSDoc blocks into the newer multi‑story `@supports` format. The rule is **disabled by default** and is **not included in any built‑in preset**; you enable it explicitly and control its behavior entirely via ESLint severity (`"off" | "warn" | "error"`). It does not change what the core rules consider valid—it only adds migration recommendations and safe auto‑fixes on top of existing validation.
|
|
252
|
+
|
|
253
|
+
Options: None – this rule does not accept a configuration object. All tuning is done via the ESLint rule level (`"off"`, `"warn"`, `"error"`).
|
|
254
|
+
|
|
255
|
+
This rule focuses on **single‑story** legacy blocks where automatic migration is unambiguous. It inspects JSDoc comments attached to function‑like constructs and looks for the following patterns:
|
|
256
|
+
|
|
257
|
+
- A single `@story` annotation with one story path.
|
|
258
|
+
- One or more simple `@req` lines in the same block (each with a single requirement ID).
|
|
259
|
+
- No `@supports` annotations yet present in that block.
|
|
260
|
+
|
|
261
|
+
When these conditions are met, the rule recommends replacing the legacy block with a single `@supports` line that encodes the same relationship between the story and its requirements.
|
|
262
|
+
|
|
263
|
+
Main behaviors:
|
|
264
|
+
|
|
265
|
+
1. **Single‑story legacy blocks → `preferImplements` (auto‑fixable)**
|
|
266
|
+
When a JSDoc block contains exactly one `@story` path and one or more simple `@req` identifiers, and no `@supports` tags, the rule reports a `preferImplements` diagnostic. In `--fix` mode, and when it is safe to do so, it rewrites the block to a consolidated `@supports` annotation of the form:
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
/**
|
|
270
|
+
* @supports docs/stories/010.0-PAYMENTS.story.md#REQ-PAYMENTS-REFUND REQ-PAYMENTS-EDGE
|
|
271
|
+
*/
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Conceptually, the auto‑fix:
|
|
275
|
+
|
|
276
|
+
- Extracts the single `@story` value.
|
|
277
|
+
- Collects the requirement IDs from each `@req` line in that block.
|
|
278
|
+
- Emits a single `@supports story-path#REQ-1 REQ-2 ...` line (or your project’s equivalent anchor scheme).
|
|
279
|
+
|
|
280
|
+
All legacy `@story` and `@req` tags in that block are removed as part of the fix, since their meaning is now captured by the `@supports` line. The fix is only applied when the story path and requirement IDs are straightforward to parse; complex or ambiguous shapes are left for manual migration.
|
|
281
|
+
|
|
282
|
+
2. **Mixed usage with existing `@supports` → `cannotAutoFix` (manual migration)**
|
|
283
|
+
If a JSDoc block already contains at least one `@supports` annotation **and** still has legacy `@story`/`@req` tags, the rule treats this as a mixed‑style block. In this case, it reports a `cannotAutoFix` diagnostic that includes a human‑readable `reason` explaining that the block already uses `@supports` and must be cleaned up manually.
|
|
284
|
+
|
|
285
|
+
The rule **does not** attempt to merge or rewrite mixed blocks automatically, to avoid guessing your intended story/requirement grouping. All annotations in such blocks are left unchanged; you are expected to convert them to your preferred `@supports` shape by hand.
|
|
286
|
+
|
|
287
|
+
3. **Multiple distinct `@story` paths → `multiStoryDetected` (manual migration)**
|
|
288
|
+
When the same JSDoc block contains **multiple different `@story` paths**, the rule reports a `multiStoryDetected` diagnostic and leaves the block unchanged. This scenario usually indicates integration code that implements requirements from several stories, and the correct multi-story `@supports` representation depends on how your project organizes those relationships.
|
|
289
|
+
|
|
290
|
+
Because there is no universally safe way to automatically group requirements across multiple stories, the rule does **not** attempt any auto‑fix in this case. Instead, it highlights the block so humans can migrate it to one or more explicit `@supports` annotations following your multi‑story conventions.
|
|
291
|
+
|
|
292
|
+
Deliberate non‑targets and ignored comments:
|
|
293
|
+
|
|
294
|
+
- JSDoc blocks that contain **only** `@story`, **only** `@req`, or **only** `@supports` are **not** modified by this rule. They remain valid and continue to be governed solely by the core rules such as `require-story-annotation`, `require-req-annotation`, and `valid-annotation-format`.
|
|
295
|
+
- Inline or line comments like `// @story ...`, `// @req ...`, or `// @supports ...` are intentionally ignored by this migration helper; they are still checked by the underlying validation rules where applicable.
|
|
296
|
+
- Any block that does not match the “single story + simple requirements, no supports” shape is treated conservatively: the rule may report a diagnostic to flag the legacy/mixed pattern, but it will not rewrite comments unless it is clearly safe.
|
|
297
|
+
|
|
298
|
+
Interaction with other rules:
|
|
299
|
+
|
|
300
|
+
- Enabling this rule does **not** change what is required or permitted by:
|
|
301
|
+
- `traceability/valid-annotation-format`
|
|
302
|
+
- `traceability/valid-req-reference`
|
|
303
|
+
- `traceability/require-story-annotation`
|
|
304
|
+
- `traceability/require-req-annotation`
|
|
305
|
+
- All existing `@story` + `@req` blocks that pass those rules are still valid when this rule is off. Turning it on simply adds a migration layer that nudges you toward the consolidated `@supports` style and, where unambiguous, performs structural rewrites on your behalf.
|
|
306
|
+
|
|
307
|
+
Example: single‑story auto‑fix
|
|
308
|
+
|
|
309
|
+
Given this legacy JSDoc block:
|
|
310
|
+
|
|
311
|
+
```js
|
|
312
|
+
/**
|
|
313
|
+
* @story docs/stories/010.0-PAYMENTS.story.md
|
|
314
|
+
* @req REQ-PAYMENTS-REFUND
|
|
315
|
+
* @req REQ-PAYMENTS-REFUND-EDGE
|
|
316
|
+
*/
|
|
317
|
+
function issueRefund() {
|
|
318
|
+
// ...
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
With `traceability/prefer-implements-annotation` enabled and ESLint run with `--fix`, the rule rewrites it to:
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
/**
|
|
326
|
+
* @supports docs/stories/010.0-PAYMENTS.story.md#REQ-PAYMENTS-REFUND REQ-PAYMENTS-REFUND-EDGE
|
|
327
|
+
*/
|
|
328
|
+
function issueRefund() {
|
|
329
|
+
// ...
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
All other function‑level rules (such as `require-story-annotation`, `require-req-annotation`, and `valid-annotation-format`) continue to validate the resulting `@supports` annotation according to your existing configuration.
|
|
334
|
+
|
|
335
|
+
Configuration example (opt‑in at `"warn"`):
|
|
336
|
+
|
|
337
|
+
```js
|
|
338
|
+
// eslint.config.js (flat config)
|
|
339
|
+
import js from "@eslint/js";
|
|
340
|
+
import traceability from "eslint-plugin-traceability";
|
|
341
|
+
|
|
342
|
+
export default [
|
|
343
|
+
js.configs.recommended,
|
|
344
|
+
traceability.configs.recommended,
|
|
345
|
+
{
|
|
346
|
+
rules: {
|
|
347
|
+
"traceability/prefer-implements-annotation": "warn"
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
];
|
|
351
|
+
```
|
|
352
|
+
|
|
245
353
|
## Configuration Presets
|
|
246
354
|
|
|
247
355
|
The plugin provides two built-in presets for easy configuration:
|
|
@@ -574,5 +682,4 @@ If `--from` or `--to` is missing, the CLI prints an error, shows the help text,
|
|
|
574
682
|
In CI:
|
|
575
683
|
|
|
576
684
|
```bash
|
|
577
|
-
npm run traceability:verify
|
|
578
|
-
```
|
|
685
|
+
npm run traceability:verify
|
package/user-docs/examples.md
CHANGED
|
@@ -84,7 +84,7 @@ Create a Jest test file, for example `tests/dev-test-traceability.spec.ts`:
|
|
|
84
84
|
* @supports docs/stories/021.0-DEV-TEST-TRACEABILITY.story.md#REQ-TEST-TRACEABILITY
|
|
85
85
|
*/
|
|
86
86
|
|
|
87
|
-
describe("
|
|
87
|
+
describe("Story 021.0-DEV-TEST-TRACEABILITY", () => {
|
|
88
88
|
it("[REQ-TEST-TRACEABILITY] should handle the primary test scenario", () => {
|
|
89
89
|
// Arrange
|
|
90
90
|
const input = "happy-path";
|
|
@@ -112,5 +112,4 @@ describe("docs/stories/021.0-DEV-TEST-TRACEABILITY.story.md", () => {
|
|
|
112
112
|
function performOperation(input: string): string {
|
|
113
113
|
if (input === "edge-case") return "edge-ok";
|
|
114
114
|
return "ok";
|
|
115
|
-
}
|
|
116
|
-
```
|
|
115
|
+
}
|
|
@@ -73,8 +73,41 @@ For teams that want to gradually migrate from `@story` + `@req` to `@supports`,
|
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
This rule is an **optional migration aid**, not a deprecation notice. `@story` and `@req` remain fully supported, and there is no hard requirement or deadline to migrate existing annotations. Use the rule only where `@supports` gives you clearer, multi-story traceability.
|
|
77
|
+
|
|
78
|
+
When enabled, it offers **conservative auto-fixes** that rewrite eligible `@story` + `@req` combinations into equivalent `@supports` lines, without attempting risky or ambiguous transformations. It intentionally refuses to modify comments that are even slightly unclear, and will instead surface diagnostics that explain what needs manual attention.
|
|
79
|
+
|
|
80
|
+
Aligned with the internal rule behavior, the key cases are:
|
|
81
|
+
|
|
82
|
+
- **Simple, single-story JSDoc blocks**
|
|
83
|
+
For comments that contain exactly one `@story` path and one or more simple `@req` lines, the rule:
|
|
84
|
+
- Reports a recommendation to consolidate them, and
|
|
85
|
+
- In `--fix` mode, converts them into a single `@supports` line that keeps the same story path and requirement IDs.
|
|
86
|
+
|
|
87
|
+
- **Mixed `@story` / `@req` plus existing `@supports`**
|
|
88
|
+
For comments that already contain one or more `@supports` lines alongside `@story` and/or `@req`, the rule:
|
|
89
|
+
- Reports a diagnostic explaining that mixed usage cannot be auto-fixed safely, and
|
|
90
|
+
- Leaves the comment unchanged so you can decide how to migrate it manually.
|
|
91
|
+
|
|
92
|
+
- **Multiple distinct `@story` paths**
|
|
93
|
+
For comments that refer to more than one different `@story` path, the rule:
|
|
94
|
+
- Reports that multiple stories were detected, and
|
|
95
|
+
- Requires you to manually convert them into separate `@supports` lines (one per story path, each followed by the appropriate requirement IDs).
|
|
96
|
+
|
|
97
|
+
- **Intentionally ignored comments**
|
|
98
|
+
The following are **ignored** by this rule and remain valid:
|
|
99
|
+
- Comments that contain only `@story` lines,
|
|
100
|
+
- Comments that contain only `@req` lines,
|
|
101
|
+
- Comments that contain only `@supports` lines, and
|
|
102
|
+
- Line comments such as `// @story ...`.
|
|
103
|
+
|
|
104
|
+
These forms are still supported by the plugin and are not modified by `traceability/prefer-implements-annotation`.
|
|
105
|
+
|
|
106
|
+
A typical migration path is:
|
|
107
|
+
|
|
108
|
+
- Start with the rule set to `"off"` while you introduce `@supports` in new or refactored code.
|
|
109
|
+
- Enable it as `"warn"` to get non-breaking guidance and auto-fixes for straightforward cases.
|
|
110
|
+
- Optionally move to `"error"` once you want to strictly enforce `@supports` usage for all JSDoc blocks that are eligible for safe conversion.
|
|
78
111
|
|
|
79
112
|
#### When to keep `@story` + `@req`
|
|
80
113
|
|
|
@@ -171,4 +204,4 @@ Production dependency guarantees are enforced by CI scripts that run `npm audit
|
|
|
171
204
|
|
|
172
205
|
---
|
|
173
206
|
|
|
174
|
-
If you encounter any issues during migration, please file an issue at https://github.com/voder-ai/eslint-plugin-traceability/issues.
|
|
207
|
+
If you encounter any issues during migration, please file an issue at https://github.com/voder-ai/eslint-plugin-traceability/issues.
|