eslint-plugin-executable-stories-jest 2.1.4 → 2.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-executable-stories-jest",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "type": "module",
5
5
  "description": "ESLint rules for executable-stories-jest: step context, doc.story in test/it",
6
6
  "main": "./dist/index.cjs",
@@ -40,13 +40,13 @@
40
40
  "devDependencies": {
41
41
  "@types/eslint": "^9.6.1",
42
42
  "@types/estree": "^1.0.8",
43
- "@types/node": "^25.5.0",
43
+ "@types/node": "^25.6.0",
44
44
  "eslint": "^10.0.1",
45
45
  "tsup": "^8.5.1",
46
- "typescript": "^5.9.3",
47
- "vitest": "^4.1.0",
46
+ "typescript": "^6.0.3",
47
+ "vitest": "^4.1.5",
48
48
  "eslint-config-executable-stories": "0.2.0",
49
- "executable-stories-vitest": "8.1.4"
49
+ "executable-stories-vitest": "8.1.11"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=22"
@@ -1,166 +0,0 @@
1
- ---
2
- name: eslint-jest-rules
3
- description: >
4
- ESLint flat config plugin for executable-stories-jest. Three rules:
5
- require-init-before-steps (init before given/when/then),
6
- require-story-context-for-steps (steps must be inside story callback or story.init scope),
7
- require-test-context-for-doc-story (doc.story must be inside test/it).
8
- Recommended config enables all at error level.
9
- type: core
10
- library: eslint-plugin-executable-stories-jest
11
- library_version: "0.1.0"
12
- sources:
13
- - "jagreehal/executable-stories:packages/eslint-plugin-executable-stories-jest/src/index.ts"
14
- ---
15
-
16
- # ESLint Plugin: executable-stories-jest
17
-
18
- ## Setup
19
-
20
- ```typescript
21
- // eslint.config.mjs
22
- import jestStories from "eslint-plugin-executable-stories-jest";
23
-
24
- export default [
25
- // Option A: Use recommended config (enables all rules at error)
26
- ...jestStories.configs.recommended,
27
-
28
- // Option B: Manual configuration
29
- {
30
- plugins: {
31
- "executable-stories-jest": jestStories,
32
- },
33
- rules: {
34
- "executable-stories-jest/require-init-before-steps": "error",
35
- "executable-stories-jest/require-story-context-for-steps": "error",
36
- "executable-stories-jest/require-test-context-for-doc-story": "error",
37
- },
38
- },
39
- ];
40
- ```
41
-
42
- ## Core Patterns
43
-
44
- ### Rule: require-init-before-steps
45
-
46
- Ensures `story.init()` is called before any step markers.
47
-
48
- ```typescript
49
- // Fails lint
50
- it("my test", () => {
51
- story.given("something", () => {}); // Error: story.init() must be called first
52
- story.init();
53
- });
54
-
55
- // Passes lint
56
- it("my test", () => {
57
- story.init();
58
- story.given("something", () => {});
59
- });
60
- ```
61
-
62
- Detects all step methods: `given`, `when`, `then`, `and`, `but`, `arrange`, `act`, `assert`, `setup`, `context`, `execute`, `action`, `verify`, `fn`, `expect`.
63
-
64
- ### Rule: require-story-context-for-steps
65
-
66
- Ensures bare step functions (`given`, `when`, `then`, `and`, `but` and aliases) are called inside a `story()` callback, `doc.story(..., callback)`, or a function that has `story.init()`.
67
-
68
- ```typescript
69
- // Fails lint
70
- it("my test", () => {
71
- given("something", () => {}); // Error: must be inside story() or story.init() scope
72
- });
73
-
74
- // Passes lint — inside story() callback
75
- story("Login", () => {
76
- given("a user", () => {});
77
- when("they sign in", () => {});
78
- then("they see the dashboard", () => {});
79
- });
80
-
81
- // Passes lint — story.init() in same scope
82
- it("my test", () => {
83
- story.init();
84
- given("a user", () => {});
85
- });
86
- ```
87
-
88
- ### Rule: require-test-context-for-doc-story
89
-
90
- Ensures `doc.story(title)` is called inside a `test()` or `it()` callback.
91
-
92
- ```typescript
93
- // Fails lint
94
- function setup() {
95
- doc.story("My story"); // Error: must be inside test/it callback
96
- }
97
-
98
- // Fails lint
99
- it("my test", () => {
100
- doc.story(); // Error: requires a title argument
101
- });
102
-
103
- // Passes lint
104
- it("my test", () => {
105
- doc.story("My story");
106
- });
107
-
108
- // Also detects modifiers: it.only, it.skip, it.todo, it.concurrent, it.failing
109
- it.only("focused test", () => {
110
- doc.story("My story"); // Passes lint
111
- });
112
- ```
113
-
114
- ## Common Mistakes
115
-
116
- ### HIGH Using legacy .eslintrc instead of flat config
117
-
118
- Wrong:
119
-
120
- ```json
121
- {
122
- "plugins": ["executable-stories-jest"],
123
- "rules": {
124
- "executable-stories-jest/require-story-context-for-steps": "error"
125
- }
126
- }
127
- ```
128
-
129
- Correct:
130
-
131
- ```typescript
132
- // eslint.config.mjs (flat config)
133
- import jestStories from "eslint-plugin-executable-stories-jest";
134
-
135
- export default [...jestStories.configs.recommended];
136
- ```
137
-
138
- This plugin only supports ESLint 9 flat config.
139
-
140
- Source: packages/eslint-plugin-executable-stories-jest/src/index.ts
141
-
142
- ### MEDIUM Not scoping rules to story test files
143
-
144
- ```typescript
145
- // eslint.config.mjs
146
- import jestStories from "eslint-plugin-executable-stories-jest";
147
-
148
- export default [
149
- {
150
- // Scope to story test files only
151
- files: ["**/*.story.test.ts", "**/*.story.spec.ts"],
152
- plugins: {
153
- "executable-stories-jest": jestStories,
154
- },
155
- rules: {
156
- "executable-stories-jest/require-init-before-steps": "error",
157
- "executable-stories-jest/require-story-context-for-steps": "error",
158
- "executable-stories-jest/require-test-context-for-doc-story": "error",
159
- },
160
- },
161
- ];
162
- ```
163
-
164
- Scoping avoids false positives on non-story test files that don't use the story API.
165
-
166
- Source: packages/eslint-plugin-executable-stories-jest/src/index.ts