shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Feature: ignore a list of files without modifying them

Open lamyergeier opened this issue 3 years ago • 10 comments

For bugs

  • My shellcheck version (shellcheck --version or "online"): 0.8.0
  • [x] The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • [x] I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit

For new checks and feature suggestions

  • [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this

  • [x] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related

  • New directive to ignore file · Issue #1996 · koalaman/shellcheck, can be used to ignore files by modifying them i.e. by adding # shellcheck disable=all. But, I want to ignore certain files without modifying them.

  • Motivation: I don't want to touch files created by others.

How can I ignore a list of files? Is it posible to include that list in .shellcheckrc?

lamyergeier avatar Dec 11 '21 09:12 lamyergeier

I would like this functionality as well - especially for integration with editors/IDEs (Visual Studio Code/VSCode is my current preference). It automatically runs shellcheck on all my shell files - which is usually what I want - but I have, in my current project, a couple of specific .sh files which I intentionally want to be "bad formatted/poor quality".

Yes, I could add # shellcheck disable=all at the start of the file(s), as per #1996's comment but it would be easier to either have a .shellcheckignore in the style of .gitignore/.dockerignore or to allow .shellcheckrc to have a list of files/directories to ignore.

(currently shellcheck 0.8.0)

rbairwell avatar Jul 23 '22 10:07 rbairwell

Would love to see this

TSMMark avatar Jan 30 '23 17:01 TSMMark

me too

adamhibbert avatar Mar 03 '23 16:03 adamhibbert

Ditto. Would increase adoption (easing configuration of CI in the tool/external to the collateral) in older repositories.

qneill-sifive avatar Jul 20 '23 23:07 qneill-sifive

me too

neatudarius avatar Oct 18 '23 03:10 neatudarius

Greetings!

In case of Visual Studio Code ("VSCode"; as of version 1.83.1, 2023-10-10) and Shellcheck extension, it's possible to configure the extension to ignore specific locations due to the approach the extension is implemented, i.e. exposed class constructor parameter ignorePatterns.


From the extension documentation (as of version 0.34.0, 2023-08-27):

The shellcheck.ignorePatterns works exactly the same as search.exclude, read more about glob patterns here

For example:

{
  "shellcheck.ignorePatterns": {
    "**/*.zsh": true,
    "**/*.zsh*": true,
    "**/.git/*.sh": true,
    "**/folder/**/*.sh": true
  }
}

To add additional ignore patterns atop the default patterns, you have to copy the default ignore patterns and then add yours to the end of the list (#1196).

Source


Just in case, the above JSON excerpt may be also stated in VSCode User and Workspace Settings.


Please keep it safe and stay sublime!

Best and kind regards ✨

Related

- "Shellcheck VSCode extension": '.../src/utils/filematcher.ts'#L2; - "JSHint": '.../jshint-server/src/server.ts'#L258; - "JSHint" GitHub repository; - #2849.

serious-angel avatar Oct 25 '23 04:10 serious-angel

Hello

Just to mention such feature would be nice i.e. being able to start shellcheck in the console (not from within VSCode) with the possibility to exclude folders like with --exclude "folder1,folder2,folder3".

Here and there I see workarounds like using find xxxx | grep xxx | xargs xxx but these are slow and didn't return the correct exit code. Indeed if a shell script contains errors, I would like the get an exitCode different than 0 but, with find I get, I suppose, the exitCode of the last scanned file and this is perhaps 0 even when shellcheck has detected a lot of warnings before.

cavo789 avatar Apr 04 '24 07:04 cavo789