eslint-plugin-jest 26.4.6 → 26.4.7
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.
|
@@ -30,6 +30,23 @@ var _default = (0, _utils.createRule)({
|
|
|
30
30
|
defaultOptions: [{}],
|
|
31
31
|
|
|
32
32
|
create(context, [restrictedChains]) {
|
|
33
|
+
const reportIfRestricted = (loc, chain) => {
|
|
34
|
+
if (!(chain in restrictedChains)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const message = restrictedChains[chain];
|
|
39
|
+
context.report({
|
|
40
|
+
messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
|
|
41
|
+
data: {
|
|
42
|
+
message,
|
|
43
|
+
chain
|
|
44
|
+
},
|
|
45
|
+
loc
|
|
46
|
+
});
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
|
|
33
50
|
return {
|
|
34
51
|
CallExpression(node) {
|
|
35
52
|
if (!(0, _utils.isExpectCall)(node)) {
|
|
@@ -41,58 +58,37 @@ var _default = (0, _utils.createRule)({
|
|
|
41
58
|
modifier
|
|
42
59
|
} = (0, _utils.parseExpectCall)(node);
|
|
43
60
|
|
|
44
|
-
if (matcher) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (chain in restrictedChains) {
|
|
48
|
-
const message = restrictedChains[chain];
|
|
49
|
-
context.report({
|
|
50
|
-
messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
|
|
51
|
-
data: {
|
|
52
|
-
message,
|
|
53
|
-
chain
|
|
54
|
-
},
|
|
55
|
-
node: matcher.node.property
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
61
|
+
if (matcher && reportIfRestricted(matcher.node.property.loc, matcher.name)) {
|
|
62
|
+
return;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
if (modifier) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (chain in restrictedChains) {
|
|
65
|
-
const message = restrictedChains[chain];
|
|
66
|
-
context.report({
|
|
67
|
-
messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
|
|
68
|
-
data: {
|
|
69
|
-
message,
|
|
70
|
-
chain
|
|
71
|
-
},
|
|
72
|
-
node: modifier.node.property
|
|
73
|
-
});
|
|
66
|
+
if (reportIfRestricted(modifier.node.property.loc, modifier.name)) {
|
|
74
67
|
return;
|
|
75
68
|
}
|
|
69
|
+
|
|
70
|
+
if (modifier.negation) {
|
|
71
|
+
if (reportIfRestricted(modifier.negation.property.loc, 'not') || reportIfRestricted({
|
|
72
|
+
start: modifier.node.property.loc.start,
|
|
73
|
+
end: modifier.negation.property.loc.end
|
|
74
|
+
}, `${modifier.name}.not`)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
if (matcher && modifier) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
context.report({
|
|
84
|
-
messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
|
|
85
|
-
data: {
|
|
86
|
-
message,
|
|
87
|
-
chain
|
|
88
|
-
},
|
|
89
|
-
loc: {
|
|
90
|
-
start: modifier.node.property.loc.start,
|
|
91
|
-
end: matcher.node.property.loc.end
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
return;
|
|
81
|
+
let chain = modifier.name;
|
|
82
|
+
|
|
83
|
+
if (modifier.negation) {
|
|
84
|
+
chain += '.not';
|
|
95
85
|
}
|
|
86
|
+
|
|
87
|
+
chain += `.${matcher.name}`;
|
|
88
|
+
reportIfRestricted({
|
|
89
|
+
start: modifier.node.property.loc.start,
|
|
90
|
+
end: matcher.node.property.loc.end
|
|
91
|
+
}, chain);
|
|
96
92
|
}
|
|
97
93
|
}
|
|
98
94
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-jest",
|
|
3
|
-
"version": "26.4.
|
|
3
|
+
"version": "26.4.7",
|
|
4
4
|
"description": "ESLint rules for Jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@semantic-release/changelog": "^6.0.0",
|
|
93
93
|
"@semantic-release/git": "^10.0.0",
|
|
94
94
|
"@types/dedent": "^0.7.0",
|
|
95
|
-
"@types/jest": "^
|
|
95
|
+
"@types/jest": "^28.0.0",
|
|
96
96
|
"@types/node": "^16.0.0",
|
|
97
97
|
"@types/prettier": "^2.0.0",
|
|
98
98
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|