question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prettier <file> without --write option does not ignore what's in .prettierignore

See original GitHub issue

When I run this:

prettier --config .prettierrc.json '**'

it echoes a lot of stuff to stdout, for files that are ignored by .prettierignore. It should ignore what’s in .prettierignore when the --write option is not used.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
thorn0commented, Apr 30, 2020

Not having --write or --check means outputting the result to stdout. If a file formatter, having been asked to format a file and to return the result to stdout, returns nothing, the consumer (e.g. an editor integration that uses the formatter via its CLI) has to suppose that the formatting result is the empty string (see https://github.com/prettier/prettier/issues/3590). So, imagine: the user invokes the “Format” command in their editor, and the editor suddenly deletes the whole content of the file, which was supposed to be ignored by that formatter! Would you call this behavior respecting .prettierignore? That’s why, if a file is ignored, Prettier outputs it as is instead of printing nothing. It doesn’t disrespect .prettierignore at all, as you can see. That’s just the way it respects it.

Now, what does this all have to do with globs, you ask? That’s a good question. It’s difficult for me to think of a use case where multiple files matched by a glob would need to be formatted and output to stdout. I wonder whether anybody actually uses Prettier to format multiple files at once and print the concatenated result to stdout. It seems like you, @ORESoftware and @cdaringe, actually do this though. I second @lydell’s curiosity, what for?

0reactions
no-response[bot]commented, May 14, 2020

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >
Inspect at see why prettier ignores one file (that is not listed in ...
Prettier seems to be working just fine for all other files except this one file that I can't format without forcing it.
Read more >
Prettier - Code formatter - Visual Studio Marketplace
If you want to disable Prettier on a particular language you can either create a .prettierignore file or you can use VS Code's...
Read more >
how to disable prettier formatting for individual files or folders
To disable prettier formatting on a single file, open the .prettierignore file ... prettier-ignore-start --> now you can write multi-line things and it...
Read more >
prettier exclude file | The AI Search Engine You Control
To exclude files from formatting, create a .prettierignore file in the root of your ... When I disabled it, however, no json file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found