eslint-plugin-wdio 8.0.0 → 8.0.7

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,38 @@
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 ADDED
@@ -0,0 +1,33 @@
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;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,46 @@
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;
@@ -0,0 +1,29 @@
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;
@@ -0,0 +1,29 @@
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;
@@ -0,0 +1,10 @@
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;
package/package.json CHANGED
@@ -1,13 +1,24 @@
1
1
  {
2
2
  "name": "eslint-plugin-wdio",
3
- "version": "8.0.0",
3
+ "version": "8.0.7",
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
8
  "type": "module",
9
- "exports": "./build/index.js",
9
+ "main": "./cjs/index.js",
10
+ "module": "./build/index.js",
10
11
  "types": "./build/index.d.ts",
12
+ "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
+ ]
21
+ },
11
22
  "typeScriptVersion": "3.8.3",
12
23
  "engines": {
13
24
  "node": "^16.13 || >=18"
@@ -31,5 +42,5 @@
31
42
  "@types/estree": "^0.0.52",
32
43
  "eslint": "^8.10.0"
33
44
  },
34
- "gitHead": "a9b5954c62b7dff2af701159ff7837eb98a9b258"
45
+ "gitHead": "a874a82a727634d1323fff05c17455ba0907a020"
35
46
  }