eslint-plugin-wdio
v10.2.0
Published
Eslint rules for WebdriverIO
Readme
eslint-plugin-wdio
ESLint rules for WebdriverIO
Installation
You'll first need to install ESLint 10:
npm i eslint --save-devNext, install eslint-plugin-wdio:
npm install eslint-plugin-wdio --save-devNote: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-wdio globally.
Recommended configuration
This plugin exports a flat config that enforces good practices. Add it to eslint.config.mjs:
import { configs as wdioConfig } from "eslint-plugin-wdio";
export default [
wdioConfig['flat/recommended'],
];The eslintrc export plugin:wdio/recommended is gone. Flat config is the supported setup.
See ESLint documentation for more information about extending configuration files.
TypeScript Support
When typescript-eslint is installed, the recommended configuration automatically replaces wdio/await-expect with wdio/no-floating-promise for stricter, type-aware promise handling.
To enable this, install the required dependencies:
npm install --save-dev typescript typescript-eslintBy default, ESLint lints only .js, .mjs and .cjs files. Add a files pattern so that it also lints your TypeScript specs:
import { configs as wdioConfig } from "eslint-plugin-wdio";
export default [
{ files: ['**/*.{ts,mts,cts,tsx}'], ...wdioConfig['flat/recommended'] },
];wdio/no-floating-promise needs type information, so your spec files must be part of a tsconfig.json.
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:
export default [
{ files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx}'], ...wdioConfig['flat/recommended'] },
];If a matched file is not part of the TypeScript project, ESLint reports "was not found by the project service".
List of supported rules
expect calls must be prefixed with an await
Don't allow browser.debug() statements
Don't allow browser.pause(<number>) statements
Check for unhandled promises
