cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
borkdude 2019-10-02T15:48:24.063500Z

I'm writing an "unused private var" linter in kondo right now and testing it on CLJS. It seems there are quite some unused ones:

$ rg extend-object!
src/main/cljs/cljs/core.cljs
3015:(defn- extend-object!

1
😱 1
borkdude 2019-10-02T15:49:23.063700Z

$ rg flatten1
src/main/cljs/cljs/core.cljs
5114:(defn- flatten1

borkdude 2019-10-02T17:56:45.064400Z

I'm surprised a lot of these private fns aren't used anywhere: https://github.com/clojure/clojurescript/blob/a760439b5084937a556712d6ee056e95f4f075c7/src/main/cljs/cljs/pprint.cljs#L169 Like set-max-column. I must be overseeing something.

borkdude 2019-10-02T18:00:06.065300Z

The challenge in this linter is that some private fns defined in .cljc/.cljs may be used in .cljs/.cljc, so it's not just a matter of checking all defs/calls in one file

2019-10-05T12:06:14.065800Z

You can also access a private var by using the Var directly, instead of resolving it through a symbol. E.g. (#'some.lib/a-private-fn 1 2 3), which can be called from anywhere.

🦜 1
borkdude 2019-10-05T12:06:54.066Z

True. That's already accounted for in the linter, it will let you do that.

thheller 2019-10-02T18:11:30.065700Z

totally possible those aren't used anymore but were in the past