prettier-eslint-cli icon indicating copy to clipboard operation
prettier-eslint-cli copied to clipboard

Is it possible to provide a `--check` option like prettier?

Open laike9m opened this issue 4 years ago • 2 comments

Right now there seems to be no way to use prettier-eslint-cli to report unformatted code. This makes it hard to apply it in CI checks. https://github.com/u3u/prettier-eslint-check solves this problem, but it's no longer maintained. It would be nice if the official CLI can support this feature.

laike9m avatar Apr 03 '21 01:04 laike9m

I'd recommend trying the --list-different option. It gives a list of files that need to be formatted and returns a failure code.

E.g. prettier-eslint \"./**/*.js\" --list-different

…/src/light-async.js
…/src/prism-async.js
success formatting 2 files with prettier-eslint
7 files were unchanged
npm ERR! Lifecycle script `prettier` failed with error: 
npm ERR! Error: command failed 

The main drawback is the mixed messages about success and error, but people should be able to figure it out.

fredvisser avatar Aug 18 '21 14:08 fredvisser

PR welcome to add this feature!

JounQin avatar Aug 13 '22 02:08 JounQin