fix: fallback to bundled Prettier when finding Prettier 2 #960
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
yaml-language-server
uses Prettier 2.x to power its formatting, this confuse our formatting because we expect Prettier 3. Really, they shouldn't be using Prettier in the first place (see redhat-developer/yaml-language-server#933), but alas, they do. We don't use their formatting at all, but still this affects us.This PR refactor the package loading to not try to load Prettier 2 when it's there, which should fix both this situation and also when people have dependencies using Prettier 2. Installing Prettier in your own repo also still works, as
require.resolve
will find it first before more nested versions.Fix #946
Testing
Tests should still pass, and tested locally that it outputs the error message correctly
Docs
N/A