a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias
Installations
npm install eslint-import-resolver-alias
Developer
johvin
Developer Guide
Module System
CommonJS
Min. Node Version
>= 4
Typescript Support
No
Node Version
10.13.0
NPM Version
6.4.1
Statistics
181 Stars
54 Commits
10 Forks
2 Watching
1 Branches
1 Contributors
Updated on 23 Oct 2024
Bundle Size
1.72 kB
Minified
880.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
122,912,256
Last day
-11.8%
178,301
Compared to previous day
Last week
0%
1,025,045
Compared to previous week
Last month
7.6%
4,410,913
Compared to previous month
Last year
51.1%
46,136,713
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
Dev Dependencies
4
eslint-import-resolver-alias
This is a simple Node.js module import resolution plugin for eslint-plugin-import
, which supports native Node.js module resolution, module alias/mapping and custom file extensions.
Installation
Prerequisites: Node.js >=4.x and corresponding version of npm.
1npm install eslint-plugin-import eslint-import-resolver-alias --save-dev
Usage
Pass this resolver and its parameters to eslint-plugin-import
using your eslint
config file, .eslintrc
or .eslintrc.js
.
1// .eslintrc.js 2module.exports = { 3 settings: { 4 'import/resolver': { 5 alias: { 6 map: [ 7 ['babel-polyfill', 'babel-polyfill/dist/polyfill.min.js'], 8 ['helper', './utils/helper'], 9 ['material-ui/DatePicker', '../custom/DatePicker'], 10 ['material-ui', 'material-ui-ie10'] 11 ], 12 extensions: ['.ts', '.js', '.jsx', '.json'] 13 } 14 } 15 } 16};
Note:
- The alias config object contains two properties,
map
andextensions
, both of which are array types - The item of
map
array is also array type which contains 2 string- The first string represents the alias of module name or path
- The second string represents the actual module name or path
- The
map
item['helper', './utils/helper']
means that the modules which matchhelper
orhelper/*
will be resolved to./utils/helper
or./utils/helper/*
which are located relative to theprocess current working directory
(almost the project root directory). If you just want to resolvehelper
to./utils/helper
, use['^helper$', './utils/helper']
instead. See issue #3 - The order of 'material-ui/DatePicker' and 'material-ui' cannot be reversed, otherwise the alias rule 'material-ui/DatePicker' does not work
- The default value of
extensions
property is['.js', '.json', '.node']
if it is assigned to an empty array or not specified
If the extensions
property is not specified, the config object can be simplified to the map
array.
1// .eslintrc.js 2module.exports = { 3 settings: { 4 'import/resolver': { 5 alias: [ 6 ['babel-polyfill', 'babel-polyfill/dist/polyfill.min.js'], 7 ['helper', './utils/helper'], 8 ['material-ui/DatePicker', '../custom/DatePicker'], 9 ['material-ui', 'material-ui-ie10'] 10 ] 11 } 12 } 13};
When the config is not a valid object (such as true
), the resolver falls back to native Node.js module resolution.
1// .eslintrc.js 2module.exports = { 3 settings: { 4 'import/resolver': { 5 alias: true 6 } 7 } 8};
CHANGELOG
References
- eslint-plugin-import/no-extraneous-dependencies
- eslint-plugin-import/no-unresolved
- eslint-module-utils/resolve
- resolve
- eslint-import-resolver-node
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More