-
Notifications
You must be signed in to change notification settings - Fork 2
/
customization_example.clj
54 lines (45 loc) · 2.07 KB
/
customization_example.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(ns customization-example
"Documents how users can customize formatting-stack, as a runnable example.
Not a part of the test suite.
See also:
* https://github.com/nedap/formatting-stack/blob/master/README.md
* https://github.com/nedap/formatting-stack/wiki/FAQ"
(:require
[formatting-stack.core]
[formatting-stack.defaults]
[formatting-stack.linters.kondo :as kondo]
[formatting-stack.linters.line-length :as line-length]
[formatting-stack.linters.ns-aliases :as ns-aliases]))
;; You an implement your own linters:
(def custom-linters
[(reify formatting-stack.protocols.linter/Linter
(--lint! [this filenames]
[{:source ::my-linter
:level :warning
:column 40
:line 6
:msg "Hello, I am a sample linter!"
:filename "path.clj"}]))])
;; You can tweak the default linters' configuration:
(def tweaked-linters
(->> formatting-stack.defaults/default-linters
(keep (fn [{:keys [id] :as linter}]
;; all formatters and linters have an `:id`.
(case id
;; change :max-line-length from 130 to 80:
::line-length/id (assoc linter :max-line-length 80)
;; remove an undesired linter:
::ns-aliases/id nil
;; override some kondo defaults. They will be deep-merged against formatting-stack's kondo config:
::kondo/id (assoc linter
:kondo-clj-options {:linters {:cond-else {:level :warning}}}
;; remember there are different options, for clj and cljs.
:kondo-cljs-options {:linters {:duplicate-require {:level :warning}}})
linter)))
(vec)))
(def all-linters
(into custom-linters tweaked-linters))
(comment
(formatting-stack.core/format! :linters all-linters
:formatters [] ;; disable all formatters (as an example of how to do that)
:in-background? false))