This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-29
Channels
- # announcements (3)
- # babashka (47)
- # beginners (88)
- # calva (17)
- # clj-kondo (8)
- # cljdoc (1)
- # clojars (9)
- # clojure (98)
- # clojure-europe (53)
- # clojure-norway (2)
- # clojure-seattle (1)
- # clojure-uk (5)
- # clojurescript (20)
- # cursive (11)
- # data-oriented-programming (1)
- # data-science (3)
- # datahike (1)
- # datascript (3)
- # events (3)
- # graalvm (5)
- # honeysql (7)
- # hyperfiddle (1)
- # jobs-discuss (10)
- # leiningen (3)
- # malli (16)
- # music (4)
- # nbb (17)
- # off-topic (45)
- # pathom (9)
- # portal (7)
- # releases (1)
- # shadow-cljs (80)
- # sql (15)
- # tools-build (5)
- # xtdb (23)
Hi! Custom hooks question
> (I'm like addicted to these now lol)
Haven't seen anything in the docs about this, but is there some kind of support for "multiple" hooks per function?
Specifically, I'm thinking of the following:
1. I, with @borkdude’s help of course, introduced a couple hooks for #helix (`defnc/$/d/*`), that have since been released and thus introduced into our work codebase (as we use helix)
2. At the same time, we have some business-logic / org-specific things we want to lint for those same functions, that wouldn't make sense for upstream contribution
a. (eg a linter warning against using a business-logic-specific fn that doesn't work well in helix components but works great otherwise)
3. I could turn off clojure-lsp
's auto copying of library hooks, and then introduce the desired new org-specific linters inline into our own hook(s) for helix, but then I'd lose automatically getting any upstream changes when helix (and its hooks) update (at which point clojure-lsp
would copy over the changed hooks)
Any thoughts or prior art on this?
1. I'm wondering, if it doesn't already exist, if some way to override or "cascade" (in the sense of like, CSS or something) hooks might work.
◦ Not sure how one might navigate the fact that the "order" of apply hooks matters a lot, as one hook's output might utterly invalidate subsequent ones' input expectations.
2. Or is it just worth it instead to introduce some degree of configurability into the #helix hooks such that they can - to start with - accept some collection of no-no symbols to warn against usage?
@rayatrahman9 Currently there can be only one hook for a function/macro. I'm considering multiple hooks, but if one hook transforms the call, then the other hooks won't get to see the input at all, so it's tricky. You could just configure your own hooks, then the imported hooks should be ignored
1. Yeah, tricky indeed. I'll simply say then that I'm very curious what you, in particular, are able to come up with for multiple hooks, should you choose to continue to consider it at all 2. Will try. It will mean still that upstream changes will not be auto copied, but since the upstream library's author is my manager anyways, I don't think it'll be too hard to keep track haha
What I mean with using it as a library: you could define your own hook, do your own things - don't know if you're only doing some linting or also transformation
But if you don't do transformation, you can then pass the node to the imported hook function