Skip to content

clj-kondo

clj-kondo documentation

clj-kondo - GitHub

Configuration in Mega-Linter

Variable Description Default value
CLOJURE_CLJ_KONDO_ARGUMENTS User custom arguments to add in linter CLI call
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_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_CONFIG_FILE clj-kondo configuration file name
Use 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 Mega-Linter 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

IDE Integration

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

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

Mega-Linter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default Mega-Linter Flavor 84 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

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

Example calls

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

Help content

clj-kondo v2021.02.13


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>: config may be a file or an EDN expression. See
    https://cljdoc.org/d/clj-kondo/clj-kondo/2021.02.13/doc/configuration

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

  --run-as-pod: run clj-kondo as a babashka pod

  --parallel: lint sources in parallel.

  --no-warnings: don't report warnings. Useful for when populating cache.

Installation on mega-linter Docker image

  • Dockerfile commands :
FROM cljkondo/clj-kondo:2021.02.13-alpine as clj-kondo
COPY --from=clj-kondo /bin/clj-kondo /usr/bin/

Example success log

Results of clj-kondo linter (version 2020.09.09)
See documentation on https://nvuillam.github.io/mega-linter/descriptors/clojure_clj_kondo/
-----------------------------------------------

[SUCCESS] .automation/test/clojure/clojure_good_1.clj
    linting took 14ms, errors: 0, warnings: 0

Example error log

Results of clj-kondo linter (version 2020.09.09)
See documentation on https://nvuillam.github.io/mega-linter/descriptors/clojure_clj_kondo/
-----------------------------------------------

[ERROR] .automation/test/clojure/clojure_bad_1.clj
    .automation/test/clojure/clojure_bad_1.clj:5:5: warning: namespace clojure.set is required but never used
    .automation/test/clojure/clojure_bad_1.clj:8:2: error: unresolved symbol but-last
    .automation/test/clojure/clojure_bad_1.clj:12:1: error: clojure.string/join is called with 0 args but expects 1 or 2
    .automation/test/clojure/clojure_bad_1.clj:15:17: warning: unused binding y
    .automation/test/clojure/clojure_bad_1.clj:17:3: warning: redundant do
    .automation/test/clojure/clojure_bad_1.clj:19:5: warning: inline def
    .automation/test/clojure/clojure_bad_1.clj:22:7: warning: Redundant let expression.
    .automation/test/clojure/clojure_bad_1.clj:22:13: warning: unused binding z
    .automation/test/clojure/clojure_bad_1.clj:24:9: error: y is called with 1 arg but expects 0
    .automation/test/clojure/clojure_bad_1.clj:26:9: error: recur argument count mismatch (expected 2, got 0)
    .automation/test/clojure/clojure_bad_1.clj:29:9: error: h is called with 1 arg but expects 0
    .automation/test/clojure/clojure_bad_1.clj:30:9: error: f is called with 1 arg but expects 0
    .automation/test/clojure/clojure_bad_1.clj:34:1: warning: redefined var #'foo/private-fn
    .automation/test/clojure/clojure_bad_1.clj:34:8: warning: Unused private var foo/private-fn
    .automation/test/clojure/clojure_bad_1.clj:38:6: error: Expected: number, received: keyword.
    .automation/test/clojure/clojure_bad_1.clj:42:1: error: java.lang.Thread/sleep is called with 3 args but expects 1 or 2
    .automation/test/clojure/clojure_bad_1.clj:48:1: error: foo/foo-fn is called with 0 args but expects 2
    .automation/test/clojure/clojure_bad_1.clj:51:1: error: #'foo/private-fn is private
    .automation/test/clojure/clojure_bad_1.clj:54:7: error: duplicate key :a
    .automation/test/clojure/clojure_bad_1.clj:56:5: error: duplicate set element 1
    .automation/test/clojure/clojure_bad_1.clj:58:7: error: missing value for key :b
    .automation/test/clojure/clojure_bad_1.clj:64:3: warning: missing test assertion
    linting took 14ms, errors: 13, warnings: 9