Fork me on GitHub
#clojurescript
<
2019-06-20
>
hlolli10:06:43

just a curiousity for cljs-react devs (almost all). I wonder, as a style guide, why it isn't a common practice to name react elements and react classes with capital letters. I've seen over and over again reagent/create-react-class, and that functions is a lowercase kebab-case function name. Jumping between js/ts and cljs, this lowercase love hurts my eyes a bit. Is there no cljs style guide recommending UpperCase for react-elements and react-classes?

Leland-kwong11:06:55

@hlolli I've been thinking about the same thing as well. I believe part of it had to do with the fact that PascalCase is currently used for https://github.com/bbatsov/clojure-style-guide/blob/master/README.adoc#CamelCase-for-protocols-records-structs-and-types

Leland-kwong11:06:11

Although I've been starting to think that namespacing components might be a better alternative.

hlolli11:06:29

I namespace components often, in react native, I'd do :> rn/FlatList, but the symbol name stays PascalCase

hlolli11:06:45

wasn't there a clojurescript specific style-guide?

tomjkidd13:06:01

Ran into something unexpected this morning using [org.clojure/clojurescript "1.10.520"] , (uuid "not-valid") produces #uuid "not-valid", which makes (uuid? (uuid "not-valid")) equal true. Is this a bug?

hlolli14:06:32

@tomjkidd this is also the case in older cljs versions, uuid is just a deftype in the cljs code. So any string creates a uuid, and all have the same print method. I guess you need to look for 3rd party library for validation, or regex if possible.

hlolli14:06:27

(defn uuid?
  [x] (implements? IUUID x))
could be misleading

dpsutton14:06:07

also annoyingly transit has a UUID which returns false to uuid?

hlolli14:06:59

there's no native javascript way of validating uuid (one could create webcrypto instance for it, but it could be an overkill).

tomjkidd14:06:24

Thanks @hlolli, just wanted to know if that was the intent. I will validate it myself with a regex before passing to uuid

👍 4
tomjkidd14:06:49

Definitely worth some docstring love

akiel15:06:30

Is there a UUID v5 lib in ClojureScript?

👋 4
lilactown16:06:32

FWIW I also PascalCase my React components. I know I might be in the minority

4
lilactown16:06:18

esp. since hx creates vanilla React components, it helps to make the naming of in-app and 3rd party components consistent

dpsutton17:06:56

you work in js and cljs a bunch correct? I never really knew it was a convention until recently

lilactown19:06:35

I keep my feet in both troughs yes 😅

parens 4