How to Add Support for a New Tool to Super-Linter
If you want to propose a Pull Request to add new language support or a new tool, follow these steps.
Update Documentation
- Ensure the
README.md
is updated to reflect the new linter, including its entry in the supported linters table.
Provide Test Cases
- Create a new directory:
test/linters/<LANGUAGE_NAME>
. - Provide at least one test case with a file that is supposed to pass validation (e.g.,
test/linters/<LANGUAGE_NAME>/<name-of-tool>-good.<ext>
). - Provide at least one test case with a file that is supposed to fail validation (e.g.,
test/linters/<LANGUAGE_NAME>/<name-of-tool>-bad.<ext>
). If the tool supports fix mode, the failing test case should contain only violations that can be automatically fixed. - Update expected summary reports in
test/data/super-linter-summary
. - If the tool supports fix mode, add the
<LANGUAGE>
to theLANGUAGES_WITH_FIX_MODE
array intest/testUtils.sh
.
Update the Test Suite
Update the InSpec test suite to check for the newly installed packages and commands:
test/inspec/super-linter/controls/super_linter.rb
Install the Tool
All tools are installed via the main Dockerfile
. The method depends on the tool's ecosystem:
- PyPi Packages: Add a
dependencies/python/<tool-name>.txt
file, update thePATH
in theDockerfile
, and add it to thedependabot.yml
configuration. - NPM Packages: Update
dependencies/package.json
anddependencies/package-lock.json
. - Ruby Gems: Update
dependencies/Gemfile
anddependencies/Gemfile.lock
. - Java/Gradle Packages: Create a
dependencies/<tool-name>
directory with abuild.gradle
file and an associatedscripts/install-<tool-name>.sh
script to handle the installation. - Container Images: Add a new build stage in the
Dockerfile
usingFROM your/image:version as <tool-name>
andCOPY --from=<tool-name>
to copy the binary into the final image. Add the new dependency todependabot.yml
.
Integrate the Tool
Update the core orchestration scripts to run the new tool:
lib/globals/languages.sh
: Add a new entry to theLANGUAGES_ARRAY
.lib/functions/linterCommands.sh
: Define the command to invoke the tool in a newLINTER_COMMANDS_ARRAY_<LANGUAGE_NAME>
variable.lib/globals/linterCommandsOptions.sh
: If the tool supports it, add options for "check-only" and "fix" modes.
Configure the New Tool
lib/globals/linterRules.sh
: Define a variable for the tool's configuration file name.TEMPLATES/
: Add a default, minimal configuration file for the new tool.lib/functions/linterCommands.sh
: Update the command to pass the configuration file path to the tool.
File Detection and List Building
lib/functions/buildFileList.sh
: Add logic to identify and categorize files that should be processed by the new linter.scripts/linterVersions.sh
: Add logic to retrieve and record the tool's version.lib/functions/detectFiles.sh
: If necessary, add more complex logic to detect if a file should be processed by this tool.