From cb874d6e87aa2cac097bdd4a2bfe2c58dac330ed Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Wed, 18 Nov 2026 15:36:19 -0600 Subject: [PATCH 1/3] Mark several recommended Playwright rules as errors instead of warnings --- packages/eslint-config-playwright/index.js | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/packages/eslint-config-playwright/index.js b/packages/eslint-config-playwright/index.js index 606cc324..fb24b77f 100644 --- a/packages/eslint-config-playwright/index.js +++ b/packages/eslint-config-playwright/index.js @@ -15,12 +15,30 @@ export const playwrightConfig = defineConfig([ */ 'no-await-in-loop': 'off', + /* + Playwright marks this as recommended but configures it as 'warn'. + A test without an assertion can't fail on incorrect behavior, so it gives a false sense of coverage. + */ + 'playwright/expect-expect': 'error', + /* Playwright marks this as recommended but configures it as 'warn'. Deeply nested describe blocks are likely an indication that test files are too complicated. */ 'playwright/max-nested-describe': 'error', + /* + Commented out tests are easy to forget about and lose coverage silently. + Use a skipped test accompanied by a comment linking to a work item instead. + */ + 'playwright/no-commented-out-tests': 'error', + + /* + Playwright marks this as recommended but configures it as 'warn'. + An assertion that is conditionally skipped can cause a test to pass without verifying anything. + */ + 'playwright/no-conditional-expect': 'error', + /* Playwright marks this as recommended but configures it as 'warn'. Conditional logic in tests is usually an indication that a test is attempting to cover too much, and not testing the logic it intends to. @@ -47,6 +65,12 @@ export const playwrightConfig = defineConfig([ */ 'playwright/no-force-option': 'error', + /* + Playwright marks this as recommended but configures it as 'warn'. + Identical titles make it hard to tell which test failed and can cause tests to be filtered or reported incorrectly. + */ + 'playwright/no-identical-title': 'error', + /* Playwright marks this as recommended but configures it as 'warn'. Using page.pause should be reserved for debugging, not production code. @@ -60,23 +84,53 @@ export const playwrightConfig = defineConfig([ */ 'playwright/no-skipped-test': 'off', + /* + Playwright marks this as recommended but configures it as 'warn'. + Awaiting a value that is not a promise is unnecessary and misleading about what is asynchronous. + */ + 'playwright/no-useless-await': 'error', + /* Playwright marks this as recommended but configures it as 'warn'. Assertions are easier to read when using a dedicated matcher rather than negating the opposite matcher. */ 'playwright/no-useless-not': 'error', + /* + Playwright marks this as recommended but configures it as 'warn'. + page.waitForSelector is discouraged. Instead use locators with web-first assertions, which wait automatically. + */ + 'playwright/no-wait-for-selector': 'error', + /* Playwright marks this as recommended but configures it as 'warn'. Waiting for arbitrary amounts of time can cause test intermittency. Instead wait for a specific condition. */ 'playwright/no-wait-for-timeout': 'error', + /* + Playwright marks this as recommended but configures it as 'warn'. + Locators are auto-waiting and retryable. Instead of page methods like page.click use page.locator().click(). + */ + 'playwright/prefer-locator': 'error', + + /* + Playwright marks this as recommended but configures it as 'warn'. + toHaveCount() retries until the count matches, which avoids intermittency compared to asserting on locator.count(). + */ + 'playwright/prefer-to-have-count': 'error', + /* In order to have a better failure message, toHaveLength() should be used when asserting expectations on objects length property. */ 'playwright/prefer-to-have-length': 'error', + /* + Skipped tests are allowed (see no-skipped-test) but must explain why they are skipped. + The reason should link to a work item that tracks re-enabling the test. + */ + 'playwright/require-annotation-reason': 'error', + /* Having a top-level describe block in each test file is common practice which aligns with patterns we use in Jasmine */ From b5320b7dcf2d65e83cc088b8cb43babdeb50cd65 Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Wed, 18 Nov 2026 15:36:39 -0600 Subject: [PATCH 2/3] Update eslint-plugin-playwright version --- package-lock.json | 2 +- packages/eslint-config-playwright/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 81af6d01..c95d9083 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13971,7 +13971,7 @@ "peerDependencies": { "@ni/eslint-config-javascript": "^5.2.0", "@ni/eslint-config-typescript": "^5.0.7", - "eslint-plugin-playwright": "^2.10.2" + "eslint-plugin-playwright": "^2.12.0" } }, "packages/eslint-config-typescript": { diff --git a/packages/eslint-config-playwright/package.json b/packages/eslint-config-playwright/package.json index 1a214e95..2efd6fdc 100644 --- a/packages/eslint-config-playwright/package.json +++ b/packages/eslint-config-playwright/package.json @@ -39,6 +39,6 @@ "peerDependencies": { "@ni/eslint-config-typescript": "^5.0.7", "@ni/eslint-config-javascript": "^5.2.0", - "eslint-plugin-playwright": "^2.10.2" + "eslint-plugin-playwright": "^2.12.0" } } From a0aa720bb5e1e29ed6c99d9f1d68b0f73d4a124e Mon Sep 17 00:00:00 2001 From: Jesse Attas Date: Wed, 18 Nov 2026 15:37:09 -0600 Subject: [PATCH 3/3] Change files --- ...ig-playwright-9c9f29cc-9f05-4cc9-bce6-934610f4b899.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@ni-eslint-config-playwright-9c9f29cc-9f05-4cc9-bce6-934610f4b899.json diff --git a/change/@ni-eslint-config-playwright-9c9f29cc-9f05-4cc9-bce6-934610f4b899.json b/change/@ni-eslint-config-playwright-9c9f29cc-9f05-4cc9-bce6-934610f4b899.json new file mode 100644 index 00000000..6fba2132 --- /dev/null +++ b/change/@ni-eslint-config-playwright-9c9f29cc-9f05-4cc9-bce6-934610f4b899.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Mark several recommended Playwright rules as errors instead of warnings", + "packageName": "@ni/eslint-config-playwright", + "email": "jattasNI@users.noreply.github.com", + "dependentChangeType": "patch" +}