Unexpected use of file extension "jsx" for "./components/App.jsx" (import/extensions)
See original GitHub issueUnable to use .jsx
extension using the airbnb
ESLint config
index.jsx
import React from 'react';
import App from './components/App.jsx'; <<<<<<<<< Unexpected use of file extension "jsx"...
ReactDOM.render(
<App />,
document.getElementById('root'),
);
.eslintrc
{
"extends": "airbnb",
"env":{
"browser": true
},
"plugins": [
"react",
"jsx-a11y",
"import"
],
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
}
}
Dependencies
- “eslint”: “^4.10.0”,
- “eslint-config-airbnb”: “^16.1.0”,
- “eslint-plugin-import”: “^2.8.0”,
- “eslint-plugin-jsx-a11y”: “^6.0.2”,
- “eslint-plugin-react”: “^7.4.0”,
Unsuccessful Implementations/Examples
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
React ESLint Config "Unexpected file extension JSX"
Removed extension on import statement: import App from './components/App';. Which lead to unable to resolve error.
Read more >I had to add this to .eslintrc.js "import/extensions": [ "error...
Discussion on: How to setup a React. ... You should also add the other line jsx-filename-extension and then it also needs import resolver....
Read more >React ESLint Config “Unexpected file extension JSX” - iTecNote
Running Airbnb's Eslint Config and running into an issue using the .jsx extension. index.jsx import React from 'react'; import ReactDOM from 'react-dom'; ...
Read more >Curso Profesional de React Hooks - Platzi
Alguna sugerencia este error me lo envia el eslint Unexpected use of file extension “jsx” for “./components/App.jsx” import/extensions. Víctor VíctorMoya07.
Read more >https://unpkg.com/react-beautiful-dnd@2.2.4/.eslintrc
... to add file extensions for the following extensions "import/extensions": ... /eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md // JSX props ...
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
You’re not supposed to use the extension there. The best practice for file extensions on imported code is to omit them, which is why our config requires that as well.
@ljharb Sorry the previous question didn’t correctly state my issue. The omitting of file extensions in import statements is fine, the actual problem I was having was resolving
.jsx
with Webpack without setting up a resolve object in mywebpack.config
.In reading the documentation I was trying to find something like:
"In creating imports omit your file extensions. In the case you are using Webpack you can resolve paths using Webpack Resolve in your
webpack.config
Ex.
In doing that, the issue was resolved. I’m hoping that is the correct way to get things setup properly. Just having something to point me in the right direction would’ve been really helpful.