Plugin is Too Aggressive at Formatting Non Shell Files (crontabs and others)

Posted 5 months ago

Plugin is Too Aggressive at Formatting Non Shell Files (crontabs and others) #258

Why in the world is this tool called vs-shell-format if it can format a dozen different syntax/languages? Incredibly misleading and frankly it breaks the DOTW (Do One Thing Well) mantra of software engineering. I digress.

The problem at hand for me is I want to use this plugin to format shell scripts only. It's formatting all sorts of other files outside of the traditional *.sh files - that may be VS Code's problem and not this plugin. Regardless, I have a crontab file that I'm editing in VS Code titled as such, yet it's getting formatted as if it were a shell script. My snippet:

# The following is the original
0 3 * * * . "$HOME"/.env-crontab; run_some_command > /dev/null

# The following is the output after saving
0 3 * * * . "$HOME"/.env-crontab
run_some_command >/dev/null

Crontabs don't support multiple-line commands and thus, this plugin is breaking my crontabs while editing. I've tried adding an .editorconfig file that has no effect (I'm not specifying any custom shfmt flags, I've checked the Shellformat: Use Editor Config checkbox in settings, my editor config looks like the following):

ignore = true

It's incredibly frustrating when a tool doesn't follow the principle of least surprise and has odd side-effects that cannot be overridden nor are documented well or at all.

What can I do to fix this or how can we patch this plugin to not be so aggressive at formatting files that it shouldn't?

Created 3 months ago

Any thoughts on this? It's been 2 months now without any comments.

Created 2 days ago

5 months is ample time to at least acknowledge this issue. Is there a way I can get this plugin to only format my shell scripts and exclude cron files or not?