un-ts / prettier

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

[prettier-plugin-sh] Fails in Dockerfile using "RUN if" #292

Closed barona-mika-vilpas closed 8 months ago

barona-mika-vilpas commented 8 months ago

Hello, just ran into this error:

❯ npx prettier --write node/Dockerfile.template
node/Dockerfile.template
[error] node/Dockerfile.template: SyntaxError: "then" can only be used in an if
[error]   24 |     )
[error]   25 |
[error] > 26 | RUN if [[ x$LATEST_NPM = xtrue ]]; then yarn global add npm@latest; fi
[error]      |                                    ^
[error]   27 |
[error]   28 | ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
[error]   29 |

Any ideas what might be wrong?

JounQin commented 8 months ago

Please provide a runnable reproduction, thx.

barona-mika-vilpas commented 8 months ago

Here's a minimal reproduction. The readme contains instructions on how to reproduce the error.

https://github.com/barona-mika-vilpas/un-ts-issue-reproduction

JounQin commented 8 months ago

Sorry I don't have enough time recently, I'll try to review your reproduction ASAP.

JounQin commented 8 months ago

I'm sorry, but actually Dockerfile is not officially supported by mvdan/sh what means only basic and simple Dockerfile usage cases can be handled correctly. We can not do much inside.