Add --check option#5629
Conversation
|
I think it'd be better to use a reporter-like solution: // my-reporter.js
module.exports = function ({ filename, source, formatted }, { logger }) {
// ...
}(It looks like we can even rewrite |
|
Hi @ikatyang! 👋 Will a project owner have to add One more thought: implementing Optionally, we can park the concept of reporters till 2.0 as suggested by @lydell in #5520 (comment) and simply focus on giving users a simple working solution. |
|
I’m wondering if |
|
I meant that the reporter could be a sharable module just like
I'm fine with either way as I think we probably need to rewrite our API/CLI in 2.0, and it does not look like it'll happen soon. |
|
@j-f1 good point about the
2.0 feels like a good time to reconsider the API design, so perhaps the introduction of custom / built-in reporters can be done later. Showing diffs fits the idea of reporters quite well, but I'm not sure that it should be enabled by default. I was recently helping to switch one rather large project into Prettier, which involved adding The main use case for Let's wait for objections to what I wrote in the docs for a few more days and I'll go for implementing a minimal change, which will make this feature real 😉 |
|
I'm 👍 on the stuff described in the docs. |
Co-Authored-By: kachkaev <alexander@kachkaev.ru>
…--list-different + --write
|
RFC 🕺 A few notes: I had to change the proposed output from to This because the file list is constructed asynchronously and it would be challenging to "hold" it until all formatting is done in order to print the summary message above. The docs are updated accordingly. prettier-check, which inspired me, spawns Prettier using execa and this is what lets it gather the list before producing the final output. Streaming the list as it gets populated is potentially beneficial in large projects. The implementation of Added tests are also quite boring – I just duplicated the ones for
See below |
|
Would it be reasonable to assign this feature to 1.16 milestone? 🤔 It'd be great if it was released together with the next batch of perks! ✌️ |
|
What do you think about displaying a line with the filename currently being formatted that gets deleted and rewritten if the file passes? This would give the user more feedback so it wouldn’t look like Prettier was frozen. |
|
Good point @j-f1! I've implemented this. The filename currently being formatted is also shown in TTY for |
|
Just tried |
|
Thanks! |
|
this is not released yet right? it's a little confusing as it's already shown at https://prettier.io/docs/en/cli.html - I just wanted to set this up and found out that it's not working |
|
That’s true, we should comment out the docs. |
Closes #5520
WDYT folks?