Can not resolve `index.js` under aliased folders?
See original GitHub issueEslint complains about index.js
under aliased folders import/no-unresolved
.
For exp, I have folder utils
under the path @
, it contains a lot of files and index.js
to export everything.
import { foo, bar } from '@/utils'; // eslint: `import/no-unresolved`
import { foo, bar } from '@/utils/index'; // adding `index` would work
Anything else like
import store from './store';
which is a folder and contains index.js
works fine.
Also my webpack
works fine with same settings:
// webpack settings
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': path.resolve(__dirname, './packs'),
},
},
My
.eslintrc.js
const path = require('path');
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: ['plugin:vue/essential', 'airbnb-base', 'plugin:lodash/recommended'],
plugins: [
'vue',
'lodash',
'lodash-fp',
],
settings: {
'import/resolver': {
alias: {
extensions: ['.js', '.vue', '.json'],
map: [
['@', path.resolve(__dirname, './packs')],
],
},
},
},
rules: {
'import/extensions': ['error', 'always', {
js: 'never',
vue: 'never'
}],
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: [
'state', // for vuex state
'acc', // for reduce accumulators
'e' // for e.returnvalue
]
}],
'import/no-extraneous-dependencies': ['error', {
optionalDependencies: ['test/unit/index.js']
}],
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
}
}
Dependencies in
package.json
about eslint
"babel-eslint": "^8.2.3",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-import-resolver-alias": "^1.1.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-lodash": "^2.7.0",
"eslint-plugin-lodash-fp": "^2.1.3",
"eslint-plugin-vue": "^4.5.0",
yarn list --depth 0 | grep eslint
ββ babel-eslint@8.2.3
ββ create-eslint-index@1.0.0
ββ eslint-ast-utils@1.1.0
ββ eslint-config-airbnb-base@12.1.0
ββ eslint-friendly-formatter@4.0.1
ββ eslint-import-resolver-alias@1.1.0
ββ eslint-import-resolver-node@0.3.2
ββ eslint-loader@2.0.0
ββ eslint-module-utils@2.2.0
ββ eslint-plugin-import@2.12.0
ββ eslint-plugin-lodash-fp@2.1.3
ββ eslint-plugin-lodash@2.7.0
ββ eslint-plugin-vue@4.5.0
ββ eslint-restricted-globals@0.1.1
ββ eslint-scope@3.7.1
ββ eslint-visitor-keys@1.0.0
ββ eslint@4.19.1
ββ vue-eslint-parser@2.0.3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Why create-react-app alias is not able to find index.js from ...
Common practice is to create symlinks in src folder for modules outside it and set up aliases to resolve from the src folder....
Read more >How to solve the problem with unresolved path aliases in ...
Check the index.js in the output (build) folder β Now, the path is resolved from alias (@modules/myfunction) back to absolute (.
Read more >Typescript β How to solve the problem with unresolved path ...
Check the index.js in the output (build) folder β Now, the path is resolved from alias (@modules/myfunction) back to absolute (./app/Β ...
Read more >Resolve | webpack
index.js may resolve to another file if defined in the package.json . ... Setting resolve.alias to false will tell webpack to ignore a...
Read more >Module Resolution or Import Alias: The Final Guide - Raul Melo
How can I add aliases to my imports? The idea here is to do not stitch in any specific framework/tool but to give...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I face a similar issue, but in my case, the error occurs only if the path has only one level depth.
For example,
p.s. I use typescript, not sure if this related
Any news on this?