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.

Success and error messages are printed to stdout when reading from a file

See original GitHub issue

This 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:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
osenercommented, Mar 8, 2017

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.

0reactions
kentcdoddscommented, Apr 14, 2017

This has been released in the latest version 😃

Read more comments on GitHub >

github_iconTop 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 >

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