2023-10-30 14:23:40 +00:00
|
|
|
const rulesDirPlugin = require( 'eslint-plugin-rulesdir' );
|
2024-05-14 08:23:17 +00:00
|
|
|
rulesDirPlugin.RULES_DIR = `${ __dirname }/rules`;
|
2023-10-30 14:23:40 +00:00
|
|
|
|
2023-08-08 13:25:45 +00:00
|
|
|
const config = {
|
2024-05-14 08:23:17 +00:00
|
|
|
extends: [
|
|
|
|
'plugin:playwright/recommended',
|
|
|
|
'plugin:@typescript-eslint/base',
|
|
|
|
],
|
2023-10-30 14:23:40 +00:00
|
|
|
plugins: [ 'rulesdir' ],
|
2024-05-14 08:23:17 +00:00
|
|
|
parserOptions: {
|
|
|
|
tsconfigRootDir: __dirname,
|
|
|
|
project: './tsconfig.json',
|
|
|
|
},
|
2023-08-08 13:25:45 +00:00
|
|
|
rules: {
|
2024-05-14 08:23:17 +00:00
|
|
|
'@wordpress/no-global-active-element': 'off',
|
|
|
|
'@wordpress/no-global-get-selection': 'off',
|
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
selector: 'CallExpression[callee.property.name="$"]',
|
|
|
|
message: '`$` is discouraged, please use `locator` instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
selector: 'CallExpression[callee.property.name="$$"]',
|
|
|
|
message: '`$$` is discouraged, please use `locator` instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
selector:
|
|
|
|
'CallExpression[callee.object.name="page"][callee.property.name="waitForTimeout"]',
|
|
|
|
message: 'Prefer page.locator instead.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'playwright/no-conditional-in-test': 'off',
|
|
|
|
'@typescript-eslint/await-thenable': 'error',
|
|
|
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
|
|
'@typescript-eslint/no-misused-promises': 'error',
|
2023-10-30 14:23:40 +00:00
|
|
|
'rulesdir/no-raw-playwright-test-import': 'error',
|
2024-05-15 11:05:52 +00:00
|
|
|
// Since we're restoring the database for each test, hooks other than
|
|
|
|
// `beforeEach` don't make sense.
|
|
|
|
// See https://github.com/woocommerce/woocommerce/pull/46432.
|
|
|
|
'playwright/no-hooks': [ 'error', { allow: [ 'beforeEach' ] } ],
|
2023-08-08 13:25:45 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = config;
|