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

Prettier does not seem to like a comment that starts with two colons #6102

Closed
benjie opened this issue May 5, 2019 · 5 comments
Closed

Prettier does not seem to like a comment that starts with two colons #6102

benjie opened this issue May 5, 2019 · 5 comments
Labels
area:comments Issues with how Prettier prints comments area:flow comment types lang:javascript Issues affecting JS type:bug Issues identifying ugly output, or a defect in the program

Comments

@benjie
Copy link

benjie commented May 5, 2019

Prettier 1.17.0
Playground link

--parser babylon
--single-quote
--trailing-comma es5

Input:

a(
  // ::
  1
);

Output:

Error: Comment "::" was not printed. Please report this error!
    at https://prettier.io/lib/standalone.js:16137:13
    at Array.forEach (<anonymous>)
    at ensureAllCommentsPrinted (https://prettier.io/lib/standalone.js:16135:15)
    at coreFormat (https://prettier.io/lib/standalone.js:16186:3)
    at format (https://prettier.io/lib/standalone.js:16427:73)
    at formatWithCursor (https://prettier.io/lib/standalone.js:16443:12)
    at https://prettier.io/lib/standalone.js:30799:15
    at Object.format (https://prettier.io/lib/standalone.js:30807:12)
    at formatCode (https://prettier.io/worker.js:234:21)
    at handleMessage (https://prettier.io/worker.js:185:18)

Expected behavior:


This is a minimal reproduction, this issue was triggered by this file:

https://github.com/graphile/graphile-engine/blob/4ba5eb30eacd3bec8e1dccc10ff6bbdb6c765794/packages/graphile-build-pg/src/plugins/PgTypesPlugin.js

@purge
Copy link

purge commented May 5, 2019

i'm seeing the same when parser is set to babel or babel-flow in the playground.

benjie added a commit to graphile/graphile-engine that referenced this issue May 5, 2019
@j-f1 j-f1 added area:comments Issues with how Prettier prints comments lang:javascript Issues affecting JS type:bug Issues identifying ugly output, or a defect in the program labels May 5, 2019
benjie added a commit to graphile/graphile-engine that referenced this issue May 5, 2019
* Upgrade pg-sql2

* Upgrade dependencies

* Upgrade babel to v7

* Work around prettier bug

prettier/prettier#6102
@jordwalke
Copy link

Seeing this as well in the following example (playground, latest version):

module.exports = {};

module.exports = ((module.exports /*:: : a*/) /*:: :b */);

@warpr
Copy link

warpr commented Aug 12, 2020

Also happens with just a single colon:

Prettier 2.0.5
Playground link

--parser babel

Input:

const files = ((Object.values(page.files)/*: any */) /*: Array<FileModel> */);

Output:

ensureAllCommentsPrinted/<@https://prettier.io/lib/standalone.js:17105:15
ensureAllCommentsPrinted@https://prettier.io/lib/standalone.js:17103:17
coreFormat@https://prettier.io/lib/standalone.js:17151:29
format@https://prettier.io/lib/standalone.js:17369:77
formatWithCursor@https://prettier.io/lib/standalone.js:17385:14
withPlugins/<@https://prettier.io/lib/standalone.js:32887:14
format@https://prettier.io/lib/standalone.js:32896:14
formatCode@https://prettier.io/worker.js:117:21
handleMessage@https://prettier.io/worker.js:68:18
self.onmessage@https://prettier.io/worker.js:38:14

Expected behavior:

const files = ((Object.values(page.files) /*: any */) /*: Array<FileModel> */);

@mrtnzlml
Copy link

mrtnzlml commented Jan 6, 2022

I just encountered the same problem when testing the new Rust Compiler for Relay which generates the following code:

const node = " … ";
module.exports = ((node/*: any*/)/*: Mutation<
  ProductEditFormMutation$variables,
  ProductEditFormMutation$data,
>*/);

Results in the following error:

Error: Comment ": Mutation<
  ProductEditFormMutation$variables,
  ProductEditFormMutation$data,
>" was not printed. Please report this error!
    at Object.ensureAllCommentsPrinted (https://prettier.io/lib/standalone.js:1:218494)
    at qD (https://prettier.io/lib/standalone.js:1:225762)
    at JD (https://prettier.io/lib/standalone.js:1:228265)
    at Object.formatWithCursor (https://prettier.io/lib/standalone.js:40:40390)
    at formatCode (https://prettier.io/worker.js:141:21)
    at handleMessage (https://prettier.io/worker.js:78:26)
    at self.onmessage (https://prettier.io/worker.js:36:14)

https://prettier.io/playground/#N4Igxg9gdgLgprEAuc0DOMAEUIBM6YC8mAOiJoGQEpIA3CVALZ4CuANnAHRwAeADhACcYaIpgAUYnPgD0AKiSYAhlACes6QEo5CgLLMYimAEtoAHnqZMABQEswMAKK4jMAGKCGeg8egASAG6KAkaKAEbsaAA0Fta2uMz2Ti7uAp76hiZQvriGitFQAHzqGnRQIJEgELw+UGjIoEG2AO5WQQh1KIqsTYoqdRWhAopgANZwMADKigxwADJGUHDIAGZdaHADQ6PjE7zDCwDmyDACzBsgcAyhcLj4uLPKB8yKB3ApDIbGUEed+hDlIAAFjAGKwAOqAlxwNB7MBwCbtFxGfwuFTIcBofogBbrIQ2F4fFZrc4AKzQ3Amh3YAEVmBB4ETWOsKnsBLj0aEwnBWADeMFYGCjLgYIDkAAOAAMLNs6zBQ146L50LgAn8SwqAEc6fAbFUOiBFGgALSLG43AECOBaoyW-EHQlIVZM87rBhGY6nF1UuC0+lLR3EioGUKC4WipAAJiDQyMrEOAGEIAwHRc0ABWAHMdYAFTCHSdzJA-jOAEkoPhYBMwMFqgBBcsTGAqdiM9YAXzbQA

mrtnzlml added a commit to adeira/universe that referenced this issue Jan 6, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2
mrtnzlml added a commit to adeira/universe that referenced this issue Jan 6, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2
mrtnzlml added a commit to adeira/universe that referenced this issue Jan 6, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2
mrtnzlml added a commit to adeira/universe that referenced this issue Jan 6, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2
mrtnzlml added a commit to adeira/universe that referenced this issue Jan 7, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2
kodiakhq bot pushed a commit to adeira/universe that referenced this issue Jan 7, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2
adeira-github-bot pushed a commit to mrtnzlml-archive/kochka.com.mx that referenced this issue Jan 7, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2

adeira-source-id: bc3d10741250e32b6fd399245f62d25484c6ae70
adeira-github-bot pushed a commit to adeira/relay-example that referenced this issue Jan 7, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2

adeira-source-id: bc3d10741250e32b6fd399245f62d25484c6ae70
adeira-github-bot pushed a commit to adeira/relay that referenced this issue Jan 7, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2

adeira-source-id: bc3d10741250e32b6fd399245f62d25484c6ae70
adeira-github-bot pushed a commit to adeira/abacus-backoffice that referenced this issue Jan 29, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2

adeira-source-id: bc3d10741250e32b6fd399245f62d25484c6ae70
adeira-github-bot pushed a commit to adeira/abacus-kochka that referenced this issue Jan 29, 2022
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2

adeira-source-id: bc3d10741250e32b6fd399245f62d25484c6ae70
@thorn0
Copy link
Member

thorn0 commented Oct 24, 2022

Fixed by #13687

@thorn0 thorn0 closed this as completed Oct 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:comments Issues with how Prettier prints comments area:flow comment types lang:javascript Issues affecting JS type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

7 participants