How to make eslint resolve paths mapped in jsconfig
I was using babel-eslint as my parser in eslintrc. While searching, I realized I need to add babel-plugin-module-resolver
in babelrc to resolve the modules. In this file we can define our mapped paths which are there in our jsconfig.
Hence adding the following plugin in the babelrc file compiled my code successfully.
[
"module-resolver",
{
"alias": {
"@": "./"
}
}
]
According to the docs for eslint-import-resolver-alias, the map
property should be an array of arrays, so try this:
module.exports = {
... ,
settings: {
"import/resolver": {
alias: {
extensions: [".js"],
map: [ ["@", "."] ]
}
}
}
}
Also, double-check that you actually have eslint-import-resolver-alias
installed - it's easy to forget!