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

fix #1083 #1084

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))))))