When I transpile my .jsx files with babel they will be renamed to have a .js extension. That’s why I usually avoid the .jsx extentions in the import path, but sometimes other contributors of my project commit code that has import statements with file extensions.
Having an eslint rule would be perfect to identify such problems.
When the rule is configured with: no-import-file-extensions: [ 2, [ '.js', '.jsx', '.json' ] ] this would be considered as problems:
import Foo from './Foo.jsx';
import lib from './lib.js';
import data from './data.json';
This would not be considered as a problem:
import Foo from './Foo';
import lib from './lib';
import data from './data';
When I transpile my
.jsxfiles with babel they will be renamed to have a.jsextension. That’s why I usually avoid the.jsxextentions in the import path, but sometimes other contributors of my project commit code that has import statements with file extensions.Having an eslint rule would be perfect to identify such problems.
When the rule is configured with:
no-import-file-extensions: [ 2, [ '.js', '.jsx', '.json' ] ]this would be considered as problems:This would not be considered as a problem: