eslint-plugin-playwright 1.6.1 → 1.6.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 +19 -19
- package/dist/index.mjs +21 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -329,6 +329,24 @@ function getNodeName(node) {
|
|
|
329
329
|
}
|
|
330
330
|
return null;
|
|
331
331
|
}
|
|
332
|
+
var isVariableDeclarator = (node) => node.type === "VariableDeclarator";
|
|
333
|
+
var isAssignmentExpression = (node) => node.type === "AssignmentExpression";
|
|
334
|
+
function isNodeLastAssignment(node, assignment) {
|
|
335
|
+
if (node.range && assignment.range && node.range[0] < assignment.range[1]) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
return assignment.left.type === "Identifier" && assignment.left.name === node.name;
|
|
339
|
+
}
|
|
340
|
+
function dereference(context, node) {
|
|
341
|
+
if (node?.type !== "Identifier") {
|
|
342
|
+
return node;
|
|
343
|
+
}
|
|
344
|
+
const scope = context.sourceCode.getScope(node);
|
|
345
|
+
const parents = scope.references.map((ref) => ref.identifier).map((ident) => ident.parent);
|
|
346
|
+
const decl = parents.filter(isVariableDeclarator).find((p) => p.id.type === "Identifier" && p.id.name === node.name);
|
|
347
|
+
const expr = parents.filter(isAssignmentExpression).reverse().find((assignment) => isNodeLastAssignment(node, assignment));
|
|
348
|
+
return expr?.right ?? decl?.init;
|
|
349
|
+
}
|
|
332
350
|
|
|
333
351
|
// src/utils/createRule.ts
|
|
334
352
|
function interpolate(str, data) {
|
|
@@ -2534,7 +2552,7 @@ var prefer_to_have_count_default = createRule({
|
|
|
2534
2552
|
if (call?.type !== "expect" || !equalityMatchers.has(call.matcherName)) {
|
|
2535
2553
|
return;
|
|
2536
2554
|
}
|
|
2537
|
-
const
|
|
2555
|
+
const argument = dereference(context, call.args[0]);
|
|
2538
2556
|
if (argument?.type !== "AwaitExpression" || argument.argument.type !== "CallExpression" || argument.argument.callee.type !== "MemberExpression" || !isPropertyAccessor(argument.argument.callee, "count")) {
|
|
2539
2557
|
return;
|
|
2540
2558
|
}
|
|
@@ -2669,24 +2687,6 @@ var supportedMatchers = /* @__PURE__ */ new Set([
|
|
|
2669
2687
|
"toBeTruthy",
|
|
2670
2688
|
"toBeFalsy"
|
|
2671
2689
|
]);
|
|
2672
|
-
var isVariableDeclarator = (node) => node.type === "VariableDeclarator";
|
|
2673
|
-
var isAssignmentExpression = (node) => node.type === "AssignmentExpression";
|
|
2674
|
-
function isNodeLastAssignment(node, assignment) {
|
|
2675
|
-
if (node.range && assignment.range && node.range[0] < assignment.range[1]) {
|
|
2676
|
-
return false;
|
|
2677
|
-
}
|
|
2678
|
-
return assignment.left.type === "Identifier" && assignment.left.name === node.name;
|
|
2679
|
-
}
|
|
2680
|
-
function dereference(context, node) {
|
|
2681
|
-
if (node?.type !== "Identifier") {
|
|
2682
|
-
return node;
|
|
2683
|
-
}
|
|
2684
|
-
const scope = context.sourceCode.getScope(node);
|
|
2685
|
-
const parents = scope.references.map((ref) => ref.identifier).map((ident) => ident.parent);
|
|
2686
|
-
const decl = parents.filter(isVariableDeclarator).find((p) => p.id.type === "Identifier" && p.id.name === node.name);
|
|
2687
|
-
const expr = parents.filter(isAssignmentExpression).reverse().find((assignment) => isNodeLastAssignment(node, assignment));
|
|
2688
|
-
return expr?.right ?? decl?.init;
|
|
2689
|
-
}
|
|
2690
2690
|
var prefer_web_first_assertions_default = createRule({
|
|
2691
2691
|
create(context) {
|
|
2692
2692
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -313,7 +313,23 @@ function getNodeName(node) {
|
|
|
313
313
|
}
|
|
314
314
|
return null;
|
|
315
315
|
}
|
|
316
|
-
|
|
316
|
+
function isNodeLastAssignment(node, assignment) {
|
|
317
|
+
if (node.range && assignment.range && node.range[0] < assignment.range[1]) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
return assignment.left.type === "Identifier" && assignment.left.name === node.name;
|
|
321
|
+
}
|
|
322
|
+
function dereference(context, node) {
|
|
323
|
+
if (node?.type !== "Identifier") {
|
|
324
|
+
return node;
|
|
325
|
+
}
|
|
326
|
+
const scope = context.sourceCode.getScope(node);
|
|
327
|
+
const parents = scope.references.map((ref) => ref.identifier).map((ident) => ident.parent);
|
|
328
|
+
const decl = parents.filter(isVariableDeclarator).find((p) => p.id.type === "Identifier" && p.id.name === node.name);
|
|
329
|
+
const expr = parents.filter(isAssignmentExpression).reverse().find((assignment) => isNodeLastAssignment(node, assignment));
|
|
330
|
+
return expr?.right ?? decl?.init;
|
|
331
|
+
}
|
|
332
|
+
var isTemplateLiteral, equalityMatchers, joinNames, isVariableDeclarator, isAssignmentExpression;
|
|
317
333
|
var init_ast = __esm({
|
|
318
334
|
"src/utils/ast.ts"() {
|
|
319
335
|
"use strict";
|
|
@@ -322,6 +338,8 @@ var init_ast = __esm({
|
|
|
322
338
|
(value === void 0 || node.quasis[0].value.raw === value);
|
|
323
339
|
equalityMatchers = /* @__PURE__ */ new Set(["toBe", "toEqual", "toStrictEqual"]);
|
|
324
340
|
joinNames = (a, b) => a && b ? `${a}.${b}` : null;
|
|
341
|
+
isVariableDeclarator = (node) => node.type === "VariableDeclarator";
|
|
342
|
+
isAssignmentExpression = (node) => node.type === "AssignmentExpression";
|
|
325
343
|
}
|
|
326
344
|
});
|
|
327
345
|
|
|
@@ -2855,7 +2873,7 @@ var init_prefer_to_have_count = __esm({
|
|
|
2855
2873
|
if (call?.type !== "expect" || !equalityMatchers.has(call.matcherName)) {
|
|
2856
2874
|
return;
|
|
2857
2875
|
}
|
|
2858
|
-
const
|
|
2876
|
+
const argument = dereference(context, call.args[0]);
|
|
2859
2877
|
if (argument?.type !== "AwaitExpression" || argument.argument.type !== "CallExpression" || argument.argument.callee.type !== "MemberExpression" || !isPropertyAccessor(argument.argument.callee, "count")) {
|
|
2860
2878
|
return;
|
|
2861
2879
|
}
|
|
@@ -2961,23 +2979,7 @@ var init_prefer_to_have_length = __esm({
|
|
|
2961
2979
|
});
|
|
2962
2980
|
|
|
2963
2981
|
// src/rules/prefer-web-first-assertions.ts
|
|
2964
|
-
|
|
2965
|
-
if (node.range && assignment.range && node.range[0] < assignment.range[1]) {
|
|
2966
|
-
return false;
|
|
2967
|
-
}
|
|
2968
|
-
return assignment.left.type === "Identifier" && assignment.left.name === node.name;
|
|
2969
|
-
}
|
|
2970
|
-
function dereference(context, node) {
|
|
2971
|
-
if (node?.type !== "Identifier") {
|
|
2972
|
-
return node;
|
|
2973
|
-
}
|
|
2974
|
-
const scope = context.sourceCode.getScope(node);
|
|
2975
|
-
const parents = scope.references.map((ref) => ref.identifier).map((ident) => ident.parent);
|
|
2976
|
-
const decl = parents.filter(isVariableDeclarator).find((p) => p.id.type === "Identifier" && p.id.name === node.name);
|
|
2977
|
-
const expr = parents.filter(isAssignmentExpression).reverse().find((assignment) => isNodeLastAssignment(node, assignment));
|
|
2978
|
-
return expr?.right ?? decl?.init;
|
|
2979
|
-
}
|
|
2980
|
-
var methods3, supportedMatchers, isVariableDeclarator, isAssignmentExpression, prefer_web_first_assertions_default;
|
|
2982
|
+
var methods3, supportedMatchers, prefer_web_first_assertions_default;
|
|
2981
2983
|
var init_prefer_web_first_assertions = __esm({
|
|
2982
2984
|
"src/rules/prefer-web-first-assertions.ts"() {
|
|
2983
2985
|
"use strict";
|
|
@@ -3025,8 +3027,6 @@ var init_prefer_web_first_assertions = __esm({
|
|
|
3025
3027
|
"toBeTruthy",
|
|
3026
3028
|
"toBeFalsy"
|
|
3027
3029
|
]);
|
|
3028
|
-
isVariableDeclarator = (node) => node.type === "VariableDeclarator";
|
|
3029
|
-
isAssignmentExpression = (node) => node.type === "AssignmentExpression";
|
|
3030
3030
|
prefer_web_first_assertions_default = createRule({
|
|
3031
3031
|
create(context) {
|
|
3032
3032
|
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.6.
|
|
4
|
+
"version": "1.6.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",
|