Fork me on GitHub
#clj-kondo
<
2019-10-01
>
maxp04:10:45

How to make clj-kondo handle mount.core/defstate macro correctly? :lint-as something?

maxp04:10:37

(defstate my-state :start ... :stop ...)

borkdude07:10:39

@maxp you can try {:lint-as {mount.core/defstate clojure.core/def}}

maxp07:10:55

thank you, it works.

genmeblog11:10:13

Is it possible to have one clj-kondo config for all projects (eg. in home directory)? I have set of macros which cause an arity false positive error. I don't want to add exclusion for each and every project which uses it.

borkdude11:10:02

@tsulej the binary accepts a --config flag which you can use for bringing in additional config. maybe that works for you?

borkdude11:10:41

it's a little bit discouraged to scatter config over multiple places because it should ideally be in the same git repo as your code, so your collaborators don't have to re-invent that

genmeblog11:10:42

You're right in general. But in my case I have a bunch of clojure2d sketches here and there as separate projects and they all are filled with kind of threading macros (there are two actually).

genmeblog11:10:51

So they are my personal projects.

genmeblog11:10:26

Maybe the other option: I work with emacs and flycheck, how to feed flycheck with custom config then?

borkdude11:10:25

you can can call (flycheck-clj-kondo-define-checkers "--config" "your-config.edn")

borkdude11:10:34

it's not documented but I think that should work.

genmeblog11:10:41

perfect, let me check

borkdude11:10:11

the --cache option is no longer needed, it has become the default. so you can leave that out

genmeblog11:10:39

@borkdude now I'm getting

Suspicious state from syntax checker clj-kondo-clj: Flycheck checker clj-kondo-clj returned non-zero exit code 124, but its output contained no errors: Unexpected error. Please report an issue.
java.lang.ClassCastException: java.lang.String cannot be cast to java.io.File
	at clj_kondo.impl.core$read_edn_file$fn__4643.invoke(core.clj:51)
	at clj_kondo.impl.core$read_edn_file.invokeStatic(core.clj:51)
	at clj_kondo.impl.core$resolve_config.invokeStatic(core.clj:62)
	at clj_kondo.core$run_BANG_.invokeStatic(core.clj:83)
	at clj_kondo.main$main.invokeStatic(main.clj:85)
	at clj_kondo.main$main.doInvoke(main.clj:78)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:665)
	at clj_kondo.main$_main$fn__4787.invoke(main.clj:104)
	at clj_kondo.main$_main.invokeStatic(main.clj:104)
	at clj_kondo.main$_main.doInvoke(main.clj:102)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clj_kondo.main.main(Unknown Source)

Try installing a more recent version of clj-kondo-clj, and please open a bug report if the issue persists in the latest release.  Thanks!
when using config containing
{:linters {:invalid-arity {:skip-args [clojure2d.core/with-canvas->
                                       clojure2d.core/with-canvas]}}}

genmeblog11:10:50

and line in my init.el (flycheck-clj-kondo-define-checkers "--config" "~/.emacs.d/clj-kondo-config.edn")

borkdude11:10:20

I think clj-kondo doesn't interpolate ~ but maybe you can fix that using some emacs lisp wizardry

genmeblog11:10:42

yeah! works 🙂

genmeblog11:10:51

thank you for quick support

borkdude17:10:24

what about it?

danielcompton17:10:33

Not sure if this is up for discussion, but wondering if this would be a better way to show side-effects?

(ns foo
  (:require foo.specs ;; <-- leave as is
            [bar.utils :as bu] ;; <-- unused, free to remove
    ,,,))

borkdude17:10:13

That would be against "how to ns" advice. Also it's not what most people are already doing.

borkdude17:10:57

This option has been suggested in that thread and maybe had some other drawbacks that I can't remember off the top of my head right now.

borkdude17:10:00

One thing was maybe that in CLJS you can have strings for ns names and maybe that didn't work outside a vector or something. Not sure

danielcompton17:10:20

No problem, couldn't see that in the thread when I scanned but that makes sense

borkdude17:10:30

I think capturing what most people already seem to be doing is best for a linter, since adoption will be less painful

mynomoto18:10:18

I think @danielcompton example works. clj-kondo doesn't complain about naked requires as in (:require clojure.string) produces no warnings. I use that convention on my projects.

dominicm19:10:28

I use non aliased requires all the time, I still want them marked if they're not in use.

mynomoto19:10:36

It's hard to please everyone. I remember the thread where this was discussed. It was long an full of opinions.

mynomoto19:10:09

I wonder if unused-symbols could be a :warning by default. It's the only :info on default configuration and Ale doesn't show that on vim 😕 and there is no way to have a global config for clj-kondo afaik.

borkdude20:10:19

@mynomoto PR welcome to bump it to :warning. I was planning to anyway

borkdude20:10:13

@dominicm you can have it your way with {:linters {:unused-namespace {:simple-libspec true}}}.

mynomoto20:10:06

@borkdude will do, thanks.