This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-22
Channels
- # adventofcode (21)
- # announcements (2)
- # babashka (35)
- # beginners (45)
- # calva (22)
- # cider (28)
- # clj-kondo (39)
- # clj-on-windows (69)
- # clojure (28)
- # clojure-europe (15)
- # clojure-nl (7)
- # clojure-uk (24)
- # clojurescript (95)
- # cursive (9)
- # data-science (3)
- # datalevin (2)
- # emacs (11)
- # etaoin (9)
- # fulcro (1)
- # graphql (4)
- # jobs (8)
- # lsp (66)
- # malli (10)
- # missionary (3)
- # pathom (4)
- # polylith (67)
- # releases (3)
- # reveal (2)
- # shadow-cljs (53)
- # spacemacs (2)
- # specter (1)
- # sql (1)
- # tools-deps (6)
- # vim (4)
- # xtdb (16)
Hi! Would it make sense with a linter for orgs that want to wrap all fns in a threading form with parentheses? So this:
(-> x
fn-a
(fn-b arg1 arg2))
should be corrected to this:
(-> x
(fn-a)
(fn-b arg1 arg2))
@U21QNFC5C you can use them for linting too. I got it working here: .clj-kondo/thread_hook.clj
(ns thread-hook
(:require [clj-kondo.hooks-api :as api]))
(defn thread-hook [{:keys [node]}]
(let [children (rest (:children node))]
(run! (fn [node]
(when-not (api/list-node? node)
(api/reg-finding! (assoc (meta node)
:message (str "Wrap in a list: " node)
:type :org.acme/thread-list)))) children)))
.clj-kondo/config.edn
{:hooks {:analyze-call {clojure.core/-> thread-hook/thread-hook}}
:linters {:org.acme/thread-list {:level :warning}}}
$ clj-kondo --lint example.clj
example.clj:1:5: warning: Wrap in a list: 1
example.clj:1:7: warning: Wrap in a list: 2
example.clj:1:7: error: a number is not a function
example.clj:1:9: warning: Wrap in a list: 3
example.clj:1:9: error: a number is not a function
linting took 74ms, errors: 2, warnings: 3
I wonder why it complains about parse-long
?
clojure-lsp version used: 2021.12.20-00.36.56
clj-kondo version used: 2021.12.19
@zelark parse-long
is a new var in clojure 1.11 and clj-kondo has already been updated for that
however if you lint your deps, then it should pick up on your project's clojure version I think
Hm, I linted via cli and it doesn’t complain about parse-long , maybe it’s a Calva specific issue, or I don’t know
> if you lint your deps what does it mean? I have
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.0-alpha3"}
...
just figured out that I have clj-kondo extension installed in my vs code, after I deleted it, things look nice again, thanks
Is {:paths ["."]}
a legitimate configuration for .clj-kondo/config.edn
?
Background: I am using https://github.com/github/super-linter for markdown and it should do Clojure as well, but suspect its not finding the deps.edn file in the root of the project (practicalli/clojure-deps-edn). I think I just need to put in the config what I would otherwise specify on the command line with the --lint
flag. Does that make sense?
Hmm, I'll take a look at the Super Linter PRs that added clj-kondo and see if I can work out why its not picking up the deps.edn file.
I have a separate GitHub action that specificially checks the deps.edn file, using the lint deps.edn` command line arg, so not a big issue. Nice to have just one GitHub action though 🙂
clj-kondo --lint $(clojure -Spath) --dependencies
+ clj-kondo --lint src:test
is usually how you should lint your projects
In DeLaGuardo/setup-clj-kondo github action I use the following, which seems to work.
This isnt for a Clojure project, its for a user level config project, so it only has a deps.edn
file plus some markdown for docs, nothing else Clojure wise.
jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: DeLaGuardo/[email protected]
with:
version: '2021.12.16'
- uses: actions/[email protected]
- name: Run on Ubuntu
run: clj-kondo --lint deps.edn
I'll see if I can get Super Linter to do the same. But if not, its still covered. Thanks.
Super Linter is calling clj-kondo with the following command, so not sure what path would be used by default.
clj-kondo --config ${CLOJURE_LINTER_RULES} --lint
Would it be better to specify "."
as the argument to --lint (assuming neither clojure or lein commands are available in the GitHub action image). Or do specific directories need to be added for src and test, etc.?I have no idea how Super Linter works. I don't think specifying .
is always a good default.
unless you can find good examples of how other people use it. http://grep.app is a tool you can maybe use for this
Super Linter just runs the command above (and uses the latest clj-kondo it seems) I wonder if I do a PR to add a CLOJURE_LINTER_PATHS variable to the super linter then the paths can be specified in the github action yaml file that defined the jobs (maybe).
running --lint
without any arguments doesn't do anything, so I would be surprised if that was all there is to it. Are you supposed to provide arguments to it yourself?
As --lint
without arguments doesnt do anything, that would explain my results. Thanks. I'll try figure out how to add some paths to the command. 🙂
There are some options to set paths, but they arent being passed to the Clojure linter. It seems https://megalinter.github.io/latest/descriptors/clojure_clj_kondo/what I think super-linter should do for clj-kondo, so I'll switch to that. Thanks.
Looking at the config options, they are very different: I'd consider super-linter broken for now until there is an env var to set the lint path (a PR adding the setup of mega-linter to super linter seems to be required - but then why not just use mega-linter 🙂 )
Mega linter has some very nice docs for clj-kondo https://megalinter.github.io/latest/descriptors/clojure_clj_kondo/