Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: eslint plugin playwright #433

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion template/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"devDependencies": {
"eslint-plugin-cypress": "^2.15.1"
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-playwright": "^0.21.0"
}
}
7 changes: 6 additions & 1 deletion utils/renderEslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -35,6 +35,11 @@ export default function renderEslint(
additionalDependencies['eslint-plugin-cypress'] = eslintDeps['eslint-plugin-cypress']
}

if (needsPlaywright) {
additionalConfig.extends = ['plugin:playwright/recommended']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the plugin apply only the Playwright files (as done for Cypress above)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ESLint will apply the rules defined in the root of your configuration to all files in your project (which is not ideal).
@georgi-mateev Can you target e2e folder - something like files: ['e2e/**/*.{js,ts,jsx,tsx}']?

additionalDependencies['eslint-plugin-playwright'] = eslintDeps['eslint-plugin-playwright']
}

const { pkg, files } = createESLintConfig({
vueVersion: '3.x',
// we currently don't support other style guides
Expand Down
Loading