prettier-eslint-cli: Allow prettier-eslint-cli to write eslint errors/warnings to stderr?
prettier-eslint-cliversion: 8.0.1prettierversion: 2.7.1eslintversion: 8.19.0
Prior to prettier-eslint v. 16.2.0, it discarded all errors/warnings from eslint. Now there is an alternate entry to prettier-eslint that captures that information. I run prettier-eslint-cli automatically on save from my editor, so it would be convenient for any such warnings/errors to be written to stderr. That way, any errors would pop up in the editor when I save, which would prevent me from having a surprise that there are eslint violations when I go to try to make a commit.
Could an option be added to prettier-eslint-cli that will cause eslint errors/warnings to be written to stderr? Perhaps --report-errors ?
About this issue
- Original URL
- State: open
- Created 6 months ago
- Comments: 15 (15 by maintainers)
Great. With the holidays not sure exactly when I will be able to finish the PR, but I will try to get it done by mid-next month if not before.
No,
eslintwithout--fixsimply tells you about all questionable formatting in your code, it does not (even attempt to suggest how to) correct your code. On the other hand,prettier-eslint-cli --report-issueswithout the--writeoption would still write out the corrected code to stdout, just the idea is that it will now also tell you about the issues that it does not now how to fix (without--report-issuesthose issues are silenetly ignored). So the question is where should that additional information go?But as mentioned above,
eslintwithout--fixdoes not provide corrections, whereasprettier-eslint-clidoes always produce corrections. The closesteslintvariant to whatprettier-eslint-clidoes iseslint --fix-dry-run– but that does not write out the corrected code. Invoked exactly like that, all it does is write to stdout the unfixable errors, amusingly enough. There is another varianteslint --fix-dry-run --format jsonwhich writes a big JSON structure to stdout that encodes all of the errors (fixable and unfixable) as well as the proposed fixed code (in one of the top-level properties of the structure). But I don’t think suddenly adding a JSON output format toprettier-eslint-climakes sense. It is focused on correcting code; I would just like to know in addition if it noticed any unfixable problems with the code. This is not really a mode of operation ofeslint, and would if implemented be a noticeable added value ofprettier-eslint-cliif we can agree on an implementation. Hence, to reiterate my working proposal:In the
prettier-eslint-cli --write --report-errorscase, which is quite analogous toeslint --fix, you would like to matcheslintbehavor and send the errors/warnings to stdout.In the
prettier-eslint-cli --report-errorscase, to match the current behavior ofprettier-eslint-cli, the corrected code should be written to stdout. There isn’t a closely analogous mode ofeslint, and so to make it easy for people using the tool to separate the suggested fixed code from the (unfixable) warnings/errors, I propose the latter be sent to stderr in this case. Such behavior doesn’t really conflict with eslint, and will make it quite easy to use the tool to do whatever you want with both the fixed code and with the warning/error information – just send stdout and stderr (respectively) wherever you like.Please let me know if this scheme meets with your approval for a PR, or suggest concrete different behavior that you would like to see implemented. Thanks!
I like
--report-issues. But I am unclear: is it possible to support both--report-issuesand--report-issues error? How can the command-line parser then tell whethererroris the argument to--report-issuesor a glob argument? Or should there be a mandatory argument so that you must say either--report-issues allor--report-issues error(or--report-issues nonewhich is the current behavior and so presumably the new default)?As far as where the errors/warnings go, since the default behavior of prettier-eslint is to write the formatted version to stdout, it seems to me this information has to (all) go to stderr. It’s also convenient because my editor is expecting nothing on stderr and if there is anything, it shows it in a popup. But if you have another convention in mind for what should go to stdout/stderr under what conditions, just let me know.
When these design points are settled I will be happy to supply a PR as soon as I am able.