-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Feature Request: nx format:check should provide a workaround for Prettier not supporting format diffing #4159
Comments
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
It's like a slap in the face without ever even telling you why. Imagine a compiler telling you "Error, GFY, period". Please add this. |
My entire team is complaining about this, going to have to remove my formatting check from pre-commit hook because it is just confusing everyone. The --verbose flag should be at minimum spitting out the same output of the format:write command which at least shows the command crawling through the project directories doing the formatting. FYI for others with this issue it seems like you can run prettier using npm and get the output from running the prettier command directly instead of through Nx. |
Why it's closed? My project is failing on nx format:check without any message besides the |
I don't understand "stale" logic as well. My pipeline also failed at this step without any reason. Verbose is not informative at all. |
Yeah, reopen this issue - verbose is broken |
Same here |
Just ran into the same issue, would like to see this issue being reopened... |
If it helps anyone, running |
Try adding angular.json, nx.json, and tsconfig.base.json to your prettier
ignore file and that should work. I noticed on every change prettier was
touching angular.json file even when it wasn't changed, once I ignored
those files I was getting proper behavior running nx format:check without
the verbose flag (we actually no longer run check and our pre-commit hooks
run nx format:write which has been working fine after ignoring the above
files).
TCModus
…On Tue, Feb 22, 2022, 11:33 AM konnic ***@***.***> wrote:
If it helps anyone, running nx format:write solved issue for me.
—
Reply to this email directly, view it on GitHub
<#4159 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/APEHQMLCL653STVWERMXE43U4O3DZANCNFSM4UD77B6A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
edit: e.g. nx format:check --base=main --head=HEAD
# exit code 0
nx format:check --base=main --head=HEAD --verbose
# exit code 0
nx format:check
> NX Affected criteria defaulted to --base=main --head=HEAD
/path/to/failed/file
# exit code 1
nx format:check --verbose
> NX Affected criteria defaulted to --base=main --head=HEAD
/path/to/failed/file
# exit code 1 Unless there's some way to turn off the "warning" logging that nx has select a |
This is passing locally and failing in CI for me. Both running on same node and npm versions. |
How has this not been addressed , it's running fine locally, failing in CI with no information. |
I added this to my actions.yml file and it seems to do the trick. Rather than rely on It's probably not necessary to use both but just to still make sure NX is some-what happy, I wanted to use their format checker. Seems to work now, hope we can get a proper solution for this in the future. At least with |
Please correct me if I'm wrong but it seems like all nx does is execute prettier under the hood anyways: nx/packages/nx/src/command-line/format.ts Line 201 in 969aa32
So if we want more verbose output, this will probably be the place to implement it. |
That worked for me thanks friend finally got nxcloud builds in flight npmjs.org held me down for whole month in a user account debilitation locked out from their case logic creating users for emails that they dont even validate... ditched npmjs for github registry and I think this is the trend. sorry npmjs its been real. nxcloud rocks... integrated to everything do not release bad stuff into the public domain its going to get engineers very upset who are live in the field operating prod instances and thus far Nx and GitHub has been great. Wish I could say same for yarn, npm, webpack and other flanking entities. I know I wont sign my name to anything buggy. npmjs was last straw. |
why is this closed as completed if it's still a problem? |
Our team is having the same issue. |
+1 for showing what is wrong with the file(s) |
I am still having this issue with my CI any solution? |
Same issue here, we are missing the detailed error output of prettier. Would be great if you could reopen the issue. |
We parse our build logs to collect data on issues. The output of
But as others have mentioned, actually showing some verbose output is desperately needed. |
bump This is affecting my work flow as well. Please add descriptive text that identifies what is being flagged. |
+1 for providing info on failed check please 🙏 |
I am confused as well. I am evaluating Nx and am playing around with their Azure DevOps example here. The documentation offers this snippet:
But, I get an error when it runs
Using a suggestion in another comment (changing it from check to write), I get the same error in the logs, but it doesn't return an exit code of 1 and allows my pipeline to continue on to the next build task. Full build logs with
with
I created a documentation issue (#16241) for this initially, but it sounds like this command may be having troubles in a pipeline? |
I'm also facing this issue in gitlab ci |
I had same issue too and it's really confusing. Is it My name: Publish Libraries
'on':
push:
branches:
- main
pull_request:
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo ✅
uses: actions/checkout@v2
- name: Install Dependencies 🔧
run: |
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
- name: Pretty code 💄
run: npx nx format:check
- name: Lint ♻️
run: npx nx affected -t lint
- name: Build 📦
run: npx nx affected -t build
- name: Test 🧪
run: npx nx affected -t test --ci --code-coverage
- name: Release 🚀
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx nx affected -t release
and it fails at the linting stage, saying Run npx nx affected -t lint
npx nx affected -t lint
shell: /usr/bin/bash -e {0}
> NX Affected criteria defaulted to --base=master --head=HEAD
fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
nx affected
Run target for affected projects
Run command using --base=[SHA1] (affected by the committed, uncommitted and untracked changes):
--base Base of the current branch (usually main) [string]
or using --base=[SHA1] --head=[SHA[2](https://github.com/tomavic/enigma-nx-angular/actions/runs/4710392822/jobs/8353993527?pr=2#step:5:2)] (affected by the committed changes):
--base Base of the current branch (usually main) [string]
--head Latest commit of the current branch (usually HEAD) [string] |
@tomavic you are encountering a different issue. you need to add fetch-depth to your actions/checkout action to have all history you need for nx. from https://github.com/actions/checkout#readme
also have a look at: https://github.com/nrwl/nx-set-shas |
Thanks @pujux That is a really different issue and I've fixed it using the correct usage of |
Same here, failing in ci but working locally. |
+1 |
opened an MR to address this here: #4159, open to feedback |
Same here, the fact that it's been almost 2.5 years without a fix to such a obvious issue is sad |
If your format check is failing on CI but working locally, you might have some files which are being generated in CI, which might not be formatted properly. You can add those files to Workflow:
You can verify this as not being a problem with |
I really wonder how this command made it into production. The documentation actually says nothing about what the command really does, instead it's written somewhere else. And the output is just a bad joke 🙈. |
Seriously, why does it output nothing but the affected files. Yes you can write to fix, but it's so unbelievably frustrating to have no idea what the output is. |
I've blasted up there youtube threads with links too this issue, maybe the team will finally address it. |
please fix ... |
Why hasn't this issue been formally addressed yet? this should be fixed |
@vsavkin, this issue was raised nearly 3 years ago. It has the most 👍 and ❤️ reactions of any issue for this project, and has about 46 subscribers.
Can you please give an update on whether this issue will ever be addressed, or mark |
I added a message on their discord if everyone here replies to that maybe they'll notice something? 🤷🏻♂️ |
So I mentioned Miroslav Jonas on Twitter to try and see if the team has taken notice on the issue and here is his reply: https://x.com/meeroslav/status/1706345582242001064?s=46&t=ZnrURlqYmjZQZciRM14ZDA we might be getting a solution soon 🥳 |
Hi Folks, Nx format is currently exclusively built on top of prettier. For The simple common case solution is to run To summarize this thread, however: Right now a user might want to try and learn more about their Based on the feedback in this issue 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 I have opened PR #23503 which updates the case where Before After Notes on actually diffing Naturally, what we recommend is to continue to give feedback to the Prettier team that you want this feature. However, if a user here would like to take things a step further and prototype what it might look like for Nx to attempt to make up for the lack of diffing in prettier, then please do, we would be willing to consider a PR for this if a reliable solution can be found. However, it is worth noting that this behavior should not be activated by simply passing
Instead, it would have to be powered by some opt-in additional flag, such as |
I have updated the issue description to more accurately reflect the nature of this request and provided a link to my most recent comment as the latest status on this. Thanks all! |
This issue has been automatically marked as stale because it hasn't had any activity for 6 months. |
UPDATE FROM NX TEAM (2024-05-17)
Please read: #4159 (comment)
Description
As
nx format:check
shows which files fail the format check but not what is actually wrong in them, I would love if the--verbose
option could actually add that information. At the moment, unless I am doing something wrong,nx format:check --verbose
has the same output asnx format:check
.Motivation
The command would give more information about what is actually wrong in the file format.
Suggested Implementation
I would love if the
--verbose
option could actually add that information.Alternate Implementations
As an alternative, I would like even only to see either the line where the check fails, or maybe the broken rule.
The text was updated successfully, but these errors were encountered: