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

prettier-plugin-sh fails to format standard VisualStudio.gitignore file #336

Closed
interfrastic opened this issue Dec 20, 2023 · 1 comment
Closed

Comments

@interfrastic
Copy link

interfrastic commented Dec 20, 2023

I configured prettier-plugin-sh to format my .gitignore files and this worked fine until I tried to format the standard .gitignore provided for Visual Studio Code:

https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

Attempts to format the file fail with this error:

$ curl -OfsSL https://github.com/github/gitignore/raw/main/VisualStudio.gitignore
$ md5sum VisualStudio.gitignore.txt
a5dc339689e7c51d0b5fdea48a242ebb  VisualStudio.gitignore.txt
$ head VisualStudio.gitignore.txt
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
$ npx prettier --write VisualStudio.gitignore
VisualStudio.gitignore
[error] VisualStudio.gitignore: SyntaxError: a command can only contain words and redirects; encountered (
[error]   273 | *.rptproj.rsuser
[error]   274 | *- [Bb]ackup.rdl
[error] > 275 | *- [Bb]ackup ([0-9]).rdl
[error]       |              ^
[error]   276 | *- [Bb]ackup ([0-9][0-9]).rdl
[error]   277 |
[error]   278 | # Microsoft Fakes

The workaround is to comment out these two lines:

$ diff VisualStudio.gitignore.orig VisualStudio.gitignore
275,276c275,276
< *- [Bb]ackup ([0-9]).rdl
< *- [Bb]ackup ([0-9][0-9]).rdl
---
> # *- [Bb]ackup ([0-9]).rdl
> # *- [Bb]ackup ([0-9][0-9]).rdl
$ npx prettier --write VisualStudio.gitignore
VisualStudio.gitignore 31ms (unchanged)
@JounQin
Copy link
Member

JounQin commented Dec 21, 2023

Just like #278

I'm sorry, but actually ignore files are not officially supported by https://github.com/mvdan/sh what means only basic and simple ignore files usage cases can be handled correctly. We can not do much inside.

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants