question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: use installed prettier version

See original GitHub issue

Expected 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

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:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
kylecordescommented, Sep 25, 2019

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.

3reactions
wKovacs64commented, Sep 24, 2019

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. running yarn prettier (or nx 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found