mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
dev(lint): add :path-invalid-construct/string-join linter
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
{:exclude [frontend.db.conn frontend.db.react logseq.db.default]}}}}
|
||||
|
||||
:linters
|
||||
{:aliased-namespace-symbol {:level :warning}
|
||||
{:path-invalid-construct/string-join {:level :warning}
|
||||
:aliased-namespace-symbol {:level :warning}
|
||||
;; Disable until it doesn't trigger false positives on rum/defcontext
|
||||
:earmuffed-var-not-dynamic {:level :off}
|
||||
:unresolved-symbol {:exclude [goog.DEBUG
|
||||
@@ -108,7 +109,8 @@
|
||||
:used-underscored-binding {:level :warning}}
|
||||
|
||||
:hooks {:analyze-call {rum.core/defc hooks.rum/defc
|
||||
rum.core/defcs hooks.rum/defcs}}
|
||||
rum.core/defcs hooks.rum/defcs
|
||||
clojure.string/join hooks.path-invalid-construct/string-join}}
|
||||
:lint-as {promesa.core/let clojure.core/let
|
||||
promesa.core/loop clojure.core/loop
|
||||
promesa.core/recur clojure.core/recur
|
||||
|
||||
15
.clj-kondo/hooks/path_invalid_construct.clj
Normal file
15
.clj-kondo/hooks/path_invalid_construct.clj
Normal file
@@ -0,0 +1,15 @@
|
||||
(ns hooks.path-invalid-construct
|
||||
"This hook try to find out those error-prone path construction expressions:
|
||||
- (string/join \"/\" [...])"
|
||||
(:require [clj-kondo.hooks-api :as api]))
|
||||
|
||||
|
||||
(defn string-join
|
||||
[{:keys [node]}]
|
||||
(let [[_ sep-v & _args] (:children node)]
|
||||
;; (prn :string-join)
|
||||
(when (and (api/string-node? sep-v)
|
||||
(= ["/"] (:lines sep-v)))
|
||||
(api/reg-finding! (assoc (meta node)
|
||||
:message "don't use clojure.string/join to build a path, (use #_{:clj-kondo/ignore [:path-invalid-construct/string-join]} to ignore)"
|
||||
:type :path-invalid-construct/string-join)))))
|
||||
Reference in New Issue
Block a user