Success and error messages are printed to stdout when reading from a file
See original GitHub issueThis makes it hard to use this tool as a drop-in replacement for prettier, for example when using Emacs editor integration https://github.com/prettier/prettier/tree/master/editors/emacs as it works using temporary files instead of --stdin
.
I was able to fix this easily by using console.error
instead of console.log
in format-files.js
, but couldn’t send a quick PR as it breaks more than half of the tests.
$ echo "import 'foo'" > file.js
$ prettier-eslint file.js > formatted.js
formatted.js contents:
import 'foo'
success formatting 1 file with prettier-eslint
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Why stdout for error messages [closed] - Stack Overflow
It's lazyness. stderr was created to print error messages, so you can redirect the output of a program without having mixed error messages....
Read more >Writing Error Messages to Standard Error Instead of Standard ...
First, let's observe how all content printed by minigrep is currently being written to standard output, including error messages that we want to...
Read more >Do progress reports/logging information belong on stderr or ...
The usage message should go to stdout if the user has invoked it with --help and to stderr if they have made a...
Read more >The Rust Programming Language
Yup, our error message is being printed to standard output. It's much more useful for error messages like this to be printed to...
Read more >How to redirect standard (stderr) error in bash - nixCraft
Standard error (also known as stderr) is the default error output device. Use stderr to write all system error messages. The number (FD...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Stderr is not only for errors, but also for diagnostic messages. Outputting the data in stdout and printing the meta messages on stderr allows users to consume the formatted JS by reading stdout. Simplest example of this is
prettier-eslint file.js > formatted.js
.This is outlined in POSIX standard as explained here: https://unix.stackexchange.com/questions/331611/do-progress-reports-logging-information-belong-on-stderr-or-stdout. The third answer also makes a good point that no diagnostic information should be outputted in case of successful execution (unless the user asked for it), so I think even if
--summary-log
is added, it should default to false.This has been released in the latest version 😃