Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ugh, yeah I should've made the React files JSX #29

Closed
jaebradley opened this issue Mar 20, 2018 · 1 comment
Closed

Ugh, yeah I should've made the React files JSX #29

jaebradley opened this issue Mar 20, 2018 · 1 comment

Comments

@jaebradley
Copy link
Contributor

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.

...Airbnb does...

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.

...and so since we're following the airbnb/javascript style guide, I think we should follow Airbnb's lead here.

@jaebradley
Copy link
Contributor Author

Actually lol I did

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant