Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clj-kondo configuration #1

Open
dpassen opened this issue Jan 21, 2024 · 3 comments
Open

clj-kondo configuration #1

dpassen opened this issue Jan 21, 2024 · 3 comments

Comments

@dpassen
Copy link

dpassen commented Jan 21, 2024

Is there any interest in clj-kondo configuration? I see mount-lite has some hooks defined.

@aroemers
Copy link
Owner

Hi Derek,

Yes, for sure. That way many clj-kondo users benefit from better linting.

@piranha
Copy link

piranha commented Oct 14, 2024

Got it working like that (based on mount-lite hook):

(ns hooks.redelay
  (:require [clojure.string :as str]))

(defn- qualified-exprs [qualifiers exprs]
  (loop [qualifiers (set qualifiers)
         exprs      exprs
         qualifier  nil
         qualified  {}]
    (if (seq exprs)
      (let [expr (first exprs)]
        (if-let [qualifier (qualifiers expr)]
          (recur (disj qualifiers qualifier) (rest exprs) qualifier qualified)
          (recur qualifiers (rest exprs) qualifier (update qualified qualifier (fnil conj []) expr))))
      qualified)))

(defmacro defstate [name & args]
  (let [{:keys [start stop] names :name metas :meta implicit-start nil}
        (qualified-exprs [:name :start :stop :meta]
          (concat [:name name] args))
        start (or start implicit-start)
        hmap  {:name     (first names)
               :start-fn `(fn [] ~@start)
               :stop-fn  (if (str/includes? (str stop) "this")
                           `(fn [~'this] ~@stop)
                           `(fn [] ~@stop))
               :meta     (first metas)}]
    `(def ~name (redelay.core/map->State ~hmap))))

@aroemers
Copy link
Owner

aroemers commented Nov 6, 2024

@dpassen and @piranha could you have a look at #2? I hope it satisfies your needs with minimal code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants