formatting-stack is a formatting/linting solution that can be integrated with:
eval
As of today, it is integrated with:
And it also bundles a few tiny linters of its own:
It is fully extensible: you can configure the bundled formatters, remove them, and/or add your own.
Whenever it's safe, each formatter/linter will make full use of your CPU's cores.
Linters' reports are presented under a unified format.
As mentioned, formatting-stack understands your codebase and its dependencies. It knows which vars in the project are macros. It also reads the metadata of all function/macro vars.
It also associates :style
metadata to your project's vars, in a clean manner, when needed.
Armed with those powers, we can do two nifty things:
You can find examples of how to do such configuration in the wiki.
Git integration is documented at formatting-stack.strategies
.
The general intent is to make formatting:
...that's the default Git strategy
anyway, apt for repl-driven development. You are free to supply an alternative strategy.
Commonly needed alternative strategies are offered/documented in branch-formatter and project-formatter.
As you can see in the screenshot, formatting-stack presents linters' outputs under a hierarchical, file-grouped format.
[formatting-stack "3.1.1-alpha2"]
Also you might have to add the refactor-nrepl dependency.
formatting-stack provides components that you can integrate into your system.
The provided components are fully configurable. See formatting-stack.core
, formatting-stack.component
, formatting-stack.integrant
.
com.stuartsierra.component.repl/reset
will use formatting-stack, applying all its formatters/linters.
integrant.repl/reset
will use formatting-stack, applying all its formatters/linters.
The above can be good enough. However reset
ting your system can be somewhat expensive,
and you may find yourself using clojure.tools.namespace.repl/refresh
instead.
For that case, you can create some facility (e.g. shortcut, snippet) for the following code:
(clojure.tools.namespace.repl/refresh :after 'formatting-stack.core/format!)
formatting-stack.core/format!
is a plain function, considered a public API, that is safe to invoke over REPL, a script, or anything you please.
If you want to add custom members to the format!
options (namely: :formatters
, or :strategies
, etc), a typical pattern would be:
(formatting-stack.core/format! :formatters (conj formatting-stack.defaults/default-formatters my-custom-formatter))
You can also pass []
for disabling a particular aspect:
;; The default :formatters will be used, no :linters will be run:
(formatting-stack.core/format! :linters [])
If you need something more fine-grained, you are encouraged to copy the contents of the formatting-stack.defaults
ns to your project, adapting things as needed.
That ns is a deliberately thin and data-only one, with the precise purpose of being forked at no cost.
We might implement an easier way to configure the stack: #38
Copyright © Nedap
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0.
Can you improve this documentation? These fine people already did:
vemv & Jeroen de JongEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close