eslint-plugin-playwright 2.10.1 → 2.10.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.cjs +52 -31
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -324,8 +324,14 @@ function parse(context, node) {
|
|
|
324
324
|
return null;
|
|
325
325
|
}
|
|
326
326
|
let type = group;
|
|
327
|
-
if (
|
|
328
|
-
|
|
327
|
+
if (name === "describe") {
|
|
328
|
+
if (!isFunction(node.arguments.at(-1))) {
|
|
329
|
+
type = "config";
|
|
330
|
+
}
|
|
331
|
+
} else if (name === "test") {
|
|
332
|
+
if (node.arguments.length < 2 || !isFunction(node.arguments.at(-1))) {
|
|
333
|
+
type = "config";
|
|
334
|
+
}
|
|
329
335
|
}
|
|
330
336
|
return {
|
|
331
337
|
...parsedFnCall,
|
|
@@ -1058,29 +1064,26 @@ var missing_playwright_await_default = createRule({
|
|
|
1058
1064
|
// Add any custom matchers to the set
|
|
1059
1065
|
...options.customMatchers || []
|
|
1060
1066
|
]);
|
|
1061
|
-
function isVariableConsumed(
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
if (refParent.type === "VariableDeclarator") {
|
|
1076
|
-
if (checkValidity2(ref.identifier, visited)) {
|
|
1077
|
-
return true;
|
|
1078
|
-
}
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
if (checkValidity2(refParent, visited)) {
|
|
1067
|
+
function isVariableConsumed(variable, visited) {
|
|
1068
|
+
for (const ref of variable.references) {
|
|
1069
|
+
if (!ref.isRead()) {
|
|
1070
|
+
continue;
|
|
1071
|
+
}
|
|
1072
|
+
const refParent = ref.identifier.parent;
|
|
1073
|
+
if (!refParent || visited.has(refParent)) {
|
|
1074
|
+
continue;
|
|
1075
|
+
}
|
|
1076
|
+
if (validTypes.has(refParent.type)) {
|
|
1077
|
+
return true;
|
|
1078
|
+
}
|
|
1079
|
+
if (refParent.type === "VariableDeclarator") {
|
|
1080
|
+
if (checkValidity(ref.identifier, visited)) {
|
|
1082
1081
|
return true;
|
|
1083
1082
|
}
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
if (checkValidity(refParent, visited)) {
|
|
1086
|
+
return true;
|
|
1084
1087
|
}
|
|
1085
1088
|
}
|
|
1086
1089
|
return false;
|
|
@@ -1125,7 +1128,19 @@ var missing_playwright_await_default = createRule({
|
|
|
1125
1128
|
return checkValidity(parent, visited);
|
|
1126
1129
|
}
|
|
1127
1130
|
if (parent.type === "VariableDeclarator") {
|
|
1128
|
-
return
|
|
1131
|
+
return context.sourceCode.getDeclaredVariables(parent).some((v) => isVariableConsumed(v, visited));
|
|
1132
|
+
}
|
|
1133
|
+
if (parent.type === "AssignmentExpression" && parent.right === node && parent.left.type === "Identifier") {
|
|
1134
|
+
const parentName = parent.left.name;
|
|
1135
|
+
let scope = context.sourceCode.getScope(node);
|
|
1136
|
+
while (scope) {
|
|
1137
|
+
const variable = scope.variables.find((v) => v.name === parentName);
|
|
1138
|
+
if (variable) {
|
|
1139
|
+
return isVariableConsumed(variable, visited);
|
|
1140
|
+
}
|
|
1141
|
+
scope = scope.upper;
|
|
1142
|
+
}
|
|
1143
|
+
return false;
|
|
1129
1144
|
}
|
|
1130
1145
|
return false;
|
|
1131
1146
|
}
|
|
@@ -4561,8 +4576,8 @@ var valid_test_tags_default = createRule({
|
|
|
4561
4576
|
}
|
|
4562
4577
|
if (node.arguments.length > 0) {
|
|
4563
4578
|
const titleArg = node.arguments[0];
|
|
4564
|
-
if (titleArg
|
|
4565
|
-
const titleTags = extractTagsFromTitle(titleArg
|
|
4579
|
+
if (titleArg) {
|
|
4580
|
+
const titleTags = extractTagsFromTitle(getStringValue(titleArg));
|
|
4566
4581
|
for (const tag of titleTags) {
|
|
4567
4582
|
validateTag(tag, node);
|
|
4568
4583
|
}
|
|
@@ -4583,21 +4598,27 @@ var valid_test_tags_default = createRule({
|
|
|
4583
4598
|
return;
|
|
4584
4599
|
}
|
|
4585
4600
|
const tagValue = tagProperty.value;
|
|
4586
|
-
if (tagValue.type === "Literal") {
|
|
4587
|
-
if (typeof tagValue.value !== "string") {
|
|
4601
|
+
if (tagValue.type === "Literal" || tagValue.type === "TemplateLiteral") {
|
|
4602
|
+
if (tagValue.type === "Literal" && typeof tagValue.value !== "string") {
|
|
4588
4603
|
context.report({
|
|
4589
4604
|
messageId: "invalidTagValue",
|
|
4590
4605
|
node
|
|
4591
4606
|
});
|
|
4592
4607
|
return;
|
|
4593
4608
|
}
|
|
4594
|
-
validateTag(tagValue
|
|
4609
|
+
validateTag(getStringValue(tagValue), node);
|
|
4595
4610
|
} else if (tagValue.type === "ArrayExpression") {
|
|
4596
4611
|
for (const element of tagValue.elements) {
|
|
4597
|
-
if (!element
|
|
4612
|
+
if (!element) {
|
|
4613
|
+
return;
|
|
4614
|
+
}
|
|
4615
|
+
if (element.type !== "Literal" && element.type !== "TemplateLiteral") {
|
|
4616
|
+
return;
|
|
4617
|
+
}
|
|
4618
|
+
if (element.type === "Literal" && typeof element.value !== "string") {
|
|
4598
4619
|
return;
|
|
4599
4620
|
}
|
|
4600
|
-
validateTag(element
|
|
4621
|
+
validateTag(getStringValue(element), node);
|
|
4601
4622
|
}
|
|
4602
4623
|
} else {
|
|
4603
4624
|
context.report({
|