Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright ESLint Configuration

From Leeroopedia
Knowledge Sources
Domains Code Quality, Build Tooling
Last Updated 2026-02-12 00:00 GMT

Overview

The root ESLint flat configuration file that defines linting rules, parser settings, and per-package overrides for the entire Playwright monorepo.

Description

eslint.config.mjs uses ESLint's flat config format (ESM) to configure TypeScript linting across all Playwright packages. It imports @typescript-eslint/eslint-plugin and @typescript-eslint/parser for TypeScript support, eslint-plugin-notice for copyright header enforcement, @stylistic/eslint-plugin for formatting rules, and eslint-plugin-import for import ordering. The configuration defines a shared baseRules object and then applies package-specific overrides for different directories, including stricter rules for injected scripts, client code, server utilities, test files, and React-based UI packages.

Key Configuration Sections

  • Ignores: Excludes generated code, third-party vendored sources, build outputs, test assets, and utility scripts from linting.
  • Base Rules (baseRules): Enforces single quotes, semicolons, prefer-const, eqeqeq, 2-space indentation, copyright headers via notice/notice, and a comprehensive set of anti-pattern guards (no-var, no-caller, no-implied-eval, etc.).
  • Package-level Overrides:
    • packages/**/*.ts -- Enables no-console, restricts process.exit / process.stdout / process.stderr, and enforces import ordering.
    • packages/playwright/**/*.ts -- Adds @typescript-eslint/no-floating-promises.
    • packages/playwright-core/src/utils/**/*.ts -- Restricts both Node and Web globals, adds floating-promise and boolean-compare rules.
    • packages/injected/src/**/*.ts -- Restricts Web globals (must use InjectedScript builtins instead of window, document, setTimeout, etc.).
    • packages/playwright-core/src/client/**/*.ts and protocol/**/*.ts -- Restricts Node globals (process).
    • tests/**/*.spec.js and tests/**/*.ts -- Enables floating-promise checks with a test-specific tsconfig.
    • React packages (html-reporter, recorder, trace-viewer) -- Extends plugin:react/recommended and plugin:react-hooks/recommended, adds no-console and a custom rule forbidding stray semicolons after JSX elements.
  • Parser Configuration: Uses @typescript-eslint/parser with ECMAScript 2018 (version 9), module source type, and project-specific tsconfig.json references where type-aware rules are needed.

Usage

This file is consumed by ESLint when running npx eslint or any IDE integration from the repository root. It is the single source of truth for code style and quality enforcement across all Playwright packages. Contributors must satisfy these rules before merging pull requests.

Code Reference

Source Location

Exported Symbols

  • baseRules -- Named export; the shared rule set object, available for external consumption or testing.
  • default export -- The flat config array consumed by ESLint.

Notable Dependencies

  • @typescript-eslint/eslint-plugin / @typescript-eslint/parser
  • @stylistic/eslint-plugin
  • eslint-plugin-notice
  • eslint-plugin-import
  • @eslint/compat (FlatCompat for legacy React plugin configs)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment