Skip to content

Commit 0094c24

Browse files
committed
dev internal: update whitespace linter
Whitespace linter now: - works on JDK8 - is OS file-separator agnostic
1 parent 38b0fa6 commit 0094c24

File tree

4 files changed

+39
-76
lines changed

4 files changed

+39
-76
lines changed

build.clj

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
(ns build
22
(:require [clojure.edn :as edn]
33
[clojure.java.io :as io]
4-
[clojure.string :as string]
54
[clojure.tools.build.api :as b]
65
[deps-deploy.deps-deploy :as dd]
76
[whitespace-linter]))
@@ -19,18 +18,6 @@
1918
(def jar-file (format "target/%s.jar" (name lib)))
2019
(def built-jar-version-file "target/built-jar-version.txt")
2120

22-
(def windows? (string/starts-with? (System/getProperty "os.name") "Windows"))
23-
24-
(defn- localize-path [p]
25-
(if windows?
26-
(string/replace p "/" "\\")
27-
p))
28-
29-
(defn- localize-regex-path [p]
30-
(if windows?
31-
(string/replace p "/" "\\\\")
32-
p))
33-
3421
(defn jar
3522
"Build library jar file.
3623
Also writes built version to target/built-jar-version.txt for easy peasy pickup by any interested downstream operation.
@@ -89,40 +76,38 @@
8976
(println lib))
9077

9178
(defn lint-whitespace
92-
"Wrap camsaul's whitespace-linter to handle OS specific file separator"
79+
"Use camsaul's whitespace-linter"
9380
[_]
94-
(whitespace-linter/lint {:paths (->> [".clj-kondo/config.edn"
95-
".codecov.yml"
96-
".github"
97-
".gitignore"
98-
"CHANGELOG.adoc"
99-
"CODE_OF_CONDUCT.md"
100-
"CONTRIBUTING.md"
101-
"LICENSE"
102-
"ORIGINATOR"
103-
"README.adoc"
104-
"bb.edn"
105-
"build.clj"
106-
"deps.edn"
107-
"doc"
108-
"fig.cljs.edn"
109-
"package.json"
110-
"pom.xml"
111-
"resources"
112-
"script"
113-
"src"
114-
"template"
115-
"test"
116-
"test-isolated"
117-
"tests.edn"
118-
"version.edn"]
119-
(mapv localize-path))
120-
:include-patterns ["\\.clj.?$" "\\.edn$" "\\.yaml$" "\\.adoc$" "\\.md$"
121-
"CODEOWNERS$" "LICENSE$" "ORIGINATOR$"
122-
".clj-kondo.config.edn"]
123-
:exclude-patterns (->> [;; exclude things generated
124-
"doc/generated/.*$"
125-
"src/rewrite_clj/(node|zip)\\.cljc$"
126-
"src/rewrite_clj/node/string\\.clj$"
127-
"src/rewrite_clj/zip/(edit|find|remove|seq)\\.clj"]
128-
(mapv localize-regex-path))}))
81+
(whitespace-linter/lint {:paths [".clj-kondo/config.edn"
82+
".codecov.yml"
83+
".github/"
84+
".gitignore"
85+
"CHANGELOG.adoc"
86+
"CODE_OF_CONDUCT.md"
87+
"CONTRIBUTING.md"
88+
"LICENSE"
89+
"ORIGINATOR"
90+
"README.adoc"
91+
"bb.edn"
92+
"build.clj"
93+
"deps.edn"
94+
"doc/"
95+
"fig.cljs.edn"
96+
"package.json"
97+
"pom.xml"
98+
"resources/"
99+
"script/"
100+
"src/"
101+
"template/"
102+
"test/"
103+
"test-isolated/"
104+
"tests.edn"
105+
"version.edn"]
106+
:include-patterns [#"\.clj.?$" #"\.edn$" #"\.yaml$" #"\.adoc$" #"\.md$"
107+
#"CODEOWNERS$" #"LICENSE$" #"ORIGINATOR$"
108+
#"\.clj-kondo/config.edn"]
109+
:exclude-patterns [;; exclude things generated
110+
#"doc/generated/.*$"
111+
#"src/rewrite_clj/(node|zip)\.cljc$"
112+
#"src/rewrite_clj/node/string\.clj$"
113+
#"src/rewrite_clj/zip/(edit|find|remove|seq)\.clj"]}))

deps.edn

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
;; document block testing
4444
:test-doc-blocks {:replace-deps {org.clojure/clojure {:mvn/version "1.10.3"}
45-
com.github.lread/test-doc-blocks {:mvn/version "1.0.146-alpha"}}
45+
com.github.lread/test-doc-blocks {:mvn/version "1.0.146-alpha"}}
4646
:replace-paths []
4747
:ns-default lread.test-doc-blocks
4848
:exec-args {:docs ["doc/01-user-guide.adoc"
@@ -123,7 +123,8 @@
123123
;;
124124
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.6.3" :git/sha "4a1b53a"}
125125
io.github.slipset/deps-deploy {:sha "9b8db1f57722d19cf92de57ac7db28d71a915bcf"}
126-
io.github.camsaul/whitespace-linter {:sha "942b34e117c5cb7667abfdb8d3f2449f27e46f57"}}
126+
;; TODO: switch back to io.github.camsaul after https://github.com/camsaul/whitespace-linter/pull/8 merged
127+
io.github.lread/whitespace-linter {:sha "a5b5561ce4d199db54917390695449d9c59c38b6"}}
127128
:ns-default build}
128129

129130
;;

script/helper/jdk.clj

Lines changed: 0 additions & 19 deletions
This file was deleted.

script/lint_whitespace.clj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
#!/usr/bin/env bb
22

33
(ns lint-whitespace
4-
(:require [helper.jdk :as jdk]
5-
[helper.main :as main]
4+
(:require [helper.main :as main]
65
[helper.shell :as shell]
76
[lread.status-line :as status]))
87

98
(defn- lint []
109
(status/line :head "whitespace: linting")
11-
(let [jdk-version (jdk/version)]
12-
(if (< (:major jdk-version) 11)
13-
(status/line :warn "Skipping linting, min of JDK 11 required, detected JDK %s" (:version jdk-version))
14-
(shell/command "clojure -T:build lint-whitespace"))))
10+
(shell/command "clojure -T:build lint-whitespace"))
1511

1612
(defn -main [& args]
1713
(when (main/doc-arg-opt args)

0 commit comments

Comments
 (0)