prettier/prettier

Ignore ".prettierignore" when calling prettier on a single file

EdmundsEcho opened this issue · 0 comments

Prettier is a great productivity tool. Thank you so much. I've expanded my use of the tool when i have to work on not just js and the like, but now html, css, json etc... Great stuff.

I came across a counter-intuitive behavior. This is related to #10395, however, the recommendation might address the root cause more explicitly (not to be confused with draconian :)).

When calling prettier onto a single buffer or file, perhaps there might be a way to ignore the .prettierignore file (double negative = positive). This might be accomplished by having a flag that ignores the ignore file (e.g., --force).

The IDEs, plugins, dev-pipelines and the like that enable prettier wouldn't be impacted by the change unless they opted-in to reading the flag. On the other hand, by opting-in, the flag would allow the plugins and CLIs to ignore the .prettierignore file when they deemed it appropriate e.g., when explicitly setting prettier to check a file. To limit the use it might be something that can only be called (not something set in a configuration).

This behavior would be a norm consistent with how the options set when calling a binary take precedence over the same settings in a configuration file.

All in all, the behavior "as is" was counter-intuitive to me; it took a few folks a while to realize what was going on. When setting things up there is a long list of reasons things might not work as expected. The .prettierignore file wasn't even on the list! :))