Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
eslint-import-resolver-babel-module
Advanced tools
babel-plugin-module-resolver resolver for eslint-plugin-import
The eslint-import-resolver-babel-module package is an ESLint plugin that allows you to resolve import paths using Babel's module resolver. This is particularly useful for projects that use Babel to transform module paths, as it ensures that ESLint can correctly resolve and lint these paths.
Custom Module Resolution
This feature allows you to configure ESLint to use Babel's module resolver for resolving import paths. This ensures that ESLint can correctly resolve paths that are transformed by Babel.
{
"settings": {
"import/resolver": {
"babel-module": {}
}
}
}
Alias Configuration
This feature allows you to define custom aliases for module paths. This is useful for simplifying import statements and making your codebase more maintainable.
{
"settings": {
"import/resolver": {
"babel-module": {
"alias": {
"@components": "./src/components",
"@utils": "./src/utils"
}
}
}
}
}
Custom Extensions
This feature allows you to specify custom file extensions that should be resolved by Babel's module resolver. This is useful for projects that use multiple file types, such as JavaScript and TypeScript.
{
"settings": {
"import/resolver": {
"babel-module": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
}
The eslint-import-resolver-webpack package is an ESLint plugin that allows you to resolve import paths using Webpack's module resolver. This is useful for projects that use Webpack to bundle their code, as it ensures that ESLint can correctly resolve and lint these paths. Compared to eslint-import-resolver-babel-module, this package is more suitable for projects that rely heavily on Webpack for module resolution.
The eslint-import-resolver-alias package is an ESLint plugin that allows you to resolve import paths using custom alias configurations. This is useful for projects that use custom aliases for module paths, similar to eslint-import-resolver-babel-module. However, it does not rely on Babel and is more lightweight, making it a good choice for projects that do not use Babel for module resolution.
A babel-plugin-module-resolver resolver for eslint-plugin-import
npm install --save-dev eslint-plugin-import eslint-import-resolver-babel-module
Inside your .eslintrc
file, pass this resolver to eslint-plugin-import
:
"settings": {
"import/resolver": {
"babel-module": {}
}
}
And see babel-plugin-module-resolver to know how to configure your aliases.
{
"extends": "airbnb",
"rules": {
"comma-dangle": 0
},
"settings": {
"import/resolver": {
"babel-module": {}
}
}
}
Some babel plugins like babel-plugin-import-directory or babel-plugin-wildcard allow to import directories (i.e. each file inside a directory) as an object. In order to support this, you can activate the allowExistingDirectories
option as follows:
"settings": {
"import/resolver": {
"babel-module": { allowExistingDirectories: true }
}
}
Now when you import a directory like this, the ESLint plugin won't complain and recognize the existing directory:
import * as Items from './dir';
MIT, see LICENSE.md for details.
FAQs
babel-plugin-module-resolver resolver for eslint-plugin-import
We found that eslint-import-resolver-babel-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.