oakmac / clojurefmt-js

clojurefmt in JavaScript
ISC License
4 stars 0 forks source link

Clojure should have a simple code formatter #1

Open oakmac opened 1 year ago

oakmac commented 1 year ago

Clojure is a popular functional language that targets host platforms on the JVM, JavaScript, and more (1, 2, etc). Clojure is a Lisp and shares in the rich history of that unique syntax.

As of 2023, there is not a standard way to format Clojure code. The Clojure Style Guide is a popular document, but it has many rules and requires program runtime information to be applied 100% correctly. There are some excellent libraries to automatically format Clojure code such cljfmt and zprint. While many engineering teams use these tools successfully to consistently format their codebase, they have some downsides. Both projects provide many config options and are not easy to run in all environments and IDEs.

In 2018, there was a request to create a standard Clojure formatter in the spirit of gofmt (the standard code formatter for the go programming language). This resulted in much valuable discussion, but ultimately no tool was created with large community adoption.

The purpose of this project is to provide a "no config, runs everywhere, follows simple rules" formatter for Clojure code. It is heavily inspired by the Better Clojure Formatting article written by Niki Tonsky.

This project is written in JavaScript - which has wide platform reach - with the intention of creating a small, language-portable implementation that can be cloned to multiple languages with ease. This approach is inspired by how the Parinfer core algorithm is ported to multiple languages (parinfer.py, parinfer-lua, etc).