Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
eslint-import-resolver-alias
Advanced tools
a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias.
The eslint-import-resolver-alias package is an ESLint plugin that allows you to resolve import paths using custom alias mappings. This is particularly useful in projects where you have complex directory structures and want to simplify import statements.
Custom Alias Resolution
This feature allows you to define custom alias mappings for your project. In the example, `@components` is mapped to `./src/components` and `@utils` is mapped to `./src/utils`. This makes it easier to import modules without having to use relative paths.
{"settings":{"import/resolver":{"alias":{"map":[["@components","./src/components"],["@utils","./src/utils"]],"extensions":[".js",".jsx",".ts",".tsx"]}}}}
Support for Multiple Extensions
You can specify multiple file extensions that the resolver should consider. In this example, the resolver will look for files with `.js`, `.jsx`, `.ts`, and `.tsx` extensions when resolving the `@components` alias.
{"settings":{"import/resolver":{"alias":{"map":[["@components","./src/components"]],"extensions":[".js",".jsx",".ts",".tsx"]}}}}
The eslint-import-resolver-webpack package allows you to use your Webpack configuration to resolve import paths. This is useful if you are already using Webpack and want to maintain consistency between your Webpack and ESLint configurations. Unlike eslint-import-resolver-alias, which focuses on custom alias mappings, eslint-import-resolver-webpack leverages the entire Webpack configuration.
The eslint-import-resolver-node package resolves import paths using Node.js' resolution algorithm. This is useful for projects that follow Node.js conventions and do not require custom alias mappings. It is simpler compared to eslint-import-resolver-alias and is ideal for straightforward Node.js projects.
This is a simple Node module import resolution plugin for eslint-plugin-import
, which supports module alias.
module.exports = {
settings: {
'import/resolver': {
'alias': [
['babel-polyfill', 'babel-polyfill/dist/polyfill.min.js'],
['material-ui/DatePicker', '../custom/DatePicker'],
['material-ui', 'material-ui-ie10']
]
}
}
};
Note:
[1.0.0] - 2016-12-23
FAQs
a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias.
The npm package eslint-import-resolver-alias receives a total of 765,990 weekly downloads. As such, eslint-import-resolver-alias popularity was classified as popular.
We found that eslint-import-resolver-alias 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.