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.2 to 1.13.3-beta.1

149

lib/index.js

@@ -1,110 +0,75 @@

"use strict";
var _interopRequireDefault = require("/Users/chencheng/Code/github.com/ant-design/babel-plugin-import/node_modules/babel-preset-umi/node_modules/@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _toConsumableArray2 = _interopRequireDefault(require("/Users/chencheng/Code/github.com/ant-design/babel-plugin-import/node_modules/babel-preset-umi/node_modules/@babel/runtime/helpers/toConsumableArray"));
var _assert = _interopRequireDefault(require("assert"));
var _Plugin = _interopRequireDefault(require("./Plugin"));
function _default(_ref) {
var types = _ref.types;
var plugins = null; // Only for test
// eslint-disable-next-line no-underscore-dangle
global.__clearBabelAntdPlugin = function () {
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _assert = require('assert'); var _assert2 = _interopRequireDefault(_assert);
var _Plugin = require('./Plugin'); var _Plugin2 = _interopRequireDefault(_Plugin);
exports. default = function({types}) {
let plugins = null;
global.__clearBabelAntdPlugin = () => {
plugins = null;
};
function applyInstance(method, args, context) {
// eslint-disable-next-line no-restricted-syntax
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var plugin = _step.value;
if (plugin[method]) {
plugin[method].apply(plugin, [].concat((0, _toConsumableArray2.default)(args), [context]));
}
for (const plugin of plugins) {
if (plugin[method]) {
plugin[method].apply(plugin, [...args, context]);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
var Program = {
enter: function enter(path, _ref2) {
var _ref2$opts = _ref2.opts,
opts = _ref2$opts === void 0 ? {} : _ref2$opts;
// Init plugin instances once.
const Program = {
enter(path, {opts = {}}) {
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;
(0, _assert.default)(libraryName, 'libraryName should be provided');
return new _Plugin.default(libraryName, libraryDirectory, style, styleLibraryDirectory, customStyleName, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index);
plugins = opts.map(({
libraryName,
libraryDirectory,
style,
styleLibraryDirectory,
customStyleName,
camel2DashComponentName,
camel2UnderlineComponentName,
fileName,
customName,
transformToDefaultImport
}, index) => {
_assert2.default.call(void 0, libraryName, "libraryName should be provided");
return new (0, _Plugin2.default)(libraryName, libraryDirectory, style, styleLibraryDirectory, customStyleName, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index);
});
} else {
(0, _assert.default)(opts.libraryName, 'libraryName should be provided');
plugins = [new _Plugin.default(opts.libraryName, opts.libraryDirectory, opts.style, opts.styleLibraryDirectory, opts.customStyleName, opts.camel2DashComponentName, opts.camel2UnderlineComponentName, opts.fileName, opts.customName, opts.transformToDefaultImport, types)];
_assert2.default.call(void 0, opts.libraryName, "libraryName should be provided");
plugins = [
new (0, _Plugin2.default)(opts.libraryName, opts.libraryDirectory, opts.style, opts.styleLibraryDirectory, opts.customStyleName, opts.camel2DashComponentName, opts.camel2UnderlineComponentName, opts.fileName, opts.customName, opts.transformToDefaultImport, types)
];
}
}
applyInstance('ProgramEnter', arguments, this); // eslint-disable-line
applyInstance("ProgramEnter", arguments, this);
},
exit: function exit() {
applyInstance('ProgramExit', arguments, this); // eslint-disable-line
exit() {
applyInstance("ProgramExit", arguments, this);
}
};
var methods = ['ImportDeclaration', 'CallExpression', 'MemberExpression', 'Property', 'VariableDeclarator', 'ArrayExpression', 'LogicalExpression', 'ConditionalExpression', 'IfStatement', 'ExpressionStatement', 'ReturnStatement', 'ExportDefaultDeclaration', 'BinaryExpression', 'NewExpression', 'ClassDeclaration', 'SwitchStatement', 'SwitchCase'];
var ret = {
visitor: {
Program: Program
}
}; // eslint-disable-next-line no-restricted-syntax
var _loop = function _loop() {
var method = _methods[_i];
ret.visitor[method] = function () {
// eslint-disable-line
applyInstance(method, arguments, ret.visitor); // eslint-disable-line
const methods = [
"ImportDeclaration",
"CallExpression",
"MemberExpression",
"Property",
"VariableDeclarator",
"ArrayExpression",
"LogicalExpression",
"ConditionalExpression",
"IfStatement",
"ExpressionStatement",
"ReturnStatement",
"ExportDefaultDeclaration",
"BinaryExpression",
"NewExpression",
"ClassDeclaration",
"SwitchStatement",
"SwitchCase"
];
const ret = {
visitor: {Program}
};
for (const method of methods) {
ret.visitor[method] = function() {
applyInstance(method, arguments, ret.visitor);
};
};
for (var _i = 0, _methods = methods; _i < _methods.length; _i++) {
_loop();
}
return ret;
}
}

@@ -1,55 +0,22 @@

"use strict";
var _interopRequireDefault = require("/Users/chencheng/Code/github.com/ant-design/babel-plugin-import/node_modules/babel-preset-umi/node_modules/@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("/Users/chencheng/Code/github.com/ant-design/babel-plugin-import/node_modules/babel-preset-umi/node_modules/@babel/runtime/helpers/defineProperty"));
var _classCallCheck2 = _interopRequireDefault(require("/Users/chencheng/Code/github.com/ant-design/babel-plugin-import/node_modules/babel-preset-umi/node_modules/@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("/Users/chencheng/Code/github.com/ant-design/babel-plugin-import/node_modules/babel-preset-umi/node_modules/@babel/runtime/helpers/createClass"));
var _path = require("path");
var _helperModuleImports = require("@babel/helper-module-imports");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
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; }
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _path = require('path');
var _helpermoduleimports = require('@babel/helper-module-imports');
function transCamel(_str, symbol) {
var str = _str[0].toLowerCase() + _str.substr(1);
return str.replace(/([A-Z])/g, function ($1) {
return "".concat(symbol).concat($1.toLowerCase());
});
const str = _str[0].toLowerCase() + _str.substr(1);
return str.replace(/([A-Z])/g, ($1) => `${symbol}${$1.toLowerCase()}`);
}
function winPath(path) {
return path.replace(/\\/g, '/');
function winPath(path2) {
return path2.replace(/\\/g, "/");
}
function normalizeCustomName(originCustomName) {
// If set to a string, treat it as a JavaScript source file path.
if (typeof originCustomName === 'string') {
// eslint-disable-next-line import/no-dynamic-require
var customNameExports = require(originCustomName);
return typeof customNameExports === 'function' ? customNameExports : customNameExports.default;
if (typeof originCustomName === "string") {
const customNameExports = require(originCustomName);
return typeof customNameExports === "function" ? customNameExports : customNameExports.default;
}
return originCustomName;
}
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;
this.libraryDirectory = typeof libraryDirectory === 'undefined' ? 'lib' : libraryDirectory;
this.camel2DashComponentName = typeof camel2DashComponentName === 'undefined' ? true : camel2DashComponentName;
this.libraryDirectory = typeof libraryDirectory === "undefined" ? "lib" : libraryDirectory;
this.camel2DashComponentName = typeof camel2DashComponentName === "undefined" ? true : camel2DashComponentName;
this.camel2UnderlineComponentName = camel2UnderlineComponentName;

@@ -59,280 +26,190 @@ this.style = style || false;

this.customStyleName = normalizeCustomName(customStyleName);
this.fileName = fileName || '';
this.fileName = fileName || "";
this.customName = normalizeCustomName(customName);
this.transformToDefaultImport = typeof transformToDefaultImport === 'undefined' ? true : transformToDefaultImport;
this.transformToDefaultImport = typeof transformToDefaultImport === "undefined" ? true : transformToDefaultImport;
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
}
return state[this.pluginStateKey];
getPluginState(state) {
if (!state[this.pluginStateKey]) {
state[this.pluginStateKey] = {};
}
}, {
key: "importMethod",
value: function importMethod(methodName, file, pluginState) {
if (!pluginState.selectedMethods[methodName]) {
var 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);
if (this.customStyleName) {
var stylePath = winPath(this.customStyleName(transformedMethodName));
(0, _helperModuleImports.addSideEffect)(file.path, "".concat(stylePath));
} else if (this.styleLibraryDirectory) {
var _stylePath = winPath((0, _path.join)(this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName));
(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);
}
return state[this.pluginStateKey];
}
importMethod(methodName, file, pluginState) {
if (!pluginState.selectedMethods[methodName]) {
const {style, libraryDirectory} = this;
const transformedMethodName = this.camel2UnderlineComponentName ? transCamel(methodName, "_") : this.camel2DashComponentName ? transCamel(methodName, "-") : methodName;
const path2 = winPath(this.customName ? this.customName(transformedMethodName, file) : _path.join.call(void 0, this.libraryName, libraryDirectory, transformedMethodName, this.fileName));
pluginState.selectedMethods[methodName] = this.transformToDefaultImport ? _helpermoduleimports.addDefault.call(void 0, file.path, path2, {nameHint: methodName}) : _helpermoduleimports.addNamed.call(void 0, file.path, methodName, path2);
if (this.customStyleName) {
const stylePath = winPath(this.customStyleName(transformedMethodName));
_helpermoduleimports.addSideEffect.call(void 0, file.path, `${stylePath}`);
} else if (this.styleLibraryDirectory) {
const stylePath = winPath(_path.join.call(void 0, this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName));
_helpermoduleimports.addSideEffect.call(void 0, file.path, `${stylePath}`);
} else if (style === true) {
_helpermoduleimports.addSideEffect.call(void 0, file.path, `${path2}/style`);
} else if (style === "css") {
_helpermoduleimports.addSideEffect.call(void 0, file.path, `${path2}/style/css`);
} else if (typeof style === "function") {
const stylePath = style(path2, file);
if (stylePath) {
_helpermoduleimports.addSideEffect.call(void 0, 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;
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
return {...pluginState.selectedMethods[methodName]};
}
buildExpressionHandler(node, props, path2, state) {
const file = path2 && path2.hub && path2.hub.file || state && state.file;
const {types} = this;
const pluginState = this.getPluginState(state);
props.forEach((prop) => {
if (!types.isIdentifier(node[prop]))
return;
if (pluginState.specified[node[prop].name] && types.isImportSpecifier(path2.scope.getBinding(node[prop].name).path)) {
node[prop] = this.importMethod(pluginState.specified[node[prop].name], file, pluginState);
}
});
}
buildDeclaratorHandler(node, prop, path2, state) {
const file = path2 && path2.hub && path2.hub.file || state && state.file;
const {types} = this;
const pluginState = this.getPluginState(state);
const checkScope = (targetNode) => pluginState.specified[targetNode.name] && path2.scope.hasBinding(targetNode.name) && path2.scope.getBinding(targetNode.name).path.type === "ImportSpecifier";
if (types.isIdentifier(node[prop]) && checkScope(node[prop])) {
node[prop] = this.importMethod(pluginState.specified[node[prop].name], file, pluginState);
} 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);
}
});
}
}, {
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);
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
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();
}
ProgramEnter(path2, state) {
const pluginState = this.getPluginState(state);
pluginState.specified = Object.create(null);
pluginState.libraryObjs = Object.create(null);
pluginState.selectedMethods = Object.create(null);
pluginState.pathsToRemove = [];
}
ProgramExit(path2, state) {
this.getPluginState(state).pathsToRemove.forEach((p) => !p.removed && p.remove());
}
ImportDeclaration(path2, state) {
const {node} = path2;
if (!node)
return;
const {value} = node.source;
const {libraryName} = this;
const {types} = this;
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(path2);
}
}, {
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);
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);
}
CallExpression(path2, state) {
const {node} = path2;
const file = path2 && path2.hub && path2.hub.file || state && state.file;
const {name} = node.callee;
const {types} = this;
const pluginState = this.getPluginState(state);
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);
if (types.isIdentifier(node.callee)) {
if (pluginState.specified[name]) {
node.callee = this.importMethod(pluginState.specified[name], file, pluginState);
}
node.arguments = node.arguments.map((arg) => {
const {name: argName} = arg;
if (pluginState.specified[argName] && path2.scope.hasBinding(argName) && path2.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;
if (pluginState.specified[argName] && path.scope.hasBinding(argName) && path.scope.getBinding(argName).path.type === 'ImportSpecifier') {
return _this3.importMethod(pluginState.specified[argName], file, pluginState);
}
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 (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),
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);
}
return arg;
});
}
MemberExpression(path2, state) {
const {node} = path2;
const file = path2 && path2.hub && path2.hub.file || state && state.file;
const pluginState = this.getPluginState(state);
if (!node.object || !node.object.name)
return;
if (pluginState.libraryObjs[node.object.name]) {
path2.replaceWith(this.importMethod(node.property.name, file, pluginState));
} else if (pluginState.specified[node.object.name] && path2.scope.hasBinding(node.object.name)) {
const {scope} = path2.scope.getBinding(node.object.name);
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);
}
Property(path2, state) {
const {node} = path2;
this.buildDeclaratorHandler(node, "value", path2, state);
}
VariableDeclarator(path2, state) {
const {node} = path2;
this.buildDeclaratorHandler(node, "init", path2, state);
}
ArrayExpression(path2, state) {
const {node} = path2;
const props = node.elements.map((_, index) => index);
this.buildExpressionHandler(node.elements, props, path2, state);
}
LogicalExpression(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["left", "right"], path2, state);
}
ConditionalExpression(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["test", "consequent", "alternate"], path2, state);
}
IfStatement(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["test"], path2, state);
this.buildExpressionHandler(node.test, ["left", "right"], path2, state);
}
ExpressionStatement(path2, state) {
const {node} = path2;
const {types} = this;
if (types.isAssignmentExpression(node.expression)) {
this.buildExpressionHandler(node.expression, ["right"], path2, 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);
}
}
}, {
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', 'arguments'], 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;
}();
exports.default = Plugin;
}
ReturnStatement(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["argument"], path2, state);
}
ExportDefaultDeclaration(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["declaration"], path2, state);
}
BinaryExpression(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["left", "right"], path2, state);
}
NewExpression(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["callee", "arguments"], path2, state);
}
SwitchStatement(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["discriminant"], path2, state);
}
SwitchCase(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["test"], path2, state);
}
ClassDeclaration(path2, state) {
const {node} = path2;
this.buildExpressionHandler(node, ["superClass"], path2, state);
}
} exports.default = Plugin;
{
"name": "babel-plugin-import",
"version": "1.13.2",
"version": "1.13.3-beta.1",
"description": "Component modular import plugin for babel.",

@@ -11,9 +11,9 @@ "repository": {

"scripts": {
"build": "umi-tools build",
"test": "umi-tools test --coverage",
"debug": "umi-tools test",
"build": "father-next",
"test": "umi-test --coverage",
"debug": "umi-test",
"lint": "eslint --ext .js src",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"prepack": "npm run build",
"prepublishOnly": "npm run build && np --no-cleanup --yolo --no-publish"
"prepublishOnly": "npm run build && np --no-cleanup --yolo --no-publish --any-branch"
},

@@ -40,2 +40,3 @@ "husky": {

"@babel/preset-react": "^7.0.0",
"@umijs/test": "^3.2.28",
"babel-core": "^7.0.0-0",

@@ -49,2 +50,3 @@ "babel-preset-umi": "^1.0.0",

"eslint-plugin-prettier": "^3.1.3",
"father-next": "^3.0.0-alpha.3",
"husky": "^4.2.5",

@@ -55,4 +57,3 @@ "lint-staged": "^10.2.8",

"prettier": "^2.0.5",
"react-toolbox": "^1.2.5",
"umi-tools": "^0.4.0"
"react-toolbox": "^1.2.5"
},

@@ -59,0 +60,0 @@ "babel": {

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