fix(core): more helpful output for format:check --verbose
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
After
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 |
☁️ Nx Cloud Report
CI is running/has finished running commands for commit a832a141230ca56aebeab01f80b0cf1232cbfb2e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
📂 See all runs for this CI Pipeline Execution
✅ Successfully ran 6 targets
-
nx affected --targets=e2e,e2e-ci --base=53345f22418c04b52dbe1f9ddb2cc577572c38c2 --head=a832a141230ca56aebeab01f80b0cf1232cbfb2e --parallel=1 -
nx affected --targets=lint,test,build --base=53345f22418c04b52dbe1f9ddb2cc577572c38c2 --head=a832a141230ca56aebeab01f80b0cf1232cbfb2e --parallel=3 -
nx run-many -t check-imports check-commit check-lock-files check-codeowners documentation --parallel=1 --no-dte -
nx-cloud record -- nx format:check --base=53345f22418c04b52dbe1f9ddb2cc577572c38c2 --head=a832a141230ca56aebeab01f80b0cf1232cbfb2e -
nx documentation --no-dte -
nx affected -t e2e-macos-ci --parallel=1 --base=53345f22418c04b52dbe1f9ddb2cc577572c38c2 --head=a832a141230ca56aebeab01f80b0cf1232cbfb2e
Sent with 💌 from NxCloud.
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.