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

Update: Support JSXFragment node #9664

Merged
merged 2 commits into from
May 28, 2018

Conversation

clemmy
Copy link
Contributor

@clemmy clemmy commented Nov 29, 2017

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ x ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

This is related to #9662.
Currently, when a parser, such as babel-eslint is used, it'll now return JSXFragment. This PR updates some standard rules to add some support for fragments so that JSXFragments can generally be used in the place of JSXElement.

Current behavior example

<>foo</>;

warns that foo should be wrapped in quotes, using the options:

"parser": "babel-eslint",
"rules": { "quotes": [ "error", "single" ] }

Behavior with my changes

<>foo</>;

doesn't give any warnings!

Rationale

I'm just throwing this out here because I'm not really sure if this is a change makes sense to make in this repo at this point in time. This is only applicable when an external parser is specified. If this makes sense, then I can refine the PR. 🙂

@aladdin-add aladdin-add added enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules labels Dec 1, 2017
@ilyavolodin
Copy link
Member

I think Acorn JSX plugin has already been updated to support JSX fragments, so we should have native support for them with the next release of Espree. However, I have no idea what they are supposed to do, so I can't comment on if it makes sense to add this to the rule.

@platinumazure
Copy link
Member

@ilyavolodin Are we any closer to being able to support JSXFragment in espree? (Is that something we definitely want to do?)

@ilyavolodin
Copy link
Member

@platinumazure As far as I understand it, JSXFragment is officially part of the JSX spec, so we should probably support it. However, it looks like we can't upgrade Acorn to the latest version yet, because there are some breaking changes. I think we might have to implement it in Espree ourselves.

@kaicataldo kaicataldo added the blocked This change can't be completed until another issue is resolved label Jan 24, 2018
@platinumazure platinumazure added the do not merge This pull request should not be merged yet label Mar 21, 2018
@aladdin-add
Copy link
Member

seems this is no longer blocked, since eslint/espree#371 merged.

@aladdin-add aladdin-add removed the blocked This change can't be completed until another issue is resolved label Apr 9, 2018
Copy link
Member

@ilyavolodin ilyavolodin 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 fine to me, but I would like to verify that Acorn-JSX actually outputs new node with name JSXFragment before merging this in.

Copy link
Member

@ilyavolodin ilyavolodin left a comment

Choose a reason for hiding this comment

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

Actually, looking at it again, we do need some new unit tests to verify those changes.

@platinumazure platinumazure removed the do not merge This pull request should not be merged yet label Apr 9, 2018
@platinumazure
Copy link
Member

Hi @clemmy, after a long time, it seems we are ready to look at this again. (We needed to do a breaking change with acorn-jsx and so align this with the ESLint major release-- finally we are doing release candidates.)

At this point, it looks like we need some unit tests (per Ilya's review), and we also need you to fix the commit message. My recommendation is to just push some new commits (with the new unit tests and any other changes you might make), and then edit the PR title to follow our commit message guidelines.

Please let us know if we can help with anything, either by leaving a comment here or by visiting us in our Gitter chat.

Thanks again for contributing. Let's get this in! 😄

@clemmy
Copy link
Contributor Author

clemmy commented Apr 26, 2018

Hi @platinumazure, sorry for the delayed response! I’ve been busy for the past few weeks and probably won’t have any time to dive into this for another couple of weeks. I’m wondering if there is currently any progress being made here or if anyone else wants to continue this work? If not, I’d be happy to pick this issue up again in a few weeks’ time. :)

@clemmy clemmy force-pushed the update-standard-rules-for-jsx-fragments branch from eb6638a to 5cac04e Compare May 21, 2018 15:22
@clemmy clemmy force-pushed the update-standard-rules-for-jsx-fragments branch from 5cac04e to 567efa3 Compare May 21, 2018 15:46
@aladdin-add aladdin-add changed the title Support JSXFragment node Update: Support JSXFragment node May 21, 2018
@clemmy
Copy link
Contributor Author

clemmy commented May 22, 2018

Ready for review again.

I updated this PR from last time by adding some unit tests, then rebasing & squashing it into 2 commits -- one for lib changes and one for unit test changes.

Copy link
Member

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@platinumazure platinumazure dismissed ilyavolodin’s stale review May 28, 2018 14:24

Unit tests have been added and Ilya is on vacation. Will ask for one more review from another TSC member.

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @clemmy!

@btmills btmills added accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint and removed enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels May 28, 2018
@btmills btmills merged commit d848949 into eslint:master May 28, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 26, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants