This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-28
Channels
- # announcements (1)
- # babashka (9)
- # beginners (82)
- # calva (6)
- # cider (3)
- # clj-kondo (69)
- # cljdoc (4)
- # cljs-dev (10)
- # cljsrn (2)
- # clojure (74)
- # clojure-europe (11)
- # clojure-italy (9)
- # clojure-nl (15)
- # clojure-spec (18)
- # clojure-uk (89)
- # code-reviews (8)
- # core-async (42)
- # cursive (22)
- # datomic (26)
- # fulcro (13)
- # graalvm (31)
- # graphql (1)
- # leiningen (20)
- # malli (19)
- # music (1)
- # off-topic (4)
- # pathom (56)
- # re-frame (3)
- # reitit (26)
- # shadow-cljs (40)
- # spacemacs (5)
- # tools-deps (25)
want to help test a new feature? warnings about missing requires:
linux https://7518-176829714-gh.circle-artifacts.com/0/release/clj-kondo-2019.11.24-SNAPSHOT-linux-amd64.zip
mac: https://7517-176829714-gh.circle-artifacts.com/0/release/clj-kondo-2019.11.24-SNAPSHOT-macos-amd64.zip
branch: missing-require
example:
Thank you for this very useful feature. I tested on my Debian 10 linux using the binary above and it seems to work nice
The name of the linter and the message are subject to change, feel free to post suggestions at https://github.com/borkdude/clj-kondo/issues/339
hello, is there a way to exclude certain namespaces (with a regex) from being checked for :unresolved-symbol
?
https://github.com/borkdude/clj-kondo/blob/master/doc/config.md I don't think so (yet). Do you have an example of how this would be useful?
@borkdude I use hugsql in namespaces that all end in .data
and I’d rather not declare
all my hugsql-generated functions
correct
ok, thanks!
by the way, does this look ok to you? :unresolved-symbol {:exclude [(secretary.core [defroute])]}
could you first make an issue about it with a proposed solution and then a corresponding PR?
it seems to crash clj-kondo
Unexpected error. Please report an issue.
java.lang.IllegalArgumentException: no conversion to symbol
at clojure.core$symbol.invokeStatic(core.clj:596)
at clojure.core$symbol.invoke(core.clj:589)
at clj_kondo.impl.config$fn__4141$delayed_cfg__4142$fn__4144.invoke(config.clj:187)
at clojure.lang.ArrayChunk.reduce(ArrayChunk.java:63)
at clojure.core.protocols$fn__8139.invokeStatic(protocols.clj:136)
at clojure.core.protocols$fn__8139.invoke(protocols.clj:124)
at clojure.core.protocols$fn__8099$G__8094__8108.invoke(protocols.clj:19)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
at clojure.core.protocols$fn__8131.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8131.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8073$G__8068__8086.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6828)
at clojure.core$reduce.invoke(core.clj:6810)
at clj_kondo.impl.config$fn__4141$delayed_cfg__4142.invoke(config.clj:186)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:665)
at clojure.core$memoize$fn__6862.doInvoke(core.clj:6353)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clj_kondo.impl.config$fn__4141$fn__4150.invoke(config.clj:195)
at clj_kondo.impl.namespace$reg_unresolved_symbol_BANG_.invokeStatic(namespace.clj:162)
at clj_kondo.impl.namespace$reg_unresolved_symbol_BANG_.invoke(namespace.clj:157)
at clj_kondo.impl.linters$lint_var_usage$iter__5082__5090$fn__5091$iter__5084__5092$fn__5093.invoke(linters.clj:239)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:51)
at clojure.lang.RT.seq(RT.java:531)
at clojure.core$seq__5387.invokeStatic(core.clj:137)
at clojure.core$seq__5387.invoke(core.clj:137)
at clj_kondo.impl.linters$lint_var_usage$iter__5082__5090$fn__5091.invoke(linters.clj:201)
@stathissideris ah gotcha:
$ clj -A:clj-kondo --config '{:linters {:unresolved-symbol {:exclude [(secretary.core/defroute)]}}}' --lint - <<< "(require '[secretary.core]) (secretary.core/defroute foo)"
linting took 61ms, errors: 0, warnings: 0
oooh, sorry, I misread the manual
no problem. there is an issue for a config validator. once that's there, we should no longer have to bother with this kind of problem
so any pointers on where I could start with implementing the new exclusion for the :unresolved-symbol
linter?
@stathissideris yes: here is the related config code: https://github.com/borkdude/clj-kondo/blob/de8add6672d5c795a0012e6ba9043f3bfe4b9c4b/src/clj_kondo/impl/config.clj#L179 and here is a config that already uses regexes, as an example: https://github.com/borkdude/clj-kondo/blob/de8add6672d5c795a0012e6ba9043f3bfe4b9c4b/src/clj_kondo/impl/config.clj#L161
thanks, I’ll have a look!
if you have a suggestion for a map-based configuration format instead of the vector with lists or symbols, feel free to come up with one as well
because one problem now is that this config isn't merged with built-in ones (e.g. clojure.test/is)
one thing that was a bit unexpected in the config is that each linter seems to expect different (but kinda similar) configs
The related issue for that one is: https://github.com/borkdude/clj-kondo/issues/608
I think it's good to discuss some alternative formats first before implementing it. But this is another feature really, so let's just focus on the regex first 🙂
It might be slightly related though, since the regex feature may affect the "ignore in call" exclusion or the symbol itself
I had a semi-working branch for that exact feature, could try and polish it up and submit a PR over the weekend!
My use case was wanting to support Meander macros and ignore all unresolved-symbol warnings for symbols ending with !
and ?
one odd quirk I found with the regex configurations was how they don't accept actual #"" regex literals and require string literals with double-escaped backslashes
but I do actually support it with edamame (which is a configurable EDN parser), but clj-kondo predates it
Since US is on holiday, I finally have space to think about this clj-kondo current directory thing.
I think I'm concluding that ideally, I want to lint stdin, but supply the filename somehow so that the clj-kondo can find the config directory.
eslint (the first one I checked) does this with --stdin
and --stdin-filename
options.
@eraserhd -
is already there for linting stdin, --stdin-filename
would that only be used for finding the config dir? then we could also have --cwd
which overrides the current working directory?
Oh, to disclose: I'm still pondering. This proposal seems the most "correct", although it requires a bit of rework on the editor part.
@marc-omorain’s plugin also doesn't use stdin, it uses the raw file + filename, so there it still make sense what we're currently doing
huh. That's actually an easy fix. That suggests all linters can find their config in a parent directory?
because I anticipated the same problem for a multi-project git repo, then I checked, and I was happy that it worked in my case (having two .clj-kondo dirs in the same repo)
Hmm, well changing to the linted file's directory is easy, but it still writes the buffer to a temporary directory passed by absolute path.
in the intellij setup it's also working like this: the working dir is the file's dir: https://github.com/borkdude/clj-kondo/blob/master/doc/editor-integration.md#intellij-idea
@eraserhd you would of course set the cwd to the dir of the linted file, not the copied tmp file
but yeah, using the path of the copied tmp file for resolving the config dir is a bit pointless
@eraserhd https://github.com/flycheck/flycheck/blob/269237f6529a4ad7db5bbbc5a40c1f038accf3cd/flycheck.el#L4990