Skip to content

Commit

Permalink
Merge pull request #1084 from metosin/fix-1083
Browse files Browse the repository at this point in the history
fix #1083
  • Loading branch information
ikitommi authored Aug 5, 2024
2 parents 28fea8f + 81ccc09 commit 07dbe8b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/malli/clj_kondo.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@
([config]
(save! config :clj))
([config key]
(save! config key nil))
([config key options]
(let [cfg-file (apply io/file (conj
(get config :clj-kondo-dir-path [])
(get options :clj-kondo-dir-path [])
".clj-kondo" "metosin" (str "malli-types-" (name key)) "config.edn"))]
;; delete the old file if exists (does not throw)
(.delete (apply io/file (conj
(get config :clj-kondo-dir-path [])
(get options :clj-kondo-dir-path [])
".clj-kondo" "configs" "malli" "config.edn")))
(io/make-parents cfg-file)
(spit cfg-file (with-out-str (fipp/pprint config {:width 120})))
Expand Down Expand Up @@ -207,7 +209,7 @@
#?(:clj
(defn emit!
([] (emit! {}))
([options] (->> (collect) (linter-config) (merge options) (save!)) nil)))
([options] (-> (collect) (linter-config) (save! :clj options)) nil)))

(defn collect-cljs
([] (collect-cljs nil))
Expand Down
1 change: 1 addition & 0 deletions test/demo.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
:city "Tampere"
:zip 33100
:lonlat [61.4858322, 23.7832851]}}))

9 changes: 9 additions & 0 deletions test/malli/clj_kondo_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
(:require [clojure.test :refer [deftest is testing]]
[malli.clj-kondo :as clj-kondo]
[malli.core :as m]
#?@(:clj [[clojure.java.io :as io]
[clojure.edn :as edn]])
[malli.util :as mu]))

(def Schema
Expand Down Expand Up @@ -155,3 +157,10 @@
(testing "regular expressions"
(is (= :string (clj-kondo/transform [:re "kikka"]))
"the :re schema models a string, clj-kondo's :regex a Pattern object")))

#?(:clj
(deftest fix-1083
(clj-kondo/emit! {:key "value"})
(let [data (edn/read-string (slurp (io/file ".clj-kondo/metosin/malli-types-clj/config.edn")))]
(is (map? data))
(is (= [:linters] (keys data))))))

0 comments on commit 07dbe8b

Please sign in to comment.