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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* 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
|
-
* @supports docs/stories/007.0-DEV-ERROR-REPORTING.story.md REQ-ERROR-RESILIENCE
|
|
9
|
-
*/
|
|
10
|
-
const require_story_core_1 = require("../../src/rules/helpers/require-story-core");
|
|
11
|
-
const require_story_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
|
|
12
|
-
const require_story_core_test_helpers_1 = require("../utils/require-story-core-test-helpers");
|
|
13
|
-
describe("Require Story Core (Story 003.0)", () => {
|
|
14
|
-
test("createAddStoryFix covers primary branch combinations via shared helper", () => {
|
|
15
|
-
const defaultTemplate = (0, require_story_helpers_1.getAnnotationTemplate)();
|
|
16
|
-
const factory = (target, _annotationTemplate) => (0, require_story_core_1.createAddStoryFix)(target, defaultTemplate);
|
|
17
|
-
(0, require_story_core_test_helpers_1.exerciseCreateAddStoryFixBranches)(factory, {
|
|
18
|
-
annotationText: defaultTemplate,
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
test("reportMissing uses context.getSourceCode fallback when sourceCode not provided and still reports", () => {
|
|
22
|
-
const node = {
|
|
23
|
-
type: "FunctionDeclaration",
|
|
24
|
-
id: { name: "fnX" },
|
|
25
|
-
range: [0, 10],
|
|
26
|
-
};
|
|
27
|
-
const fakeSource = {
|
|
28
|
-
/* intentionally missing getJSDocComment to exercise branch */ getText: () => "",
|
|
29
|
-
};
|
|
30
|
-
const context = { getSourceCode: () => fakeSource, report: jest.fn() };
|
|
31
|
-
(0, require_story_helpers_1.reportMissing)(context, undefined, {
|
|
32
|
-
node,
|
|
33
|
-
target: node,
|
|
34
|
-
options: { autoFixToggle: true },
|
|
35
|
-
});
|
|
36
|
-
expect(context.report).toHaveBeenCalledTimes(1);
|
|
37
|
-
const call = context.report.mock.calls[0][0];
|
|
38
|
-
expect(call.node).toBe(node);
|
|
39
|
-
expect(call.messageId).toBe("missingStory");
|
|
40
|
-
});
|
|
41
|
-
test("coreReportMissing swallows dependency errors and does not break lint run", () => {
|
|
42
|
-
const deps = {
|
|
43
|
-
hasStoryAnnotation: () => {
|
|
44
|
-
throw new Error("boom");
|
|
45
|
-
},
|
|
46
|
-
getReportedFunctionName: () => "fnX",
|
|
47
|
-
resolveAnnotationTargetNode: () => ({ type: "FunctionDeclaration" }),
|
|
48
|
-
getNameNodeForReport: (node) => node,
|
|
49
|
-
buildTemplateConfig: () => ({
|
|
50
|
-
effectiveTemplate: "/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
|
|
51
|
-
allowFix: true,
|
|
52
|
-
}),
|
|
53
|
-
extractName: () => "fnX",
|
|
54
|
-
getAnnotationTemplate: () => "/** @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md */",
|
|
55
|
-
shouldApplyAutoFix: () => true,
|
|
56
|
-
createAddStoryFix: () => () => ({}),
|
|
57
|
-
createMethodFix: () => () => ({}),
|
|
58
|
-
};
|
|
59
|
-
const context = {
|
|
60
|
-
report: jest.fn(),
|
|
61
|
-
};
|
|
62
|
-
const node = { type: "FunctionDeclaration" };
|
|
63
|
-
expect(() => (0, require_story_core_1.coreReportMissing)(deps, context, {}, { node })).not.toThrow();
|
|
64
|
-
expect(context.report).not.toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* 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 - Verify createMethodFix and reportMethod behaviors
|
|
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_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
|
|
11
|
-
describe("Require Story Core (Story 003.0)", () => {
|
|
12
|
-
test("createMethodFix uses parent range start when parent is export", () => {
|
|
13
|
-
const node = {
|
|
14
|
-
type: "MethodDefinition",
|
|
15
|
-
range: [30, 60],
|
|
16
|
-
parent: { type: "ExportNamedDeclaration", range: [12, 90] },
|
|
17
|
-
};
|
|
18
|
-
const fixer = {
|
|
19
|
-
insertTextBeforeRange: jest.fn((r, t) => ({ r, t })),
|
|
20
|
-
};
|
|
21
|
-
const defaultTemplate = (0, require_story_helpers_1.getAnnotationTemplate)();
|
|
22
|
-
const fixFn = (0, require_story_core_1.createMethodFix)(node, defaultTemplate);
|
|
23
|
-
const result = fixFn(fixer);
|
|
24
|
-
expect(fixer.insertTextBeforeRange).toHaveBeenCalledTimes(1);
|
|
25
|
-
const calledArgs = fixer.insertTextBeforeRange.mock.calls[0];
|
|
26
|
-
expect(calledArgs[0]).toEqual([12, 12]);
|
|
27
|
-
expect(typeof calledArgs[1]).toBe("string");
|
|
28
|
-
expect(calledArgs[1].length).toBeGreaterThan(0);
|
|
29
|
-
expect(result).toEqual({ r: [12, 12], t: calledArgs[1] });
|
|
30
|
-
});
|
|
31
|
-
test("reportMethod calls context.report with proper data and suggest.fix works", () => {
|
|
32
|
-
const node = {
|
|
33
|
-
type: "MethodDefinition",
|
|
34
|
-
key: { name: "myMethod" },
|
|
35
|
-
range: [40, 80],
|
|
36
|
-
parent: { type: "ClassBody" },
|
|
37
|
-
};
|
|
38
|
-
const fakeSource = { getText: () => "" };
|
|
39
|
-
const context = {
|
|
40
|
-
getSourceCode: () => fakeSource,
|
|
41
|
-
report: jest.fn(),
|
|
42
|
-
};
|
|
43
|
-
(0, require_story_helpers_1.reportMethod)(context, fakeSource, { node, target: node });
|
|
44
|
-
expect(context.report).toHaveBeenCalledTimes(1);
|
|
45
|
-
const call = context.report.mock.calls[0][0];
|
|
46
|
-
expect(call.messageId).toBe("missingStory");
|
|
47
|
-
expect(call.data).toHaveProperty("name");
|
|
48
|
-
expect(call.data).toHaveProperty("functionName");
|
|
49
|
-
expect(typeof call.data.name).toBe("string");
|
|
50
|
-
expect(typeof call.data.functionName).toBe("string");
|
|
51
|
-
// The suggest fix should be a function; exercise it with a mock fixer
|
|
52
|
-
expect(Array.isArray(call.suggest)).toBe(true);
|
|
53
|
-
expect(typeof call.suggest[0].fix).toBe("function");
|
|
54
|
-
const fixer = {
|
|
55
|
-
insertTextBeforeRange: jest.fn((r, t) => ({ r, t })),
|
|
56
|
-
};
|
|
57
|
-
const fixResult = call.suggest[0].fix(fixer);
|
|
58
|
-
expect(fixer.insertTextBeforeRange).toHaveBeenCalled();
|
|
59
|
-
const args = fixer.insertTextBeforeRange.mock.calls[0];
|
|
60
|
-
expect(args[0]).toEqual([40, 40]);
|
|
61
|
-
expect(typeof args[1]).toBe("string");
|
|
62
|
-
expect(args[1].length).toBeGreaterThan(0);
|
|
63
|
-
expect(fixResult).toEqual({ r: [40, 40], t: args[1] });
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
3
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
|
-
* @req REQ-HELPERS-EDGE-CASES - Edge-case behavior tests for helpers in require-story-helpers.ts
|
|
5
|
-
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-HELPERS-EDGE-CASES
|
|
6
|
-
*/
|
|
7
|
-
export {};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
4
|
-
* @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
|
|
5
|
-
* @req REQ-HELPERS-EDGE-CASES - Edge-case behavior tests for helpers in require-story-helpers.ts
|
|
6
|
-
* @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-HELPERS-EDGE-CASES
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const require_story_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
|
|
10
|
-
describe("Require Story Helpers - edge cases (Story 003.0)", () => {
|
|
11
|
-
test("jsdocHasStory returns false when JSDoc exists but value is not a string", () => {
|
|
12
|
-
const fakeSource = { getJSDocComment: () => ({ value: 123 }) };
|
|
13
|
-
const res = (0, require_story_helpers_1.jsdocHasStory)(fakeSource, {});
|
|
14
|
-
expect(res).toBe(false);
|
|
15
|
-
});
|
|
16
|
-
test("commentsBeforeHasStory returns false when comments exist but value is not a string", () => {
|
|
17
|
-
const fakeSource = { getCommentsBefore: () => [{ value: 123 }] };
|
|
18
|
-
const res = (0, require_story_helpers_1.commentsBeforeHasStory)(fakeSource, {});
|
|
19
|
-
expect(res).toBe(false);
|
|
20
|
-
});
|
|
21
|
-
test("leadingCommentsHasStory detects @story in leadingComments array", () => {
|
|
22
|
-
const node = {
|
|
23
|
-
leadingComments: [
|
|
24
|
-
{ type: "Block", value: "some other text" },
|
|
25
|
-
{
|
|
26
|
-
type: "Block",
|
|
27
|
-
value: "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md",
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
expect((0, require_story_helpers_1.leadingCommentsHasStory)(node)).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
test("resolveTargetNode returns ExpressionStatement parent for FunctionExpression", () => {
|
|
34
|
-
const fakeSource = { getText: () => "" };
|
|
35
|
-
const node = {
|
|
36
|
-
type: "FunctionExpression",
|
|
37
|
-
parent: { type: "ExpressionStatement" },
|
|
38
|
-
};
|
|
39
|
-
const resolved = (0, require_story_helpers_1.resolveTargetNode)(fakeSource, node);
|
|
40
|
-
expect(resolved).toBe(node.parent);
|
|
41
|
-
});
|
|
42
|
-
test("shouldProcessNode respects exportPriority 'exported' and 'non-exported'", () => {
|
|
43
|
-
const exportedNode = {
|
|
44
|
-
type: "FunctionDeclaration",
|
|
45
|
-
parent: { parent: { type: "ExportNamedDeclaration" } },
|
|
46
|
-
};
|
|
47
|
-
const nonExportedNode = {
|
|
48
|
-
type: "FunctionDeclaration",
|
|
49
|
-
parent: { parent: { type: "SomeOther" } },
|
|
50
|
-
};
|
|
51
|
-
expect((0, require_story_helpers_1.shouldProcessNode)(exportedNode, require_story_helpers_1.DEFAULT_SCOPE, "exported")).toBe(true);
|
|
52
|
-
expect((0, require_story_helpers_1.shouldProcessNode)(nonExportedNode, require_story_helpers_1.DEFAULT_SCOPE, "exported")).toBe(false);
|
|
53
|
-
// non-exported should reject exported nodes
|
|
54
|
-
expect((0, require_story_helpers_1.shouldProcessNode)(exportedNode, require_story_helpers_1.DEFAULT_SCOPE, "non-exported")).toBe(false);
|
|
55
|
-
expect((0, require_story_helpers_1.shouldProcessNode)(nonExportedNode, require_story_helpers_1.DEFAULT_SCOPE, "non-exported")).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
test("reportMissing does not report when linesBeforeHasStory finds a preceding @story", () => {
|
|
58
|
-
const jsdoc = "/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\n";
|
|
59
|
-
const rest = "function fnA() {}\n";
|
|
60
|
-
const full = jsdoc + rest;
|
|
61
|
-
const fakeSource = {
|
|
62
|
-
getText: () => full,
|
|
63
|
-
getJSDocComment: () => null,
|
|
64
|
-
lines: full.split(/\r?\n/),
|
|
65
|
-
getCommentsBefore: () => [],
|
|
66
|
-
};
|
|
67
|
-
const node = {
|
|
68
|
-
type: "FunctionDeclaration",
|
|
69
|
-
range: [full.indexOf("function"), full.length],
|
|
70
|
-
loc: {
|
|
71
|
-
start: {
|
|
72
|
-
line: fakeSource.lines.findIndex((l) => l.includes("function fnA() {}")) + 1,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
const context = { getSourceCode: () => fakeSource, report: jest.fn() };
|
|
77
|
-
(0, require_story_helpers_1.reportMissing)(context, fakeSource, { node, target: node });
|
|
78
|
-
expect(context.report).not.toHaveBeenCalled();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|