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
|
@@ -138,6 +138,38 @@ function fallbackTextBeforeHasReq(sourceCode, node) {
|
|
|
138
138
|
}
|
|
139
139
|
return false;
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Helper to combine advanced, location-based heuristics for requirement detection.
|
|
143
|
+
* Uses preceding lines, parent-chain comments, and fallback text windows to find @req/@supports.
|
|
144
|
+
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
145
|
+
* @story docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md
|
|
146
|
+
* @req REQ-ANNOTATION-REQ-DETECTION - Use multiple heuristics to detect @req markers around the node
|
|
147
|
+
* @req REQ-REQUIRE-ACCEPTS-IMPLEMENTS - Use multiple heuristics to detect @supports markers around the node
|
|
148
|
+
*/
|
|
149
|
+
function hasReqInAdvancedHeuristics(sourceCode, node) {
|
|
150
|
+
if (!sourceCode || !node) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return (linesBeforeHasReq(sourceCode, node) ||
|
|
154
|
+
parentChainHasReq(sourceCode, node) ||
|
|
155
|
+
fallbackTextBeforeHasReq(sourceCode, node));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Helper to check JSDoc and nearby comments for requirement annotations.
|
|
159
|
+
* Accepts both @req and @supports markers as evidence of requirement coverage.
|
|
160
|
+
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
161
|
+
* @story docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md
|
|
162
|
+
* @req REQ-ANNOTATION-REQ-DETECTION - Determine presence of @req annotation in JSDoc/comments
|
|
163
|
+
* @req REQ-REQUIRE-ACCEPTS-IMPLEMENTS - Accept @supports as requirement coverage in JSDoc/comments
|
|
164
|
+
*/
|
|
165
|
+
function hasReqInJsdocOrComments(jsdoc, comments) {
|
|
166
|
+
if (jsdoc &&
|
|
167
|
+
typeof jsdoc.value === "string" &&
|
|
168
|
+
(jsdoc.value.includes("@req") || jsdoc.value.includes("@supports"))) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
return comments.some(commentContainsReq);
|
|
172
|
+
}
|
|
141
173
|
/**
|
|
142
174
|
* Helper to determine whether a JSDoc or any nearby comments contain a requirement annotation.
|
|
143
175
|
* Treats both @req and @supports annotations as evidence of requirement coverage.
|
|
@@ -151,30 +183,12 @@ function hasReqAnnotation(jsdoc, comments, context, node) {
|
|
|
151
183
|
const sourceCode = context && typeof context.getSourceCode === "function"
|
|
152
184
|
? context.getSourceCode()
|
|
153
185
|
: undefined;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// @req REQ-ANNOTATION-REQ-DETECTION - Use multiple heuristics to detect @req markers around the node
|
|
157
|
-
// @req REQ-REQUIRE-ACCEPTS-IMPLEMENTS - Use multiple heuristics to detect @supports markers around the node
|
|
158
|
-
if (sourceCode && node) {
|
|
159
|
-
if (linesBeforeHasReq(sourceCode, node) ||
|
|
160
|
-
parentChainHasReq(sourceCode, node) ||
|
|
161
|
-
fallbackTextBeforeHasReq(sourceCode, node)) {
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
186
|
+
if (hasReqInAdvancedHeuristics(sourceCode, node)) {
|
|
187
|
+
return true;
|
|
164
188
|
}
|
|
165
189
|
}
|
|
166
190
|
catch {
|
|
167
|
-
//
|
|
168
|
-
// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
169
|
-
// @req REQ-ANNOTATION-REQ-DETECTION - Fail gracefully when advanced detection heuristics throw
|
|
191
|
+
// swallow and fall through to simple checks
|
|
170
192
|
}
|
|
171
|
-
|
|
172
|
-
// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
173
|
-
// @story docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md
|
|
174
|
-
// @req REQ-ANNOTATION-REQ-DETECTION
|
|
175
|
-
// @req REQ-REQUIRE-ACCEPTS-IMPLEMENTS
|
|
176
|
-
return ((jsdoc &&
|
|
177
|
-
typeof jsdoc.value === "string" &&
|
|
178
|
-
(jsdoc.value.includes("@req") || jsdoc.value.includes("@supports"))) ||
|
|
179
|
-
comments.some(commentContainsReq));
|
|
193
|
+
return hasReqInJsdocOrComments(jsdoc, comments);
|
|
180
194
|
}
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
* Tests for CLI error handling when plugin loading fails
|
|
8
8
|
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
9
9
|
* @req REQ-ERROR-HANDLING - Plugin CLI should exit with error on rule load failure
|
|
10
|
+
* @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-ERROR-HANDLING
|
|
10
11
|
*/
|
|
11
12
|
const child_process_1 = require("child_process");
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for ESLint config rule schemas.
|
|
4
|
+
*
|
|
5
|
+
* @supports docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
|
|
6
|
+
* @req REQ-RULE-OPTIONS
|
|
7
|
+
* @req REQ-CONFIG-VALIDATION
|
|
8
|
+
* @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
|
|
9
|
+
*/
|
|
2
10
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
11
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
12
|
};
|
|
@@ -36,9 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
/**
|
|
37
37
|
* Tests for: docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
|
|
38
38
|
* @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
|
|
39
|
-
* @
|
|
40
|
-
* @req REQ-FLAT-CONFIG - Ensure presets work with ESLint v9 flat config
|
|
41
|
-
* @req REQ-PROJECT-INTEGRATION - Support seamless integration via documented preset usage
|
|
39
|
+
* @supports docs/stories/002.0-DEV-ESLINT-CONFIG.story.md REQ-CONFIG-PRESETS REQ-FLAT-CONFIG REQ-PROJECT-INTEGRATION
|
|
42
40
|
*/
|
|
43
41
|
const use_at_your_own_risk_1 = require("eslint/use-at-your-own-risk");
|
|
44
42
|
const index_1 = __importStar(require("../../src/index"));
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the require-story-annotation rule schema configuration.
|
|
3
|
+
*
|
|
4
|
+
* Verifies that the ESLint rule options for require-story-annotation
|
|
5
|
+
* define the expected schema properties and constraints.
|
|
6
|
+
*
|
|
7
|
+
* @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
|
|
8
|
+
* @supports docs/stories/002.0-DEV-ESLINT-CONFIG.story.md REQ-RULE-OPTIONS
|
|
9
|
+
*/
|
|
1
10
|
export {};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for the require-story-annotation rule schema configuration.
|
|
4
|
+
*
|
|
5
|
+
* Verifies that the ESLint rule options for require-story-annotation
|
|
6
|
+
* define the expected schema properties and constraints.
|
|
7
|
+
*
|
|
8
|
+
* @story docs/stories/002.0-DEV-ESLINT-CONFIG.story.md
|
|
9
|
+
* @supports docs/stories/002.0-DEV-ESLINT-CONFIG.story.md REQ-RULE-OPTIONS
|
|
10
|
+
*/
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -3,6 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* Tests for CLI integration of the traceability plugin.
|
|
8
|
+
* Validates that the plugin registers correctly and enforces
|
|
9
|
+
* traceability-related rules when invoked via the ESLint CLI.
|
|
10
|
+
*
|
|
11
|
+
* @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-PLUGIN-STRUCTURE
|
|
12
|
+
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
13
|
+
*/
|
|
6
14
|
/**
|
|
7
15
|
* Tests for CLI integration functionality
|
|
8
16
|
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
@@ -10,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
18
|
*/
|
|
11
19
|
const child_process_1 = require("child_process");
|
|
12
20
|
const path_1 = __importDefault(require("path"));
|
|
13
|
-
describe("
|
|
21
|
+
describe("CLI Integration (Story 001.0-DEV-PLUGIN-SETUP)", () => {
|
|
14
22
|
const eslintPkgDir = path_1.default.dirname(require.resolve("eslint/package.json"));
|
|
15
23
|
const eslintCliPath = path_1.default.join(eslintPkgDir, "bin", "eslint.js");
|
|
16
24
|
const configPath = path_1.default.resolve(__dirname, "../../eslint.config.js");
|
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
39
39
|
* @req REQ-MAINT-BATCH - Perform batch updates
|
|
40
40
|
* @req REQ-MAINT-VERIFY - Verify annotation references
|
|
41
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-BATCH REQ-MAINT-VERIFY
|
|
41
42
|
*/
|
|
42
43
|
const fs = __importStar(require("fs"));
|
|
43
44
|
const path = __importStar(require("path"));
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
* @req REQ-MAINT-REPORT - CLI reporting of stale annotations
|
|
12
12
|
* @req REQ-MAINT-UPDATE - CLI updating of annotation references
|
|
13
13
|
* @req REQ-MAINT-SAFE - Clear exit codes and non-destructive dry-run
|
|
14
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT REQ-MAINT-VERIFY REQ-MAINT-REPORT REQ-MAINT-UPDATE REQ-MAINT-SAFE
|
|
14
15
|
*/
|
|
15
16
|
const fs_1 = __importDefault(require("fs"));
|
|
16
17
|
const path_1 = __importDefault(require("path"));
|
|
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
* Tests for: docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
38
38
|
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
39
39
|
* @req REQ-MAINT-DETECT - Detect stale annotation references
|
|
40
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
|
|
40
41
|
*/
|
|
41
42
|
const path = __importStar(require("path"));
|
|
42
43
|
const os = __importStar(require("os"));
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
* Tests for: docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
8
8
|
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
9
9
|
* @req REQ-MAINT-DETECT - Detect stale annotation references
|
|
10
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-DETECT
|
|
10
11
|
*/
|
|
11
12
|
const fs_1 = __importDefault(require("fs"));
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* Tests for: docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
5
5
|
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
6
6
|
* @req REQ-MAINT-SAFE - Ensure all maintenance tools are exported correctly
|
|
7
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-SAFE REQ-MAINT-DETECT REQ-MAINT-UPDATE REQ-MAINT-BATCH REQ-MAINT-VERIFY REQ-MAINT-REPORT
|
|
7
8
|
*/
|
|
8
9
|
const maintenance_1 = require("../../src/maintenance");
|
|
9
10
|
describe("Maintenance Tools Index Exports (Story 009.0-DEV-MAINTENANCE-TOOLS)", () => {
|
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
39
39
|
* @req REQ-MAINT-REPORT - Generate maintenance report
|
|
40
40
|
* @req REQ-MAINT-SAFE - Ensure operations are safe and reversible
|
|
41
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-REPORT REQ-MAINT-SAFE
|
|
41
42
|
*/
|
|
42
43
|
const fs = __importStar(require("fs"));
|
|
43
44
|
const path = __importStar(require("path"));
|
|
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
* Tests for: docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
38
38
|
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
39
39
|
* @req REQ-MAINT-UPDATE - Update annotation references
|
|
40
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-UPDATE
|
|
40
41
|
*/
|
|
41
42
|
const fs = __importStar(require("fs"));
|
|
42
43
|
const path = __importStar(require("path"));
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
* Tests for: docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
8
8
|
* @story docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md
|
|
9
9
|
* @req REQ-MAINT-UPDATE - Update annotation references
|
|
10
|
+
* @supports docs/stories/009.0-DEV-MAINTENANCE-TOOLS.story.md REQ-MAINT-UPDATE
|
|
10
11
|
*/
|
|
11
12
|
const fs_1 = __importDefault(require("fs"));
|
|
12
13
|
const os_1 = __importDefault(require("os"));
|
|
@@ -35,6 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
/**
|
|
37
37
|
* Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
38
|
+
* @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-PLUGIN-STRUCTURE REQ-RULE-REGISTRY REQ-CONFIG-SYSTEM
|
|
39
|
+
* @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-SEVERITY
|
|
38
40
|
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
39
41
|
* @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
|
|
40
42
|
* @req REQ-PLUGIN-STRUCTURE - Validate plugin default export and configs in src/index.ts
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
* Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
3
3
|
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
4
4
|
* @req REQ-ERROR-HANDLING - Gracefully handles plugin loading errors and missing dependencies
|
|
5
|
+
* @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-ERROR-HANDLING
|
|
5
6
|
*/
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
4
4
|
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
5
5
|
* @req REQ-ERROR-HANDLING - Gracefully handles plugin loading errors and missing dependencies
|
|
6
|
+
* @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-ERROR-HANDLING
|
|
6
7
|
*/
|
|
7
8
|
describe("Traceability ESLint Plugin Error Handling (Story 001.0-DEV-PLUGIN-SETUP)", () => {
|
|
8
9
|
beforeEach(() => {
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
/**
|
|
37
37
|
* Tests for: docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
38
38
|
* @story docs/stories/001.0-DEV-PLUGIN-SETUP.story.md
|
|
39
|
-
* @
|
|
39
|
+
* @supports docs/stories/001.0-DEV-PLUGIN-SETUP.story.md REQ-PLUGIN-STRUCTURE
|
|
40
40
|
*/
|
|
41
41
|
const index_1 = __importStar(require("../src/index"));
|
|
42
42
|
describe("Traceability ESLint Plugin (Story 001.0-DEV-PLUGIN-SETUP)", () => {
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
* @story docs/stories/008.0-DEV-AUTO-FIX.story.md
|
|
9
9
|
* @req REQ-AUTOFIX-MISSING - Verify ESLint --fix automatically adds missing @story annotations to functions
|
|
10
10
|
* @req REQ-AUTOFIX-FORMAT - Verify ESLint --fix corrects simple annotation format issues for @story annotations
|
|
11
|
+
* @supports docs/stories/008.0-DEV-AUTO-FIX.story.md REQ-AUTOFIX-MISSING REQ-AUTOFIX-FORMAT
|
|
11
12
|
*/
|
|
12
13
|
const eslint_1 = require("eslint");
|
|
13
14
|
const require_story_annotation_1 = __importDefault(require("../../src/rules/require-story-annotation"));
|
|
@@ -177,6 +178,21 @@ describe("Auto-fix behavior (Story 008.0-DEV-AUTO-FIX)", () => {
|
|
|
177
178
|
},
|
|
178
179
|
],
|
|
179
180
|
},
|
|
181
|
+
{
|
|
182
|
+
name: "[REQ-AUTOFIX-SELECTIVE] does not apply suffix fix when autoFix is false",
|
|
183
|
+
code: `// @story docs/stories/005.0-DEV-ANNOTATION-VALIDATION.story`,
|
|
184
|
+
output: null,
|
|
185
|
+
options: [
|
|
186
|
+
{
|
|
187
|
+
autoFix: false,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
errors: [
|
|
191
|
+
{
|
|
192
|
+
messageId: "invalidStoryFormat",
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
},
|
|
180
196
|
],
|
|
181
197
|
});
|
|
182
198
|
});
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
/**
|
|
7
7
|
* Tests for: docs/stories/007.0-DEV-ERROR-REPORTING.story.md
|
|
8
8
|
* @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
|
|
9
|
+
* @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-SPECIFIC REQ-ERROR-SUGGESTION REQ-ERROR-CONTEXT REQ-ERROR-LOCATION
|
|
9
10
|
* @req REQ-ERROR-SPECIFIC - Specific details about what annotation is missing or invalid
|
|
10
11
|
* @req REQ-ERROR-SUGGESTION - Suggest concrete steps to fix the issue
|
|
11
12
|
* @req REQ-ERROR-CONTEXT - Include relevant context in error messages
|
|
@@ -33,6 +33,14 @@ describe("prefer-implements-annotation rule (Story 010.3-DEV-MIGRATE-TO-SUPPORTS
|
|
|
33
33
|
name: "[REQ-BACKWARD-COMP-VALIDATION] comment with @supports only is ignored",
|
|
34
34
|
code: `/**\n * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED\n */\nfunction alreadyImplements() {}`,
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
name: "[REQ-BACKWARD-COMP-VALIDATION] comment with @story and @supports but no @req is ignored",
|
|
38
|
+
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED\n */\nfunction storyAndSupportsNoReq() {}`,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "[REQ-BACKWARD-COMP-VALIDATION] comment with @req and @supports but no @story is ignored",
|
|
42
|
+
code: `/**\n * @req REQ-ANNOTATION-REQUIRED\n * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED\n */\nfunction reqAndSupportsNoStory() {}`,
|
|
43
|
+
},
|
|
36
44
|
],
|
|
37
45
|
invalid: [
|
|
38
46
|
{
|
|
@@ -11,6 +11,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
* @req REQ-ERROR-SPECIFIC - Branch-level missing-annotation error messages are specific and informative
|
|
12
12
|
* @req REQ-ERROR-CONSISTENCY - Branch-level missing-annotation error messages follow shared conventions
|
|
13
13
|
* @req REQ-ERROR-SUGGESTION - Branch-level missing-annotation errors include suggestions when applicable
|
|
14
|
+
* @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-BRANCH-DETECTION
|
|
15
|
+
* @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-SPECIFIC REQ-ERROR-CONSISTENCY REQ-ERROR-SUGGESTION
|
|
14
16
|
*/
|
|
15
17
|
const eslint_1 = require("eslint");
|
|
16
18
|
const require_branch_annotation_1 = __importDefault(require("../../src/rules/require-branch-annotation"));
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* Edge-case tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
6
|
* @req REQ-AUTOFIX - Cover additional branch cases in require-story-core (addStoryFixer/reportMissing)
|
|
7
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-AUTOFIX
|
|
7
8
|
*/
|
|
8
9
|
const require_story_core_1 = require("../../src/rules/helpers/require-story-core");
|
|
9
10
|
const require_story_core_test_helpers_1 = require("../utils/require-story-core-test-helpers");
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
6
|
* @req REQ-AUTOFIX - Cover additional branch cases in require-story-core (addStoryFixer/reportMissing)
|
|
7
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-AUTOFIX
|
|
7
8
|
*/
|
|
8
9
|
const require_story_core_1 = require("../../src/rules/helpers/require-story-core");
|
|
9
10
|
const require_story_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
6
|
* @req REQ-AUTOFIX - Verify createMethodFix and reportMethod behaviors
|
|
7
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-AUTOFIX
|
|
7
8
|
*/
|
|
8
9
|
const require_story_core_1 = require("../../src/rules/helpers/require-story-core");
|
|
9
10
|
const require_story_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
3
3
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @req REQ-HELPERS-EDGE-CASES - Edge-case behavior tests for helpers in require-story-helpers.ts
|
|
5
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-HELPERS-EDGE-CASES
|
|
5
6
|
*/
|
|
6
7
|
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @req REQ-HELPERS-EDGE-CASES - Edge-case behavior tests for helpers in require-story-helpers.ts
|
|
6
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-HELPERS-EDGE-CASES
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
const require_story_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
6
6
|
* @req REQ-ANNOTATION-REQUIRED - Verify helper functions in require-story helpers produce correct fixes and reporting behavior
|
|
7
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
|
|
7
8
|
*/
|
|
8
9
|
const require_story_core_1 = require("../../src/rules/helpers/require-story-core");
|
|
9
10
|
const require_story_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
|
|
@@ -49,7 +50,7 @@ describe("Require Story Helpers (Story 003.0)", () => {
|
|
|
49
50
|
test("reportMissing does not call context.report if JSDoc contains @story", () => {
|
|
50
51
|
const node = {
|
|
51
52
|
type: "FunctionDeclaration",
|
|
52
|
-
id: { name: "fn" },
|
|
53
|
+
id: { type: "Identifier", name: "fn" },
|
|
53
54
|
range: [0, 10],
|
|
54
55
|
};
|
|
55
56
|
const fakeSource = {
|
|
@@ -68,7 +69,7 @@ describe("Require Story Helpers (Story 003.0)", () => {
|
|
|
68
69
|
test("reportMissing calls context.report when no JSDoc story present", () => {
|
|
69
70
|
const node = {
|
|
70
71
|
type: "FunctionDeclaration",
|
|
71
|
-
id: { name: "fn2" },
|
|
72
|
+
id: { type: "Identifier", name: "fn2" },
|
|
72
73
|
range: [0, 10],
|
|
73
74
|
};
|
|
74
75
|
const fakeSource = {
|
|
@@ -82,7 +83,7 @@ describe("Require Story Helpers (Story 003.0)", () => {
|
|
|
82
83
|
(0, require_story_helpers_1.reportMissing)(context, fakeSource, { node, target: node });
|
|
83
84
|
expect(context.report).toHaveBeenCalledTimes(1);
|
|
84
85
|
const call = context.report.mock.calls[0][0];
|
|
85
|
-
expect(call.node).toBe(node);
|
|
86
|
+
expect(call.node).toBe(node.id);
|
|
86
87
|
expect(call.messageId).toBe("missingStory");
|
|
87
88
|
});
|
|
88
89
|
/**
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
3
3
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @req REQ-IO-BEHAVIOR-EDGE-CASES - Edge-case behavior tests for IO helpers in require-story-io.ts
|
|
5
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-IO-BEHAVIOR-EDGE-CASES
|
|
5
6
|
*/
|
|
6
7
|
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @req REQ-IO-BEHAVIOR-EDGE-CASES - Edge-case behavior tests for IO helpers in require-story-io.ts
|
|
6
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-IO-BEHAVIOR-EDGE-CASES
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
const require_story_io_1 = require("../../src/rules/helpers/require-story-io");
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
3
3
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @req REQ-ANNOTATION-REQUIRED - Edge case tests for IO helpers (linesBeforeHasStory/fallbackTextBeforeHasStory/parentChainHasStory)
|
|
5
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
|
|
5
6
|
*/
|
|
6
7
|
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @req REQ-ANNOTATION-REQUIRED - Edge case tests for IO helpers (linesBeforeHasStory/fallbackTextBeforeHasStory/parentChainHasStory)
|
|
6
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
const require_story_io_1 = require("../../src/rules/helpers/require-story-io");
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
3
3
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @req REQ-VISITORS-BEHAVIOR - Behavior tests for visitors in require-story-visitors.ts
|
|
5
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-VISITORS-BEHAVIOR
|
|
5
6
|
*/
|
|
6
7
|
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
4
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
5
|
* @req REQ-VISITORS-BEHAVIOR - Behavior tests for visitors in require-story-visitors.ts
|
|
6
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-VISITORS-BEHAVIOR
|
|
6
7
|
*/
|
|
7
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
const require_story_visitors_1 = require("../../src/rules/helpers/require-story-visitors");
|
|
@@ -45,6 +45,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
* @req REQ-ERROR-CONTEXT - Verify file-related error messages include contextual information (path, underlying error)
|
|
46
46
|
* @req REQ-ERROR-CONSISTENCY - Verify file-related error messages follow consistent formatting and identifiers
|
|
47
47
|
* @req REQ-ERROR-HANDLING - Verify file-related errors are reported via diagnostics instead of uncaught exceptions
|
|
48
|
+
* @supports docs/stories/006.0-DEV-FILE-VALIDATION.story.md REQ-FILE-EXISTENCE REQ-CONFIGURABLE-PATHS
|
|
49
|
+
* @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-SPECIFIC REQ-ERROR-CONTEXT REQ-ERROR-CONSISTENCY REQ-ERROR-HANDLING
|
|
48
50
|
*/
|
|
49
51
|
const eslint_1 = require("eslint");
|
|
50
52
|
const valid_story_reference_1 = __importDefault(require("../../src/rules/valid-story-reference"));
|
|
@@ -6,6 +6,7 @@ exports.runAnnotationCheckerTests = runAnnotationCheckerTests;
|
|
|
6
6
|
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
7
7
|
* @req REQ-TYPESCRIPT-SUPPORT - Support TypeScript-specific function syntax
|
|
8
8
|
* @req REQ-TEST-UTILS-TS-LANG - Shared TS RuleTester language options helper
|
|
9
|
+
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-TYPESCRIPT-SUPPORT REQ-TEST-UTILS-TS-LANG
|
|
9
10
|
*/
|
|
10
11
|
const eslint_1 = require("eslint");
|
|
11
12
|
const annotation_checker_1 = require("../../src/utils/annotation-checker");
|
|
@@ -52,7 +53,7 @@ const rule = {
|
|
|
52
53
|
};
|
|
53
54
|
},
|
|
54
55
|
};
|
|
55
|
-
describe("annotation-checker helper", () => {
|
|
56
|
+
describe("annotation-checker helper (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", () => {
|
|
56
57
|
runAnnotationCheckerTests("annotation-checker", {
|
|
57
58
|
rule,
|
|
58
59
|
valid: [
|
|
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
* Tests for: docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
6
6
|
* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
7
7
|
* @req REQ-CONFIGURABLE-SCOPE - Allow configuration of branch types for annotation enforcement
|
|
8
|
+
* @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-CONFIGURABLE-SCOPE
|
|
8
9
|
*/
|
|
9
10
|
const branch_annotation_helpers_1 = require("../../src/utils/branch-annotation-helpers");
|
|
10
|
-
describe("validateBranchTypes helper", () => {
|
|
11
|
+
describe("validateBranchTypes helper (Story 004.0-DEV-BRANCH-ANNOTATIONS)", () => {
|
|
11
12
|
let context;
|
|
12
13
|
beforeEach(() => {
|
|
13
14
|
context = { options: [], report: jest.fn() };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-traceability",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.1",
|
|
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",
|