Socket
Socket
Sign inDemoInstall

eslint-plugin-jest

Package Overview
Dependencies
1
Maintainers
9
Versions
320
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 27.6.0 to 27.6.3

7

lib/processors/snapshot-processor.js

@@ -6,6 +6,11 @@ "use strict";

});
exports.preprocess = exports.postprocess = void 0;
exports.preprocess = exports.postprocess = exports.meta = void 0;
var _package = require("../../package.json");
// https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins
// https://github.com/typescript-eslint/typescript-eslint/issues/808
const meta = exports.meta = {
name: _package.name,
version: _package.version
};
const preprocess = source => [source];

@@ -12,0 +17,0 @@ exports.preprocess = preprocess;

4

lib/rules/expect-expect.js

@@ -73,3 +73,3 @@ "use strict";

if (node.type === _utils.AST_NODE_TYPES.FunctionDeclaration) {
const declaredVariables = context.getDeclaredVariables(node);
const declaredVariables = (0, _utils2.getDeclaredVariables)(context, node);
const testCallExpressions = (0, _utils2.getTestCallExpressionsFromDeclaredVariables)(declaredVariables, context);

@@ -94,3 +94,3 @@ checkCallExpressionUsed(testCallExpressions);

// Return early in case of nested `it` statements.
checkCallExpressionUsed(context.getAncestors());
checkCallExpressionUsed((0, _utils2.getAncestors)(context, node));
}

@@ -97,0 +97,0 @@ },

@@ -27,3 +27,3 @@ "use strict";

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, _utils.getSourceCode)(context);
function checkNode(node) {

@@ -30,0 +30,0 @@ if (!hasTests(node)) {

@@ -33,3 +33,3 @@ "use strict";

FunctionDeclaration(node) {
const declaredVariables = context.getDeclaredVariables(node);
const declaredVariables = (0, _utils2.getDeclaredVariables)(context, node);
const testCallExpressions = (0, _utils2.getTestCallExpressionsFromDeclaredVariables)(declaredVariables, context);

@@ -36,0 +36,0 @@ if (testCallExpressions.length > 0) {

@@ -33,3 +33,2 @@ "use strict";

CallExpression(node) {
const scope = context.getScope();
const jestFnCall = (0, _utils.parseJestFnCall)(node, context);

@@ -43,3 +42,3 @@ if (!jestFnCall) {

}
if (!['global', 'module'].includes(scope.type)) {
if (!['global', 'module'].includes((0, _utils.getScope)(context, node).type)) {
context.report({

@@ -46,0 +45,0 @@ messageId: 'globalSetTimeout',

@@ -71,3 +71,3 @@ "use strict";

'CallExpression[callee.name="pending"]'(node) {
if ((0, _utils.resolveScope)(context.getScope(), 'pending')) {
if ((0, _utils.resolveScope)((0, _utils.getScope)(context, node), 'pending')) {
return;

@@ -74,0 +74,0 @@ }

@@ -86,3 +86,3 @@ "use strict";

} = callback;
const sourceCode = context.getSourceCode();
const sourceCode = (0, _utils2.getSourceCode)(context);
const firstBodyToken = sourceCode.getFirstToken(body);

@@ -89,0 +89,0 @@ const lastBodyToken = sourceCode.getLastToken(body);

@@ -62,3 +62,3 @@ "use strict";

FunctionDeclaration(node) {
const declaredVariables = context.getDeclaredVariables(node);
const declaredVariables = (0, _utils2.getDeclaredVariables)(context, node);
const testCallExpressions = (0, _utils2.getTestCallExpressionsFromDeclaredVariables)(declaredVariables, context);

@@ -65,0 +65,0 @@ stack.push(testCallExpressions.length > 0);

@@ -40,3 +40,3 @@ "use strict";

if (calleeName === 'spyOn' || calleeName === 'spyOnProperty' || calleeName === 'fail' || calleeName === 'pending') {
if ((0, _utils2.resolveScope)(context.getScope(), calleeName)) {
if ((0, _utils2.resolveScope)((0, _utils2.getScope)(context, node), calleeName)) {
// It's a local variable, not a jasmine global.

@@ -43,0 +43,0 @@ return;

@@ -23,3 +23,3 @@ "use strict";

if (node.type === _utils.AST_NODE_TYPES.ExpressionStatement && 'left' in node.expression && node.expression.left.type === _utils.AST_NODE_TYPES.MemberExpression && (0, _utils2.isSupportedAccessor)(node.expression.left.property)) {
const fileName = context.getFilename();
const fileName = (0, _utils2.getFilename)(context);
const allowedSnapshotsInFile = allowedSnapshots[fileName];

@@ -26,0 +26,0 @@ if (allowedSnapshotsInFile) {

@@ -48,3 +48,3 @@ "use strict";

FunctionDeclaration(node) {
const declaredVariables = context.getDeclaredVariables(node);
const declaredVariables = (0, _utils2.getDeclaredVariables)(context, node);
const testCallExpressions = (0, _utils2.getTestCallExpressionsFromDeclaredVariables)(declaredVariables, context);

@@ -51,0 +51,0 @@ if (testCallExpressions.length === 0) {

@@ -90,3 +90,3 @@ "use strict";

fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, _utils2.getSourceCode)(context);

@@ -93,0 +93,0 @@ // preserve the existing modifier if it's not a negation

@@ -58,3 +58,3 @@ "use strict";

const buildFixer = equalityMatcher => fixer => {
const sourceCode = context.getSourceCode();
const sourceCode = (0, _utils2.getSourceCode)(context);

@@ -61,0 +61,0 @@ // preserve the existing modifier if it's not a negation

@@ -55,3 +55,3 @@ "use strict";

fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, _utils2.getSourceCode)(context);

@@ -58,0 +58,0 @@ // there shouldn't be more than one argument, but if there is don't try

@@ -38,3 +38,3 @@ "use strict";

const [arg] = jestFnCall.arguments;
const argSource = arg && context.getSourceCode().getText(arg);
const argSource = arg && (0, _utils2.getSourceCode)(context).getText(arg);
return argSource ? `.mockImplementation(${argSource})` : '.mockImplementation()';

@@ -41,0 +41,0 @@ };

@@ -63,3 +63,3 @@ "use strict";

fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, _utils2.getSourceCode)(context);

@@ -66,0 +66,0 @@ // we need to negate the expectation if the current expected

@@ -6,5 +6,5 @@ "use strict";

});
exports.getFirstMatcherArg = exports.findTopMostCallExpression = exports.createRule = exports.TestCaseName = exports.ModifierName = exports.HookName = exports.EqualityMatcher = exports.DescribeAlias = void 0;
exports.getFirstMatcherArg = exports.getFilename = exports.getDeclaredVariables = exports.getAncestors = exports.findTopMostCallExpression = exports.createRule = exports.TestCaseName = exports.ModifierName = exports.HookName = exports.EqualityMatcher = exports.DescribeAlias = void 0;
exports.getNodeName = getNodeName;
exports.replaceAccessorFixer = exports.removeExtraArgumentsFixer = exports.isFunction = exports.isBooleanLiteral = exports.hasOnlyOneArgument = exports.getTestCallExpressionsFromDeclaredVariables = void 0;
exports.replaceAccessorFixer = exports.removeExtraArgumentsFixer = exports.isFunction = exports.isBooleanLiteral = exports.hasOnlyOneArgument = exports.getTestCallExpressionsFromDeclaredVariables = exports.getSourceCode = exports.getScope = void 0;
var _path = require("path");

@@ -124,3 +124,3 @@ var _utils = require("@typescript-eslint/utils");

const lastArg = func.arguments[func.arguments.length - 1];
const sourceCode = context.getSourceCode();
const sourceCode = getSourceCode(context);
let tokenAfterLastParam = sourceCode.getTokenAfter(lastArg);

@@ -161,2 +161,44 @@ if (tokenAfterLastParam.value === ',') {

};
exports.getFirstMatcherArg = getFirstMatcherArg;
/* istanbul ignore next */
exports.getFirstMatcherArg = getFirstMatcherArg;
const getFilename = context => {
return 'filename' in context ? context.filename : context.getFilename();
};
/* istanbul ignore next */
exports.getFilename = getFilename;
const getSourceCode = context => {
return 'sourceCode' in context ? context.sourceCode : context.getSourceCode();
};
/* istanbul ignore next */
exports.getSourceCode = getSourceCode;
const getScope = (context, node) => {
const sourceCode = getSourceCode(context);
if ('getScope' in sourceCode) {
return sourceCode.getScope(node);
}
return context.getScope();
};
/* istanbul ignore next */
exports.getScope = getScope;
const getAncestors = (context, node) => {
const sourceCode = getSourceCode(context);
if ('getAncestors' in sourceCode) {
return sourceCode.getAncestors(node);
}
return context.getAncestors();
};
/* istanbul ignore next */
exports.getAncestors = getAncestors;
const getDeclaredVariables = (context, node) => {
const sourceCode = getSourceCode(context);
if ('getDeclaredVariables' in sourceCode) {
return sourceCode.getDeclaredVariables(node);
}
return context.getDeclaredVariables(node);
};
exports.getDeclaredVariables = getDeclaredVariables;

@@ -99,3 +99,3 @@ "use strict";

}
const resolved = resolveToJestFn(context, (0, _utils2.getAccessorValue)(first));
const resolved = resolveToJestFn(context, first);

@@ -307,4 +307,5 @@ // we're not a jest function

exports.resolveScope = resolveScope;
const resolveToJestFn = (context, identifier) => {
const maybeImport = resolveScope(context.getScope(), identifier);
const resolveToJestFn = (context, accessor) => {
const identifier = (0, _utils2.getAccessorValue)(accessor);
const maybeImport = resolveScope((0, _utils2.getScope)(context, accessor), identifier);

@@ -311,0 +312,0 @@ // the identifier was found as a local variable or function declaration

{
"name": "eslint-plugin-jest",
"version": "27.6.0",
"version": "27.6.3",
"description": "ESLint rules for Jest",

@@ -157,3 +157,3 @@ "keywords": [

},
"packageManager": "yarn@3.6.4",
"packageManager": "yarn@3.7.0",
"engines": {

@@ -164,3 +164,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"

"provenance": true
},
"resolutions": {
"typescript": "~5.2.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc