Skip to content

cljstyle

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

This linter has been temporary disabled in this version

cljstyle documentation

cljstyle - GitHub

Configuration in MegaLinter

Variable Description Default value
CLOJURE_CLJSTYLE_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
CLOJURE_CLJSTYLE_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
CLOJURE_CLJSTYLE_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
CLOJURE_CLJSTYLE_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
CLOJURE_CLJSTYLE_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_CLJSTYLE_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".clj", ".cljs", ".cljc", ".edn"]
CLOJURE_CLJSTYLE_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_CLJSTYLE_PRE_COMMANDS List of bash commands to run before the linter None
CLOJURE_CLJSTYLE_POST_COMMANDS List of bash commands to run after the linter None
CLOJURE_CLJSTYLE_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling CLOJURE_CLJSTYLE and its pre/post commands None
CLOJURE_CLJSTYLE_CONFIG_FILE cljstyle configuration file nameUse LINTER_DEFAULT to let the linter find it .cljstyle
CLOJURE_CLJSTYLE_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
CLOJURE_CLJSTYLE_DISABLE_ERRORS Run linter but consider errors as warnings false
CLOJURE_CLJSTYLE_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
CLOJURE_CLJSTYLE_CLI_EXECUTABLE Override CLI executable ['cljstyle']

IDE Integration

Use cljstyle in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Emacs cljstyle-mode Visit Web Site

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 121 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

  • cljstyle is called one time by identified file (file CLI lint mode)

Example calls

cljstyle check
cljstyle fix
clj-kondo fix myfile.clj path/to/myfile.clj

Help content

Usage: cljstyle [options] <command> [args...]

Commands:
    find      Find files which would be processed.
    check     Check source files and print a diff for errors.
    fix       Edit source files to fix formatting errors.
    pipe      Fixes formatting errors from stdin and pipes the results to stdout.
    config    Show config used for a given path.
    migrate   Migrate legacy configuration files.
    version   Print program version information.

Options:
      --ignore PATTERN       Ignore files matching the given pattern. May be set multiple times.
      --timeout SEC     300  Maximum time to allow the process to run for.
      --timeout-trace        Dump thread stack traces when the tool times out.
      --stats FILE           Write formatting stats to the named file. The extension controls the format and may be either 'edn' or 'tsv'.
      --report               Print stats report at the end of a run.
      --report-timing        Print detailed rule timings at the end of a run.
      --no-color             Don't output ANSI color codes.
  -v, --verbose              Print detailed debugging output.
  -h, --help                 Show help and usage 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/greglook/cljstyle/main/util/install-cljstyle \
    && chmod +x install-cljstyle \
    && ./install-cljstyle