ESLint plugin for Playwright.
npm
npm install -D eslint-plugin-playwright
Yarn
yarn add -D eslint-plugin-playwright
pnpm
pnpm add -D eslint-plugin-playwright
The recommended setup is to use the files
field to target only Playwright test files. In the examples below, this is done by targeting files in the tests
directory and only applying the Playwright rules to those files. In your project, you may need to change the files
field to match your Playwright test file patterns.
Flat config (eslint.config.js)
import playwright from 'eslint-plugin-playwright' export default [ { ...playwright.configs['flat/recommended'], files: ['tests/**'], rules: { ...playwright.configs['flat/recommended'].rules, // Customize Playwright rules // ... }, }, ]
Legacy config (.eslintrc)
{ "overrides": [ { "files": "tests/**", "extends": "plugin:playwright/recommended" } ] }Aliased Playwright Globals
If you import Playwright globals (e.g. test
, expect
) with a custom name, you can configure this plugin to be aware of these additional names.
{ "settings": { "playwright": { "globalAliases": { "test": ["myTest"], "expect": ["myExpect"] } } } }
You can customize the error messages for rules using the settings.playwright.messages
property. This is useful if you would like to increase the verbosity of error messages or provide additional context.
Only the message ids you define in this setting will be overridden, so any other messages will use the default message defined by the plugin.
{ "settings": { "playwright": { "messages": { "conditionalExpect": "Avoid conditional expects as they can lead to false positives" } } } }
✅ Set in the recommended
configuration
🔧 Automatically fixable by the --fix
CLI option
💡 Manually fixable by editor suggestions
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4