eslint-plugin-traceability 1.23.0 → 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 +2 -2
- package/lib/{src/rules → rules}/require-traceability.js +49 -4
- package/package.json +8 -8
- package/user-docs/api-reference.md +25 -0
- package/lib/tests/cli-error-handling.test.d.ts +0 -1
- package/lib/tests/cli-error-handling.test.js +0 -54
- package/lib/tests/config/eslint-config-validation.test.d.ts +0 -9
- package/lib/tests/config/eslint-config-validation.test.js +0 -101
- package/lib/tests/config/flat-config-presets-integration.test.d.ts +0 -1
- package/lib/tests/config/flat-config-presets-integration.test.js +0 -76
- package/lib/tests/config/require-story-annotation-config.test.d.ts +0 -10
- package/lib/tests/config/require-story-annotation-config.test.js +0 -26
- package/lib/tests/fixtures/stale/example.d.ts +0 -0
- package/lib/tests/fixtures/stale/example.js +0 -4
- package/lib/tests/fixtures/update/example.d.ts +0 -0
- package/lib/tests/fixtures/update/example.js +0 -4
- package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
- package/lib/tests/fixtures/valid-annotations/example.js +0 -3
- package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.d.ts +0 -1
- package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.js +0 -133
- package/lib/tests/integration/catch-annotation-prettier.integration.test.d.ts +0 -1
- package/lib/tests/integration/catch-annotation-prettier.integration.test.js +0 -121
- package/lib/tests/integration/cli-integration.test.d.ts +0 -1
- package/lib/tests/integration/cli-integration.test.js +0 -96
- package/lib/tests/integration/else-if-annotation-prettier.integration.test.d.ts +0 -1
- package/lib/tests/integration/else-if-annotation-prettier.integration.test.js +0 -100
- package/lib/tests/integration/no-redundant-annotation.integration.test.d.ts +0 -1
- package/lib/tests/integration/no-redundant-annotation.integration.test.js +0 -129
- package/lib/tests/integration/prettier-test-helpers.d.ts +0 -9
- package/lib/tests/integration/prettier-test-helpers.js +0 -35
- package/lib/tests/integration/require-traceability-aliases.integration.test.d.ts +0 -1
- package/lib/tests/integration/require-traceability-aliases.integration.test.js +0 -152
- package/lib/tests/integration/require-traceability-test-callbacks.integration.test.d.ts +0 -1
- package/lib/tests/integration/require-traceability-test-callbacks.integration.test.js +0 -149
- package/lib/tests/maintenance/batch.test.d.ts +0 -1
- package/lib/tests/maintenance/batch.test.js +0 -80
- package/lib/tests/maintenance/cli.test.d.ts +0 -1
- package/lib/tests/maintenance/cli.test.js +0 -306
- package/lib/tests/maintenance/detect-isolated.test.d.ts +0 -1
- package/lib/tests/maintenance/detect-isolated.test.js +0 -187
- package/lib/tests/maintenance/detect.test.d.ts +0 -1
- package/lib/tests/maintenance/detect.test.js +0 -46
- package/lib/tests/maintenance/index.test.d.ts +0 -1
- package/lib/tests/maintenance/index.test.js +0 -26
- package/lib/tests/maintenance/report.test.d.ts +0 -1
- package/lib/tests/maintenance/report.test.js +0 -68
- package/lib/tests/maintenance/storyParser.test.d.ts +0 -8
- package/lib/tests/maintenance/storyParser.test.js +0 -505
- package/lib/tests/maintenance/update-isolated.test.d.ts +0 -1
- package/lib/tests/maintenance/update-isolated.test.js +0 -71
- package/lib/tests/maintenance/update.test.d.ts +0 -1
- package/lib/tests/maintenance/update.test.js +0 -27
- package/lib/tests/perf/maintenance-cli-large-workspace.test.d.ts +0 -1
- package/lib/tests/perf/maintenance-cli-large-workspace.test.js +0 -229
- package/lib/tests/perf/maintenance-large-workspace.test.d.ts +0 -1
- package/lib/tests/perf/maintenance-large-workspace.test.js +0 -169
- package/lib/tests/perf/require-branch-annotation-large-file.test.d.ts +0 -1
- package/lib/tests/perf/require-branch-annotation-large-file.test.js +0 -67
- package/lib/tests/perf/valid-annotation-format-large-file.test.d.ts +0 -1
- package/lib/tests/perf/valid-annotation-format-large-file.test.js +0 -75
- package/lib/tests/plugin-default-export-and-configs.test.d.ts +0 -1
- package/lib/tests/plugin-default-export-and-configs.test.js +0 -121
- package/lib/tests/plugin-setup-error.test.d.ts +0 -6
- package/lib/tests/plugin-setup-error.test.js +0 -38
- package/lib/tests/plugin-setup.test.d.ts +0 -1
- package/lib/tests/plugin-setup.test.js +0 -63
- package/lib/tests/rules/auto-fix-behavior-008.test.d.ts +0 -1
- package/lib/tests/rules/auto-fix-behavior-008.test.js +0 -285
- package/lib/tests/rules/error-reporting.test.d.ts +0 -1
- package/lib/tests/rules/error-reporting.test.js +0 -99
- package/lib/tests/rules/no-redundant-annotation.test.d.ts +0 -1
- package/lib/tests/rules/no-redundant-annotation.test.js +0 -163
- package/lib/tests/rules/prefer-implements-annotation.test.d.ts +0 -1
- package/lib/tests/rules/prefer-implements-annotation.test.js +0 -162
- package/lib/tests/rules/require-branch-annotation.test.d.ts +0 -1
- package/lib/tests/rules/require-branch-annotation.test.js +0 -593
- package/lib/tests/rules/require-req-annotation.test.d.ts +0 -1
- package/lib/tests/rules/require-req-annotation.test.js +0 -264
- package/lib/tests/rules/require-story-annotation.test.d.ts +0 -1
- package/lib/tests/rules/require-story-annotation.test.js +0 -376
- package/lib/tests/rules/require-story-core-edgecases.test.d.ts +0 -1
- package/lib/tests/rules/require-story-core-edgecases.test.js +0 -15
- package/lib/tests/rules/require-story-core.autofix.test.d.ts +0 -1
- package/lib/tests/rules/require-story-core.autofix.test.js +0 -66
- package/lib/tests/rules/require-story-core.test.d.ts +0 -1
- package/lib/tests/rules/require-story-core.test.js +0 -65
- package/lib/tests/rules/require-story-helpers-edgecases.test.d.ts +0 -7
- package/lib/tests/rules/require-story-helpers-edgecases.test.js +0 -80
- package/lib/tests/rules/require-story-helpers.test.d.ts +0 -1
- package/lib/tests/rules/require-story-helpers.test.js +0 -474
- package/lib/tests/rules/require-story-io-behavior.test.d.ts +0 -7
- package/lib/tests/rules/require-story-io-behavior.test.js +0 -46
- package/lib/tests/rules/require-story-io.edgecases.test.d.ts +0 -7
- package/lib/tests/rules/require-story-io.edgecases.test.js +0 -46
- package/lib/tests/rules/require-story-utils.test.d.ts +0 -7
- package/lib/tests/rules/require-story-utils.test.js +0 -158
- package/lib/tests/rules/require-story-visitors-edgecases.test.d.ts +0 -7
- package/lib/tests/rules/require-story-visitors-edgecases.test.js +0 -27
- package/lib/tests/rules/require-test-traceability.test.d.ts +0 -1
- package/lib/tests/rules/require-test-traceability.test.js +0 -95
- package/lib/tests/rules/valid-annotation-format-internal.test.d.ts +0 -8
- package/lib/tests/rules/valid-annotation-format-internal.test.js +0 -47
- package/lib/tests/rules/valid-annotation-format.test.d.ts +0 -1
- package/lib/tests/rules/valid-annotation-format.test.js +0 -634
- package/lib/tests/rules/valid-req-reference.test.d.ts +0 -1
- package/lib/tests/rules/valid-req-reference.test.js +0 -129
- package/lib/tests/rules/valid-story-reference.test.d.ts +0 -1
- package/lib/tests/rules/valid-story-reference.test.js +0 -413
- package/lib/tests/utils/annotation-checker-autofix-behavior.test.d.ts +0 -5
- package/lib/tests/utils/annotation-checker-autofix-behavior.test.js +0 -103
- package/lib/tests/utils/annotation-checker.test.d.ts +0 -24
- package/lib/tests/utils/annotation-checker.test.js +0 -84
- package/lib/tests/utils/annotation-scope-analyzer.test.d.ts +0 -1
- package/lib/tests/utils/annotation-scope-analyzer.test.js +0 -211
- package/lib/tests/utils/branch-annotation-catch-insert-position.test.d.ts +0 -1
- package/lib/tests/utils/branch-annotation-catch-insert-position.test.js +0 -69
- package/lib/tests/utils/branch-annotation-catch-position.test.d.ts +0 -1
- package/lib/tests/utils/branch-annotation-catch-position.test.js +0 -115
- package/lib/tests/utils/branch-annotation-else-if-insert-position.test.d.ts +0 -1
- package/lib/tests/utils/branch-annotation-else-if-insert-position.test.js +0 -82
- package/lib/tests/utils/branch-annotation-else-if-position.test.d.ts +0 -1
- package/lib/tests/utils/branch-annotation-else-if-position.test.js +0 -145
- package/lib/tests/utils/branch-annotation-helpers.test.d.ts +0 -1
- package/lib/tests/utils/branch-annotation-helpers.test.js +0 -462
- package/lib/tests/utils/fsTestHelpers.d.ts +0 -7
- package/lib/tests/utils/fsTestHelpers.js +0 -26
- package/lib/tests/utils/ioTestHelpers.d.ts +0 -7
- package/lib/tests/utils/ioTestHelpers.js +0 -24
- package/lib/tests/utils/req-annotation-detection.test.d.ts +0 -1
- package/lib/tests/utils/req-annotation-detection.test.js +0 -358
- package/lib/tests/utils/require-story-core-test-helpers.d.ts +0 -10
- package/lib/tests/utils/require-story-core-test-helpers.js +0 -75
- package/lib/tests/utils/temp-dir-helpers.d.ts +0 -19
- package/lib/tests/utils/temp-dir-helpers.js +0 -62
- package/lib/tests/utils/ts-language-options.d.ts +0 -16
- package/lib/tests/utils/ts-language-options.js +0 -30
- /package/lib/{src/index.d.ts → index.d.ts} +0 -0
- /package/lib/{src/index.js → index.js} +0 -0
- /package/lib/{src/maintenance → maintenance}/batch.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/batch.js +0 -0
- /package/lib/{src/maintenance → maintenance}/cli.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/cli.js +0 -0
- /package/lib/{src/maintenance → maintenance}/commands.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/commands.js +0 -0
- /package/lib/{src/maintenance → maintenance}/detect.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/detect.js +0 -0
- /package/lib/{src/maintenance → maintenance}/flags.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/flags.js +0 -0
- /package/lib/{src/maintenance → maintenance}/index.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/index.js +0 -0
- /package/lib/{src/maintenance → maintenance}/report.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/report.js +0 -0
- /package/lib/{src/maintenance → maintenance}/storyParser.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/storyParser.js +0 -0
- /package/lib/{src/maintenance → maintenance}/update.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/update.js +0 -0
- /package/lib/{src/maintenance → maintenance}/utils.d.ts +0 -0
- /package/lib/{src/maintenance → maintenance}/utils.js +0 -0
- /package/lib/{src/rules → rules}/helpers/pattern-validators.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/pattern-validators.js +0 -0
- /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-core.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-core.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-helpers.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-helpers.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-io.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-io.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-node-utils.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-node-utils.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-utils.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-utils.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-visitors.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-story-visitors.js +0 -0
- /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.js +0 -0
- /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.js +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.js +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.js +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-options.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-options.js +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.js +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-implements-utils.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-implements-utils.js +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.js +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.d.ts +0 -0
- /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.js +0 -0
- /package/lib/{src/rules → rules}/no-redundant-annotation.d.ts +0 -0
- /package/lib/{src/rules → rules}/no-redundant-annotation.js +0 -0
- /package/lib/{src/rules → rules}/prefer-implements-annotation.d.ts +0 -0
- /package/lib/{src/rules → rules}/prefer-implements-annotation.js +0 -0
- /package/lib/{src/rules → rules}/require-branch-annotation.d.ts +0 -0
- /package/lib/{src/rules → rules}/require-branch-annotation.js +0 -0
- /package/lib/{src/rules → rules}/require-req-annotation.d.ts +0 -0
- /package/lib/{src/rules → rules}/require-req-annotation.js +0 -0
- /package/lib/{src/rules → rules}/require-story-annotation.d.ts +0 -0
- /package/lib/{src/rules → rules}/require-story-annotation.js +0 -0
- /package/lib/{src/rules → rules}/require-test-traceability.d.ts +0 -0
- /package/lib/{src/rules → rules}/require-test-traceability.js +0 -0
- /package/lib/{src/rules → rules}/require-traceability.d.ts +0 -0
- /package/lib/{src/rules → rules}/valid-annotation-format.d.ts +0 -0
- /package/lib/{src/rules → rules}/valid-annotation-format.js +0 -0
- /package/lib/{src/rules → rules}/valid-req-reference.d.ts +0 -0
- /package/lib/{src/rules → rules}/valid-req-reference.js +0 -0
- /package/lib/{src/rules → rules}/valid-story-reference.d.ts +0 -0
- /package/lib/{src/rules → rules}/valid-story-reference.js +0 -0
- /package/lib/{src/utils → utils}/annotation-checker.d.ts +0 -0
- /package/lib/{src/utils → utils}/annotation-checker.js +0 -0
- /package/lib/{src/utils → utils}/annotation-scope-analyzer.d.ts +0 -0
- /package/lib/{src/utils → utils}/annotation-scope-analyzer.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-if-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-if-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-report-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-report-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.js +0 -0
- /package/lib/{src/utils → utils}/branch-validation.d.ts +0 -0
- /package/lib/{src/utils → utils}/branch-validation.js +0 -0
- /package/lib/{src/utils → utils}/comment-text-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/comment-text-helpers.js +0 -0
- /package/lib/{src/utils → utils}/function-annotation-helpers.d.ts +0 -0
- /package/lib/{src/utils → utils}/function-annotation-helpers.js +0 -0
- /package/lib/{src/utils → utils}/redundancy-detector.d.ts +0 -0
- /package/lib/{src/utils → utils}/redundancy-detector.js +0 -0
- /package/lib/{src/utils → utils}/reqAnnotationDetection.d.ts +0 -0
- /package/lib/{src/utils → utils}/reqAnnotationDetection.js +0 -0
- /package/lib/{src/utils → utils}/storyReferenceUtils.d.ts +0 -0
- /package/lib/{src/utils → utils}/storyReferenceUtils.js +0 -0
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/**
|
|
7
|
-
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
8
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
9
|
-
* @req REQ-ANNOTATION-REQUIRED - Verify require-req-annotation rule enforces @req on functions
|
|
10
|
-
* @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
|
|
11
|
-
* @req REQ-ERROR-SPECIFIC - Verify enhanced, specific error messaging behavior
|
|
12
|
-
*
|
|
13
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
14
|
-
* @req REQ-TYPESCRIPT-SUPPORT - Verify TypeScript declarations are checked via shared annotation checker helper
|
|
15
|
-
*
|
|
16
|
-
* @story docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md
|
|
17
|
-
* @req REQ-REQUIRE-ACCEPTS-IMPLEMENTS - Verify @supports is accepted as satisfying requirement annotations
|
|
18
|
-
*/
|
|
19
|
-
const eslint_1 = require("eslint");
|
|
20
|
-
const require_req_annotation_1 = __importDefault(require("../../src/rules/require-req-annotation"));
|
|
21
|
-
const ts_language_options_1 = require("../utils/ts-language-options");
|
|
22
|
-
const annotation_checker_test_1 = require("../utils/annotation-checker.test");
|
|
23
|
-
const ruleTester = new eslint_1.RuleTester({
|
|
24
|
-
languageOptions: {
|
|
25
|
-
parserOptions: { ecmaVersion: 2022, sourceType: "module" },
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
/**
|
|
29
|
-
* Build a standard missingReq error object for a given function name.
|
|
30
|
-
*
|
|
31
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
32
|
-
* @req REQ-ANNOTATION-REQUIRED - Standardize missingReq error shape in tests
|
|
33
|
-
*/
|
|
34
|
-
function missingReq(functionName) {
|
|
35
|
-
return {
|
|
36
|
-
messageId: "missingReq",
|
|
37
|
-
data: { name: functionName, functionName },
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @trace Story 003.0-DEV-FUNCTION-ANNOTATIONS / REQ-TYPESCRIPT-SUPPORT
|
|
42
|
-
* Exercise the require-req-annotation rule's behavior on TSDeclareFunction and
|
|
43
|
-
* TSMethodSignature via the shared runAnnotationCheckerTests helper.
|
|
44
|
-
*
|
|
45
|
-
* The helper delegates to the real rule's TypeScript-specific visitors
|
|
46
|
-
* without changing its behavior; it provides the common TS parser
|
|
47
|
-
* configuration and assertion plumbing.
|
|
48
|
-
*/
|
|
49
|
-
(0, annotation_checker_test_1.runAnnotationCheckerTests)("require-req-annotation", {
|
|
50
|
-
rule: require_req_annotation_1.default,
|
|
51
|
-
valid: [
|
|
52
|
-
{
|
|
53
|
-
name: "[REQ-TYPESCRIPT-SUPPORT] valid with @req annotation on TSDeclareFunction",
|
|
54
|
-
code: `/**\n * @req REQ-EXAMPLE\n */\ndeclare function foo(): void;`,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "[REQ-TYPESCRIPT-SUPPORT] valid with @req annotation on TSMethodSignature",
|
|
58
|
-
code: `interface I {\n /**\n * @req REQ-EXAMPLE\n */\n method(): void;\n}`,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
invalid: [
|
|
62
|
-
{
|
|
63
|
-
name: "[REQ-TYPESCRIPT-SUPPORT] missing @req on TSDeclareFunction",
|
|
64
|
-
code: `declare function baz(): void;`,
|
|
65
|
-
errors: [missingReq("baz")],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "[REQ-TYPESCRIPT-SUPPORT] missing @req on TSMethodSignature",
|
|
69
|
-
code: `interface I { method(): void; }`,
|
|
70
|
-
errors: [missingReq("method")],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
});
|
|
74
|
-
describe("Require Req Annotation Rule (Story 003.0-DEV-FUNCTION-ANNOTATIONS)", () => {
|
|
75
|
-
ruleTester.run("require-req-annotation", require_req_annotation_1.default, {
|
|
76
|
-
valid: [
|
|
77
|
-
{
|
|
78
|
-
name: "[REQ-ANNOTATION-REQUIRED] valid with only @req annotation",
|
|
79
|
-
code: `/**\n * @req REQ-EXAMPLE\n */\nfunction foo() {}`,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "[REQ-REQUIRE-ACCEPTS-IMPLEMENTS] valid with only @implements annotation",
|
|
83
|
-
code: `/**\n * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED\n */\nfunction implOnly() {}`,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: "[REQ-ANNOTATION-REQUIRED] valid with @story and @req annotations",
|
|
87
|
-
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n * @req REQ-EXAMPLE\n */\nfunction bar() {}`,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: "[REQ-FUNCTION-DETECTION][Story 003.0] valid FunctionExpression with @req annotation",
|
|
91
|
-
code: `const fn = /**\n * @req REQ-EXAMPLE\n */\nfunction() {};`,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
name: "[REQ-FUNCTION-DETECTION][Story 003.0] valid MethodDefinition with @req annotation",
|
|
95
|
-
code: `class C {\n /**\n * @req REQ-EXAMPLE\n */\n m() {}\n}`,
|
|
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
|
-
},
|
|
105
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
106
|
-
name: "[REQ-TYPESCRIPT-SUPPORT][REQ-FUNCTION-DETECTION][Story 003.0] valid TS FunctionExpression in variable declarator with @req",
|
|
107
|
-
code: `const fn = /**\n * @req REQ-EXAMPLE\n */\nfunction () {};`,
|
|
108
|
-
}),
|
|
109
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
110
|
-
name: "[REQ-TYPESCRIPT-SUPPORT][REQ-FUNCTION-DETECTION][Story 003.0] valid exported TS FunctionExpression in variable declarator with @req",
|
|
111
|
-
code: `export const fn = /**\n * @req REQ-EXAMPLE\n */\nfunction () {};`,
|
|
112
|
-
}),
|
|
113
|
-
{
|
|
114
|
-
name: "[REQ-CONFIGURABLE-SCOPE][Story 003.0] FunctionExpression ignored when scope only includes FunctionDeclaration",
|
|
115
|
-
code: `const fn = function () {};`,
|
|
116
|
-
options: [{ scope: ["FunctionDeclaration"] }],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] non-exported function ignored when exportPriority is 'exported'",
|
|
120
|
-
code: `function nonExported() {}`,
|
|
121
|
-
options: [{ exportPriority: "exported" }],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] exported function required when exportPriority is 'exported'",
|
|
125
|
-
code: `/** @req REQ-EXAMPLE */\nexport function exportedFn() {}`,
|
|
126
|
-
options: [{ exportPriority: "exported" }],
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] exported function ignored when exportPriority is 'non-exported'",
|
|
130
|
-
code: `export function exportedFn() {}`,
|
|
131
|
-
options: [{ exportPriority: "non-exported" }],
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] non-exported function required when exportPriority is 'non-exported'",
|
|
135
|
-
code: `/** @req REQ-EXAMPLE */\nfunction nonExported() {}`,
|
|
136
|
-
options: [{ exportPriority: "non-exported" }],
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] exported method ignored when exportPriority is 'non-exported'",
|
|
140
|
-
code: `export class C {\n m() {}\n}`,
|
|
141
|
-
options: [{ exportPriority: "non-exported" }],
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] non-exported method required when exportPriority is 'non-exported'",
|
|
145
|
-
code: `class C {\n /** @req REQ-EXAMPLE */\n m() {}\n}`,
|
|
146
|
-
options: [{ exportPriority: "non-exported" }],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-ALL-BLOCK-TYPES] function-level @supports requirement inside body is valid when annotationPlacement is 'inside'",
|
|
150
|
-
code: `function withInsideReq() {\n // @supports docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md REQ-FN-INSIDE\n return 1;\n}`,
|
|
151
|
-
options: [{ annotationPlacement: "inside" }],
|
|
152
|
-
},
|
|
153
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
154
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-ALL-BLOCK-TYPES] method-level @req inside body is valid when annotationPlacement is 'inside'",
|
|
155
|
-
code: `class C {\n method() {\n // @req REQ-METHOD-INSIDE\n return 1;\n }\n}`,
|
|
156
|
-
options: [{ annotationPlacement: "inside" }],
|
|
157
|
-
}),
|
|
158
|
-
{
|
|
159
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT] before-function @req remains valid when annotationPlacement is 'inside' (REQ-REQ-PLACEMENT-BC)",
|
|
160
|
-
code: `/**\n * @req REQ-BEFORE-FN\n */\nfunction beforeReqOnly() {\n return 1;\n}`,
|
|
161
|
-
options: [{ annotationPlacement: "inside" }],
|
|
162
|
-
},
|
|
163
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
164
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT] before-method @req remains valid when annotationPlacement is 'inside' (REQ-REQ-PLACEMENT-BC)",
|
|
165
|
-
code: `class C {\n /**\n * @req REQ-BEFORE-METHOD\n */\n method() {\n return 1;\n }\n}`,
|
|
166
|
-
options: [{ annotationPlacement: "inside" }],
|
|
167
|
-
}),
|
|
168
|
-
],
|
|
169
|
-
invalid: [
|
|
170
|
-
{
|
|
171
|
-
name: "[REQ-ANNOTATION-REQUIRED][REQ-REQUIRE-ACCEPTS-IMPLEMENTS] missing @req on function without JSDoc remains invalid under multi-story support",
|
|
172
|
-
code: `function baz() {}`,
|
|
173
|
-
errors: [missingReq("baz")],
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
name: "[REQ-ANNOTATION-REQUIRED] missing @req on function with only @story annotation",
|
|
177
|
-
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction qux() {}`,
|
|
178
|
-
errors: [missingReq("qux")],
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
name: "[REQ-FUNCTION-DETECTION][Story 003.0] missing @req on FunctionExpression assigned to variable",
|
|
182
|
-
code: `const fn = function () {};`,
|
|
183
|
-
errors: [missingReq("fn")],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: "[REQ-FUNCTION-DETECTION][Story 003.0] missing @req on anonymous FunctionExpression (no variable name)",
|
|
187
|
-
code: `(function () {})();`,
|
|
188
|
-
errors: [missingReq("(anonymous)")],
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: "[REQ-FUNCTION-DETECTION][Story 003.0] missing @req on MethodDefinition in class",
|
|
192
|
-
code: `class C {\n m() {}\n}`,
|
|
193
|
-
errors: [missingReq("m")],
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: "[REQ-FUNCTION-DETECTION][Story 003.0] missing @req on MethodDefinition in object literal",
|
|
197
|
-
code: `const o = { m() {} };`,
|
|
198
|
-
errors: [missingReq("m")],
|
|
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
|
-
},
|
|
210
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
211
|
-
name: "[REQ-TYPESCRIPT-SUPPORT][REQ-FUNCTION-DETECTION][Story 003.0] missing @req on TS FunctionExpression in variable declarator",
|
|
212
|
-
code: `const fn = function () {};`,
|
|
213
|
-
errors: [missingReq("fn")],
|
|
214
|
-
}),
|
|
215
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
216
|
-
name: "[REQ-TYPESCRIPT-SUPPORT][REQ-FUNCTION-DETECTION][Story 003.0] missing @req on exported TS FunctionExpression in variable declarator",
|
|
217
|
-
code: `export const fn = function () {};`,
|
|
218
|
-
errors: [missingReq("fn")],
|
|
219
|
-
}),
|
|
220
|
-
{
|
|
221
|
-
name: "[REQ-CONFIGURABLE-SCOPE][Story 003.0] FunctionDeclaration still reported when scope only includes FunctionDeclaration",
|
|
222
|
-
code: `function scoped() {}`,
|
|
223
|
-
options: [{ scope: ["FunctionDeclaration"] }],
|
|
224
|
-
errors: [missingReq("scoped")],
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] exported function reported when exportPriority is 'exported'",
|
|
228
|
-
code: `export function exportedFn() {}`,
|
|
229
|
-
options: [{ exportPriority: "exported" }],
|
|
230
|
-
errors: [missingReq("exportedFn")],
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] non-exported function reported when exportPriority is 'non-exported'",
|
|
234
|
-
code: `function nonExported() {}`,
|
|
235
|
-
options: [{ exportPriority: "non-exported" }],
|
|
236
|
-
errors: [missingReq("nonExported")],
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] exported method reported when exportPriority is 'exported'",
|
|
240
|
-
code: `export class C {\n m() {}\n}`,
|
|
241
|
-
errors: [missingReq("m")],
|
|
242
|
-
options: [{ exportPriority: "exported" }],
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] non-exported method reported when exportPriority is 'non-exported'",
|
|
246
|
-
code: `class C {\n m() {}\n}`,
|
|
247
|
-
errors: [missingReq("m")],
|
|
248
|
-
options: [{ exportPriority: "non-exported" }],
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] exported FunctionExpression reported when exportPriority is 'exported'",
|
|
252
|
-
code: `export const fn = function () {};`,
|
|
253
|
-
options: [{ exportPriority: "exported" }],
|
|
254
|
-
errors: [missingReq("fn")],
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: "[REQ-EXPORT-PRIORITY][Story 003.0] non-exported FunctionExpression reported when exportPriority is 'non-exported'",
|
|
258
|
-
code: `const fn = function () {};`,
|
|
259
|
-
options: [{ exportPriority: "non-exported" }],
|
|
260
|
-
errors: [missingReq("fn")],
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
});
|
|
264
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/**
|
|
7
|
-
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
8
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
9
|
-
* @story docs/stories/010.2-DEV-MULTI-STORY-SUPPORT.story.md
|
|
10
|
-
* @req REQ-ANNOTATION-REQUIRED - Verify require-story-annotation rule enforces @story annotation on functions
|
|
11
|
-
* @req REQ-REQUIRE-ACCEPTS-IMPLEMENTS - Verify @supports annotation is accepted as satisfying story requirements
|
|
12
|
-
*/
|
|
13
|
-
const eslint_1 = require("eslint");
|
|
14
|
-
const require_story_annotation_1 = __importDefault(require("../../src/rules/require-story-annotation"));
|
|
15
|
-
const ts_language_options_1 = require("../utils/ts-language-options");
|
|
16
|
-
const ruleTester = new eslint_1.RuleTester({
|
|
17
|
-
languageOptions: ts_language_options_1.tsRuleTesterLanguageOptions,
|
|
18
|
-
});
|
|
19
|
-
describe("Require Story Annotation Rule (Story 003.0-DEV-FUNCTION-ANNOTATIONS)" /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */ /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */, () => {
|
|
20
|
-
ruleTester.run("require-story-annotation", require_story_annotation_1.default, {
|
|
21
|
-
valid: [
|
|
22
|
-
{
|
|
23
|
-
name: "[REQ-ANNOTATION-REQUIRED] valid with JSDoc @story annotation",
|
|
24
|
-
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction foo() {}`,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "[REQ-REQUIRE-ACCEPTS-IMPLEMENTS] valid with only @implements annotation",
|
|
28
|
-
code: `/**\n * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED\n */\nfunction implOnly() {}`,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: "[REQ-ANNOTATION-REQUIRED] valid with line comment @story annotation",
|
|
32
|
-
code: `// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
33
|
-
function foo() {}`,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: "[REQ-ANNOTATION-REQUIRED] valid on function expression with annotation",
|
|
37
|
-
code: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nconst fnExpr = function() {};`,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "[REQ-ANNOTATION-REQUIRED] valid on arrow function with annotation",
|
|
41
|
-
code: `// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
42
|
-
const arrowFn = () => {};`,
|
|
43
|
-
},
|
|
44
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
45
|
-
name: "[REQ-ANNOTATION-REQUIRED] valid on class method with annotation",
|
|
46
|
-
code: `class A {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
|
|
47
|
-
}),
|
|
48
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
49
|
-
name: "[REQ-FUNCTION-DETECTION] valid with annotation on TS declare function",
|
|
50
|
-
code: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */
|
|
51
|
-
declare function tsDecl(): void;`,
|
|
52
|
-
}),
|
|
53
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
54
|
-
name: "[REQ-FUNCTION-DETECTION] valid with annotation on TS method signature",
|
|
55
|
-
code: `interface C {
|
|
56
|
-
/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */
|
|
57
|
-
method(): void;
|
|
58
|
-
}`,
|
|
59
|
-
}),
|
|
60
|
-
{
|
|
61
|
-
name: "[REQ-ARROW-FUNCTION-EXCLUDED] anonymous arrow callback in higher-order function is allowed without annotation",
|
|
62
|
-
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction mapValues(items) {\n return items.map(() => {\n return 1;\n });\n}`,
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: "[REQ-NESTED-FUNCTION-INHERITANCE] anonymous inner function inherits outer annotation",
|
|
66
|
-
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction outer() {\n const inner = function() {\n return 1;\n };\n return inner();\n}`,
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "[REQ-TEST-CALLBACK-EXCLUSION][Story 003.0] default exclusion of Jest-style anonymous test callbacks",
|
|
70
|
-
code: `/**
|
|
71
|
-
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-TEST-CALLBACK-EXCLUSION
|
|
72
|
-
*/
|
|
73
|
-
describe('Feature X', () => {
|
|
74
|
-
it('does something', () => {});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Mocha-style suite/context/specify examples
|
|
78
|
-
suite('Mocha suite', () => {
|
|
79
|
-
beforeEach(() => {});
|
|
80
|
-
afterEach(() => {});
|
|
81
|
-
before(() => {});
|
|
82
|
-
after(() => {});
|
|
83
|
-
|
|
84
|
-
test('Mocha test', () => {});
|
|
85
|
-
specify('Mocha specify', () => {});
|
|
86
|
-
context('Mocha context', () => {
|
|
87
|
-
it('nested it', () => {});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Vitest-style APIs including hooks and bench
|
|
92
|
-
describe('Vitest suite', () => {
|
|
93
|
-
beforeEach(() => {});
|
|
94
|
-
afterEach(() => {});
|
|
95
|
-
beforeAll(() => {});
|
|
96
|
-
afterAll(() => {});
|
|
97
|
-
|
|
98
|
-
it('Vitest it', () => {});
|
|
99
|
-
test('Vitest test', () => {});
|
|
100
|
-
bench('Vitest bench', () => {});
|
|
101
|
-
});`,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: "[REQ-TEST-CALLBACK-EXCLUSION][Story 003.0] additionalTestHelperNames excludes configured helper callbacks when excludeTestCallbacks=true",
|
|
105
|
-
code: `withTestCase("does something", () => {});`,
|
|
106
|
-
options: [{ additionalTestHelperNames: ["withTestCase"] }],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-ALL-BLOCK-TYPES] function-level @supports annotation inside body is valid when annotationPlacement is 'inside'",
|
|
110
|
-
code: `function insideAnnotated() {\n // @supports docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md REQ-INSIDE-FN\n return 1;\n}`,
|
|
111
|
-
options: [{ annotationPlacement: "inside" }],
|
|
112
|
-
},
|
|
113
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
114
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-ALL-BLOCK-TYPES] function-level @story annotation inside body is valid when annotationPlacement is 'inside' (TS)",
|
|
115
|
-
code: `function insideAnnotatedTs() {\n // @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md\n return 1;\n}`,
|
|
116
|
-
options: [{ annotationPlacement: "inside" }],
|
|
117
|
-
}),
|
|
118
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
119
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT] before-method @story remains valid when annotationPlacement is 'inside' (placement BC)",
|
|
120
|
-
code: `class C {\n /** @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md */\n method() {\n return 1;\n }\n}`,
|
|
121
|
-
options: [{ annotationPlacement: "inside" }],
|
|
122
|
-
}),
|
|
123
|
-
],
|
|
124
|
-
invalid: [
|
|
125
|
-
{
|
|
126
|
-
// Backward compatibility: plain unannotated functions remain invalid under multi-story support
|
|
127
|
-
name: "[REQ-ANNOTATION-REQUIRED][BACKCOMPAT] missing @story annotation on function with no @supports",
|
|
128
|
-
code: `function bar() {}`,
|
|
129
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction bar() {}`,
|
|
130
|
-
errors: [
|
|
131
|
-
{
|
|
132
|
-
messageId: "missingStory",
|
|
133
|
-
suggestions: [
|
|
134
|
-
{
|
|
135
|
-
desc: `Add traceability annotation for function 'bar' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
136
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction bar() {}`,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: "[REQ-ANNOTATION-REQUIRED] missing @story on function expression",
|
|
144
|
-
code: `const fnExpr = function() {};`,
|
|
145
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nconst fnExpr = function() {};`,
|
|
146
|
-
errors: [
|
|
147
|
-
{
|
|
148
|
-
messageId: "missingStory",
|
|
149
|
-
suggestions: [
|
|
150
|
-
{
|
|
151
|
-
desc: `Add traceability annotation for function 'fnExpr' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
152
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nconst fnExpr = function() {};`,
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
159
|
-
name: "[REQ-ANNOTATION-REQUIRED] missing @story on class method",
|
|
160
|
-
code: `class C {\n method() {}\n}`,
|
|
161
|
-
output: `class C {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
|
|
162
|
-
errors: [
|
|
163
|
-
{
|
|
164
|
-
messageId: "missingStory",
|
|
165
|
-
data: { name: "method", functionName: "method" },
|
|
166
|
-
suggestions: [
|
|
167
|
-
{
|
|
168
|
-
desc: `Add traceability annotation for function 'method' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
169
|
-
output: `class C {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n method() {}\n}`,
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
}),
|
|
175
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
176
|
-
name: "[REQ-ANNOTATION-REQUIRED] missing @story on TS declare function",
|
|
177
|
-
code: `declare function tsDecl(): void;`,
|
|
178
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ndeclare function tsDecl(): void;`,
|
|
179
|
-
errors: [
|
|
180
|
-
{
|
|
181
|
-
messageId: "missingStory",
|
|
182
|
-
suggestions: [
|
|
183
|
-
{
|
|
184
|
-
desc: `Add traceability annotation for function 'tsDecl' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
185
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ndeclare function tsDecl(): void;`,
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
}),
|
|
191
|
-
(0, ts_language_options_1.withTsLanguageOptions)({
|
|
192
|
-
name: "[REQ-ANNOTATION-REQUIRED] missing @story on TS method signature",
|
|
193
|
-
code: `interface D {\n method(): void;\n}`,
|
|
194
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ninterface D {\n method(): void;\n}`,
|
|
195
|
-
errors: [
|
|
196
|
-
{
|
|
197
|
-
messageId: "missingStory",
|
|
198
|
-
suggestions: [
|
|
199
|
-
{
|
|
200
|
-
desc: `Add traceability annotation for function 'method' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
201
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\ninterface D {\n method(): void;\n}`,
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
}),
|
|
207
|
-
{
|
|
208
|
-
name: "[REQ-ARROW-FUNCTION-EXCLUDED] named arrow function must be annotated",
|
|
209
|
-
code: `const handler = () => {};`,
|
|
210
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nconst handler = () => {};`,
|
|
211
|
-
errors: [
|
|
212
|
-
{
|
|
213
|
-
messageId: "missingStory",
|
|
214
|
-
suggestions: [
|
|
215
|
-
{
|
|
216
|
-
desc: `Add traceability annotation for function 'handler' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
217
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nconst handler = () => {};`,
|
|
218
|
-
},
|
|
219
|
-
],
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
name: "[REQ-NESTED-FUNCTION-INHERITANCE] named inner function inside annotated outer must still be annotated",
|
|
225
|
-
code: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction outer() {\n function innerNamed() {\n return 1;\n }\n return innerNamed();\n}`,
|
|
226
|
-
output: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction outer() {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction innerNamed() {\n return 1;\n }\n return innerNamed();\n}`,
|
|
227
|
-
errors: [
|
|
228
|
-
{
|
|
229
|
-
messageId: "missingStory",
|
|
230
|
-
suggestions: [
|
|
231
|
-
{
|
|
232
|
-
desc: `Add traceability annotation for function 'innerNamed' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
233
|
-
output: `/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\nfunction outer() {\n /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction innerNamed() {\n return 1;\n }\n return innerNamed();\n}`,
|
|
234
|
-
},
|
|
235
|
-
],
|
|
236
|
-
},
|
|
237
|
-
],
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
name: "[REQ-TEST-CALLBACK-EXCLUSION][Story 003.0] bench callback still reported even when included in additionalTestHelperNames",
|
|
241
|
-
code: `bench("bench case", () => {});`,
|
|
242
|
-
options: [{ additionalTestHelperNames: ["bench"], autoFix: false }],
|
|
243
|
-
errors: [
|
|
244
|
-
{
|
|
245
|
-
messageId: "missingStory",
|
|
246
|
-
suggestions: [
|
|
247
|
-
{
|
|
248
|
-
desc: `Add traceability annotation for function '(anonymous)' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
249
|
-
output: `bench("bench case", /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n() => {});`,
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
},
|
|
253
|
-
],
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
name: "[REQ-BEFORE-BRACE-ERROR][REQ-INSIDE-BRACE-PLACEMENT] before-function annotation is ignored when annotationPlacement is 'inside'",
|
|
257
|
-
code: `// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md\nfunction beforeOnly() {\n return 1;\n}`,
|
|
258
|
-
options: [{ annotationPlacement: "inside", autoFix: false }],
|
|
259
|
-
errors: [
|
|
260
|
-
{
|
|
261
|
-
messageId: "missingStory",
|
|
262
|
-
suggestions: 1, // satisfy TypeScript's SuggestionOutput[] typing while asserting suggestion count
|
|
263
|
-
},
|
|
264
|
-
],
|
|
265
|
-
},
|
|
266
|
-
],
|
|
267
|
-
});
|
|
268
|
-
ruleTester.run("require-story-annotation with exportPriority option", require_story_annotation_1.default, {
|
|
269
|
-
valid: [
|
|
270
|
-
{
|
|
271
|
-
name: "[exportPriority] unexported function without @story should be valid",
|
|
272
|
-
code: `function local() {}`,
|
|
273
|
-
options: [{ exportPriority: "exported" }],
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
name: "[exportPriority] exported with annotation",
|
|
277
|
-
code: `// @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\nexport function exportedAnnotated() {}`,
|
|
278
|
-
options: [{ exportPriority: "exported" }],
|
|
279
|
-
},
|
|
280
|
-
],
|
|
281
|
-
invalid: [
|
|
282
|
-
{
|
|
283
|
-
name: "[exportPriority] exported function missing @story annotation",
|
|
284
|
-
code: `export function exportedMissing() {}`,
|
|
285
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nexport function exportedMissing() {}`,
|
|
286
|
-
options: [{ exportPriority: "exported" }],
|
|
287
|
-
errors: [
|
|
288
|
-
{
|
|
289
|
-
messageId: "missingStory",
|
|
290
|
-
suggestions: [
|
|
291
|
-
{
|
|
292
|
-
desc: `Add traceability annotation for function 'exportedMissing' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
293
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nexport function exportedMissing() {}`,
|
|
294
|
-
},
|
|
295
|
-
],
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
name: "[exportPriority][REQ-ARROW-FUNCTION-EXCLUDED] exported named arrow function must be annotated",
|
|
301
|
-
code: `export const arrowExported = () => {};`,
|
|
302
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nexport const arrowExported = () => {};`,
|
|
303
|
-
options: [{ exportPriority: "exported" }],
|
|
304
|
-
errors: [
|
|
305
|
-
{
|
|
306
|
-
messageId: "missingStory",
|
|
307
|
-
suggestions: [
|
|
308
|
-
{
|
|
309
|
-
desc: `Add traceability annotation for function 'arrowExported' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
310
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nexport const arrowExported = () => {};`,
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
},
|
|
314
|
-
],
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
});
|
|
318
|
-
ruleTester.run("require-story-annotation with scope option", require_story_annotation_1.default, {
|
|
319
|
-
valid: [
|
|
320
|
-
{
|
|
321
|
-
name: "[scope] arrow function ignored when scope is FunctionDeclaration",
|
|
322
|
-
code: `const arrow = () => {};`,
|
|
323
|
-
options: [{ scope: ["FunctionDeclaration"] }],
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
invalid: [
|
|
327
|
-
{
|
|
328
|
-
name: "[scope] function declaration missing annotation when scope is FunctionDeclaration",
|
|
329
|
-
code: `function onlyDecl() {}`,
|
|
330
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction onlyDecl() {}`,
|
|
331
|
-
options: [{ scope: ["FunctionDeclaration"] }],
|
|
332
|
-
errors: [
|
|
333
|
-
{
|
|
334
|
-
messageId: "missingStory",
|
|
335
|
-
suggestions: [
|
|
336
|
-
{
|
|
337
|
-
desc: `Add traceability annotation for function 'onlyDecl' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
338
|
-
output: `/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\nfunction onlyDecl() {}`,
|
|
339
|
-
},
|
|
340
|
-
],
|
|
341
|
-
},
|
|
342
|
-
],
|
|
343
|
-
},
|
|
344
|
-
],
|
|
345
|
-
});
|
|
346
|
-
ruleTester.run("require-story-annotation with excludeTestCallbacks option", require_story_annotation_1.default, {
|
|
347
|
-
valid: [
|
|
348
|
-
{
|
|
349
|
-
name: "[REQ-TEST-CALLBACK-EXCLUSION][Story 003.0] non-test arrow function annotated when excludeTestCallbacks=false",
|
|
350
|
-
code: `/**
|
|
351
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
352
|
-
*/
|
|
353
|
-
const handler = () => {};`,
|
|
354
|
-
options: [{ excludeTestCallbacks: false }],
|
|
355
|
-
},
|
|
356
|
-
],
|
|
357
|
-
invalid: [
|
|
358
|
-
{
|
|
359
|
-
name: "[REQ-TEST-CALLBACK-EXCLUSION][Story 003.0] Jest-style it() callback requires annotation when excludeTestCallbacks=false",
|
|
360
|
-
code: `it('does something', () => {});`,
|
|
361
|
-
options: [{ excludeTestCallbacks: false, autoFix: false }],
|
|
362
|
-
errors: [
|
|
363
|
-
{
|
|
364
|
-
messageId: "missingStory",
|
|
365
|
-
suggestions: [
|
|
366
|
-
{
|
|
367
|
-
desc: `Add traceability annotation for function '(anonymous)' using @supports (preferred) or @story (legacy), for example: /** @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */`,
|
|
368
|
-
output: `it('does something', /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */\n() => {});`,
|
|
369
|
-
},
|
|
370
|
-
],
|
|
371
|
-
},
|
|
372
|
-
],
|
|
373
|
-
},
|
|
374
|
-
],
|
|
375
|
-
});
|
|
376
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Edge-case tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
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
|
|
8
|
-
*/
|
|
9
|
-
const require_story_core_1 = require("../../src/rules/helpers/require-story-core");
|
|
10
|
-
const require_story_core_test_helpers_1 = require("../utils/require-story-core-test-helpers");
|
|
11
|
-
describe("Require Story Core - edge cases (Story 003.0)", () => {
|
|
12
|
-
test("createAddStoryFix covers primary branch combinations via shared helper (edge cases)", () => {
|
|
13
|
-
(0, require_story_core_test_helpers_1.exerciseCreateAddStoryFixBranches)(require_story_core_1.createAddStoryFix);
|
|
14
|
-
});
|
|
15
|
-
});
|