eslint-plugin-wdio 9.4.4 → 9.9.1
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 +13 -6
- package/build/index.cjs +49 -11
- package/build/index.js +46 -8
- package/build/rules/no-debug.d.ts.map +1 -1
- package/build/rules/no-pause.d.ts.map +1 -1
- package/build/utils/helpers.d.ts +1 -1
- package/build/utils/helpers.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/rules/no-debug.ts +22 -3
- package/src/rules/no-pause.ts +22 -3
- package/src/utils/helpers.ts +6 -3
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ If you are using the latest version of Eslint with the [flat configuration](http
|
|
|
42
42
|
|
|
43
43
|
```js
|
|
44
44
|
// eslint.config.mjs
|
|
45
|
-
import {
|
|
45
|
+
import { configs as wdioConfig } from "eslint-plugin-wdio";
|
|
46
46
|
|
|
47
47
|
export default [
|
|
48
48
|
{
|
|
@@ -58,8 +58,15 @@ See [ESLint documentation](https://eslint.org/docs/latest/use/configure/configur
|
|
|
58
58
|
|
|
59
59
|
## List of supported rules
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
|
|
62
|
+
- [`wdio/await-expect`](./docs/async-methods.md)
|
|
63
|
+
|
|
64
|
+
`expect` calls must be prefixed with an `await`
|
|
65
|
+
|
|
66
|
+
- [`wdio/no-debug`](./docs/no-debug.md)
|
|
67
|
+
|
|
68
|
+
Don't allow `browser.debug()` statements
|
|
69
|
+
|
|
70
|
+
- [`wdio/no-pause`](./docs/no-pause.md)
|
|
71
|
+
|
|
72
|
+
Don't allow `browser.pause(<number>)` statements
|
package/build/index.cjs
CHANGED
|
@@ -19,12 +19,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
|
|
21
21
|
// src/index.ts
|
|
22
|
-
var
|
|
23
|
-
__export(
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
24
|
configs: () => configs,
|
|
25
25
|
rules: () => rules
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/constants.ts
|
|
30
30
|
var MATCHERS = [
|
|
@@ -93,9 +93,9 @@ var rule = {
|
|
|
93
93
|
var await_expect_default = rule;
|
|
94
94
|
|
|
95
95
|
// src/utils/helpers.ts
|
|
96
|
-
var isCommand = function(expression, command) {
|
|
96
|
+
var isCommand = function(expression, command, instances = ["browser"]) {
|
|
97
97
|
const callee = expression?.callee;
|
|
98
|
-
return callee && "object" in callee && "name" in callee.object && callee.object?.name
|
|
98
|
+
return callee && "object" in callee && "name" in callee.object && instances.includes(callee.object?.name) && "property" in callee && "name" in callee.property && callee.property?.name === command;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
// src/rules/no-debug.ts
|
|
@@ -112,13 +112,32 @@ var rule2 = {
|
|
|
112
112
|
unexpectedDebug: "Unexpected browser.debug() not allowed"
|
|
113
113
|
},
|
|
114
114
|
hasSuggestions: true,
|
|
115
|
-
schema: [
|
|
115
|
+
schema: [{
|
|
116
|
+
type: "object",
|
|
117
|
+
properties: {
|
|
118
|
+
instances: {
|
|
119
|
+
type: "array",
|
|
120
|
+
items: {
|
|
121
|
+
type: "string"
|
|
122
|
+
},
|
|
123
|
+
description: 'List of browser instances to check (default: ["browser"])',
|
|
124
|
+
default: ["browser"]
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
additionalProperties: false
|
|
128
|
+
}]
|
|
116
129
|
},
|
|
117
130
|
create: function(context) {
|
|
131
|
+
const options = context.options[0] || {};
|
|
132
|
+
const instances = options.instances || ["browser"];
|
|
118
133
|
return {
|
|
119
134
|
CallExpression(node) {
|
|
120
|
-
if (isCommand(node, "debug")) {
|
|
121
|
-
context.report({
|
|
135
|
+
if (isCommand(node, "debug", instances)) {
|
|
136
|
+
context.report({
|
|
137
|
+
node,
|
|
138
|
+
messageId: "unexpectedDebug",
|
|
139
|
+
data: { instance: instances.join(", ") }
|
|
140
|
+
});
|
|
122
141
|
}
|
|
123
142
|
}
|
|
124
143
|
};
|
|
@@ -140,13 +159,32 @@ var rule3 = {
|
|
|
140
159
|
unexpectedPause: "Unexpected browser.pause() not allowed"
|
|
141
160
|
},
|
|
142
161
|
hasSuggestions: true,
|
|
143
|
-
schema: [
|
|
162
|
+
schema: [{
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
instances: {
|
|
166
|
+
type: "array",
|
|
167
|
+
items: {
|
|
168
|
+
type: "string"
|
|
169
|
+
},
|
|
170
|
+
description: 'List of browser instances to check (default: ["browser"])',
|
|
171
|
+
default: ["browser"]
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
additionalProperties: false
|
|
175
|
+
}]
|
|
144
176
|
},
|
|
145
177
|
create: function(context) {
|
|
178
|
+
const options = context.options[0] || {};
|
|
179
|
+
const instances = options.instances || ["browser"];
|
|
146
180
|
return {
|
|
147
181
|
CallExpression(node) {
|
|
148
|
-
if (isCommand(node, "pause")) {
|
|
149
|
-
context.report({
|
|
182
|
+
if (isCommand(node, "pause", instances)) {
|
|
183
|
+
context.report({
|
|
184
|
+
node,
|
|
185
|
+
messageId: "unexpectedPause",
|
|
186
|
+
data: { instance: instances.join(", ") }
|
|
187
|
+
});
|
|
150
188
|
}
|
|
151
189
|
}
|
|
152
190
|
};
|
package/build/index.js
CHANGED
|
@@ -65,9 +65,9 @@ var rule = {
|
|
|
65
65
|
var await_expect_default = rule;
|
|
66
66
|
|
|
67
67
|
// src/utils/helpers.ts
|
|
68
|
-
var isCommand = function(expression, command) {
|
|
68
|
+
var isCommand = function(expression, command, instances = ["browser"]) {
|
|
69
69
|
const callee = expression?.callee;
|
|
70
|
-
return callee && "object" in callee && "name" in callee.object && callee.object?.name
|
|
70
|
+
return callee && "object" in callee && "name" in callee.object && instances.includes(callee.object?.name) && "property" in callee && "name" in callee.property && callee.property?.name === command;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
// src/rules/no-debug.ts
|
|
@@ -84,13 +84,32 @@ var rule2 = {
|
|
|
84
84
|
unexpectedDebug: "Unexpected browser.debug() not allowed"
|
|
85
85
|
},
|
|
86
86
|
hasSuggestions: true,
|
|
87
|
-
schema: [
|
|
87
|
+
schema: [{
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
instances: {
|
|
91
|
+
type: "array",
|
|
92
|
+
items: {
|
|
93
|
+
type: "string"
|
|
94
|
+
},
|
|
95
|
+
description: 'List of browser instances to check (default: ["browser"])',
|
|
96
|
+
default: ["browser"]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
additionalProperties: false
|
|
100
|
+
}]
|
|
88
101
|
},
|
|
89
102
|
create: function(context) {
|
|
103
|
+
const options = context.options[0] || {};
|
|
104
|
+
const instances = options.instances || ["browser"];
|
|
90
105
|
return {
|
|
91
106
|
CallExpression(node) {
|
|
92
|
-
if (isCommand(node, "debug")) {
|
|
93
|
-
context.report({
|
|
107
|
+
if (isCommand(node, "debug", instances)) {
|
|
108
|
+
context.report({
|
|
109
|
+
node,
|
|
110
|
+
messageId: "unexpectedDebug",
|
|
111
|
+
data: { instance: instances.join(", ") }
|
|
112
|
+
});
|
|
94
113
|
}
|
|
95
114
|
}
|
|
96
115
|
};
|
|
@@ -112,13 +131,32 @@ var rule3 = {
|
|
|
112
131
|
unexpectedPause: "Unexpected browser.pause() not allowed"
|
|
113
132
|
},
|
|
114
133
|
hasSuggestions: true,
|
|
115
|
-
schema: [
|
|
134
|
+
schema: [{
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
instances: {
|
|
138
|
+
type: "array",
|
|
139
|
+
items: {
|
|
140
|
+
type: "string"
|
|
141
|
+
},
|
|
142
|
+
description: 'List of browser instances to check (default: ["browser"])',
|
|
143
|
+
default: ["browser"]
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
additionalProperties: false
|
|
147
|
+
}]
|
|
116
148
|
},
|
|
117
149
|
create: function(context) {
|
|
150
|
+
const options = context.options[0] || {};
|
|
151
|
+
const instances = options.instances || ["browser"];
|
|
118
152
|
return {
|
|
119
153
|
CallExpression(node) {
|
|
120
|
-
if (isCommand(node, "pause")) {
|
|
121
|
-
context.report({
|
|
154
|
+
if (isCommand(node, "pause", instances)) {
|
|
155
|
+
context.report({
|
|
156
|
+
node,
|
|
157
|
+
messageId: "unexpectedPause",
|
|
158
|
+
data: { instance: instances.join(", ") }
|
|
159
|
+
});
|
|
122
160
|
}
|
|
123
161
|
}
|
|
124
162
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-debug.d.ts","sourceRoot":"","sources":["../../src/rules/no-debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAGlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"no-debug.d.ts","sourceRoot":"","sources":["../../src/rules/no-debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAGlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA4ChB,CAAA;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-pause.d.ts","sourceRoot":"","sources":["../../src/rules/no-pause.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAGlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"no-pause.d.ts","sourceRoot":"","sources":["../../src/rules/no-pause.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAGlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA4ChB,CAAA;AAED,eAAe,IAAI,CAAA"}
|
package/build/utils/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
type CallExpression = Parameters<NonNullable<Rule.NodeListener['CallExpression']>>[0];
|
|
3
|
-
export declare const isCommand: (expression: CallExpression, command: "pause" | "debug") => boolean;
|
|
3
|
+
export declare const isCommand: (expression: CallExpression, command: "pause" | "debug", instances?: string[]) => boolean;
|
|
4
4
|
export {};
|
|
5
5
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC,KAAK,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAErF,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElC,KAAK,cAAc,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAErF,eAAO,MAAM,SAAS,eACN,cAAc,WACjB,OAAO,GAAG,OAAO,cACf,MAAM,EAAE,KACpB,OAWF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-wdio",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.1",
|
|
4
4
|
"description": "Eslint rules for WebdriverIO",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/eslint-plugin-wdio",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"@types/estree": "^1.0.1",
|
|
40
40
|
"eslint": "^9.0.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "a7f0c07b223c9a4a7774fead36ec82296a99177f"
|
|
43
43
|
}
|
package/src/rules/no-debug.ts
CHANGED
|
@@ -14,14 +14,33 @@ const rule: Rule.RuleModule = {
|
|
|
14
14
|
unexpectedDebug: 'Unexpected browser.debug() not allowed'
|
|
15
15
|
},
|
|
16
16
|
hasSuggestions: true,
|
|
17
|
-
schema: [
|
|
17
|
+
schema: [{
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
instances: {
|
|
21
|
+
type: 'array',
|
|
22
|
+
items: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
},
|
|
25
|
+
description: 'List of browser instances to check (default: ["browser"])',
|
|
26
|
+
default: ['browser'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
}],
|
|
18
31
|
},
|
|
19
32
|
|
|
20
33
|
create: function (context: Rule.RuleContext): Rule.RuleListener {
|
|
34
|
+
const options = context.options[0] || {}
|
|
35
|
+
const instances = options.instances || ['browser']
|
|
21
36
|
return {
|
|
22
37
|
CallExpression(node): void {
|
|
23
|
-
if (isCommand(node, 'debug')) {
|
|
24
|
-
context.report({
|
|
38
|
+
if (isCommand(node, 'debug', instances)) {
|
|
39
|
+
context.report({
|
|
40
|
+
node,
|
|
41
|
+
messageId: 'unexpectedDebug',
|
|
42
|
+
data: { instance: instances.join(', ') }
|
|
43
|
+
})
|
|
25
44
|
}
|
|
26
45
|
}
|
|
27
46
|
}
|
package/src/rules/no-pause.ts
CHANGED
|
@@ -14,14 +14,33 @@ const rule: Rule.RuleModule = {
|
|
|
14
14
|
unexpectedPause: 'Unexpected browser.pause() not allowed'
|
|
15
15
|
},
|
|
16
16
|
hasSuggestions: true,
|
|
17
|
-
schema: [
|
|
17
|
+
schema: [{
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
instances: {
|
|
21
|
+
type: 'array',
|
|
22
|
+
items: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
},
|
|
25
|
+
description: 'List of browser instances to check (default: ["browser"])',
|
|
26
|
+
default: ['browser'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
}],
|
|
18
31
|
},
|
|
19
32
|
|
|
20
33
|
create: function (context: Rule.RuleContext): Rule.RuleListener {
|
|
34
|
+
const options = context.options[0] || {}
|
|
35
|
+
const instances = options.instances || ['browser']
|
|
21
36
|
return {
|
|
22
37
|
CallExpression(node): void {
|
|
23
|
-
if (isCommand(node, 'pause')) {
|
|
24
|
-
context.report({
|
|
38
|
+
if (isCommand(node, 'pause', instances)) {
|
|
39
|
+
context.report({
|
|
40
|
+
node,
|
|
41
|
+
messageId: 'unexpectedPause',
|
|
42
|
+
data: { instance: instances.join(', ') }
|
|
43
|
+
})
|
|
25
44
|
}
|
|
26
45
|
}
|
|
27
46
|
}
|
package/src/utils/helpers.ts
CHANGED
|
@@ -2,14 +2,17 @@ import type { Rule } from 'eslint'
|
|
|
2
2
|
|
|
3
3
|
type CallExpression = Parameters<NonNullable<Rule.NodeListener['CallExpression']>>[0]
|
|
4
4
|
|
|
5
|
-
export const isCommand = function(
|
|
5
|
+
export const isCommand = function(
|
|
6
|
+
expression: CallExpression,
|
|
7
|
+
command: 'pause' | 'debug',
|
|
8
|
+
instances: string[] = ['browser']
|
|
9
|
+
): boolean {
|
|
6
10
|
const callee = expression?.callee
|
|
7
|
-
|
|
8
11
|
return (
|
|
9
12
|
callee &&
|
|
10
13
|
'object' in callee &&
|
|
11
14
|
'name' in callee.object &&
|
|
12
|
-
callee.object?.name
|
|
15
|
+
instances.includes(callee.object?.name) &&
|
|
13
16
|
'property' in callee &&
|
|
14
17
|
'name' in callee.property &&
|
|
15
18
|
callee.property?.name === command
|