This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-22
Channels
- # babashka (106)
- # beginners (29)
- # biff (29)
- # calva (9)
- # cider (6)
- # clj-kondo (24)
- # clojure (40)
- # clojure-europe (94)
- # clojure-japan (1)
- # clojure-nl (1)
- # clojure-norway (45)
- # clojure-uk (13)
- # clojuredesign-podcast (5)
- # clojurescript (12)
- # clr (4)
- # community-development (2)
- # conjure (13)
- # cryogen (4)
- # cursive (4)
- # deps-new (1)
- # fulcro (18)
- # hugsql (2)
- # hyperfiddle (67)
- # jobs (1)
- # malli (47)
- # meander (2)
- # missionary (34)
- # off-topic (1)
- # podcasts-discuss (1)
- # polylith (24)
- # reagent (19)
- # reitit (9)
- # sci (7)
- # shadow-cljs (3)
- # testing (28)
- # tools-deps (1)
- # xtdb (9)
A JS interop case that bit me yesterday was this line: (js/console "Something" js-obj-thing)
and of course I meant js/console.log "Something" js-obj-thing
but the output was to debug a third party library whose calling semantics were a bit obscured cos it's written in TS and I was getting all kinds of other errors that blinded me to that SNAFU ... totally floored when I realized that I had fixed the call to the library 30 mins ago but was still banging my head trying to understand this
TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function
at bt (file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:338:125)
at file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:597:410
at R (file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:309:469)
at file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:558:423
at R (file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:309:469)
at file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:559:305
at R (file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:309:469)
at file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_core.js:418:411
at file:///home/ray/acme/repos/publish-rate-card/node_modules/nbb/lib/nbb_promesa.js:39:342
at processTicksAndRejections (internal/process/task_queues.js:95:5)
This makes me wonder if it would be useful to support a simple regex rule type (if there isn't already such a thing). For a static case like this, you would define a rule something like:
{:regex {:match "js/console "
:message "Did you mean `js/console.log`?"}}
Having a warning that it was not js/console.log
or js/console.error
would have been nice 🙂
oh, and the rule should be called consolation
😛 ... I'd be interested in making a PR if you want to give me a steer @borkdude
Hey Ray, thanks for the ideas, but not sure how generalizable this is. There might be objects on js
that are legit, defined by libraries as globals. How would clj-kondo know what's valid?
Yeah, I’m not sure how to make it general but I still think that having some known good vs unknown states could be useful. Somebody might have console globally but if it is in the function slot, it should be callable ie not an object or an object property
Hello — I'm using lambdaisland/glogi and sometimes it happens that I do something like (log/info :test)
but since glogi expects map-entries this should be at least (log/info :test nil)
— I tried adding a :lint-as
entry pointing to clojure.core/hash-map
but so far it doesn't seem like that is being picked up. Am I missing anything here?
thank you! enjoy strange loop 🙂
I guess lint-as doesn't really treat type checking the same way, maybe for good reasons
ah but isn't this more of an arity-check in a way?
I don't think lint-as affects arity checking, it's mostly for getting rid of unknown macro syntax things
you could set this type for glogi/log manually:
'hash-map {:arities {:varargs {:args [{:op :rest :spec [:any :any]}]
:ret :map}}}
{:linters {:type-mismatch {:namespaces {lint-as {dude {:arities {:varargs {:args [{:op :rest :spec [:any :any]}]
:ret :map}}}}}}}
Thanks, that's doing what I was looking for 🙂