Skip to content

Commit 01bd627

Browse files
authored
Support flat config (#169)
* feat: Support flat config * chore: Update examples to flat config * chore: Update docs * chore: Fix docs
1 parent a62b551 commit 01bd627

File tree

7 files changed

+323
-115
lines changed

7 files changed

+323
-115
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ This plugin bundles two configurations to work with both `@playwright/test` or
3333

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

36+
[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
37+
(**eslint.config.js**)
38+
39+
```javascript
40+
import playwright from 'eslint-plugin-playwright';
41+
42+
export default [
43+
playwright.configs['flat/recommended'],
44+
{
45+
rules: {
46+
// Customize Playwright rules
47+
// ...
48+
},
49+
},
50+
];
51+
```
52+
53+
[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
54+
(**.eslintrc**)
55+
3656
```json
3757
{
3858
"extends": ["plugin:playwright/recommended"]
@@ -41,6 +61,30 @@ This plugin bundles two configurations to work with both `@playwright/test` or
4161

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

64+
[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
65+
(**eslint.config.js**)
66+
67+
```javascript
68+
import playwright from 'eslint-plugin-playwright';
69+
import jest from 'eslint-plugin-jest';
70+
71+
export default [
72+
playwright.configs['flat/jest-playwright'],
73+
{
74+
plugins: {
75+
jest,
76+
},
77+
rules: {
78+
// Customize Playwright rules
79+
// ...
80+
},
81+
},
82+
];
83+
```
84+
85+
[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
86+
(**.eslintrc**)
87+
4488
```json
4589
{
4690
"extends": ["plugin:playwright/jest-playwright"]
@@ -63,6 +107,24 @@ under the `playwright` key. It supports the following settings:
63107

64108
You can configure these settings like so:
65109

110+
[Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)
111+
(**eslint.config.js**)
112+
113+
```javascript
114+
export default [
115+
{
116+
settings: {
117+
playwright: {
118+
additionalAssertFunctionNames: ['assertCustomCondition'],
119+
},
120+
},
121+
},
122+
];
123+
```
124+
125+
[Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
126+
(**.eslintrc**)
127+
66128
```json
67129
{
68130
"settings": {

examples/.eslintrc

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/eslint.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import playwright from 'eslint-plugin-playwright';
2+
3+
export default [
4+
playwright.configs['flat/recommended'],
5+
{
6+
languageOptions: {
7+
sourceType: 'module',
8+
ecmaVersion: 2022,
9+
},
10+
rules: {
11+
'playwright/prefer-lowercase-title': 'warn',
12+
'playwright/prefer-to-be': 'warn',
13+
'playwright/prefer-to-have-length': 'warn',
14+
'playwright/prefer-strict-equal': 'warn',
15+
'playwright/max-nested-describe': ['warn', { max: 1 }],
16+
'playwright/no-restricted-matchers': [
17+
'error',
18+
{
19+
toBeFalsy: 'Use `toBe(false)` instead.',
20+
not: null,
21+
},
22+
],
23+
},
24+
},
25+
];

examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"dependencies": {
88
"@playwright/test": "^1.38.1",
9-
"eslint": "^8.50.0",
10-
"eslint-plugin-playwright": "workspace:*"
9+
"eslint": "^8.51.0",
10+
"eslint-plugin-playwright": "file:../"
1111
}
1212
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,8 @@
4545
"eslint-plugin-jest": {
4646
"optional": true
4747
}
48+
},
49+
"dependencies": {
50+
"globals": "^13.23.0"
4851
}
4952
}

0 commit comments

Comments
 (0)