Skip to content

Commit

Permalink
[#550] ignore reader tag in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Oct 26, 2019
1 parent 3ff1b2f commit 40daf53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/clj_kondo/impl/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1442,5 +1442,5 @@
;;;; Scratch

(comment
(parse-string "#'foo")
(parse-string "#js [1 2 3]")
)
18 changes: 12 additions & 6 deletions src/clj_kondo/impl/analyzer/usages.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
([ctx expr {:keys [:quote? :syntax-quote?] :as opts}]
(let [ns (:ns ctx)
ns-name (:name ns)
tag (tag expr)
quote? (or quote? (= :quote tag))]
(if (one-of tag [:unquote :unquote-splicing])
t (tag expr)
quote? (or quote? (= :quote t))]
(if (one-of t [:unquote :unquote-splicing])
(when-let [f (:analyze-expression** ctx)]
(f ctx expr))
(when (or (not quote?)
Expand All @@ -54,8 +54,8 @@
syntax-quote?)
(let [syntax-quote?
(or syntax-quote?
(= :syntax-quote tag))]
(case tag
(= :syntax-quote t))]
(case t
:token
(if-let [symbol-val (symbol-from-token expr)]
(let [simple-symbol? (empty? (namespace symbol-val))]
Expand Down Expand Up @@ -98,7 +98,13 @@
:config (:config ctx)})))))
(when (:k expr)
(analyze-keyword ctx expr)))
:reader-macro
(doall (mapcat
#(analyze-usages2 ctx %
(assoc opts :quote? quote? :syntax-quote? syntax-quote?))
(rest (:children expr))))
;; catch-call
(doall (mapcat
#(analyze-usages2 ctx % (assoc opts :quote? quote? :syntax-quote? syntax-quote?))
#(analyze-usages2 ctx %
(assoc opts :quote? quote? :syntax-quote? syntax-quote?))
(:children expr))))))))))
2 changes: 2 additions & 0 deletions test/clj_kondo/main_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,8 @@
(is (empty? (lint! "(import my.ns.Obj) (Obj.)"
{:linters {:unresolved-symbol {:level :error}}})))
(is (empty? (lint! (io/file "project.clj")
{:linters {:unresolved-symbol {:level :error}}})))
(is (empty? (lint! "^{:a #js [1 2 3]} [1 2 3]"
{:linters {:unresolved-symbol {:level :error}}}))))

(deftest deftest-test
Expand Down

0 comments on commit 40daf53

Please sign in to comment.