Day 56 of 100: ESLint for Test Code — Rules That Prevent Flakiness
Day 56 of 100 — 100 Days of Playwright with TypeScript Challenge. Phase: TypeScript. JavaScript (Days 1-33) → TypeScript (Days 34-63) → Playwright (Days 64-96) → AI Framework Capstone (Days 97-100).
🎭 Want to master this with real projects? Join the Playwright Automation Mastery course at The Testing Academy.
Linting is automated code review. For test suites, three rules pay for the whole setup.
Contents
Setup
npm install -D eslint @eslint/js typescript-eslint eslint-plugin-playwright
npx eslint --init # or write eslint.config.js directly
🚀 Level Up Your Playwright
From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.
eslint.config.js for a Playwright Project
import tseslint from 'typescript-eslint';
import playwright from 'eslint-plugin-playwright';
export default tseslint.config(
...tseslint.configs.recommendedTypeChecked,
{
files: ['tests/**', 'src/**'],
languageOptions: { parserOptions: { projectService: true } },
rules: {
'@typescript-eslint/no-floating-promises': 'error', // missing await
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/await-thenable': 'error',
},
},
{
files: ['tests/**'],
...playwright.configs['flat/recommended'],
rules: {
'playwright/no-wait-for-timeout': 'error', // bans waitForTimeout
'playwright/no-focused-test': 'error', // bans test.only in CI
'playwright/expect-expect': 'error', // tests must assert
},
},
);
The Three Rules That Matter Most
- no-floating-promises → catches missing await (THE flaky-test source)
- playwright/no-wait-for-timeout → bans hardcoded sleeps
- playwright/no-focused-test → a forgotten test.only cannot silently skip your suite in CI
Tomorrow (Day 57): Mapped and conditional types — reading Playwright’s own types.
🎓 Master Playwright End to End
Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.
