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

Linguist should understand JSX in .js files #3677

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,7 @@ JSX:
type: programming
group: JavaScript
extensions:
- ".js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is .js really the primary extension for JSX? If not, please move this below .jsx as the first extension is considered the primary extension.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, it's kind of impossible to do that research on Github because it ignores some important characters - but from my knowledge much more people use .js extension for writing JSX code than .jsx.

If you go to React's official repo examples, you'll see that all of them uses JSX in .js files (and the entire ecosystem does - Redux etc). Based on that, I assume that if the creators of JSX use the .js extension, it's the primary extension for the language. But I can't ensure that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for the confirmation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, another useful info: facebook/create-react-app#87

- ".jsx"
tm_scope: source.js.jsx
ace_mode: javascript
Expand Down
23 changes: 23 additions & 0 deletions samples/JSX/sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const React = require('react')

module.exports = React.createClass({
render: function() {
let {feeds, log} = this.props;

log.info(feeds);
return <div className="feed-list">
<h3>News Feed's</h3>
<ul>
{feeds.map(function(feed) {
return <li key={feed.name} className={feed.fetched ? 'loaded' : 'loading'}>
{feed.data && feed.data.length > 0 ?
<span>{feed.name} <span className='light'>({feed.data.length})</span></span>
: 'feed.name' }
</li>
})}
</ul>
</div>;
}
});