From e82c1df0d6defd014ec6ad06f2eb698368401d7e Mon Sep 17 00:00:00 2001 From: Georgi Mateev Date: Fri, 26 Jan 2024 18:29:44 +0200 Subject: [PATCH 1/2] feat: eslint plugin playwright --- index.ts | 8 +++++++- template/eslint/package.json | 3 ++- utils/renderEslint.ts | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index b04c20e9..9fc382b9 100755 --- a/index.ts +++ b/index.ts @@ -432,7 +432,13 @@ async function init() { // Render ESLint config if (needsEslint) { - renderEslint(root, { needsTypeScript, needsCypress, needsCypressCT, needsPrettier }) + renderEslint(root, { + needsTypeScript, + needsCypress, + needsCypressCT, + needsPrettier, + needsPlaywright + }) } // Render code template. diff --git a/template/eslint/package.json b/template/eslint/package.json index 24786f0a..cc3f0961 100644 --- a/template/eslint/package.json +++ b/template/eslint/package.json @@ -1,5 +1,6 @@ { "devDependencies": { - "eslint-plugin-cypress": "^2.15.1" + "eslint-plugin-cypress": "^2.15.1", + "eslint-plugin-playwright": "^0.21.0" } } diff --git a/utils/renderEslint.ts b/utils/renderEslint.ts index 86a7fbb5..56e69f9b 100644 --- a/utils/renderEslint.ts +++ b/utils/renderEslint.ts @@ -13,7 +13,7 @@ const eslintDeps = eslintTemplatePackage.devDependencies export default function renderEslint( rootDir, - { needsTypeScript, needsCypress, needsCypressCT, needsPrettier } + { needsTypeScript, needsCypress, needsCypressCT, needsPrettier, needsPlaywright } ) { const additionalConfig: Linter.Config = {} const additionalDependencies = {} @@ -35,6 +35,11 @@ export default function renderEslint( additionalDependencies['eslint-plugin-cypress'] = eslintDeps['eslint-plugin-cypress'] } + if (needsPlaywright) { + additionalConfig.extends = ['plugin:playwright/recommended'] + additionalDependencies['eslint-plugin-playwright'] = eslintDeps['eslint-plugin-playwright'] + } + const { pkg, files } = createESLintConfig({ vueVersion: '3.x', // we currently don't support other style guides From 776a9e7346cb99e6890477f8c3b7e810bc082a16 Mon Sep 17 00:00:00 2001 From: Georgi Mateev Date: Mon, 5 Feb 2024 13:06:35 +0200 Subject: [PATCH 2/2] fix: set plugin on correct files --- utils/renderEslint.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/renderEslint.ts b/utils/renderEslint.ts index 56e69f9b..dba48959 100644 --- a/utils/renderEslint.ts +++ b/utils/renderEslint.ts @@ -36,7 +36,13 @@ export default function renderEslint( } if (needsPlaywright) { - additionalConfig.extends = ['plugin:playwright/recommended'] + additionalConfig.overrides = [ + { + files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'], + extends: ['plugin:playwright/recommended'] + } + ] + additionalDependencies['eslint-plugin-playwright'] = eslintDeps['eslint-plugin-playwright'] }