ESLint rules for WebdriverIO
You'll first need to install ESLint:
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.
This plugin exports a recommended configuration that enforces good practices.
To enable this configuration use the extends property in your .eslintrc config file:
{
"plugins": ["wdio"],
"extends": [
"eslint:recommended",
"plugin:wdio/recommended"
]
}If you are using the latest version of ESLint with the flat configuration, you can embed this plugin as follows:
// eslint.config.mjs
import { configs as wdioConfig } from "eslint-plugin-wdio";
export default [
wdioConfig['flat/recommended'],
];See ESLint documentation for more information about extending configuration files.
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.
To enable this, install the required dependencies:
npm install --save-dev typescript @typescript-eslint/eslint-pluginexpect calls must be prefixed with an await
Don't allow browser.debug() statements
Don't allow browser.pause(<number>) statements
Check for unhandled promises