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

--insert-pragma causing weird commenting issue due to single asterisk comment #3269

Closed
sygint opened this issue Nov 14, 2017 · 7 comments
Closed
Labels
scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program

Comments

@sygint
Copy link

sygint commented Nov 14, 2017

Prettier 1.8.2
Playground link

--insert-pragma

Input:

/* ShippingValidation: 
 * Encapsulates the validation on the payment options page in checkout
 */

Output:

/**
 * /* ShippingValidation:
 * Encapsulates the validation on the payment options page in checkout
 *
 * @format
 */

Expected behavior:

/** @format */

/* ShippingValidation:
 * Encapsulates the validation on the payment options page in checkout
 */

or

/**
 * ShippingValidation:
 * Encapsulates the validation on the payment options page in checkout
 *
 * @format
 */

or

/*
 * ShippingValidation:
 * Encapsulates the validation on the payment options page in checkout
 *
 * @format
 */

I'd be fine if it added the proper Doc Block asterisk or if it just kept it a single, either way is fine.
I can TRY to get around to creating a PR for this, but I'm not sure I have the time today.

@sygint
Copy link
Author

sygint commented Nov 14, 2017

Looks to be an issue with jest-docblock not realizing it's a malformed doc-block, I'll work on a fix for that.

@lydell lydell added scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program labels Nov 14, 2017
@lydell
Copy link
Member

lydell commented Nov 14, 2017

This is definitely a bug. Not sure what the expected output is though.

@sygint
Copy link
Author

sygint commented Nov 14, 2017

@lydell, it's a bug, but the bug is really in jest-docblock, it's desired behavior could be a few things, I think option 1 is the most sensible with the least caveats.

@sygint
Copy link
Author

sygint commented Nov 14, 2017

Single line comments do even weirder things...

** Input **

/* ShippingValidation: 
 */

** Output **

/**undefined * /* ShippingValidation:undefined *undefined * @formatundefined */

** Input **

/* ShippingValidation: */

** Output **

/**undefined * /* ShippingValidation:undefined *undefined * @formatundefined */

@sygint
Copy link
Author

sygint commented Nov 14, 2017

I think it's all just a minor parsing issue in jest-docblock, I'll look into it later

@aij
Copy link

aij commented Jan 16, 2019

It's also problematic with eslint and flow.

For example, eslint no-undef reports errors after prettier --insert-pragma changes

/* global foo */

to

/**
 * /* global foo
 *
 * @format
 */

Making the global declaration unrecognizable to eslint.

The @flow comments are handled similarly... They at least remain recognizable to flow itself, but (in addition to being ugly) some editor plugins fail to recognize them.

@fisker
Copy link
Member

fisker commented Nov 24, 2022

Fixed by #13054

@fisker fisker closed this as completed Nov 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

4 participants