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