Fork me on GitHub
#helix
<
2021-06-04
>
dominicm08:06:27

Just reviewing the docs on custom defnc and reflecting on this line: ~(merge default-opts opts). One major downside to this is that you can't do a partial override of the options, e.g. {:helix/features {:define-factory true}} will accidentally turn off fast-refresh. I was thinking of instead using ~(assoc (merge default-opts opts) :helix/features (merge (:helix/features default-opts) (:helix/features opts))) on the basis that all the helix features can be turned off as easily as on (e.g. the replace mode isn't required)

dominicm12:06:54

Just spotted https://github.com/lilactown/helix/blob/master/resources/clj-kondo.exports/lilactown/helix/config.edn#L1. This didn't work for us, and we ended up expanding to:

(defn ~name [& ~@args] ~@body)
This fixed the factory usage, where you might have (defnc foo [props ref]) But you're supposed to call it as (foo {:ref …}) which then upsets kondo about missing arguments. Just one to ponder, no real action.

lilactown18:06:18

ack, thanks!

lilactown18:06:47

I would accept PRs for both of those improvements

lilactown18:06:59

I'm still a little fuzzy on the clj-kondo config.

wilkerlucio18:06:26

@dominicm @lilactown not sure if is the issue here, but I have two things that help me to make the foreign clj-kondo config works: 1. on the Helix side, make sure resources is present on classpath 2. on the project client side, use clj-kondo --copy-configs --dependencies --lint "$(clojure -Spath -A:provided:dev)" --parallel to make kondo copy over the configs

lilactown19:06:11

ack, i did forget that

lilactown19:06:28

I think @dominicm’s point was that even once he was able to use the config I tried to ship with helix, clj-kondo was complaining due to the fact that they're using defnc's factory function feature flag

lilactown19:06:35

not sure how to support both tbh

dominicm07:06:16

@lilactown You'll need to use hooks. Although for usage via $ clj-kondo only cares that there's a var in place (e.g. it could be expanded to (def name nil) ). It depends how much you care about finding mistakes vs just making the warnings go away 🙂

dominicm07:06:46

Regarding location, I might be inclined to just stick the clj-kondo.exports in the src folder tbh. There's no real advantage to separating them out.

lilactown18:06:26

it would be pretty cool to add analysis for $

lilactown18:06:21

but that’s fraught. not all props are necessary, and & merge obfuscates compile-time analysis