Eslint import error without jsx

I am trying to import jsx files in es6 without requiring the .jsx extension:

import LoginErrorDialog from './LoginErrorDialogView'; 

Not:

 import LoginErrorDialog from './LoginErrorDialogView.jsx'; 

So far, I have webpack to import this way successfully:

 export default { entry: './src/ui/js/app.js', output: { publicPath: '/', filename: 'bundle.js' }, resolve: { extensions: ['.js', '.jsx'], 

Eslint ( esw webpack.config.* ./ --color --ext .js --ext .jsx ) is still a bug.

Unable to resolve path to module './LoginView' import/no-unresolved

Any ideas?

+6
source share
1 answer

I had the same problem and fixed the addition of additional configuration in my .eslint.

Extends the add property:

 "plugin:import/react" 

Setting the add property:

 "import/resolver": { "node": { "extensions": [".js",".jsx"] } } 

Your .eslint will look like:

 { "extends": [ ... "plugin:import/react", ... ], ... "settings": { "import/resolver": { "node": { "extensions": [".js",".jsx"] } } }, ... } 
+4
source

Source: https://habr.com/ru/post/1015021/


All Articles