eslint-plugin-executable-stories-playwright 2.1.0 → 2.1.2

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.0",
3
+ "version": "2.1.2",
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",
@@ -16,7 +16,9 @@
16
16
  },
17
17
  "files": [
18
18
  "dist",
19
- "README.md"
19
+ "skills",
20
+ "README.md",
21
+ "bin"
20
22
  ],
21
23
  "repository": {
22
24
  "type": "git",
@@ -38,16 +40,20 @@
38
40
  "devDependencies": {
39
41
  "@types/eslint": "^9.6.1",
40
42
  "@types/estree": "^1.0.8",
41
- "@types/node": "^25.3.0",
43
+ "@types/node": "^25.3.2",
42
44
  "eslint": "^10.0.1",
43
45
  "tsup": "^8.5.1",
44
46
  "typescript": "^5.9.3",
45
47
  "vitest": "^4.0.18",
46
- "eslint-config-executable-stories": "0.2.0"
48
+ "eslint-config-executable-stories": "0.2.0",
49
+ "executable-stories-vitest": "7.0.2"
47
50
  },
48
51
  "engines": {
49
52
  "node": ">=22"
50
53
  },
54
+ "bin": {
55
+ "intent": "./bin/intent.js"
56
+ },
51
57
  "scripts": {
52
58
  "build": "tsup",
53
59
  "type-check": "node -e \"const fs=require('fs');const {execSync}=require('child_process');const p=require('path').resolve(process.cwd(),'../executable-stories-playwright/package.json');if(!fs.existsSync(p)){console.log('Skipping type-check: executable-stories-playwright not in workspace');process.exit(0);}execSync('pnpm --filter executable-stories-playwright run build && tsc --noEmit',{stdio:'inherit'});\"",
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: eslint-playwright-rules
3
+ description: >
4
+ ESLint flat config plugin for executable-stories-playwright. Two rules:
5
+ require-story-context-for-steps (steps must be inside story callback),
6
+ require-test-context-for-doc-story (doc.story must be inside test()).
7
+ Recommended config enables both at error level. Detects Playwright
8
+ modifiers: only, skip, fixme, fail, slow.
9
+ type: core
10
+ library: eslint-plugin-executable-stories-playwright
11
+ library_version: "0.1.0"
12
+ sources:
13
+ - "jagreehal/executable-stories:packages/eslint-plugin-executable-stories-playwright/src/index.ts"
14
+ ---
15
+
16
+ # ESLint Plugin: executable-stories-playwright
17
+
18
+ ## Setup
19
+
20
+ ```typescript
21
+ // eslint.config.mjs
22
+ import playwrightStories from "eslint-plugin-executable-stories-playwright";
23
+
24
+ export default [
25
+ // Option A: Use recommended config
26
+ ...playwrightStories.configs.recommended,
27
+
28
+ // Option B: Manual configuration
29
+ {
30
+ plugins: {
31
+ "executable-stories-playwright": playwrightStories,
32
+ },
33
+ rules: {
34
+ "executable-stories-playwright/require-story-context-for-steps": "error",
35
+ "executable-stories-playwright/require-test-context-for-doc-story": "error",
36
+ },
37
+ },
38
+ ];
39
+ ```
40
+
41
+ ## Core Patterns
42
+
43
+ ### Rule: require-story-context-for-steps
44
+
45
+ Ensures step functions (`given`, `when`, `then`, `and`, `but` and aliases) are called inside a `story()` or `doc.story(..., callback)`.
46
+
47
+ ```typescript
48
+ // Fails lint
49
+ test("my test", async ({ page }, testInfo) => {
50
+ given("something"); // Error: must be inside story() or doc.story()
51
+ });
52
+
53
+ // Passes lint
54
+ test("my test", async ({ page }, testInfo) => {
55
+ story.init(testInfo);
56
+ story.given("something");
57
+ });
58
+ ```
59
+
60
+ ### Rule: require-test-context-for-doc-story
61
+
62
+ Ensures `doc.story(title)` is called inside a `test()` callback.
63
+
64
+ ```typescript
65
+ // Fails lint
66
+ function setup() {
67
+ doc.story("My story"); // Error: must be inside test() callback
68
+ }
69
+
70
+ // Passes lint
71
+ test("my test", async ({ page }, testInfo) => {
72
+ doc.story("My story");
73
+ });
74
+
75
+ // Detects Playwright modifiers: test.only, test.skip, test.fixme, test.fail, test.slow
76
+ test.skip("skipped test", async ({ page }, testInfo) => {
77
+ doc.story("My story"); // Passes lint
78
+ });
79
+ ```
80
+
81
+ ## Common Mistakes
82
+
83
+ ### HIGH Using legacy .eslintrc instead of flat config
84
+
85
+ Wrong:
86
+
87
+ ```json
88
+ {
89
+ "plugins": ["executable-stories-playwright"],
90
+ "rules": {
91
+ "executable-stories-playwright/require-story-context-for-steps": "error"
92
+ }
93
+ }
94
+ ```
95
+
96
+ Correct:
97
+
98
+ ```typescript
99
+ // eslint.config.mjs (flat config)
100
+ import playwrightStories from "eslint-plugin-executable-stories-playwright";
101
+
102
+ export default [...playwrightStories.configs.recommended];
103
+ ```
104
+
105
+ This plugin only supports ESLint 9 flat config.
106
+
107
+ Source: packages/eslint-plugin-executable-stories-playwright/src/index.ts