Skip to content

Fixes 31036: Playwright guardrails — enforce test anti-patterns in CI via ESLint + suppressions ratchet - #31994

Merged
ShaileshParmar11 merged 58 commits into
mainfrom
ShaileshParmar11/playwright-guardrails
Aug 28, 2026
Merged

ShaileshParmar11 merged 58 commits into
mainfrom
ShaileshParmar11/playwright-guardrails

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #31036

Part of #31035.

PR 1 of a series. This one adds the enforcement machinery; the remediation follows in separate, reviewable PRs.

No violation is fixed here — all 1,520 are captured in the suppressions baseline, so no rule forces a rewrite. The one exception is deliberate: 16 genuine race conditions are fixed by hand across 10 spec/util files rather than suppressed, because require-response-listener-before-action ships with a clean baseline. Each is the same change — hoist page.waitForResponse(...) above the action that triggers it, then await the stored promise — so the listener cannot miss a response that fires before the wait is registered. Those 16 are the only behavioural changes in this PR; everything else is inert.

Playwright test quality was governed by prose, not by machines. A 30,000-word PLAYWRIGHT_DEVELOPER_HANDBOOK.md, three overlapping skills, and .claude/rules/frontend-playwright.md all stated rules that nothing enforced — and they had drifted out of agreement with each other and with the linter. The handbook banned .first() for years; ESLint never checked, and 1,265 uses accumulated.

This moves every guardrail into one runnable command, yarn lint:playwright, at error severity.

Type of change:

  • Improvement

High-level design:

The ratchet. ESLint 9.39's native bulk suppressions let every rule run at error from day one without fixing anything first. --suppress-all captured today's violations per file/rule; a new violation has no entry and fails CI, while legacy ones don't block. The count only ever decreases, and the suppressions file doubles as the remediation backlog.

The starting notch is 1,520, measured against the current corpus (366 spec files, 618 linted). corpus.test.ts pins it and fails if the total ever exceeds it. That number is the ratchet's initialization, not a budget: none of these rules has ever been enforced on main, so the backlog is simply what an unlinted corpus accumulated. From here it only moves downward — the burn-down PRs below take it apart, and any PR that pushes it up is doing the thing this gate exists to prevent.

18 rules, all error:

  • 13 eslint-plugin-playwright rules promoted (6 had zero violations and cost nothing)
  • 5 custom rules in a local plugin at playwright/eslint-rules/
Rule Catches Baseline
no-positional-locator .first() / .last() / .nth() — "not recommended" per Playwright's docs 1,265
no-blanket-test-slow test.slow() at file/describe/beforeEach scope, which hides real perf regressions 89
justified-rule-disable disabling a playwright rule without a -- <why> justification 9
require-assertion-per-test a test that only performs page interactions and verifies nothing 1
require-response-listener-before-action await waitForResponse after the triggering action 0

The last shipped with a clean baseline: all 16 real race conditions were fixed by hand rather than suppressed. Those 16 are the only test changes in this PR.

Two rules were built and then removed after measurement showed they were net-negative: no-unscoped-count-assertion (~77% false positives — it fired on the exact remediation its own error message recommended) and require-unique-entity-name (0.18% true positives; 59% of its hits were Playwright's own getByRole(…, { name }), where adding uuid() would break the locator).

Helpers ship with the rules, on the principle that a restrictive rule without an ergonomic alternative just creates a backlog that never burns down: clickAndWaitFor() makes the listener-before-action race unrepresentable, and getRowByName() / expectRowFor() scope list assertions to a test's own entity instead of by position.

Anti-drift. The handbook's rule table is now generated from eslint.config.mjs, with a --check mode in CI. A rule can no longer appear in the docs without existing in the linter — which is exactly how the two diverged before.

CI. The guardrail checks run inside ui-checkstyle.yml's existing playwright step, full-corpus. Full-corpus matters: --prune-suppressions against a partial file set deletes suppressions for unlinted files. A full lint takes ~8s.

They are folded into the existing step rather than added as a new one because CodeQL flags every run: that executes PR-authored code in this pull_request_target job as a cache-poisoning risk — a separate step adds one more for no gain in isolation, since it would run the same commands with the same privileges against the same checkout. The checks run before --fix/--write so they judge what the contributor actually wrote, and the changed-files matcher is widened to eslint.config.mjs and eslint-suppressions.json so a config-only change still triggers the gate.

Tests:

Use cases covered

  • A new .first() / waitForTimeout / force: true in any playwright file fails CI
  • Pre-existing violations don't block, but their count can never grow
  • A stale suppression (violation fixed, entry not pruned) fails CI, forcing cleanup to be recorded
  • A blanket /* eslint-disable */ cannot silently opt a file out of all 18 rules
  • The handbook rule table drifting from the ESLint config fails CI

Unit tests

  • Added — one RuleTester suite per custom rule
  • Files: playwright/eslint-rules/tests/*.test.ts — 5 rule suites, a plugin smoke test, and corpus.test.ts, which pins the suppression ceiling and asserts the corpus stays TypeScript-only
  • yarn test:eslint-rules → 107/107 pass (this now runs the repo's existing eslint-rules/*.test.mjs suites too; a duplicate script key was shadowing them, so CI had been running only half)

Backend integration tests

  • Not applicable (no backend changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable as new tests — this is test infrastructure. The only test changes are the 16 waitForResponse race fixes described above.

Manual testing performed

  1. yarn lint:playwright → exit 0
  2. yarn test:eslint-rules → 107/107
  3. node scripts/generate-playwright-rule-table.ts --check → exit 0
  4. Injected a .first() into a spec → CI sequence fails; reverted → passes
  5. Inflated a suppression count → lint fails with the stale-suppression error
  6. Added a blanket /* eslint-disable */ → blocked
  7. yarn tsc:playwright → 165 errors, unchanged from main (the count moved with main, not with this branch)

UI screen recording / screenshots:

Not applicable — no application UI changes. Test infrastructure, lint config, CI, and docs only.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable.
  • For UI changes: not applicable.
  • I have added tests and listed them above.

What follows this PR

The remediation, split by rule so each is reviewable on its own:

PR Scope Sites
2–5 no-positional-locator, split by area (utils+support / Pages / Features / Flow+PageObject) 1,341
later no-blanket-test-slow 83
later no-wait-for-timeout / no-wait-for-selector / no-force-option / no-skipped-test 83

Those PRs each modify eslint-suppressions.json, so they can be reviewed in parallel but must merge sequentially, each rebasing and re-pruning after the previous.

🤖 Generated with Claude Code

Greptile Summary

The PR adds enforceable Playwright lint guardrails, a suppression baseline, generated documentation checks, and CI integration while correcting response-listener ordering in affected tests.

  • Adds five local Playwright ESLint rules and their unit and corpus tests.
  • Establishes a suppression ratchet for existing violations.
  • Expands the Playwright CI gate to validate lint rules, suppressions, blanket disables, and generated documentation.
  • Adds reusable scoped-locator and response-wait helpers.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
.github/workflows/ui-checkstyle.yml Expands change detection and adds full-corpus Playwright guardrail checks; the previously reported blanket-disable and module-extension gaps are addressed at current HEAD.
openmetadata-ui/src/main/resources/ui/eslint.config.mjs Registers the local Playwright plugin and promotes the configured test-quality rules to errors under the intended test-file scope.
openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs Pins the suppression ceiling and rejects unsupported JavaScript and module-extension files before they can execute outside the lint scope.
openmetadata-ui/src/main/resources/ui/eslint-suppressions.json Introduces the baseline of legacy Playwright lint violations used by ESLint’s suppression ratchet.
openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/index.mjs Exposes the five custom Playwright lint rules through the local plugin.
openmetadata-ui/src/main/resources/ui/playwright/utils/waitHelpers.ts Adds a helper that registers response listeners before triggering actions to avoid missed-response races.

Reviews (21): Last reviewed commit: "docs(playwright): correct the corpus gua..." | Re-trigger Greptile

ShaileshParmar11 and others added 24 commits August 25, 2026 10:42
Adds the CommonJS eslint-rules plugin skeleton (rules: {}) that later
tasks register rules into, wires it into eslint.config.mjs under the
om-playwright namespace, and adds a node --test based unit test target.

Also adds an eslint.config.mjs block scoping the plugin's own .js files
to CommonJS globals/no-require-imports:off, and switches the
test:eslint-rules script to a glob instead of a bare directory path --
both needed because `node --test <dir>` does not recurse into an
explicit directory argument on this repo's pinned Node (22.17.0),
confirmed against the .nvmrc version, not just the locally active one.
…d fix 16 races

Registers a listener promise before the triggering action instead of awaiting
waitForResponse() after it, which races an already-fired response and hangs
until timeout. Zero suppressions — all 16 pre-existing violations fixed by hand.
…n, not as a weaker loader wait

Review found the explore.ts fix from the prior commit substituted a strictly
weaker wait (toHaveCount(0) is a no-op if the loader hasn't mounted yet) with
an inaccurate comment. selectDataAssetFilter has exactly one call site, so
the listener moves to EntitySummaryPanel.spec.ts's single beforeEach, before
the sidebarClick that actually triggers the query.
…test objects

- beforeEach runs on the triggering test's own timeout slot (verified
  against [email protected] worker/workerMain.js), so test.slow() there
  has the same blast radius as a describe-scope call; the previous
  heuristic treated it as legal. beforeAll/afterAll/afterEach each get
  their own slot and correctly remain legal.
- Widen detection to aliased test objects (e.g. base.slow() inside
  base.describe(), where base = test.extend(...)) via a dynamic
  test-object-identifier signal, while excluding variables bound
  directly to the describe function itself (const d = test.describe;)
  from being misclassified as per-test callbacks.
- Add RuleTester cases pinning beforeEach, beforeAll, afterEach,
  test.step, aliased test objects, and the describe-alias edge case.
- Re-snapshot: 89 violations (79 + 9 beforeEach + 1 aliased describe),
  suppressions total 94 (unchanged, 4 promoted rules) + 89 = 183.
Flags e2e tests whose body only performs page/locator interactions
(clicks, fills, navigation) with no expect() reference anywhere and no
call to anything beyond the test's own Playwright fixtures - i.e. tests
that are provably assertion-free.

The rule intentionally does not flag delegation to a helper or
page-object method (entity.descriptionUpdate(page), addUser(...),
verifyAuthenticated(...)), since those may assert internally and
proving otherwise needs interprocedural analysis this rule doesn't do.
An earlier text-scan-only design flagged 474 tests, but hand-verifying
samples showed most delegate to helpers that do assert - a large,
confirmed false-positive rate. Scoping the rule to only what it can
prove (no expect text + every call rooted at a page fixture) drops
that to a single, high-confidence violation:
playwright/e2e/nightly/ServiceIngestion.spec.ts's "Default Pagination
size should be 15" test, which waits on two network patterns and
clicks once but never asserts a status, body, or visible count.

Registered as om-playwright/require-assertion-per-test, scoped to
playwright/e2e/**/*.spec.{js,jsx,ts,tsx} only (utils/support files
contain no tests). Snapshot suppresses the one existing violation via
--suppress-rule; the four already-promoted playwright/* suppressions
(94) and om-playwright/no-blanket-test-slow (89) are untouched.

Co-Authored-By: Claude Opus 5 <[email protected]>
…e-assertion-per-test

test.slow(true), test.setTimeout(...), and test.step(...) were being
treated as ordinary non-page calls, so any test opening with one of
them (89 suppressed sites use test.slow()) was silently exempted no
matter how purely it clicked afterward - none of them can assert.

A call rooted at the `test` identifier is now filtered out before the
"every remaining call is page/locator-only" check, instead of counting
either way. test.step's own nested calls are unaffected: they're
separate CallExpression nodes checked on their own merits, since the
callback is inline and fully visible, not a delegated helper.

Corpus impact: still exactly 1 violation, same site
(ServiceIngestion.spec.ts:189) - no re-snapshot needed.

Co-Authored-By: Claude Opus 5 <[email protected]>
…row helper defaults

Widen no-positional-locator to flag Identifier/MemberExpression receivers
(hoisted-variable and property-stored locators), not just inline call-chain
tails - 185 previously-missed sites, closing the cheapest evasion path
(hoist into a variable). Discriminate genuine Playwright .first()/.last()/
.nth() calls from same-named non-Locator calls (e.g. lodash) by argument
arity instead.

Fix scopedLocators helpers: getRowByName defaulted to a CSS attribute
selector that never matches implicit ARIA roles (Ant Design <tr> rows),
and expectRowFor never forwarded rowSelector. Default to page.getByRole('row')
and thread rowSelector through both helpers; document the hasText
substring-collision failure mode.

Re-snapshot: no-positional-locator suppressions 1068 -> 1253 via
--suppress-rule (never --suppress-all/--prune-suppressions); the three
pre-existing suppression groups are byte-identical.

Co-Authored-By: Claude Opus 5 <[email protected]>
…e escape hatch

Add no-unscoped-count-assertion and require-unique-entity-name (heuristic,
expect false positives) plus justified-rule-disable, the escape hatch that
lets a developer document why a heuristic misfire is being suppressed.

require-unique-entity-name is implemented, tested, and registered in the
plugin but deliberately not enabled: a raw pass found 1625 violations, and
a 25-sample hand review found 0/25 true positives (matches were almost
entirely Playwright's own getByRole(..., { name }) option and static
config keys, not entity creation). Snapshotting that baseline would ratchet
near-total noise; left for a follow-up to narrow the heuristic. The other
two rules were sanity-checked, found to carry real signal, and are
snapshotted normally (+73, +9 violations; suppressions total 1437 -> 1519).

Co-Authored-By: Claude Opus 5 <[email protected]>
…e-entity-name

Both were reviewed against their full/near-full population, not just the
sanity-check samples from the initial implementation:

- require-unique-entity-name: confirmed ~3/1625 (0.18%) true-positive
  rate. The heuristic can't distinguish assigning a name to a new entity
  from using one to look an existing element up — 59% of hits are
  Playwright's own getByRole/getByLabel(role, { name }) accessible-name
  option, where adding uuid() would break the locator. 43/51 files under
  playwright/support/entity/ already call uuid() internally, so
  uniqueness is solved one layer down from where this rule looked.
  Never enabled, so no suppressions to remove.

- no-unscoped-count-assertion: full classification of all 73 sites found
  ~77% false positives (17 true / 56 false), dominated by the rule
  flagging locators already scoped through a variable per its own
  recommended fix (const c = loc.filter({ hasText }); expect(c)...) —
  failing code for following its own advice. Suppressions pruned via a
  full-corpus --prune-suppressions run; total 1519 -> 1446.

justified-rule-disable is untouched (its count of 9 was independently
re-verified) and now registers as the fifth rule in the plugin.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ate guidance

Docs previously listed a hand-written, stale error/warn split for the Playwright
ESLint rules that no longer matched eslint.config.mjs (every rule now runs at
error). Generate the rule table from the config instead, so the docs can't
drift from what CI actually enforces, and consolidate the overlapping rules
file and skills onto the generated table and the real lint:playwright:suppressions gate.
Adds a corpus meta-test that fails if eslint-suppressions.json's total
grows (ceiling 1446, the current baseline), and wires a full-corpus CI
step running the rule unit tests, the suppressions-aware lint with
pruning, and the generated rule-table freshness check. The step is
unconditional rather than changed-files-scoped because
--prune-suppressions against a partial file set would delete valid
suppressions for files the PR didn't touch. Until this lands, all 18
Playwright guardrail rules only ran locally.

Also updates skills/playwright-validation/SKILL.md's stale
three-rule/warn-tier description to reflect that every rule is now
error-level with no warn tier.
…wright guardrail step

--prune-suppressions writes eslint-suppressions.json in place when it
drops a stale entry, and the step never restored it — a later step in
the same job (lint_core_components) runs a repo-wide git status check
that could then misattribute this failure to itself. Restore the file
unconditionally on both the pass and fail paths.

Also guard the failure-detail grep with `|| true`: under GitHub's
default `bash -eo pipefail` shell, a grep with no matches exits
non-zero and would abort the script before the GITHUB_OUTPUT writes,
leaving the PR summary comment blank.
Playwright already runs with retries: 1 and the JSON reporter is already
enabled, so flaky/failed data is produced and discarded on every CI run.
Add a small aggregator that turns results.json into a flake-report.json
summary per shard, uploaded as an artifact. Purely additive: no new test
runtime, no changes to any existing step or job outcome.
…load

Four fixes from final branch review:
- ui-checkstyle: run the non-pruning yarn lint:playwright:full so a fixed
  violation fails CI until its stale suppression is pruned and committed,
  instead of silently discarding the rewrite; drop the now-dead
  git checkout restore; update the failure-reason text accordingly.
- justified-rule-disable rule + CI grep guard: a bare eslint-disable (no
  rule list) or a disable of the rule itself previously bypassed all 18
  guardrail rules undetected; the rule now reports blanket disables and a
  CI-level grep guard catches the self-referential case the rule cannot see.
- playwright-postgresql-e2e: add continue-on-error/overwrite/if-no-files-found
  to the flake-report upload so artifact-name collisions on job re-run don't
  fail an otherwise-passing 40-minute shard.
- docs: point developer-facing lint instructions at
  yarn lint:playwright:suppressions to match the new CI command split.

Co-Authored-By: Claude Opus 5 <[email protected]>
CI's changed-files checkstyle runs prettier, which the guardrail work did not.

Co-Authored-By: Claude Opus 5 <[email protected]>
CodeQL flagged the separate guardrail step as a high-severity cache-poisoning
risk: it executes PR-authored code (the eslint config and the local rule
plugin) in a pull_request_target job with a privileged checkout.

The file already documents the convention - every `run:` executing PR code in
this job is a poisonable step, so a separate step adds one more for no gain in
isolation. Folding the guardrail commands into the existing playwright step
removes the new alert without weakening the gate.

The checks now run before --fix/--write so they judge what the contributor
actually wrote, and the changed-files matcher is widened to eslint.config.mjs
and eslint-suppressions.json so a config-only change still triggers the gate.

Co-Authored-By: Claude Opus 5 <[email protected]>
`--suppress-all` over the current corpus (366 spec files, 618 linted)
captures every existing violation per file/rule, so all 18 rules can run at
`error` without fixing anything first.

The notch is what an unlinted corpus accumulated, not a budget: no rule here
has ever been enforced, so nothing has held the count down. corpus.test.js
pins it and fails if the total rises. From here it only moves downward.
The guard's second alternative used [^\\n]* to span the gap between
'eslint-disable' and the rule name. Inside a POSIX bracket expression a
backslash is literal, so [^\\n] means 'not a backslash and not the letter
n' — it cannot cross the 'n' in '-next-line'. The most common bypass form,

  // eslint-disable-next-line om-playwright/justified-rule-disable

therefore slipped straight through the check meant to catch it, while the
block form was caught. Use .* instead: grep is line-oriented, so the
newline exclusion was redundant as well as wrong.
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-08-27T01:34:02Z)

Blocked the queue: ui-checkstyle

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-08-27T05:47:16Z)

Blocked the queue: ui-checkstyle

main moved 25 commits under the branch, three of them touching playwright.
#30909 (Conversation V2) reworked 21 spec and util files (+600/-270), which
pushed several files past their recorded counts while others dropped below —
so the merge-queue run failed both ways at once: 17 no-positional-locator
errors plus stale entries.

Net movement is small: no-positional-locator 1341 -> 1343 (main added two new
call sites), no-wait-for-selector 36 -> 35. Total 1519 -> 1520.

These landed before the gate is live, so absorbing them is initialization
rather than the ratchet slipping — the same argument as the original 1265 ->
1341. The never-rises rule binds every PR after this one merges.
Comment thread .github/workflows/ui-checkstyle.yml Resolved
#29849 (QueryBuilderWidgetV1 migration) merged along with #32097 and #32112,
touching the playwright corpus. The full lint failed both ways as expected:
10 unsuppressed errors plus stale entries.

Net movement is downward — no-positional-locator 1343 -> 1339, total
1520 -> 1516. #29849's diff added 18 positional call sites, but other changes
in the same range removed more than that, so the ratchet tightens rather than
loosens here.

tsc:playwright moves 165 -> 166; the new error is in
playwright/e2e/Features/AdvancedSearch.spec.ts, a file main changed and this
branch does not touch. Zero tsc errors come from any file this PR adds.
Raising the floor to >=22.18.0 broke Collate's build. collate-ui's
prepare_collate-ui target runs `yarn install` against this package on Node
22.17, and yarn enforces engines at install time — so the build failed before
anything ran:

  error [email protected]: The engine "node" is incompatible with this
  module. Expected version ">=22.18.0". Got "22.17.0"

That step only installs; it never loads eslint.config.mjs, so the floor was
blocking a consumer that does not need the capability it describes.

The underlying requirement is real — importing the plugin as .ts needs Node's
type stripping, unflagged from 22.18 and behind --experimental-strip-types
from 22.6 — so it is now documented at the import site rather than dropped
silently. This repo's own .nvmrc is v22.22.2, and CI runs it, so the
supported path is unaffected.
Reverts the TypeScript conversion for the plugin, its tests and the rule-table
generator, and with it the Node floor that broke Collate's build.

Importing the plugin as .ts made eslint.config.mjs depend on Node's type
stripping — unflagged only from 22.18. That is a real requirement, so engines
was raised to match; but collate-ui runs `yarn install` against this package
on Node 22.17 and yarn enforces engines at install time, so a capability the
Collate build never uses blocked it from installing at all.

Writing the plugin as plain ESM removes the requirement rather than declaring
or working around it. It also matches what this repo already does: every
other rule plugin in eslint-rules/ is .mjs, including main's own
openmetadata-playwright.mjs, and scripts/ is .js/.mjs throughout — the .ts
files were the only ones of their kind.

Verified the constraint is genuinely gone: eslint now runs clean with
--no-experimental-strip-types, the exact condition that previously failed with
ERR_UNKNOWN_FILE_EXTENSION.

Also drops @types/estree, added only for the annotations, and removes
allowImportingTsExtensions plus the eslint-rules/tests exclude from
playwright/tsconfig.json, which existed only because the tests were .ts.
ShaileshParmar11 and others added 3 commits August 28, 2026 10:16
main moved the Playwright corpus since the last push: SettingsNavigationPage
gained one positional locator (8 -> 9) and Users.spec.ts had five fixed
(21 -> 16). Absorb both so the ratchet reflects the merged tree.

no-positional-locator 1339 -> 1335; baseline total 1516 -> 1512.

Co-Authored-By: Claude Opus 5 <[email protected]>
Cut comments that restated the code and compressed the rationale blocks that
had grown into essays. Kept the notes that record something unrecoverable from
reading the source: the workerMain.js timeout-slot evidence, the grep
basename-matching gotcha, --prune-suppressions exiting 0, the organize-imports
crash on .json, and the $$ replacement corruption.

Comments only; no functional lines touched.

Co-Authored-By: Claude Opus 5 <[email protected]>
chirag-madlani
chirag-madlani previously approved these changes Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-08-28T06:05:37Z)

Blocked the queue: ui-checkstyle

ShaileshParmar11 and others added 7 commits August 28, 2026 11:41
scripts/ had no ESLint config block, so `process` and `console` were undefined
there. The rule table generator was shielded by its .ts extension --
typescript-eslint disables no-undef for TypeScript -- until it moved to .mjs to
drop the Node type-stripping dependency. That re-armed no-undef against a
directory the config never covered.

Only reachable when a scripts/ file lands in a changed-file lint: a PR event
resolves a narrower diff, while the merge queue lists the whole PR against main
and always includes it.

Scoped to .mjs; the .js tooling alongside is CommonJS and needs a separate fix.

Co-Authored-By: Claude Opus 5 <[email protected]>
The guard rejected only .js/.jsx, but Playwright's default testMatch also
collects .mjs/.cjs/.mts/.cts, and the guardrails are scoped to .ts/.tsx -- so a
.spec.mjs would run entirely unlinted. Now that .mjs is a normal extension in
this tree, that is a realistic bypass.

Stated as an allowlist rather than a list of banned extensions, so any future
module extension is closed by default. Non-module files (.png, .md, .json) are
untouched.

Co-Authored-By: Claude Opus 5 <[email protected]>
Narrowing these to {ts,tsx} left the guardrails depending entirely on the
corpus TypeScript-only test: a .js spec would run with no rules applied if that
one test were ever skipped or bypassed. The narrowing bought nothing -- no
.js/.jsx exists under playwright/ -- so restoring them is free and puts the
lint back as a second line of defence behind the guard.

Verified unchanged: 0 errors, 218 warnings before and after.

Co-Authored-By: Claude Opus 5 <[email protected]>
Comments only; no functional lines touched.

Co-Authored-By: Claude Opus 5 <[email protected]>
Found by review of the merge-queue failure. Each was reproduced.

Trigger globs missed playwright/eslint-rules/**, playwright.config.ts and the
module extensions, and the whole step is gated on any_changed -- so a PR
touching only the guardrail plugin, the Playwright config, or a .spec.mts ran
no guardrails at all. The plugin's own tests never gated changes to the plugin.

The bypass grep only recognised directives starting with eslint-disable. An
inline `/* eslint <rule>: 0 */` silenced every rule undetected: a probe with
.first(), force:true and waitForTimeout linted clean.

Return codes are now captured so the git-status gate always runs. organize-imports
and prettier disagree permanently, so files are dirty between those lines; under
bash -e a lint failure aborted before cleanup and left the dirt for the next step,
which is how a playwright lint error turned the unrelated i18n job red.

The suppressions gate now splits real violations from stale entries. Both exit
non-zero, and the code is 2 even when a real violation is present, so keying off
it would swallow violations. Violations are counted from errorCount in the JSON
report and fail; a stale entry is main drifting under the branch, not a defect
here, and only warns.

Co-Authored-By: Claude Opus 5 <[email protected]>
`[^\n]*` cannot span a newline, so a directive whose rule list wrapped was not
recognised as a directive at all -- the rule reported nothing and no
justification was demanded. The CI grep missed it too, since that only fires
when eslint-disable sits alone on its line.

Co-Authored-By: Claude Opus 5 <[email protected]>
@gitar-bot

gitar-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 4 resolved / 5 findings

Enforces Playwright test anti-patterns via ESLint with a suppressions ratchet, fixing 16 genuine race conditions by hoisting response listeners and capturing 1,520 legacy violations in a baseline. Update the corpus.test.mjs comment and assertion message (lines 75–80, 105–109) to reflect that .js/.jsx files are now linted alongside .ts/.tsx by the widened glob, so future contributors understand why the corpus-only guard exists.

💡 Quality: corpus.test comment/message contradict the js/jsx glob change

📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:75-80 📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:105-109

This same commit widened the guardrail globs in eslint.config.mjs (lines 451, 555) and package.json to {js,jsx,ts,tsx}, so .js/.jsx files ARE now linted. Yet the corpus-test comment still states "eslint.config.mjs scopes the guardrails to .ts/.tsx only" and the assertion message claims these files "would run unlinted" and labels .mts/.cts as "Non-TypeScript modules" — all now inaccurate. Update the comment and failure message to reflect that the corpus is kept .ts/.tsx by convention (js/jsx are actually linted, and .mts/.cts are TypeScript) so a future contributor hitting the assertion isn't misled about why it fires.

✅ 4 resolved
✅ Security: Bypass-guard grep skips .js/.jsx Playwright files

📄 .github/workflows/ui-checkstyle.yml:313-314
The ESLint rule config applies all 18 rules to **/playwright/**/*.{js,jsx,ts,tsx}, but the CI bypass grep only scans --include='*.ts' --include='*.tsx'. A blanket /* eslint-disable */ (or a disable of om-playwright/justified-rule-disable) placed in a .js/.jsx file under playwright/ would silently opt that file out of every guardrail and would not be caught here (and, per the comment, cannot be caught by the rule itself). The .test.js exclusion is the stated reason, but that only requires excluding the eslint-rules/tests/ path, not all JS. Consider grepping .js/.jsx too while path-excluding the rule test fixtures.

✅ Quality: eslint version floor (^9.18.0) predates bulk-suppressions feature

📄 openmetadata-ui/src/main/resources/ui/package.json:248
The ratchet relies on ESLint bulk suppressions (--suppressions-location/--prune-suppressions), which only exist from ESLint 9.24+. package.json still declares "eslint": "^9.18.0"; the range floor (9.18.0) does not support these flags. It works today only because yarn.lock happens to resolve 9.39.4 — a future lockfile regeneration or fresh resolution that lands on 9.18–9.23 would break lint:playwright:full in CI with an unknown-flag error. Bump the declared floor to ^9.24.0 (or ^9.39.0) to match the feature the guardrails depend on.

✅ Bug: no-explicit-any 'error' may break CI on remaining any casts

📄 openmetadata-ui/src/main/resources/ui/eslint.config.mjs:201-205
Promoting '@typescript-eslint/no-explicit-any' from 'warn' to 'error' relies on the comment's claim that every non-generated site is cleared to zero (src/generated/** is correctly ignored). However grep still finds as any casts in production, non-generated files such as Settings/Services/Services.tsx and utils/ApplicationUtils.tsx. If any of these are not covered by an inline eslint-disable, flipping the rule to 'error' will fail the lint step in CI. Verify these sites are either removed or explicitly disabled (or run yarn lint on the full corpus) before merging; otherwise keep the rule at 'warn' until the cleanup stack lands.

✅ Edge Case: Corpus TypeScript-only guard misses .mjs/.cjs spec files

📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:89 📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:97-105
The corpus guard only flags /\.(js|jsx)$/, but Playwright's chromium project has no explicit testMatch, so it falls back to the default .*(test|spec)\.(js|ts|mjs) — meaning a *.spec.mjs under playwright/e2e would be collected and run by Playwright while escaping both the guardrail ESLint scope (./playwright/**/*.{ts,tsx}) and this guard. This commit makes .mjs a first-class, expected extension in the playwright tree, so an unlinted .spec.mjs slipping through is now realistic and defeats the guard's stated purpose. Extend the regex to also reject .mjs, .cjs, .mts, and .cts (keeping the existing EXEMPT set for tooling dirs).

🤖 Prompt for agents
Code Review: Enforces Playwright test anti-patterns via ESLint with a suppressions ratchet, fixing 16 genuine race conditions by hoisting response listeners and capturing 1,520 legacy violations in a baseline. Update the `corpus.test.mjs` comment and assertion message (lines 75–80, 105–109) to reflect that `.js`/`.jsx` files are now linted alongside `.ts`/`.tsx` by the widened glob, so future contributors understand why the corpus-only guard exists.

1. 💡 Quality: corpus.test comment/message contradict the js/jsx glob change
   Files: openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:75-80, openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:105-109

   This same commit widened the guardrail globs in eslint.config.mjs (lines 451, 555) and package.json to `{js,jsx,ts,tsx}`, so `.js`/`.jsx` files ARE now linted. Yet the corpus-test comment still states "eslint.config.mjs scopes the guardrails to .ts/.tsx only" and the assertion message claims these files "would run unlinted" and labels `.mts`/`.cts` as "Non-TypeScript modules" — all now inaccurate. Update the comment and failure message to reflect that the corpus is kept .ts/.tsx by convention (js/jsx are actually linted, and .mts/.cts are TypeScript) so a future contributor hitting the assertion isn't misled about why it fires.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Restoring js/jsx to the guardrail globs made this file's wording wrong: it still
claimed the guardrails cover .ts/.tsx only, that every flagged extension would
run unlinted, and it called .mts/.cts "non-TypeScript".

What is actually true: .js/.jsx are linted but do not belong in the corpus;
.mjs/.cjs/.mts/.cts fall outside the globs and really would run unlinted.

Co-Authored-By: Claude Opus 5 <[email protected]>
@gitar-bot

gitar-bot Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 5 resolved / 5 findings

Establishes Playwright guardrails via ESLint with an 18-rule suite, 1,520-violation suppression baseline, and five custom rules with tests. Fixes 16 genuine race conditions by hoisting waitForResponse listeners ahead of their triggering actions. Resolved bypass-guard grep to include .js/.jsx files, raised eslint floor to ^9.39.0 for bulk suppressions, removed no-explicit-any error severity to avoid breaking type-cast sites, and synchronized corpus.test comment with the js/jsx glob expansion. Ready to merge.

✅ 5 resolved
✅ Security: Bypass-guard grep skips .js/.jsx Playwright files

📄 .github/workflows/ui-checkstyle.yml:313-314
The ESLint rule config applies all 18 rules to **/playwright/**/*.{js,jsx,ts,tsx}, but the CI bypass grep only scans --include='*.ts' --include='*.tsx'. A blanket /* eslint-disable */ (or a disable of om-playwright/justified-rule-disable) placed in a .js/.jsx file under playwright/ would silently opt that file out of every guardrail and would not be caught here (and, per the comment, cannot be caught by the rule itself). The .test.js exclusion is the stated reason, but that only requires excluding the eslint-rules/tests/ path, not all JS. Consider grepping .js/.jsx too while path-excluding the rule test fixtures.

✅ Quality: eslint version floor (^9.18.0) predates bulk-suppressions feature

📄 openmetadata-ui/src/main/resources/ui/package.json:248
The ratchet relies on ESLint bulk suppressions (--suppressions-location/--prune-suppressions), which only exist from ESLint 9.24+. package.json still declares "eslint": "^9.18.0"; the range floor (9.18.0) does not support these flags. It works today only because yarn.lock happens to resolve 9.39.4 — a future lockfile regeneration or fresh resolution that lands on 9.18–9.23 would break lint:playwright:full in CI with an unknown-flag error. Bump the declared floor to ^9.24.0 (or ^9.39.0) to match the feature the guardrails depend on.

✅ Bug: no-explicit-any 'error' may break CI on remaining any casts

📄 openmetadata-ui/src/main/resources/ui/eslint.config.mjs:201-205
Promoting '@typescript-eslint/no-explicit-any' from 'warn' to 'error' relies on the comment's claim that every non-generated site is cleared to zero (src/generated/** is correctly ignored). However grep still finds as any casts in production, non-generated files such as Settings/Services/Services.tsx and utils/ApplicationUtils.tsx. If any of these are not covered by an inline eslint-disable, flipping the rule to 'error' will fail the lint step in CI. Verify these sites are either removed or explicitly disabled (or run yarn lint on the full corpus) before merging; otherwise keep the rule at 'warn' until the cleanup stack lands.

✅ Quality: corpus.test comment/message contradict the js/jsx glob change

📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:75-80 📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:105-109
This same commit widened the guardrail globs in eslint.config.mjs (lines 451, 555) and package.json to {js,jsx,ts,tsx}, so .js/.jsx files ARE now linted. Yet the corpus-test comment still states "eslint.config.mjs scopes the guardrails to .ts/.tsx only" and the assertion message claims these files "would run unlinted" and labels .mts/.cts as "Non-TypeScript modules" — all now inaccurate. Update the comment and failure message to reflect that the corpus is kept .ts/.tsx by convention (js/jsx are actually linted, and .mts/.cts are TypeScript) so a future contributor hitting the assertion isn't misled about why it fires.

✅ Edge Case: Corpus TypeScript-only guard misses .mjs/.cjs spec files

📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:89 📄 openmetadata-ui/src/main/resources/ui/playwright/eslint-rules/tests/corpus.test.mjs:97-105
The corpus guard only flags /\.(js|jsx)$/, but Playwright's chromium project has no explicit testMatch, so it falls back to the default .*(test|spec)\.(js|ts|mjs) — meaning a *.spec.mjs under playwright/e2e would be collected and run by Playwright while escaping both the guardrail ESLint scope (./playwright/**/*.{ts,tsx}) and this guard. This commit makes .mjs a first-class, expected extension in the playwright tree, so an unlinted .spec.mjs slipping through is now realistic and defeats the guard's stated purpose. Extend the regex to also reject .mjs, .cjs, .mts, and .cts (keeping the existing EXEMPT set for tooling dirs).

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playwright guardrails: enforce test anti-patterns in CI via ESLint + suppressions ratchet

3 participants