Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-import

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import - npm Package Compare versions

Comparing version 1.13.4 to 1.13.5

71

lib/index.js
"use strict";
var _interopRequireDefault = require("/Users/chencheng/code/github.com/umijs/babel-plugin-import/node_modules/.pnpm/babel-preset-umi@1.8.4/node_modules/@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -10,4 +8,2 @@ value: true

var _toConsumableArray2 = _interopRequireDefault(require("/Users/chencheng/code/github.com/umijs/babel-plugin-import/node_modules/.pnpm/babel-preset-umi@1.8.4/node_modules/@babel/runtime/helpers/toConsumableArray"));
var _assert = _interopRequireDefault(require("assert"));

@@ -17,2 +13,4 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

@@ -22,10 +20,11 @@

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _default(_ref) {
var types = _ref.types;
var plugins = null; // Only for test
function _default({
types
}) {
let plugins = null; // Only for test
// eslint-disable-next-line no-underscore-dangle
global.__clearBabelAntdPlugin = function () {
global.__clearBabelAntdPlugin = () => {
plugins = null;

@@ -41,6 +40,6 @@ };

for (_iterator.s(); !(_step = _iterator.n()).done;) {
var plugin = _step.value;
const plugin = _step.value;
if (plugin[method]) {
plugin[method].apply(plugin, [].concat((0, _toConsumableArray2.default)(args), [context]));
plugin[method].apply(plugin, [...args, context]);
}

@@ -55,21 +54,21 @@ }

var Program = {
enter: function enter(path, _ref2) {
var _ref2$opts = _ref2.opts,
opts = _ref2$opts === void 0 ? {} : _ref2$opts;
const Program = {
enter(path, {
opts = {}
}) {
// Init plugin instances once.
if (!plugins) {
if (Array.isArray(opts)) {
plugins = opts.map(function (_ref3, index) {
var libraryName = _ref3.libraryName,
libraryDirectory = _ref3.libraryDirectory,
style = _ref3.style,
styleLibraryDirectory = _ref3.styleLibraryDirectory,
customStyleName = _ref3.customStyleName,
camel2DashComponentName = _ref3.camel2DashComponentName,
camel2UnderlineComponentName = _ref3.camel2UnderlineComponentName,
fileName = _ref3.fileName,
customName = _ref3.customName,
transformToDefaultImport = _ref3.transformToDefaultImport;
plugins = opts.map(({
libraryName,
libraryDirectory,
style,
styleLibraryDirectory,
customStyleName,
camel2DashComponentName,
camel2UnderlineComponentName,
fileName,
customName,
transformToDefaultImport
}, index) => {
(0, _assert.default)(libraryName, 'libraryName should be provided');

@@ -86,15 +85,17 @@ return new _Plugin.default(libraryName, libraryDirectory, style, styleLibraryDirectory, customStyleName, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index);

},
exit: function exit() {
exit() {
applyInstance('ProgramExit', arguments, this); // eslint-disable-line
}
};
var methods = ['ImportDeclaration', 'CallExpression', 'MemberExpression', 'Property', 'VariableDeclarator', 'ArrayExpression', 'LogicalExpression', 'ConditionalExpression', 'IfStatement', 'ExpressionStatement', 'ReturnStatement', 'ExportDefaultDeclaration', 'BinaryExpression', 'NewExpression', 'ClassDeclaration', 'SwitchStatement', 'SwitchCase'];
var ret = {
const methods = ['ImportDeclaration', 'CallExpression', 'MemberExpression', 'Property', 'VariableDeclarator', 'ArrayExpression', 'LogicalExpression', 'ConditionalExpression', 'IfStatement', 'ExpressionStatement', 'ReturnStatement', 'ExportDefaultDeclaration', 'BinaryExpression', 'NewExpression', 'ClassDeclaration', 'SwitchStatement', 'SwitchCase'];
const ret = {
visitor: {
Program: Program
Program
}
}; // eslint-disable-next-line no-restricted-syntax
var _loop = function _loop() {
var method = _methods[_i];
for (var _i = 0, _methods = methods; _i < _methods.length; _i++) {
const method = _methods[_i];

@@ -105,6 +106,2 @@ ret.visitor[method] = function () {

};
};
for (var _i = 0, _methods = methods; _i < _methods.length; _i++) {
_loop();
}

@@ -111,0 +108,0 @@

"use strict";
var _interopRequireDefault = require("/Users/chencheng/code/github.com/umijs/babel-plugin-import/node_modules/.pnpm/babel-preset-umi@1.8.4/node_modules/@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -10,8 +8,2 @@ value: true

var _defineProperty2 = _interopRequireDefault(require("/Users/chencheng/code/github.com/umijs/babel-plugin-import/node_modules/.pnpm/babel-preset-umi@1.8.4/node_modules/@babel/runtime/helpers/defineProperty"));
var _classCallCheck2 = _interopRequireDefault(require("/Users/chencheng/code/github.com/umijs/babel-plugin-import/node_modules/.pnpm/babel-preset-umi@1.8.4/node_modules/@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("/Users/chencheng/code/github.com/umijs/babel-plugin-import/node_modules/.pnpm/babel-preset-umi@1.8.4/node_modules/@babel/runtime/helpers/createClass"));
var _path = require("path");

@@ -23,10 +15,10 @@

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function transCamel(_str, symbol) {
var str = _str[0].toLowerCase() + _str.substr(1);
const str = _str[0].toLowerCase() + _str.substr(1);
return str.replace(/([A-Z])/g, function ($1) {
return "".concat(symbol).concat($1.toLowerCase());
});
return str.replace(/([A-Z])/g, $1 => `${symbol}${$1.toLowerCase()}`);
}

@@ -42,3 +34,3 @@

// eslint-disable-next-line import/no-dynamic-require
var customNameExports = require(originCustomName);
const customNameExports = require(originCustomName);

@@ -51,6 +43,4 @@ return typeof customNameExports === 'function' ? customNameExports : customNameExports.default;

var Plugin = /*#__PURE__*/function () {
function Plugin(libraryName, libraryDirectory, style, styleLibraryDirectory, customStyleName, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types) {
var index = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : 0;
(0, _classCallCheck2.default)(this, Plugin);
class Plugin {
constructor(libraryName, libraryDirectory, style, styleLibraryDirectory, customStyleName, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index = 0) {
this.libraryName = libraryName;

@@ -67,280 +57,240 @@ this.libraryDirectory = typeof libraryDirectory === 'undefined' ? 'lib' : libraryDirectory;

this.types = types;
this.pluginStateKey = "importPluginState".concat(index);
this.pluginStateKey = `importPluginState${index}`;
}
(0, _createClass2.default)(Plugin, [{
key: "getPluginState",
value: function getPluginState(state) {
if (!state[this.pluginStateKey]) {
state[this.pluginStateKey] = {}; // eslint-disable-line
}
getPluginState(state) {
if (!state[this.pluginStateKey]) {
state[this.pluginStateKey] = {}; // eslint-disable-line
}
return state[this.pluginStateKey];
}
}, {
key: "importMethod",
value: function importMethod(methodName, file, pluginState) {
if (!pluginState.selectedMethods[methodName]) {
var style = this.style,
return state[this.pluginStateKey];
}
importMethod(methodName, file, pluginState) {
if (!pluginState.selectedMethods[methodName]) {
const style = this.style,
libraryDirectory = this.libraryDirectory;
var transformedMethodName = this.camel2UnderlineComponentName // eslint-disable-line
? transCamel(methodName, '_') : this.camel2DashComponentName ? transCamel(methodName, '-') : methodName;
var path = winPath(this.customName ? this.customName(transformedMethodName, file) : (0, _path.join)(this.libraryName, libraryDirectory, transformedMethodName, this.fileName) // eslint-disable-line
);
pluginState.selectedMethods[methodName] = this.transformToDefaultImport // eslint-disable-line
? (0, _helperModuleImports.addDefault)(file.path, path, {
nameHint: methodName
}) : (0, _helperModuleImports.addNamed)(file.path, methodName, path);
const transformedMethodName = this.camel2UnderlineComponentName // eslint-disable-line
? transCamel(methodName, '_') : this.camel2DashComponentName ? transCamel(methodName, '-') : methodName;
const path = winPath(this.customName ? this.customName(transformedMethodName, file) : (0, _path.join)(this.libraryName, libraryDirectory, transformedMethodName, this.fileName) // eslint-disable-line
);
pluginState.selectedMethods[methodName] = this.transformToDefaultImport // eslint-disable-line
? (0, _helperModuleImports.addDefault)(file.path, path, {
nameHint: methodName
}) : (0, _helperModuleImports.addNamed)(file.path, methodName, path);
if (this.customStyleName) {
var stylePath = winPath(this.customStyleName(transformedMethodName, file));
(0, _helperModuleImports.addSideEffect)(file.path, "".concat(stylePath));
} else if (this.styleLibraryDirectory) {
var _stylePath = winPath((0, _path.join)(this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName));
if (this.customStyleName) {
const stylePath = winPath(this.customStyleName(transformedMethodName, file));
(0, _helperModuleImports.addSideEffect)(file.path, `${stylePath}`);
} else if (this.styleLibraryDirectory) {
const stylePath = winPath((0, _path.join)(this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName));
(0, _helperModuleImports.addSideEffect)(file.path, `${stylePath}`);
} else if (style === true) {
(0, _helperModuleImports.addSideEffect)(file.path, `${path}/style`);
} else if (style === 'css') {
(0, _helperModuleImports.addSideEffect)(file.path, `${path}/style/css`);
} else if (typeof style === 'function') {
const stylePath = style(path, file);
(0, _helperModuleImports.addSideEffect)(file.path, "".concat(_stylePath));
} else if (style === true) {
(0, _helperModuleImports.addSideEffect)(file.path, "".concat(path, "/style"));
} else if (style === 'css') {
(0, _helperModuleImports.addSideEffect)(file.path, "".concat(path, "/style/css"));
} else if (typeof style === 'function') {
var _stylePath2 = style(path, file);
if (_stylePath2) {
(0, _helperModuleImports.addSideEffect)(file.path, _stylePath2);
}
if (stylePath) {
(0, _helperModuleImports.addSideEffect)(file.path, stylePath);
}
}
return _objectSpread({}, pluginState.selectedMethods[methodName]);
}
}, {
key: "buildExpressionHandler",
value: function buildExpressionHandler(node, props, path, state) {
var _this = this;
var file = path && path.hub && path.hub.file || state && state.file;
var types = this.types;
var pluginState = this.getPluginState(state);
props.forEach(function (prop) {
if (!types.isIdentifier(node[prop])) return;
return _objectSpread({}, pluginState.selectedMethods[methodName]);
}
if (pluginState.specified[node[prop].name] && types.isImportSpecifier(path.scope.getBinding(node[prop].name).path)) {
node[prop] = _this.importMethod(pluginState.specified[node[prop].name], file, pluginState); // eslint-disable-line
buildExpressionHandler(node, props, path, state) {
const file = path && path.hub && path.hub.file || state && state.file;
const types = this.types;
const pluginState = this.getPluginState(state);
props.forEach(prop => {
if (!types.isIdentifier(node[prop])) return;
if (pluginState.specified[node[prop].name] && types.isImportSpecifier(path.scope.getBinding(node[prop].name).path)) {
node[prop] = this.importMethod(pluginState.specified[node[prop].name], file, pluginState); // eslint-disable-line
}
});
}
buildDeclaratorHandler(node, prop, path, state) {
const file = path && path.hub && path.hub.file || state && state.file;
const types = this.types;
const pluginState = this.getPluginState(state);
const checkScope = targetNode => pluginState.specified[targetNode.name] && // eslint-disable-line
path.scope.hasBinding(targetNode.name) && // eslint-disable-line
path.scope.getBinding(targetNode.name).path.type === 'ImportSpecifier'; // eslint-disable-line
if (types.isIdentifier(node[prop]) && checkScope(node[prop])) {
node[prop] = this.importMethod(pluginState.specified[node[prop].name], file, pluginState); // eslint-disable-line
} else if (types.isSequenceExpression(node[prop])) {
node[prop].expressions.forEach((expressionNode, index) => {
if (types.isIdentifier(expressionNode) && checkScope(expressionNode)) {
node[prop].expressions[index] = this.importMethod(pluginState.specified[expressionNode.name], file, pluginState); // eslint-disable-line
}
});
}
}, {
key: "buildDeclaratorHandler",
value: function buildDeclaratorHandler(node, prop, path, state) {
var _this2 = this;
}
var file = path && path.hub && path.hub.file || state && state.file;
var types = this.types;
var pluginState = this.getPluginState(state);
ProgramEnter(path, state) {
const pluginState = this.getPluginState(state);
pluginState.specified = Object.create(null);
pluginState.libraryObjs = Object.create(null);
pluginState.selectedMethods = Object.create(null);
pluginState.pathsToRemove = [];
}
var checkScope = function checkScope(targetNode) {
return pluginState.specified[targetNode.name] && // eslint-disable-line
path.scope.hasBinding(targetNode.name) && // eslint-disable-line
path.scope.getBinding(targetNode.name).path.type === 'ImportSpecifier';
}; // eslint-disable-line
ProgramExit(path, state) {
this.getPluginState(state).pathsToRemove.forEach(p => !p.removed && p.remove());
}
ImportDeclaration(path, state) {
const node = path.node; // path maybe removed by prev instances.
if (types.isIdentifier(node[prop]) && checkScope(node[prop])) {
node[prop] = this.importMethod(pluginState.specified[node[prop].name], file, pluginState); // eslint-disable-line
} else if (types.isSequenceExpression(node[prop])) {
node[prop].expressions.forEach(function (expressionNode, index) {
if (types.isIdentifier(expressionNode) && checkScope(expressionNode)) {
node[prop].expressions[index] = _this2.importMethod(pluginState.specified[expressionNode.name], file, pluginState); // eslint-disable-line
}
});
}
}
}, {
key: "ProgramEnter",
value: function ProgramEnter(path, state) {
var pluginState = this.getPluginState(state);
pluginState.specified = Object.create(null);
pluginState.libraryObjs = Object.create(null);
pluginState.selectedMethods = Object.create(null);
pluginState.pathsToRemove = [];
}
}, {
key: "ProgramExit",
value: function ProgramExit(path, state) {
this.getPluginState(state).pathsToRemove.forEach(function (p) {
return !p.removed && p.remove();
if (!node) return;
const value = node.source.value;
const libraryName = this.libraryName;
const types = this.types;
const pluginState = this.getPluginState(state);
if (value === libraryName) {
node.specifiers.forEach(spec => {
if (types.isImportSpecifier(spec)) {
pluginState.specified[spec.local.name] = spec.imported.name;
} else {
pluginState.libraryObjs[spec.local.name] = true;
}
});
pluginState.pathsToRemove.push(path);
}
}, {
key: "ImportDeclaration",
value: function ImportDeclaration(path, state) {
var node = path.node; // path maybe removed by prev instances.
}
if (!node) return;
var value = node.source.value;
var libraryName = this.libraryName;
var types = this.types;
var pluginState = this.getPluginState(state);
CallExpression(path, state) {
const node = path.node;
const file = path && path.hub && path.hub.file || state && state.file;
const name = node.callee.name;
const types = this.types;
const pluginState = this.getPluginState(state);
if (value === libraryName) {
node.specifiers.forEach(function (spec) {
if (types.isImportSpecifier(spec)) {
pluginState.specified[spec.local.name] = spec.imported.name;
} else {
pluginState.libraryObjs[spec.local.name] = true;
}
});
pluginState.pathsToRemove.push(path);
if (types.isIdentifier(node.callee)) {
if (pluginState.specified[name]) {
node.callee = this.importMethod(pluginState.specified[name], file, pluginState);
}
}
}, {
key: "CallExpression",
value: function CallExpression(path, state) {
var _this3 = this;
var node = path.node;
var file = path && path.hub && path.hub.file || state && state.file;
var name = node.callee.name;
var types = this.types;
var pluginState = this.getPluginState(state);
node.arguments = node.arguments.map(arg => {
const argName = arg.name;
if (types.isIdentifier(node.callee)) {
if (pluginState.specified[name]) {
node.callee = this.importMethod(pluginState.specified[name], file, pluginState);
}
if (pluginState.specified[argName] && path.scope.hasBinding(argName) && path.scope.getBinding(argName).path.type === 'ImportSpecifier') {
return this.importMethod(pluginState.specified[argName], file, pluginState);
}
node.arguments = node.arguments.map(function (arg) {
var argName = arg.name;
return arg;
});
}
if (pluginState.specified[argName] && path.scope.hasBinding(argName) && path.scope.getBinding(argName).path.type === 'ImportSpecifier') {
return _this3.importMethod(pluginState.specified[argName], file, pluginState);
}
MemberExpression(path, state) {
const node = path.node;
const file = path && path.hub && path.hub.file || state && state.file;
const pluginState = this.getPluginState(state); // multiple instance check.
return arg;
});
}
}, {
key: "MemberExpression",
value: function MemberExpression(path, state) {
var node = path.node;
var file = path && path.hub && path.hub.file || state && state.file;
var pluginState = this.getPluginState(state); // multiple instance check.
if (!node.object || !node.object.name) return;
if (!node.object || !node.object.name) return;
if (pluginState.libraryObjs[node.object.name]) {
// antd.Button -> _Button
path.replaceWith(this.importMethod(node.property.name, file, pluginState));
} else if (pluginState.specified[node.object.name] && path.scope.hasBinding(node.object.name)) {
var _path$scope$getBindin = path.scope.getBinding(node.object.name),
if (pluginState.libraryObjs[node.object.name]) {
// antd.Button -> _Button
path.replaceWith(this.importMethod(node.property.name, file, pluginState));
} else if (pluginState.specified[node.object.name] && path.scope.hasBinding(node.object.name)) {
const _path$scope$getBindin = path.scope.getBinding(node.object.name),
scope = _path$scope$getBindin.scope; // global variable in file scope
if (scope.path.parent.type === 'File') {
node.object = this.importMethod(pluginState.specified[node.object.name], file, pluginState);
}
if (scope.path.parent.type === 'File') {
node.object = this.importMethod(pluginState.specified[node.object.name], file, pluginState);
}
}
}, {
key: "Property",
value: function Property(path, state) {
var node = path.node;
this.buildDeclaratorHandler(node, 'value', path, state);
}
}, {
key: "VariableDeclarator",
value: function VariableDeclarator(path, state) {
var node = path.node;
this.buildDeclaratorHandler(node, 'init', path, state);
}
}, {
key: "ArrayExpression",
value: function ArrayExpression(path, state) {
var node = path.node;
var props = node.elements.map(function (_, index) {
return index;
});
this.buildExpressionHandler(node.elements, props, path, state);
}
}, {
key: "LogicalExpression",
value: function LogicalExpression(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['left', 'right'], path, state);
}
}, {
key: "ConditionalExpression",
value: function ConditionalExpression(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['test', 'consequent', 'alternate'], path, state);
}
}, {
key: "IfStatement",
value: function IfStatement(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['test'], path, state);
this.buildExpressionHandler(node.test, ['left', 'right'], path, state);
}
}, {
key: "ExpressionStatement",
value: function ExpressionStatement(path, state) {
var node = path.node;
var types = this.types;
}
if (types.isAssignmentExpression(node.expression)) {
this.buildExpressionHandler(node.expression, ['right'], path, state);
}
Property(path, state) {
const node = path.node;
this.buildDeclaratorHandler(node, 'value', path, state);
}
VariableDeclarator(path, state) {
const node = path.node;
this.buildDeclaratorHandler(node, 'init', path, state);
}
ArrayExpression(path, state) {
const node = path.node;
const props = node.elements.map((_, index) => index);
this.buildExpressionHandler(node.elements, props, path, state);
}
LogicalExpression(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['left', 'right'], path, state);
}
ConditionalExpression(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['test', 'consequent', 'alternate'], path, state);
}
IfStatement(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['test'], path, state);
this.buildExpressionHandler(node.test, ['left', 'right'], path, state);
}
ExpressionStatement(path, state) {
const node = path.node;
const types = this.types;
if (types.isAssignmentExpression(node.expression)) {
this.buildExpressionHandler(node.expression, ['right'], path, state);
}
}, {
key: "ReturnStatement",
value: function ReturnStatement(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['argument'], path, state);
}
}, {
key: "ExportDefaultDeclaration",
value: function ExportDefaultDeclaration(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['declaration'], path, state);
}
}, {
key: "BinaryExpression",
value: function BinaryExpression(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['left', 'right'], path, state);
}
}, {
key: "NewExpression",
value: function NewExpression(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['callee'], path, state);
var argumentsProps = node.arguments.map(function (_, index) {
return index;
});
this.buildExpressionHandler(node.arguments, argumentsProps, path, state);
}
}, {
key: "SwitchStatement",
value: function SwitchStatement(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['discriminant'], path, state);
}
}, {
key: "SwitchCase",
value: function SwitchCase(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['test'], path, state);
}
}, {
key: "ClassDeclaration",
value: function ClassDeclaration(path, state) {
var node = path.node;
this.buildExpressionHandler(node, ['superClass'], path, state);
}
}]);
return Plugin;
}();
}
ReturnStatement(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['argument'], path, state);
}
ExportDefaultDeclaration(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['declaration'], path, state);
}
BinaryExpression(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['left', 'right'], path, state);
}
NewExpression(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['callee'], path, state);
const argumentsProps = node.arguments.map((_, index) => index);
this.buildExpressionHandler(node.arguments, argumentsProps, path, state);
}
SwitchStatement(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['discriminant'], path, state);
}
SwitchCase(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['test'], path, state);
}
ClassDeclaration(path, state) {
const node = path.node;
this.buildExpressionHandler(node, ['superClass'], path, state);
}
}
exports.default = Plugin;
{
"name": "babel-plugin-import",
"version": "1.13.4",
"version": "1.13.5",
"description": "Component modular import plugin for babel.",

@@ -48,3 +48,3 @@ "repository": {

"eslint-plugin-prettier": "^3.1.3",
"father-build": "^1.21.2",
"father-build": "^1.22.1",
"husky": "^4.2.5",

@@ -57,7 +57,2 @@ "lint-staged": "^10.2.8",

},
"babel": {
"presets": [
"umi"
]
},
"files": [

@@ -70,5 +65,4 @@ "src",

"dependencies": {
"@babel/helper-module-imports": "^7.0.0",
"@babel/runtime": "^7.0.0"
"@babel/helper-module-imports": "^7.0.0"
}
}
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