File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 159
159
:protocol-impl-recur-with-target true
160
160
:single-segment-namespace true
161
161
:munged-namespace true
162
+ :js-used-as-alias true
162
163
:ns-var-clash true
163
164
:non-dynamic-earmuffed-var true
164
165
:extend-type-invalid-method-shape true
439
440
(str " Namespace " name " contains a reserved JavaScript keyword,"
440
441
" the corresponding Google Closure namespace will be munged to " munged)))
441
442
443
+ (defmethod error-message :js-used-as-alias
444
+ [warning-type {:keys [spec] :as info}]
445
+ (str " In " (pr-str spec) " , the alias name js is reserved for JavaScript interop" ))
446
+
442
447
(defmethod error-message :ns-var-clash
443
448
[warning-type {:keys [ns var] :as info}]
444
449
(str " Namespace " ns " clashes with var " var))
2994
2999
lib' ((alias-type @aliases) alias)]
2995
3000
(when (and (some? lib') (not= lib lib'))
2996
3001
(throw (error env (parse-ns-error-msg spec " :as alias must be unique" ))))
3002
+ (when (= alias 'js)
3003
+ (when-not (= lib (get-in @aliases [(if macros? :fns :macros ) 'js])) ; warn only once
3004
+ (warning :js-used-as-alias env {:spec spec})))
2997
3005
(swap! aliases
2998
3006
update-in [alias-type]
2999
3007
conj [alias lib] (when js-module-provides [js-module-provides lib]))))
Original file line number Diff line number Diff line change 1493
1493
(:import goog))]))
1494
1494
(is (= {} (get-in @cenv [::ana/namespaces 'test.foo :imports ])))))
1495
1495
1496
+ (deftest test-cljs-3320
1497
+ (let [ws (atom [])]
1498
+ (ana/with-warning-handlers [(collecting-warning-handler ws)]
1499
+ (binding [ana/*cljs-ns* 'cljs.user]
1500
+ (analyze ns-env '(ns cljs3320.core (:require [cljs.js :as js])))))
1501
+ (is (string/includes? (first @ws) " the alias name js is reserved for JavaScript interop" ))))
1502
+
1496
1503
(deftest test-cljs-3371
1497
1504
(let [ws (atom [])]
1498
1505
(ana/with-warning-handlers [(collecting-warning-handler ws)]
You can’t perform that action at this time.
0 commit comments