eslint-plugin-playwright 2.1.0 → 2.2.0

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
@@ -139,6 +139,7 @@ CLI option\
139
139
  | [no-raw-locators](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-raw-locators.md) | Disallow using raw locators | | | |
140
140
  | [no-restricted-matchers](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | |
141
141
  | [no-skipped-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-skipped-test.md) | Disallow usage of the `.skip` annotation | ✅ | | 💡 |
142
+ | [no-slowed-test](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-slowed-test.md) | Disallow usage of the `.slow` annotation | ✅ | | 💡 |
142
143
  | [no-standalone-expect](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-standalone-expect.md) | Disallow using expect outside of `test` blocks | ✅ | | |
143
144
  | [no-unsafe-references](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-unsafe-references.md) | Prevent unsafe variable references in `page.evaluate()` | ✅ | 🔧 | |
144
145
  | [no-useless-await](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-useless-await.md) | Disallow unnecessary `await`s for Playwright methods | ✅ | 🔧 | |
package/dist/index.cjs CHANGED
@@ -100,6 +100,7 @@ var VALID_CHAINS = /* @__PURE__ */ new Set([
100
100
  "test.only",
101
101
  "test.skip",
102
102
  "test.step",
103
+ "test.step.skip",
103
104
  "test.slow",
104
105
  "test.use"
105
106
  ]);
@@ -485,7 +486,7 @@ var expect_expect_default = createRule({
485
486
  },
486
487
  "Program:exit"() {
487
488
  unchecked.forEach((node) => {
488
- context.report({ messageId: "noAssertions", node });
489
+ context.report({ messageId: "noAssertions", node: node.callee });
489
490
  });
490
491
  }
491
492
  };
@@ -664,6 +665,7 @@ var expectPlaywrightMatchers = [
664
665
  "toPass"
665
666
  ];
666
667
  var playwrightTestMatchers = [
668
+ "toBeAttached",
667
669
  "toBeChecked",
668
670
  "toBeDisabled",
669
671
  "toBeEditable",
@@ -671,23 +673,23 @@ var playwrightTestMatchers = [
671
673
  "toBeEnabled",
672
674
  "toBeFocused",
673
675
  "toBeHidden",
676
+ "toBeInViewport",
677
+ "toBeOK",
674
678
  "toBeVisible",
675
679
  "toContainText",
680
+ "toHaveAccessibleErrorMessage",
676
681
  "toHaveAttribute",
682
+ "toHaveCSS",
677
683
  "toHaveClass",
678
684
  "toHaveCount",
679
- "toHaveCSS",
680
685
  "toHaveId",
681
686
  "toHaveJSProperty",
682
- "toBeOK",
683
687
  "toHaveScreenshot",
684
688
  "toHaveText",
685
689
  "toHaveTitle",
686
690
  "toHaveURL",
687
691
  "toHaveValue",
688
- "toHaveValues",
689
- "toBeAttached",
690
- "toBeInViewport"
692
+ "toHaveValues"
691
693
  ];
692
694
  function getReportNode(node) {
693
695
  const parent = getParent(node);
@@ -1254,18 +1256,11 @@ var no_hooks_default = createRule({
1254
1256
  });
1255
1257
 
1256
1258
  // src/rules/no-nested-step.ts
1257
- function isStepCall(node) {
1258
- const inner = node.type === "CallExpression" ? node.callee : node;
1259
- if (inner.type !== "MemberExpression") {
1260
- return false;
1261
- }
1262
- return isPropertyAccessor(inner, "step");
1263
- }
1264
1259
  var no_nested_step_default = createRule({
1265
1260
  create(context) {
1266
1261
  const stack = [];
1267
1262
  function pushStepCallback(node) {
1268
- if (node.parent.type !== "CallExpression" || !isStepCall(node.parent)) {
1263
+ if (node.parent.type !== "CallExpression" || !isTypeOfFnCall(context, node.parent, ["step"])) {
1269
1264
  return;
1270
1265
  }
1271
1266
  stack.push(0);
@@ -1278,7 +1273,7 @@ var no_nested_step_default = createRule({
1278
1273
  }
1279
1274
  function popStepCallback(node) {
1280
1275
  const { parent } = node;
1281
- if (parent.type === "CallExpression" && isStepCall(parent)) {
1276
+ if (parent.type === "CallExpression" && isTypeOfFnCall(context, parent, ["step"])) {
1282
1277
  stack.pop();
1283
1278
  }
1284
1279
  }
@@ -1538,7 +1533,7 @@ var no_skipped_test_default = createRule({
1538
1533
  const options = context.options[0] || {};
1539
1534
  const allowConditional = !!options.allowConditional;
1540
1535
  const call = parseFnCall(context, node);
1541
- if (call?.group !== "test" && call?.group !== "describe") {
1536
+ if (call?.group !== "test" && call?.group !== "describe" && call?.group !== "step") {
1542
1537
  return;
1543
1538
  }
1544
1539
  const skipNode = call.members.find((s) => getStringValue(s) === "skip");
@@ -1594,6 +1589,70 @@ var no_skipped_test_default = createRule({
1594
1589
  }
1595
1590
  });
1596
1591
 
1592
+ // src/rules/no-slowed-test.ts
1593
+ var no_slowed_test_default = createRule({
1594
+ create(context) {
1595
+ return {
1596
+ CallExpression(node) {
1597
+ const options = context.options[0] || {};
1598
+ const allowConditional = !!options.allowConditional;
1599
+ const call = parseFnCall(context, node);
1600
+ if (call?.group !== "test") {
1601
+ return;
1602
+ }
1603
+ const slowNode = call.members.find((s) => getStringValue(s) === "slow");
1604
+ if (!slowNode)
1605
+ return;
1606
+ const isStandalone = call.type === "config";
1607
+ if (isStandalone && allowConditional) {
1608
+ return;
1609
+ }
1610
+ context.report({
1611
+ messageId: "noSlowedTest",
1612
+ node: isStandalone ? node : slowNode,
1613
+ suggest: [
1614
+ {
1615
+ fix: (fixer) => {
1616
+ return isStandalone ? fixer.remove(node.parent) : fixer.removeRange([
1617
+ slowNode.range[0] - 1,
1618
+ slowNode.range[1] + Number(slowNode.type !== "Identifier")
1619
+ ]);
1620
+ },
1621
+ messageId: "removeSlowedTestAnnotation"
1622
+ }
1623
+ ]
1624
+ });
1625
+ }
1626
+ };
1627
+ },
1628
+ meta: {
1629
+ docs: {
1630
+ category: "Best Practices",
1631
+ description: "Prevent usage of the `.slow()` slow test annotation.",
1632
+ recommended: true,
1633
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/no-slowed-test.md"
1634
+ },
1635
+ hasSuggestions: true,
1636
+ messages: {
1637
+ noSlowedTest: "Unexpected use of the `.slow()` annotation.",
1638
+ removeSlowedTestAnnotation: "Remove the `.slow()` annotation."
1639
+ },
1640
+ schema: [
1641
+ {
1642
+ additionalProperties: false,
1643
+ properties: {
1644
+ allowConditional: {
1645
+ default: false,
1646
+ type: "boolean"
1647
+ }
1648
+ },
1649
+ type: "object"
1650
+ }
1651
+ ],
1652
+ type: "suggestion"
1653
+ }
1654
+ });
1655
+
1597
1656
  // src/rules/no-standalone-expect.ts
1598
1657
  var getBlockType = (context, statement) => {
1599
1658
  const func = getParent(statement);
@@ -2165,7 +2224,7 @@ var prefer_comparison_matcher_default = createRule({
2165
2224
  category: "Best Practices",
2166
2225
  description: "Suggest using the built-in comparison matchers",
2167
2226
  recommended: false,
2168
- url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-comparision-matcher.md"
2227
+ url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-comparison-matcher.md"
2169
2228
  },
2170
2229
  fixable: "code",
2171
2230
  messages: {
@@ -3973,6 +4032,7 @@ var index = {
3973
4032
  "no-raw-locators": no_raw_locators_default,
3974
4033
  "no-restricted-matchers": no_restricted_matchers_default,
3975
4034
  "no-skipped-test": no_skipped_test_default,
4035
+ "no-slowed-test": no_slowed_test_default,
3976
4036
  "no-standalone-expect": no_standalone_expect_default,
3977
4037
  "no-unsafe-references": no_unsafe_references_default,
3978
4038
  "no-useless-await": no_useless_await_default,
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": "2.1.0",
4
+ "version": "2.2.0",
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",