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

[New] Support shorthand fragment syntax #1956

Merged
merged 16 commits into from Sep 8, 2018

Conversation

alexzherdev
Copy link
Contributor

@alexzherdev alexzherdev commented Aug 22, 2018

Resolves #1694.

* @param {object} node - node to check.
* @returns {boolean} Whether or not the node if a JSX element or fragment.
*/
function isJSX(node) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggestions for a better name welcome (isJSXElementOrFragment seemed too wordy)

@@ -32,6 +32,10 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
{
code: '<App {...props}>foo</App>'
},
{
code: '<>foo</>',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This rule doesn't really care whether it's an element or a fragment, so I just added one simple valid test, and one invalid.

@ljharb
Copy link
Member

ljharb commented Aug 22, 2018

I'll wait to merge this til we've updated all the relevant rules.

@alexzherdev
Copy link
Contributor Author

Quick q: I noticed some of the rules are using selectors e.g. https://github.com/yannickcr/eslint-plugin-react/blob/master/lib/rules/jsx-curly-brace-presence.js#L249
Selectors were introduced in ESLint 3.18 and we seem to be supporting ^3.0.0, so I guess we should avoid using them?

@ljharb
Copy link
Member

ljharb commented Aug 23, 2018

Fair point; altho nobody's complained. I guess we should fix that.

@alexzherdev
Copy link
Contributor Author

I was asking mostly because this change could use the syntax for 'JSXElement, JSXFragment'. I will avoid it then and fix existing cases separately afterwards.

@alexzherdev alexzherdev changed the title [WIP] Support shorthand fragment syntax Support shorthand fragment syntax Aug 27, 2018
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM assuming all the relevant test cases have been updated

@alexzherdev
Copy link
Contributor Author

I believe I covered what needed to be covered, perhaps even redundantly.

Copy link
Collaborator

@EvHaus EvHaus left a comment

Choose a reason for hiding this comment

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

Changes look good to me. Test coverage is very good. Nothing seems to break as a result. Nice one!

This was referenced Jan 4, 2019
@ghost ghost mentioned this pull request Jan 12, 2019
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants