From 8227f790741922a4b205f5feee79be947c379b19 Mon Sep 17 00:00:00 2001 From: Kurt von Laven Date: Mon, 30 Aug 2021 09:19:56 -0700 Subject: [PATCH] Add a template config file for ShellCheck (#1900) * Improve wording of LINTER_RULES_PATH docs (#1634). * Add a template config file for ShellCheck (#1633). Instruct ShellCheck to search SCRIPTDIR, the directory that the script being linted is in, for other scripts that are sourced. Otherwise, the commonly-used source command results in linter error SC1091. See https://github.com/koalaman/shellcheck/wiki/SC1091 for more details. * fix line ending Co-authored-by: Lukas Gravley --- README.md | 6 +++--- TEMPLATES/.shellcheckrc | 1 + TEMPLATES/README.md | 2 +- docs/disabling-linters.md | 2 +- lib/linter.sh | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 TEMPLATES/.shellcheckrc diff --git a/README.md b/README.md index 64c16ece..820504be 100644 --- a/README.md +++ b/README.md @@ -388,12 +388,12 @@ But if you wish to select or exclude specific linters, we give you full control You can use the **GitHub** **Super-Linter** _with_ or _without_ your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level. -- Copy **any** or **all** template rules files from `TEMPLATES/` into your repository in the location: `.github/linters/` of your repository - - If your repository does not have rules files, they will fall back to defaults in [this repository's `TEMPLATE` folder](https://github.com/github/super-linter/tree/master/TEMPLATES) +- Copy **any** or **all** template rules files from `TEMPLATES/` into the `.github/linters/` directory of your repository, and modify them to suit your needs. + - The rules files in [this repository's `TEMPLATE` folder](https://github.com/github/super-linter/tree/master/TEMPLATES) will be used as defaults should any be omitted. ### Using your own rules files -If your repository contains your own rules files that live outside of a ``.github/linters/`` directory, you will have to tell Super-Linter where your rules files are located in your repository, and what their file names are. To learn more, see [Using your own rules files](docs/using-rules-files.md). +If your repository contains your own rules files that live outside of a `.github/linters/` directory, you will have to tell Super-Linter where your rules files are located in your repository, and what their filenames are. To learn more, see [Using your own rules files](docs/using-rules-files.md). ### Disabling rules diff --git a/TEMPLATES/.shellcheckrc b/TEMPLATES/.shellcheckrc new file mode 100644 index 00000000..472bfba3 --- /dev/null +++ b/TEMPLATES/.shellcheckrc @@ -0,0 +1 @@ +source-path=SCRIPTDIR diff --git a/TEMPLATES/README.md b/TEMPLATES/README.md index 2e539781..23604c68 100644 --- a/TEMPLATES/README.md +++ b/TEMPLATES/README.md @@ -1,6 +1,6 @@ # TEMPLATES -The files in this folder are template rules for the linters that will run against your code base. If you chose to copy these to your local repository in the directory: `.github/linters` they will be used at runtime. If they are not present, they will be used by default in the linter run. +The files in this folder are template rules for the linters that will run against your code base. If you choose to copy these to your local repository in the `.github/linters/` directory, they will be used at runtime. If rule files are not present locally, the templates will be used by default. The file(s) will be parsed at run time on the local branch to load all rules needed to run the **Super-Linter** **GitHub** Action. The **GitHub** Action will inform the user via the **Checks API** on the status and success of the process. diff --git a/docs/disabling-linters.md b/docs/disabling-linters.md index 69d7c85e..76cd36d8 100644 --- a/docs/disabling-linters.md +++ b/docs/disabling-linters.md @@ -2,7 +2,7 @@ Linters can often require additional configuration to ensure they work with your codebase and your team's coding style, to avoid flagging false-positives. The **GitHub Super-Linter** has set up some default configurations for each linter which should work reasonably well with common code bases, but many of the linters can be configured to disable certain rules or configure the rules to ignore certain pieces of codes. -To run with your own configuration for a linter, copy the relevant [`TEMPLATE` configuration file for the linter you are using from this repo](https://github.com/github/super-linter/tree/master/TEMPLATES) into the `.github/linters` folder in your own repository, and then edit it to modify, disable - or even add - rules and configuration to suit how you want your code checked. +To run with your own configuration for a linter, copy the relevant [`TEMPLATE` configuration file for the linter you are using from this repo](https://github.com/github/super-linter/tree/master/TEMPLATES) into the `.github/linters/` folder in your own repository, and then edit it to modify, disable - or even add - rules and configuration to suit how you want your code checked. How the changes are made differ for each linter, and also how much the **Github Super-Linter** has decided to change the linter's defaults. So, for some linters (e.g. [pylint for python](https://github.com/github/super-linter/blob/master/TEMPLATES/.python-lint)), there may be a large configuration file. For others (e.g. [stylelint for CSS](https://github.com/github/super-linter/blob/master/TEMPLATES/.stylelintrc.json)) the default configuration file may initially be nearly empty. And for some (e.g. StandardJS) it may not be possible to change configuration at all so there is no Template file. diff --git a/lib/linter.sh b/lib/linter.sh index 68284de2..2c061599 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -66,7 +66,7 @@ source /action/lib/functions/worker.sh # Source the function script(s) ########### # Default Vars DEFAULT_RULES_LOCATION='/action/lib/.automation' # Default rules files location -LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory +LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter rules directory GITHUB_API_URL="${GITHUB_CUSTOM_API_URL:-"https://api.github.com"}" # GitHub API root url VERSION_FILE='/action/lib/functions/linterVersions.txt' # File to store linter versions export VERSION_FILE # Workaround SC2034