Feature Request: use installed prettier version
See original GitHub issueExpected Behavior
I’d expect nx
to use the installed prettier
version for formatting.
Running prettier
or nx format
on the command line for the same file should yield the SAME results.
Current Behavior
Nx uses a fixed internal version of prettier and ignores the installed prettier version
Failure Information (for bugs)
Steps to Reproduce
- install nx version 8.5.0
- install prettier version 1.18.2
E.g. use else
in an Angular template
<div *ngIf="someBoolean; else otherTemplate">
</div>
now the following checks should yield the same result:
$ nx format:check --files login.component.html
$ prettier -c login.component.html
But since nx version 8.5.0
uses an older version of prettier (1.16.4
), the results are inconsistent.
Other
When nx uses the installed prettier version this can avoid
- confusion: e.g. Stackoverflow: prettier vs. nx format:check
- inconsistencies fix(nx): update workspace to use prettier v1.18.2
- and we can use newer prettier versions without updating nx
Notes:
- If using the installed prettier version is not possible, then maybe nx can at least show an error/warning when the installed prettier version does not match
- The
nx format
docs should mention that nx ignores the installed prettier version - It would be helpful to have an nx command to print the internal prettier version
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Options
If you change any options, it's recommended to do it via a configuration file. This way the Prettier CLI, editor integrations and other...
Read more >How to configure Prettier and VSCode
To use the Prettier we have just installed from VSCode we need to install the Prettier VSCode extension: Launch VS Code Quick Open...
Read more >prettier-eslint
Start using prettier-eslint in your project by running `npm i ... then it will use the version that prettier-eslint has installed locally.
Read more >Rust with Visual Studio Code
You should install the Release Version. rust-analyzer extension in the Extensions view. We'll discuss many of rust-analyzer features in this ...
Read more >Tooling - GitLab Docs
The recommended method to include Prettier in your workflow is to set up your preferred editor (all major editors are supported) accordingly. We...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah, based on that above info, I think maybe this item should be titled something more like:
“Make prettier a peerDependency instead of a dependency”
I don’t know if this is a good idea or if the Nx team wants it, but it’s much more plausibly good than the earlier interpretation “use the globally installed prettier” that a bunch of us immediately dismissed.
Personally, I would be very surprised if a project used my globally installed version of a tool rather than the package-local version. The current behavior is exactly what I would expect. Running
prettier
(globally installed) vs. runningyarn prettier
(ornx format:check
in this case) mean different things. Is this more of a documentation opportunity rather than a code/behavior change?Maybe I am in the minority here and checking for a globally installed version of something to take precedence over a package-local version is more conventional than I realize. If so, can someone point to a common/popular example of where this happens? Always happy to educate myself.
Thanks.