Skip to content

Recommend using .jsx extension for React components, rather than .js - #374

Merged
goatslacker merged 1 commit into
masterfrom
horace/jsx-ext-for-react
Jun 25, 2015
Merged

Recommend using .jsx extension for React components, rather than .js#374
goatslacker merged 1 commit into
masterfrom
horace/jsx-ext-for-react

Conversation

@horaceko

Copy link
Copy Markdown
Collaborator

Recommending that JSX files use the .js file extension is to imply that JS and JSX are interchangeable, which they are not. We should clearly distinguish between the two.

I also took the liberty of cleaning up some of the copy for consistency and grammar.

to: @alvinsng @spikebrehm @justjake

@spikebrehm

Copy link
Copy Markdown
Collaborator

👍 thank you

@justjake

Copy link
Copy Markdown
Collaborator

LGTM

goatslacker added a commit that referenced this pull request Jun 25, 2015
Recommend using .jsx extension for React components, rather than .js
@goatslacker
goatslacker merged commit 38d2282 into master Jun 25, 2015
@goatslacker
goatslacker deleted the horace/jsx-ext-for-react branch June 25, 2015 19:02
@alvinsng

Copy link
Copy Markdown
Contributor

Ah for context the main argument was from #331 (comment)

@nkbt

nkbt commented Jun 25, 2015 via email

Copy link
Copy Markdown

@ljharb

ljharb commented Jun 25, 2015

Copy link
Copy Markdown
Collaborator

JSX isn't JS because it can't run without a transpile step. ES6 is JS, because in a spec-compliant engine, it will run (spec-compliance being the critical thing here)

I think it's a very bad idea to ever have non-standard syntax in a .js file.

If you're concerned about renaming, then you could just always name it .jsx?

@nkbt

nkbt commented Jun 25, 2015

Copy link
Copy Markdown

ES7 is not part of a spec yet too and cannot run without compiler. ES6 is,
but still cannot run without compilation. Isn't CamelCasing component's
name enough to tell it is a component?

@spikebrehm

Copy link
Copy Markdown
Collaborator

JSX is different than ES6 and ES7. JSX is not JavaScript.

Isn't CamelCasing component's name enough to tell it is a component?

Nope. We PascalCase all filenames that export a class constructor, like Flux stores.

@goatslacker

Copy link
Copy Markdown
Collaborator

@nkbt reason this was merged is because Airbnb adheres to this style guide internally and this is just the pattern that we happen to follow.

We also don't write any ES2016 at the moment.

@nkbt

nkbt commented Jun 25, 2015 via email

Copy link
Copy Markdown

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

Successfully merging this pull request may close these issues.

7 participants