Like other linting tools (jshint, eslint, sass-lint, etc) does shellcheck support an external rules file to override default rules?
It currently does not. The closest thing right now is the environment variable SHELLCHECK_OPTS.
@koalaman How about passing desired rules to "skip" via CLI? I thought I saw this somewhere, but I cant seem to find it?
There's an -e/--exclude flag. See https://github.com/koalaman/shellcheck/wiki/Ignore
@koalaman perfect, this will suffice. Using Atom and I can supply CLI arguments.
Have you considered providing yml support? Not urgent, sure it is a small use case. Just curious
I haven't put much thought into it myself, but I'm easily swayed by popular vote so leave this bug open
@koalaman sounds good. I have an acceptable workaround for the time being, but would be a nice addition 馃憤
I think support for this kind of file-based configuration would be awesome.
Include a .shellcheck.yml in your Git repository and everyone has the same experience; easily copy it from project to project and make all your shell scripts more robust.
tl;dr: 馃憤 from my side
+1 from me also for a .shellcheck.yml file, or for reading a section from setup.cfg.
This is similar to #323, so we should try to keep them both in mind.
So it's not yml since it just reuses the directive parsing code, but 581bcc3907 adds support for this. Here's the description for the man page:
Unless --norc is used, ShellCheck will look for a file .shellcheckrc or
shellcheckrc in the script's directory and each parent directory. If found,
it will read key=value pairs from it and treat them as file-wide directives.
Here is an example .shellcheckrc:
# Don't suggest using -n in [ $var ]
disable=SC2244
# Allow using `which` since it gives full paths and is common enough
disable=SC2230
If no .shellcheckrc is found in any of the parent directories, ShellCheck
will look in ~/.shellcheckrc followed by the XDG config directory
(usually ~/.config/shellcheckrc) on Unix, or %APPDATA%/shellcheckrc` on
Windows. Only the first file found will be used.
Note for Snap users: the Snap sandbox disallows access to hidden files.
Use shellcheckrc without the dot instead.
Note for Docker users: ShellCheck will only be able to look for files that
are mounted in the container, so ~/.shellcheckrc will not be read.
Fantastic! Will this appear in 0.7.0 sometime soon?
That would be better to file as a new issue so it's not lost
Most helpful comment
So it's not yml since it just reuses the directive parsing code, but 581bcc3907 adds support for this. Here's the description for the man page:
RC FILES
Unless
--norcis used, ShellCheck will look for a file.shellcheckrcorshellcheckrcin the script's directory and each parent directory. If found,it will read
key=valuepairs from it and treat them as file-wide directives.Here is an example
.shellcheckrc:If no
.shellcheckrcis found in any of the parent directories, ShellCheckwill look in
~/.shellcheckrcfollowed by the XDG config directory(usually
~/.config/shellcheckrc) on Unix, or %APPDATA%/shellcheckrc` onWindows. Only the first file found will be used.
Note for Snap users: the Snap sandbox disallows access to hidden files.
Use
shellcheckrcwithout the dot instead.Note for Docker users: ShellCheck will only be able to look for files that
are mounted in the container, so
~/.shellcheckrcwill not be read.