Skip to content

Commit

Permalink
Dump scalafmt to 3.5.9 in tests and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Aug 16, 2022
1 parent a0cfbee commit fd0e808
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
@@ -1,4 +1,4 @@
version = "3.5.8"
version = "3.5.9"

align.preset = more
maxColumn = 100
Expand Down
Expand Up @@ -50,13 +50,13 @@ class FmtTests extends ScalaCliSuite {
)

val simpleInputsWithVersionOnly: TestInputs = TestInputs(
os.rel / confFileName -> "version = \"3.5.5\"".stripMargin,
os.rel / confFileName -> "version = \"3.5.9\"".stripMargin,
os.rel / "Foo.scala" -> simpleInputsUnformattedContent
)

val simpleInputsWithCustomConfLocation: TestInputs = TestInputs(
os.rel / "custom.conf" ->
s"""|version = "3.5.5"
s"""|version = "3.5.9"
|runner.dialect = scala213
|""".stripMargin,
os.rel / "Foo.scala" -> simpleInputsUnformattedContent
Expand Down Expand Up @@ -138,11 +138,11 @@ class FmtTests extends ScalaCliSuite {

test("--scalafmt-version") {
simpleInputs.fromRoot { root =>
os.proc(TestUtil.cli, "fmt", ".", "--scalafmt-version", "3.5.5").call(cwd = root)
os.proc(TestUtil.cli, "fmt", ".", "--scalafmt-version", "3.5.9").call(cwd = root)
val confLines = os.read.lines(root / Constants.workspaceDirName / confFileName)
val versionInConf = confLines(0).stripPrefix("version = ").trim
val updatedContent = noCrLf(os.read(root / "Foo.scala"))
expect(versionInConf == "\"3.5.5\"")
expect(versionInConf == "\"3.5.9\"")
expect(updatedContent == expectedSimpleInputsFormattedContent)
}
}
Expand All @@ -154,7 +154,7 @@ class FmtTests extends ScalaCliSuite {
val versionInConf = confLines(0).stripPrefix("version = ").trim
val dialectInConf = confLines(1).stripPrefix("runner.dialect = ").trim
val updatedContent = noCrLf(os.read(root / "Foo.scala"))
expect(versionInConf == "\"3.5.5\"")
expect(versionInConf == "\"3.5.9\"")
expect(dialectInConf == "scala213")
expect(updatedContent == expectedSimpleInputsFormattedContent)
}
Expand All @@ -163,13 +163,13 @@ class FmtTests extends ScalaCliSuite {
test("--scalafmt-conf-str") {
simpleInputsWithVersionOnly.fromRoot { root =>
val confStr =
s"""version = 3.5.7${System.lineSeparator}runner.dialect = scala213${System.lineSeparator}"""
s"""version = 3.5.9${System.lineSeparator}runner.dialect = scala213${System.lineSeparator}"""
os.proc(TestUtil.cli, "fmt", ".", "--scalafmt-conf-str", s"$confStr").call(cwd = root)
val confLines = os.read.lines(root / Constants.workspaceDirName / confFileName)
val versionInConf = confLines(0).stripPrefix("version = ")
val dialectInConf = confLines(1).stripPrefix("runner.dialect = ")
val updatedContent = noCrLf(os.read(root / "Foo.scala"))
expect(versionInConf == "\"3.5.7\"")
expect(versionInConf == "\"3.5.9\"")
expect(dialectInConf == "scala213")
expect(updatedContent == expectedSimpleInputsFormattedContent)
}
Expand Down
16 changes: 8 additions & 8 deletions website/docs/commands/fmt.md
Expand Up @@ -24,7 +24,7 @@ scala-cli fmt --check

Scala CLI `fmt` command supports passing the `scalafmt` **version** and **dialect** directly from the command line, using the `--scalafmt-dialect` and `--scalafmt-version` options respectively:
```
scala-cli fmt --scalafmt-dialect scala3 --scalafmt-version 3.5.8
scala-cli fmt --scalafmt-dialect scala3 --scalafmt-version 3.5.9
```
You can skip passing either of those, which will make Scala CLI infer a default value:
- If a `.scalafmt.conf` file is present in the workspace and it has the field defined, the value will be read from there, unless explicitly specified with Scala CLI options.
Expand All @@ -35,7 +35,7 @@ It is possible to pass the configuration as a string directly from the command l
#### Example 1

``` text title=.scalafmt.conf
version = "3.5.8"
version = "3.5.9"
runner.dialect = scala212
```

Expand All @@ -44,7 +44,7 @@ scala-cli fmt --scalafmt-dialect scala213
```

For the setup above, `fmt` will use:
- `version="3.5.8"` from the file
- `version="3.5.9"` from the file
- `dialect=scala213`, because passed `--scalafmt-dialect` option overrides dialect found in the file

#### Example 2
Expand All @@ -54,11 +54,11 @@ version = "2.7.5"
```

```bash
scala-cli fmt --scalafmt-version 3.5.8
scala-cli fmt --scalafmt-version 3.5.9
```

For the setup above, `fmt` will use:
- `version="3.5.8"`, because passed `--scalafmt-version` option overrides version from the file
- `version="3.5.9"`, because passed `--scalafmt-version` option overrides version from the file
- `dialect=scala3`, because dialect is neither passed as an option nor is it present in the configuration file, so it is inferred based on the Scala version; the Scala version wasn't explicitly specified in the command either, so it falls back to the default Scala version - the latest one, thus the resulting dialect is `scala3`.

### Scalafmt options
Expand All @@ -72,7 +72,7 @@ scala-cli fmt -F --version
```

```text
scalafmt 3.5.8
scalafmt 3.5.9
```

</ChainedSnippets>
Expand All @@ -87,7 +87,7 @@ scala-cli fmt --scalafmt-help
```

```text
scalafmt 3.5.8
scalafmt 3.5.9
Usage: scalafmt [options] [<file>...]
-h, --help prints this usage text
Expand All @@ -105,7 +105,7 @@ would be ignored. In order to prevent that from happening, the `--respect-projec
default.

```text title=.scalafmt.conf
version = "3.5.8"
version = "3.5.9"
runner.dialect = scala3
project {
includePaths = [
Expand Down
2 changes: 1 addition & 1 deletion website/docs/release_notes.md
Expand Up @@ -12,7 +12,7 @@ Scala CLI can now run the `fmt` command without a `.scalafmt.conf` file present.

The Scala CLI `fmt` command now supports passing the `scalafmt` version and dialect directly from the command line, using the `--scalafmt-dialect` and `--scalafmt-version` options respectively:
```
scala-cli fmt --scalafmt-dialect scala3 --scalafmt-version 3.5.8
scala-cli fmt --scalafmt-dialect scala3 --scalafmt-version 3.5.9
```
Either of those (or both) can be skipped, which will make Scala CLI infer a default value.

Expand Down

0 comments on commit fd0e808

Please sign in to comment.