eslint-plugin-jest 27.1.4 → 27.1.5
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.
|
@@ -68,7 +68,7 @@ var _default = (0, _utils.createRule)({
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
'CallExpression[callee.name="pending"]'(node) {
|
|
71
|
-
if ((0, _utils.
|
|
71
|
+
if ((0, _utils.resolveScope)(context.getScope(), 'pending')) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (testDepth > 0) {
|
|
@@ -37,7 +37,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
if (calleeName === 'spyOn' || calleeName === 'spyOnProperty' || calleeName === 'fail' || calleeName === 'pending') {
|
|
40
|
-
if ((0, _utils2.
|
|
40
|
+
if ((0, _utils2.resolveScope)(context.getScope(), calleeName)) {
|
|
41
41
|
// It's a local variable, not a jasmine global.
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getNodeChain = getNodeChain;
|
|
7
|
-
exports.
|
|
7
|
+
exports.resolveScope = exports.parseJestFnCallWithReason = exports.parseJestFnCall = exports.isTypeOfJestFnCall = void 0;
|
|
8
8
|
var _utils = require("@typescript-eslint/utils");
|
|
9
9
|
var _utils2 = require("../utils");
|
|
10
10
|
const isTypeOfJestFnCall = (node, context, types) => {
|
|
@@ -286,55 +286,23 @@ const describePossibleImportDef = def => {
|
|
|
286
286
|
}
|
|
287
287
|
return null;
|
|
288
288
|
};
|
|
289
|
-
const collectReferences = scope => {
|
|
290
|
-
const locals = new Set();
|
|
291
|
-
const imports = new Map();
|
|
292
|
-
const unresolved = new Set();
|
|
293
|
-
let currentScope = scope;
|
|
294
|
-
while (currentScope !== null) {
|
|
295
|
-
for (const ref of currentScope.variables) {
|
|
296
|
-
if (ref.defs.length === 0) {
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
const def = ref.defs[ref.defs.length - 1];
|
|
300
|
-
const importDetails = describePossibleImportDef(def);
|
|
301
|
-
if (importDetails) {
|
|
302
|
-
imports.set(importDetails.local, importDetails);
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
locals.add(ref.name);
|
|
306
|
-
}
|
|
307
|
-
for (const ref of currentScope.through) {
|
|
308
|
-
unresolved.add(ref.identifier.name);
|
|
309
|
-
}
|
|
310
|
-
currentScope = currentScope.upper;
|
|
311
|
-
}
|
|
312
|
-
return {
|
|
313
|
-
locals,
|
|
314
|
-
imports,
|
|
315
|
-
unresolved
|
|
316
|
-
};
|
|
317
|
-
};
|
|
318
289
|
const resolveScope = (scope, identifier) => {
|
|
319
290
|
let currentScope = scope;
|
|
320
291
|
while (currentScope !== null) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
continue;
|
|
324
|
-
}
|
|
292
|
+
const ref = currentScope.set.get(identifier);
|
|
293
|
+
if (ref && ref.defs.length > 0) {
|
|
325
294
|
const def = ref.defs[ref.defs.length - 1];
|
|
326
295
|
const importDetails = describePossibleImportDef(def);
|
|
327
296
|
if ((importDetails === null || importDetails === void 0 ? void 0 : importDetails.local) === identifier) {
|
|
328
297
|
return importDetails;
|
|
329
298
|
}
|
|
330
|
-
|
|
331
|
-
return 'local';
|
|
332
|
-
}
|
|
299
|
+
return 'local';
|
|
333
300
|
}
|
|
334
301
|
currentScope = currentScope.upper;
|
|
335
302
|
}
|
|
336
303
|
return null;
|
|
337
304
|
};
|
|
305
|
+
exports.resolveScope = resolveScope;
|
|
338
306
|
const resolveToJestFn = (context, identifier) => {
|
|
339
307
|
const maybeImport = resolveScope(context.getScope(), identifier);
|
|
340
308
|
|
|
@@ -360,17 +328,4 @@ const resolveToJestFn = (context, identifier) => {
|
|
|
360
328
|
local: identifier,
|
|
361
329
|
type: 'global'
|
|
362
330
|
};
|
|
363
|
-
};
|
|
364
|
-
const scopeHasLocalReference = (scope, referenceName) => {
|
|
365
|
-
const references = collectReferences(scope);
|
|
366
|
-
return (
|
|
367
|
-
// referenceName was found as a local variable or function declaration.
|
|
368
|
-
references.locals.has(referenceName) ||
|
|
369
|
-
// referenceName was found as an imported identifier
|
|
370
|
-
references.imports.has(referenceName) ||
|
|
371
|
-
// referenceName was not found as an unresolved reference,
|
|
372
|
-
// meaning it is likely not an implicit global reference.
|
|
373
|
-
!references.unresolved.has(referenceName)
|
|
374
|
-
);
|
|
375
|
-
};
|
|
376
|
-
exports.scopeHasLocalReference = scopeHasLocalReference;
|
|
331
|
+
};
|
package/lib/rules/valid-title.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _utils = require("@typescript-eslint/utils");
|
|
8
8
|
var _utils2 = require("./utils");
|
|
9
|
-
const trimFXprefix = word => ['f', 'x'].includes(word.charAt(0)) ? word.
|
|
9
|
+
const trimFXprefix = word => ['f', 'x'].includes(word.charAt(0)) ? word.substring(1) : word;
|
|
10
10
|
const doesBinaryExpressionContainStringNode = binaryExp => {
|
|
11
11
|
if ((0, _utils2.isStringNode)(binaryExp.right)) {
|
|
12
12
|
return true;
|