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