From b3d51d5faf2b3d7f92724fb8835a241edfd42206 Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Wed, 18 Jan 2023 14:11:46 -0600 Subject: [PATCH] Add more Playwright rules (#31) * Add more Playwright rules * Changeset --- .changeset/tasty-donkeys-agree.md | 5 +++++ packages/eslint-config-widen/package.json | 2 +- packages/eslint-config-widen/src/playwright.ts | 18 ++++++++++++++++++ yarn.lock | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .changeset/tasty-donkeys-agree.md diff --git a/.changeset/tasty-donkeys-agree.md b/.changeset/tasty-donkeys-agree.md new file mode 100644 index 0000000..b6c8a62 --- /dev/null +++ b/.changeset/tasty-donkeys-agree.md @@ -0,0 +1,5 @@ +--- +'eslint-config-widen': minor +--- + +Add more Playwright rules diff --git a/packages/eslint-config-widen/package.json b/packages/eslint-config-widen/package.json index dbb6ec7..26f83d3 100644 --- a/packages/eslint-config-widen/package.json +++ b/packages/eslint-config-widen/package.json @@ -30,7 +30,7 @@ "eslint": ">= 8", "eslint-plugin-jest": ">= 25", "eslint-plugin-jsx-a11y": ">= 6", - "eslint-plugin-playwright": ">=0.11.1", + "eslint-plugin-playwright": ">=0.12.0", "eslint-plugin-react": ">= 7", "eslint-plugin-react-hooks": ">= 4", "eslint-plugin-sort": ">= 2", diff --git a/packages/eslint-config-widen/src/playwright.ts b/packages/eslint-config-widen/src/playwright.ts index aed24a9..afa025d 100644 --- a/packages/eslint-config-widen/src/playwright.ts +++ b/packages/eslint-config-widen/src/playwright.ts @@ -2,10 +2,28 @@ export = { extends: ['plugin:playwright/playwright-test'], plugins: ['playwright'], rules: { + 'playwright/missing-playwright-await': [ + 'error', + { customMatchers: ['toBeAccessible', 'toPassAxe'] }, + ], + 'playwright/no-restricted-matchers': [ + 'warn', + { + toEqualValue: 'Use `toHaveValue` instead.', + toHaveSelector: 'Use `toBeVisible` instead.', + toHaveSelectorCount: 'Use `toHaveCount` instead.', + toMatchAttribute: 'Use `toHaveAttribute` instead.', + toMatchText: 'Use `toHaveText` instead.', + toMatchURL: 'Use `toHaveURL` instead.', + toMatchValue: 'Use `toHaveValue` instead.', + }, + ], 'playwright/prefer-lowercase-title': [ 'warn', { ignoreTopLevelDescribe: true }, ], + 'playwright/prefer-strict-equal': 'warn', + 'playwright/prefer-to-be': 'warn', 'playwright/prefer-to-have-length': 'warn', 'playwright/require-top-level-describe': 'warn', }, diff --git a/yarn.lock b/yarn.lock index d68ea7e..778f8ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3852,7 +3852,7 @@ __metadata: eslint: ">= 8" eslint-plugin-jest: ">= 25" eslint-plugin-jsx-a11y: ">= 6" - eslint-plugin-playwright: ">=0.11.1" + eslint-plugin-playwright: ">=0.12.0" eslint-plugin-react: ">= 7" eslint-plugin-react-hooks: ">= 4" eslint-plugin-sort: ">= 2"