Skip to content

clj-kondo

GitHub stars GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

clj-kondo documentation

clj-kondo - GitHub

Configuration in MegaLinter

Variable Description Default value
CLOJURE_CLJ_KONDO_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
CLOJURE_CLJ_KONDO_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
CLOJURE_CLJ_KONDO_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
CLOJURE_CLJ_KONDO_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
CLOJURE_CLJ_KONDO_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- project: Call the linter from the root of the project
file
CLOJURE_CLJ_KONDO_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".clj", ".cljs", ".cljc", ".edn"]
CLOJURE_CLJ_KONDO_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
CLOJURE_CLJ_KONDO_PRE_COMMANDS List of bash commands to run before the linter None
CLOJURE_CLJ_KONDO_POST_COMMANDS List of bash commands to run after the linter None
CLOJURE_CLJ_KONDO_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling CLOJURE_CLJ_KONDO and its pre/post commands None
CLOJURE_CLJ_KONDO_CONFIG_FILE clj-kondo configuration file nameUse LINTER_DEFAULT to let the linter find it .clj-kondo/config.edn
CLOJURE_CLJ_KONDO_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
CLOJURE_CLJ_KONDO_DISABLE_ERRORS Run linter but consider errors as warnings false
CLOJURE_CLJ_KONDO_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
CLOJURE_CLJ_KONDO_CLI_EXECUTABLE Override CLI executable ['clj-kondo']

IDE Integration

Use clj-kondo in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Atom linter-kondo Visit Web Site
Emacs flycheck-clj-kondo Visit Web Site
Visual Studio Code clj-kondo Install in VSCode
Visual Studio Code Clojure lint Visit Web Site

MegaLinter Flavors

This linter is available in the following flavors

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 124 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 84 Docker Image Size (tag) Docker Pulls
java Optimized for JAVA based projects 53 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .clj, .cljs, .cljc, .edn

How the linting is performed

  • clj-kondo is called one time by identified file (file CLI lint mode)

Example calls

clj-kondo --lint myfile.clj
clj-kondo --lint --config .clj-kondo/config.edn myfile.clj

Help content

clj-kondo v2024.11.14

Options:

  --lint <file>: a file can either be a normal file, directory or classpath. In the
    case of a directory or classpath, only .clj, .cljs and .cljc will be
    processed. Use - as filename for reading from stdin.

  --lang <lang>: if lang cannot be derived from the file extension this option will be
    used. Supported values: clj, cljs, cljc.

  --filename <file>: in case stdin is used for linting, use this to set the
    reported filename.

  --cache-dir: when this option is provided, the cache will be resolved to this
    directory. If --cache is false, this option will be ignored.

  --cache: if false, won't use cache. Otherwise, will try to resolve cache
  using `--cache-dir`. If `--cache-dir` is not set, cache is resolved using the
  nearest `.clj-kondo` directory in the current and parent directories.

  --config <config>: extra config that is merged. May be a file or an EDN expression. See https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md.

  --config-dir <config-dir>: use this config directory instead of auto-detected
    .clj-kondo dir.

  --parallel: lint sources in parallel.

  --dependencies: don't report any findings. Useful for populating cache while linting dependencies.

  --copy-configs: copy configs from dependencies while linting.

  --skip-lint: skip lint/analysis, still check for other tasks like copy-configs.

  --fail-level <level>: minimum severity for exit with error code.  Supported values:
    warning, error.  The default level if unspecified is warning.

  --report-level <level>: minimum severity for which to report.  Supported values:
    info, warning, error.  The default level if unspecified is info.

  --debug: print debug information.

Installation on mega-linter Docker image

  • Dockerfile commands :
# Parent descriptor install
ENV LANG=C.UTF-8
RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" && \
    ALPINE_GLIBC_PACKAGE_VERSION="2.34-r0" && \
    ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
    ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
    ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
    apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \
    echo \
        "-----BEGIN PUBLIC KEY-----\
        MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m\
        y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu\
        tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp\
        m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY\
        KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc\
        Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m\
        1QIDAQAB\
        -----END PUBLIC KEY-----" | sed 's/   */\\n/g' > "/etc/apk/keys/sgerrand.rsa.pub" && \
    wget --quiet --tries=10 --waitretry=10 \
        "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
    mv /etc/nsswitch.conf /etc/nsswitch.conf.bak && \
    apk add --no-cache --force-overwrite \
        "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
    \
    mv /etc/nsswitch.conf.bak /etc/nsswitch.conf && \
    rm "/etc/apk/keys/sgerrand.rsa.pub" && \
    (/usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true) && \
    echo "export LANG=$LANG" > /etc/profile.d/locale.sh && \
    \
    apk del glibc-i18n && \
    \
    rm "/root/.wget-hsts" && \
    apk del .build-dependencies && \
    rm \
        "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"

# Linter install
RUN curl --retry 5 --retry-delay 5 -sLO https://raw.githubusercontent.com/clj-kondo/clj-kondo/master/script/install-clj-kondo \
    && chmod +x install-clj-kondo \
    && ./install-clj-kondo