eslint-plugin-playwright 2.10.0 → 2.10.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.
Files changed (2) hide show
  1. package/dist/index.cjs +18 -2
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -392,8 +392,21 @@ function findParent(node, type) {
392
392
  function dig(node, identifier) {
393
393
  return node.type === "MemberExpression" ? dig(node.property, identifier) : node.type === "CallExpression" ? dig(node.callee, identifier) : node.type === "Identifier" ? isIdentifier(node, identifier) : false;
394
394
  }
395
+ var pageFrameFullPattern = /(^(page|frame)|(Page|Frame)$)/;
396
+ var pageFramePrefixPattern = /^(page|frame)/;
395
397
  function isPageMethod(node, name) {
396
- return node.callee.type === "MemberExpression" && dig(node.callee.object, /(^(page|frame)|(Page|Frame)$)/) && isPropertyAccessor(node.callee, name);
398
+ if (node.callee.type !== "MemberExpression") {
399
+ return false;
400
+ }
401
+ if (!isPropertyAccessor(node.callee, name)) {
402
+ return false;
403
+ }
404
+ const obj = node.callee.object;
405
+ if (obj.type === "MemberExpression") {
406
+ const pattern = obj.object.type === "ThisExpression" ? pageFrameFullPattern : pageFramePrefixPattern;
407
+ return isIdentifier(obj.property, pattern);
408
+ }
409
+ return dig(obj, pageFrameFullPattern);
397
410
  }
398
411
  function isFunction(node) {
399
412
  return node?.type === "ArrowFunctionExpression" || node?.type === "FunctionExpression";
@@ -849,6 +862,9 @@ var max_nested_describe_default = createRule({
849
862
 
850
863
  // src/rules/missing-playwright-await.ts
851
864
  var validTypes = /* @__PURE__ */ new Set(["AwaitExpression", "ReturnStatement", "ArrowFunctionExpression"]);
865
+ function isArrayLike(node) {
866
+ return node.type === "ArrayExpression" || node.type === "NewExpression" && isIdentifier(node.callee, "Array") || node.type === "CallExpression" && node.callee.type === "MemberExpression" && isIdentifier(node.callee.object, "Array");
867
+ }
852
868
  var waitForMethods = [
853
869
  "waitForConsoleMessage",
854
870
  "waitForDownload",
@@ -1128,7 +1144,7 @@ var missing_playwright_await_default = createRule({
1128
1144
  }
1129
1145
  if (includePageLocatorMethods && node.callee.type === "MemberExpression") {
1130
1146
  const methodName = getStringValue(node.callee.property);
1131
- const isPlaywrightMethod = locatorMethods.has(methodName) || pageMethods.has(methodName) && isPageMethod(node, methodName);
1147
+ const isPlaywrightMethod = !isArrayLike(node.callee.object) && (locatorMethods.has(methodName) || pageMethods.has(methodName) && isPageMethod(node, methodName));
1132
1148
  if (isPlaywrightMethod) {
1133
1149
  if (!checkValidity(node, /* @__PURE__ */ new Set())) {
1134
1150
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-playwright",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "ESLint plugin for Playwright testing.",
5
5
  "license": "MIT",
6
6
  "author": "Mark Skelton <mark@mskelton.dev>",