-
-
Save jbullers/4db8ce3f4ff84ad47c43c6267f7a5c01 to your computer and use it in GitHub Desktop.
clj kondo arity linting for hiccup elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{: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]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{: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