eslint-plugin-webdriverio

raw JSON →
1.0.1 verified Sat Apr 25 auth: no javascript

ESLint plugin that provides environment settings for WebdriverIO globals (browser, $, $$). Current stable version is 1.0.1. It is a small, focused plugin that adds a custom environment 'webdriverio/wdio' to ESLint, preventing no-undef errors when using WebdriverIO's globally available helpers. Unlike generic globals configuration, this plugin allows granular control by scoping to the 'wdio' environment, making it easy to combine with other environments like Mocha. Primarily used in WebdriverIO test projects.

error Parsing error: The keyword 'env' is reserved
cause Using 'env' property incorrectly in .eslintrc (e.g. without proper JSON structure).
fix
Ensure .eslintrc is valid JSON and 'env' is an object.
error Environment key "webdriverio/wdio" is unknown
cause The plugin is not added to the 'plugins' array.
fix
Add 'plugins: ["webdriverio"]' to your ESLint config.
gotcha Environment must be 'webdriverio/wdio' not just 'wdio'
fix Use 'webdriverio/wdio' in env or eslint-env comment.
gotcha Plugin name in plugins array must be 'webdriverio' not 'eslint-plugin-webdriverio'
fix Use 'webdriverio' in plugins array.
npm install eslint-plugin-webdriverio
yarn add eslint-plugin-webdriverio
pnpm add eslint-plugin-webdriverio

Shows how to configure ESLint with the webdriverio environment to avoid no-undef errors for WebdriverIO globals.

// .eslintrc.json
{
  "plugins": ["webdriverio"],
  "env": {
    "webdriverio/wdio": true,
    "mocha": true
  }
}

// test.spec.js
/* eslint-env webdriverio/wdio, mocha */
describe('My test', () => {
  it('should work', () => {
    browser.url('https://example.com');
    const heading = $('h1');
    console.log(heading.getText());
  });
});