eslint-plugin-playwright 0.17.0 → 0.18.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 -1
- package/lib/rules/expect-expect.js +2 -2
- package/lib/rules/no-skipped-test.js +19 -0
- package/lib/utils/ast.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ under the `playwright` key. It supports the following settings:
|
|
|
101
101
|
the presence of at least one assertion per test case. This allows such rules
|
|
102
102
|
to recognise custom assertion functions as valid assertions. The global
|
|
103
103
|
setting applies to all modules. The
|
|
104
|
-
[`expect-expect` rule accepts an option by the same name](
|
|
104
|
+
[`expect-expect` rule accepts an option by the same name](https://github.com/playwright-community/eslint-plugin-playwright/tree/main/docs/rules/expect-expect.md#additionalassertfunctionnames)
|
|
105
105
|
to enable per-module configuration (.e.g, for module-specific custom assert
|
|
106
106
|
functions).
|
|
107
107
|
|
|
@@ -4,7 +4,7 @@ const ast_1 = require("../utils/ast");
|
|
|
4
4
|
const misc_1 = require("../utils/misc");
|
|
5
5
|
function isAssertionCall(node, additionalAssertFunctionNames) {
|
|
6
6
|
return ((0, ast_1.isExpectCall)(node) ||
|
|
7
|
-
additionalAssertFunctionNames.find((name) => (0, ast_1.
|
|
7
|
+
additionalAssertFunctionNames.find((name) => (0, ast_1.dig)(node.callee, name)));
|
|
8
8
|
}
|
|
9
9
|
exports.default = {
|
|
10
10
|
create(context) {
|
|
@@ -25,7 +25,7 @@ exports.default = {
|
|
|
25
25
|
unchecked.push(node);
|
|
26
26
|
}
|
|
27
27
|
else if (isAssertionCall(node, additionalAssertFunctionNames)) {
|
|
28
|
-
checkExpressions(context.getAncestors());
|
|
28
|
+
checkExpressions(context.sourceCode.getAncestors(node));
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
'Program:exit'() {
|
|
@@ -5,11 +5,18 @@ exports.default = {
|
|
|
5
5
|
create(context) {
|
|
6
6
|
return {
|
|
7
7
|
CallExpression(node) {
|
|
8
|
+
const options = context.options[0] || {};
|
|
9
|
+
const allowConditional = !!options.allowConditional;
|
|
8
10
|
const { callee } = node;
|
|
9
11
|
if (((0, ast_1.isTestIdentifier)(callee) || (0, ast_1.isDescribeCall)(node)) &&
|
|
10
12
|
callee.type === 'MemberExpression' &&
|
|
11
13
|
(0, ast_1.isPropertyAccessor)(callee, 'skip')) {
|
|
12
14
|
const isHook = (0, ast_1.isTest)(node) || (0, ast_1.isDescribeCall)(node);
|
|
15
|
+
// If allowConditional is enabled and it's not a test/describe hook,
|
|
16
|
+
// we ignore any `test.skip` calls that have no arguments.
|
|
17
|
+
if (!isHook && allowConditional && node.arguments.length) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
13
20
|
context.report({
|
|
14
21
|
messageId: 'noSkippedTest',
|
|
15
22
|
node: isHook ? callee.property : node,
|
|
@@ -43,6 +50,18 @@ exports.default = {
|
|
|
43
50
|
noSkippedTest: 'Unexpected use of the `.skip()` annotation.',
|
|
44
51
|
removeSkippedTestAnnotation: 'Remove the `.skip()` annotation.',
|
|
45
52
|
},
|
|
53
|
+
schema: [
|
|
54
|
+
{
|
|
55
|
+
additionalProperties: false,
|
|
56
|
+
properties: {
|
|
57
|
+
allowConditional: {
|
|
58
|
+
default: false,
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
type: 'object',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
46
65
|
type: 'suggestion',
|
|
47
66
|
},
|
|
48
67
|
};
|
package/lib/utils/ast.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPageMethod = exports.getMatchers = exports.isExpectCall = exports.getExpectType = exports.isTestHook = exports.isTest = exports.findParent = exports.isDescribeCall = exports.isTestIdentifier = exports.isPropertyAccessor = exports.isBooleanLiteral = exports.isStringLiteral = exports.isIdentifier = exports.getRawValue = exports.getStringValue = void 0;
|
|
3
|
+
exports.isPageMethod = exports.dig = exports.getMatchers = exports.isExpectCall = exports.getExpectType = exports.isTestHook = exports.isTest = exports.findParent = exports.isDescribeCall = exports.isTestIdentifier = exports.isPropertyAccessor = exports.isBooleanLiteral = exports.isStringLiteral = exports.isIdentifier = exports.getRawValue = exports.getStringValue = void 0;
|
|
4
4
|
function getStringValue(node) {
|
|
5
5
|
if (!node)
|
|
6
6
|
return '';
|
|
@@ -132,6 +132,7 @@ function dig(node, identifier) {
|
|
|
132
132
|
? isIdentifier(node, identifier)
|
|
133
133
|
: false;
|
|
134
134
|
}
|
|
135
|
+
exports.dig = dig;
|
|
135
136
|
function isPageMethod(node, name) {
|
|
136
137
|
return (node.callee.type === 'MemberExpression' &&
|
|
137
138
|
dig(node.callee.object, /(^(page|frame)|(Page|Frame)$)/) &&
|
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": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"packageManager": "pnpm@8.8.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"repository": "https://github.com/playwright-community/eslint-plugin-playwright",
|