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,593 +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/004.0-DEV-BRANCH-ANNOTATIONS.story.md, docs/stories/007.0-DEV-ERROR-REPORTING.story.md, docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md
|
|
8
|
-
* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
9
|
-
* @story docs/stories/007.0-DEV-ERROR-REPORTING.story.md
|
|
10
|
-
* @story docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md
|
|
11
|
-
* @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
12
|
-
* @req REQ-BRANCH-DETECTION - Verify require-branch-annotation rule enforces branch annotations
|
|
13
|
-
* @req REQ-ERROR-SPECIFIC - Branch-level missing-annotation error messages are specific and informative
|
|
14
|
-
* @req REQ-ERROR-CONSISTENCY - Branch-level missing-annotation error messages follow shared conventions
|
|
15
|
-
* @req REQ-ERROR-SUGGESTION - Branch-level missing-annotation errors include suggestions when applicable
|
|
16
|
-
* @req REQ-NESTED-HANDLING - Nested branch annotations are correctly enforced without duplicative reporting
|
|
17
|
-
* @req REQ-SUPPORTS-ALTERNATIVE - Branches annotated only with @supports are treated as fully annotated
|
|
18
|
-
* @req REQ-PLACEMENT-CONFIG - Rule supports configurable annotation placement modes
|
|
19
|
-
* @req REQ-DEFAULT-BACKWARD-COMPAT - Default placement remains backward compatible with existing behavior
|
|
20
|
-
* @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-BRANCH-DETECTION REQ-NESTED-HANDLING REQ-SUPPORTS-ALTERNATIVE
|
|
21
|
-
* @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-SPECIFIC REQ-ERROR-CONSISTENCY REQ-ERROR-SUGGESTION
|
|
22
|
-
* @supports docs/stories/026.0-DEV-ELSE-IF-ANNOTATION-POSITION.story.md REQ-DUAL-POSITION-DETECTION-ELSE-IF REQ-FALLBACK-LOGIC-ELSE-IF REQ-POSITION-PRIORITY-ELSE-IF REQ-PRETTIER-AUTOFIX-ELSE-IF
|
|
23
|
-
* @supports docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md REQ-PLACEMENT-CONFIG REQ-DEFAULT-BACKWARD-COMPAT
|
|
24
|
-
*/
|
|
25
|
-
const eslint_1 = require("eslint");
|
|
26
|
-
const require_branch_annotation_1 = __importDefault(require("../../src/rules/require-branch-annotation"));
|
|
27
|
-
const ruleTester = new eslint_1.RuleTester({
|
|
28
|
-
languageOptions: { parserOptions: { ecmaVersion: 2020 } },
|
|
29
|
-
});
|
|
30
|
-
/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */
|
|
31
|
-
const makeMissingAnnotationErrors = (...missing) => missing.map((item) => ({
|
|
32
|
-
messageId: "missingAnnotation",
|
|
33
|
-
data: { missing: item },
|
|
34
|
-
}));
|
|
35
|
-
/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */
|
|
36
|
-
const runRule = (tests) => ruleTester.run("require-branch-annotation", require_branch_annotation_1.default, tests);
|
|
37
|
-
describe("Require Branch Annotation Rule (Story 004.0-DEV-BRANCH-ANNOTATIONS)" /** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */, () => {
|
|
38
|
-
runRule({
|
|
39
|
-
valid: [
|
|
40
|
-
{
|
|
41
|
-
name: "[REQ-BRANCH-DETECTION] valid fallback scanning comment detection",
|
|
42
|
-
code: `switch (value) {
|
|
43
|
-
|
|
44
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
45
|
-
// @req REQ-BRANCH-DETECTION
|
|
46
|
-
case 'z':
|
|
47
|
-
break;
|
|
48
|
-
}`,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "[REQ-BRANCH-DETECTION] valid if-statement with annotations",
|
|
52
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
53
|
-
// @req REQ-BRANCH-DETECTION
|
|
54
|
-
if (condition) {}`,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "[REQ-BRANCH-DETECTION] valid for loop with block comment annotations",
|
|
58
|
-
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
59
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
60
|
-
for (let i = 0; i < 10; i++) {}`,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "[REQ-BRANCH-DETECTION] valid switch-case with annotations",
|
|
64
|
-
code: `switch (value) {
|
|
65
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
66
|
-
// @req REQ-BRANCH-DETECTION
|
|
67
|
-
case 'a':
|
|
68
|
-
break;
|
|
69
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
70
|
-
// @req REQ-SWITCH-DEFAULT-REQUIRED
|
|
71
|
-
default:
|
|
72
|
-
break;
|
|
73
|
-
}`,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "[REQ-SWITCH-FALLTHROUGH] valid fall-through group only requires annotation on last case before body",
|
|
77
|
-
code: `switch (status) {
|
|
78
|
-
case "pending":
|
|
79
|
-
case "processing":
|
|
80
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
81
|
-
// @req REQ-SWITCH-FALLTHROUGH
|
|
82
|
-
case "validating":
|
|
83
|
-
handleInProgress();
|
|
84
|
-
break;
|
|
85
|
-
}`,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: "[REQ-BRANCH-DETECTION] valid try-finally with annotations",
|
|
89
|
-
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
90
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
91
|
-
try {
|
|
92
|
-
doSomething();
|
|
93
|
-
} finally {
|
|
94
|
-
cleanUp();
|
|
95
|
-
}`,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: "[REQ-BRANCH-DETECTION] valid catch with annotations",
|
|
99
|
-
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
100
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
101
|
-
try {
|
|
102
|
-
doSomething();
|
|
103
|
-
}
|
|
104
|
-
/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
105
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
106
|
-
catch (error) {
|
|
107
|
-
handleError(error);
|
|
108
|
-
}`,
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-PLACEMENT-CONFIG] try block annotated inside body under annotationPlacement: 'inside' (Story 028.0)",
|
|
112
|
-
code: `try {
|
|
113
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
114
|
-
// @req REQ-TRY-INSIDE-BRANCH
|
|
115
|
-
doWork();
|
|
116
|
-
} finally {
|
|
117
|
-
cleanup();
|
|
118
|
-
}`,
|
|
119
|
-
options: [{ annotationPlacement: "inside" }],
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: "[REQ-BRANCH-DETECTION] valid do-while loop with annotations",
|
|
123
|
-
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
124
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
125
|
-
do {
|
|
126
|
-
process();
|
|
127
|
-
} while (condition);`,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: "[REQ-BRANCH-DETECTION] valid for-of loop with annotations",
|
|
131
|
-
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
132
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
133
|
-
for (const item of items) {
|
|
134
|
-
process(item);
|
|
135
|
-
}`,
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
name: "[REQ-LOOP-PLACEMENT-FLEXIBLE] for-of loop annotated via comment inside body",
|
|
139
|
-
code: `for (const item of items) {
|
|
140
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
141
|
-
// @req REQ-LOOP-ANNOTATION
|
|
142
|
-
process(item);
|
|
143
|
-
}`,
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
name: "[REQ-BRANCH-DETECTION] valid for-in loop with annotations",
|
|
147
|
-
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
148
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
149
|
-
for (const key in object) {
|
|
150
|
-
console.log(key);
|
|
151
|
-
}`,
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: "[REQ-BRANCH-DETECTION] valid while loop with annotations",
|
|
155
|
-
code: `/* @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md */
|
|
156
|
-
/* @req REQ-BRANCH-DETECTION */
|
|
157
|
-
while (condition) {
|
|
158
|
-
iterate();
|
|
159
|
-
}`,
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: "[REQ-LOOP-PLACEMENT-FLEXIBLE] while loop annotated via comment inside body",
|
|
163
|
-
code: `while (condition) {
|
|
164
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
165
|
-
// @req REQ-LOOP-ANNOTATION
|
|
166
|
-
iterate();
|
|
167
|
-
}`,
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
name: "[REQ-BRANCH-DETECTION] valid switch-case with inline annotation",
|
|
171
|
-
code: `switch (value) {
|
|
172
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
173
|
-
// @req REQ-BRANCH-DETECTION
|
|
174
|
-
case 'a':
|
|
175
|
-
break;
|
|
176
|
-
}`,
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
name: "[REQ-NESTED-HANDLING] nested if-statements with annotations on outer and inner branches",
|
|
180
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
181
|
-
// @req REQ-BRANCH-DETECTION
|
|
182
|
-
if (outer) {
|
|
183
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
184
|
-
// @req REQ-NESTED-HANDLING
|
|
185
|
-
if (inner) {
|
|
186
|
-
doWork();
|
|
187
|
-
}
|
|
188
|
-
}`,
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: "[REQ-CONFIGURABLE-SCOPE] custom branchTypes ignores unlisted branch types",
|
|
192
|
-
code: `switch (value) { case 'a': break; }`,
|
|
193
|
-
options: [{ branchTypes: ["IfStatement"] }],
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: "[REQ-CONFIGURABLE-SCOPE] custom branchTypes only enforce listed types",
|
|
197
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
198
|
-
// @req REQ-BRANCH-DETECTION
|
|
199
|
-
if (condition) {}`,
|
|
200
|
-
options: [{ branchTypes: ["IfStatement", "SwitchCase"] }],
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
name: "[REQ-PLACEMENT-CONFIG][REQ-DEFAULT-BACKWARD-COMPAT] if-statement with before-brace annotations using annotationPlacement: 'before'",
|
|
204
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
205
|
-
// @req REQ-PLACEMENT-CONFIG
|
|
206
|
-
if (condition) {}`,
|
|
207
|
-
options: [{ annotationPlacement: "before" }],
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-PLACEMENT-CONFIG] if-statement annotated inside block under annotationPlacement: 'inside' (Story 028.0)",
|
|
211
|
-
code: `if (condition) {
|
|
212
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
213
|
-
// @req REQ-INSIDE-BRACE-PLACEMENT
|
|
214
|
-
doSomething();
|
|
215
|
-
}`,
|
|
216
|
-
options: [{ annotationPlacement: "inside" }],
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-PLACEMENT-CONFIG] for-of loop annotated inside block under annotationPlacement: 'inside' (Story 028.0)",
|
|
220
|
-
code: `for (const item of items) {
|
|
221
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
222
|
-
// @req REQ-LOOP-INSIDE
|
|
223
|
-
process(item);
|
|
224
|
-
}`,
|
|
225
|
-
options: [{ annotationPlacement: "inside" }],
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-PLACEMENT-CONFIG] switch cases annotated inside block under annotationPlacement: 'inside' (Story 028.0)",
|
|
229
|
-
code: `switch (value) {
|
|
230
|
-
case 'a': {
|
|
231
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
232
|
-
// @req REQ-SWITCH-CASE-INSIDE
|
|
233
|
-
doSomething();
|
|
234
|
-
}
|
|
235
|
-
default: {
|
|
236
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
237
|
-
// @req REQ-SWITCH-DEFAULT-INSIDE
|
|
238
|
-
doDefault();
|
|
239
|
-
}
|
|
240
|
-
}`,
|
|
241
|
-
options: [{ annotationPlacement: "inside" }],
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
name: "[REQ-SUPPORTS-ALTERNATIVE] if-statement with only @supports annotation is treated as fully annotated",
|
|
245
|
-
code: `// @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-SUPPORTS-ALTERNATIVE
|
|
246
|
-
if (shouldHandleAlternative) {
|
|
247
|
-
handleAlternative();
|
|
248
|
-
}`,
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
name: "[REQ-SUPPORTS-ALTERNATIVE] try/catch where both branches are annotated only with @supports",
|
|
252
|
-
code: `// @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-SUPPORTS-ALTERNATIVE
|
|
253
|
-
try {
|
|
254
|
-
mightThrow();
|
|
255
|
-
}
|
|
256
|
-
// @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-SUPPORTS-ALTERNATIVE
|
|
257
|
-
catch (error) {
|
|
258
|
-
recoverFrom(error);
|
|
259
|
-
}`,
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
name: "[REQ-SUPPORTS-ALTERNATIVE] else-if branch with @supports inside the block body",
|
|
263
|
-
code: `// @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-SUPPORTS-ALTERNATIVE
|
|
264
|
-
if (mode === 'primary') {
|
|
265
|
-
handlePrimary();
|
|
266
|
-
} else if (mode === 'alternative') {
|
|
267
|
-
// @supports docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md REQ-SUPPORTS-ALTERNATIVE
|
|
268
|
-
handleAlternativeMode();
|
|
269
|
-
}`,
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
invalid: [
|
|
273
|
-
{
|
|
274
|
-
name: "[REQ-BRANCH-DETECTION] missing annotations on if-statement",
|
|
275
|
-
code: `if (condition) {}`,
|
|
276
|
-
output: `// @story <story-file>.story.md
|
|
277
|
-
if (condition) {}`,
|
|
278
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
name: "[REQ-BRANCH-DETECTION] missing @req on for loop when only story present",
|
|
282
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
283
|
-
for (let i = 0; i < 5; i++) {}`,
|
|
284
|
-
output: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
285
|
-
// @req <REQ-ID>
|
|
286
|
-
for (let i = 0; i < 5; i++) {}`,
|
|
287
|
-
errors: makeMissingAnnotationErrors("@req"),
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
name: "[REQ-BRANCH-DETECTION] missing @story on while loop when only req present",
|
|
291
|
-
code: `// @req REQ-BRANCH-DETECTION
|
|
292
|
-
while (true) {}`,
|
|
293
|
-
output: `// @req REQ-BRANCH-DETECTION
|
|
294
|
-
// @story <story-file>.story.md
|
|
295
|
-
while (true) {}`,
|
|
296
|
-
errors: makeMissingAnnotationErrors("@story"),
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
name: "[REQ-LOOP-ANNOTATION] missing annotations when loop body contains only non-comment code",
|
|
300
|
-
code: `for (const item of items) {
|
|
301
|
-
process(item);
|
|
302
|
-
}`,
|
|
303
|
-
output: `// @story <story-file>.story.md
|
|
304
|
-
for (const item of items) {
|
|
305
|
-
process(item);
|
|
306
|
-
}`,
|
|
307
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
name: "[REQ-BRANCH-DETECTION] missing annotations on switch-case",
|
|
311
|
-
code: `switch (value) {
|
|
312
|
-
case 'a':
|
|
313
|
-
break;
|
|
314
|
-
}`,
|
|
315
|
-
output: `switch (value) {
|
|
316
|
-
// @story <story-file>.story.md
|
|
317
|
-
case 'a':
|
|
318
|
-
break;
|
|
319
|
-
}`,
|
|
320
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
name: "[REQ-SWITCH-FALLTHROUGH] intermediate fall-through case should not be the only annotated case",
|
|
324
|
-
code: `switch (status) {
|
|
325
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
326
|
-
// @req REQ-SWITCH-FALLTHROUGH
|
|
327
|
-
case "pending":
|
|
328
|
-
case "processing":
|
|
329
|
-
case "validating":
|
|
330
|
-
handleInProgress();
|
|
331
|
-
break;
|
|
332
|
-
}`,
|
|
333
|
-
output: `switch (status) {
|
|
334
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
335
|
-
// @req REQ-SWITCH-FALLTHROUGH
|
|
336
|
-
case "pending":
|
|
337
|
-
case "processing":
|
|
338
|
-
// @story <story-file>.story.md
|
|
339
|
-
case "validating":
|
|
340
|
-
handleInProgress();
|
|
341
|
-
break;
|
|
342
|
-
}`,
|
|
343
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
name: "[REQ-SWITCH-DEFAULT-REQUIRED] missing annotations on default case",
|
|
347
|
-
code: `switch (value) {
|
|
348
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
349
|
-
// @req REQ-BRANCH-DETECTION
|
|
350
|
-
case 'a':
|
|
351
|
-
doSomething();
|
|
352
|
-
default:
|
|
353
|
-
doDefault();
|
|
354
|
-
}`,
|
|
355
|
-
output: `switch (value) {
|
|
356
|
-
// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
357
|
-
// @req REQ-BRANCH-DETECTION
|
|
358
|
-
case 'a':
|
|
359
|
-
doSomething();
|
|
360
|
-
// @story <story-file>.story.md
|
|
361
|
-
default:
|
|
362
|
-
doDefault();
|
|
363
|
-
}`,
|
|
364
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
name: "[REQ-BRANCH-DETECTION] missing annotations on do-while loop",
|
|
368
|
-
code: `do {
|
|
369
|
-
action();
|
|
370
|
-
} while (condition);`,
|
|
371
|
-
output: `// @story <story-file>.story.md
|
|
372
|
-
do {
|
|
373
|
-
action();
|
|
374
|
-
} while (condition);`,
|
|
375
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
name: "[REQ-BRANCH-DETECTION] missing annotations on for-in loop",
|
|
379
|
-
code: `for (const key in object) {
|
|
380
|
-
console.log(key);
|
|
381
|
-
}`,
|
|
382
|
-
output: `// @story <story-file>.story.md
|
|
383
|
-
for (const key in object) {
|
|
384
|
-
console.log(key);
|
|
385
|
-
}`,
|
|
386
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
name: "[REQ-BRANCH-DETECTION] missing annotations on try-catch blocks",
|
|
390
|
-
code: `try {
|
|
391
|
-
doSomething();
|
|
392
|
-
} catch (error) {
|
|
393
|
-
handleError(error);
|
|
394
|
-
}`,
|
|
395
|
-
output: `// @story <story-file>.story.md
|
|
396
|
-
try {
|
|
397
|
-
doSomething();
|
|
398
|
-
} catch (error) {
|
|
399
|
-
handleError(error);
|
|
400
|
-
}`,
|
|
401
|
-
errors: [
|
|
402
|
-
...makeMissingAnnotationErrors("@story", "@req"),
|
|
403
|
-
...makeMissingAnnotationErrors("@story", "@req"),
|
|
404
|
-
],
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
name: "[REQ-BRANCH-DETECTION] missing annotations on switch-case with blank line",
|
|
408
|
-
code: `switch (value) {
|
|
409
|
-
|
|
410
|
-
case 'a':
|
|
411
|
-
break;
|
|
412
|
-
}`,
|
|
413
|
-
output: `switch (value) {
|
|
414
|
-
|
|
415
|
-
// @story <story-file>.story.md
|
|
416
|
-
case 'a':
|
|
417
|
-
break;
|
|
418
|
-
}`,
|
|
419
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
name: "[REQ-NESTED-HANDLING] missing annotations on nested if-statement inside annotated outer branch",
|
|
423
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
424
|
-
// @req REQ-BRANCH-DETECTION
|
|
425
|
-
if (outer) {
|
|
426
|
-
if (inner) {
|
|
427
|
-
doWork();
|
|
428
|
-
}
|
|
429
|
-
}`,
|
|
430
|
-
output: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
431
|
-
// @req REQ-BRANCH-DETECTION
|
|
432
|
-
if (outer) {
|
|
433
|
-
// @story <story-file>.story.md
|
|
434
|
-
if (inner) {
|
|
435
|
-
doWork();
|
|
436
|
-
}
|
|
437
|
-
}`,
|
|
438
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
name: "[REQ-CONFIGURABLE-SCOPE] missing annotations on configured branch type ForStatement",
|
|
442
|
-
code: `for (let i = 0; i < 3; i++) {}`,
|
|
443
|
-
options: [{ branchTypes: ["ForStatement"] }],
|
|
444
|
-
output: `// @story <story-file>.story.md
|
|
445
|
-
for (let i = 0; i < 3; i++) {}`,
|
|
446
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
name: "[REQ-PRETTIER-AUTOFIX-ELSE-IF] missing annotations on else-if branch with Prettier-style autofix insertion",
|
|
450
|
-
code: `if (a) {
|
|
451
|
-
doA();
|
|
452
|
-
} else if (b) {
|
|
453
|
-
doB();
|
|
454
|
-
}`,
|
|
455
|
-
output: `// @story <story-file>.story.md
|
|
456
|
-
if (a) {
|
|
457
|
-
doA();
|
|
458
|
-
} else if (b) {
|
|
459
|
-
doB();
|
|
460
|
-
}`,
|
|
461
|
-
errors: makeMissingAnnotationErrors("@story", "@req", "@story", "@req"),
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
// Current behavior: inside-only catch annotations do NOT satisfy try branch in inside-placement mode.
|
|
465
|
-
name: "TODO-FUTURE-BEHAVIOR: [REQ-INSIDE-BRACE-PLACEMENT][REQ-PLACEMENT-CONFIG] catch clause annotated inside block under annotationPlacement: 'inside' (Story 028.0)",
|
|
466
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
467
|
-
// @req REQ-BRANCH-TRY
|
|
468
|
-
try {
|
|
469
|
-
doSomething();
|
|
470
|
-
} catch (error) {
|
|
471
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
472
|
-
// @req REQ-INSIDE-CATCH
|
|
473
|
-
handleError(error);
|
|
474
|
-
}`,
|
|
475
|
-
options: [{ annotationPlacement: "inside" }],
|
|
476
|
-
output: "\n\ntry {\n // @story <story-file>.story.md\n doSomething();\n} catch (error) {\n // @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md\n // @req REQ-INSIDE-CATCH\n handleError(error);\n}",
|
|
477
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-BEFORE-BRACE-ERROR][REQ-PLACEMENT-CONFIG] before-brace annotations ignored when annotationPlacement: 'inside'",
|
|
481
|
-
code: `// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
482
|
-
// @req REQ-BEFORE-BRACE-ERROR
|
|
483
|
-
if (condition) {
|
|
484
|
-
doSomething();
|
|
485
|
-
}`,
|
|
486
|
-
options: [{ annotationPlacement: "inside" }],
|
|
487
|
-
output: "\n\nif (condition) {\n // @story <story-file>.story.md\n doSomething();\n}",
|
|
488
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-BEFORE-BRACE-ERROR][REQ-PLACEMENT-CONFIG] before-loop annotations ignored when annotationPlacement: 'inside' for loops",
|
|
492
|
-
code: `// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
493
|
-
// @req REQ-LOOP-BEFORE
|
|
494
|
-
for (const item of items) {
|
|
495
|
-
process(item);
|
|
496
|
-
}`,
|
|
497
|
-
options: [{ annotationPlacement: "inside" }],
|
|
498
|
-
output: "\n\nfor (const item of items) {\n // @story <story-file>.story.md\n process(item);\n}",
|
|
499
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-BEFORE-BRACE-ERROR][REQ-PLACEMENT-CONFIG] before-catch annotations ignored when annotationPlacement: 'inside' for CatchClause",
|
|
503
|
-
code: `// @story docs/stories/004.0-DEV-BRANCH-ANNOTATIONS.story.md
|
|
504
|
-
// @req REQ-BRANCH-TRY
|
|
505
|
-
try {
|
|
506
|
-
doSomething();
|
|
507
|
-
}
|
|
508
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
509
|
-
// @req REQ-CATCH-BEFORE
|
|
510
|
-
catch (error) {
|
|
511
|
-
handleError(error);
|
|
512
|
-
}`,
|
|
513
|
-
options: [{ annotationPlacement: "inside" }],
|
|
514
|
-
output: "\n\ntry {\n // @story <story-file>.story.md\n doSomething();\n}\n// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md\n// @req REQ-CATCH-BEFORE\ncatch (error) {\n handleError(error);\n}",
|
|
515
|
-
errors: makeMissingAnnotationErrors("@story", "@req", "@story", "@req"),
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-BEFORE-BRACE-ERROR][REQ-PLACEMENT-CONFIG] before-try annotations ignored when annotationPlacement: 'inside' for TryStatement (Story 028.0)",
|
|
519
|
-
code: `// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
520
|
-
// @req REQ-TRY-BEFORE
|
|
521
|
-
try {
|
|
522
|
-
doWork();
|
|
523
|
-
} finally {
|
|
524
|
-
cleanup();
|
|
525
|
-
}`,
|
|
526
|
-
options: [{ annotationPlacement: "inside" }],
|
|
527
|
-
output: "\n\ntry {\n // @story <story-file>.story.md\n doWork();\n} finally {\n cleanup();\n}",
|
|
528
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
529
|
-
},
|
|
530
|
-
{
|
|
531
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-BEFORE-BRACE-ERROR][REQ-PLACEMENT-CONFIG] before-else-if annotations ignored when annotationPlacement: 'inside' for else-if branch (Story 028.0)",
|
|
532
|
-
code: `if (a) {
|
|
533
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
534
|
-
// @req REQ-OUTER-IF-INSIDE
|
|
535
|
-
doA();
|
|
536
|
-
}
|
|
537
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
538
|
-
// @req REQ-ELSE-IF-BEFORE
|
|
539
|
-
else if (b) {
|
|
540
|
-
doB();
|
|
541
|
-
}`,
|
|
542
|
-
options: [{ annotationPlacement: "inside" }],
|
|
543
|
-
output: "if (a) {\n // @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md\n // @req REQ-OUTER-IF-INSIDE\n doA();\n}\n// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md\n// @req REQ-ELSE-IF-BEFORE\nelse if (b) {\n // @story <story-file>.story.md\n doB();\n}",
|
|
544
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-PLACEMENT-CONFIG] else-if branch annotated inside block but initial if branch missing annotation under annotationPlacement: 'inside' (Story 028.0)",
|
|
548
|
-
code: `// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
549
|
-
// @req REQ-INSIDE-OUTER-IF
|
|
550
|
-
if (a) {
|
|
551
|
-
doA();
|
|
552
|
-
} else if (b) {
|
|
553
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
554
|
-
// @req REQ-INSIDE-ELSE-IF
|
|
555
|
-
doB();
|
|
556
|
-
} else {
|
|
557
|
-
doC();
|
|
558
|
-
}`,
|
|
559
|
-
options: [{ annotationPlacement: "inside" }],
|
|
560
|
-
output: "\n\nif (a) {\n // @story <story-file>.story.md\n doA();\n} else if (b) {\n // @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md\n // @req REQ-INSIDE-ELSE-IF\n doB();\n} else {\n doC();\n}",
|
|
561
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
name: "[REQ-INSIDE-BRACE-PLACEMENT][REQ-BEFORE-BRACE-ERROR][REQ-PLACEMENT-CONFIG] before-case annotations ignored when annotationPlacement: 'inside' for SwitchCase",
|
|
565
|
-
code: `switch (value) {
|
|
566
|
-
// @story docs/stories/028.0-DEV-ANNOTATION-PLACEMENT-STANDARDIZATION.story.md
|
|
567
|
-
// @req REQ-SWITCH-BEFORE
|
|
568
|
-
case 'a': {
|
|
569
|
-
doSomething();
|
|
570
|
-
}
|
|
571
|
-
}`,
|
|
572
|
-
options: [{ annotationPlacement: "inside" }],
|
|
573
|
-
output: "switch (value) {\n \n \n // @story <story-file>.story.md\n case 'a': {\n doSomething();\n }\n}",
|
|
574
|
-
errors: makeMissingAnnotationErrors("@story", "@req"),
|
|
575
|
-
},
|
|
576
|
-
],
|
|
577
|
-
});
|
|
578
|
-
runRule({
|
|
579
|
-
valid: [],
|
|
580
|
-
invalid: [
|
|
581
|
-
{
|
|
582
|
-
name: "[REQ-CONFIGURABLE-SCOPE] invalid branchTypes option should error schema",
|
|
583
|
-
code: "if (condition) {}",
|
|
584
|
-
options: [{ branchTypes: ["UnknownType"] }],
|
|
585
|
-
errors: [
|
|
586
|
-
{
|
|
587
|
-
message: /should be equal to one of the allowed values/,
|
|
588
|
-
},
|
|
589
|
-
],
|
|
590
|
-
},
|
|
591
|
-
],
|
|
592
|
-
});
|
|
593
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|