-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinting_formatters_example.clj
49 lines (43 loc) · 2.36 KB
/
linting_formatters_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
(ns linting-formatters-example
"Documents how formatters can be used as linters for a non-mutative experience.
Not a part of the test suite.
NOTE: Highly subject to change! see https://github.com/nedap/formatting-stack/pull/152
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 :refer [default-linters]]
[formatting-stack.formatters.clean-ns :as formatters.clean-ns]
[formatting-stack.formatters.cljfmt :as formatters.cljfmt]
[formatting-stack.formatters.how-to-ns :as formatters.how-to-ns]
[formatting-stack.formatters.newlines :as formatters.newlines]
[formatting-stack.formatters.no-extra-blank-lines :as formatters.no-extra-blank-lines]
[formatting-stack.formatters.trivial-ns-duplicates :as formatters.trivial-ns-duplicates]
[formatting-stack.indent-specs :refer [default-third-party-indent-specs]]
[formatting-stack.strategies :as strategies]))
(def formatters
(->> [(-> (formatters.cljfmt/new {:third-party-indent-specs default-third-party-indent-specs})
(assoc :strategies [strategies/all-files]))
(-> (formatters.how-to-ns/new {})
(assoc :strategies [strategies/all-files]))
(formatters.no-extra-blank-lines/new)
(formatters.newlines/new {})
(-> (formatters.trivial-ns-duplicates/new {})
(assoc :strategies [strategies/all-files
strategies/files-with-a-namespace
strategies/exclude-edn]))
(when (strategies/refactor-nrepl-available?)
(-> (formatters.clean-ns/new {})
(assoc :strategies [strategies/all-files
strategies/files-with-a-namespace
strategies/exclude-cljc
strategies/exclude-cljs
strategies/exclude-edn
strategies/namespaces-within-refresh-dirs-only
strategies/do-not-use-cached-results!])))]
(filterv some?)))
(comment
(formatting-stack.core/format! :linters (into default-linters formatters)
:formatters [] ;; disable all formatters
:in-background? false))