Skip to content

clj-kondo/hooks-workshop-clojured-2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hooks-workshop-clojured-2022

Getting hooked on clj-kondo!

Introduction

Clj-kondo is a linter and static analyzer for Clojure/Script. It has out of the box support for syntactic constructs in Clojure, often defined by macros. For third party macros similar to Clojure's own, clj-kondo has an easy configuration option: :lint-as. But what about macros that invent their own language? You can disable linting for those, but what if there was something better. Clj-kondo hooks are a flexible way to teach clj-kondo's static analyzer about any macro. Not only will clj-kondo understand them and will you get useful linting feedback, you can insert your own checks and linting rules. As a library author you can export your hooks so every library user can profit. In this workshop we will learn how to write our own hooks using real-world examples. Only a basic understanding of Clojure is required to get hooked!

Prerequisites

Before entering the workshop, please make sure you have the following in place.

  • A Clojure REPL with the following dependencies:
clj-kondo/clj-kondo {:mvn/version "2022.05.31"}

Recommended:

  • A command line installation of clj-kondo version 2022.05.31 or newer
  • If you are using clojure-lsp: version 2022.05.31-17.35.50 or newer. When using Calva, this will be installed automatically.
  • When using Cursive, clojure-extras, the newest version

See Installation and Editor integration for further details.

Agenda

  • Part 0: team up!
  • Part 1: dealing with macros without hooks
  • Part 2: :macroexpand hooks
  • Part 3: :analyze-call hooks
  • Part 4: hooks with customized lint warnings
  • Part 5: distributing configuration and hooks

About

Hooks workshop at ClojureD 2022

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published