eslint-plugin-jest 26.8.7 → 27.0.0-next.1
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/lib/rules/expect-expect.js +1 -3
- package/lib/rules/no-conditional-expect.js +1 -3
- package/lib/rules/no-done-callback.js +2 -2
- package/lib/rules/no-large-snapshots.js +1 -3
- package/lib/rules/prefer-snapshot-hint.js +1 -3
- package/lib/rules/require-hook.js +1 -3
- package/lib/rules/require-top-level-describe.js +1 -3
- package/lib/rules/utils/parseJestFnCall.js +5 -7
- package/lib/rules/valid-title.js +4 -6
- package/package.json +3 -3
|
@@ -89,9 +89,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
89
89
|
|
|
90
90
|
return {
|
|
91
91
|
CallExpression(node) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const name = (_getNodeName = (0, _utils2.getNodeName)(node.callee)) !== null && _getNodeName !== void 0 ? _getNodeName : '';
|
|
92
|
+
const name = (0, _utils2.getNodeName)(node.callee) ?? '';
|
|
95
93
|
|
|
96
94
|
if ((0, _utils2.isTypeOfJestFnCall)(node, context, ['test']) || additionalTestBlockFunctions.includes(name)) {
|
|
97
95
|
if (node.callee.type === _utils.AST_NODE_TYPES.MemberExpression && (0, _utils2.isSupportedAccessor)(node.callee.property, 'todo')) {
|
|
@@ -47,11 +47,9 @@ var _default = (0, _utils2.createRule)({
|
|
|
47
47
|
},
|
|
48
48
|
|
|
49
49
|
CallExpression(node) {
|
|
50
|
-
var _parseJestFnCall;
|
|
51
|
-
|
|
52
50
|
const {
|
|
53
51
|
type: jestFnCallType
|
|
54
|
-
} = (
|
|
52
|
+
} = (0, _utils2.parseJestFnCall)(node, context) ?? {};
|
|
55
53
|
|
|
56
54
|
if (jestFnCallType === 'test') {
|
|
57
55
|
inTestCase = true;
|
|
@@ -50,10 +50,10 @@ var _default = (0, _utils2.createRule)({
|
|
|
50
50
|
create(context) {
|
|
51
51
|
return {
|
|
52
52
|
CallExpression(node) {
|
|
53
|
-
var _getNodeName
|
|
53
|
+
var _getNodeName;
|
|
54
54
|
|
|
55
55
|
// done is the second argument for it.each, not the first
|
|
56
|
-
const isJestEach = (
|
|
56
|
+
const isJestEach = ((_getNodeName = (0, _utils2.getNodeName)(node.callee)) === null || _getNodeName === void 0 ? void 0 : _getNodeName.endsWith('.each')) ?? false;
|
|
57
57
|
|
|
58
58
|
if (isJestEach && node.callee.type !== _utils.AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
59
59
|
// isJestEach but not a TaggedTemplateExpression, so this must be
|
|
@@ -107,10 +107,8 @@ var _default = (0, _utils2.createRule)({
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
if (['toMatchInlineSnapshot', 'toThrowErrorMatchingInlineSnapshot'].includes((0, _utils2.getAccessorValue)(jestFnCall.matcher)) && jestFnCall.args.length) {
|
|
110
|
-
var _options$inlineMaxSiz;
|
|
111
|
-
|
|
112
110
|
reportOnViolation(context, jestFnCall.args[0], { ...options,
|
|
113
|
-
maxSize:
|
|
111
|
+
maxSize: options.inlineMaxSize ?? options.maxSize
|
|
114
112
|
});
|
|
115
113
|
}
|
|
116
114
|
}
|
|
@@ -104,10 +104,8 @@ var _default = (0, _utils.createRule)({
|
|
|
104
104
|
|
|
105
105
|
'CallExpression:exit'(node) {
|
|
106
106
|
if ((0, _utils.isTypeOfJestFnCall)(node, context, ['describe', 'test'])) {
|
|
107
|
-
var _depths$pop;
|
|
108
|
-
|
|
109
107
|
/* istanbul ignore next */
|
|
110
|
-
expressionDepth =
|
|
108
|
+
expressionDepth = depths.pop() ?? 0;
|
|
111
109
|
}
|
|
112
110
|
},
|
|
113
111
|
|
|
@@ -77,11 +77,9 @@ var _default = (0, _utils2.createRule)({
|
|
|
77
77
|
}],
|
|
78
78
|
|
|
79
79
|
create(context) {
|
|
80
|
-
var _context$options$;
|
|
81
|
-
|
|
82
80
|
const {
|
|
83
81
|
allowedFunctionCalls
|
|
84
|
-
} =
|
|
82
|
+
} = context.options[0] ?? {};
|
|
85
83
|
|
|
86
84
|
const checkBlockBody = body => {
|
|
87
85
|
for (const statement of body) {
|
|
@@ -37,11 +37,9 @@ var _default = (0, _utils.createRule)({
|
|
|
37
37
|
defaultOptions: [{}],
|
|
38
38
|
|
|
39
39
|
create(context) {
|
|
40
|
-
var _context$options$;
|
|
41
|
-
|
|
42
40
|
const {
|
|
43
41
|
maxNumberOfTopLevelDescribes = Infinity
|
|
44
|
-
} =
|
|
42
|
+
} = context.options[0] ?? {};
|
|
45
43
|
let numberOfTopLevelDescribeBlocks = 0;
|
|
46
44
|
let numberOfDescribeBlocks = 0;
|
|
47
45
|
return {
|
|
@@ -69,9 +69,9 @@ const determineJestFnType = name => {
|
|
|
69
69
|
const ValidJestFnCallChains = ['afterAll', 'afterEach', 'beforeAll', 'beforeEach', 'describe', 'describe.each', 'describe.only', 'describe.only.each', 'describe.skip', 'describe.skip.each', 'fdescribe', 'fdescribe.each', 'xdescribe', 'xdescribe.each', 'it', 'it.concurrent', 'it.concurrent.each', 'it.concurrent.only.each', 'it.concurrent.skip.each', 'it.each', 'it.failing', 'it.only', 'it.only.each', 'it.only.failing', 'it.skip', 'it.skip.each', 'it.skip.failing', 'it.todo', 'fit', 'fit.each', 'fit.failing', 'xit', 'xit.each', 'xit.failing', 'test', 'test.concurrent', 'test.concurrent.each', 'test.concurrent.only.each', 'test.concurrent.skip.each', 'test.each', 'test.failing', 'test.only', 'test.only.each', 'test.only.failing', 'test.skip', 'test.skip.each', 'test.skip.failing', 'test.todo', 'xtest', 'xtest.each', 'xtest.failing'];
|
|
70
70
|
|
|
71
71
|
const resolvePossibleAliasedGlobal = (global, context) => {
|
|
72
|
-
var _context$settings$jes
|
|
72
|
+
var _context$settings$jes;
|
|
73
73
|
|
|
74
|
-
const globalAliases = (_context$settings$jes =
|
|
74
|
+
const globalAliases = ((_context$settings$jes = context.settings.jest) === null || _context$settings$jes === void 0 ? void 0 : _context$settings$jes.globalAliases) ?? {};
|
|
75
75
|
const alias = Object.entries(globalAliases).find(([, aliases]) => aliases.includes(global));
|
|
76
76
|
|
|
77
77
|
if (alias) {
|
|
@@ -110,7 +110,7 @@ const parseJestFnCallWithReason = (node, context) => {
|
|
|
110
110
|
exports.parseJestFnCallWithReason = parseJestFnCallWithReason;
|
|
111
111
|
|
|
112
112
|
const parseJestFnCallWithReasonInner = (node, context) => {
|
|
113
|
-
var
|
|
113
|
+
var _node$parent2, _node$parent3;
|
|
114
114
|
|
|
115
115
|
const chain = getNodeChain(node);
|
|
116
116
|
|
|
@@ -137,7 +137,7 @@ const parseJestFnCallWithReasonInner = (node, context) => {
|
|
|
137
137
|
return null;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const name =
|
|
140
|
+
const name = resolved.original ?? resolved.local;
|
|
141
141
|
const links = [name, ...rest.map(link => (0, _utils2.getAccessorValue)(link))];
|
|
142
142
|
|
|
143
143
|
if (name !== 'jest' && name !== 'expect' && !ValidJestFnCallChains.includes(links.join('.'))) {
|
|
@@ -293,9 +293,7 @@ const findImportSourceNode = node => {
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
if (node.type === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.isIdentifier)(node.callee, 'require')) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return (_node$arguments$ = node.arguments[0]) !== null && _node$arguments$ !== void 0 ? _node$arguments$ : null;
|
|
296
|
+
return node.arguments[0] ?? null;
|
|
299
297
|
}
|
|
300
298
|
|
|
301
299
|
return null;
|
package/lib/rules/valid-title.js
CHANGED
|
@@ -124,12 +124,10 @@ var _default = (0, _utils2.createRule)({
|
|
|
124
124
|
mustMatch
|
|
125
125
|
}]) {
|
|
126
126
|
const disallowedWordsRegexp = new RegExp(`\\b(${disallowedWords.join('|')})\\b`, 'iu');
|
|
127
|
-
const mustNotMatchPatterns = compileMatcherPatterns(mustNotMatch
|
|
128
|
-
const mustMatchPatterns = compileMatcherPatterns(mustMatch
|
|
127
|
+
const mustNotMatchPatterns = compileMatcherPatterns(mustNotMatch ?? {});
|
|
128
|
+
const mustMatchPatterns = compileMatcherPatterns(mustMatch ?? {});
|
|
129
129
|
return {
|
|
130
130
|
CallExpression(node) {
|
|
131
|
-
var _mustNotMatchPatterns, _mustMatchPatterns$je;
|
|
132
|
-
|
|
133
131
|
const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
|
|
134
132
|
|
|
135
133
|
if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'describe' && (jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'test') {
|
|
@@ -205,7 +203,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
205
203
|
}
|
|
206
204
|
|
|
207
205
|
const jestFunctionName = unprefixedName;
|
|
208
|
-
const [mustNotMatchPattern, mustNotMatchMessage] =
|
|
206
|
+
const [mustNotMatchPattern, mustNotMatchMessage] = mustNotMatchPatterns[jestFunctionName] ?? [];
|
|
209
207
|
|
|
210
208
|
if (mustNotMatchPattern) {
|
|
211
209
|
if (mustNotMatchPattern.test(title)) {
|
|
@@ -222,7 +220,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
222
|
|
|
225
|
-
const [mustMatchPattern, mustMatchMessage] =
|
|
223
|
+
const [mustMatchPattern, mustMatchMessage] = mustMatchPatterns[jestFunctionName] ?? [];
|
|
226
224
|
|
|
227
225
|
if (mustMatchPattern) {
|
|
228
226
|
if (!mustMatchPattern.test(title)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-jest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.0.0-next.1",
|
|
4
4
|
"description": "ESLint rules for Jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
},
|
|
142
142
|
"peerDependencies": {
|
|
143
143
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
144
|
-
"eslint": "^
|
|
144
|
+
"eslint": "^7.0.0 || ^8.0.0"
|
|
145
145
|
},
|
|
146
146
|
"peerDependenciesMeta": {
|
|
147
147
|
"@typescript-eslint/eslint-plugin": {
|
|
@@ -153,6 +153,6 @@
|
|
|
153
153
|
},
|
|
154
154
|
"packageManager": "yarn@3.2.2",
|
|
155
155
|
"engines": {
|
|
156
|
-
"node": "^
|
|
156
|
+
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
|
157
157
|
}
|
|
158
158
|
}
|