Fork me on GitHub
#clj-kondo
<
2022-07-01
>
Sakib10:07:08

I'm getting this error. I'm using vscode Unresolved namespace System. Are you missing a require?clj-kondo(unresolved-namespace)

borkdude11:07:49

@nsakib.cse Need more info please. Your code and file extension. I.e. a repro.

Sakib16:07:59

https://github.com/starain31/hello-deps-edn I try to create a sample. Here I got the error in .cljc file but not in .clj file. I don't know the difference of those file type. @borkdude

borkdude16:07:25

@nsakib.cse This is expected since .cljc files are usually used for both Clojure and ClojureScript and System is not a known thing in ClojureScript. You can solve this by writing:

#?(:clj (System/...))

thanks3 1
Sakib16:07:05

Got it, thanks. BTW can you recommend some tutorial on Reader Conditionals @borkdude?

Sakib21:07:02

If I solve by this way

(defn exit
  [status]
  #?(:clj (System/exit status)))
I get another warning unused binding status clj-kondo(unused-binding) I could get away from all warning by adding reader conditionals to the defn
#?(:clj (defn exit
          "Exit the process with `status` and show `msg`."
          [status]
          (System/exit status)))
I'm calling this function from a babashka task
{:paths ["script"]
 :min-bb-version "0.7.0"
 :tasks
 {pre-push {:extra-paths ["test"]
            :requires    ([pre-push])
            :task        (pre-push/main *command-line-args*)}}}
Which technique is correct or preferable?

borkdude21:07:46

@nsakib.cse Good. Yes, sometimes this can be a bit annoying, but sometimes it can also be helpful to see that you forgot to use a binding in one branch

borkdude21:07:13

Yes, this seems good. bb tasks also supports a short-hand for

:requires    ([pre-push])
:task        (pre-push/main *command-line-args*)}
Simply:
:task pre-push/main

Sakib21:07:10

Do you prefer wrap defn with #?(:clj) ?

borkdude21:07:28

If you don't use that function in ClojureScript, why not?

👍 1
borkdude21:07:44

whatever works best for you