This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-10
Channels
- # aleph (1)
- # announcements (21)
- # babashka (3)
- # beginners (98)
- # calva (2)
- # circleci (3)
- # clara (58)
- # clj-kondo (123)
- # cljs-dev (1)
- # cljsrn (7)
- # clojure (162)
- # clojure-europe (2)
- # clojure-finland (7)
- # clojure-italy (5)
- # clojure-nl (6)
- # clojure-sanfrancisco (1)
- # clojure-spec (1)
- # clojure-survey (17)
- # clojure-uk (70)
- # clojuredesign-podcast (2)
- # clojurescript (46)
- # cloverage (5)
- # cursive (2)
- # data-science (22)
- # datascript (1)
- # datomic (60)
- # emacs (3)
- # figwheel-main (1)
- # fulcro (26)
- # graalvm (5)
- # jackdaw (3)
- # leiningen (8)
- # luminus (1)
- # off-topic (8)
- # other-lisps (2)
- # pedestal (27)
- # re-frame (17)
- # reagent (20)
- # reitit (3)
- # shadow-cljs (37)
- # spacemacs (23)
- # sql (69)
- # tools-deps (2)
- # utah-clojurians (9)
- # xtdb (3)
who was asking me recently about orchestra/defn-spec? I forgot, but I now have a solution for it on master. possibly also for rum macros (cc @robert-stuttaford)
{:lint-as {foo/my-defn clj-kondo.lint-as/def-catch-call}}
thanks @borkdude - the catch-all is definitely feeling better!
@robert-stuttaford Feel free to provide examples of code in the rum issue. That's what's still missing. Without any repros I can't do much
i'll write a short summary of the concern so it's there for future improvements
i did so, @borkdude https://github.com/borkdude/clj-kondo/issues/536#issuecomment-572997925 - super happy to update this comment if better information comes from elsewhere 🙂
Hello, I have the following function:
(defn wrap-internal-error [_handler]
(fn [_req]
(try+
(_handler _req)
(catch [:type :too-large-pdf] {:keys [request]}
...
and running clj-kondo
gives me the following error: my_file.clj:22:44: error: unresolved symbol request
. The try+
macro is from slingshot:0.12.2
.
Any suggestions on how to fix or work around the error?@lauri.lehmijoki You can ignore unresolved-symbols using a configuration: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#exclude-unresolved-symbols-from-being-reported so something like:
{:linters {:unresolved-symbol {:exclude [(foo/try+)]}}}
thank you so much!
I have the following expression:
(context "/api" []
:header-params [{authorization :- (describe s/Str (str "API key. For demo use: [TOKEN " @api-key "]")) nil}]
and running clj-kondo
gives me the following error: my_file.clj:117:41: error: unresolved symbol authorization
. The context
macro is from https://github.com/metosin/compojure-api/blob/85738b802c7f150f4f550ffca91a4782c75f8091/src/compojure/api/core.clj#L58.
Any suggestions on how to fix this one?My .clj-kondo/config.edn
is as follows:
{:linters {:unresolved-symbol {:exclude [(compojure.api.core/context)]}}
:output {:progress true}}
This works for me:
(ns foo
{:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [(compojure.api.core/context)]}}}}
(:require [compojure.api.core :refer [context]]))
(context "/api" []
:header-params
[{authorization :- (describe s/Str (str "API key. For demo use: [TOKEN " @api-key "]")) nil}])
Thanks, I realised that my namespace actually required compojure.api.sweet/context
instead of compojure.api.core/context
.
With config.edn
being
{:linters {:unresolved-symbol {:exclude [(compojure.api.sweet/context)]}}
:output {:progress true}}
I see no clj-kondo
errors.
Thank you for clj-kondo
and fast responses here on Slack!@borkdude I'm starting to think that using https://github.com/borkdude/clj-kondo/pull/696 is better than having a npm package for shadow-cljs projects
thoughts?
if you want to invoke clj-kondo on the JVM, you can just use it as a dependency. if you want to run the binary, then a package manager like npm or scoop may be better
yeah in the shadow case there is a JVM available
tbh it wasn't clear (to me) at all how to do it with shadow in the same way it was possible to do it with tools.deps and lein
hence adding the pr
does the :exclude-files
config entry support wildcards/globs/something to group things by, or does it need each individual file to be listed?
I had to look it up, but it seems each string in that entry is interpreted as a Java regex: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#include-and-exclude-files-from-the-output
I've been trying to exclude a folder for the last 10 minutes and haven't had much success....
I'm running shadow-cljs run clj-kondo.main --lint src/
I want to exclude everything in src/cljs/devcards/
what's the double slash?
Nope, this should just work:
user=> (re-find (re-pattern "/src/cljs/devcards") "/src/cljs/devcards/foo.cljs")
"/src/cljs/devcards"
I get reports like this
src\cljs\devcards\d_reactive.cljs:87:16: warning: unused binding *x
src\cljs\devcards\d_reactive.cljs:87:25: error: unresolved symbol conn
src\cljs\devcards\d_reactive.cljs:88:16: warning: unused binding *p
src\cljs\devcards\d_reactive.cljs:90:16: warning: unused binding *titles
src\cljs\devcards\d_reactive.cljs:109:27: error: unresolved symbol _
src\cljs\devcards\d_reactive.cljs:135:24: error: unresolved symbol dispatch
src\cljs\devcards\d_reactive.cljs:141:22: error: unresolved symbol ctx
src\cljs\devcards\keys.cljs:11:23: error: unresolved symbol x
src\cljs\devcards\keys.cljs:25:25: error: unresolved symbol app-state
src\cljs\devcards\keys.cljs:37:23: error: unresolved symbol ctx
src\cljs\devcards\keys.cljs:58:24: error: unresolved symbol id
maybe it's because I'm on windows
so the slash never works?
If I just use :output {:exclude-files ["d_reactive.cljs"]}
I can do away with the first file
but so far I'm unable to exclude the folder...
user=> (re-find (re-pattern "src\\\\cljs\\\\devcards\\\\") "src\\cljs\\devcards\\keys.cljs")
"src\\cljs\\devcards\\"
ok I can't do that then, because now the pattern might work locally but it will never work on CI or colleagues machines.... 😕
is there a way to exclude namespaces?
those wouldn't have path slash problems
no. I think in this case you just want to pass multiple paths:
--lint src\cljs\your-code src\cljs\your-other-code
ok I'll try that
thank you
these are just patterns passed to re-pattern and then applied to the paths with re-find. so there's nothing OS or filesystem specific in there
that can be done, but it's one of those "surprising in a bad way" things
the double escapes were very surprising
I don't think it's a matter of knowing the language, double escapes exist outside of clojure too
but I agree it is annoying. on the other hand, I don't know anyone who uses this feature
I wouldn't say it's a very important thing, no
it's just one of those "oh yeah I'm on windows so everything is harder" kind of thing
tbh most of the windows compat problems in the platforms I've come across are just path separator issues hahah
on another project we tried to put a path abstraction on top of both unix and windows paths and then... we ended up with 3 types of paths to make work 😐
another question please
is there any good way of knowing the name of the rule that's failing?
I'm going through a codebase and need to add some exceptions
some are straightforward enough to guess like unresolved-symbol
gotcha
I was looking at that file but some stuff is hard to match
like use the idiom (seq x) rather than (not (empty? x))
I was looking for prefer
use
seq
idiom
If you have any ideas about how to make this more accessible, e.g. by relating messages and their key in a table or something, PR welcome 🙂
I know tslint shows the rule name somewhere
but with tslint the usual pattern is to add an exclude comment so it is slightly different
I don't know if clj-kondo allows exclude comments too
not at the moment. I'm holding back on that a bit, since I don't want to confront users with all kinds of tooling metadata
I'll open an issue for showing the rule name somewhere for this scenario
if I have a macro that I can't/know how to make work with :lint-as
, is there a good way of just ignoring stuff using it?
e.g. clojure.core.match
I can destructure inside of it
(match [action]
[{:test t
:action a}] (when (t evt)
(a evt))
[action] (do
(.preventDefault evt)
(action evt))))
but will get unresolved symbol t
errors
1) There is an issue to add support for core.match. 2) You can ignore unresolved symbols inside a call, see config docs
I see now
thank you
(This might be unrelated to clj-kondo itself, but I couldn't find a #nix channel or something like that 🙂 - feel free to remove this!)
Would it be feasible to make a clj-kondo's nix package that also works on Macs?
I got the dreaded clj-kondo/default.nix:45 is not supported on ‘x86_64-darwin’
while trying to add it to a project. Some googling made me realise that my current nix-fu is not even close to sufficient to be able to diagnose/fix this 😬
(@UKFSJSM38 tagging you because I can see you got a PR accepted on that file!)
@aisamu clj-kondo depends on graalvm(https://github.com/NixOS/nixpkgs/pull/75733/files#diff-fdcc5997b875e2e3f53ef279f9e38864R48) that graalvm on nix its only supported to x86_64-linux
users(https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/graalvm/default.nix#L407) :/
Hi, I made the first version of the nix package. The problem is that graalvm doesn't build currently on Darwin (for nixos). I think there is a PR to fix that, once graalvm works on Darwin you should be able to build clj-kondo on Darwin without any modifications
Btw, for nix related questions, there is a relatively active community here: https://discourse.nixos.org/
Yup, but I'm unsure where nix package maintainers hang out 🙈. I know that at least one of them is here, so I thought it'd be worth a shot. Sorry for the noise!
@aisamu This issue was originally created for the nixOS package: https://github.com/borkdude/clj-kondo/issues/414 you can ping the author of that issue there as well
is it possible to exclude unresolved namespaces?
adding an exclude to the linter config doesn't seem to do it
https://github.com/borkdude/clj-kondo/blob/172d3fa53b39b7ed7dbe35f001debaafe5d0322b/src/clj_kondo/impl/namespace.clj#L201-L204 sounds like it should work with unresolved-symbol excludes instead
but I'm not having luck adding the ns itself to the unresolved-symbol list
I can, however, add the macro that uses the unresolved-namespace to the unresolved-symbol exclude list though
it's a the same as lazy-component
in https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html
it's meant to take a namespace
yeah, clj-kondo assumes you forgot a require there, which is in most cases helpful, but maybe in a macro like this isn't. it looks at the exclusions in :unresolved-symbol
though, as I suspected most macros that had this problem already needed such a rule there and it would be annoying to repeat rules for the same macro in two places