clj-kondo

https://github.com/clj-kondo/clj-kondo
seancorfield 2021-03-21T19:33:49.102700Z

Just noticed this issue:

Can't parse /Developer/workspace/clj-new/src/clj/new/app/deps.edn, No value supplied for key: namespace clj-kondo (syntax)
for this deps.edn file (which is a template in clj-new):
{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.10.3"}}
 :aliases
 {:run-m {:main-opts ["-m" "{{namespace}}"]}
  :run-x {:ns-default {{namespace}} ; complaining about this
          :exec-fn greet
          :exec-args {:name "Clojure"}}
...
This is a Stencil template (but Selmer and others use the same syntax). Not sure if it’s possible to work around this since it’s a parsing issue at the EDN level but I thought I’d mention it in case…

borkdude 2021-03-21T19:45:02.103200Z

@seancorfield If the file ends with .edn, clj-kondo will treat it as edn

borkdude 2021-03-21T19:45:27.103400Z

you can exclude the file in your config

seancorfield 2021-03-21T19:47:02.104Z

Right, I meant more “Could clj-kondo understand that {{sym}} is a template var and still parse the file?“.

seancorfield 2021-03-21T19:47:36.104800Z

Also, while you’re here — I just ran across this:

(ns kondo.reducers
  (:require [clojure.core.reducers :as r]))

(defn map-test []
  (r/map inc [1 2 3 4]))
  ;^ r/map flagged as an unresolved var

borkdude 2021-03-21T19:47:58.105300Z

that would require a change in the parser, which imo isn't worth it. the r/map issue will be fixed in the newest clj-kondo which I'm about to release

seancorfield 2021-03-21T19:48:39.105700Z

Oh, good timing on my part then 🙂

seancorfield 2021-03-21T19:49:09.106400Z

Yeah, I figured it wouldn’t be worth fixing the EDN parse issue. I was just curious if anyone else had run into it.

borkdude 2021-03-21T19:49:35.106700Z

I have run into it myself :)

borkdude 2021-03-21T19:50:25.107200Z

it's unfortunate that {{ ... }} is invalid EDN in this case

borkdude 2021-03-21T19:52:31.107600Z

if only we had some HEREDOC feature in clojure :P (j/k)

seancorfield 2021-03-21T19:53:05.108Z

(which wouldn’t solve that parsing issue but… 🙂 )

borkdude 2021-03-21T20:41:00.109200Z

I just had a pain with lein updating the clj-kondo LSP plugin. Turns out I had clj-kondo in my .lein/profiles.clj as well, so it had included an older version for a while.

lein with-profiles -user
fixes this.. 🤦

borkdude 2021-03-21T20:46:45.109900Z

Well, here it is then:

borkdude 2021-03-21T20:46:58.110200Z

clj-kondo v2021.03.22: no new features, just bug fixes. https://github.com/clj-kondo/clj-kondo/blob/master/CHANGELOG.md#20210322

borkdude 2021-03-21T22:05:26.111400Z

@seancorfield I guess a quick hack for templates would be to str/replace all {{ ... }}s with e.g. nil and then lint it as .edn. But how would you tell clj-kondo that it should do that.