You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/commands/fix.md
+51-5Lines changed: 51 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,56 @@ You can pass it explicitly or set it globally by running:
10
10
scala-cli config power true
11
11
:::
12
12
13
-
The `fix` command scans your project for `using` directives and extracts them into the `project.scala` file placed in the project root directory.
14
-
This allows to fix warnings tied to having `using` directives present in multiple files.
15
-
Additionally, `fix` will format the result file, thus allowing to quickly spot configuration options that may be duplicated.
13
+
The `fix` command is used to check, lint, rewrite or otherwise rearrange code in a Scala CLI project.
16
14
17
-
Files containing `using target` directives, e.g. `//> using target.scala 3.0.0` will not be changed by `fix`.
15
+
Currently, the following sets of rules are supported:
16
+
- built-in rules (enabled automatically and controlled with the `--enable-built-in` flag)
17
+
-`scalafix`, running [Scalafix](https://scalacenter.github.io/scalafix/) under the hood (enabled automatically and controlled with `--enable-scalafix` flag).
18
18
19
-
The command respects the original scope of each extracted directive and will transform them into their `test.` equivalent if needed.
19
+
You can disable unnecessary rule sets when needed.
20
+
For example, to disable built-in rules, you can run:
21
+
```bash
22
+
scala-cli fix . --power --enable-built-in=false
23
+
```
24
+
25
+
## Built-in rules
26
+
27
+
Currently, the only built-in rule is extraction of `using` directives into the `project.scala` configuration file.
28
+
This allows to fix warnings tied to having `using` directives present in multiple files and eliminate duplicate directives.
29
+
Files containing (experimental) `using target` directives, e.g. `//> using target.scala 3.0.0` will not be changed by `fix`.
30
+
The original scope (`main` or `test`) of each extracted directive is respected. `main` scope directives are transformed
31
+
them into their `test.*` equivalent when needed.
32
+
33
+
## `scalafix` integration
34
+
35
+
Scala CLI is capable of running [Scalafix](https://scalacenter.github.io/scalafix/) (a refactoring and linting tool for Scala) on your project.
36
+
Before using this command you need to provide the configuration at `.scalafix.conf`.
37
+
For example:
38
+
```text title=.scalafix.conf
39
+
// .scalafix.conf
40
+
rules = [
41
+
DisableSyntax
42
+
]
43
+
```
44
+
45
+
Then you can run it:
46
+
```bash
47
+
scala-cli fix . --power
48
+
```
49
+
50
+
If you’re setting up a continuous integration (CI) server, Scala CLI also has you covered.
Adding an [external scalafix rule](https://scalacenter.github.io/scalafix/docs/rules/external-rules.html) to Scala CLI can be done with the [`scalafix.dep`](./compile.md#compile-only-dependencies) directive:
0 commit comments