nx icon indicating copy to clipboard operation
nx copied to clipboard

fix(core): more helpful output for format:check --verbose

Open JamesHenry opened this issue 1 year ago • 2 comments

Nx format is currently exclusively built on top of prettier. We leverage the --list-different feature of prettier to show the user which files failed the formatting check. The simple common case solution is to run nx format:write (powered by prettier --write) and commit the result.

Right now a user might want to try and learn more about their format:check failure by passing --verbose but it will not change the output in any way.

Based on the feedback in https://github.com/nrwl/nx/issues/4159 some users are expecting to see the diff output of what correct vs incorrect formatting would look like.

However, because nx format is currently exclusively built on top of prettier, it is therefore subject to its limitations. https://github.com/prettier/prettier/issues/6885 remains unresolved and so there is no native way for users to see a diff.

It is important to note that only showing the names of the files in the default nx format:check output is an important feature - it allows easy piping into custom scripts to perform further handling. Therefore we do not want to change the default output here.

This PR updates the case where --verbose is passed in order to provide more information context about the overall problem and how to fix it.

Before

image

After

image

JamesHenry avatar May 17 '24 18:05 JamesHenry

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview May 17, 2024 7:32pm

vercel[bot] avatar May 17 '24 18:05 vercel[bot]

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

github-actions[bot] avatar May 28 '24 00:05 github-actions[bot]