prettier: Comment "x" was not printed. Please report this error!

Environments:

  • Prettier Version: 2.2.1 (This does not seem to be an issue in 2.0.5)
  • Running Prettier via: VSCode/CLI
  • Runtime: Typescript / Angular
  • Operating System: Mac OS

Steps to reproduce:

Adding a comment such as /* something here */ or // something here above a class, such as:

/* something here */
@Component({
  selector: 'something-here',
  templateUrl: './something-here.html'
})
export class SomethingHere {

or

// something here
@Component({
  selector: 'something-here',
  templateUrl: './something-here.html'
})
export class SomethingHere {

Expected behavior:

Actual behavior:

I get the following error message:

["ERROR" - 11:44:04 AM] Comment "something here" was not printed. Please report this error!
Error: Comment "something here" was not printed. Please report this error!
	at /<project>/node_modules/prettier/index.js:13827:13
	at Array.forEach (<anonymous>)
	at ensureAllCommentsPrinted (/<project>/node_modules/prettier/index.js:13825:15)
	at coreFormat (/<project>/node_modules/prettier/index.js:13874:3)
	at format (/<project>/node_modules/prettier/index.js:14115:73)
	at formatWithCursor (/<project>/node_modules/prettier/index.js:14131:12)
	at /<project>/node_modules/prettier/index.js:42399:15
	at Object.format (/<project>/node_modules/prettier/index.js:42418:12)
	at t.default.<anonymous> (/<user>/.vscode/extensions/esbenp.prettier-vscode-6.3.1/dist/extension.js:1:16946)
	at Generator.next (<anonymous>)
	at s (/<user>/.vscode/extensions/esbenp.prettier-vscode-6.3.1/dist/extension.js:1:9119)
["INFO" - 11:44:04 AM] Formatting completed in 134.263562ms.

Thanks,

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Not sure how this happened to you all, but to me, it started after changing branch (and with that changing a lot of prettier config files). After restarting VSCode it was fine. Probably some issues with caching the config and ignore files.

(Still not sure why the error would be related to comments, but hey, just trying to help here)

Not sure how this happened to you all, but to me, it started after changing branch (and with that changing a lot of prettier config files). After restarting VSCode it was fine. Probably some issues with caching the config and ignore files.

(Still not sure why the error would be related to comments, but hey, just trying to help here)

Restart VSCode works for me too. Thx @johnnyasantoss

Not sure how this happened to you all, but to me, it started after changing branch (and with that changing a lot of prettier config files). After restarting VSCode it was fine. Probably some issues with caching the config and ignore files.

(Still not sure why the error would be related to comments, but hey, just trying to help here)

@johnnyasantoss this worked for me, thanks for sharing!

I also face the same issue. As long as the code has comments, the prettier cannot work.