Coding conventions

From Status Wiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

This document details coding style followed by status-react project.

It is based on following documents:

Some points particularly relevant are refined bellow.


No :use, :refer or :refer :all, only :as

(ns examples.ns
  (:require [ :as zip]))

Use consistent aliases across namespaces

Align keywords

(ns examples.ns
  (:require [clojure.string :as str]
                 [     :as zip]))

Use long aliases when needed


Comments start with ;;

;; some comment

Comments should be added before form

;; public key of current logged in account
(s/def ::current-public-key (s/nilable string?))

;; used in modal list (for example for wallet)
(s/def :contacts/contacts-click-params (s/nilable map?)) 


Declare keys on first line

    :<- [:get :contacts]
    :<- [:get-contacts]
    (fn [contacts [_ id]]
      (:photo-path (contacts id))))

 (register-handler :request-discoveries

+(reg-fx ::init-store
 +  (fn []
 +    (data-store/init)))

TODO Keywords and namespaces?


Use meaningful namespaced keywords

(s/def :contact/last-updated (s/nilable int?))