const __importMetaUrl = require('url').pathToFileURL(__filename).href; "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { configs: () => configs, rules: () => rules }); module.exports = __toCommonJS(src_exports); // src/constants.ts var MATCHERS = [ "toHaveTitle", "toHaveUrl", "toBeClickable", "toBeDisabled", "toBeDisplayed", "toBeDisplayedInViewport", "toBeEnabled", "toExist", "toBeExisting", "toBePresent", "toBeFocused", "toBeSelected", "toHaveAttribute", "toHaveChildren", "toHaveElementClass", "toHaveElementProperty", "toHaveHref", "toHaveId", "toHaveStyle", "toHaveText", "toHaveValue", "toBeElementsArrayOfSize", "toBeRequested", "toBeRequestedTimes", "toBeRequestedWith", "toBeRequestedWithResponse" ]; // src/rules/await-expect.ts var rule = { meta: { type: "problem", docs: { description: "expect must be prefixed with await", category: "Possible Errors", url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/await-expect.md", recommended: false }, messages: { missingAwait: "Missing await before an expect statement" }, hasSuggestions: true }, create: function(context) { return { CallExpression(node) { if (node.callee.type !== "MemberExpression" || node.callee.object.type !== "CallExpression" || node.callee.object.callee.name !== "expect" || !MATCHERS.includes(node.callee.property.name)) { return; } if ( /** * expect is called without an `await` and as part of an * expression */ node.parent.type === "ExpressionStatement" ) { context.report({ node, messageId: "missingAwait" }); } } }; } }; var await_expect_default = rule; // src/utils/helpers.ts var isCommand = function(expression, command) { const callee = expression?.callee; return callee && "object" in callee && "name" in callee.object && callee.object?.name === "browser" && "property" in callee && "name" in callee.property && callee.property?.name === command; }; // src/rules/no-debug.ts var rule2 = { meta: { type: "problem", docs: { description: "Disallow browser.debug() in tests", category: "Possible Errors", url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-debug.md", recommended: false }, messages: { unexpectedDebug: "Unexpected browser.debug() not allowed" }, hasSuggestions: true, schema: [] }, create: function(context) { return { CallExpression(node) { if (isCommand(node, "debug")) { context.report({ node, messageId: "unexpectedDebug" }); } } }; } }; var no_debug_default = rule2; // src/rules/no-pause.ts var rule3 = { meta: { type: "problem", docs: { description: "Disallow browser.pause() in tests", category: "Possible Errors", url: "https://github.com/webdriverio/webdriverio/blob/main/packages/eslint-plugin-wdio/docs/rules/no-pause.md", recommended: false }, messages: { unexpectedPause: "Unexpected browser.pause() not allowed" }, hasSuggestions: true, schema: [] }, create: function(context) { return { CallExpression(node) { if (isCommand(node, "pause")) { context.report({ node, messageId: "unexpectedPause" }); } } }; } }; var no_pause_default = rule3; // src/index.ts var sharedGlobals = { $: false, $$: false, browser: false, driver: false, expect: false, multiremotebrowser: false }; var sharedConfig = { rules: { "wdio/await-expect": "error", "wdio/no-debug": "error", "wdio/no-pause": "error" } }; var index = { configs: {}, rules: { "await-expect": await_expect_default, "no-debug": no_debug_default, "no-pause": no_pause_default } }; var legacyConfig = { ...sharedConfig, globals: sharedGlobals, plugins: ["wdio"] }; var flatConfig = { ...sharedConfig, languageOptions: { globals: sharedGlobals }, plugins: { wdio: index } }; var configs = { "flat/recommended": flatConfig, recommended: legacyConfig }; var rules = index.rules; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { configs, rules });