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.

Seamlessly handle re-loading Prettier if it has been changed

See original GitHub issue

Is your feature request related to a problem? Please describe. Currently if the version of Prettier inside of a project changes (typically from an npm or yarn install), the version the extension uses becomes stale, still using the version it initially cached, leading to changes on save that may not match what the Prettier CLI would output. As this point reloading the VS Code window is necessary in order to have the extension pick up the correct, new, version of Prettier and use it instead.

Describe the solution you’d like I think a working solution here would be to setup a file watcher for the found modules directory. If a change is made to any of those files / the directory itself, then we can invalidate the existing cache we have, allowing the next save to re-detect the module it should be using to run Prettier on the file.

Describe alternatives you’ve considered An alternative solution would be to add a command which can reset the cache on demand. This would be be slightly better than reloading the entire window, but would still need to be on demand, meaning you have to know you need to do it.

Additional context I’ve primarily hit this problem when rolling out a Prettier upgrade org-wide. People tend to upgrade their dependencies, then hit VS Code formatting things improperly and reach out for support. FWIW I’ve hit the same problem with the VS Code ESLint extension 😞.

Figured I’d toss up an issue for this for discussion @ntotten. I’ve also started a WIP branch so you can get a general sense of what I’m thinking about here: https://github.com/prettier/prettier-vscode/compare/master...JHilker:experiment-with-file-watching. It’s definitely a bit messy with debugging logic, but is for the most part fully functional (aside from the global module resolution logic) if you want to check it out locally. I’m also planning on adding tests before tossing up a PR if you think this is a change you’d like to see in the extension.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ntottencommented, Mar 17, 2021

log no longer specifies what version of Prettier is loaded making it a bit harder

Enable debug logs for the extension. I reduced the default logging.

0reactions
github-actions[bot]commented, Oct 25, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Seamlessly handle re-loading Prettier if it has been changed
I think a working solution here would be to setup a file watcher for the found modules directory. If a change is made...
Read more >
Speeding up Prettier locally and on your CI with dprint
Sometime though hot reload just fails and I had to manually reload the page, or manually remount the component I'm working on (by...
Read more >
Ember.js - A framework for ambitious web developers
And tools like Prettier pair perfectly with your Ember app's JavaScript code. Manage State Authenticate Translate Deploy. Ember Concurrency is an Ember addon ......
Read more >
Laravel Development on Windows in 2022 - kleypot
The first thing you should do is install Windows Subsystem for Linux ... WSL has completely changed the way I develop in Windows,...
Read more >
Configure TypeScript, TSLint, and Prettier in VS Code for ...
In this guide I will show you how to configure VS Code to handle your code formatting, linting, and type checking. Updated article...
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