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

Support flat config #169

Merged
merged 4 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ This plugin bundles two configurations to work with both `@playwright/test` or

### With [Playwright test runner](https://playwright.dev/docs/writing-tests)

[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
(**eslint.config.js**)

```javascript
import playwright from 'eslint-plugin-playwright';

export default [
playwright.configs['flat/recommended'],
{
rules: {
// Customize Playwright rules
// ...
},
},
];
```

[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
(**.eslintrc**)

```json
{
"extends": ["plugin:playwright/recommended"]
Expand All @@ -41,6 +61,30 @@ This plugin bundles two configurations to work with both `@playwright/test` or

### With [Jest Playwright](https://github.com/playwright-community/jest-playwright)

[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
(**eslint.config.js**)

```javascript
import playwright from 'eslint-plugin-playwright';
import jest from 'eslint-plugin-jest';

export default [
playwright.configs['flat/jest-playwright'],
{
plugins: {
jest,
},
rules: {
// Customize Playwright rules
// ...
},
},
];
```

[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
(**.eslintrc**)

```json
{
"extends": ["plugin:playwright/jest-playwright"]
Expand All @@ -63,6 +107,24 @@ under the `playwright` key. It supports the following settings:

You can configure these settings like so:

[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
(**eslint.config.js**)

```javascript
export default [
{
settings: {
playwright: {
additionalAssertFunctionNames: ['assertCustomCondition'],
},
},
},
];
```

[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
(**.eslintrc**)

```json
{
"settings": {
Expand Down
21 changes: 0 additions & 21 deletions examples/.eslintrc

This file was deleted.

25 changes: 25 additions & 0 deletions examples/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import playwright from 'eslint-plugin-playwright';

export default [
playwright.configs['flat/recommended'],
{
languageOptions: {
sourceType: 'module',
ecmaVersion: 2022,
},
rules: {
'playwright/prefer-lowercase-title': 'warn',
'playwright/prefer-to-be': 'warn',
'playwright/prefer-to-have-length': 'warn',
'playwright/prefer-strict-equal': 'warn',
'playwright/max-nested-describe': ['warn', { max: 1 }],
'playwright/no-restricted-matchers': [
'error',
{
toBeFalsy: 'Use `toBe(false)` instead.',
not: null,
},
],
},
},
];
4 changes: 2 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"dependencies": {
"@playwright/test": "^1.38.1",
"eslint": "^8.50.0",
"eslint-plugin-playwright": "workspace:*"
"eslint": "^8.51.0",
"eslint-plugin-playwright": "file:../"
}
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@
"eslint-plugin-jest": {
"optional": true
}
},
"dependencies": {
"globals": "^13.23.0"
}
}
Loading