Socket
Socket
Sign inDemoInstall

babel-plugin-jest-hoist

Package Overview
Dependencies
Maintainers
6
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-jest-hoist - npm Package Compare versions

Comparing version 29.0.0 to 29.0.2

38

build/index.js

@@ -38,3 +38,4 @@ 'use strict';

const JEST_GLOBALS_MODULE_JEST_EXPORT_NAME = 'jest';
const hoistedVariables = new WeakSet(); // We allow `jest`, `expect`, `require`, all default Node.js globals and all
const hoistedVariables = new WeakSet();
const hoistedJestExpressions = new WeakSet(); // We allow `jest`, `expect`, `require`, all default Node.js globals and all
// ES2015 built-ins to be used inside of a `jest.mock` factory.

@@ -164,2 +165,15 @@ // We also allow variables prefixed with `mock` as an escape-hatch.

}
} else if (binding?.path.isImportSpecifier()) {
const importDecl = binding.path.parentPath;
const imported = binding.path.node.imported;
if (
importDecl.node.source.value === JEST_GLOBALS_MODULE_NAME &&
((0, _types().isIdentifier)(imported)
? imported.name
: imported.value) === JEST_GLOBALS_MODULE_JEST_EXPORT_NAME
) {
isAllowedIdentifier = true; // Imports are already hoisted, so we don't need to add it
// to hoistedVariables.
}
}

@@ -263,4 +277,22 @@ }

const functionLooksHoistable = FUNCTIONS[propertyName]?.(args);
return functionLooksHoistable ? jestObjExpr : null;
let functionLooksHoistableOrInHoistable = FUNCTIONS[propertyName]?.(args);
for (
let path = expr;
path && !functionLooksHoistableOrInHoistable;
path = path.parentPath
) {
functionLooksHoistableOrInHoistable = hoistedJestExpressions.has(
// @ts-expect-error: it's ok if path.node is not an Expression, .has will
// just return false.
path.node
);
}
if (functionLooksHoistableOrInHoistable) {
hoistedJestExpressions.add(expr.node);
return jestObjExpr;
}
return null;
};

@@ -267,0 +299,0 @@ /* eslint-disable sort-keys */

4

package.json
{
"name": "babel-plugin-jest-hoist",
"version": "29.0.0",
"version": "29.0.2",
"repository": {

@@ -40,3 +40,3 @@ "type": "git",

},
"gitHead": "75006e46c76f6fda14bbc0548f86edb2ba087cd2"
"gitHead": "616fcf56bb8481d29ba29cc34be32a92b1cf85e5"
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc