This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-22
Channels
- # announcements (9)
- # asami (52)
- # aws (1)
- # babashka (7)
- # babashka-sci-dev (12)
- # beginners (72)
- # calva (24)
- # cider (9)
- # clj-kondo (76)
- # cljs-dev (15)
- # clojure (19)
- # clojure-australia (4)
- # clojure-europe (33)
- # clojure-france (9)
- # clojure-gamedev (17)
- # clojure-nl (6)
- # clojure-portugal (5)
- # clojure-uk (5)
- # clojurescript (61)
- # clojureverse-ops (4)
- # code-reviews (23)
- # conjure (1)
- # data-science (2)
- # datalevin (6)
- # datomic (49)
- # gratitude (1)
- # helix (24)
- # holy-lambda (14)
- # jobs (3)
- # lsp (92)
- # malli (7)
- # missionary (8)
- # pathom (12)
- # proletarian (3)
- # re-frame (4)
- # remote-jobs (1)
- # shadow-cljs (4)
- # spacemacs (3)
- # sql (9)
- # tools-build (90)
- # vim (1)
- # xtdb (11)
can we exclude some type of warnings from all the test files? In our codebase, if we have foo.clj, in the foo_test.clj we are always importing foo with :refer :all and I want to stop the flagging for that
Yes, you can. See https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#refer-all
yes, but I have to manually put all the test files here and update it if I add a new test file, right?
then I have to do the same thing for all the source files, if I add a new source file, I’ll have to mention it in the config.edn, correct?
correct, but you can also just globally turn off this linter. I don't see why you would want to make an exception for tests, just use :refer
or an alias
I think :refer :all
doesn't make tests more readable, but this is my personal opinion.
yes, it’s just that we are using it across all our codebase, but we might as well switch to aliasing rather than turning it off
are you using clj-kondo on the JVM for linting in CI? why is it a problem that these "legacy" issues appear?
ah, so my story is, we were previously using replace
in our configs(mistakenly) which was only picking up like 5-6 of the configs, we recently turned it off and added a pre-commit hooks
Perhaps it's possible to make a .clj-kondo/config.edn
in project/test
and refer to your base config with :config-paths
. I'm not entirely sure if this works correctly with clojure-lsp etc though.
this will add extra config file to maintain even if it works, I think we can switch to aliasing or turn off it globally
on a separate thing, is it possible to ignore the full functions from linter warnings?
something like this,
#_clj-kondo{:ignore-function}
(defn foo [] (prom/mlet [...stuff]))
we are using this https://github.com/kumarshantanu/promenade library in some legacy parts of our codebase and I tried to ignore those warnings with :lint-as
but couldn’t make it work
we only have countable functions written with this library where clj-kondo gives warnings, if we can disable some type of errors for the whole function then it will help my case
preferably libraries will include clj-kondo config and export it so everyone can use it instead of everyone ignoring it
hmm, there are other functions like either-as->
and if-mlet
which I remember not working when linting as ->
and if-let
Then you can disable those here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#unresolved-symbol
the author can also provide macroexpansion hooks for clj-kondo to make linting better
what you could do is try to figure those out yourself and then contribute, but this is obviously more work. for now, disabling is the workaround then
Hey all! quick question about some clj-kondo “errors” I’m seeing in a #sicmutils project; I have a bootstrap-repl!
macro that expands to a require
form, so I can do the equivalent of use
for REPL interaction in both Clojurescript and Clojure. The problem is that clj-kondo doesn’t see these required forms, leading to:
And yes, in a library or production codebase it would be quite poor style to reference vars this way. But this came up when using VSCode to work on a more interactive namespace that I am rendering using #nextjournal’s Clerk project
reading now!
@U04V15CAJ if I am writing these for macros in a library, like in this case, is there a good way to share these
for example I have a bunch of macros in #sicmutils that DO work in SCI already
@U017QJZ9M7W have you read https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration?
Here’s an example of clj-kondo exports for rewrite-clj https://github.com/clj-commons/rewrite-clj/blob/main/resources/clj-kondo.exports/rewrite-clj/rewrite-clj/config.edn
ie I have rewritten them already to work in the SCI context; it would be nice to not have to copy them again over to a config namespace
@U017QJZ9M7W let's focus on this bootstrap macro for now and not try to optimize everything at once
in general you can't run everything in clj-kondo like you can in SCI, clj-kondo isn't a normal Clojure runtime
so I expect you could share some macros but probably not all, like when you use resolve
or ns-publics
or whatever, you will have to make changes
@UE21H2HHD that’s awesome, that for sure answers how to bundle these config options with the sicmutils library.
@U04V15CAJ yeah, this particular one does use ns-publics
to go grab everything from the sicmutils.env
namespace and make it available
of course I could write something that just manually grabs everything on a library public
but it's far more reliable if you can pre-generate all your public vars and just let your clj-kondo macro-expansion spit them out for example
it would work for published versions…. it would have to be a commit hook to be stable for git deps
so that any commit, at least to main
, would have things up to date
the UX thing I am trying to avoid is
of course, where the editor can see a var but clj-kondo
can’t
(I get why there is a divergence here!)
do that inside the macroexpand hook?
okay, cool, I will give that a try
and then lint a file, I will see this in my console:
{:clj {foo {:ns app.core, :name foo, :fixed-arities #{0}}}}
of course you should not print in your expansion "in production", I was just trying to tell you how you could inspect the contents of this stuff
just saw this extra stuff, this is great. Thank you again!