From 19560a0e767a9da1b5a11c2d7e69e23f64e22487 Mon Sep 17 00:00:00 2001 From: Nikolai Katkov Date: Thu, 1 Feb 2024 23:30:02 +0100 Subject: [PATCH] fix playwright --- src/config/rulesets/ruleset.playwright.ts | 47 ++++++++++++----------- src/lib/eslint/getConfig.ts | 12 ++++-- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/config/rulesets/ruleset.playwright.ts b/src/config/rulesets/ruleset.playwright.ts index 029d6be..e84ea36 100644 --- a/src/config/rulesets/ruleset.playwright.ts +++ b/src/config/rulesets/ruleset.playwright.ts @@ -1,68 +1,71 @@ -import type { Rule } from '../../lib/eslint/rulesConfig' +import type { Rule, RuleInput } from '../../lib/eslint/rulesConfig' import { projectHas } from '../../lib/eslint/rulesConfig' -const yes = projectHas('@playwright/test') +const forAllPlaywrightUsage = ({ projectDependencies }: RuleInput) => + projectDependencies.includes('@playwright/test') || projectDependencies.includes('playwright') + +const forTestsOnly = projectHas('@playwright/test') export const ruleset: Record = { 'playwright/max-nested-describe': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/missing-playwright-await': { - enabled: yes, + enabled: forTestsOnly, fixable: true, }, 'playwright/no-conditional-in-test': { - enabled: false, // may be too disruptive and lacking justificaition // yes, + enabled: false, // may be too disruptive and lacking justificaition // forTestsOnly, }, 'playwright/no-element-handle': { - enabled: yes, + enabled: forAllPlaywrightUsage, }, 'playwright/no-eval': { - enabled: yes, + enabled: forAllPlaywrightUsage, }, 'playwright/no-focused-test': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/no-force-option': { - enabled: yes, + enabled: forAllPlaywrightUsage, }, 'playwright/no-page-pause': { - enabled: yes, + enabled: forAllPlaywrightUsage, }, 'playwright/no-restricted-matchers': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/no-skipped-test': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/no-useless-not': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/no-wait-for-timeout': { - enabled: yes, + enabled: forAllPlaywrightUsage, }, 'playwright/prefer-lowercase-title': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/prefer-strict-equal': { - enabled: yes, + enabled: forAllPlaywrightUsage, }, 'playwright/prefer-to-be': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/prefer-to-have-length': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/prefer-web-first-assertions': { - enabled: yes, + enabled: forTestsOnly, }, 'playwright/require-soft-assertions': { - enabled: false, // too opinionated + enabled: false, // too opinionated // forTestsOnly }, 'playwright/require-top-level-describe': { - enabled: false, // rconsider after + enabled: false, // rconsider after // forTestsOnly }, 'playwright/valid-expect': { - enabled: yes, + enabled: forTestsOnly, }, } diff --git a/src/lib/eslint/getConfig.ts b/src/lib/eslint/getConfig.ts index f55794e..ac02e61 100644 --- a/src/lib/eslint/getConfig.ts +++ b/src/lib/eslint/getConfig.ts @@ -75,7 +75,10 @@ const getPlugins = (projectDependencies: string[]): ByScope => { if (projectDependencies.includes('jest')) { plugins.testJest.push('jest') } - if (projectDependencies.includes('@playwright/test')) { + if ( + projectDependencies.includes('@playwright/test') || + projectDependencies.includes('playwright') + ) { plugins.testJest.push('playwright') } return plugins @@ -246,8 +249,11 @@ const getDependencies = (projectDependencies: string[]): ExactDependency[] => { if (projectDependencies.includes('jest')) { dependencies.push(['eslint-plugin-jest', '27.6.0']) } - if (projectDependencies.includes('@playwright/test')) { - dependencies.push(['eslint-plugin-playwright', '0.14.2']) + if ( + projectDependencies.includes('@playwright/test') || + projectDependencies.includes('playwright') + ) { + dependencies.push(['eslint-plugin-playwright', '0.14.3']) } return dependencies }