Skip to content

Commit

Permalink
fix playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Katkov committed Feb 1, 2024
1 parent 9f72f9c commit 19560a0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
47 changes: 25 additions & 22 deletions src/config/rulesets/ruleset.playwright.ts
Original file line number Diff line number Diff line change
@@ -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<string, Rule> = {
'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,
},
}
12 changes: 9 additions & 3 deletions src/lib/eslint/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ const getPlugins = (projectDependencies: string[]): ByScope<string[]> => {
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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 19560a0

Please sign in to comment.