eslint-plugin-playwright 0.15.0 → 0.15.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.
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ast_1 = require("../utils/ast");
4
- const methods = new Set([
4
+ const locatorMethods = new Set([
5
5
  'and',
6
- 'childFrames',
7
6
  'first',
8
- 'frame',
9
- 'frameLocator',
10
- 'frames',
11
7
  'getByAltText',
12
8
  'getByLabel',
13
9
  'getByPlaceholder',
@@ -15,15 +11,21 @@ const methods = new Set([
15
11
  'getByTestId',
16
12
  'getByText',
17
13
  'getByTitle',
18
- 'isClosed',
19
- 'isDetached',
20
14
  'last',
21
15
  'locator',
16
+ 'nth',
17
+ 'or',
18
+ ]);
19
+ const pageMethods = new Set([
20
+ 'childFrames',
21
+ 'frame',
22
+ 'frameLocator',
23
+ 'frames',
24
+ 'isClosed',
25
+ 'isDetached',
22
26
  'mainFrame',
23
27
  'name',
24
- 'nth',
25
28
  'on',
26
- 'or',
27
29
  'page',
28
30
  'parentFrame',
29
31
  'setDefaultNavigationTimeout',
@@ -33,6 +35,13 @@ const methods = new Set([
33
35
  'viewportSize',
34
36
  'workers',
35
37
  ]);
38
+ function isSupportedMethod(node) {
39
+ if (node.callee.type !== 'MemberExpression')
40
+ return false;
41
+ const name = (0, ast_1.getStringValue)(node.callee.property);
42
+ return (locatorMethods.has(name) ||
43
+ (pageMethods.has(name) && (0, ast_1.isPageMethod)(node, name)));
44
+ }
36
45
  exports.default = {
37
46
  create(context) {
38
47
  return {
@@ -45,8 +54,7 @@ exports.default = {
45
54
  if (callee.type !== 'MemberExpression')
46
55
  return;
47
56
  // Must be a method we care about
48
- const { property } = callee;
49
- if (!methods.has((0, ast_1.getStringValue)(property)))
57
+ if (!isSupportedMethod(node.argument))
50
58
  return;
51
59
  const start = node.loc.start;
52
60
  const range = node.range;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-playwright",
3
3
  "description": "ESLint plugin for Playwright testing.",
4
- "version": "0.15.0",
4
+ "version": "0.15.1",
5
5
  "packageManager": "pnpm@8.4.0",
6
6
  "main": "lib/index.js",
7
7
  "repository": "https://github.com/playwright-community/eslint-plugin-playwright",