-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add :extra-configs option, pull in additional :extra-indents
Allows pulling in :extra-indents from other configs. extra-configs are respected in order listed, so later configs overwrite earlier ones. :extra-indents in the base config override everything, allowing users to overrule indents pulled in that they don't agree with. :extra-configs file paths are expected to be relative to the base config.
- Loading branch information
Showing
10 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ pom.xml.asc | |
.nrepl-port | ||
reports | ||
.cpcache | ||
.clj-kondo | ||
.lsp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
(ns cljfmt.config-test | ||
(:require [cljfmt.config :as config] | ||
[clojure.test :refer [deftest is]])) | ||
[clojure.test :refer [deftest is testing]] | ||
[clojure.java.io :as io]) | ||
(:import (java.io File))) | ||
|
||
(deftest test-convert-legacy-keys | ||
(is (= {:indents {'foo [[:inner 0]]}} | ||
(config/convert-legacy-keys {:indents {'foo [[:inner 0]]}}))) | ||
(is (= {:extra-indents {'foo [[:inner 0]]}} | ||
(config/convert-legacy-keys {:legacy/merge-indents? true | ||
:indents {'foo [[:inner 0]]}})))) | ||
|
||
(deftest test-load-config-extra-configs | ||
(testing "`:extra-configs` allows you to import `:extra-indents`" | ||
(is (= (config/load-config (io/resource "empty-cljfmt.edn")) | ||
(-> (config/load-config (io/resource "cljfmt.edn")) | ||
(dissoc :extra-configs) | ||
(assoc :extra-indents {}))) | ||
"should only differ by `:extra-indents` (via `:extra-configs`). All other keys are ignored.") | ||
(is (= '{;; exists only in base config `test_resources/cljfmt.edn` | ||
com.unrelated/a [[:inner 0]] | ||
com.foo/a [[:inner 0]], | ||
;; exists only in `test_resources/extra1-cljfmt.edn` | ||
com.foo/b [[:inner 1]], | ||
;; overwritten in `test_resources/extra2-cljfmt.edn` | ||
com.foo/c [[:inner 2]], | ||
com.foo/d [[:inner 2]], | ||
;; exists only in `test_resources/extra2-cljfmt.edn` | ||
com.foo/e [[:inner 2]]} | ||
(:extra-indents (config/load-config (io/resource "cljfmt.edn")))) | ||
"should respect :extra-configs in order (later is higher-prio), with base highest prio."))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{:extra-indents {com.foo/a [[:inner 0]] | ||
com.unrelated/a [[:inner 0]]} | ||
:extra-configs ["extra1-cljfmt.edn" | ||
"extra2-cljfmt.edn"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{:parallel? true | ||
:paths ["x"] | ||
:sort-ns-references? true | ||
:extra-indents {;; exists in base | ||
com.foo/a [[:inner 1]] | ||
;; not included in later config | ||
com.foo/b [[:inner 1]] | ||
;; overridden in later configs | ||
com.foo/c [[:inner 1]] | ||
com.foo/d [[:inner 1]]} | ||
:extra-configs []} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{:parallel? false | ||
:paths ["y"] | ||
:sort-ns-references? false | ||
:extra-indents {com.foo/c [[:inner 2]] | ||
com.foo/d [[:inner 2]] | ||
com.foo/e [[:inner 2]]} | ||
:extra-configs []} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{:extra-configs ["config.edn"]} |