Skip to content

Commit c9eb1ed

Browse files
committed
Add scalafmt
1 parent 66b032f commit c9eb1ed

File tree

5 files changed

+160
-5
lines changed

5 files changed

+160
-5
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
3434

3535
- name: Test
36-
run: sbt ++${{ matrix.scala }} clean test "scalafixAll --check"
36+
run: sbt ++${{ matrix.scala }} clean test scalafmtCheckAll scalafmtSbtCheck "scalafixAll --check"

.scalafmt.conf

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
version = 3.3.0
2+
3+
maxColumn = 120
4+
5+
assumeStandardLibraryStripMargin = true
6+
7+
runner.dialect = scala213source3
8+
9+
indent.main = 2
10+
indent.callSite = 2
11+
indent.ctrlSite = 2
12+
indent.defnSite = 2
13+
indent.ctorSite = 2
14+
indent.caseSite = 2
15+
indent.extendSite = 4
16+
indent.withSiteRelativeToExtends = 2
17+
indent.commaSiteRelativeToExtends = 4
18+
indent.extraBeforeOpenParenDefnSite = 2
19+
20+
indentOperator.topLevelOnly = false
21+
22+
align.preset = some
23+
align.tokens = [
24+
{code = "%", owner = "Term.ApplyInfix"},
25+
{code = "%%", owner = "Term.ApplyInfix"},
26+
{code = "%%%", owner = "Term.ApplyInfix"},
27+
{code = "=>", owner = "Case"}
28+
]
29+
align.arrowEnumeratorGenerator = false
30+
align.closeParenSite = false
31+
align.openParenCallSite = false
32+
align.openParenDefnSite = false
33+
align.openParenTupleSite = true
34+
align.stripMargin = true
35+
align.multiline = false
36+
37+
newlines.source = keep
38+
newlines.topLevelStatementBlankLines = [
39+
{
40+
blanks { before = 1, after = 1 }
41+
}
42+
]
43+
newlines.beforeTemplateBodyIfBreakInParentCtors = true
44+
newlines.beforeMultiline = fold
45+
newlines.alwaysBeforeElseAfterCurlyIf = false
46+
newlines.beforeCurlyLambdaParams = never
47+
newlines.afterCurlyLambdaParams = squash
48+
newlines.implicitParamListModifierForce = [after]
49+
newlines.avoidForSimpleOverflow = [punct]
50+
newlines.avoidInResultType = true
51+
newlines.neverBeforeJsNative = true
52+
newlines.sometimesBeforeColonInMethodReturnType = false
53+
54+
danglingParentheses.defnSite = true
55+
danglingParentheses.callSite = true
56+
danglingParentheses.ctrlSite = true
57+
danglingParentheses.tupleSite = true
58+
59+
runner.optimizer.forceConfigStyleOnOffset = 60
60+
runner.optimizer.forceConfigStyleMinArgCount = 1
61+
62+
rewrite.rules = [
63+
AvoidInfix,
64+
RedundantBraces,
65+
RedundantParens,
66+
SortModifiers,
67+
PreferCurlyFors
68+
]
69+
rewrite.neverInfix.excludeFilters."+" = [
70+
# better for play-framework
71+
and, andKeep, andThen,
72+
# For scalatest
73+
in, should, shouldBe, when, must, mustEqual, mustBe, "must_==="
74+
]
75+
rewrite.redundantBraces.stringInterpolation = true
76+
rewrite.redundantBraces.generalExpressions = true
77+
rewrite.redundantBraces.ifElseExpressions = true
78+
rewrite.redundantBraces.methodBodies = true
79+
rewrite.redundantBraces.includeUnitMethods = false
80+
rewrite.redundantBraces.parensForOneLineApply = true
81+
rewrite.trailingCommas.style = never
82+
83+
verticalMultiline.atDefnSite = false
84+
verticalMultiline.newlineAfterOpenParen = true
85+
86+
spaces.beforeContextBoundColon = Never
87+
spaces.inImportCurlyBraces = false
88+
spaces.inInterpolatedStringCurlyBraces = false
89+
spaces.inParentheses = false
90+
spaces.afterKeywordBeforeParen = true
91+
spaces.inByNameTypes = true
92+
spaces.afterSymbolicDefs = false
93+
spaces.neverAroundInfixTypes = ["##"]
94+
95+
literals.long = Upper
96+
literals.float = Upper
97+
literals.double = Upper
98+
literals.hexPrefix = Lower
99+
literals.hexDigits = Lower
100+
literals.scientific = Lower
101+
102+
xmlLiterals.assumeFormatted = true
103+
104+
binPack.literalArgumentLists = true
105+
106+
includeCurlyBraceInSelectChains = true
107+
includeNoParensInSelectChains = true
108+
109+
optIn.annotationNewlines = true
110+
optIn.configStyleArguments = true
111+
optIn.breakChainOnFirstMethodDot = true
112+
optIn.breaksInsideChains = false
113+
optIn.encloseClassicChains = false
114+
optIn.forceBlankLineBeforeDocstring = true
115+
116+
rewriteTokens = {
117+
"⇒": "=>"
118+
"→": "->"
119+
"←": "<-"
120+
}
121+
122+
project.includePaths."+" = ["glob:**.md"]
123+
124+
fileOverride {
125+
"glob:**/project/**.scala" {
126+
newlines.source = unfold
127+
}
128+
"glob:**/project/Dependencies.scala" {
129+
maxColumn = 150
130+
align.preset = most
131+
align.multiline = true
132+
danglingParentheses.preset = false
133+
}
134+
"glob:**/project/DependenciesNPM.scala" {
135+
maxColumn = 150
136+
align.preset = more
137+
align.multiline = true
138+
align.tokens."+" = [
139+
{code = "->", owner = "Term.ApplyInfix"}
140+
]
141+
}
142+
"glob:**/build.sbt" {
143+
maxColumn = 80
144+
newlines.source = unfold
145+
}
146+
}

commands.sbt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
addCommandAlias("fix", "+scalafixAll")
2+
addCommandAlias("fmt", "+scalafmtAll; +demo/scalafmt; +scalafmtSbt;")
3+
addCommandAlias("format", "fix;fmt;")
24

3-
addCommandAlias("dev", "; demo/fastOptJS::stopWebpackDevServer; ~demo/fastOptJS::startWebpackDevServer")
5+
addCommandAlias(
6+
"dev",
7+
"; demo/fastOptJS::stopWebpackDevServer; ~demo/fastOptJS::startWebpackDevServer"
8+
)

project/Dependencies.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
44
object Dependencies {
55

66
object Versions {
7-
val catsCoreV = "2.7.0"
8-
val scalaCssV = "1.0.0"
9-
val scalaJsDomV = "2.1.0"
7+
val catsCoreV = "2.7.0"
8+
val scalaCssV = "1.0.0"
9+
val scalaJsDomV = "2.1.0"
1010
val scalaJsReactV = "2.0.0"
1111
}
1212

1313
import Versions._
1414

15+
// format: off
1516
//A -> Z
1617
val catsCore = Def.setting("org.typelevel" %%% "cats-core" % catsCoreV)
1718
val scalaCssCore = Def.setting("com.github.japgolly.scalacss" %%% "core" % scalaCssV)
@@ -20,4 +21,5 @@ object Dependencies {
2021
val scalaJsDom = Def.setting("org.scala-js" %%% "scalajs-dom" % scalaJsDomV)
2122
val scalaJsReactCore = Def.setting("com.github.japgolly.scalajs-react" %%% "core" % scalaJsReactV)
2223
val scalaJsReactExtra = Def.setting("com.github.japgolly.scalajs-react" %%% "extra" % scalaJsReactV)
24+
// format: on
2325
}

project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20")
1010

1111
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.33")
1212

13+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
14+
1315
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")

0 commit comments

Comments
 (0)