Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate :clj-kondo config expressed in Leiningen project maps #9

Merged
merged 2 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Translate :clj-kondo config expressed in Leiningen project maps
Closes #8
  • Loading branch information
vemv committed Jul 1, 2022
commit ac22c48178891c2cdb2efdd3ebcfffa538981371
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ A Leiningen plugin to run [clj-kondo](https://github.com/clj-kondo/clj-kondo).
Running clj-kondo through Leiningen has some advantages, since it can compute for you things that would have to be specified by hand otherwise
(and those things can be forgotten, outdated, etc).

There's the tradeoff of startup speed, which might not be as critical in a CI environment as it is in your CLI.
It also provides the ability to express clj-kondo options as Lein project map options, which can work nicely with Lein profiles, plugins, etc.

With using Leiningen, there's the tradeoff of startup speed, which might not be as critical in a CI environment as it is in your CLI.

## Installation

Expand Down Expand Up @@ -54,6 +56,20 @@ You can configure your project.clj to add custom aliases to run specific clj-kon
,,,
```

## Config

lein-clj-kondo understands clj-kondo config expressed as `:config` in a Leiningen project map. Example:

```clj
;; Enable a specific linter
:clj-kondo {:config {:linters {:docstring-leading-trailing-whitespace {:level :warning}}}}
```

The traditional ways of specifying options of course keep working:

* You can place a `.clj-kondo/config.edn` file in your project.
* You can use the `--config ...` CLI option.

### Deploy

`bb tag x.y.z` to tag the new release, github actions will do the deploy to clojars automatically.
Expand Down
6 changes: 5 additions & 1 deletion src/leiningen/clj_kondo.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
(:import
(java.io File)))

(defn ^:private run-kondo! [{:keys [source-paths test-paths]} options]
(defn ^:private run-kondo! [{:keys [source-paths test-paths]
{:keys [config]} :clj-kondo}
options]
(let [args (or (not-empty options)
(when-let [v (->> [source-paths test-paths]
(reduce into [])
Expand All @@ -15,6 +17,8 @@
(not-empty))]
(apply lein-core/info "Linting" v)
(into ["--lint"] v)))
args (cond-> args
config (conj "--config" config))
exit-status (apply kondo/main args)]
(when-not (zero? exit-status)
(lein-core/exit exit-status))))
Expand Down