eslint-plugin-traceability 1.22.0 → 1.23.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 CHANGED
@@ -1,14 +1,9 @@
1
- # [1.22.0](https://github.com/voder-ai/eslint-plugin-traceability/compare/v1.21.1...v1.22.0) (2026-01-10)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * move voder-ai to optionalDependencies to allow CI without GitHub Packages access ([1a674cb](https://github.com/voder-ai/eslint-plugin-traceability/commit/1a674cb65d5223c75710910817393667435bfcd8))
1
+ # [1.23.0](https://github.com/voder-ai/eslint-plugin-traceability/compare/v1.22.0...v1.23.0) (2026-01-10)
7
2
 
8
3
 
9
4
  ### Features
10
5
 
11
- * **ci:** add post-deployment verification step ([00d3d21](https://github.com/voder-ai/eslint-plugin-traceability/commit/00d3d214f21e18bfc26e3de4fbcb0bd9f0aa8f28))
6
+ * **rules:** add ArrowFunctionExpression support to require-req-annotation ([92d2e60](https://github.com/voder-ai/eslint-plugin-traceability/commit/92d2e60686c661faa58c41fd533e7d9e6acbae18))
12
7
 
13
8
  # Changelog
14
9
 
@@ -2,6 +2,56 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const require_story_helpers_1 = require("./helpers/require-story-helpers");
4
4
  const annotation_checker_1 = require("../utils/annotation-checker");
5
+ /**
6
+ * Build visitor handlers for require-req-annotation rule.
7
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
8
+ * @req REQ-FUNCTION-DETECTION - Provide visitor construction for all function types
9
+ */
10
+ function buildReqAnnotationVisitors(runCheck) {
11
+ return {
12
+ /**
13
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
14
+ * @req REQ-FUNCTION-DETECTION - Detect function declarations
15
+ * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on function declarations
16
+ */
17
+ FunctionDeclaration: runCheck,
18
+ /**
19
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
20
+ * @req REQ-FUNCTION-DETECTION - Detect function expressions
21
+ * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on function expressions
22
+ */
23
+ FunctionExpression(node) {
24
+ if (node.parent && node.parent.type === "MethodDefinition") {
25
+ return;
26
+ }
27
+ runCheck(node);
28
+ },
29
+ /**
30
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
31
+ * @req REQ-FUNCTION-DETECTION - Detect arrow function expressions
32
+ * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on arrow function expressions
33
+ */
34
+ ArrowFunctionExpression: runCheck,
35
+ /**
36
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
37
+ * @req REQ-FUNCTION-DETECTION - Detect method definitions
38
+ * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on method definitions
39
+ */
40
+ MethodDefinition: runCheck,
41
+ /**
42
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
43
+ * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript declare functions
44
+ * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on TS declare functions
45
+ */
46
+ TSDeclareFunction: runCheck,
47
+ /**
48
+ * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
49
+ * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript method signatures
50
+ * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on TS method signatures
51
+ */
52
+ TSMethodSignature: runCheck,
53
+ };
54
+ }
5
55
  const rule = {
6
56
  meta: {
7
57
  type: "problem",
@@ -78,51 +128,7 @@ const rule = {
78
128
  annotationPlacement,
79
129
  });
80
130
  };
81
- return {
82
- /**
83
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
84
- * @req REQ-FUNCTION-DETECTION - Detect function declarations
85
- * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on function declarations
86
- */
87
- FunctionDeclaration(node) {
88
- runCheck(node);
89
- },
90
- /**
91
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
92
- * @req REQ-FUNCTION-DETECTION - Detect function expressions
93
- * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on function expressions
94
- */
95
- FunctionExpression(node) {
96
- if (node.parent && node.parent.type === "MethodDefinition") {
97
- return;
98
- }
99
- runCheck(node);
100
- },
101
- /**
102
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
103
- * @req REQ-FUNCTION-DETECTION - Detect method definitions
104
- * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on method definitions
105
- */
106
- MethodDefinition(node) {
107
- runCheck(node);
108
- },
109
- /**
110
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
111
- * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript declare functions
112
- * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on TS declare functions
113
- */
114
- TSDeclareFunction(node) {
115
- runCheck(node);
116
- },
117
- /**
118
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
119
- * @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript method signatures
120
- * @req REQ-ANNOTATION-REQUIRED - Enforce @req annotation on TS method signatures
121
- */
122
- TSMethodSignature(node) {
123
- runCheck(node);
124
- },
125
- };
131
+ return buildReqAnnotationVisitors(runCheck);
126
132
  },
127
133
  };
128
134
  exports.default = rule;
@@ -94,6 +94,14 @@ describe("Require Req Annotation Rule (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", (
94
94
  name: "[REQ-FUNCTION-DETECTION][Story 003.0] valid MethodDefinition with @req annotation",
95
95
  code: `class C {\n /**\n * @req REQ-EXAMPLE\n */\n m() {}\n}`,
96
96
  },
97
+ {
98
+ name: "[REQ-FUNCTION-DETECTION][Story 003.0] valid ArrowFunctionExpression with @req annotation",
99
+ code: `/** @req REQ-EXAMPLE */\nconst arrow = () => {};`,
100
+ },
101
+ {
102
+ name: "[REQ-FUNCTION-DETECTION][Story 003.0] valid exported ArrowFunctionExpression with @req annotation",
103
+ code: `/** @req REQ-EXAMPLE */\nexport const arrow = () => {};`,
104
+ },
97
105
  (0, ts_language_options_1.withTsLanguageOptions)({
98
106
  name: "[REQ-TYPESCRIPT-SUPPORT][REQ-FUNCTION-DETECTION][Story 003.0] valid TS FunctionExpression in variable declarator with @req",
99
107
  code: `const fn = /**\n * @req REQ-EXAMPLE\n */\nfunction () {};`,
@@ -189,6 +197,16 @@ describe("Require Req Annotation Rule (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", (
189
197
  code: `const o = { m() {} };`,
190
198
  errors: [missingReq("m")],
191
199
  },
200
+ {
201
+ name: "[REQ-FUNCTION-DETECTION][Story 003.0] missing @req on ArrowFunctionExpression",
202
+ code: `const arrow = () => {};`,
203
+ errors: [missingReq("arrow")],
204
+ },
205
+ {
206
+ name: "[REQ-FUNCTION-DETECTION][Story 003.0] missing @req on exported ArrowFunctionExpression",
207
+ code: `export const arrow = () => {};`,
208
+ errors: [missingReq("arrow")],
209
+ },
192
210
  (0, ts_language_options_1.withTsLanguageOptions)({
193
211
  name: "[REQ-TYPESCRIPT-SUPPORT][REQ-FUNCTION-DETECTION][Story 003.0] missing @req on TS FunctionExpression in variable declarator",
194
212
  code: `const fn = function () {};`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-traceability",
3
- "version": "1.22.0",
3
+ "version": "1.23.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/src/index.js",
6
6
  "types": "lib/src/index.d.ts",
@@ -51,8 +51,7 @@
51
51
  "debug:require-story": "node scripts/debug-require-story.js",
52
52
  "debug:repro": "node scripts/debug-repro.js",
53
53
  "report:eslint-suppressions": "node scripts/report-eslint-suppressions.js",
54
- "check:scripts": "node scripts/validate-scripts-nonempty.js",
55
- "voder": "voder --help"
54
+ "check:scripts": "node scripts/validate-scripts-nonempty.js"
56
55
  },
57
56
  "lint-staged": {
58
57
  "src/**/*.{js,jsx,ts,tsx,json,md}": [
@@ -100,9 +99,6 @@
100
99
  "ts-jest": "^29.4.6",
101
100
  "typescript": "^5.9.3"
102
101
  },
103
- "optionalDependencies": {
104
- "@voder-ai/voder-ai": "^5.6.1"
105
- },
106
102
  "peerDependencies": {
107
103
  "eslint": "^9.0.0"
108
104
  },
@@ -63,13 +63,13 @@ Among the supported scopes, anonymous callbacks passed directly to common test f
63
63
 
64
64
  ### traceability/require-req-annotation
65
65
 
66
- 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 that function-like constructs consistently declare their linked requirements via traceability annotations, preferring `@supports` when possible while still accepting `@req`. The rule targets the same function-like node types as `traceability/require-story-annotation` (standard function declarations, non-arrow function expressions used as callbacks or assignments, class/object methods, TypeScript declare functions, and interface method signatures), and enforces that each of them has at least one `@req` tag in the nearest associated JSDoc comment. When you adopt multi-story `@supports` annotations, this rule also treats `@supports story-path REQ-ID...` tags as satisfying the requirement coverage check, although deep verification of requirement IDs continues to be handled by `traceability/valid-req-reference`. Arrow functions (`ArrowFunctionExpression`) are not currently checked by this rule.
66
+ 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 that function-like constructs consistently declare their linked requirements via traceability annotations, preferring `@supports` when possible while still accepting `@req`. The rule targets the same function-like node types as `traceability/require-story-annotation` (standard function declarations, function expressions, arrow functions, class/object methods, TypeScript declare functions, and interface method signatures), and enforces that each of them has at least one `@req` tag in the nearest associated JSDoc comment. When you adopt multi-story `@supports` annotations, this rule also treats `@supports story-path REQ-ID...` tags as satisfying the requirement coverage check, although deep verification of requirement IDs continues to be handled by `traceability/valid-req-reference`.
67
67
 
68
68
  This rule is typically used alongside `traceability/require-story-annotation` so that each function-level traceability block includes both an `@story` and an `@req` annotation, but it can also be enabled independently if you only want to enforce requirement linkage. Unlike `traceability/require-story-annotation`, this rule does not currently provide an auto-fix mode for inserting placeholder `@req` annotations; it only reports missing or malformed requirement annotations on the configured scopes.
69
69
 
70
70
  Options:
71
71
 
72
- - `scope` (string[], optional) – Controls which function-like node types are required to have @req annotations. Allowed values: "FunctionDeclaration", "FunctionExpression", "MethodDefinition", "TSDeclareFunction", "TSMethodSignature". Default: ["FunctionDeclaration", "FunctionExpression", "MethodDefinition", "TSDeclareFunction", "TSMethodSignature"].
72
+ - `scope` (string[], optional) – Controls which function-like node types are required to have @req annotations. Allowed values: "FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression", "MethodDefinition", "TSDeclareFunction", "TSMethodSignature". Default: ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression", "MethodDefinition", "TSDeclareFunction", "TSMethodSignature"].
73
73
  - `exportPriority` ("all" | "exported" | "non-exported", optional) – Controls whether the rule checks all functions, only exported ones, or only non-exported ones. Default: "all".
74
74
  - `annotationPlacement` ("before" | "inside", optional)  Controls whether the rule treats before-function comments as the source of annotations (`"before"`, the default and backward-compatible behavior) or instead requires annotations as the first comment-only lines inside function and method bodies (`"inside"`). In `"inside"` mode, JSDoc and before-function comments are ignored for block-bodied functions and methods, and only inside-body comments are considered; declaration-only nodes (e.g., TS signatures) continue to use before-node annotations.
75
75