Registry / testing / eslint-plugin-playwright

eslint-plugin-playwright

JSON →
library2.10.2jsnpmunverified

ESLint plugin for Playwright testing framework, providing lint rules to catch common mistakes and enforce best practices. Current stable version is v2.10.2, with frequent releases (weekly to bi-weekly). Supports both flat config (eslint.config.js) and legacy .eslintrc. Ships TypeScript types. Key differentiators: it is the official Playwright ESLint plugin, actively maintained, with 30+ rules including 'missing-playwright-await' to detect missing await on Playwright assertions, and 'no-wait-for-selector' replacement for deprecated APIs.

npm install eslint-plugin-playwright
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-PLAY
E
eslint-plugin-playwright
testingjavascriptv2.10.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (entire plugin object)
import playwright from 'eslint-plugin-playwright'
const { configs, rules } = require('eslint-plugin-playwright')
CommonJS users must use `const playwright = require('eslint-plugin-playwright')`. The default import provides the plugin object with configs and rules.
flat config (recommended)
playwright.configs['flat/recommended']
playwright.configs.recommended
Since v2, flat config is accessed via `flat/recommended` key. Legacy `recommended` is for .eslintrc only.
individual rules
import { rules } from 'eslint-plugin-playwright' // then reference rules['missing-playwright-await']
import { missingPlaywrightAwait } from 'eslint-plugin-playwright'
Rules are not exported as named exports; you must access via the `rules` object.

Shows flat config usage: targeting tests/ folder, extending recommended flat config, and customizing a rule.

// eslint.config.js (flat config) import { defineConfig } from '@eslint/config' import playwright from 'eslint-plugin-playwright' export default defineConfig([ { files: ['tests/**'], extends: [playwright.configs['flat/recommended']], rules: { 'playwright/max-expects': ['error', { max: 3 }], }, }, ])
Debug
Known issues
breakingFlat config breaking change: configs are under 'flat/recommended' not 'recommended'
fix
Use `playwright.configs['flat/recommended']` instead of `playwright.configs.recommended`
affects: >=2.0.0
breakingRequires ESLint >= 8.40.0
fix
Update ESLint to >= 8.40.0 or stay on v1 if using older ESLint
affects: >=2.0.0
deprecatedRule 'no-wait-for-selector' is deprecated in favor of Playwright's built-in auto-waiting
fix
Remove usage of page.waitForSelector and let Playwright handle waiting automatically
affects: >=1.0.0
gotchaCommonJS require returns the whole plugin object, not a default export
fix
Use `const playwright = require('eslint-plugin-playwright')` then `playwright.configs['flat/recommended']`
affects: >=2.0.0
gotchaUsing legacy config (eslintrc) with flat config will cause errors
fix
Choose one config format: flat config (eslint.config.js) or legacy (eslintrc)
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-playwright'
Package not installed or not in node_modules
fix
Run `npm install -D eslint-plugin-playwright` (or yarn/pnpm)
Error: Failed to load plugin 'playwright' declared in 'extends': The plugin is missing.
Legacy config referencing 'plugin:playwright/recommended' but package not installed
fix
Ensure eslint-plugin-playwright is installed and in your package.json devDependencies
Error: [playwright/expect-expect] Expected assertion to be made in a test body.
A test block has no assertion (expect) call
fix
Add an assertion inside the test, e.g., await expect(page).toHaveTitle(...)
Error: [playwright/missing-playwright-await] Expected 'await' before Playwright async method.
Calling async Playwright method like page.goto() or locator.click() without await
fix
Add `await` before the method call: `await page.goto(url)`
Upgrade
Version history
2.10.2latest on npm
Audit
Dependencies
eslintoptionalpeer dependency for running ESLint rules
Agent activity
39 hits · last 30 days
node
38
Resources
eslint-plugin-playwright — npm install eslint-plugin-playwright · libregistry