Skip to content

chore(deps): add eslint-plugin-playwright and fix invalid expects#40111

Open
przemyslvw wants to merge 1 commit intomicrosoft:mainfrom
przemyslvw:chore/eslint-playwright-and-deps
Open

chore(deps): add eslint-plugin-playwright and fix invalid expects#40111
przemyslvw wants to merge 1 commit intomicrosoft:mainfrom
przemyslvw:chore/eslint-playwright-and-deps

Conversation

@przemyslvw
Copy link
Copy Markdown

Motivation

This PR introduces essential security updates and strengthens the testing guardrails at the linting stage, preventing common Playwright anti-patterns from slipping into the codebase.

  1. Security: The concurrently dependency is bumped to ^9.0.0 to address known shell injection vulnerabilities present in the 6.x line.
  2. Test Reliability: The repository currently lacks eslint-plugin-playwright. This creates a blind spot for testing anti-patterns (e.g., unawaited assertions, committed page.pause(), or missing matchers).

Changes

  • Dependencies: Updated concurrently to ^9.0.0 and installed eslint-plugin-playwright.
  • ESLint Configuration (eslint.config.mjs):
    • Added playwright/no-wait-for-timeout as a warn. There are currently 71 instances of hard waits in the suite. Setting this to warn prevents breaking the CI while making the tech debt visible to developers.
    • Enforced playwright/no-focused-test and playwright/valid-expect as error to block future regressions during code review.
  • Fixed existing valid-expect violations (6 errors resolved):
    • tests/library/resource-timing.spec.ts: Added missing .toBeTruthy() to an incomplete assertion.
    • tests/page/selectors-text.spec.ts: Cleaned up 3 dead/redundant expect(await locator.isVisible()) calls that lacked matchers.
    • tests/page/expect-boolean.spec.ts: Added // eslint-disable-next-line playwright/valid-expect to negative tests that intentionally pass incorrect types to verify error handling.

Validation

  • npm run lint now passes with 0 errors, 71 warnings.
  • No impact on existing test execution (verified locally).

- Bump `concurrently` to ^9.0.0 to mitigate shell injection vulnerabilities.
- Introduce `eslint-plugin-playwright` to enforce testing guardrails.
- Set `playwright/no-wait-for-timeout` to `warn` to keep CI green while flagging tech debt.
- Enforce `playwright/valid-expect` and `playwright/no-focused-test` as `error`.
- Fix existing `valid-expect` violations:
  - Add missing `.toBeTruthy()` in `resource-timing.spec.ts`.
  - Remove redundant, matcher-less expects in `selectors-text.spec.ts`.
  - Add inline eslint-disable for intentional negative tests in `expect-boolean.spec.ts`.
@przemyslvw
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant