Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile format #640

Closed
sbrunner opened this issue Dec 6, 2020 · 3 comments
Closed

Add Dockerfile format #640

sbrunner opened this issue Dec 6, 2020 · 3 comments

Comments

@sbrunner
Copy link

sbrunner commented Dec 6, 2020

Some plugin using this project like:

Use this formatter to format Dockerfile and with correct option, the result is not so bad but in prefect...

Isn't possible to support it officially?

The issues I detect:
Removing some ending '; ':

RUN set -eux; \
    false; \
    true

=>

RUN set -eux
false
true

Error with multiline if and for:

RUN if [ "$TEST" == TRUE ]; \
    then \
    echo test; \
    fi

=> error:

"then" can only be used in an if
RUN for item in "${TEST}"; \
    do \
        echo $item; \
    done

=> error:

"do" can only be used in a loop
@mvdan
Copy link
Owner

mvdan commented Dec 7, 2020

Sorry, but this software does not aim to parse or format Dockerfiles. It parses and formats shell. Dockerfiles simply embed bits of shell in them, but the overall syntax is not shell.

A previous occurrence of this issue is #424. cc @JounQin @kaey

My overall thoughts are that someone could easily build a Dockerfile formatter in Go on top of this shell formatter. The closest one that I know of is https://github.com/jessfraz/dockfmt; it does its own simple formatting of shell code, which is why I raised jessfraz/dockfmt#2 a while back. The issue is labeled "help wanted", so I'm sure a PR would be welcome.

@JounQin
Copy link
Contributor

JounQin commented Mar 24, 2021

@sbrunner binaryNextLine is auto enabled in prettier-plugin-sh, so actually it's not a problem for prettier-plugin-sh.

@mvdan
Copy link
Owner

mvdan commented Mar 25, 2021

I got no answer to the above, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants