Skip to content

Instantly share code, notes, and snippets.

@jbullers
Last active May 19, 2023 13:18
Show Gist options
  • Save jbullers/4db8ce3f4ff84ad47c43c6267f7a5c01 to your computer and use it in GitHub Desktop.
Save jbullers/4db8ce3f4ff84ad47c43c6267f7a5c01 to your computer and use it in GitHub Desktop.
clj kondo arity linting for hiccup elements
(ns arity-sample
(:require [hiccup.core :as h]
[hiccup.form :as f]))
(defn create-form []
(h/html
(f/form-to
;; form-to won't fail linting if I add an attribute map here only because it takes varargs
[:post "/endpoint"]
;; The following two forms generate linting errors like this:
;; hiccup.form/text-field is called with 3 args but expects 1 or 2 clj-kondo(invalid-arity)
(f/text-field {:style "background-color: blue;"} "name" "Enter your name")
;; I can remove the errors like so, but would prefer to configure it once and be done with it:
#_{:clj-kondo/ignore [:invalid-arity]}
(f/submit-button {:style "background-color: red;"} "Submit"))))
{:lint-as
;; This helped remove other linting errors when I used the defelem and defhtml macros
{hiccup.def/defelem clojure.core/defn
hiccup.def/defhtml clojure.core/defn}
;; This doesn't seem to have any effect
:linters
{:invalid-arity
{:skip-args [hiccup.form/text-field
hiccup.form/submit-button]}}}
{:deps
{hiccup/hiccup {:mvn/version "1.0.5"}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment