eslint-plugin-jest 26.2.2 → 26.4.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/README.md +1 -0
- package/docs/rules/prefer-hooks-in-order.md +133 -0
- package/lib/rules/consistent-test-it.js +9 -8
- package/lib/rules/expect-expect.js +1 -1
- package/lib/rules/max-nested-describe.js +2 -2
- package/lib/rules/no-conditional-expect.js +2 -2
- package/lib/rules/no-conditional-in-test.js +2 -2
- package/lib/rules/no-disabled-tests.js +32 -57
- package/lib/rules/no-done-callback.js +4 -2
- package/lib/rules/no-duplicate-hooks.js +22 -23
- package/lib/rules/no-export.js +1 -1
- package/lib/rules/no-focused-tests.js +14 -22
- package/lib/rules/no-hooks.js +4 -2
- package/lib/rules/no-identical-title.js +10 -7
- package/lib/rules/no-if.js +4 -2
- package/lib/rules/no-standalone-expect.js +2 -2
- package/lib/rules/no-test-prefixes.js +12 -20
- package/lib/rules/no-test-return-statement.js +4 -1
- package/lib/rules/prefer-expect-assertions.js +2 -2
- package/lib/rules/prefer-hooks-in-order.js +84 -0
- package/lib/rules/prefer-hooks-on-top.js +2 -2
- package/lib/rules/prefer-lowercase-title.js +11 -22
- package/lib/rules/prefer-snapshot-hint.js +2 -2
- package/lib/rules/prefer-todo.js +24 -7
- package/lib/rules/require-hook.js +2 -2
- package/lib/rules/require-top-level-describe.js +9 -4
- package/lib/rules/utils/parseJestFnCall.js +306 -0
- package/lib/rules/utils.js +40 -252
- package/lib/rules/valid-describe-callback.js +4 -2
- package/lib/rules/valid-expect-in-promise.js +9 -11
- package/lib/rules/valid-title.js +7 -6
- package/package.json +1 -1
package/lib/rules/valid-title.js
CHANGED
|
@@ -131,8 +131,9 @@ var _default = (0, _utils2.createRule)({
|
|
|
131
131
|
var _mustNotMatchPatterns, _mustMatchPatterns$je;
|
|
132
132
|
|
|
133
133
|
const scope = context.getScope();
|
|
134
|
+
const jestFnCall = (0, _utils2.parseJestFnCall)(node, scope);
|
|
134
135
|
|
|
135
|
-
if (
|
|
136
|
+
if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'describe' && (jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'test') {
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -147,7 +148,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
if (argument.type !== _utils.AST_NODE_TYPES.TemplateLiteral && !(ignoreTypeOfDescribeName &&
|
|
151
|
+
if (argument.type !== _utils.AST_NODE_TYPES.TemplateLiteral && !(ignoreTypeOfDescribeName && jestFnCall.type === 'describe')) {
|
|
151
152
|
context.report({
|
|
152
153
|
messageId: 'titleMustBeString',
|
|
153
154
|
loc: argument.loc
|
|
@@ -163,7 +164,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
163
164
|
context.report({
|
|
164
165
|
messageId: 'emptyTitle',
|
|
165
166
|
data: {
|
|
166
|
-
jestFunctionName:
|
|
167
|
+
jestFunctionName: jestFnCall.type === 'describe' ? _utils2.DescribeAlias.describe : _utils2.TestCaseName.test
|
|
167
168
|
},
|
|
168
169
|
node
|
|
169
170
|
});
|
|
@@ -193,10 +194,10 @@ var _default = (0, _utils2.createRule)({
|
|
|
193
194
|
});
|
|
194
195
|
}
|
|
195
196
|
|
|
196
|
-
const
|
|
197
|
+
const unprefixedName = trimFXprefix(jestFnCall.name);
|
|
197
198
|
const [firstWord] = title.split(' ');
|
|
198
199
|
|
|
199
|
-
if (firstWord.toLowerCase() ===
|
|
200
|
+
if (firstWord.toLowerCase() === unprefixedName) {
|
|
200
201
|
context.report({
|
|
201
202
|
messageId: 'duplicatePrefix',
|
|
202
203
|
node: argument,
|
|
@@ -204,7 +205,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
204
205
|
});
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
const
|
|
208
|
+
const jestFunctionName = unprefixedName;
|
|
208
209
|
const [mustNotMatchPattern, mustNotMatchMessage] = (_mustNotMatchPatterns = mustNotMatchPatterns[jestFunctionName]) !== null && _mustNotMatchPatterns !== void 0 ? _mustNotMatchPatterns : [];
|
|
209
210
|
|
|
210
211
|
if (mustNotMatchPattern) {
|