We have solution for absolute path, like this:
import MyComponent from 'src/components/MyComponent'
It is work fine for yarn start, but for yarn lint:
Unable to resolve path to module 'src/components/MyComponent' import/no-unresolved
I have solution for my other project (no RSK) with WebStorm:
1) project_dir - Mark Directory as > Resource Root
2) yarn add eslint-import-resolver-webpack -D
3) config/default.js
...
resolve: {
// We can now require('file') instead of require('file.jsx')
extensions: ['', '.js', '.jsx', '.scss'],
alias: {
src: path.resolve(__dirname, '../src')
}
},
...
4) .eslintrc.js
/* global __dirname */
const path = require('path');
...
settings: {
'import/resolver': {
webpack: {
config: path.join(__dirname, '/config', 'default.js')
}
}
}
...
How to solve this issue for RSK? Please help me.
"import/no-unresolved": "off"
(as temporary solution)
Maybe you should track this project.https://github.com/benmosher/eslint-plugin-import/issues/496
Aha~ I'm facing a same issue like you
I wanted to do absolute imports with a special prefix(So I can tell what's extenal easily). #1193
I fixed the mocha test to work with this using-webpack-aliases-in-mocha-tests/
Now I don't know how to eslint it.
I used to solve this problem by eslint-import-resolver-webpack in another project. However, it seems not working with newest webpack.
Update: you will face the test problem, too.
For me it was a case sensitivity issue. I opened the project using atom . which gave me path /desktop/apps/my_app when i go into atom and open the project manually it's actually at /Desktop/apps/my_app this gets rid of the error for me.
You have the option of this lib here
https://github.com/unconfident/eslint-import-resolver-babel-plugin-root-import
As @karanssj4 linked to, this seems to be fixed by adding the following to .eslintrc
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
If you crawled through here from google and have absolute paths when importing resulting in eslint screaming at you NOT FOUND:
Use eslint-plugin-import:
// App.js
import { ComponentName } from 'components/ComponentName';
// .eslintrc.js
module.exports = {
...
"settings": {
"import/resolver": {
"node": {
"paths": ["src"],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
},
},
}
// .eslintrc.json
"settings": {
"import/resolver": {
"node": {
"paths": ["src"],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
You can use this package https://www.npmjs.com/package/eslint-import-resolver-webpack
"settings": {
"import/resolver": "webpack"
}
"settings": {
"import/resolver": {
"node": {
"paths": ["src"],
"extensions": [".js", ".ts", ".d.ts"]
}
}
}
If you crawled through here from google and have absolute paths when importing resulting in eslint screaming at you NOT FOUND:
Use eslint-plugin-import:
// App.js import { ComponentName } from 'components/ComponentName';```
// .eslintrc.js
module.exports = {
...
"settings": {
"import/resolver": {
"node": {
"paths": ["src"],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
},
},
}
great solution thanks
I just needed
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx"]
}
},
}
馃帀
For people using eslint + webpack + single repo
// .eslintrc.js
module.exports = {
...
"settings": {
"import/resolver": {
node: {
paths: [".", "app", "lib", "functions"], //name the subproject folders here!!!
extensions: [".js", ".jsx", ".ts", ".tsx"]
}
},
},
}
and you may want some overrides if using storybook
// .eslintrc.js
module.exports = {
...
overrides: [
{
files: ["**/*.stories.tsx", "backend/**/*", "storybook/**/*"],
rules: {
"import/no-unresolved": "off",
},
},
],
}
Unable to resolve path to module 'buefy'
Working Fine for module aliases.
Most helpful comment
As @karanssj4 linked to, this seems to be fixed by adding the following to
.eslintrc