### Dockerfile Installation Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Example of Dockerfile instructions for installing a linter. This snippet shows how to copy a binary from a builder stage and initialize it. ```dockerfile FROM accurics/terrascan:latest as terrascan COPY --from=terrascan /go/bin/terrascan /usr/bin/ RUN terrascan init ``` -------------------------------- ### Dockerfile Instructions Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Example of specifying Dockerfile instructions as strings for installation overrides. ```json [ "ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk", "ENV PATH=\"$JAVA_HOME/bin:${PATH}\"" ] ``` -------------------------------- ### SQL Pre-command Example with Composer Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html An example of a pre-command configuration using 'composer install' for a workspace directory. ```json { "command": "composer install", "continue_if_failed": false, "cwd": "workspace" } ``` -------------------------------- ### Dockerfile Installation Override Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Provides Dockerfile instructions to install a linter for a specific platform, overriding default installation steps. ```json { "dockerfile": [ "FROM accurics/terrascan:latest as terrascan", "COPY --from=terrascan /go/bin/terrascan /usr/bin/", "RUN terrascan init" ] } ``` -------------------------------- ### Gem Package Installation Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Example of a list of Gem packages for Ruby linters. Specify package names with or without versions. ```ruby [ "rubocop:0.82.0", "rubocop-github:0.16.0", "rubocop-performance" ] ``` -------------------------------- ### NPM Package Installation Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Example of a list of NPM packages for Node.js linters. Specify package names with or without versions. ```javascript [ "eslint", "eslint-config-airbnb@3.2.1" ] ``` -------------------------------- ### Example Composer Install Command Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Demonstrates a command configuration for PHP projects using Composer, specifying the command, failure handling, and working directory. ```json [ { "command": "composer install", "continue_if_failed": false, "cwd": "workspace" } ] ``` -------------------------------- ### APK Packages Installation Override Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Lists APK packages required for linter installation on Linux, overriding default installation steps. ```json [ "perl", "perl-dev" ] ``` -------------------------------- ### PIP Package Installation Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Example of a list of PIP packages for Python linters. Specify package names with or without versions. ```python [ "flake8" ] ``` -------------------------------- ### Example Pre-run Command Configuration Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Defines a bash command to run before Megalinter starts. This example shows how to execute an npm test script, with options to control failure behavior and the working directory. ```json [ { "command": "npm run test", "continue_if_failed": false, "cwd": "workspace" } ] ``` -------------------------------- ### Linter Definition Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Defines the behavior and installation for a specific linter, such as ESLint. Includes configuration arguments, installation packages, and example commands. ```json { "cli_config_extra_args": [ "--no-eslintrc", "--no-ignore" ], "config_file_name": ".eslintrc.yml", "examples": [ "eslint myfile.js", "eslint -c .eslintrc.yml --no-eslintrc --no-ignore myfile.js" ], "install": { "npm": [ "eslint", "eslint-config-airbnb", "eslint-config-prettier", "eslint-plugin-jest", "eslint-plugin-prettier", "babel-eslint" ] }, "linter_banner_image_url": "https://d33wubrfki0l68.cloudfront.net/3b5ac7586466159bb6f237b633bfc4f5a8d5acf8/ee0a1/assets/img/posts/eslint-collective.png", "linter_name": "eslint", "linter_url": "https://eslint.org", "name": "JAVASCRIPT_ES" } ``` -------------------------------- ### NPM Package Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Example of specifying an NPM package identifier for installation overrides. ```json [ "sfdx-cli" ] ``` -------------------------------- ### djlint Command Line Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/html_djlint.md Example of how to run djlint on multiple HTML files from the command line. ```shell djlint myfile1.html myfile2.html ``` -------------------------------- ### NPM Packages Installation Override Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Lists NPM packages required for linter installation, overriding default installation steps. ```json { "npm": [ "eslint", "eslint-config-airbnb", "eslint-config-prettier", "eslint-plugin-jest", "eslint-plugin-prettier", "babel-eslint" ] } ``` -------------------------------- ### Example Pre-Run Command Configuration Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Illustrates how to configure a pre-run command, specifying the bash command, failure handling, working directory, and output variables. ```json [ { "command": "npm run test", "continue_if_failed": false, "cwd": "workspace", "output_variables": [ "VAR_NAME" ] } ] ``` -------------------------------- ### Install Grype Linter Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/repository_grype.md Installs the Grype vulnerability scanner using a script from GitHub. This is typically used in Dockerfile setups. ```dockerfile ARG REPOSITORY_GRYPE_VERSION=0.112.0 RUN curl -sSfL https://raw.githubusercontent.com/anchore/grype/refs/tags/v${REPOSITORY_GRYPE_VERSION}/install.sh | sh -s -- -b /usr/local/bin ``` -------------------------------- ### Example of Pre-run Command Configuration Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Shows a basic configuration for a pre-run command, including the command itself. ```json [ { "command": "npm install" } ] ``` -------------------------------- ### ESLint Linter Configuration Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/descriptor.html Configuration for the ESLint linter, including installation commands, configuration file name, and example usage. ```json [ { "cli_config_extra_args": [ "--no-eslintrc", "--no-ignore" ], "config_file_name": ".eslintrc.yml", "examples": [ "eslint myfile.js", "eslint -c .eslintrc.yml --no-eslintrc --no-ignore myfile.js" ], "install": { "npm": [ "eslint", "eslint-config-airbnb", "eslint-config-prettier", "eslint-plugin-jest", "eslint-plugin-prettier", "@babel/eslint-parser" ] }, "linter_banner_image_url": "https://d33wubrfki0l68.cloudfront.net/3b5ac7586466159bb6f237b633bfc4f5a8d5acf8/ee0a1/assets/img/posts/eslint-collective.png", "linter_name": "eslint", "linter_url": "https://eslint.org", "name": "JAVASCRIPT_ES" }, { "examples": [ "standard myfile.js" ], "install": { "npm": [ "standard" ] }, "linter_banner_image_url": "https://github.com/standard/standard/raw/master/sticker.png", "linter_name": "standard", "linter_url": "https://github.com/standard/standard", "name": "JAVASCRIPT_STANDARD" } ] ``` -------------------------------- ### npmPkgJsonLint Command Line Examples Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/json_npm_package_json_lint.md Demonstrates various ways to use the npmPkgJsonLint command-line tool with different patterns and options. ```shell npmPkgJsonLint --version ``` ```shell npmPkgJsonLint . ``` ```shell npmPkgJsonLint ./packages ``` ```shell npmPkgJsonLint ./package1 ./package2 ``` ```shell npmPkgJsonLint -c ./config/.npmpackagejsonlintrc.json . ``` ```shell npmPkgJsonLint --configFile ./config/npmpackagejsonlint.config.json . ``` ```shell npmPkgJsonLint -q . ``` ```shell npmPkgJsonLint --quiet ./packages ``` ```shell npmPkgJsonLint . --ignorePath .gitignore ``` ```shell npmPkgJsonLint . -i .gitignore ``` ```shell npmPkgJsonLint . --maxWarnings 10 ``` ```shell npmPkgJsonLint . -mw 10 ``` -------------------------------- ### Kubescape List Controls Command Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/kubernetes_kubescape.md Example command to list the supported controls that Kubescape can check. ```shell kubescape list controls ``` -------------------------------- ### Revive Command-Line Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/go_revive.md Demonstrates how to run the revive linter with specific configuration options, including a configuration file, formatter, excluded files, and target directories. ```shell revive -config c.toml -formatter friendly -exclude a.go -exclude b.go ./... ``` -------------------------------- ### Example Pre-Run Command: Specify Working Directory Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html This example demonstrates how to specify the working directory for a pre-run command. 'workspace' indicates the command will run in the checked-out code folder. ```json { "cwd": "workspace" } ``` -------------------------------- ### Mypy Stub Installation Failed Resolution Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/python_mypy.md Example of pre-installing Mypy type stub packages using a pre-command in .mega-linter.yml. ```yaml PYTHON_MYPY_PRE_COMMANDS: - command: "pip install types-requests types-PyYAML" venv: mypy continue_if_failed: false ``` -------------------------------- ### Zizmor CLI Example Calls Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/action_zizmor.md Demonstrates various ways to call the zizmor command-line tool with different file inputs and configurations. ```shell zizmor ci.yml tests.yml lint.yml action.yml ``` ```shell zizmor ./subdir/ci.yml ../sibling/tests.yml ./action/action.yml ``` ```shell zizmor . ``` ```shell zizmor --config zizmor.yml . ``` -------------------------------- ### Install Salesforce CLI and Packaging Plugin Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/salesforce.md Installs specific versions of the Salesforce CLI and its packaging plugin using npm. This is part of the Dockerfile setup for MegaLinter. ```dockerfile # renovate: datasource=npm depName=@salesforce/cli ARG NPM_SALESFORCE_CLI_VERSION=2.136.8 # renovate: datasource=npm depName=@salesforce/plugin-packaging ARG NPM_SALESFORCE_PLUGIN_PACKAGING_VERSION=2.28.3 ``` -------------------------------- ### Run Custom Flavor Setup Command Source: https://github.com/oxsecurity/megalinter/blob/main/docs/custom-flavors.md Execute this command in your repository folder to start the custom flavor setup process. You can optionally specify linters to include. ```bash npx mega-linter-runner@beta --custom-flavor-setup ``` ```bash npx mega-linter-runner@beta --custom-flavor-setup --custom-flavor-linters "PYTHON_BANDIT,PYTHON_BLACK,PYTHON_RUFF,REPOSITORY_TRIVY" ``` -------------------------------- ### Serve Local Documentation Source: https://github.com/oxsecurity/megalinter/blob/main/CLAUDE.md Starts a local documentation server for viewing documentation. The server will be available at http://127.0.0.1:8000. ```bash # Documentation hatch run docs:serve # Local docs server at http://127.0.0.1:8000 ``` -------------------------------- ### Resolution for Stylelint Custom Syntax Not Found Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/css_stylelint.md Provides instructions for resolving 'CSS_STYLELINT_ERROR_CUSTOM_SYNTAX_NOT_FOUND' by installing necessary postcss syntax plugins. It shows an example using npm install for `postcss-scss` and `postcss-html`. ```yaml CSS_STYLELINT_PRE_COMMANDS: - command: "npm install postcss-scss postcss-html" cwd: "root" continue_if_failed: false ``` -------------------------------- ### Example Proselint CLI Call Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/spell_proselint.md Demonstrates how to invoke Proselint with a configuration file and multiple files for linting. ```shell proselint --config .proselintrc myfile.md myfile2.txt myfile3.rst ``` -------------------------------- ### Kubescape Download Artifacts Command Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/kubernetes_kubescape.md Example command to download necessary artifacts for air-gapped environments. ```shell kubescape download artifacts ``` -------------------------------- ### PHP_PHPCSFIXER_PRE_COMMANDS: venv Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Specifies the Python virtual environment to use for running the command. For example, 'flake8' if a flake8 plugin needs to be installed. ```text venv ``` -------------------------------- ### Example Tag: before_plugins Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Example of the 'before_plugins' tag for execution order. ```string "before_plugins" ``` -------------------------------- ### BASH_EXEC: Pre-run Commands Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Define bash commands to execute before BASH_EXEC starts. This is useful for setting up the environment or performing initial checks. ```text BASH_EXEC_PRE_COMMANDS ``` -------------------------------- ### Example of REPOSITORY_PRE_COMMANDS item with full options Source: https://github.com/oxsecurity/megalinter/blob/main/docs/json-schemas/configuration.html Illustrates a comprehensive REPOSITORY_PRE_COMMANDS item, including command, continue_if_failed, cwd, output_variables, secured_env, and tag. ```json { "command": "npm run test", "continue_if_failed": false, "cwd": "workspace", "output_variables": ["VAR1", "VAR2"], "secured_env": false, "tag": "before_plugins" } ``` -------------------------------- ### SQLFluff Templating Failed Resolution Example Source: https://github.com/oxsecurity/megalinter/blob/main/docs/descriptors/sql_sqlfluff.md Guidance on resolving SQLFluff templating failures, including dbt project setup and Jinja variable configuration. ```text sqlfluff could not render a templated SQL file (Jinja, dbt, Python templater). This is a templating/environment issue, not a lint finding. Resolutions: - For dbt projects, pre-install dbt and prepare the dbt project via pre-commands in your .mega-linter.yml: SQL_SQLFLUFF_PRE_COMMANDS: - command: "pip install dbt-core dbt-postgres" venv: sqlfluff continue_if_failed: false - command: "dbt deps && dbt compile" cwd: "workspace" continue_if_failed: false - For Jinja, define missing variables under `[sqlfluff:templater:jinja:context]` in `.sqlfluff`. - For files that should not be templated, set `templater = raw` in `.sqlfluff`. ```