@clipboard-health/playwright-flake-linter

中文文档
1.4.15发布于 2026/11/05MITTypeScriptCommonJS近 30 天下载 1.2万

Shared configurable checks for Playwright flake anti-patterns.

原始使用文档
文档目录6 节
  1. Install
  2. Configure
  3. Wire into CI
  4. Rules
  5. Allowlisting
  6. Future shared rules

@clipboard-health/playwright-flake-linter

Shared, configurable TypeScript AST checks for Playwright flake anti-patterns. The rule implementation lives in this package; consuming repositories provide only their paths, helper names, mechanism names, and justified exceptions.

Install

npm install --save-dev @clipboard-health/playwright-flake-linter

TypeScript is a runtime dependency because the checker uses the compiler API; glob provides the repository-standard source discovery used by embedex. Both are actively maintained, commercially compatible (Apache-2.0 and ISC), already standardized in this monorepo, and the CLI is not included in application bundles.

Configure

Create playwright-flake-lint.config.mjs at the repository root:

export default {
  scanRoots: ["playwright"],
  hardenedIdentityHelperNames: ["generateRandomUserEmail"],
  identityHelperMinimumLengths: {
    generateRandomAlphaNumericString: 24,
    generateRandomString: 26,
  },
  retryHelperNames: ["retry"],
  specificRequestMatcherNames: ["isMatchingRequest"],
  transientClassifierNamePatterns: ["^isRetryable", "retryClassification"],
  undiscriminatingRetryHelperNames: ["retryUntilPassOrTimeout", "toPass"],
  sharedReadinessMechanisms: [
    {
      name: "Home Health response readiness",
      filePathPattern: "playwright/e2e/homeHealth/.*\\.spec\\.ts$",
      directCallNames: ["waitForResponse"],
      sharedHelperNames: ["waitForHomeHealthResponse"],
    },
  ],
};

The mobile repository can use its own genuine names without changing a rule:

export default {
  scanRoots: ["playwright"],
  identityHelperMinimumLengths: {
    mobileRandomSuffix: 32,
  },
  retryHelperNames: ["retryMobileAction"],
  specificRequestMatcherNames: ["matchesMobileRequest"],
  transientClassifierNamePatterns: ["^isTransientMobile"],
  sharedReadinessMechanisms: [
    {
      name: "BottomSheet readiness",
      filePathPattern: "playwright/e2e/sheets/.*\\.spec\\.ts$",
      directCallNames: ["waitForResponse"],
      sharedHelperNames: ["waitForBottomSheet"],
    },
  ],
};

All pattern fields are JavaScript regular-expression source strings. Optional configuration:

FieldPurpose
allowlistReason-required repository exceptions by rule and file pattern
hardenedIdentityHelperNamesIdentity helpers that are safe without a length argument
identityHelperMinimumLengthsRepository random-helper names and their safe minimum lengths
identityNamePatternNames treated as parallel-worker-sensitive identities
responseWaitCallNamesRepository response-wait utility names
retryHelperNamesRetry utilities whose callbacks must classify transient failures
sharedReadinessMechanismsFile/mechanism registry mapping direct gates to shared helpers
specificRequestMatcherNamesDelegated helpers that fully discriminate a response request
specFilePatternFiles where fixed-sleep checks apply
transientClassifierNamePatternsClassifier names accepted inside retry callbacks
undiscriminatingRetryHelperNamesUtilities that inherently retry any failure and are always rejected

sharedReadinessMechanisms[].name is the diagnostic label, so repositories can use their native terminology such as Dialog or BottomSheet.

Wire into CI

Add the executable to the repository's existing verification chain:

{
  "scripts": {
    "architecture:check": "existing-checks && playwright-flake-lint"
  }
}

Use a non-default config location with playwright-flake-lint --config path/to/config.mjs.

Rules

Rule IDAnti-patternRequired alternative
fixed-sleepwaitForTimeout or setTimeout delays in specsRubric B2: use a deterministic readiness signal
response-waitStatus/.ok() response predicates without specific request dataRubric B2: match method, URL, and a discriminating request predicate
retry-classificationRetry utilities invoked without transient-only classificationRubric B1: classify transient failures and fail fast otherwise
test-data-identityLow-entropy identities or bypasses of hardened random helpersRubric A2: use configured hardened or UUID-backed identities
shared-readinessPer-spec readiness gates where a shared mechanism helper existsRubric A1: use or extend the configured shared helper

Allowlisting

Prefer fixing a violation. A justified inline exception must immediately precede the violating statement and include a reason:

// flake-lint-allow fixed-sleep -- The timer fixture verifies elapsed product time.
await page.waitForTimeout(100);

A repository-level exception also requires a reason:

export default {
  scanRoots: ["playwright"],
  allowlist: [
    {
      ruleId: "fixed-sleep",
      filePathPattern: "playwright/e2e/legacy/timer\\.spec\\.ts$",
      reason: "The timer fixture verifies elapsed product time.",
    },
  ],
};

Comments or config entries without a non-empty reason do not suppress a violation.

Future shared rules

The existing per-repository Dialog/query-list checks are a candidate for this package. Their component-name difference (Dialog in admin and BottomSheet in mobile) belongs in repository config when that rule is migrated; this package does not change those checks yet.

版本与发布记录

@clipboard-health/playwright-flake-linter 共发布 41 个版本,首次发布于 2026/07/17;过去 12 个月发布了 41 个版本。

版本发布日期距今
1.4.15latest2026/11/054 天前
1.4.142026/11/055 天前
1.4.132026/11/045 天前
1.4.122026/10/3110 天前
1.4.112026/10/2812 天前
1.4.102026/10/2813 天前

关于 @clipboard-health/playwright-flake-linter 的常见问题

@clipboard-health/playwright-flake-linter 是什么?

Shared configurable checks for Playwright flake anti-patterns.

如何安装 @clipboard-health/playwright-flake-linter?

在项目目录运行 npm install @clipboard-health/playwright-flake-linter,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 playwright-flake-lint,可以用 npx playwright-flake-lint 直接运行。

@clipboard-health/playwright-flake-linter 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clipboard-health/playwright-flake-linter 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@clipboard-health/playwright-flake-linter 可以商用吗?

@clipboard-health/playwright-flake-linter 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@clipboard-health/playwright-flake-linter 的下载量有多少?

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

@clipboard-health/playwright-flake-linter 还在维护吗?

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