This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-06
Channels
- # babashka (31)
- # beginners (108)
- # calva (6)
- # clj-kondo (62)
- # cljsrn (5)
- # clojure (29)
- # clojure-australia (2)
- # clojure-europe (17)
- # clojure-nl (2)
- # clojure-spec (5)
- # clojure-uk (7)
- # clojurescript (25)
- # code-reviews (1)
- # datomic (13)
- # deps-new (7)
- # editors (1)
- # emacs (31)
- # figwheel-main (3)
- # garden (4)
- # graalvm (18)
- # helix (10)
- # improve-getting-started (12)
- # jobs (3)
- # lsp (20)
- # malli (12)
- # off-topic (7)
- # polylith (30)
- # re-frame (10)
- # remote-jobs (2)
- # shadow-cljs (18)
- # spacemacs (5)
- # sql (11)
- # tools-deps (10)
- # vim (9)
- # xtdb (1)
Hi, I was using some of the macros of failjure
library - https://github.com/adambard/failjure
There are ~13 macros, so what would be the best way to get rid of unresolved-symbol
linting warnings?
I have tried something like this
{:linters
{:unresolved-symbol
{:exclude [(failjure.core)]}}}
but it’s not working(it’s taking clojure-lsp initialization to load forever)This config isn't valid, don't wrap this in parens as the symbol isn't fully qualified
(defmacro ok->
"Like some->, but with ok? instead of some?
(i.e., short-circuits when it encounters a failure)"
([start & forms]
`(if-let-failed? [v# ~start]
v#
(attempt-> v# ~@forms))))
this is one of themhttps://github.com/adambard/failjure/blob/master/src/failjure/core.cljc - here you can see more of them
and if you have it all working, you can donate the config to the library itself or to clj-kondo/config so others don't have to re-invent the wheel
failjure.core/ok-> clojure.core/->
failjure.core/ok->> clojure.core/->>
failjure.core/try-all clojure.core/let
failjure.core/try* clojure.core/fn
failjure.core/when-failed clojure.core/fn
failjure.core/if-failed clojure.core/fn
failjure.core/attempt-all clojure.core/let
failjure.core/if-let-ok? clojure.core/let
failjure.core/if-let-failed? clojure.core/let
failjure.core/when-let-failed? clojure.core/let
failjure.core/when-let-ok? clojure.core/let
these mostly are the configs, I’ll take a look on the docs you shared later today, to add it in the configs or the library itselfyes, I will do that(even for when-let*s)
also this try* macro was giving error Function arguments should be wrapped in vector.
(defmacro try* [& body]
`(try-fn (fn [] ~@body)))
what could be the possible linting option for that?@pratikgandhi1997 in case you want a example of adding the config to the lib itself: https://clojurians.slack.com/archives/CHY97NXE2/p1630770692107400?thread_ts=1630770692.107400&cid=CHY97NXE2
Added a PR on failjure repo - https://github.com/adambard/failjure/pull/27/files
@pratikgandhi1997 in your PR, this way will only work for the failjure repo, not for libs using it
you need to include in the resources, check https://github.com/ptaoussanis/encore/pull/56 as example, or clj-kondo docs about that https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration
oh, I thought we need to do that only if we are using hooks to do some special thing, let me take a look
clj-kondo doesn't import config from the libraries own .clj-kondo
directory since that's not on the classpath typically
yeah, your case you don't need any clojure code as you only need the lint-as, but even so you need to add it to the resources
but you can refer to the exported config from the .clj-kondo
dir so you can use it while developing the lib
Here is how you do that: https://github.com/fulcrologic/fulcro/blob/develop/.clj-kondo/config.edn
okay, I am a little unsure about what to add in the place of com.fulcrologic/fulcro
Should it be adambard/failjure
in this case? How do we derive it?
yes, group-id/artifact-id, just something to not conflict with other configs in classpath from other libs
That should work, just not sure if adding to src is a good idea, maybe adding to the resources
folder?
since resources
folder is alredy in classpath as lein adds that folder by default
Updated the PR, please recheck, I have assumed that we don’t need to give a relative path in the .clj-kondo/config.edn
as it’s already on classpath
Why do I get Found an opening ( with no matching )
here?
(foo^ :bar)
(It’s not something I need to do, just some test data I have, and I got curious about the problem report.)Clojure is complaining in similar ways. Though it is giving me some more context by first warning: Metadata must be Symbol,Keyword,String or Map
.
This is coming from tools reader, I think.
$ plk
ClojureScript 1.10.597
cljs.user=> (foo^ :bar)
Syntax error reading source at (<cljs repl>:1).
Unmatched delimiter ).
Thanks. I should probably fix this in Calva’s tokenizer, but as long as clj-kondo protects the user it is maybe not worth it.
I realized my defroutes
warning came from clj-joker
😅 is there any reason to use both?
I stopped using other linters long ago, clj-kondo is really a joy to use and both the most complete out of the box and most used by the community.
I am using https://github.com/seancorfield/honeysql library in my project and when I use it with clj-kondo
I am getting few unresolved-var
errors, looks like some of those functions use defalias
, what would be the best way to suppress/fix them?
@pratikgandhi1997 Sounds like you're using HoneySQL 1.0? I'd strongly recommend using 2.0 for any new code.