nx
nx copied to clipboard
Ability to turn off prettier
Add the ability to turn off prettier, specifically in generators. Currently, prettier is installed automatically with npm 7/8, which there is no way to completely turn it off.
Description
For teams that dislike prettier, it would be nice to be able to turn it completely off.
Motivation
Prettier can cause headaches in larger teams and unnecessary code changes to review.
Suggested Implementation
Take into account the .prettierignore
for all prettier tasks.
Alternate Implementations
Either add a setting in nx.json
, or change prettier to be optionalDependencies
and checking if installed before using.
On VS Code you can easily disable prettier on a specific workspace by just going on extensions and disabling it. I am sure other IDE have something similar.
On VS Code you can easily disable prettier on a specific workspace by just going on extensions and disabling it. I am sure other IDE have something similar.
I'm not talking about prettier in IDE here. I don't have that plugin installed. This is about the nx generators using prettier.
Could you please provide a repo with repro steps to get the error you are seeing?
prettier
should already be optional so this is a bug :sweat:
Please help us reproduce it and we can fix it.
From the npm documentation: https://docs.npmjs.com/cli/v7/configuring-npm/package-json#peerdependencies
In npm versions 3 through 6, peerDependencies were not automatically installed, and would raise a warning if an invalid version of the peer dependency was found in the tree. As of npm v7, peerDependencies are installed by default.
So just create a new nx workspace on npm 7 or 8, and you'll see it install prettier automatically.
As you can see prettier is added to the package.json
and also installed via peerDependencies
.
Even upgrading to nx 13 and removing prettier from the package.json
, it will still be installed.
Repo: https://github.com/flippidippi/nx-prettier-bug
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. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
Reopen. Still an issue.
Hi,
This is still an issue in NX version 13.8.0. With the prettier packages removed (prettier, eslint-config-prettier, eslint-plugin-prettier), eslint fails with the following error:
UnhandledPromiseRejectionWarning:` Error: Failed to load config "prettier" to extend from.
Referenced from: .../node_modules/@nrwl/eslint-plugin-nx/src/index.js
at configInvalidError (.../node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2596:9)
I had to remove prettier from the extends
attribute of the default eslint configs in:
@nrwl/eslint-plugin-nx/src/configs/javascript.js
@nrwl/eslint-plugin-nx/src/configs/typescript.js
I have also encountered this same issue. I would like to not use prettier but keep eslint. Can it be possible to have prettier be optional?
This is an issue. We are not using prettier though the eslint-plugin-nx wants to extend the config of it. Please decouple the extension in the configs.
@FrozenPandaz can we reopen this issue? Also seeing
Failed to load config "prettier" to extend from.
Referenced from: @nrwl/eslint-plugin-nx/src/index.js
You are right @johnameyer, I will reopen this issue.
I can see .prettierignore in the root of the repo maybe we can just add
/apps /libs
into it while this issue still the case?
Until this issue is fixed, one can simply merge eslint
config from the following files from @nrwl/eslint-plugin-nx
into their root eslint
config (of course, without prettier
extension):
Don’t forget to remove these extends
from your eslint
config:
-
plugin:@nrwl/nx/typescript
; -
plugin:@nrwl/nx/javascript
.
hey @meeroslav , this PR has added about 6+ seconds of lint overhead to our current project. It's particularly bad because it's a mono repo, and this is doing an npm ls
4 times, which is costly.
Overall we have 28 total libs/apps in our NX monorepo, each which incurs a 6 second hit when using run-many
. now our lint build has gone from ~40 seconds to 7+ minutes. this will not scale well for us as we add more.
Is this something we can look into?
Hey @danielwong2268,
The performance impact you are mentioning has been fixed a few weeks ago in this PR: https://github.com/nrwl/nx/pull/11603 and landed in v14.5.7
.
Please update to the latest version of nx.
👍 thank you
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.