Skip to content

Commit

Permalink
feat: init repo with base configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
lanjoni committed Oct 15, 2024
0 parents commit 368e8ec
Show file tree
Hide file tree
Showing 26 changed files with 3,562 additions and 0 deletions.
1 change: 1 addition & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:hooks {:analyze-call {dev.lanjoni.lib/defnc clj-kondo.lilactown.helix/defnc}}}
118 changes: 118 additions & 0 deletions .clj-kondo/lilactown/helix/clj_kondo/lilactown/helix.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
(ns clj-kondo.lilactown.helix
(:require
[clj-kondo.hooks-api :as api]))


(defn $
"Macro analysis for `helix.core/$` & `helix.dom/$d`."
[{:keys [node]}]
(let [[fn-sym & body] (-> node :children)
[component-sym body] [(first body) (next body)]
[old-props body] (if (api/map-node? (first body))
[(-> body first :children) (next body)]
[nil body])
children body
new-props (when old-props
(->> old-props
(map
#(if (cond-> (api/sexpr %) symbol? (= '&))
(api/keyword-node :&)
%))
api/map-node))
expanded (api/list-node
(list* fn-sym component-sym new-props children))]
{:node (with-meta expanded (meta node))}))


(defn dom
"Macro analysis for `helix.dom/*`."
[{:keys [node]}]
(let [[fn-sym & body] (-> node :children)
[old-props body] (if (api/map-node? (first body))
[(-> body first :children) (next body)]
[nil body])
children body
new-props (when old-props
(->> old-props
(map
#(if (cond-> (api/sexpr %) symbol? (= '&))
(api/keyword-node :&)
%))
api/map-node))
expanded (api/list-node
(list* fn-sym new-props children))]
{:node (with-meta expanded (meta node))}))


(defn analyze-definition
"Macro analysis for `helix.core/defnc` and `helix.core/defnc-`."
[{:keys [node]} definer]
(let [[_ component-name & body] (-> node :children)
render-children (last body)
the-rest (butlast body)
[docstring the-rest] (if (api/string-node? (first the-rest))
[(first the-rest) (rest the-rest)]
[nil the-rest])
[metadata-map the-rest] (if (api/map-node? (first the-rest))
[(first the-rest) (rest the-rest)]
[nil the-rest])
[argvec the-rest] (if (api/vector-node? (first the-rest))
[(-> the-rest first) (rest the-rest)]
[nil the-rest])
opts-node (when (api/map-node? (first the-rest))
(first the-rest))
metadata-map (when metadata-map
(-> (api/sexpr metadata-map)
(assoc :wrap
(api/sexpr
(api/list-node
(list*
(api/token-node '->)
(api/token-node '(helix.core/fnc [] ""))
(-> (api/sexpr metadata-map)
:wrap
(api/coerce)
:children)))))))
new-opts (if opts-node
(-> (api/sexpr opts-node)
(assoc :wrap
(api/sexpr
(api/list-node
(list* (api/token-node '->)
(api/token-node
'(helix.core/fnc [] ""))
(-> (api/sexpr opts-node)
:wrap
(api/coerce)
:children)))))
api/coerce
(with-meta (meta opts-node)))
opts-node)]
(when (and opts-node (contains? (api/sexpr opts-node) :wrap))
(prn :opts-node)
(api/reg-finding! (assoc (meta new-opts)
:message ":wrap should be passed to metadata map before args"
:type :helix/wrap-after-args)))
{:node (with-meta
(api/list-node
(list*
(api/token-node definer)
component-name
(filter some?
[docstring metadata-map
(if (and opts-node (get-in (api/sexpr opts-node) [:helix/features :define-factory]))
(api/vector-node
(concat (:children argvec)
[(api/token-node '&)
(api/token-node '_children)]))
argvec)
new-opts render-children])))
(meta node))}))

(defn defnc
[{:keys [node] :as form}]
(analyze-definition form 'defn))

(defn defnc-
[{:keys [node] :as form}]
(analyze-definition form 'defn-))
138 changes: 138 additions & 0 deletions .clj-kondo/lilactown/helix/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{:hooks {:analyze-call {helix.core/$ clj-kondo.lilactown.helix/$
helix.core/defnc clj-kondo.lilactown.helix/defnc
helix.core/defnc- clj-kondo.lilactown.helix/defnc-
helix.dom/$d clj-kondo.lilactown.helix/dom
helix.dom/a clj-kondo.lilactown.helix/dom
helix.dom/abbr clj-kondo.lilactown.helix/dom
helix.dom/address clj-kondo.lilactown.helix/dom
helix.dom/area clj-kondo.lilactown.helix/dom
helix.dom/article clj-kondo.lilactown.helix/dom
helix.dom/aside clj-kondo.lilactown.helix/dom
helix.dom/audio clj-kondo.lilactown.helix/dom
helix.dom/b clj-kondo.lilactown.helix/dom
helix.dom/base clj-kondo.lilactown.helix/dom
helix.dom/bdi clj-kondo.lilactown.helix/dom
helix.dom/bdo clj-kondo.lilactown.helix/dom
helix.dom/big clj-kondo.lilactown.helix/dom
helix.dom/blockquote clj-kondo.lilactown.helix/dom
helix.dom/body clj-kondo.lilactown.helix/dom
helix.dom/br clj-kondo.lilactown.helix/dom
helix.dom/button clj-kondo.lilactown.helix/dom
helix.dom/canvas clj-kondo.lilactown.helix/dom
helix.dom/caption clj-kondo.lilactown.helix/dom
helix.dom/circle clj-kondo.lilactown.helix/dom
helix.dom/cite clj-kondo.lilactown.helix/dom
helix.dom/clipPath clj-kondo.lilactown.helix/dom
helix.dom/code clj-kondo.lilactown.helix/dom
helix.dom/col clj-kondo.lilactown.helix/dom
helix.dom/colgroup clj-kondo.lilactown.helix/dom
helix.dom/data clj-kondo.lilactown.helix/dom
helix.dom/datalist clj-kondo.lilactown.helix/dom
helix.dom/dd clj-kondo.lilactown.helix/dom
helix.dom/defs clj-kondo.lilactown.helix/dom
helix.dom/del clj-kondo.lilactown.helix/dom
helix.dom/details clj-kondo.lilactown.helix/dom
helix.dom/dfn clj-kondo.lilactown.helix/dom
helix.dom/dialog clj-kondo.lilactown.helix/dom
helix.dom/div clj-kondo.lilactown.helix/dom
helix.dom/dl clj-kondo.lilactown.helix/dom
helix.dom/dt clj-kondo.lilactown.helix/dom
helix.dom/ellipse clj-kondo.lilactown.helix/dom
helix.dom/em clj-kondo.lilactown.helix/dom
helix.dom/embed clj-kondo.lilactown.helix/dom
helix.dom/fieldset clj-kondo.lilactown.helix/dom
helix.dom/figcaption clj-kondo.lilactown.helix/dom
helix.dom/figure clj-kondo.lilactown.helix/dom
helix.dom/footer clj-kondo.lilactown.helix/dom
helix.dom/form clj-kondo.lilactown.helix/dom
helix.dom/g clj-kondo.lilactown.helix/dom
helix.dom/h1 clj-kondo.lilactown.helix/dom
helix.dom/h2 clj-kondo.lilactown.helix/dom
helix.dom/h3 clj-kondo.lilactown.helix/dom
helix.dom/h4 clj-kondo.lilactown.helix/dom
helix.dom/h5 clj-kondo.lilactown.helix/dom
helix.dom/h6 clj-kondo.lilactown.helix/dom
helix.dom/head clj-kondo.lilactown.helix/dom
helix.dom/header clj-kondo.lilactown.helix/dom
helix.dom/hr clj-kondo.lilactown.helix/dom
helix.dom/html clj-kondo.lilactown.helix/dom
helix.dom/i clj-kondo.lilactown.helix/dom
helix.dom/iframe clj-kondo.lilactown.helix/dom
helix.dom/img clj-kondo.lilactown.helix/dom
helix.dom/input clj-kondo.lilactown.helix/dom
helix.dom/ins clj-kondo.lilactown.helix/dom
helix.dom/kbd clj-kondo.lilactown.helix/dom
helix.dom/keygen clj-kondo.lilactown.helix/dom
helix.dom/label clj-kondo.lilactown.helix/dom
helix.dom/legend clj-kondo.lilactown.helix/dom
helix.dom/li clj-kondo.lilactown.helix/dom
helix.dom/line clj-kondo.lilactown.helix/dom
helix.dom/linearGradient clj-kondo.lilactown.helix/dom
helix.dom/link clj-kondo.lilactown.helix/dom
helix.dom/main clj-kondo.lilactown.helix/dom
helix.dom/map clj-kondo.lilactown.helix/dom
helix.dom/mark clj-kondo.lilactown.helix/dom
helix.dom/mask clj-kondo.lilactown.helix/dom
helix.dom/menu clj-kondo.lilactown.helix/dom
helix.dom/menuitem clj-kondo.lilactown.helix/dom
helix.dom/meta clj-kondo.lilactown.helix/dom
helix.dom/meter clj-kondo.lilactown.helix/dom
helix.dom/nav clj-kondo.lilactown.helix/dom
helix.dom/noscript clj-kondo.lilactown.helix/dom
helix.dom/object clj-kondo.lilactown.helix/dom
helix.dom/ol clj-kondo.lilactown.helix/dom
helix.dom/optgroup clj-kondo.lilactown.helix/dom
helix.dom/option clj-kondo.lilactown.helix/dom
helix.dom/output clj-kondo.lilactown.helix/dom
helix.dom/p clj-kondo.lilactown.helix/dom
helix.dom/param clj-kondo.lilactown.helix/dom
helix.dom/path clj-kondo.lilactown.helix/dom
helix.dom/pattern clj-kondo.lilactown.helix/dom
helix.dom/picture clj-kondo.lilactown.helix/dom
helix.dom/polygon clj-kondo.lilactown.helix/dom
helix.dom/polyline clj-kondo.lilactown.helix/dom
helix.dom/pre clj-kondo.lilactown.helix/dom
helix.dom/progress clj-kondo.lilactown.helix/dom
helix.dom/q clj-kondo.lilactown.helix/dom
helix.dom/radialGradient clj-kondo.lilactown.helix/dom
helix.dom/rect clj-kondo.lilactown.helix/dom
helix.dom/rp clj-kondo.lilactown.helix/dom
helix.dom/rt clj-kondo.lilactown.helix/dom
helix.dom/ruby clj-kondo.lilactown.helix/dom
helix.dom/s clj-kondo.lilactown.helix/dom
helix.dom/samp clj-kondo.lilactown.helix/dom
helix.dom/script clj-kondo.lilactown.helix/dom
helix.dom/section clj-kondo.lilactown.helix/dom
helix.dom/select clj-kondo.lilactown.helix/dom
helix.dom/small clj-kondo.lilactown.helix/dom
helix.dom/source clj-kondo.lilactown.helix/dom
helix.dom/span clj-kondo.lilactown.helix/dom
helix.dom/stop clj-kondo.lilactown.helix/dom
helix.dom/strong clj-kondo.lilactown.helix/dom
helix.dom/style clj-kondo.lilactown.helix/dom
helix.dom/sub clj-kondo.lilactown.helix/dom
helix.dom/summary clj-kondo.lilactown.helix/dom
helix.dom/sup clj-kondo.lilactown.helix/dom
helix.dom/svg clj-kondo.lilactown.helix/dom
helix.dom/table clj-kondo.lilactown.helix/dom
helix.dom/tbody clj-kondo.lilactown.helix/dom
helix.dom/td clj-kondo.lilactown.helix/dom
helix.dom/text clj-kondo.lilactown.helix/dom
helix.dom/textarea clj-kondo.lilactown.helix/dom
helix.dom/tfoot clj-kondo.lilactown.helix/dom
helix.dom/th clj-kondo.lilactown.helix/dom
helix.dom/thead clj-kondo.lilactown.helix/dom
helix.dom/time clj-kondo.lilactown.helix/dom
helix.dom/title clj-kondo.lilactown.helix/dom
helix.dom/tr clj-kondo.lilactown.helix/dom
helix.dom/track clj-kondo.lilactown.helix/dom
helix.dom/tspan clj-kondo.lilactown.helix/dom
helix.dom/u clj-kondo.lilactown.helix/dom
helix.dom/ul clj-kondo.lilactown.helix/dom
helix.dom/var clj-kondo.lilactown.helix/dom
helix.dom/video clj-kondo.lilactown.helix/dom
helix.dom/wbr clj-kondo.lilactown.helix/dom}}
:lint-as {helix.core/defhook clojure.core/defn
helix.core/fnc clojure.core/fn}
:linters {:helix/invalid-children {:level :error}
:helix/wrap-after-args {:level :warning}}}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.clj-kondo/.cache
/.cpcache
/.lsp
/.shadow-cljs
/node_modules
/public/js/*
/public/css/bundle.css
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# helix-refx-tailwind-example

Minimal helix, refx and tailwind example, with shadow-cljs.

## How to use
```bash
# Install dependencies
npm i

# Start application with shadow
npm run dev
```

### After running `npm start`
App available at http://localhost:8200
Dev tools available at http://localhost:8300
nREPL available at port 8777

## Used software
- [shadow-cljs](https://github.com/thheller/shadow-cljs)
- [helix](https://github.com/lilactown/helix)
- [refx](https://github.com/ferdinand-beyer/refx)
- [tailwind](https://github.com/tailwindlabs/tailwindcss)

## TODO
- [ ] Test: add sample tests
12 changes: 12 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{:paths ["src"]
:deps {com.fbeyer/refx {:mvn/version "0.0.49"}
lilactown/helix {:mvn/version "0.1.11"}
thheller/shadow-cljs {:mvn/version "2.28.10"}
com.teknql/shadow-cljs-tailwind-jit {:mvn/version "1.0.0"}
lambdaisland/fetch {:mvn/version "1.5.83"}
metosin/reitit-schema {:mvn/version "0.5.18"}
metosin/reitit-frontend {:mvn/version "0.5.18"}
metosin/reitit-spec {:mvn/version "0.5.18"}
funcool/promesa {:mvn/version "11.0.678"}
mhuebert/kitchen-async {:mvn/version "0.1.0"}
org.clj-commons/digest {:mvn/version "1.4.100"}}}
Loading

0 comments on commit 368e8ec

Please sign in to comment.