Running Super-Linter Locally

While Super-Linter is designed for seamless integration with GitHub Actions, its Docker-based architecture makes it easy to run in any environment, including your local development machine.

Using Docker

To run Super-Linter locally, you need a container runtime like Docker installed. Use the following command, replacing /path/to/local/codebase with the absolute path to your project's root directory:

docker run \
  -e RUN_LOCAL=true \
  -v /path/to/local/codebase:/tmp/lint \
  --rm \
  ghcr.io/super-linter/super-linter:v8.0.0

Key Command Options

  • -e RUN_LOCAL=true: This environment variable is required when running outside of GitHub Actions. It tells Super-Linter to bypass checks for GitHub-specific environment variables.
  • -v /path/to/local/codebase:/tmp/lint: This mounts your local project directory into the container at the /tmp/lint path, which is the default workspace Super-Linter scans.

Linting a Single File

If you only want to lint a single file, you can adjust the volume mount and use the USE_FIND_ALGORITHM=true flag:

docker run \
  -e RUN_LOCAL=true \
  -e USE_FIND_ALGORITHM=true \
  -v /path/to/local/codebase/file.js:/tmp/lint/file.js \
  --rm \
  ghcr.io/super-linter/super-linter:v8.0.0

Customizing the Workspace

If you prefer to mount your code to a different directory inside the container, you can override the DEFAULT_WORKSPACE environment variable:

docker run \
  -e RUN_LOCAL=true \
  -e DEFAULT_WORKSPACE=/app \
  -v /path/to/local/codebase:/app \
  --rm \
  ghcr.io/super-linter/super-linter:v8.0.0

Sharing Configuration Between Environments

To maintain consistent linting rules between your local runs and your CI pipeline, you can use an environment file.

  1. Create a configuration file (e.g., super-linter.env) in your repository. This file will store your common environment variables:

    // super-linter.env
    VALIDATE_ALL_CODEBASE=true
    VALIDATE_JAVASCRIPT_ES=true
    VALIDATE_YAML=true
    // Disable markdown linting
    VALIDATE_MARKDOWN=false
    
  2. Run Locally with --env-file:

    docker run --rm \
      -e RUN_LOCAL=true \
      --env-file ".github/super-linter.env" \
      -v "$(pwd)":/tmp/lint \
      ghcr.io/super-linter/super-linter:v8.0.0
  3. Load the file in GitHub Actions:

    Add a step to your workflow to load the environment variables from the file before running Super-Linter.

    - name: Load super-linter configuration
      run: grep -v '^#' .github/super-linter.env >> "$GITHUB_ENV"
    - name: Super-Linter
      uses: super-linter/super-linter@v8.0.0
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    
    This approach ensures that the same rules and configurations are applied everywhere, providing a consistent developer experience.