Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 22, 2024

Conversation

JamesHenry
Copy link
Collaborator

@JamesHenry JamesHenry commented May 17, 2024

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 #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. prettier/prettier#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

Copy link

vercel bot commented May 17, 2024

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

Copy link

@pujux pujux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

@JamesHenry JamesHenry merged commit 383be1f into master May 22, 2024
6 checks passed
@JamesHenry JamesHenry deleted the format-check-verbose-output branch May 22, 2024 19:05
FrozenPandaz pushed a commit that referenced this pull request May 23, 2024
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators May 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants