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
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
# require-req-annotation
|
|
2
|
-
|
|
3
|
-
Enforces the presence of `@req` annotations on functions and methods to ensure each implementation maps to a specific requirement ID.
|
|
4
|
-
|
|
5
|
-
@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
|
-
@req REQ-ANNOTATION-REQUIRED - Require `@req` annotation on functions
|
|
7
|
-
|
|
8
|
-
## Rule Details
|
|
9
|
-
|
|
10
|
-
This rule validates that the following nodes have a leading JSDoc comment containing an `@req` annotation:
|
|
11
|
-
|
|
12
|
-
- Function declarations
|
|
13
|
-
- Function expressions (non-arrow function expressions used in assignments or callbacks)
|
|
14
|
-
- Method definitions (class and object methods)
|
|
15
|
-
- TypeScript declare functions (`TSDeclareFunction`)
|
|
16
|
-
- TypeScript method signatures (`TSMethodSignature`)
|
|
17
|
-
|
|
18
|
-
Note: Arrow functions (`ArrowFunctionExpression`) are not currently checked by this rule. Support for arrow functions may be added in a future version once the underlying stories and schemas are extended.
|
|
19
|
-
|
|
20
|
-
By default, this rule uses the same detection scope as `require-story-annotation`, meaning it only checks functions and methods that are considered "in scope" by the same rules (e.g., exported functions when using export‑based scopes).
|
|
21
|
-
|
|
22
|
-
If a function or method is in scope and does not have a JSDoc with an `@req` tag, it is reported as a violation.
|
|
23
|
-
|
|
24
|
-
## Options
|
|
25
|
-
|
|
26
|
-
This rule accepts an options object with the same overall semantics and defaults as `require-story-annotation`, but applied to `@req` detection:
|
|
27
|
-
|
|
28
|
-
```json
|
|
29
|
-
{
|
|
30
|
-
"scope": [
|
|
31
|
-
"FunctionDeclaration",
|
|
32
|
-
"FunctionExpression",
|
|
33
|
-
"MethodDefinition",
|
|
34
|
-
"TSDeclareFunction",
|
|
35
|
-
"TSMethodSignature"
|
|
36
|
-
],
|
|
37
|
-
"exportPriority": "all" | "exported" | "non-exported"
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Both properties are optional.
|
|
42
|
-
|
|
43
|
-
### `scope`
|
|
44
|
-
|
|
45
|
-
`scope` is an optional array of node type strings that controls which kinds of function-like nodes are required to have an `@req` annotation.
|
|
46
|
-
|
|
47
|
-
Allowed values in the array are:
|
|
48
|
-
|
|
49
|
-
- `"FunctionDeclaration"`
|
|
50
|
-
- `"FunctionExpression"`
|
|
51
|
-
- `"MethodDefinition"`
|
|
52
|
-
- `"TSDeclareFunction"`
|
|
53
|
-
- `"TSMethodSignature"`
|
|
54
|
-
|
|
55
|
-
If `scope` is omitted, the rule defaults to the full set:
|
|
56
|
-
|
|
57
|
-
```json
|
|
58
|
-
{
|
|
59
|
-
"scope": [
|
|
60
|
-
"FunctionDeclaration",
|
|
61
|
-
"FunctionExpression",
|
|
62
|
-
"MethodDefinition",
|
|
63
|
-
"TSDeclareFunction",
|
|
64
|
-
"TSMethodSignature"
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
These semantics and defaults mirror `require-story-annotation`.
|
|
70
|
-
|
|
71
|
-
### `exportPriority`
|
|
72
|
-
|
|
73
|
-
`exportPriority` is an optional string that controls which functions/methods are considered in scope based on their export status. It uses the same semantics and defaults as `require-story-annotation`:
|
|
74
|
-
|
|
75
|
-
- `"all"` (default)
|
|
76
|
-
Check all nodes of the types listed in `scope`, regardless of export status.
|
|
77
|
-
|
|
78
|
-
- `"exported"`
|
|
79
|
-
Check only nodes of the types listed in `scope` that are considered exported.
|
|
80
|
-
|
|
81
|
-
- `"non-exported"`
|
|
82
|
-
Check only nodes of the types listed in `scope` that are not considered exported.
|
|
83
|
-
|
|
84
|
-
If `exportPriority` is omitted, it defaults to `"all"`.
|
|
85
|
-
|
|
86
|
-
## Examples
|
|
87
|
-
|
|
88
|
-
### Correct
|
|
89
|
-
|
|
90
|
-
Function declaration with `@req`:
|
|
91
|
-
|
|
92
|
-
```js
|
|
93
|
-
/**
|
|
94
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
95
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
96
|
-
*/
|
|
97
|
-
function initAuth() {
|
|
98
|
-
// authentication logic
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Function expression with `@req`:
|
|
103
|
-
|
|
104
|
-
```js
|
|
105
|
-
/**
|
|
106
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
107
|
-
*/
|
|
108
|
-
const initAuth = function () {
|
|
109
|
-
// authentication logic
|
|
110
|
-
};
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Class method with `@req`:
|
|
114
|
-
|
|
115
|
-
```js
|
|
116
|
-
class AuthService {
|
|
117
|
-
/**
|
|
118
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
119
|
-
*/
|
|
120
|
-
initAuth() {
|
|
121
|
-
// authentication logic
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Incorrect
|
|
127
|
-
|
|
128
|
-
Missing `@req` on a function declaration:
|
|
129
|
-
|
|
130
|
-
```js
|
|
131
|
-
/**
|
|
132
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
133
|
-
*/
|
|
134
|
-
function initAuth() {
|
|
135
|
-
// authentication logic
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Missing `@req` on a function expression:
|
|
140
|
-
|
|
141
|
-
```js
|
|
142
|
-
/**
|
|
143
|
-
* This initializes authentication.
|
|
144
|
-
*/
|
|
145
|
-
const initAuth = function () {
|
|
146
|
-
// authentication logic
|
|
147
|
-
};
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Missing `@req` on a class method:
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
class AuthService {
|
|
154
|
-
/**
|
|
155
|
-
* Initializes authentication.
|
|
156
|
-
*/
|
|
157
|
-
initAuth() {
|
|
158
|
-
// authentication logic
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### TypeScript Specific Syntax
|
|
164
|
-
|
|
165
|
-
#### TSDeclareFunction
|
|
166
|
-
|
|
167
|
-
Incorrect:
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
// Missing @req annotation
|
|
171
|
-
declare function initAuth(): void;
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Correct:
|
|
175
|
-
|
|
176
|
-
```ts
|
|
177
|
-
/**
|
|
178
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
179
|
-
*/
|
|
180
|
-
declare function initAuth(): void;
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
#### TSMethodSignature
|
|
184
|
-
|
|
185
|
-
Incorrect:
|
|
186
|
-
|
|
187
|
-
```ts
|
|
188
|
-
// Missing @req annotation on interface method
|
|
189
|
-
interface I {
|
|
190
|
-
method(): void;
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Correct:
|
|
195
|
-
|
|
196
|
-
```ts
|
|
197
|
-
/**
|
|
198
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
199
|
-
*/
|
|
200
|
-
interface I {
|
|
201
|
-
method(): void;
|
|
202
|
-
}
|
|
203
|
-
```
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
# require-story-annotation
|
|
2
|
-
|
|
3
|
-
Enforces the presence of `@story` annotations on function declarations to ensure traceability from code to user stories.
|
|
4
|
-
|
|
5
|
-
@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
|
-
@req REQ-ANNOTATION-REQUIRED - Require `@story` annotation on functions
|
|
7
|
-
|
|
8
|
-
## Rule Details
|
|
9
|
-
|
|
10
|
-
This rule checks function-like nodes to ensure each has a JSDoc comment containing an `@story` annotation pointing to the relevant story file. Supported node types include TSDeclareFunction and TSMethodSignature in addition to standard function nodes.
|
|
11
|
-
|
|
12
|
-
### Supported Node Types
|
|
13
|
-
|
|
14
|
-
- FunctionDeclaration
|
|
15
|
-
- FunctionExpression
|
|
16
|
-
- MethodDefinition
|
|
17
|
-
- TSDeclareFunction
|
|
18
|
-
- TSMethodSignature
|
|
19
|
-
|
|
20
|
-
### Options Schema
|
|
21
|
-
|
|
22
|
-
This rule accepts a single options object with the following optional properties:
|
|
23
|
-
|
|
24
|
-
- **scope** (array of strings)
|
|
25
|
-
- Items enum: [
|
|
26
|
-
"FunctionDeclaration",
|
|
27
|
-
"FunctionExpression",
|
|
28
|
-
"MethodDefinition",
|
|
29
|
-
"TSDeclareFunction",
|
|
30
|
-
"TSMethodSignature"
|
|
31
|
-
]
|
|
32
|
-
- Default: [
|
|
33
|
-
"FunctionDeclaration",
|
|
34
|
-
"FunctionExpression",
|
|
35
|
-
"MethodDefinition",
|
|
36
|
-
"TSDeclareFunction",
|
|
37
|
-
"TSMethodSignature"
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
- **exportPriority** (string)
|
|
41
|
-
- Enum: ["all", "exported", "non-exported"]
|
|
42
|
-
- Default: "all"
|
|
43
|
-
|
|
44
|
-
Note: The `scope` option is limited to the listed node types; arrow functions are not currently configurable via this option.
|
|
45
|
-
|
|
46
|
-
Default:
|
|
47
|
-
|
|
48
|
-
```js
|
|
49
|
-
{
|
|
50
|
-
scope: [
|
|
51
|
-
"FunctionDeclaration",
|
|
52
|
-
"FunctionExpression",
|
|
53
|
-
"MethodDefinition",
|
|
54
|
-
"TSDeclareFunction",
|
|
55
|
-
"TSMethodSignature",
|
|
56
|
-
],
|
|
57
|
-
exportPriority: "all",
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
JSON schema:
|
|
62
|
-
|
|
63
|
-
```json
|
|
64
|
-
{
|
|
65
|
-
"type": "object",
|
|
66
|
-
"properties": {
|
|
67
|
-
"scope": {
|
|
68
|
-
"type": "array",
|
|
69
|
-
"items": {
|
|
70
|
-
"enum": [
|
|
71
|
-
"FunctionDeclaration",
|
|
72
|
-
"FunctionExpression",
|
|
73
|
-
"MethodDefinition",
|
|
74
|
-
"TSDeclareFunction",
|
|
75
|
-
"TSMethodSignature"
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
"uniqueItems": true
|
|
79
|
-
},
|
|
80
|
-
"exportPriority": {
|
|
81
|
-
"type": "string",
|
|
82
|
-
"enum": ["all", "exported", "non-exported"]
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"additionalProperties": false
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
#### Example Configuration (.eslintrc.js)
|
|
90
|
-
|
|
91
|
-
```js
|
|
92
|
-
module.exports = {
|
|
93
|
-
rules: {
|
|
94
|
-
"traceability/require-story-annotation": [
|
|
95
|
-
"error",
|
|
96
|
-
{
|
|
97
|
-
scope: ["FunctionDeclaration"],
|
|
98
|
-
exportPriority: "exported",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Examples
|
|
106
|
-
|
|
107
|
-
#### Correct
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
/**
|
|
111
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
112
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
113
|
-
*/
|
|
114
|
-
function initAuth() {
|
|
115
|
-
// authentication logic
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
#### Incorrect
|
|
120
|
-
|
|
121
|
-
```js
|
|
122
|
-
function initAuth() {
|
|
123
|
-
// authentication logic
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
#### TypeScript Specific Examples
|
|
128
|
-
|
|
129
|
-
##### Correct
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
/**
|
|
133
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
134
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
135
|
-
*/
|
|
136
|
-
declare function initAuth(): void;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
```ts
|
|
140
|
-
interface IAuth {
|
|
141
|
-
/**
|
|
142
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
143
|
-
* @req REQ-ANNOTATION-REQUIRED
|
|
144
|
-
*/
|
|
145
|
-
login(user: Credentials): boolean;
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
##### Incorrect
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
declare function initAuth(): void;
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
```ts
|
|
156
|
-
interface IAuth {
|
|
157
|
-
logout(): void;
|
|
158
|
-
}
|
|
159
|
-
```
|