@empiricalrun/eslint-config

中文文档
0.9.0发布于 2026/11/10ES Module近 30 天下载 8880

ESLint config for Playwright test repositories (ESLint 9, flat config).

原始使用文档
文档目录5 节
  1. Installation
  2. TypeScript config
  3. Usage
  4. Custom rules
  5. Repo layout

@empiricalrun/eslint-config

ESLint config for Playwright test repositories (ESLint 9, flat config).

Installation

npm install @empiricalrun/eslint-config --save-dev

The package provides the repo's toolchain: eslint, prettier and typescript (pinned to an exact version), so npx eslint and npx tsc work without separate installs. Do not add typescript to the repo's own package.json; upgrade it by upgrading this package.

typescript stays on 5.x because typescript-eslint needs the TypeScript JS API, which TypeScript 7 does not ship.

TypeScript config

{
  "extends": "@empiricalrun/eslint-config/tsconfig.json"
}

Usage

Create an eslint.config.mjs file in the root of your project:

export { default } from "@empiricalrun/eslint-config/playwright";

TypeScript files are linted with type information, using the nearest tsconfig.json.

Custom rules

  • empirical/no-tags-in-name: tags go in the tag option, not the title. test("login @smoke", ...) is an error; use test("login", { tag: ["@smoke"] }, ...).
  • empirical/no-hooks-in-shared-modules: no test.beforeEach/afterEach/beforeAll/afterAll at module scope outside test files (*.spec.*, *.test.*, *.setup.*, *.teardown.*). A shared module such as fixtures.ts is evaluated once per worker, so its hooks only run for the first test file each worker imports. Use a fixture with { auto: true } instead.
  • empirical/no-describe-mode-shorthand: no test.describe.serial(...) or test.describe.parallel(...). Set the mode inside the block with test.describe.configure({ mode: "serial" }): Empirical reads the mode from describe.configure to retry and resume a serial group as a unit.

Repo layout

The config enforces the standard test repo layout:

tests/   *.spec.ts, *.setup.ts and *.teardown.ts only
pages/   code that knows the app under test: functions, no classes
lib/     the test repo's machinery shared by all tests: fixtures, test data, utilities
  • empirical/repo-layout: tests/ holds only *.spec.ts, *.setup.ts and *.teardown.ts. Any other file under tests/ is an error: a Playwright project that matches a folder collects every file in it as a test file, so the specs that import it fail to load. Folders outside tests/, pages/ and lib/ (such as scripts/ or unit/) are not checked.
  • empirical/no-helpers-in-specs: no top-level functions or classes in test files. Move them to pages/ if they drive the app, or lib/ if they don't.
  • empirical/no-classes-in-pages: pages/ exports functions.
  • import/no-restricted-paths: the rest of lib/ never imports pages/, pages/ never imports lib/fixtures/ (fixtures import pages, so that would be a cycle), and nothing imports tests/.

版本与发布记录

@empiricalrun/eslint-config 共发布 15 个版本,首次发布于 2024/09/09;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.9.0latest2026/11/103 天前
0.8.12026/11/094 天前
0.8.02026/11/076 天前
0.7.02026/11/049 天前
0.6.22026/11/049 天前
0.6.12026/10/1430 天前

关于 @empiricalrun/eslint-config 的常见问题

@empiricalrun/eslint-config 是什么?

ESLint config for Playwright test repositories (ESLint 9, flat config).

如何安装 @empiricalrun/eslint-config?

在项目目录运行 npm install @empiricalrun/eslint-config,或使用 pnpm add / yarn add / bun add。

@empiricalrun/eslint-config 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/empiricalrun__eslint-config 是否存在。

@empiricalrun/eslint-config 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@empiricalrun/eslint-config 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@empiricalrun/eslint-config 可以商用吗?

@empiricalrun/eslint-config 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@empiricalrun/eslint-config 的下载量有多少?

根据 npm 官方下载统计,@empiricalrun/eslint-config 在 2026/10/14 – 2026/11/12 这 30 天内被下载 8,880 次,日均约 296 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@empiricalrun/eslint-config 还在维护吗?

最新版本 0.9.0 发布于 2026/11/10(3 天前);至今共发布 15 个版本,其中过去 12 个月发布了 8 个;首次发布于 2024/09/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。