eslint-plugin-playwright 1.4.0 → 1.4.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/dist/index.js +25 -18
- package/dist/index.mjs +25 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -112,7 +112,7 @@ var resolveToPlaywrightFn = (context, accessor) => {
|
|
|
112
112
|
local: resolved
|
|
113
113
|
};
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function determinePlaywrightFnGroup(name) {
|
|
116
116
|
if (name === "step")
|
|
117
117
|
return "step";
|
|
118
118
|
if (name === "expect")
|
|
@@ -165,6 +165,7 @@ var parseExpectCall = (call) => {
|
|
|
165
165
|
return {
|
|
166
166
|
...call,
|
|
167
167
|
args: getExpectArguments(call),
|
|
168
|
+
group: "expect",
|
|
168
169
|
type: "expect",
|
|
169
170
|
...modifiersAndMatcher
|
|
170
171
|
};
|
|
@@ -204,8 +205,8 @@ function parse(context, node) {
|
|
|
204
205
|
}
|
|
205
206
|
if (name === "test" && links.length > 1) {
|
|
206
207
|
const nextLinkName = links[1];
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
208
|
+
const nextLinkGroup = determinePlaywrightFnGroup(nextLinkName);
|
|
209
|
+
if (nextLinkGroup !== "unknown") {
|
|
209
210
|
name = nextLinkName;
|
|
210
211
|
}
|
|
211
212
|
}
|
|
@@ -216,8 +217,8 @@ function parse(context, node) {
|
|
|
216
217
|
members: rest,
|
|
217
218
|
name
|
|
218
219
|
};
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
220
|
+
const group = determinePlaywrightFnGroup(name);
|
|
221
|
+
if (group === "expect") {
|
|
221
222
|
const result = parseExpectCall(parsedFnCall);
|
|
222
223
|
if (typeof result === "string" && findTopMostCallExpression(node) !== node) {
|
|
223
224
|
return null;
|
|
@@ -236,7 +237,15 @@ function parse(context, node) {
|
|
|
236
237
|
if (parent?.type === "CallExpression" || parent?.type === "MemberExpression") {
|
|
237
238
|
return null;
|
|
238
239
|
}
|
|
239
|
-
|
|
240
|
+
let type = group;
|
|
241
|
+
if ((name === "test" || name === "describe") && (node.arguments.length !== 2 || !isFunction(node.arguments[1]))) {
|
|
242
|
+
type = "config";
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
...parsedFnCall,
|
|
246
|
+
group,
|
|
247
|
+
type
|
|
248
|
+
};
|
|
240
249
|
}
|
|
241
250
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
242
251
|
function parseFnCallWithReason(context, node) {
|
|
@@ -790,11 +799,7 @@ var no_conditional_in_test_default = {
|
|
|
790
799
|
const call = findParent(node, "CallExpression");
|
|
791
800
|
if (!call)
|
|
792
801
|
return;
|
|
793
|
-
|
|
794
|
-
if (fnCall?.type === "test" && fnCall.members.some((member) => getStringValue(member) === "skip") && call.arguments[0]?.type === "LogicalExpression") {
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
if (fnCall?.type === "test" || fnCall?.type === "step") {
|
|
802
|
+
if (isTypeOfFnCall(context, call, ["test", "step"])) {
|
|
798
803
|
context.report({ messageId: "conditionalInTest", node });
|
|
799
804
|
}
|
|
800
805
|
}
|
|
@@ -1404,14 +1409,14 @@ var no_skipped_test_default = {
|
|
|
1404
1409
|
const options = context.options[0] || {};
|
|
1405
1410
|
const allowConditional = !!options.allowConditional;
|
|
1406
1411
|
const call = parseFnCall(context, node);
|
|
1407
|
-
if (call?.
|
|
1412
|
+
if (call?.group !== "test" && call?.group !== "describe") {
|
|
1408
1413
|
return;
|
|
1409
1414
|
}
|
|
1410
1415
|
const skipNode = call.members.find((s) => getStringValue(s) === "skip");
|
|
1411
1416
|
if (!skipNode)
|
|
1412
1417
|
return;
|
|
1413
|
-
const isStandalone = call.type === "
|
|
1414
|
-
if (isStandalone && allowConditional
|
|
1418
|
+
const isStandalone = call.type === "config";
|
|
1419
|
+
if (isStandalone && allowConditional) {
|
|
1415
1420
|
return;
|
|
1416
1421
|
}
|
|
1417
1422
|
context.report({
|
|
@@ -2732,7 +2737,7 @@ var require_hook_default = {
|
|
|
2732
2737
|
};
|
|
2733
2738
|
return {
|
|
2734
2739
|
CallExpression(node) {
|
|
2735
|
-
if (!isTypeOfFnCall(context, node, ["describe"])
|
|
2740
|
+
if (!isTypeOfFnCall(context, node, ["describe"])) {
|
|
2736
2741
|
return;
|
|
2737
2742
|
}
|
|
2738
2743
|
const [, testFn] = node.arguments;
|
|
@@ -2923,8 +2928,11 @@ var valid_describe_callback_default = {
|
|
|
2923
2928
|
return {
|
|
2924
2929
|
CallExpression(node) {
|
|
2925
2930
|
const call = parseFnCall(context, node);
|
|
2926
|
-
if (call?.
|
|
2931
|
+
if (call?.group !== "describe")
|
|
2932
|
+
return;
|
|
2933
|
+
if (call.members.some((s) => getStringValue(s) === "configure")) {
|
|
2927
2934
|
return;
|
|
2935
|
+
}
|
|
2928
2936
|
if (node.arguments.length < 1) {
|
|
2929
2937
|
return context.report({
|
|
2930
2938
|
loc: node.loc,
|
|
@@ -3425,9 +3433,8 @@ var valid_title_default = {
|
|
|
3425
3433
|
return;
|
|
3426
3434
|
}
|
|
3427
3435
|
const [argument] = node.arguments;
|
|
3428
|
-
if (!argument)
|
|
3436
|
+
if (!argument)
|
|
3429
3437
|
return;
|
|
3430
|
-
}
|
|
3431
3438
|
if (!isStringNode(argument)) {
|
|
3432
3439
|
if (argument.type === "BinaryExpression" && doesBinaryExpressionContainStringNode(argument)) {
|
|
3433
3440
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function getNodeChain(node) {
|
|
|
21
21
|
}
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function determinePlaywrightFnGroup(name) {
|
|
25
25
|
if (name === "step")
|
|
26
26
|
return "step";
|
|
27
27
|
if (name === "expect")
|
|
@@ -53,8 +53,8 @@ function parse(context, node) {
|
|
|
53
53
|
}
|
|
54
54
|
if (name === "test" && links.length > 1) {
|
|
55
55
|
const nextLinkName = links[1];
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
56
|
+
const nextLinkGroup = determinePlaywrightFnGroup(nextLinkName);
|
|
57
|
+
if (nextLinkGroup !== "unknown") {
|
|
58
58
|
name = nextLinkName;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -65,8 +65,8 @@ function parse(context, node) {
|
|
|
65
65
|
members: rest,
|
|
66
66
|
name
|
|
67
67
|
};
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
68
|
+
const group = determinePlaywrightFnGroup(name);
|
|
69
|
+
if (group === "expect") {
|
|
70
70
|
const result = parseExpectCall(parsedFnCall);
|
|
71
71
|
if (typeof result === "string" && findTopMostCallExpression(node) !== node) {
|
|
72
72
|
return null;
|
|
@@ -85,7 +85,15 @@ function parse(context, node) {
|
|
|
85
85
|
if (parent?.type === "CallExpression" || parent?.type === "MemberExpression") {
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
let type = group;
|
|
89
|
+
if ((name === "test" || name === "describe") && (node.arguments.length !== 2 || !isFunction(node.arguments[1]))) {
|
|
90
|
+
type = "config";
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...parsedFnCall,
|
|
94
|
+
group,
|
|
95
|
+
type
|
|
96
|
+
};
|
|
89
97
|
}
|
|
90
98
|
function parseFnCallWithReason(context, node) {
|
|
91
99
|
if (cache.has(node)) {
|
|
@@ -213,6 +221,7 @@ var init_parseFnCall = __esm({
|
|
|
213
221
|
return {
|
|
214
222
|
...call,
|
|
215
223
|
args: getExpectArguments(call),
|
|
224
|
+
group: "expect",
|
|
216
225
|
type: "expect",
|
|
217
226
|
...modifiersAndMatcher
|
|
218
227
|
};
|
|
@@ -836,11 +845,7 @@ var init_no_conditional_in_test = __esm({
|
|
|
836
845
|
const call = findParent(node, "CallExpression");
|
|
837
846
|
if (!call)
|
|
838
847
|
return;
|
|
839
|
-
|
|
840
|
-
if (fnCall?.type === "test" && fnCall.members.some((member) => getStringValue(member) === "skip") && call.arguments[0]?.type === "LogicalExpression") {
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
if (fnCall?.type === "test" || fnCall?.type === "step") {
|
|
848
|
+
if (isTypeOfFnCall(context, call, ["test", "step"])) {
|
|
844
849
|
context.report({ messageId: "conditionalInTest", node });
|
|
845
850
|
}
|
|
846
851
|
}
|
|
@@ -1552,14 +1557,14 @@ var init_no_skipped_test = __esm({
|
|
|
1552
1557
|
const options = context.options[0] || {};
|
|
1553
1558
|
const allowConditional = !!options.allowConditional;
|
|
1554
1559
|
const call = parseFnCall(context, node);
|
|
1555
|
-
if (call?.
|
|
1560
|
+
if (call?.group !== "test" && call?.group !== "describe") {
|
|
1556
1561
|
return;
|
|
1557
1562
|
}
|
|
1558
1563
|
const skipNode = call.members.find((s) => getStringValue(s) === "skip");
|
|
1559
1564
|
if (!skipNode)
|
|
1560
1565
|
return;
|
|
1561
|
-
const isStandalone = call.type === "
|
|
1562
|
-
if (isStandalone && allowConditional
|
|
1566
|
+
const isStandalone = call.type === "config";
|
|
1567
|
+
if (isStandalone && allowConditional) {
|
|
1563
1568
|
return;
|
|
1564
1569
|
}
|
|
1565
1570
|
context.report({
|
|
@@ -3035,7 +3040,7 @@ var init_require_hook = __esm({
|
|
|
3035
3040
|
};
|
|
3036
3041
|
return {
|
|
3037
3042
|
CallExpression(node) {
|
|
3038
|
-
if (!isTypeOfFnCall(context, node, ["describe"])
|
|
3043
|
+
if (!isTypeOfFnCall(context, node, ["describe"])) {
|
|
3039
3044
|
return;
|
|
3040
3045
|
}
|
|
3041
3046
|
const [, testFn] = node.arguments;
|
|
@@ -3258,8 +3263,11 @@ var init_valid_describe_callback = __esm({
|
|
|
3258
3263
|
return {
|
|
3259
3264
|
CallExpression(node) {
|
|
3260
3265
|
const call = parseFnCall(context, node);
|
|
3261
|
-
if (call?.
|
|
3266
|
+
if (call?.group !== "describe")
|
|
3267
|
+
return;
|
|
3268
|
+
if (call.members.some((s) => getStringValue(s) === "configure")) {
|
|
3262
3269
|
return;
|
|
3270
|
+
}
|
|
3263
3271
|
if (node.arguments.length < 1) {
|
|
3264
3272
|
return context.report({
|
|
3265
3273
|
loc: node.loc,
|
|
@@ -3785,9 +3793,8 @@ var init_valid_title = __esm({
|
|
|
3785
3793
|
return;
|
|
3786
3794
|
}
|
|
3787
3795
|
const [argument] = node.arguments;
|
|
3788
|
-
if (!argument)
|
|
3796
|
+
if (!argument)
|
|
3789
3797
|
return;
|
|
3790
|
-
}
|
|
3791
3798
|
if (!isStringNode(argument)) {
|
|
3792
3799
|
if (argument.type === "BinaryExpression" && doesBinaryExpressionContainStringNode(argument)) {
|
|
3793
3800
|
return;
|
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.4.
|
|
4
|
+
"version": "1.4.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",
|