eslint-plugin-wdio 9.0.0-alpha.78 → 9.0.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.
@@ -0,0 +1,211 @@
1
+ const __importMetaUrl = require('url').pathToFileURL(__filename).href;
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ configs: () => configs,
25
+ rules: () => rules
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/constants.ts
30
+ var MATCHERS = [
31
+ "toHaveTitle",
32
+ "toHaveTitleContaining",
33
+ "toHaveUrl",
34
+ "toHaveUrlContaining",
35
+ "toBeClickable",
36
+ "toBeDisabled",
37
+ "toBeDisplayed",
38
+ "toBeDisplayedInViewport",
39
+ "toBeEnabled",
40
+ "toExist",
41
+ "toBeExisting",
42
+ "toBePresent",
43
+ "toBeFocused",
44
+ "toBeSelected",
45
+ "toHaveAttribute",
46
+ "toHaveAttributeContaining",
47
+ "toHaveChildren",
48
+ "toHaveElementClass",
49
+ "toHaveElementClassContaining",
50
+ "toHaveElementProperty",
51
+ "toHaveHref",
52
+ "toHaveHrefContaining",
53
+ "toHaveId",
54
+ "toHaveStyle",
55
+ "toHaveText",
56
+ "toHaveTextContaining",
57
+ "toHaveValue",
58
+ "toHaveValueContaining",
59
+ "toBeElementsArrayOfSize",
60
+ "toBeRequested",
61
+ "toBeRequestedTimes",
62
+ "toBeRequestedWith",
63
+ "toBeRequestedWithResponse"
64
+ ];
65
+
66
+ // src/rules/await-expect.ts
67
+ var rule = {
68
+ meta: {
69
+ type: "problem",
70
+ docs: {
71
+ description: "expect must be prefixed with await",
72
+ category: "Possible Errors",
73
+ url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/await-expect.md",
74
+ recommended: false
75
+ },
76
+ messages: {
77
+ missingAwait: "Missing await before an expect statement"
78
+ },
79
+ hasSuggestions: true
80
+ },
81
+ create: function(context) {
82
+ return {
83
+ CallExpression(node) {
84
+ if (node.callee.type !== "MemberExpression" || node.callee.object.type !== "CallExpression" || node.callee.object.callee.name !== "expect" || !MATCHERS.includes(node.callee.property.name)) {
85
+ return;
86
+ }
87
+ if (
88
+ /**
89
+ * expect is called without an `await` and as part of an
90
+ * expression
91
+ */
92
+ node.parent.type === "ExpressionStatement"
93
+ ) {
94
+ context.report({ node, messageId: "missingAwait" });
95
+ }
96
+ }
97
+ };
98
+ }
99
+ };
100
+ var await_expect_default = rule;
101
+
102
+ // src/utils/helpers.ts
103
+ var isCommand = function(expression, command) {
104
+ const callee = expression?.callee;
105
+ return callee && callee?.object?.name === "browser" && callee?.property?.name === command;
106
+ };
107
+
108
+ // src/rules/no-debug.ts
109
+ var rule2 = {
110
+ meta: {
111
+ type: "problem",
112
+ docs: {
113
+ description: "Disallow browser.debug() in tests",
114
+ category: "Possible Errors",
115
+ url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-debug.md",
116
+ recommended: false
117
+ },
118
+ messages: {
119
+ unexpectedDebug: "Unexpected browser.debug() not allowed"
120
+ },
121
+ hasSuggestions: true,
122
+ schema: []
123
+ },
124
+ create: function(context) {
125
+ return {
126
+ CallExpression(node) {
127
+ if (isCommand(node, "debug")) {
128
+ context.report({ node, messageId: "unexpectedDebug" });
129
+ }
130
+ }
131
+ };
132
+ }
133
+ };
134
+ var no_debug_default = rule2;
135
+
136
+ // src/rules/no-pause.ts
137
+ var rule3 = {
138
+ meta: {
139
+ type: "problem",
140
+ docs: {
141
+ description: "Disallow browser.pause() in tests",
142
+ category: "Possible Errors",
143
+ url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-pause.md",
144
+ recommended: false
145
+ },
146
+ messages: {
147
+ unexpectedPause: "Unexpected browser.pause() not allowed"
148
+ },
149
+ hasSuggestions: true,
150
+ schema: []
151
+ },
152
+ create: function(context) {
153
+ return {
154
+ CallExpression(node) {
155
+ if (isCommand(node, "pause")) {
156
+ context.report({ node, messageId: "unexpectedPause" });
157
+ }
158
+ }
159
+ };
160
+ }
161
+ };
162
+ var no_pause_default = rule3;
163
+
164
+ // src/index.ts
165
+ var sharedGlobals = {
166
+ $: false,
167
+ $$: false,
168
+ browser: false,
169
+ driver: false,
170
+ expect: false,
171
+ multiremotebrowser: false
172
+ };
173
+ var sharedConfig = {
174
+ rules: {
175
+ "wdio/await-expect": "error",
176
+ "wdio/no-debug": "error",
177
+ "wdio/no-pause": "error"
178
+ }
179
+ };
180
+ var index = {
181
+ configs: {},
182
+ rules: {
183
+ "await-expect": await_expect_default,
184
+ "no-debug": no_debug_default,
185
+ "no-pause": no_pause_default
186
+ }
187
+ };
188
+ var legacyConfig = {
189
+ ...sharedConfig,
190
+ globals: sharedGlobals,
191
+ plugins: ["wdio"]
192
+ };
193
+ var flatConfig = {
194
+ ...sharedConfig,
195
+ languageOptions: {
196
+ globals: sharedGlobals
197
+ },
198
+ plugins: {
199
+ wdio: index
200
+ }
201
+ };
202
+ var configs = {
203
+ "flat/recommended": flatConfig,
204
+ recommended: legacyConfig
205
+ };
206
+ var rules = index.rules;
207
+ // Annotate the CommonJS export names for ESM import in node:
208
+ 0 && (module.exports = {
209
+ configs,
210
+ rules
211
+ });
package/build/index.d.ts CHANGED
@@ -1,24 +1,51 @@
1
- declare const rules: {
2
- 'await-expect': import("eslint").Rule.RuleModule;
3
- 'no-debug': import("eslint").Rule.RuleModule;
4
- 'no-pause': import("eslint").Rule.RuleModule;
5
- };
6
- declare const configs: {
1
+ export declare const configs: {
2
+ 'flat/recommended': {
3
+ languageOptions: {
4
+ globals: {
5
+ readonly $: false;
6
+ readonly $$: false;
7
+ readonly browser: false;
8
+ readonly driver: false;
9
+ readonly expect: false;
10
+ readonly multiremotebrowser: false;
11
+ };
12
+ };
13
+ plugins: {
14
+ wdio: {
15
+ configs: {};
16
+ rules: {
17
+ 'await-expect': import("eslint").Rule.RuleModule;
18
+ 'no-debug': import("eslint").Rule.RuleModule;
19
+ 'no-pause': import("eslint").Rule.RuleModule;
20
+ };
21
+ };
22
+ };
23
+ rules: {
24
+ readonly 'wdio/await-expect': "error";
25
+ readonly 'wdio/no-debug': "error";
26
+ readonly 'wdio/no-pause': "error";
27
+ };
28
+ };
7
29
  recommended: {
8
30
  globals: {
9
- $: boolean;
10
- $$: boolean;
11
- browser: boolean;
12
- driver: boolean;
13
- expect: boolean;
14
- multiremotebrowser: boolean;
31
+ readonly $: false;
32
+ readonly $$: false;
33
+ readonly browser: false;
34
+ readonly driver: false;
35
+ readonly expect: false;
36
+ readonly multiremotebrowser: false;
15
37
  };
38
+ plugins: string[];
16
39
  rules: {
17
- 'wdio/await-expect': string;
18
- 'wdio/no-debug': string;
19
- 'wdio/no-pause': string;
40
+ readonly 'wdio/await-expect': "error";
41
+ readonly 'wdio/no-debug': "error";
42
+ readonly 'wdio/no-pause': "error";
20
43
  };
21
44
  };
22
45
  };
23
- export { rules, configs, };
46
+ export declare const rules: {
47
+ 'await-expect': import("eslint").Rule.RuleModule;
48
+ 'no-debug': import("eslint").Rule.RuleModule;
49
+ 'no-pause': import("eslint").Rule.RuleModule;
50
+ };
24
51
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,KAAK;;;;CAIV,CAAA;AAED,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;CAgBZ,CAAA;AAED,OAAO,EACH,KAAK,EACL,OAAO,GACV,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGnB,CAAA;AACD,eAAO,MAAM,KAAK;;;;CAAc,CAAA"}
package/build/index.js CHANGED
@@ -1,26 +1,182 @@
1
- import awaitExpect from './rules/await-expect.js';
2
- import noDebug from './rules/no-debug.js';
3
- import noPause from './rules/no-pause.js';
4
- const rules = {
5
- 'await-expect': awaitExpect,
6
- 'no-debug': noDebug,
7
- 'no-pause': noPause
8
- };
9
- const configs = {
10
- recommended: {
11
- globals: {
12
- $: false,
13
- $$: false,
14
- browser: false,
15
- driver: false,
16
- expect: false,
17
- multiremotebrowser: false,
18
- },
19
- rules: {
20
- 'wdio/await-expect': 'error',
21
- 'wdio/no-debug': 'error',
22
- 'wdio/no-pause': 'error',
1
+ // src/constants.ts
2
+ var MATCHERS = [
3
+ "toHaveTitle",
4
+ "toHaveTitleContaining",
5
+ "toHaveUrl",
6
+ "toHaveUrlContaining",
7
+ "toBeClickable",
8
+ "toBeDisabled",
9
+ "toBeDisplayed",
10
+ "toBeDisplayedInViewport",
11
+ "toBeEnabled",
12
+ "toExist",
13
+ "toBeExisting",
14
+ "toBePresent",
15
+ "toBeFocused",
16
+ "toBeSelected",
17
+ "toHaveAttribute",
18
+ "toHaveAttributeContaining",
19
+ "toHaveChildren",
20
+ "toHaveElementClass",
21
+ "toHaveElementClassContaining",
22
+ "toHaveElementProperty",
23
+ "toHaveHref",
24
+ "toHaveHrefContaining",
25
+ "toHaveId",
26
+ "toHaveStyle",
27
+ "toHaveText",
28
+ "toHaveTextContaining",
29
+ "toHaveValue",
30
+ "toHaveValueContaining",
31
+ "toBeElementsArrayOfSize",
32
+ "toBeRequested",
33
+ "toBeRequestedTimes",
34
+ "toBeRequestedWith",
35
+ "toBeRequestedWithResponse"
36
+ ];
37
+
38
+ // src/rules/await-expect.ts
39
+ var rule = {
40
+ meta: {
41
+ type: "problem",
42
+ docs: {
43
+ description: "expect must be prefixed with await",
44
+ category: "Possible Errors",
45
+ url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/await-expect.md",
46
+ recommended: false
47
+ },
48
+ messages: {
49
+ missingAwait: "Missing await before an expect statement"
50
+ },
51
+ hasSuggestions: true
52
+ },
53
+ create: function(context) {
54
+ return {
55
+ CallExpression(node) {
56
+ if (node.callee.type !== "MemberExpression" || node.callee.object.type !== "CallExpression" || node.callee.object.callee.name !== "expect" || !MATCHERS.includes(node.callee.property.name)) {
57
+ return;
23
58
  }
24
- }
59
+ if (
60
+ /**
61
+ * expect is called without an `await` and as part of an
62
+ * expression
63
+ */
64
+ node.parent.type === "ExpressionStatement"
65
+ ) {
66
+ context.report({ node, messageId: "missingAwait" });
67
+ }
68
+ }
69
+ };
70
+ }
71
+ };
72
+ var await_expect_default = rule;
73
+
74
+ // src/utils/helpers.ts
75
+ var isCommand = function(expression, command) {
76
+ const callee = expression?.callee;
77
+ return callee && callee?.object?.name === "browser" && callee?.property?.name === command;
78
+ };
79
+
80
+ // src/rules/no-debug.ts
81
+ var rule2 = {
82
+ meta: {
83
+ type: "problem",
84
+ docs: {
85
+ description: "Disallow browser.debug() in tests",
86
+ category: "Possible Errors",
87
+ url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-debug.md",
88
+ recommended: false
89
+ },
90
+ messages: {
91
+ unexpectedDebug: "Unexpected browser.debug() not allowed"
92
+ },
93
+ hasSuggestions: true,
94
+ schema: []
95
+ },
96
+ create: function(context) {
97
+ return {
98
+ CallExpression(node) {
99
+ if (isCommand(node, "debug")) {
100
+ context.report({ node, messageId: "unexpectedDebug" });
101
+ }
102
+ }
103
+ };
104
+ }
105
+ };
106
+ var no_debug_default = rule2;
107
+
108
+ // src/rules/no-pause.ts
109
+ var rule3 = {
110
+ meta: {
111
+ type: "problem",
112
+ docs: {
113
+ description: "Disallow browser.pause() in tests",
114
+ category: "Possible Errors",
115
+ url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-pause.md",
116
+ recommended: false
117
+ },
118
+ messages: {
119
+ unexpectedPause: "Unexpected browser.pause() not allowed"
120
+ },
121
+ hasSuggestions: true,
122
+ schema: []
123
+ },
124
+ create: function(context) {
125
+ return {
126
+ CallExpression(node) {
127
+ if (isCommand(node, "pause")) {
128
+ context.report({ node, messageId: "unexpectedPause" });
129
+ }
130
+ }
131
+ };
132
+ }
133
+ };
134
+ var no_pause_default = rule3;
135
+
136
+ // src/index.ts
137
+ var sharedGlobals = {
138
+ $: false,
139
+ $$: false,
140
+ browser: false,
141
+ driver: false,
142
+ expect: false,
143
+ multiremotebrowser: false
144
+ };
145
+ var sharedConfig = {
146
+ rules: {
147
+ "wdio/await-expect": "error",
148
+ "wdio/no-debug": "error",
149
+ "wdio/no-pause": "error"
150
+ }
151
+ };
152
+ var index = {
153
+ configs: {},
154
+ rules: {
155
+ "await-expect": await_expect_default,
156
+ "no-debug": no_debug_default,
157
+ "no-pause": no_pause_default
158
+ }
159
+ };
160
+ var legacyConfig = {
161
+ ...sharedConfig,
162
+ globals: sharedGlobals,
163
+ plugins: ["wdio"]
164
+ };
165
+ var flatConfig = {
166
+ ...sharedConfig,
167
+ languageOptions: {
168
+ globals: sharedGlobals
169
+ },
170
+ plugins: {
171
+ wdio: index
172
+ }
173
+ };
174
+ var configs = {
175
+ "flat/recommended": flatConfig,
176
+ recommended: legacyConfig
177
+ };
178
+ var rules = index.rules;
179
+ export {
180
+ configs,
181
+ rules
25
182
  };
26
- export { rules, configs, };
@@ -1,2 +1,2 @@
1
- export declare const isCommand: (expression: any, command: 'pause' | 'debug') => boolean;
1
+ export declare const isCommand: (expression: any, command: "pause" | "debug") => boolean;
2
2
  //# sourceMappingURL=helpers.d.ts.map
package/package.json CHANGED
@@ -1,24 +1,21 @@
1
1
  {
2
2
  "name": "eslint-plugin-wdio",
3
- "version": "9.0.0-alpha.78+fee2f8a88",
3
+ "version": "9.0.0",
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",
7
7
  "license": "MIT",
8
- "type": "module",
9
- "main": "./cjs/index.js",
8
+ "main": "./build/index.cjs",
10
9
  "module": "./build/index.js",
11
10
  "types": "./build/index.d.ts",
12
11
  "exports": {
13
- ".": [
14
- {
15
- "types": "./build/index.d.ts",
16
- "import": "./build/index.js",
17
- "require": "./cjs/index.js"
18
- },
19
- "./cjs/index.js"
20
- ]
12
+ ".": {
13
+ "types": "./build/index.d.ts",
14
+ "import": "./build/index.js",
15
+ "require": "./build/index.cjs"
16
+ }
21
17
  },
18
+ "type": "module",
22
19
  "typeScriptVersion": "3.8.3",
23
20
  "engines": {
24
21
  "node": ">=18"
@@ -40,7 +37,7 @@
40
37
  },
41
38
  "devDependencies": {
42
39
  "@types/estree": "^1.0.1",
43
- "eslint": "^8.10.0"
40
+ "eslint": "^9.0.0"
44
41
  },
45
- "gitHead": "fee2f8a88d132537795eaf144abf1a7e242f99ff"
42
+ "gitHead": "957693463371a4cb329395dcdbce8fb0c930ab93"
46
43
  }
package/src/index.ts CHANGED
@@ -2,31 +2,50 @@ import awaitExpect from './rules/await-expect.js'
2
2
  import noDebug from './rules/no-debug.js'
3
3
  import noPause from './rules/no-pause.js'
4
4
 
5
- const rules = {
6
- 'await-expect': awaitExpect,
7
- 'no-debug': noDebug,
8
- 'no-pause': noPause
5
+ const sharedGlobals = {
6
+ $: false,
7
+ $$: false,
8
+ browser: false,
9
+ driver: false,
10
+ expect: false,
11
+ multiremotebrowser: false,
12
+ } as const
13
+
14
+ const sharedConfig = {
15
+ rules: {
16
+ 'wdio/await-expect': 'error',
17
+ 'wdio/no-debug': 'error',
18
+ 'wdio/no-pause': 'error',
19
+ },
20
+ } as const
21
+
22
+ const index = {
23
+ configs: {},
24
+ rules: {
25
+ 'await-expect': awaitExpect,
26
+ 'no-debug': noDebug,
27
+ 'no-pause': noPause,
28
+ },
29
+ }
30
+
31
+ const legacyConfig = {
32
+ ...sharedConfig,
33
+ globals: sharedGlobals,
34
+ plugins: ['wdio'],
9
35
  }
10
36
 
11
- const configs = {
12
- recommended: {
13
- globals: {
14
- $: false,
15
- $$: false,
16
- browser: false,
17
- driver: false,
18
- expect: false,
19
- multiremotebrowser: false,
20
- },
21
- rules: {
22
- 'wdio/await-expect': 'error',
23
- 'wdio/no-debug': 'error',
24
- 'wdio/no-pause': 'error',
25
- }
26
- }
37
+ const flatConfig = {
38
+ ...sharedConfig,
39
+ languageOptions: {
40
+ globals: sharedGlobals,
41
+ },
42
+ plugins: {
43
+ wdio: index,
44
+ },
27
45
  }
28
46
 
29
- export {
30
- rules,
31
- configs,
47
+ export const configs = {
48
+ 'flat/recommended': flatConfig,
49
+ recommended: legacyConfig,
32
50
  }
51
+ export const rules = index.rules
@@ -1,35 +0,0 @@
1
- export const MATCHERS = [
2
- 'toHaveTitle',
3
- 'toHaveTitleContaining',
4
- 'toHaveUrl',
5
- 'toHaveUrlContaining',
6
- 'toBeClickable',
7
- 'toBeDisabled',
8
- 'toBeDisplayed',
9
- 'toBeDisplayedInViewport',
10
- 'toBeEnabled',
11
- 'toExist',
12
- 'toBeExisting',
13
- 'toBePresent',
14
- 'toBeFocused',
15
- 'toBeSelected',
16
- 'toHaveAttribute',
17
- 'toHaveAttributeContaining',
18
- 'toHaveChildren',
19
- 'toHaveElementClass',
20
- 'toHaveElementClassContaining',
21
- 'toHaveElementProperty',
22
- 'toHaveHref',
23
- 'toHaveHrefContaining',
24
- 'toHaveId',
25
- 'toHaveStyle',
26
- 'toHaveText',
27
- 'toHaveTextContaining',
28
- 'toHaveValue',
29
- 'toHaveValueContaining',
30
- 'toBeElementsArrayOfSize',
31
- 'toBeRequested',
32
- 'toBeRequestedTimes',
33
- 'toBeRequestedWith',
34
- 'toBeRequestedWithResponse'
35
- ];
@@ -1,44 +0,0 @@
1
- import { MATCHERS } from '../constants.js';
2
- const rule = {
3
- meta: {
4
- type: 'problem',
5
- docs: {
6
- description: 'expect must be prefixed with await',
7
- category: 'Possible Errors',
8
- url: 'https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/await-expect.md',
9
- recommended: false,
10
- },
11
- messages: {
12
- missingAwait: 'Missing await before an expect statement'
13
- },
14
- hasSuggestions: true
15
- },
16
- create: function (context) {
17
- return {
18
- CallExpression(node) {
19
- /**
20
- * validate we have an expect statement that
21
- * calls some of the WebdriverIO matchers
22
- */
23
- if (node.callee.type !== 'MemberExpression' ||
24
- node.callee.object.type !== 'CallExpression' ||
25
- node.callee.object.callee.name !== 'expect' ||
26
- !MATCHERS.includes(node.callee.property.name)) {
27
- return;
28
- }
29
- /**
30
- * fail rule if:
31
- */
32
- if (
33
- /**
34
- * expect is called without an `await` and as part of an
35
- * expression
36
- */
37
- node.parent.type === 'ExpressionStatement') {
38
- context.report({ node, messageId: 'missingAwait' });
39
- }
40
- }
41
- };
42
- }
43
- };
44
- export default rule;
@@ -1,27 +0,0 @@
1
- import { isCommand } from '../utils/helpers.js';
2
- const rule = {
3
- meta: {
4
- type: 'problem',
5
- docs: {
6
- description: 'Disallow browser.debug() in tests',
7
- category: 'Possible Errors',
8
- url: 'https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-debug.md',
9
- recommended: false,
10
- },
11
- messages: {
12
- unexpectedDebug: 'Unexpected browser.debug() not allowed'
13
- },
14
- hasSuggestions: true,
15
- schema: [],
16
- },
17
- create: function (context) {
18
- return {
19
- CallExpression(node) {
20
- if (isCommand(node, 'debug')) {
21
- context.report({ node, messageId: 'unexpectedDebug' });
22
- }
23
- }
24
- };
25
- }
26
- };
27
- export default rule;
@@ -1,27 +0,0 @@
1
- import { isCommand } from '../utils/helpers.js';
2
- const rule = {
3
- meta: {
4
- type: 'problem',
5
- docs: {
6
- description: 'Disallow browser.pause() in tests',
7
- category: 'Possible Errors',
8
- url: 'https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-pause.md',
9
- recommended: false,
10
- },
11
- messages: {
12
- unexpectedPause: 'Unexpected browser.pause() not allowed'
13
- },
14
- hasSuggestions: true,
15
- schema: [],
16
- },
17
- create: function (context) {
18
- return {
19
- CallExpression(node) {
20
- if (isCommand(node, 'pause')) {
21
- context.report({ node, messageId: 'unexpectedPause' });
22
- }
23
- }
24
- };
25
- }
26
- };
27
- export default rule;
@@ -1,6 +0,0 @@
1
- export const isCommand = function (expression, command) {
2
- const callee = expression?.callee;
3
- return (callee &&
4
- callee?.object?.name === 'browser' &&
5
- callee?.property?.name === command);
6
- };
package/cjs/constants.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MATCHERS = void 0;
4
- exports.MATCHERS = [
5
- 'toHaveTitle',
6
- 'toHaveTitleContaining',
7
- 'toHaveUrl',
8
- 'toHaveUrlContaining',
9
- 'toBeClickable',
10
- 'toBeDisabled',
11
- 'toBeDisplayed',
12
- 'toBeDisplayedInViewport',
13
- 'toBeEnabled',
14
- 'toExist',
15
- 'toBeExisting',
16
- 'toBePresent',
17
- 'toBeFocused',
18
- 'toBeSelected',
19
- 'toHaveAttribute',
20
- 'toHaveAttributeContaining',
21
- 'toHaveChildren',
22
- 'toHaveElementClass',
23
- 'toHaveElementClassContaining',
24
- 'toHaveElementProperty',
25
- 'toHaveHref',
26
- 'toHaveHrefContaining',
27
- 'toHaveId',
28
- 'toHaveStyle',
29
- 'toHaveText',
30
- 'toHaveTextContaining',
31
- 'toHaveValue',
32
- 'toHaveValueContaining',
33
- 'toBeElementsArrayOfSize',
34
- 'toBeRequested',
35
- 'toBeRequestedTimes',
36
- 'toBeRequestedWith',
37
- 'toBeRequestedWithResponse'
38
- ];
package/cjs/index.js DELETED
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.configs = exports.rules = void 0;
7
- const await_expect_js_1 = __importDefault(require("./rules/await-expect.js"));
8
- const no_debug_js_1 = __importDefault(require("./rules/no-debug.js"));
9
- const no_pause_js_1 = __importDefault(require("./rules/no-pause.js"));
10
- const rules = {
11
- 'await-expect': await_expect_js_1.default,
12
- 'no-debug': no_debug_js_1.default,
13
- 'no-pause': no_pause_js_1.default
14
- };
15
- exports.rules = rules;
16
- const configs = {
17
- recommended: {
18
- globals: {
19
- $: false,
20
- $$: false,
21
- browser: false,
22
- driver: false,
23
- expect: false,
24
- multiremotebrowser: false,
25
- },
26
- rules: {
27
- 'wdio/await-expect': 'error',
28
- 'wdio/no-debug': 'error',
29
- 'wdio/no-pause': 'error',
30
- }
31
- }
32
- };
33
- exports.configs = configs;
package/cjs/package.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "name": "eslint-plugin-wdio-cjs",
3
- "type": "commonjs",
4
- "private": true
5
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_js_1 = require("../constants.js");
4
- const rule = {
5
- meta: {
6
- type: 'problem',
7
- docs: {
8
- description: 'expect must be prefixed with await',
9
- category: 'Possible Errors',
10
- url: 'https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/await-expect.md',
11
- recommended: false,
12
- },
13
- messages: {
14
- missingAwait: 'Missing await before an expect statement'
15
- },
16
- hasSuggestions: true
17
- },
18
- create: function (context) {
19
- return {
20
- CallExpression(node) {
21
- /**
22
- * validate we have an expect statement that
23
- * calls some of the WebdriverIO matchers
24
- */
25
- if (node.callee.type !== 'MemberExpression' ||
26
- node.callee.object.type !== 'CallExpression' ||
27
- node.callee.object.callee.name !== 'expect' ||
28
- !constants_js_1.MATCHERS.includes(node.callee.property.name)) {
29
- return;
30
- }
31
- /**
32
- * fail rule if:
33
- */
34
- if (
35
- /**
36
- * expect is called without an `await` and as part of an
37
- * expression
38
- */
39
- node.parent.type === 'ExpressionStatement') {
40
- context.report({ node, messageId: 'missingAwait' });
41
- }
42
- }
43
- };
44
- }
45
- };
46
- exports.default = rule;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const helpers_js_1 = require("../utils/helpers.js");
4
- const rule = {
5
- meta: {
6
- type: 'problem',
7
- docs: {
8
- description: 'Disallow browser.debug() in tests',
9
- category: 'Possible Errors',
10
- url: 'https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-debug.md',
11
- recommended: false,
12
- },
13
- messages: {
14
- unexpectedDebug: 'Unexpected browser.debug() not allowed'
15
- },
16
- hasSuggestions: true,
17
- schema: [],
18
- },
19
- create: function (context) {
20
- return {
21
- CallExpression(node) {
22
- if ((0, helpers_js_1.isCommand)(node, 'debug')) {
23
- context.report({ node, messageId: 'unexpectedDebug' });
24
- }
25
- }
26
- };
27
- }
28
- };
29
- exports.default = rule;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const helpers_js_1 = require("../utils/helpers.js");
4
- const rule = {
5
- meta: {
6
- type: 'problem',
7
- docs: {
8
- description: 'Disallow browser.pause() in tests',
9
- category: 'Possible Errors',
10
- url: 'https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-pause.md',
11
- recommended: false,
12
- },
13
- messages: {
14
- unexpectedPause: 'Unexpected browser.pause() not allowed'
15
- },
16
- hasSuggestions: true,
17
- schema: [],
18
- },
19
- create: function (context) {
20
- return {
21
- CallExpression(node) {
22
- if ((0, helpers_js_1.isCommand)(node, 'pause')) {
23
- context.report({ node, messageId: 'unexpectedPause' });
24
- }
25
- }
26
- };
27
- }
28
- };
29
- exports.default = rule;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isCommand = void 0;
4
- const isCommand = function (expression, command) {
5
- const callee = expression?.callee;
6
- return (callee &&
7
- callee?.object?.name === 'browser' &&
8
- callee?.property?.name === command);
9
- };
10
- exports.isCommand = isCommand;
File without changes