Skip to content

Commit

Permalink
feat: add playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
ASafaeirad committed Jun 8, 2024
1 parent 916cc77 commit 48ab977
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
49 changes: 49 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"main": "src/index.js",
"dependencies": {
"@graphql-eslint/eslint-plugin": "3.20.1",
"typescript-eslint": "rc-v8",
"deepmerge": "4.3.1",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-cypress": "3.3.0",
Expand All @@ -35,14 +34,16 @@
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-n": "17.8.1",
"eslint-plugin-playwright": "1.6.2",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-promise": "6.2.0",
"eslint-plugin-react": "7.34.2",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-storybook": "0.8.0",
"eslint-plugin-tailwindcss": "3.17.3",
"eslint-plugin-vitest": "0.5.4",
"globals": "15.4.0"
"globals": "15.4.0",
"typescript-eslint": "rc-v8"
},
"devDependencies": {
"@eslint/eslintrc": "3.1.0",
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const strict = require('./modules/strict');
const react = require('./modules/react');
const storybook = require('./modules/storybook');
const typescript = require('./modules/typescript');
const playwright = require('./modules/playwright');

const testPackages = ['jest', 'vitest', 'cypress', 'playwright'];

Expand All @@ -40,6 +41,7 @@ const defaultOptions = {
prettier: isPackageExists('prettier'),
typescript: isPackageExists('typescript') ? { projects: true } : false,
unocss: isPackageExists('unocss'),
playwright: isPackageExists('playwright'),
};

/**
Expand Down Expand Up @@ -71,6 +73,7 @@ function init(initOptions, ...extend) {
if (options.react) rules.push(react(options));
if (options.storybook) rules.push(storybook(options));
if (options.typescript) rules.push(typescript(options));
if (options.playwright) rules.push(playwright(options));

// ISSUE: Waiting for FlatConfig support https://github.com/dimaMachina/graphql-eslint/issues/2178
// if (false && options.graphql) rules.push(graphql(options));
Expand Down
1 change: 1 addition & 0 deletions src/init.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface Options {
cypress?: boolean;
storybook?: boolean;
prettier?: boolean;
playwright?: boolean;
typescript?: { projects: string[] | string };
disableExpensiveRules?: boolean;
}
Expand Down
30 changes: 30 additions & 0 deletions src/modules/playwright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const globals = require('globals');
const plugin = require('eslint-plugin-playwright');
const { globs } = require('../utils/globs');

/** @return { import('eslint').Linter.FlatConfig } */
function playwright() {
return {
plugins: { playwright: plugin },
files: globs.e2e,
rules: {
'jest/no-standalone-expect': [
'error',
{
additionalTestBlockFunctions: [
'test.jestPlaywrightDebug',
'it.jestPlaywrightDebug',
'test.jestPlaywrightSkip',
'it.jestPlaywrightSkip',
'test.jestPlaywrightConfig',
'it.jestPlaywrightConfig',
],
},
],
'playwright/missing-playwright-await': 'error',
'playwright/no-page-pause': 'warn',
},
};
}

module.exports = playwright;
5 changes: 5 additions & 0 deletions src/modules/tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const plugin = require('eslint-plugin-jest-formatting');
const { globs } = require('../utils/globs');
const { predicate } = require('../utils/conditions');
const globals = require('globals');

/**
* @param {import('../init').Options} options
Expand All @@ -10,6 +11,9 @@ function tests(options = {}) {
return {
plugins: { 'jest-formatting': plugin },
files: [...globs.test, ...globs.e2e],
languageOptions: {
globals: globals['shared-node-browser'],
},
rules: {
'jest-formatting/padding-around-after-all-blocks': 'warn',
'jest-formatting/padding-around-after-each-blocks': 'warn',
Expand All @@ -35,6 +39,7 @@ function tests(options = {}) {
'@typescript-eslint/no-namespace ': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'off',
}),
},
};
Expand Down

0 comments on commit 48ab977

Please sign in to comment.