Open DanielKucal opened 1 year ago
@DanielKucal By any chance you have developers running windows and macos? It might be an issue with line endings...
UPDATE: https://prettier.io/docs/en/options.html#end-of-line https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
@minuz we're all on MacOS
Any update on this?
Having this issue. I'm on MacOS as well.
Yes, I have found no way to ignore files from nx format:check --all
we have a project that generates API code from a swagger.json and all the files are .gitignored
and yet they still fail the format check. I have tried adding them to .nxignore
as well but they continue to fail.
Maybe unrelated, but here it goes.
I was looking at the nx format implementation due to the lack of documentation on it. (Should I use it or keep using my own format
command with prettier.)
I noticed two things, both may relate to this issue.
It directly executes prettier without an option for --ignore-path
which I use for .gitignore
. Note: Maybe this is fine b/c it’s using the Nx graph.
It has specific TS config logic in the implementation, which may not be symmetric (check and write different).
Again, unsure if this helps, but maybe y’all could scan through the implementation (it’s short) and see if that gives you insight to the issue you’re seeing.
.vscode > settings.json
{
"editor.formatOnSave": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
I've found adding this helps VS Code understand what I want it to do. I'm not entirely sure this solves your problem but my problem landed me here and I found a solution so I wanted to share.
My issue was CTRL
+
S
would override what nx format:write
was doing and vice versa
Current Behavior
So it all started when I was setting up CI on Azure DevOps starting from official example, which includes
npx nx format:check
command. It appeared to be very troublesome, because initially it was throwing errors for .yml, .yaml, .md, .json files and even for.prettierrc
🤔 After ignoring all those file types and running(npx) nx format:write
to verify everything works as it should, I can still see that tsconfig.base.json file is formatted. And here the really weird part begins: I have*.json
ignore pattern in.prettierignore
, also tried with**.json
and**/*.json
and even addedtsconfig.base.json
explicitly. It hasn't help. Then I addedto
.prettierrc
"overrides" section - still the same! tsconfig.base.json is not being excluded 😱 And the worst part isnpx nx format:check
command fails on CI (ubuntu-latest) while working on my computer (MacOS) I went through https://github.com/nrwl/nx/issues/5611 and https://github.com/nrwl/nx/issues/4159 and saw that people have similar problems with theformat:check
command on CI, but haven't found any working solution...Expected Behavior
I'd expect both format:check and format:write commands to take my ignore statements into account.
Github Repo
No response
Steps to Reproduce
"lib": ["es2017", "dom"],
in tsconfig.json(npx) nx format:write
Nx Report
Failure Logs
EDIT: after excluding all those files and running "Reformat with prettier" on
decorate-angular-cli.js
, the command finally worked (now it fails on the next one). Still runningnx format:write
failed to solve the issue.Additional Information
No response