eslint-plugin-traceability 1.4.2 → 1.4.4

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.
@@ -0,0 +1,50 @@
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-ANNOTATION-REQUIRED - Edge case tests for IO helpers (linesBeforeHasStory/fallbackTextBeforeHasStory/parentChainHasStory)
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const require_story_io_1 = require("../../src/rules/helpers/require-story-io");
9
+ describe("Require Story IO helpers - edge cases (Story 003.0)", () => {
10
+ test("linesBeforeHasStory returns false when source.lines missing or node.loc missing", () => {
11
+ const fakeSource = {};
12
+ const node = { loc: null };
13
+ expect((0, require_story_io_1.linesBeforeHasStory)(fakeSource, node)).toBe(false);
14
+ const fakeSource2 = { lines: ["line1", "line2"] };
15
+ const node2 = { loc: { start: { line: 100 } } };
16
+ expect((0, require_story_io_1.linesBeforeHasStory)(fakeSource2, node2)).toBe(false);
17
+ });
18
+ test("fallbackTextBeforeHasStory returns false when getText missing or node.range missing", () => {
19
+ const fakeSource = {};
20
+ const node = { range: null };
21
+ expect((0, require_story_io_1.fallbackTextBeforeHasStory)(fakeSource, node)).toBe(false);
22
+ const fakeSource2 = { getText: () => "no story here" };
23
+ const node2 = { range: [] };
24
+ expect((0, require_story_io_1.fallbackTextBeforeHasStory)(fakeSource2, node2)).toBe(false);
25
+ });
26
+ test("fallbackTextBeforeHasStory detects @story in text before node.range", () => {
27
+ const story = "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md";
28
+ const pre = `/* ${story} */\\n`;
29
+ const rest = "function x() {}";
30
+ const full = pre + rest;
31
+ const fakeSource = { getText: () => full };
32
+ const node = { range: [full.indexOf("function"), full.length] };
33
+ expect((0, require_story_io_1.fallbackTextBeforeHasStory)(fakeSource, node)).toBe(true);
34
+ });
35
+ test("parentChainHasStory returns true when ancestor comments contain @story", () => {
36
+ const fakeSource = {
37
+ getCommentsBefore: () => [
38
+ {
39
+ type: "Block",
40
+ value: "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md",
41
+ },
42
+ ],
43
+ };
44
+ const node = { parent: { parent: { type: "SomeParent" } } };
45
+ expect((0, require_story_io_1.parentChainHasStory)(fakeSource, node)).toBe(true);
46
+ const fakeSource2 = { getCommentsBefore: () => [] };
47
+ const node2 = { parent: null };
48
+ expect((0, require_story_io_1.parentChainHasStory)(fakeSource2, node2)).toBe(false);
49
+ });
50
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-traceability",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "A customizable ESLint plugin that enforces traceability annotations in your code, ensuring each implementation is linked to its requirement or test case.",
5
5
  "main": "lib/src/index.js",
6
6
  "types": "lib/src/index.d.ts",
@@ -22,6 +22,8 @@
22
22
  "format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
23
23
  "duplication": "jscpd src tests --reporters console --threshold 3 --ignore tests/utils/**",
24
24
  "audit:dev-high": "node scripts/generate-dev-deps-audit.js",
25
+ "safety:deps": "node scripts/ci-safety-deps.js",
26
+ "audit:ci": "node scripts/ci-audit.js",
25
27
  "smoke-test": "./scripts/smoke-test.sh",
26
28
  "prepare": "husky install"
27
29
  },