eslint-plugin-traceability 1.23.1 → 1.24.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 +3 -9
- package/lib/rules/require-traceability.js +49 -4
- package/package.json +1 -1
- package/user-docs/api-reference.md +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
# [1.24.0](https://github.com/voder-ai/eslint-plugin-traceability/compare/v1.23.1...v1.24.0) (2026-01-10)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
7
|
-
* correct plugin path in smoke test to lib/index.js ([3f343f6](https://github.com/voder-ai/eslint-plugin-traceability/commit/3f343f6686eaad9ce2528f9da7b6895c8bb083b7))
|
|
8
|
-
* correct runtime smoke test path resolution in CI ([bf20b02](https://github.com/voder-ai/eslint-plugin-traceability/commit/bf20b025e4e9743f2a87f259959ba61563196b11))
|
|
9
|
-
* correct smoke test ESLint rule name and test file annotations ([766b767](https://github.com/voder-ai/eslint-plugin-traceability/commit/766b76731713d2cadb36fb5b5619ee3a5c1d0fa9))
|
|
10
|
-
* correct TypeScript output paths from lib/src to lib ([9c82640](https://github.com/voder-ai/eslint-plugin-traceability/commit/9c8264027080ef8333bdd21106fdd773df3e4fd7))
|
|
11
|
-
* use direct path to eslint.js in smoke test ([401c1ee](https://github.com/voder-ai/eslint-plugin-traceability/commit/401c1ee750e43c7dc68f46f67b09be6cc790e809))
|
|
12
|
-
* use project eslint binary instead of npx in smoke test ([1c8cfce](https://github.com/voder-ai/eslint-plugin-traceability/commit/1c8cfcecba6f947808375694a318995421dabab3))
|
|
6
|
+
* add auto-fix support to require-traceability rule ([ee35349](https://github.com/voder-ai/eslint-plugin-traceability/commit/ee353492bfbebbc18dba7ae8e4d32b8ec386bdf1))
|
|
13
7
|
|
|
14
8
|
# Changelog
|
|
15
9
|
|
|
@@ -39,7 +39,7 @@ const rule = {
|
|
|
39
39
|
recommended: "error",
|
|
40
40
|
},
|
|
41
41
|
hasSuggestions: true,
|
|
42
|
-
fixable:
|
|
42
|
+
fixable: "code",
|
|
43
43
|
messages: {
|
|
44
44
|
// Unified messageId for potential future direct use by this rule.
|
|
45
45
|
missingTraceability: "Function '{{name}}' must declare both story and requirement traceability annotations.",
|
|
@@ -48,11 +48,56 @@ const rule = {
|
|
|
48
48
|
...(storyRule.meta?.messages ?? {}),
|
|
49
49
|
...(reqRule.meta?.messages ?? {}),
|
|
50
50
|
},
|
|
51
|
-
schema: [
|
|
51
|
+
schema: [
|
|
52
|
+
{
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
scope: {
|
|
56
|
+
type: "array",
|
|
57
|
+
items: {
|
|
58
|
+
type: "string",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
exportPriority: {
|
|
62
|
+
type: "string",
|
|
63
|
+
enum: ["all", "exported", "non-exported"],
|
|
64
|
+
},
|
|
65
|
+
annotationTemplate: {
|
|
66
|
+
type: "string",
|
|
67
|
+
},
|
|
68
|
+
methodAnnotationTemplate: {
|
|
69
|
+
type: "string",
|
|
70
|
+
},
|
|
71
|
+
autoFix: {
|
|
72
|
+
type: "boolean",
|
|
73
|
+
description: "When false, disables automatic fix behavior while retaining diagnostics. When true (default), the rule inserts placeholder annotations in --fix mode.",
|
|
74
|
+
},
|
|
75
|
+
excludeTestCallbacks: {
|
|
76
|
+
type: "boolean",
|
|
77
|
+
},
|
|
78
|
+
annotationPlacement: {
|
|
79
|
+
type: "string",
|
|
80
|
+
enum: ["before", "inside"],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
additionalProperties: false,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
52
86
|
},
|
|
53
87
|
create(context) {
|
|
54
|
-
|
|
55
|
-
|
|
88
|
+
// Create a modified context that passes through options to composed rules
|
|
89
|
+
// We need to preserve all context methods while modifying the options array
|
|
90
|
+
const options = context.options[0] || {};
|
|
91
|
+
const modifiedContext = Object.create(context, {
|
|
92
|
+
options: {
|
|
93
|
+
value: [options],
|
|
94
|
+
writable: false,
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable: false,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const storyListeners = storyRule.create(modifiedContext) || {};
|
|
100
|
+
const reqListeners = reqRule.create(modifiedContext) || {};
|
|
56
101
|
const mergedListener = {};
|
|
57
102
|
const allEventNames = new Set([
|
|
58
103
|
...Object.keys(storyListeners),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-traceability",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "A customizable ESLint plugin that enforces traceability annotations in your code, ensuring each implementation is linked to its requirement or test case.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -32,6 +32,31 @@ All three rule keys can still be configured individually if you need fine-graine
|
|
|
32
32
|
|
|
33
33
|
Description: Unified function-level traceability rule that composes the behavior of `traceability/require-story-annotation` and `traceability/require-req-annotation`. When enabled, it enforces that in‑scope functions and methods carry both a story reference (`@story` or an equivalent `@supports` tag) and at least one requirement reference (`@req` or, when configured, `@supports`). The recommended flat‑config presets in this plugin enable `traceability/require-traceability` by default alongside the legacy rule keys for backward compatibility, so that existing configurations referring to `traceability/require-story-annotation` or `traceability/require-req-annotation` continue to work without change.
|
|
34
34
|
|
|
35
|
+
When run with `--fix`, the rule delegates auto-fix behavior to its composed rules, primarily adding placeholder `@story` annotations for missing story coverage via the underlying `require-story-annotation` implementation. The rule supports the same `autoFix` option as the legacy rules, allowing you to disable automatic fixes while retaining diagnostics. All options (including `annotationTemplate`, `methodAnnotationTemplate`, `autoFix`, `scope`, `exportPriority`, `excludeTestCallbacks`, and `annotationPlacement`) are passed through to the composed rules, ensuring consistent behavior across the unified and legacy rule keys.
|
|
36
|
+
|
|
37
|
+
Options:
|
|
38
|
+
|
|
39
|
+
- `scope` (string[], optional) – Controls which function-like node types are required to have traceability annotations. Passed through to composed rules. Default behavior matches require-story-annotation defaults.
|
|
40
|
+
- `exportPriority` ("all" | "exported" | "non-exported", optional) – Controls whether the rule checks all functions, only exported ones, or only non-exported ones. Passed through to composed rules. Default: "all".
|
|
41
|
+
- `annotationTemplate` (string, optional) – Overrides the default placeholder JSDoc used when inserting missing `@story` annotations. Passed through to require-story-annotation. When omitted or blank, the built-in template from Story 008.0 is used.
|
|
42
|
+
- `methodAnnotationTemplate` (string, optional) – Overrides the default placeholder JSDoc used for class methods and TypeScript method signatures. Passed through to require-story-annotation.
|
|
43
|
+
- `autoFix` (boolean, optional) – When set to `false`, disables all automatic fix behavior for this rule while retaining its suggestions and diagnostics. When omitted or `true`, the rule behaves as before, inserting placeholder annotations in `--fix` mode. This option is passed through to the composed rules.
|
|
44
|
+
- `excludeTestCallbacks` (boolean, optional) – When `true` (default), excludes anonymous arrow functions that are direct callbacks to common test framework functions from annotation requirements. Passed through to composed rules.
|
|
45
|
+
- `annotationPlacement` ("before" | "inside", optional) – Controls whether annotations are expected before functions (`"before"`, default) or as the first lines inside function bodies (`"inside"`). Passed through to composed rules.
|
|
46
|
+
|
|
47
|
+
Default Severity: `error`
|
|
48
|
+
Example:
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
/**
|
|
52
|
+
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
53
|
+
* @req REQ-ANNOTATION-REQUIRED
|
|
54
|
+
*/
|
|
55
|
+
function initAuth() {
|
|
56
|
+
// authentication logic
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
35
60
|
### traceability/require-story-annotation
|
|
36
61
|
|
|
37
62
|
Description: **Legacy function-level key:** This rule key is retained for backward compatibility and conceptually composes the same checks as `traceability/require-traceability`. New configurations should normally enable `traceability/require-traceability` instead and rely on this key only when you need to tune it independently. Ensures every function declaration has a traceability annotation, preferring `@supports` for story coverage while still accepting legacy `@story` annotations referencing the related user story. When you adopt multi-story `@supports` annotations, this rule also accepts `@supports` as an alternative way to prove story coverage, so either `@story` or at least one `@supports` tag will satisfy the presence check. When run with `--fix`, the rule inserts a single-line placeholder JSDoc `@story` annotation above missing functions, methods, TypeScript declare functions, and interface method signatures using a built-in template aligned with Story 008.0. This template is now configurable on a per-rule basis, and the rule exposes an explicit auto-fix toggle so you can choose between diagnostic-only behavior and automatic placeholder insertion. The default template remains aligned with Story 008.0, but you can now customize it per rule configuration and optionally disable auto-fix entirely when you only want diagnostics without edits.
|