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

Do not prepend / append with a semicolon the only JSX element in a program #3330

Merged
merged 3 commits into from Nov 28, 2017
Merged

Do not prepend / append with a semicolon the only JSX element in a program #3330

merged 3 commits into from Nov 28, 2017

Conversation

sapegin
Copy link
Contributor

@sapegin sapegin commented Nov 27, 2017

Don't output semicolon before or after a single [ExpressionStatement whose expression is a JSXElement] inside a markdown code block, regardless of the semi option.

I’m not sure how to check that we’re inside Markdown.

Fixes #3196.

@sapegin sapegin changed the title Do not prepend / append with a semicolon the only JSX element in a program [WIP] Do not prepend / append with a semicolon the only JSX element in a program Nov 27, 2017
@azz
Copy link
Member

azz commented Nov 27, 2017

I’m not sure how to check that we’re inside Markdown.

One way to do this is expose the parent parser:

multiparser.js:

  next.options = Object.assign({}, options, next.options, {
+   parentParser: options.parser,
    originalText: next.text
  });

Then check with:

if (options.parentParser === "markdown") {
  // ...
}

@sapegin
Copy link
Contributor Author

sapegin commented Nov 27, 2017

@azz Thanks, it seems to work! Please have a look. Is there anything I need to change? This is my first PR to Prettier ;-)

@sapegin sapegin changed the title [WIP] Do not prepend / append with a semicolon the only JSX element in a program Do not prepend / append with a semicolon the only JSX element in a program Nov 27, 2017
Copy link
Member

@suchipi suchipi left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@suchipi suchipi merged commit 172d34e into prettier:master Nov 28, 2017
@suchipi suchipi added this to the 1.9 milestone Nov 28, 2017
@sapegin sapegin deleted the jsx-only-elem branch November 28, 2017 07:56
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants