You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even if Facebook / Dan Abramov doesn't see a huge distinction between .js and .jsx...
The distinction between .js and .jsx files was useful before Babel, but it’s not that useful anymore.
There are other syntax extensions (e.g. Flow). What would you call a JS file that uses Flow? .flow.js? What about JSX file that uses Flow? .flow.jsx? What about some other experimental syntax? .flow.stage-1.jsx?
Most editors are configurable so you can tell them to use a JSX-capable syntax scheme for .js files. Since JSX (or Flow) are strict supersets of JS, I don’t see this as an issue.
Thanks, but no. At Airbnb we believe that only JavaScript should ever go in .js files. JSX is not standard JS, and is not likely to ever be - if that changes, then our stance may as well.
You never need extensions whether it's .js or .jsx - and in fact, our linter config requires (or will soon require) that you omit file extensions in all cases.
The reason to differentiate is the same reason we only use stage 3 and above proposals: if it's not standard, it is not javascript.
In that comment on the react repo, "What people are actually doing… that's may not match." - which is indeed the case. It's far more common to put JSX in .jsx files in my experience, and regardless, that's what this guide will continue to encourage.
Even if Facebook / Dan Abramov doesn't see a huge distinction between
.js
and.jsx
...create-react-app#87
...Airbnb does...
airbnb/javascript#985
...and so since we're following the
airbnb/javascript
style guide, I think we should follow Airbnb's lead here.The text was updated successfully, but these errors were encountered: