prettier / prettier-eslint-cli

CLI for prettier-eslint
https://npm.im/prettier-eslint-cli
MIT License
542 stars 85 forks source link

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

Open laike9m opened 3 years ago

laike9m commented 3 years ago

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.

fredvisser commented 3 years ago

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.

JounQin commented 2 years ago

PR welcome to add this feature!