Open ADTC opened 1 year ago
Love this - Another option / avenue would be to include a separate verbosity flag for the write option, that would include all touched / read files, vs written.
I would like this implemented as well.. when will we see this added?
my current solution for this is prettier --write . | grep -v \"unchanged\" | xargs if anyone needs a solution without this feature being added to the main repo.
Seems like this is popular. What could be blocking us from adding this feature? @sosukesuzuki
Came looking to raise this as well, I'd be happy with either option (change the existing cli option, or add a new one)
bump
I've found adding --log-level warn
has resolved this for me.
@Sicria I think that doesn't show changed files as well.
--log-level warn
same here, "prettier --write . --log-level warn" partialy solves the problem for me in that it is not as noisy, however files that are formatead are not log. I ask ChatGTP, and this works for me on my windows box " "prettier --write . | findstr /V \"(unchanged)\"""
I do believe that @ADTC observation are correct, and the default level should only log files that are changed.
--log-level warn
same here, "prettier --write . --log-level warn" partialy solves the problem for me in that it is not as noisy, however files that are formatead are not log. I ask ChatGTP, and this works for me on my windows box " "prettier --write . | findstr /V \"(unchanged)\"""
I do believe that @ADTC observation are correct, and the default level should only log files that are change.
Note: This issue was split from #15396.
The output of
--write
is too verbose, as it lists all files being read, instead of files being written.Suggestion: Reduce verbosity.
I believe in
--log-level log
(the default level), the log should only output names of files that actually changed. So if a file remains the same and isn't overwritten with a formatted version, its file name should only be output in--log-level debug
.This will reduce the default verbosity of the
--write
option unless the full verbosity is requested using--log-level debug
. Most times the users would only want to know what files were rewritten using the--write
command, not the full list of files read. Only those trying to debug why a given file is not being formatted by Prettier would want to inspect the debug output which includes the list of files being read.Example demonstrating suggestion
Take two exact copies of a project with three files, only the second of which will change in formatting.
With the current version of Prettier, running
npx/yarn prettier --write .
on first copy:(can't show color but you can imagine it: file1 and file3 will be grey)
With a fixed version of Prettier, running
npx/yarn prettier --write .
on second copy:Relevant information
Relevant code:
https://github.com/prettier/prettier/blob/f7959cccbfaf38f685b660f39eed061f5eec5ec2/src/cli/format.js#L432-L441
Relevant issues:
This was kind of hinted before in #3525 but apparently misunderstood. I believe the original author there possibly couldn't see the grey vs white distinction because the terminal didn't support colors, and everything was in the same color. This may have led to the false impression that all files are being overwritten when in reality, all filenames were being output to log, but only changed files were overwritten.
Discussions about verbosity have also occurred recently, such as in #13480.
I can open a pull request
I believe both suggestions can be achieved with a simple change:
context.logger.debug
instead.Just let me know if the suggestions are acceptable.