eslint-plugin-playwright 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -18
- package/lib/index.js +106 -63
- package/lib/rules/no-element-handle.js +4 -1
- package/lib/rules/prefer-to-have-count.js +60 -0
- package/package.json +17 -15
package/README.md
CHANGED
|
@@ -33,6 +33,26 @@ This plugin bundles two configurations to work with both `@playwright/test` or
|
|
|
33
33
|
|
|
34
34
|
### With [Playwright test runner](https://playwright.dev/docs/writing-tests)
|
|
35
35
|
|
|
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
|
+
|
|
36
56
|
```json
|
|
37
57
|
{
|
|
38
58
|
"extends": ["plugin:playwright/recommended"]
|
|
@@ -41,6 +61,30 @@ This plugin bundles two configurations to work with both `@playwright/test` or
|
|
|
41
61
|
|
|
42
62
|
### With [Jest Playwright](https://github.com/playwright-community/jest-playwright)
|
|
43
63
|
|
|
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
|
+
|
|
44
88
|
```json
|
|
45
89
|
{
|
|
46
90
|
"extends": ["plugin:playwright/jest-playwright"]
|
|
@@ -63,6 +107,24 @@ under the `playwright` key. It supports the following settings:
|
|
|
63
107
|
|
|
64
108
|
You can configure these settings like so:
|
|
65
109
|
|
|
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
|
+
|
|
66
128
|
```json
|
|
67
129
|
{
|
|
68
130
|
"settings": {
|
|
@@ -81,31 +143,33 @@ command line option.\
|
|
|
81
143
|
💡: Some problems reported by this rule are manually fixable by editor
|
|
82
144
|
[suggestions](https://eslint.org/docs/latest/developer-guide/working-with-rules#providing-suggestions).
|
|
83
145
|
|
|
84
|
-
|
|
|
146
|
+
| ✔ | 🔧 | 💡 | Rule | Description |
|
|
85
147
|
| :-: | :-: | :-: | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
148
|
+
| ✔ | | | [expect-expect](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/expect-expect.md) | Enforce assertion to be made in a test body |
|
|
149
|
+
| ✔ | | | [max-nested-describe](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls |
|
|
150
|
+
| ✔ | 🔧 | | [missing-playwright-await](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/missing-playwright-await.md) | Enforce Playwright APIs to be awaited |
|
|
151
|
+
| ✔ | | | [no-conditional-in-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests |
|
|
152
|
+
| ✔ | | 💡 | [no-element-handle](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-element-handle.md) | Disallow usage of element handles |
|
|
153
|
+
| ✔ | | | [no-eval](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-eval.md) | Disallow usage of `page.$eval` and `page.$$eval` |
|
|
154
|
+
| ✔ | | 💡 | [no-focused-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-focused-test.md) | Disallow usage of `.only` annotation |
|
|
155
|
+
| ✔ | | | [no-force-option](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-force-option.md) | Disallow usage of the `{ force: true }` option |
|
|
156
|
+
| ✔ | | | [no-nested-step](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-nested-step.md) | Disallow nested `test.step()` methods |
|
|
157
|
+
| ✔ | | | [no-networkidle](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-networkidle.md) | Disallow usage of the `networkidle` option |
|
|
96
158
|
| | | | [no-nth-methods](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-nth-methods.md) | Disallow usage of `first()`, `last()`, and `nth()` methods |
|
|
97
|
-
|
|
|
98
|
-
|
|
|
159
|
+
| ✔ | | | [no-page-pause](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-page-pause.md) | Disallow using `page.pause` |
|
|
160
|
+
| | | | [no-raw-locators](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-raw-locators.md) | Disallow using raw locators |
|
|
161
|
+
| ✔ | 🔧 | | [no-useless-await](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-await.md) | Disallow unnecessary `await`s for Playwright methods |
|
|
99
162
|
| | | | [no-restricted-matchers](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers |
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
163
|
+
| ✔ | | 💡 | [no-skipped-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-skipped-test.md) | Disallow usage of the `.skip` annotation |
|
|
164
|
+
| ✔ | 🔧 | | [no-useless-not](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-not.md) | Disallow usage of `not` matchers when a specific matcher exists |
|
|
165
|
+
| ✔ | | 💡 | [no-wait-for-timeout](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-wait-for-timeout.md) | Disallow usage of `page.waitForTimeout` |
|
|
103
166
|
| | | 💡 | [prefer-strict-equal](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` |
|
|
104
167
|
| | 🔧 | | [prefer-lowercase-title](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-lowercase-title.md) | Enforce lowercase test names |
|
|
105
168
|
| | 🔧 | | [prefer-to-be](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-be.md) | Suggest using `toBe()` |
|
|
106
169
|
| | 🔧 | | [prefer-to-contain](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-contain.md) | Suggest using `toContain()` |
|
|
170
|
+
| | 🔧 | | [prefer-to-have-count](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-have-count.md) | Suggest using `toHaveCount()` |
|
|
107
171
|
| | 🔧 | | [prefer-to-have-length](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` |
|
|
108
|
-
|
|
|
172
|
+
| ✔ | 🔧 | | [prefer-web-first-assertions](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-web-first-assertions.md) | Suggest using web first assertions |
|
|
109
173
|
| | | | [require-top-level-describe](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `test.describe` block |
|
|
110
174
|
| | 🔧 | | [require-soft-assertions](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/require-soft-assertions.md) | Require assertions to use `expect.soft()` |
|
|
111
|
-
|
|
|
175
|
+
| ✔ | | | [valid-expect](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/valid-expect.md) | Enforce valid `expect()` usage |
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const globals = require("globals");
|
|
2
3
|
const expect_expect_1 = require("./rules/expect-expect");
|
|
3
4
|
const max_nested_describe_1 = require("./rules/max-nested-describe");
|
|
4
5
|
const missing_playwright_await_1 = require("./rules/missing-playwright-await");
|
|
@@ -21,74 +22,14 @@ const prefer_lowercase_title_1 = require("./rules/prefer-lowercase-title");
|
|
|
21
22
|
const prefer_strict_equal_1 = require("./rules/prefer-strict-equal");
|
|
22
23
|
const prefer_to_be_1 = require("./rules/prefer-to-be");
|
|
23
24
|
const prefer_to_contain_1 = require("./rules/prefer-to-contain");
|
|
25
|
+
const prefer_to_have_count_1 = require("./rules/prefer-to-have-count");
|
|
24
26
|
const prefer_to_have_length_1 = require("./rules/prefer-to-have-length");
|
|
25
27
|
const prefer_web_first_assertions_1 = require("./rules/prefer-web-first-assertions");
|
|
26
28
|
const require_soft_assertions_1 = require("./rules/require-soft-assertions");
|
|
27
29
|
const require_top_level_describe_1 = require("./rules/require-top-level-describe");
|
|
28
30
|
const valid_expect_1 = require("./rules/valid-expect");
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
'shared-node-browser': true,
|
|
32
|
-
},
|
|
33
|
-
plugins: ['playwright'],
|
|
34
|
-
rules: {
|
|
35
|
-
'no-empty-pattern': 'off',
|
|
36
|
-
'playwright/expect-expect': 'warn',
|
|
37
|
-
'playwright/max-nested-describe': 'warn',
|
|
38
|
-
'playwright/missing-playwright-await': 'error',
|
|
39
|
-
'playwright/no-conditional-in-test': 'warn',
|
|
40
|
-
'playwright/no-element-handle': 'warn',
|
|
41
|
-
'playwright/no-eval': 'warn',
|
|
42
|
-
'playwright/no-focused-test': 'error',
|
|
43
|
-
'playwright/no-force-option': 'warn',
|
|
44
|
-
'playwright/no-nested-step': 'warn',
|
|
45
|
-
'playwright/no-networkidle': 'error',
|
|
46
|
-
'playwright/no-page-pause': 'warn',
|
|
47
|
-
'playwright/no-skipped-test': 'warn',
|
|
48
|
-
'playwright/no-useless-await': 'warn',
|
|
49
|
-
'playwright/no-useless-not': 'warn',
|
|
50
|
-
'playwright/no-wait-for-timeout': 'warn',
|
|
51
|
-
'playwright/prefer-web-first-assertions': 'error',
|
|
52
|
-
'playwright/valid-expect': 'error',
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
module.exports = {
|
|
56
|
-
configs: {
|
|
57
|
-
'jest-playwright': {
|
|
58
|
-
env: {
|
|
59
|
-
jest: true,
|
|
60
|
-
'shared-node-browser': true,
|
|
61
|
-
},
|
|
62
|
-
globals: {
|
|
63
|
-
browser: true,
|
|
64
|
-
browserName: true,
|
|
65
|
-
context: true,
|
|
66
|
-
deviceName: true,
|
|
67
|
-
jestPlaywright: true,
|
|
68
|
-
page: true,
|
|
69
|
-
},
|
|
70
|
-
plugins: ['jest', 'playwright'],
|
|
71
|
-
rules: {
|
|
72
|
-
'jest/no-standalone-expect': [
|
|
73
|
-
'error',
|
|
74
|
-
{
|
|
75
|
-
additionalTestBlockFunctions: [
|
|
76
|
-
'test.jestPlaywrightDebug',
|
|
77
|
-
'it.jestPlaywrightDebug',
|
|
78
|
-
'test.jestPlaywrightSkip',
|
|
79
|
-
'it.jestPlaywrightSkip',
|
|
80
|
-
'test.jestPlaywrightConfig',
|
|
81
|
-
'it.jestPlaywrightConfig',
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
'playwright/missing-playwright-await': 'error',
|
|
86
|
-
'playwright/no-page-pause': 'warn',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
'playwright-test': recommended,
|
|
90
|
-
recommended,
|
|
91
|
-
},
|
|
31
|
+
const index = {
|
|
32
|
+
configs: {},
|
|
92
33
|
rules: {
|
|
93
34
|
'expect-expect': expect_expect_1.default,
|
|
94
35
|
'max-nested-describe': max_nested_describe_1.default,
|
|
@@ -112,6 +53,7 @@ module.exports = {
|
|
|
112
53
|
'prefer-strict-equal': prefer_strict_equal_1.default,
|
|
113
54
|
'prefer-to-be': prefer_to_be_1.default,
|
|
114
55
|
'prefer-to-contain': prefer_to_contain_1.default,
|
|
56
|
+
'prefer-to-have-count': prefer_to_have_count_1.default,
|
|
115
57
|
'prefer-to-have-length': prefer_to_have_length_1.default,
|
|
116
58
|
'prefer-web-first-assertions': prefer_web_first_assertions_1.default,
|
|
117
59
|
'require-soft-assertions': require_soft_assertions_1.default,
|
|
@@ -119,3 +61,104 @@ module.exports = {
|
|
|
119
61
|
'valid-expect': valid_expect_1.default,
|
|
120
62
|
},
|
|
121
63
|
};
|
|
64
|
+
const sharedConfig = {
|
|
65
|
+
rules: {
|
|
66
|
+
'no-empty-pattern': 'off',
|
|
67
|
+
'playwright/expect-expect': 'warn',
|
|
68
|
+
'playwright/max-nested-describe': 'warn',
|
|
69
|
+
'playwright/missing-playwright-await': 'error',
|
|
70
|
+
'playwright/no-conditional-in-test': 'warn',
|
|
71
|
+
'playwright/no-element-handle': 'warn',
|
|
72
|
+
'playwright/no-eval': 'warn',
|
|
73
|
+
'playwright/no-focused-test': 'error',
|
|
74
|
+
'playwright/no-force-option': 'warn',
|
|
75
|
+
'playwright/no-nested-step': 'warn',
|
|
76
|
+
'playwright/no-networkidle': 'error',
|
|
77
|
+
'playwright/no-page-pause': 'warn',
|
|
78
|
+
'playwright/no-skipped-test': 'warn',
|
|
79
|
+
'playwright/no-useless-await': 'warn',
|
|
80
|
+
'playwright/no-useless-not': 'warn',
|
|
81
|
+
'playwright/no-wait-for-timeout': 'warn',
|
|
82
|
+
'playwright/prefer-web-first-assertions': 'error',
|
|
83
|
+
'playwright/valid-expect': 'error',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
const legacyConfig = {
|
|
87
|
+
...sharedConfig,
|
|
88
|
+
env: {
|
|
89
|
+
'shared-node-browser': true,
|
|
90
|
+
},
|
|
91
|
+
plugins: ['playwright'],
|
|
92
|
+
};
|
|
93
|
+
const flatConfig = {
|
|
94
|
+
...sharedConfig,
|
|
95
|
+
languageOptions: {
|
|
96
|
+
globals: globals['shared-node-browser'],
|
|
97
|
+
},
|
|
98
|
+
plugins: {
|
|
99
|
+
playwright: index,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const sharedJestConfig = {
|
|
103
|
+
rules: {
|
|
104
|
+
'jest/no-standalone-expect': [
|
|
105
|
+
'error',
|
|
106
|
+
{
|
|
107
|
+
additionalTestBlockFunctions: [
|
|
108
|
+
'test.jestPlaywrightDebug',
|
|
109
|
+
'it.jestPlaywrightDebug',
|
|
110
|
+
'test.jestPlaywrightSkip',
|
|
111
|
+
'it.jestPlaywrightSkip',
|
|
112
|
+
'test.jestPlaywrightConfig',
|
|
113
|
+
'it.jestPlaywrightConfig',
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
'playwright/missing-playwright-await': 'error',
|
|
118
|
+
'playwright/no-page-pause': 'warn',
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
const legacyJestConfig = {
|
|
122
|
+
...sharedJestConfig,
|
|
123
|
+
env: {
|
|
124
|
+
jest: true,
|
|
125
|
+
'shared-node-browser': true,
|
|
126
|
+
},
|
|
127
|
+
globals: {
|
|
128
|
+
browser: true,
|
|
129
|
+
browserName: true,
|
|
130
|
+
context: true,
|
|
131
|
+
deviceName: true,
|
|
132
|
+
jestPlaywright: true,
|
|
133
|
+
page: true,
|
|
134
|
+
},
|
|
135
|
+
plugins: ['jest', 'playwright'],
|
|
136
|
+
};
|
|
137
|
+
const jestConfig = {
|
|
138
|
+
...sharedJestConfig,
|
|
139
|
+
languageOptions: {
|
|
140
|
+
globals: {
|
|
141
|
+
...globals['shared-node-browser'],
|
|
142
|
+
...globals.jest,
|
|
143
|
+
browser: 'writable',
|
|
144
|
+
browserName: 'writable',
|
|
145
|
+
context: 'writable',
|
|
146
|
+
deviceName: 'writable',
|
|
147
|
+
jestPlaywright: 'writable',
|
|
148
|
+
page: 'writable',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
plugins: {
|
|
152
|
+
playwright: index,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
module.exports = {
|
|
156
|
+
...index,
|
|
157
|
+
configs: {
|
|
158
|
+
'flat/jest-playwright': jestConfig,
|
|
159
|
+
'flat/recommended': flatConfig,
|
|
160
|
+
'jest-playwright': legacyJestConfig,
|
|
161
|
+
'playwright-test': legacyConfig,
|
|
162
|
+
recommended: legacyConfig,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
@@ -25,7 +25,10 @@ exports.default = {
|
|
|
25
25
|
// Remove the await expression if it exists as locators do
|
|
26
26
|
// not need to be awaited.
|
|
27
27
|
if (node.parent.type === 'AwaitExpression') {
|
|
28
|
-
fixes.push(fixer.removeRange([
|
|
28
|
+
fixes.push(fixer.removeRange([
|
|
29
|
+
node.parent.range[0],
|
|
30
|
+
node.range[0],
|
|
31
|
+
]));
|
|
29
32
|
}
|
|
30
33
|
return fixes;
|
|
31
34
|
},
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fixer_1 = require("../utils/fixer");
|
|
4
|
+
const parseExpectCall_1 = require("../utils/parseExpectCall");
|
|
5
|
+
const matchers = new Set(['toBe', 'toEqual', 'toStrictEqual']);
|
|
6
|
+
exports.default = {
|
|
7
|
+
create(context) {
|
|
8
|
+
return {
|
|
9
|
+
CallExpression(node) {
|
|
10
|
+
const expectCall = (0, parseExpectCall_1.parseExpectCall)(node);
|
|
11
|
+
if (!expectCall || !matchers.has(expectCall.matcherName)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const [argument] = node.arguments;
|
|
15
|
+
if (argument.type !== 'AwaitExpression' ||
|
|
16
|
+
argument.argument.type !== 'CallExpression' ||
|
|
17
|
+
argument.argument.callee.type !== 'MemberExpression') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const callee = argument.argument.callee;
|
|
21
|
+
context.report({
|
|
22
|
+
fix(fixer) {
|
|
23
|
+
return [
|
|
24
|
+
// remove the "await" expression
|
|
25
|
+
fixer.removeRange([
|
|
26
|
+
argument.range[0],
|
|
27
|
+
argument.range[0] + 'await'.length + 1,
|
|
28
|
+
]),
|
|
29
|
+
// remove the "count()" method accessor
|
|
30
|
+
fixer.removeRange([
|
|
31
|
+
callee.property.range[0] - 1,
|
|
32
|
+
argument.argument.range[1],
|
|
33
|
+
]),
|
|
34
|
+
// replace the current matcher with "toHaveCount"
|
|
35
|
+
(0, fixer_1.replaceAccessorFixer)(fixer, expectCall.matcher, 'toHaveCount'),
|
|
36
|
+
// insert "await" to before "expect()"
|
|
37
|
+
fixer.insertTextBefore(node, 'await '),
|
|
38
|
+
];
|
|
39
|
+
},
|
|
40
|
+
messageId: 'useToHaveCount',
|
|
41
|
+
node: expectCall.matcher,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
meta: {
|
|
47
|
+
docs: {
|
|
48
|
+
category: 'Best Practices',
|
|
49
|
+
description: 'Suggest using `toHaveCount()`',
|
|
50
|
+
recommended: false,
|
|
51
|
+
url: 'https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-to-have-count.md',
|
|
52
|
+
},
|
|
53
|
+
fixable: 'code',
|
|
54
|
+
messages: {
|
|
55
|
+
useToHaveCount: 'Use toHaveCount() instead',
|
|
56
|
+
},
|
|
57
|
+
schema: [],
|
|
58
|
+
type: 'suggestion',
|
|
59
|
+
},
|
|
60
|
+
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-playwright",
|
|
3
3
|
"description": "ESLint plugin for Playwright testing.",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@8.
|
|
4
|
+
"version": "0.17.0",
|
|
5
|
+
"packageManager": "pnpm@8.8.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"repository": "https://github.com/playwright-community/eslint-plugin-playwright",
|
|
8
8
|
"author": "Mark Skelton <mark@mskelton.dev>",
|
|
@@ -23,20 +23,19 @@
|
|
|
23
23
|
"ts": "tsc"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@mskelton/eslint-config": "^8.
|
|
27
|
-
"@types/
|
|
28
|
-
"@types/
|
|
29
|
-
"@
|
|
30
|
-
"@typescript-eslint/
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"eslint": "^8.43.0",
|
|
26
|
+
"@mskelton/eslint-config": "^8.4.0",
|
|
27
|
+
"@types/eslint": "^8.44.3",
|
|
28
|
+
"@types/estree": "^1.0.2",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
|
30
|
+
"@typescript-eslint/parser": "^6.7.3",
|
|
31
|
+
"dedent": "^1.5.1",
|
|
32
|
+
"eslint": "^8.50.0",
|
|
34
33
|
"eslint-plugin-sort": "^2.10.0",
|
|
35
|
-
"jest": "^29.
|
|
36
|
-
"prettier": "^
|
|
37
|
-
"semantic-release": "^
|
|
38
|
-
"ts-jest": "^29.1.
|
|
39
|
-
"typescript": "^5.
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"prettier": "^3.0.3",
|
|
36
|
+
"semantic-release": "^22.0.5",
|
|
37
|
+
"ts-jest": "^29.1.1",
|
|
38
|
+
"typescript": "^5.2.2"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
|
42
41
|
"eslint": ">=7",
|
|
@@ -46,5 +45,8 @@
|
|
|
46
45
|
"eslint-plugin-jest": {
|
|
47
46
|
"optional": true
|
|
48
47
|
}
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"globals": "^13.23.0"
|
|
49
51
|
}
|
|
50
52
|
}
|