un-ts / prettier

:package: Opinionated but Incredible Prettier plugins.
https://prettier.vercel.app
MIT License
261 stars 23 forks source link

`[error] Couldn't resolve parser "sh".` when upgrading to Prettier 3.1.0 #310

Closed nbouvrette closed 7 months ago

nbouvrette commented 7 months ago

I just upgraded to Prettier 3.1.0 this morning and got this new error:

[error] Couldn't resolve parser "sh".

When I downgrade to Prettier 3.0.3 the problem dissapears.

How to reproduce:

1) Clone https://github.com/Avansai/next-multilingual 2) Edit packages.json and set Prettier to version 3.1.0 3) run npm install 4) run npm test

JounQin commented 7 months ago
image

Seems like a prettier core bug?

cc @fisker @sosukesuzuki

fisker commented 7 months ago

I'll take a look.

fisker commented 7 months ago

Not bug. Missed plugins https://github.com/Avansai/next-multilingual/blob/main/example/.prettierrc.yaml

fisker commented 7 months ago
$ npx prettier --find-config-pah example/.env.development
example/.prettierrc.yaml
JounQin commented 7 months ago

I just upgraded to Prettier 3.1.0 this morning and got this new error:

When I downgrade to Prettier 3.0.3 the problem dissapears.

@fisker But it seems a regression, what means config resolution changed.

fisker commented 7 months ago

Maybe a bug was fixed accidentally.

fisker commented 7 months ago

Oh, caused by https://github.com/prettier/prettier/pull/15433, in pre-v3.1 we doesn't format that file at all.

https://github.com/Avansai/next-multilingual/blob/c48503df8062304e215919a9ea2f04476d9b253a/package.json#L109C18-L109C36

fisker commented 7 months ago

And that's a bug you rasied.. https://github.com/prettier/prettier/issues/15079 😄

JounQin commented 7 months ago

OK, last thing is that the error message is a bit confusing? It successfully understands that it should use sh as the parser what means prettier-plugin-sh is already loaded correctly.

fisker commented 7 months ago

No, the plugin is not loaded, the config file tells prettier to use that parser, https://github.com/Avansai/next-multilingual/blob/c48503df8062304e215919a9ea2f04476d9b253a/example/.prettierrc.yaml#L25

JounQin commented 7 months ago

Hah, that makes sense then! Thanks for your explanation! Close due to answered as above then.

nbouvrette commented 7 months ago

Thanks @fisker and @JounQin - I'm not sure why it was working before?

I thought there was some sort of inheritance but maybe this is gone? in any case adding the plugins section in the example prettier config seems to solve the issue.

JounQin commented 7 months ago

I'm not sure why it was working before?

Oh, caused by https://github.com/prettier/prettier/pull/15433, in pre-v3.1 we doesn't format that file at all.

Please read the conversation carefully.

nbouvrette commented 7 months ago

I think I get it - thanks for looking into this!