eslint-plugin-wdio 10.0.0-alpha.18 → 10.0.0

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/AGENTS.md ADDED
@@ -0,0 +1,11 @@
1
+ # eslint-plugin-wdio
2
+
3
+ ESLint rules and the `flat/recommended` config. Read the root [AGENTS.md](../../AGENTS.md) and [packages/AGENTS.md](../AGENTS.md) first.
4
+
5
+ ## Tests
6
+
7
+ `tests/index.test.ts` owns the public plugin export: meta, `flat/recommended` severities, ignores, parser options, registered rule names, and recommended globals.
8
+
9
+ Recommended globals are the WebdriverIO names (`$`, `$$`, `browser`, `driver`, `expect`, `multiRemoteBrowser`) plus `globals.mocha` and `globals.node`, spread in that order. Assert that composition. Do not paste a snapshot of every Mocha and Node global. That list fails when the `globals` package adds a name and does not fail when this package changes the contract.
10
+
11
+ Rule behavior stays in that rule's test (`await-expect`, `no-debug`, `no-pause`) through ESLint `RuleTester`. `tests/await-expect.test.ts` also keeps `MATCHERS` aligned with `expect-webdriverio` custom matchers. Snapshot matchers are not part of that list; the rule tester owns them.
package/README.md CHANGED
@@ -4,7 +4,7 @@ ESLint rules for [WebdriverIO](https://webdriver.io)
4
4
 
5
5
  ## Installation
6
6
 
7
- You'll first need to install [ESLint](https://eslint.org):
7
+ You'll first need to install [ESLint](https://eslint.org) 10:
8
8
 
9
9
  ```sh
10
10
  npm i eslint --save-dev
@@ -20,28 +20,9 @@ npm install eslint-plugin-wdio --save-dev
20
20
 
21
21
  ## Recommended configuration
22
22
 
23
- This plugin exports a recommended configuration that enforces good practices.
24
-
25
- ### With ESLint v8 and below
26
-
27
- To enable this configuration use the `extends` property in your `.eslintrc` config file:
28
-
29
- ```json
30
- {
31
- "plugins": ["wdio"],
32
- "extends": [
33
- "eslint:recommended",
34
- "plugin:wdio/recommended"
35
- ]
36
- }
37
- ```
38
-
39
- ### With ESLint v9 and Flat Config
40
-
41
- If you are using the latest version of ESLint with the [flat configuration](https://eslint.org/docs/latest/use/configure/migration-guide), you can embed this plugin as follows:
23
+ This plugin exports a flat config that enforces good practices. Add it to `eslint.config.mjs`:
42
24
 
43
25
  ```js
44
- // eslint.config.mjs
45
26
  import { configs as wdioConfig } from "eslint-plugin-wdio";
46
27
 
47
28
  export default [
@@ -49,18 +30,42 @@ export default [
49
30
  ];
50
31
  ```
51
32
 
33
+ The eslintrc export `plugin:wdio/recommended` is gone. Flat config is the supported setup.
34
+
52
35
  See [ESLint documentation](https://eslint.org/docs/latest/use/configure/configuration-files) for more information about extending configuration files.
53
36
 
54
37
  ## TypeScript Support
55
38
 
56
- When `typescript` and `@typescript-eslint/eslint-plugin` are detected, the recommended configuration automatically replaces `wdio/await-expect` with `wdio/no-floating-promise` for stricter, type-aware promise handling.
39
+ When `typescript-eslint` is installed, the recommended configuration automatically replaces `wdio/await-expect` with `wdio/no-floating-promise` for stricter, type-aware promise handling.
57
40
 
58
41
  To enable this, install the required dependencies:
59
42
 
60
43
  ```sh
61
- npm install --save-dev typescript @typescript-eslint/eslint-plugin
44
+ npm install --save-dev typescript typescript-eslint
62
45
  ```
63
46
 
47
+ By default, ESLint lints only `.js`, `.mjs` and `.cjs` files. Add a `files` pattern so that it also lints your TypeScript specs:
48
+
49
+ ```js
50
+ import { configs as wdioConfig } from "eslint-plugin-wdio";
51
+
52
+ export default [
53
+ { files: ['**/*.{ts,mts,cts,tsx}'], ...wdioConfig['flat/recommended'] },
54
+ ];
55
+ ```
56
+
57
+ `wdio/no-floating-promise` needs type information, so your spec files must be part of a `tsconfig.json`.
58
+
59
+ To also lint JavaScript files, such as `wdio.conf.js`, add them to the TypeScript project (`"allowJs": true` and the files in `include`), then widen the pattern:
60
+
61
+ ```js
62
+ export default [
63
+ { files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx}'], ...wdioConfig['flat/recommended'] },
64
+ ];
65
+ ```
66
+
67
+ If a matched file is not part of the TypeScript project, ESLint reports "was not found by the project service".
68
+
64
69
  ## List of supported rules
65
70
 
66
71
 
@@ -5,7 +5,6 @@ declare const _default: {
5
5
  readonly __filename: false;
6
6
  readonly AbortController: false;
7
7
  readonly AbortSignal: false;
8
- readonly AsyncDisposableStack: false;
9
8
  readonly atob: false;
10
9
  readonly Blob: false;
11
10
  readonly BroadcastChannel: false;
@@ -24,7 +23,6 @@ declare const _default: {
24
23
  readonly CryptoKey: false;
25
24
  readonly CustomEvent: false;
26
25
  readonly DecompressionStream: false;
27
- readonly DisposableStack: false;
28
26
  readonly DOMException: false;
29
27
  readonly ErrorEvent: false;
30
28
  readonly Event: false;
@@ -69,7 +67,6 @@ declare const _default: {
69
67
  readonly Storage: false;
70
68
  readonly structuredClone: false;
71
69
  readonly SubtleCrypto: false;
72
- readonly SuppressedError: false;
73
70
  readonly Temporal: false;
74
71
  readonly TextDecoder: false;
75
72
  readonly TextDecoderStream: false;
@@ -110,12 +107,15 @@ declare const _default: {
110
107
  readonly browser: false;
111
108
  readonly driver: false;
112
109
  readonly expect: false;
113
- readonly multiremotebrowser: false;
114
110
  readonly multiRemoteBrowser: false;
115
111
  };
116
112
  };
117
113
  plugins: {
118
114
  wdio: {
115
+ meta: {
116
+ name: string;
117
+ version: string;
118
+ };
119
119
  configs: {};
120
120
  rules: {
121
121
  'await-expect': import("eslint").Rule.RuleModule;
@@ -1,10 +1,4 @@
1
1
  import type { Rule } from 'eslint';
2
- export declare const rules: {
3
- 'no-floating-promise': Rule.RuleModule;
4
- 'await-expect': Rule.RuleModule;
5
- 'no-debug': Rule.RuleModule;
6
- 'no-pause': Rule.RuleModule;
7
- };
8
2
  declare const _default: {
9
3
  languageOptions: {
10
4
  globals: {
@@ -12,7 +6,6 @@ declare const _default: {
12
6
  readonly __filename: false;
13
7
  readonly AbortController: false;
14
8
  readonly AbortSignal: false;
15
- readonly AsyncDisposableStack: false;
16
9
  readonly atob: false;
17
10
  readonly Blob: false;
18
11
  readonly BroadcastChannel: false;
@@ -31,7 +24,6 @@ declare const _default: {
31
24
  readonly CryptoKey: false;
32
25
  readonly CustomEvent: false;
33
26
  readonly DecompressionStream: false;
34
- readonly DisposableStack: false;
35
27
  readonly DOMException: false;
36
28
  readonly ErrorEvent: false;
37
29
  readonly Event: false;
@@ -76,7 +68,6 @@ declare const _default: {
76
68
  readonly Storage: false;
77
69
  readonly structuredClone: false;
78
70
  readonly SubtleCrypto: false;
79
- readonly SuppressedError: false;
80
71
  readonly Temporal: false;
81
72
  readonly TextDecoder: false;
82
73
  readonly TextDecoderStream: false;
@@ -117,7 +108,6 @@ declare const _default: {
117
108
  readonly browser: false;
118
109
  readonly driver: false;
119
110
  readonly expect: false;
120
- readonly multiremotebrowser: false;
121
111
  readonly multiRemoteBrowser: false;
122
112
  };
123
113
  parser: any;
@@ -133,6 +123,10 @@ declare const _default: {
133
123
  'no-debug': Rule.RuleModule;
134
124
  'no-pause': Rule.RuleModule;
135
125
  };
126
+ meta: {
127
+ name: string;
128
+ version: string;
129
+ };
136
130
  configs: {};
137
131
  };
138
132
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ts-recommended.d.ts","sourceRoot":"","sources":["../../src/configs/ts-recommended.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAsClC,eAAO,MAAM,KAAK;;;;;CAGyB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3C,wBAAyD"}
1
+ {"version":3,"file":"ts-recommended.d.ts","sourceRoot":"","sources":["../../src/configs/ts-recommended.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsClC,wBAAyD"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,UAwCpB,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,UAoCpB,CAAA"}
@@ -3,7 +3,6 @@ export declare const sharedGlobals: {
3
3
  readonly __filename: false;
4
4
  readonly AbortController: false;
5
5
  readonly AbortSignal: false;
6
- readonly AsyncDisposableStack: false;
7
6
  readonly atob: false;
8
7
  readonly Blob: false;
9
8
  readonly BroadcastChannel: false;
@@ -22,7 +21,6 @@ export declare const sharedGlobals: {
22
21
  readonly CryptoKey: false;
23
22
  readonly CustomEvent: false;
24
23
  readonly DecompressionStream: false;
25
- readonly DisposableStack: false;
26
24
  readonly DOMException: false;
27
25
  readonly ErrorEvent: false;
28
26
  readonly Event: false;
@@ -67,7 +65,6 @@ export declare const sharedGlobals: {
67
65
  readonly Storage: false;
68
66
  readonly structuredClone: false;
69
67
  readonly SubtleCrypto: false;
70
- readonly SuppressedError: false;
71
68
  readonly Temporal: false;
72
69
  readonly TextDecoder: false;
73
70
  readonly TextDecoderStream: false;
@@ -108,7 +105,6 @@ export declare const sharedGlobals: {
108
105
  readonly browser: false;
109
106
  readonly driver: false;
110
107
  readonly expect: false;
111
- readonly multiremotebrowser: false;
112
108
  readonly multiRemoteBrowser: false;
113
109
  };
114
110
  //# sourceMappingURL=globals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWhB,CAAA"}
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAUhB,CAAA"}
package/build/index.cjs CHANGED
@@ -33,7 +33,7 @@ var index_exports = {};
33
33
  __export(index_exports, {
34
34
  configs: () => configs,
35
35
  default: () => index_default,
36
- rules: () => rules2
36
+ rules: () => rules
37
37
  });
38
38
  module.exports = __toCommonJS(index_exports);
39
39
 
@@ -52,14 +52,10 @@ var MATCHERS = [
52
52
  "toBeRequested",
53
53
  "toBeRequestedTimes",
54
54
  "toBeRequestedWith",
55
- "toBeRequestedWithResponse",
56
55
  "toBeSelected",
57
56
  "toExist",
58
- "toHaveAttr",
59
57
  "toHaveAttribute",
60
- "toHaveAttributeAndValue",
61
58
  "toHaveChildren",
62
- "toHaveClass",
63
59
  "toHaveClipboardText",
64
60
  "toHaveComputedLabel",
65
61
  "toHaveComputedRole",
@@ -86,7 +82,6 @@ var rule = {
86
82
  type: "problem",
87
83
  docs: {
88
84
  description: "expect must be prefixed with await",
89
- category: "Possible Errors",
90
85
  url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/await-expect.md",
91
86
  recommended: false
92
87
  },
@@ -142,7 +137,6 @@ var rule2 = {
142
137
  type: "problem",
143
138
  docs: {
144
139
  description: "Disallow browser.debug() in tests",
145
- category: "Possible Errors",
146
140
  url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-debug.md",
147
141
  recommended: false
148
142
  },
@@ -189,7 +183,6 @@ var rule3 = {
189
183
  type: "problem",
190
184
  docs: {
191
185
  description: "Disallow browser.pause() in tests",
192
- category: "Possible Errors",
193
186
  url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-pause.md",
194
187
  recommended: false
195
188
  },
@@ -230,8 +223,70 @@ var rule3 = {
230
223
  };
231
224
  var no_pause_default = rule3;
232
225
 
226
+ // package.json
227
+ var package_default = {
228
+ name: "eslint-plugin-wdio",
229
+ version: "9.31.3",
230
+ description: "Eslint rules for WebdriverIO",
231
+ author: "Christian Bromann <mail@bromann.dev>",
232
+ homepage: "https://github.com/webdriverio/webdriverio/tree/main/packages/eslint-plugin-wdio",
233
+ license: "MIT",
234
+ main: "./build/index.cjs",
235
+ module: "./build/index.js",
236
+ types: "./build/index.d.ts",
237
+ exports: {
238
+ ".": {
239
+ types: "./build/index.d.ts",
240
+ import: "./build/index.js",
241
+ require: "./build/index.cjs"
242
+ }
243
+ },
244
+ type: "module",
245
+ typeScriptVersion: "6.0.3",
246
+ engines: {
247
+ node: ">=22.19.0"
248
+ },
249
+ repository: {
250
+ type: "git",
251
+ url: "git+https://github.com/webdriverio/webdriverio.git",
252
+ directory: "packages/eslint-plugin-wdio"
253
+ },
254
+ keywords: [
255
+ "eslint",
256
+ "eslintplugin",
257
+ "eslint-plugin",
258
+ "webdriver",
259
+ "wdio"
260
+ ],
261
+ bugs: {
262
+ url: "https://github.com/webdriverio/webdriverio/issues"
263
+ },
264
+ devDependencies: {
265
+ "@types/estree": "^1.0.9",
266
+ "@wdio/types": "workspace:*",
267
+ eslint: "^10.11.0",
268
+ "expect-webdriverio": "^8.0.0-alpha.3",
269
+ globals: "^17.12.0",
270
+ "typescript-eslint": "^8.71.0"
271
+ },
272
+ peerDependencies: {
273
+ eslint: "^10.0.0",
274
+ globals: "^16.5.0 || ^17.0.0",
275
+ "typescript-eslint": "^8.56.0"
276
+ },
277
+ peerDependenciesMeta: {
278
+ "typescript-eslint": {
279
+ optional: true
280
+ }
281
+ }
282
+ };
283
+
233
284
  // src/plugin.ts
234
285
  var index = {
286
+ meta: {
287
+ name: package_default.name,
288
+ version: package_default.version
289
+ },
235
290
  configs: {},
236
291
  rules: {
237
292
  "await-expect": await_expect_default,
@@ -249,7 +304,6 @@ var sharedGlobals = {
249
304
  browser: false,
250
305
  driver: false,
251
306
  expect: false,
252
- multiremotebrowser: false,
253
307
  multiRemoteBrowser: false,
254
308
  // To be more user friendly we add mocha and node globals as well, else the use need to configure themself
255
309
  ...import_globals.default.mocha,
@@ -277,16 +331,14 @@ var import_node_module3 = require("node:module");
277
331
  // src/rules/no-floating-promise.ts
278
332
  var import_node_module = require("node:module");
279
333
  var require2 = (0, import_node_module.createRequire)(__importMetaUrl);
280
- var tryRequire = (moduleName) => {
334
+ var loadTsRule = () => {
281
335
  try {
282
- return require2(moduleName);
336
+ return require2("typescript-eslint").plugin.rules["no-floating-promises"];
283
337
  } catch {
284
338
  return null;
285
339
  }
286
340
  };
287
- var tsEslintPlugin = tryRequire("@typescript-eslint/eslint-plugin");
288
- var tsRule = tsEslintPlugin?.rules["no-floating-promises"];
289
- var error;
341
+ var tsRule = loadTsRule();
290
342
  var rule4 = {
291
343
  meta: tsRule?.meta ?? {
292
344
  type: "problem",
@@ -297,10 +349,13 @@ var rule4 = {
297
349
  schema: []
298
350
  },
299
351
  create: function(context) {
352
+ if (!tsRule) {
353
+ throw new Error('wdio/no-floating-promise needs the "typescript-eslint" package. Install it with "npm install --save-dev typescript-eslint".');
354
+ }
300
355
  try {
301
- return tsRule?.create(context) ?? {};
302
- } catch {
303
- console.error("Error in no-floating-promise rule:", error);
356
+ return tsRule.create(context);
357
+ } catch (err) {
358
+ console.error("Error in no-floating-promise rule:", err);
304
359
  return {};
305
360
  }
306
361
  }
@@ -351,92 +406,21 @@ var tsRecommended = () => {
351
406
  ignores: ["eslint.config.js", "eslint.config.cjs", "eslint.config.mjs"]
352
407
  };
353
408
  };
354
- var rules = {
355
- ...plugin_default.rules,
356
- "no-floating-promise": no_floating_promise_default
357
- };
358
409
  var ts_recommended_default = isTypeAware ? tsRecommended() : void 0;
359
410
 
360
- // package.json
361
- var package_default = {
362
- name: "eslint-plugin-wdio",
363
- version: "9.31.3",
364
- description: "Eslint rules for WebdriverIO",
365
- author: "Christian Bromann <mail@bromann.dev>",
366
- homepage: "https://github.com/webdriverio/webdriverio/tree/main/packages/eslint-plugin-wdio",
367
- license: "MIT",
368
- main: "./build/index.cjs",
369
- module: "./build/index.js",
370
- types: "./build/index.d.ts",
371
- exports: {
372
- ".": {
373
- types: "./build/index.d.ts",
374
- import: "./build/index.js",
375
- require: "./build/index.cjs"
376
- }
377
- },
378
- type: "module",
379
- typeScriptVersion: "3.8.3",
380
- engines: {
381
- node: ">=18.20.0"
382
- },
383
- repository: {
384
- type: "git",
385
- url: "git+https://github.com/webdriverio/webdriverio.git",
386
- directory: "packages/eslint-plugin-wdio"
387
- },
388
- keywords: [
389
- "eslint",
390
- "eslintplugin",
391
- "eslint-plugin",
392
- "webdriver",
393
- "wdio"
394
- ],
395
- bugs: {
396
- url: "https://github.com/webdriverio/webdriverio/issues"
397
- },
398
- devDependencies: {
399
- "@types/estree": "^1.0.8",
400
- eslint: "^9.39.2",
401
- "expect-webdriverio": "^7.0.1",
402
- globals: "^17.7.0",
403
- "typescript-eslint": "^8.54.0"
404
- },
405
- peerDependencies: {
406
- eslint: "^9.39.2 || ^10.0.0",
407
- globals: "^16.5.0 || ^17.0.0",
408
- "typescript-eslint": "^8.54.0"
409
- },
410
- peerDependenciesMeta: {
411
- "typescript-eslint": {
412
- optional: true
413
- }
414
- }
415
- };
416
-
417
411
  // src/index.ts
418
- var legacyConfig = {
419
- rules: {
420
- "wdio/await-expect": "error",
421
- "wdio/no-debug": "error",
422
- "wdio/no-pause": "error"
423
- },
424
- globals: sharedGlobals,
425
- plugins: ["wdio"]
426
- };
427
412
  var flatConfig = ts_recommended_default ?? js_recommended_default;
428
413
  var configs = {
429
- "flat/recommended": flatConfig,
430
- recommended: legacyConfig
414
+ "flat/recommended": flatConfig
431
415
  };
432
- var rules2 = ts_recommended_default?.rules ?? plugin_default.rules;
416
+ var rules = ts_recommended_default?.rules ?? plugin_default.rules;
433
417
  var index_default = {
434
418
  meta: {
435
419
  name: package_default.name,
436
420
  version: package_default.version
437
421
  },
438
422
  configs,
439
- rules: rules2
423
+ rules
440
424
  };
441
425
  // Annotate the CommonJS export names for ESM import in node:
442
426
  0 && (module.exports = {