practicalli / practicalli/practicalli.github.io

article: Clojure format with cljstyle

Open
#18 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
7
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Using cljstyle to format Clojure code

Rational

  • its part of the setup-clojure GitHub action
  • its a binary so can be used as a pre-commit hook
  • its (arguably) nicer to configure than cljfmt and zprint
  • it can easily format code the same as cljfmt, so compatible with clojure-lsp formatting
  • one day I'll add cljstyle to MegaLinter

Using

check or fix

Configure

.cljstyle file (would be nice to be able to configure the location of this file)

key changes to support cljfmt style

  • list style (aligning lists on individual lines is 2 by default and cljfmt uses 1 (TBC)

Link to .cljstyle in practicalli/dotfiles repository

Summary

cljstyle is a binary so can be run anywhere, unlike cljfmt which is a libray and a leiningen plugin. So cljstyle is easier to install and use in more situations.

I found cljfmt very agressive and the configuration a little hard to understand without experimentation. cljstyle was much easier to understand and seems to have a much wider set of options. The default options are very close to that of the default cljfmt

I've raised an issue to add cljstyle to MegaLinter (and I'll check clj-kondo is using the latest version)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the issue's notes on cljstyle usage, configuration, and cljfmt compatibility, along with the linked .cljstyle in the practicalli/dotfiles repository. The article is done when it explains check and fix usage, .cljstyle configuration, and why cljstyle is useful for Clojure formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.