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

Feature: ignore a list of files without modifying them #2411

Open
4 tasks done
lamyergeier opened this issue Dec 11, 2021 · 10 comments
Open
4 tasks done

Feature: ignore a list of files without modifying them #2411

lamyergeier opened this issue Dec 11, 2021 · 10 comments

Comments

@lamyergeier
Copy link

lamyergeier commented Dec 11, 2021

For bugs

For new checks and feature suggestions

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

@rbairwell
Copy link

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)

@TSMMark
Copy link

TSMMark commented Jan 30, 2023

Would love to see this

@adamhibbert
Copy link

me too

@qneill-sifive
Copy link

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

@neatudarius
Copy link

me too

@artshade
Copy link

artshade commented Oct 25, 2023

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.

@cavo789
Copy link

cavo789 commented Apr 4, 2024

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.

@keszybz
Copy link

keszybz commented Jul 24, 2024

I have a slightly different use case:
the project generates a shell completion script by combining a static file completions/something.bash, completions/something.fish, …, and a second part dynamically generated from Python argparse config. The static script looks like a shell script, it even has the header with a license comment and she-bang, but does not define all variables. I'd like to configure shellcheck to ignore this partial script. I do not want to silence the warnings in the file, because then they'd also be silenced in the combined script.

@kantum
Copy link

kantum commented Oct 2, 2024

Hi,

I have a .env file that I want to ignore (because its not a script in the first place).

I have githooks using shellcheck.

When I encrypt my .env with sops, the comment get encrypted and shellcheck is triggered and I have no way to ignore it.

Anyone has an idea why this issue is not addressed? I cannot find any good reason not to add a .shellcheckignore or something similar.

I'm willing to contribute if someone have the time to give me direction.

@artshade
Copy link

artshade commented Oct 9, 2024

Anyone has an idea why this issue is not addressed? I cannot find any good reason not to add a .shellcheckignore or something similar.

My apologies, I am not personally into Haskell currently enough to contribute in fairly near future.
Though, regarding the case, if we consider the .gitignore file, I would not expect a .shellcheckignore file but a CLI flag option (e.g. -i, -I, --ignore, --gitignore, --git-ignore), which would respect the .gitignore file in the current Git repository. There are Haskell libraries like the following, which should support the case:

vcs-ignore is small Haskell library used to find, check and process files ignored by selected VCS.
Source

While vcs-ignore is mainly intended to be used as a library, it also comes with small executable called ignore that can be used standalone to verify whether given path is ignored or not.
Source

Otherwise, if not Git but a more built-in exclusion, I would expect a similar to GNU tar CLI parameter options --files-from and --exclude-from:

-T, --files-from=FILE
get names to extract or create from FILE...
-X, --exclude-from=FILE
exclude patterns listed in FILE

Source

And, the "pattern" would either be the standard glob, more complex BRE/ERE, or even the marvelous PCRE but we should also consider the speed of such operations in the context of syntax validation and highlighting. Just in case, a few TypeScript references regarding the speed aspect:

Typescript is an amazing project, but a perplexing open-source blackbox... The type checker itself is Typepscript's largest component and it’s a single 25 thousand line file.
Source

Internally Deno uses Microsoft’s TypeScript compiler to check types and produce JavaScript. Compared to the time it takes V8 to parse JavaScript, it is very slow... We certainly think there are improvements that can be done here on top of the existing TypeScript compiler, but it’s clear to us that ultimately the type checking needs to be implemented in Rust.
Source

Related: microsoft/TypeScript#51387 (Convert the codebase to modules...)

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

10 participants