-
-
Notifications
You must be signed in to change notification settings - Fork 349
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 --ignore <glob> parameter #1095
Comments
What exactly is the problem with the entry in editorconfig? If the issue with the key is the lack of the prefix, we can fix that. At this point it's still unlikely I will add a flag for this unless good arguments are brought forward. "I find a flag easier than an editorconfig file" doesn't seem like a particularly strong argument. |
It is not "easier" it is not having the file at all. Let's say you want to format a repository but the maintainer of that project does not want the You then have to have to juggle with Or remember to: $ printf '[node_modules/**]\nignore = true\n' >.editorconfig && shfmt -w . && rm .editorconfig every time you work on that repo. Instead of $ shfmt -w --ignore node_modules . |
It seems to me like you have manual steps no matter what you do in this scenario. Yes, the flag is shorter/faster than the other methods, but it's still a manual step you must remember. You could always drop an Also note that editorconfig entries are a list of patterns to match filenames. And we also support matching by language (#664 (comment)). Fitting all this into a flag seems odd. |
I think the most common use case is that you format a directory and find out that 1 or 2 files (or 1 directory containing files) were formatted even though you did not want them to be formatted. $ shfmt -w .
$ git status -s
M node_modules/test.sh
M test.sh 😲 $ git reset --hard
$ shfmt --help ⇓ $ shfmt -w --ignore node_modules .
$ git status -s
M test.sh
$ git add -A
$ git commit -m 'chore: format' 🎉 $ shfmt -w .
$ git status -s
M node_modules/test.sh
M test.sh 😲 $ git reset --hard
$ shfmt --help 🤔 $ man shfmt 📘👀⌛ $ printf '[node_modules/**]\nignore = true\n' >.editorconfig
$ shfmt -w .
$ git status -s
M test.sh
?? .editorconfig 🤔 🌐👀⌛ $ git add -A -- ':!.editorconfig'
$ git commit -m 'chore: format'
$ git stash push -u -m shfm_exclude_node_modules 🎉
This depends on the In shared repositories you usually want to set that key in the repository's root directory, otherwise you will not get stable formatting between the team members thereby defeating the purpose of
This issue asks for a file-based exclusion not a language-based exclusion. See the common case above why people might want to exclude files. If one has complex needs it is better to use a config file ( |
Also, as far as I can tell, all options (but the |
Another reason I found: https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd
Well, it cannot be used for that purpose because |
I only suggest a parent EditorConfig files also stack. You can drop an
I would rather not offer, maintain, and document two parallel and different ways to ignore files and directories.
It won't. I think the man page is already clear about this, because I'm going to close this for now. I appreciate your passionate arguments, but there's a high bar to adding more options and features to this tool. |
The man page says: If any parser or printer flags are given to the tool, no EditorConfig formatting options will be used. A default like -i=0 can be used for this purpose. Since ignore=true is not a formatting option, and it's still useful when formatting options are given as flags, it should still work then. The docs said so, but we had no specific test for it. For #1095.
Having
--ignore <glob>
or however you want to call it would improve the usability of this tool.Yes, there are workarounds but they have issues.
The non-standard key in
.editorconfig
has its issue, too.Filtering while tree-walking inside of the tool is always better than piping to
xargs
, doing a for-loop, or having to create an extra file.SC2038
SC2044
The text was updated successfully, but these errors were encountered: