Fork me on GitHub
#clj-kondo
<
2020-03-02
>
Marc O'Morain15:03:02

Is there a way to tell clj-kondo that a macro is like a let binding? We have a macro that adds a binding like this:

(with-temp-file filename
  (foo (bar filename)))
And clj-kondo warns about the unresolved symbol. I can mark this macro as excluded, but is there a more sophisticated approach?

borkdude15:03:15

@marc-omorain You can use :lint-as + cljs.test/async (I know, it's weird, but this works)

Marc O'Morain15:03:34

aha, so cljs.test/async has the same pattern, gotcha 👏

Marc O'Morain15:03:44

We have some macros that expect square braces in the same way, and I lint those as fn

Marc O'Morain15:03:46

I think I’ve found a false positive case in clj-kondo, going to reduce it down now

Marc O'Morain15:03:51

(fn unresolved-symbol-x
  [x & {:keys [y]
          :or {y (inc x)}}]
  (+ y x))

Marc O'Morain15:03:32

logging in GH now

borkdude15:03:32

what is the issue, can you explain in words first?

borkdude16:03:06

I'll check in Clojure if this is supposed to work at all 😉

iGEL16:03:28

We have defined a method called zero? in our money lib, but now clj-kondo complains because we overwrite zero? from cljs.core. Is there a way to white list just these occurrences as OK, possibly similar to rubocop's rubocop:disable comments? I'd prefer not to disable this linter globally if possible

borkdude16:03:41

@igel The canonical way to do this is to use :refer-clojure :exclude [zero?]

borkdude16:03:59

this is supported by clojure / clojurescript itself

Marc O'Morain16:03:00

Clojure 1.10.1
(defn foo [x & {:keys [y] :or {y (inc x)}}]
  (+ y x))
#'user/foo
user=> (foo 1 :y 10)
11
user=> (foo 1)
3

borkdude16:03:31

@marc-omorain I've had more edge cases where people did weird things with or that accidentally worked but were confirmed by the core team as a thing to not rely on, that's why I'm going to ask in #clojure first

iGEL16:03:32

@borkdude, Thanks, didn't knew that 👍

Marc O'Morain17:03:05

@borkdude so pulling circleci/circle up the latest clj-kondo reported 4 issues. 2 legit bugs, that issue above ^, and a weird case of us abusing name-spaces to break a circular dependency between two namespaces, which clj-kondo can’t deal with (which I don’t expect it to deal with).

Marc O'Morain17:03:30

One bug was us passing a vector of 4 items as the last arg to clojure.set/union . The other was genuine broken code that happens to not crash.

borkdude17:03:48

@marc-omorain Cool, so all good now? 🙂

tanzoniteblack18:03:01

the lsp plugin with intellij doesn't seem to be reading the project's .clj-kondo/config.edn`, is there a way to convince it to do this?

borkdude18:03:59

@tanzoniteblack I think this depends on the working directory. so if you edit files within your project while your project is opened in its base directory, then it will probably work

borkdude18:03:03

same for VSCode

tanzoniteblack19:03:17

ah, I had to move the config from the module directory I was working in to the project directory, and then restart intellij before it actually kicked in

borkdude19:03:10

if this is something worth documenting for other users, PR welcome