Socket
Socket
Sign inDemoInstall

@talend/babel-plugin-import-from-index

Package Overview
Dependencies
0
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 1.4.0-alpha.1

2

package.json
{
"name": "@talend/babel-plugin-import-from-index",
"version": "1.3.0",
"version": "1.4.0-alpha.1",
"description": "Transform default imports from specific path to named import from index",

@@ -5,0 +5,0 @@ "main": "src/index.js",

const PACKAGES = ['@talend/react-components', 'lodash', 'react-bootstrap', 'redux-saga'];
const hasLib = {
lodash: false,
'react-bootstrap': true,
'@talend/react-components': true,
'redux-saga': false,
};
const hasNameSupport = {
lodash: true,
'react-bootstrap': true,
'@talend/react-components': false,
'@talend/react-components': true,
'redux-saga': true,

@@ -15,4 +23,15 @@ };

function find(path) {
return PACKAGES.find(p => path.node.source.value.startsWith(p));
function find(importDeclarationPath) {
const path = importDeclarationPath.node.source.value;
const found = PACKAGES.find(p => path.startsWith(p));
if (found && hasLib[found]) {
if (path.replace(found, '').split('/').length > 3) {
console.error(`ERROR: import too deep: ${path}`);
return undefined;
}
} else if (found && path.replace(found, '').split('/').length > 2) {
console.error(`ERROR: import too deep in ${path}`);
return undefined;
}
return found;
}

@@ -19,0 +38,0 @@

@@ -64,3 +64,15 @@ import pluginTester from 'babel-plugin-tester';

},
{
code: "import DatalistComponent from '@talend/react-components/lib/Datalist';",
output: "import { Datalist as DatalistComponent } from '@talend/react-components';",
},
{
code: "import ResourcePickerComponent from '@talend/react-components/lib/ResourcePicker';",
output: "import { ResourcePicker as ResourcePickerComponent } from '@talend/react-components';"
},
{
code: "import Foo from '@talend/react-components/lib/Bar/Foo';",
output: "import Foo from '@talend/react-components/lib/Bar/Foo';"
},
],
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc