eslint-plugin-playwright 2.0.1 → 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 +1 -0
- package/dist/index.cjs +78 -17
- package/package.json +1 -1
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
|
@@ -95,10 +95,12 @@ var VALID_CHAINS = /* @__PURE__ */ new Set([
|
|
|
95
95
|
// Test
|
|
96
96
|
"test",
|
|
97
97
|
"test.fail",
|
|
98
|
+
"test.fail.only",
|
|
98
99
|
"test.fixme",
|
|
99
100
|
"test.only",
|
|
100
101
|
"test.skip",
|
|
101
102
|
"test.step",
|
|
103
|
+
"test.step.skip",
|
|
102
104
|
"test.slow",
|
|
103
105
|
"test.use"
|
|
104
106
|
]);
|
|
@@ -484,7 +486,7 @@ var expect_expect_default = createRule({
|
|
|
484
486
|
},
|
|
485
487
|
"Program:exit"() {
|
|
486
488
|
unchecked.forEach((node) => {
|
|
487
|
-
context.report({ messageId: "noAssertions", node });
|
|
489
|
+
context.report({ messageId: "noAssertions", node: node.callee });
|
|
488
490
|
});
|
|
489
491
|
}
|
|
490
492
|
};
|
|
@@ -663,6 +665,7 @@ var expectPlaywrightMatchers = [
|
|
|
663
665
|
"toPass"
|
|
664
666
|
];
|
|
665
667
|
var playwrightTestMatchers = [
|
|
668
|
+
"toBeAttached",
|
|
666
669
|
"toBeChecked",
|
|
667
670
|
"toBeDisabled",
|
|
668
671
|
"toBeEditable",
|
|
@@ -670,23 +673,23 @@ var playwrightTestMatchers = [
|
|
|
670
673
|
"toBeEnabled",
|
|
671
674
|
"toBeFocused",
|
|
672
675
|
"toBeHidden",
|
|
676
|
+
"toBeInViewport",
|
|
677
|
+
"toBeOK",
|
|
673
678
|
"toBeVisible",
|
|
674
679
|
"toContainText",
|
|
680
|
+
"toHaveAccessibleErrorMessage",
|
|
675
681
|
"toHaveAttribute",
|
|
682
|
+
"toHaveCSS",
|
|
676
683
|
"toHaveClass",
|
|
677
684
|
"toHaveCount",
|
|
678
|
-
"toHaveCSS",
|
|
679
685
|
"toHaveId",
|
|
680
686
|
"toHaveJSProperty",
|
|
681
|
-
"toBeOK",
|
|
682
687
|
"toHaveScreenshot",
|
|
683
688
|
"toHaveText",
|
|
684
689
|
"toHaveTitle",
|
|
685
690
|
"toHaveURL",
|
|
686
691
|
"toHaveValue",
|
|
687
|
-
"toHaveValues"
|
|
688
|
-
"toBeAttached",
|
|
689
|
-
"toBeInViewport"
|
|
692
|
+
"toHaveValues"
|
|
690
693
|
];
|
|
691
694
|
function getReportNode(node) {
|
|
692
695
|
const parent = getParent(node);
|
|
@@ -1253,18 +1256,11 @@ var no_hooks_default = createRule({
|
|
|
1253
1256
|
});
|
|
1254
1257
|
|
|
1255
1258
|
// src/rules/no-nested-step.ts
|
|
1256
|
-
function isStepCall(node) {
|
|
1257
|
-
const inner = node.type === "CallExpression" ? node.callee : node;
|
|
1258
|
-
if (inner.type !== "MemberExpression") {
|
|
1259
|
-
return false;
|
|
1260
|
-
}
|
|
1261
|
-
return isPropertyAccessor(inner, "step");
|
|
1262
|
-
}
|
|
1263
1259
|
var no_nested_step_default = createRule({
|
|
1264
1260
|
create(context) {
|
|
1265
1261
|
const stack = [];
|
|
1266
1262
|
function pushStepCallback(node) {
|
|
1267
|
-
if (node.parent.type !== "CallExpression" || !
|
|
1263
|
+
if (node.parent.type !== "CallExpression" || !isTypeOfFnCall(context, node.parent, ["step"])) {
|
|
1268
1264
|
return;
|
|
1269
1265
|
}
|
|
1270
1266
|
stack.push(0);
|
|
@@ -1277,7 +1273,7 @@ var no_nested_step_default = createRule({
|
|
|
1277
1273
|
}
|
|
1278
1274
|
function popStepCallback(node) {
|
|
1279
1275
|
const { parent } = node;
|
|
1280
|
-
if (parent.type === "CallExpression" &&
|
|
1276
|
+
if (parent.type === "CallExpression" && isTypeOfFnCall(context, parent, ["step"])) {
|
|
1281
1277
|
stack.pop();
|
|
1282
1278
|
}
|
|
1283
1279
|
}
|
|
@@ -1537,7 +1533,7 @@ var no_skipped_test_default = createRule({
|
|
|
1537
1533
|
const options = context.options[0] || {};
|
|
1538
1534
|
const allowConditional = !!options.allowConditional;
|
|
1539
1535
|
const call = parseFnCall(context, node);
|
|
1540
|
-
if (call?.group !== "test" && call?.group !== "describe") {
|
|
1536
|
+
if (call?.group !== "test" && call?.group !== "describe" && call?.group !== "step") {
|
|
1541
1537
|
return;
|
|
1542
1538
|
}
|
|
1543
1539
|
const skipNode = call.members.find((s) => getStringValue(s) === "skip");
|
|
@@ -1593,6 +1589,70 @@ var no_skipped_test_default = createRule({
|
|
|
1593
1589
|
}
|
|
1594
1590
|
});
|
|
1595
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
|
+
|
|
1596
1656
|
// src/rules/no-standalone-expect.ts
|
|
1597
1657
|
var getBlockType = (context, statement) => {
|
|
1598
1658
|
const func = getParent(statement);
|
|
@@ -2164,7 +2224,7 @@ var prefer_comparison_matcher_default = createRule({
|
|
|
2164
2224
|
category: "Best Practices",
|
|
2165
2225
|
description: "Suggest using the built-in comparison matchers",
|
|
2166
2226
|
recommended: false,
|
|
2167
|
-
url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-
|
|
2227
|
+
url: "https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/prefer-comparison-matcher.md"
|
|
2168
2228
|
},
|
|
2169
2229
|
fixable: "code",
|
|
2170
2230
|
messages: {
|
|
@@ -3972,6 +4032,7 @@ var index = {
|
|
|
3972
4032
|
"no-raw-locators": no_raw_locators_default,
|
|
3973
4033
|
"no-restricted-matchers": no_restricted_matchers_default,
|
|
3974
4034
|
"no-skipped-test": no_skipped_test_default,
|
|
4035
|
+
"no-slowed-test": no_slowed_test_default,
|
|
3975
4036
|
"no-standalone-expect": no_standalone_expect_default,
|
|
3976
4037
|
"no-unsafe-references": no_unsafe_references_default,
|
|
3977
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.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",
|