-
Notifications
You must be signed in to change notification settings - Fork 9
.jsx or .js #6
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
Comments
I'd prefer and use .jsx it is a clear indication that jsx syntax are being used and the more specific we can be the better. The JSX syntax are not pure Javascript and therefore shouldn't be indicated they are by being in a .js file. A lot of IDEs now support the JSX file extension for syntax highlight (this was an issue before). |
@chriscartlidge most SublimeText users will also have the Babel sublime package for JS and JSX syntax highlighting, which highlights JSX even when contained within files with Personally, I think that if we architect a clear directory/file structure then it doesn't matter which extension we use, although I'd rather use one consistently for all files – since the contents of the files will change often – and in this case it makes more sense to use |
@munkychop I agree with having a clear directory file structure alleviates the issue.
Not every IDE supports this from what I recall. JSX syntax for me are far removed from what standard JS is and i'd rather that be indicated with the extension. That's my personal preference :) |
@chriscartlidge what about other future-JS features that babel can transpile, but which are still far removed from standard JS? You can't indicate those through the file extension, and they may be much less obvious than jsx when scanning a file. |
@mdboop Sorry, I should have been a little bit more specific. JSX for me is presentational markup and therefore it should be indicated that it is different from standard JS via the JSX file extension. |
Makes sense. Personally, I'd keep them all as .js since I don't think much is gained from .jsx extensions. That being said, I think we'd be fine either way. |
I do not think we should be tagging JSX files with the .jsx extension. A few reasons for this:
|
I'm also for using
|
I can see your train of thought @nickbalestra but for me Stuff like From my understand However, even if it was apart of the standard because it is presentational it is better of having a separate file extension to signify this. I'm happy to go with the collective FYI. Just putting my point across :) |
@chriscartlidge I see that and thanks for contributing to the conversation! I am just not sure I will make a differente case only because 'its defining a presentational markup', actually jsx is just a JavaScript syntax extension, and in that way jsx is closer to sweetjs then to a markup a language(to bring another example on the table sweetjs files have been also treated with simple .js extension and not with something else as far as i know). I agree that this doesn't come with an easy answer, but what will dictate the extension beeing used?: The actual target language or an extension of it being used? And what if there will be more extensions being used at the same time? |
It's interesting the topic but at the end of the day, a jsx file just like someone else said before indicates that it's actually React code ... and while Facebook it's not saying anything about it, I'm stick with their rules, and I prefer the old fashion so to say it --- |
Airbnb enforce the use of .jsx extension for react specific files where jsx syntax is being used.
There are different opinions on the subject (I suggest reading this thread on the topic). On the same issue Dan Abramov offers reasoning why he prefers .js instead of .jsx.
Would love to hear your feedback on this topic.
The text was updated successfully, but these errors were encountered: