Fork me on GitHub
#clj-kondo
<
2023-08-29
>
John Doe17:08:37

anybody know what's the proper syntax to lint-as def :^dynamic {:lint-as {xxx.core/mydef clojure.core/def}}, here I dont want a normal def, but a dynamic def

2
borkdude17:08:03

how does the problem manifest itself when you use the above config?

John Doe17:08:45

so I'm defining my weird def to lint as normal def, but since I use my-weird-def with earmuffed name always, so I'm actully defining my-weird-def as def :^dynamic, hope that make sense:slightly_smiling_face:

borkdude17:08:34

can you please give an example/repro of what code goes in and what undesired warnings come out?

John Doe17:08:10

sure, take this repo for example: https://github.com/teknql/systemic it has {:lint-as {systemic.core/defsys clojure.core/def}} , but from usage example its defsys all have earmuffed name. clj-kondo [earmuffed-var-not-dynamic]: Var has earmuffed name but is not declared dynamic: server

John Doe17:08:11

so this case I guess it'd be more proper to lint systemic.core/defsys as def :^dynamic i guess

borkdude17:08:39

I can't reproduce:

$ clj-kondo --config '{:lint-as {foo/deffoo clojure.core/def}}' --lint - <<< "(ns foo) (declare deffoo)  (deffoo ^:dynamic *foo* 1)"
linting took 5ms, errors: 0, warnings: 0

hiredman17:08:02

or, if don't want to be warned for defining names with earmuffs that are not dynamic, turn off the linter that does that

borkdude17:08:20

do you mean that deffoo always creates a dynamic var?

John Doe17:08:22

yeah, turing that off is another way 😄

John Doe17:08:50

yes, deffoo always creates a dynamic var

borkdude17:08:04

@U0599HVJX70

$ clj-kondo --config '{:config-in-call {foo/deffoo {:linters {:earmuffed-var-not-dynamic {:level :off}}}} :lint-as {foo/deffoo clojure.core/def}}' --lint - <<< "(ns foo) (declare deffoo)  (deffoo *foo* 1)"
linting took 58ms, errors: 0, warnings: 0

borkdude17:08:23

:config-in-call lets you disable this linter only in calls to your macro, see above

hiredman17:08:31

in the example code above it is not the case that defsys creates a dynamic var

hiredman17:08:05

you can tell because you can grep the code base for :dynamic and Dynamic

John Doe17:08:48

yeah, i know, i happen to like its convention of earmuffed name this case, nothing about dynamic or not this case

John Doe17:08:08

thanks @U04V15CAJ, that works!

👍 2