eslint-plugin-playwright 1.5.0 → 1.5.2

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.
package/README.md CHANGED
@@ -37,7 +37,7 @@ This plugin bundles two configurations to work with both `@playwright/test` or
37
37
  (**eslint.config.js**)
38
38
 
39
39
  ```javascript
40
- import playwright from 'eslint-plugin-playwright';
40
+ import playwright from 'eslint-plugin-playwright'
41
41
 
42
42
  export default [
43
43
  playwright.configs['flat/recommended'],
@@ -47,7 +47,7 @@ export default [
47
47
  // ...
48
48
  },
49
49
  },
50
- ];
50
+ ]
51
51
  ```
52
52
 
53
53
  [Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
@@ -65,8 +65,8 @@ export default [
65
65
  (**eslint.config.js**)
66
66
 
67
67
  ```javascript
68
- import playwright from 'eslint-plugin-playwright';
69
- import jest from 'eslint-plugin-jest';
68
+ import playwright from 'eslint-plugin-playwright'
69
+ import jest from 'eslint-plugin-jest'
70
70
 
71
71
  export default [
72
72
  playwright.configs['flat/jest-playwright'],
@@ -79,7 +79,7 @@ export default [
79
79
  // ...
80
80
  },
81
81
  },
82
- ];
82
+ ]
83
83
  ```
84
84
 
85
85
  [Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files)
package/dist/index.js CHANGED
@@ -637,7 +637,8 @@ var missing_playwright_await_default = {
637
637
  docs: {
638
638
  category: "Possible Errors",
639
639
  description: `Identify false positives when async Playwright APIs are not properly awaited.`,
640
- recommended: true
640
+ recommended: true,
641
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/missing-playwright-await.md"
641
642
  },
642
643
  fixable: "code",
643
644
  messages: {
@@ -1220,7 +1221,8 @@ var no_networkidle_default = {
1220
1221
  docs: {
1221
1222
  category: "Possible Errors",
1222
1223
  description: "Prevent usage of the networkidle option",
1223
- recommended: true
1224
+ recommended: true,
1225
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-networkidle.md"
1224
1226
  },
1225
1227
  messages: {
1226
1228
  noNetworkidle: "Unexpected use of networkidle."
@@ -1280,7 +1282,8 @@ var no_page_pause_default = {
1280
1282
  docs: {
1281
1283
  category: "Possible Errors",
1282
1284
  description: "Prevent usage of page.pause()",
1283
- recommended: true
1285
+ recommended: true,
1286
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-page-pause.md"
1284
1287
  },
1285
1288
  messages: {
1286
1289
  noPagePause: "Unexpected use of page.pause()."
@@ -1728,7 +1731,8 @@ var no_useless_await_default = {
1728
1731
  docs: {
1729
1732
  category: "Possible Errors",
1730
1733
  description: "Disallow unnecessary awaits for Playwright methods",
1731
- recommended: true
1734
+ recommended: true,
1735
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-await.md"
1732
1736
  },
1733
1737
  fixable: "code",
1734
1738
  messages: {
@@ -2005,7 +2009,8 @@ var prefer_comparison_matcher_default = {
2005
2009
  docs: {
2006
2010
  category: "Best Practices",
2007
2011
  description: "Suggest using the built-in comparison matchers",
2008
- recommended: false
2012
+ recommended: false,
2013
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-comparision-matcher.md"
2009
2014
  },
2010
2015
  fixable: "code",
2011
2016
  messages: {
@@ -2781,7 +2786,7 @@ var require_hook_default = {
2781
2786
  if (!isTypeOfFnCall(context, node, ["describe"])) {
2782
2787
  return;
2783
2788
  }
2784
- const [, testFn] = node.arguments;
2789
+ const testFn = node.arguments.at(-1);
2785
2790
  if (!isFunction(testFn) || testFn.body.type !== "BlockStatement") {
2786
2791
  return;
2787
2792
  }
@@ -2974,26 +2979,24 @@ var valid_describe_callback_default = {
2974
2979
  if (call.members.some((s) => getStringValue(s) === "configure")) {
2975
2980
  return;
2976
2981
  }
2977
- if (node.arguments.length < 1) {
2982
+ const callback = node.arguments.at(-1);
2983
+ if (!callback) {
2978
2984
  return context.report({
2979
2985
  loc: node.loc,
2980
- messageId: "nameAndCallback"
2986
+ messageId: "missingCallback"
2981
2987
  });
2982
2988
  }
2983
- const [, callback] = node.arguments;
2984
- if (!callback) {
2985
- context.report({
2989
+ if (node.arguments.length === 1 && isStringLiteral(callback)) {
2990
+ return context.report({
2986
2991
  loc: paramsLocation(node.arguments),
2987
- messageId: "nameAndCallback"
2992
+ messageId: "missingCallback"
2988
2993
  });
2989
- return;
2990
2994
  }
2991
2995
  if (!isFunction(callback)) {
2992
- context.report({
2996
+ return context.report({
2993
2997
  loc: paramsLocation(node.arguments),
2994
- messageId: "secondArgumentMustBeFunction"
2998
+ messageId: "invalidCallback"
2995
2999
  });
2996
- return;
2997
3000
  }
2998
3001
  if (callback.async) {
2999
3002
  context.report({
@@ -3001,7 +3004,7 @@ var valid_describe_callback_default = {
3001
3004
  node: callback
3002
3005
  });
3003
3006
  }
3004
- if (call.members.every((s) => getStringValue(s) !== "each") && callback.params.length) {
3007
+ if (callback.params.length) {
3005
3008
  context.report({
3006
3009
  loc: paramsLocation(callback.params),
3007
3010
  messageId: "unexpectedDescribeArgument"
@@ -3034,9 +3037,9 @@ var valid_describe_callback_default = {
3034
3037
  url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/valid-describe-callback.md"
3035
3038
  },
3036
3039
  messages: {
3037
- nameAndCallback: "Describe requires name and callback arguments",
3040
+ invalidCallback: "Callback argument must be a function",
3041
+ missingCallback: "Describe requires a callback",
3038
3042
  noAsyncDescribeCallback: "No async describe callback",
3039
- secondArgumentMustBeFunction: "Second argument must be function",
3040
3043
  unexpectedDescribeArgument: "Unexpected argument(s) in describe callback",
3041
3044
  unexpectedReturnInDescribe: "Unexpected return statement in describe callback"
3042
3045
  },
package/dist/index.mjs CHANGED
@@ -661,7 +661,8 @@ var init_missing_playwright_await = __esm({
661
661
  docs: {
662
662
  category: "Possible Errors",
663
663
  description: `Identify false positives when async Playwright APIs are not properly awaited.`,
664
- recommended: true
664
+ recommended: true,
665
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/missing-playwright-await.md"
665
666
  },
666
667
  fixable: "code",
667
668
  messages: {
@@ -1331,7 +1332,8 @@ var init_no_networkidle = __esm({
1331
1332
  docs: {
1332
1333
  category: "Possible Errors",
1333
1334
  description: "Prevent usage of the networkidle option",
1334
- recommended: true
1335
+ recommended: true,
1336
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-networkidle.md"
1335
1337
  },
1336
1338
  messages: {
1337
1339
  noNetworkidle: "Unexpected use of networkidle."
@@ -1405,7 +1407,8 @@ var init_no_page_pause = __esm({
1405
1407
  docs: {
1406
1408
  category: "Possible Errors",
1407
1409
  description: "Prevent usage of page.pause()",
1408
- recommended: true
1410
+ recommended: true,
1411
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-page-pause.md"
1409
1412
  },
1410
1413
  messages: {
1411
1414
  noPagePause: "Unexpected use of page.pause()."
@@ -1905,7 +1908,8 @@ var init_no_useless_await = __esm({
1905
1908
  docs: {
1906
1909
  category: "Possible Errors",
1907
1910
  description: "Disallow unnecessary awaits for Playwright methods",
1908
- recommended: true
1911
+ recommended: true,
1912
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-await.md"
1909
1913
  },
1910
1914
  fixable: "code",
1911
1915
  messages: {
@@ -2221,7 +2225,8 @@ var init_prefer_comparison_matcher = __esm({
2221
2225
  docs: {
2222
2226
  category: "Best Practices",
2223
2227
  description: "Suggest using the built-in comparison matchers",
2224
- recommended: false
2228
+ recommended: false,
2229
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-comparision-matcher.md"
2225
2230
  },
2226
2231
  fixable: "code",
2227
2232
  messages: {
@@ -3086,7 +3091,7 @@ var init_require_hook = __esm({
3086
3091
  if (!isTypeOfFnCall(context, node, ["describe"])) {
3087
3092
  return;
3088
3093
  }
3089
- const [, testFn] = node.arguments;
3094
+ const testFn = node.arguments.at(-1);
3090
3095
  if (!isFunction(testFn) || testFn.body.type !== "BlockStatement") {
3091
3096
  return;
3092
3097
  }
@@ -3311,26 +3316,24 @@ var init_valid_describe_callback = __esm({
3311
3316
  if (call.members.some((s) => getStringValue(s) === "configure")) {
3312
3317
  return;
3313
3318
  }
3314
- if (node.arguments.length < 1) {
3319
+ const callback = node.arguments.at(-1);
3320
+ if (!callback) {
3315
3321
  return context.report({
3316
3322
  loc: node.loc,
3317
- messageId: "nameAndCallback"
3323
+ messageId: "missingCallback"
3318
3324
  });
3319
3325
  }
3320
- const [, callback] = node.arguments;
3321
- if (!callback) {
3322
- context.report({
3326
+ if (node.arguments.length === 1 && isStringLiteral(callback)) {
3327
+ return context.report({
3323
3328
  loc: paramsLocation(node.arguments),
3324
- messageId: "nameAndCallback"
3329
+ messageId: "missingCallback"
3325
3330
  });
3326
- return;
3327
3331
  }
3328
3332
  if (!isFunction(callback)) {
3329
- context.report({
3333
+ return context.report({
3330
3334
  loc: paramsLocation(node.arguments),
3331
- messageId: "secondArgumentMustBeFunction"
3335
+ messageId: "invalidCallback"
3332
3336
  });
3333
- return;
3334
3337
  }
3335
3338
  if (callback.async) {
3336
3339
  context.report({
@@ -3338,7 +3341,7 @@ var init_valid_describe_callback = __esm({
3338
3341
  node: callback
3339
3342
  });
3340
3343
  }
3341
- if (call.members.every((s) => getStringValue(s) !== "each") && callback.params.length) {
3344
+ if (callback.params.length) {
3342
3345
  context.report({
3343
3346
  loc: paramsLocation(callback.params),
3344
3347
  messageId: "unexpectedDescribeArgument"
@@ -3371,9 +3374,9 @@ var init_valid_describe_callback = __esm({
3371
3374
  url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/valid-describe-callback.md"
3372
3375
  },
3373
3376
  messages: {
3374
- nameAndCallback: "Describe requires name and callback arguments",
3377
+ invalidCallback: "Callback argument must be a function",
3378
+ missingCallback: "Describe requires a callback",
3375
3379
  noAsyncDescribeCallback: "No async describe callback",
3376
- secondArgumentMustBeFunction: "Second argument must be function",
3377
3380
  unexpectedDescribeArgument: "Unexpected argument(s) in describe callback",
3378
3381
  unexpectedReturnInDescribe: "Unexpected return statement in describe callback"
3379
3382
  },
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": "1.5.0",
4
+ "version": "1.5.2",
5
5
  "repository": "https://github.com/playwright-community/eslint-plugin-playwright",
6
6
  "author": "Mark Skelton <mark@mskelton.dev>",
7
7
  "packageManager": "pnpm@8.12.0",
@@ -32,8 +32,8 @@
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts --format cjs,esm --dts --out-dir dist",
34
34
  "lint": "eslint .",
35
- "format": "prettier --write .",
36
- "format:check": "prettier --check .",
35
+ "fmt": "prettier --write .",
36
+ "fmt:check": "prettier --check .",
37
37
  "test": "vitest",
38
38
  "test:watch": "vitest --reporter=dot",
39
39
  "ts": "tsc --noEmit"