Skip to content

Commit 4c5ad32

Browse files
authoredDec 17, 2024··
Merge pull request #497 from numtide/document-missing-formatter
docs: add guide on handling unmatched formatters
2 parents 1ab9c08 + 60d91b9 commit 4c5ad32

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed
 

‎docs/content/.pages

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
nav:
22
- getting-started
3+
- guides
34
- contributing
4-
- reference
5+
- reference
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Handling Unmatched Files
2+
3+
By default, treefmt lists all files that aren't matched by any formatter:
4+
5+
```console
6+
$ treefmt
7+
WARN no formatter for path: .gitignore
8+
WARN no formatter for path: LICENSE
9+
WARN no formatter for path: README.md
10+
WARN no formatter for path: go.mod
11+
WARN no formatter for path: go.sum
12+
WARN no formatter for path: build/build.go
13+
# ...
14+
```
15+
16+
This helps you decide whether to add formatters for specific files or ignore them entirely.
17+
18+
## Customizing Notifications
19+
20+
### Reducing Log Verbosity
21+
If you find the unmatched file warnings too noisy, you can lower the logging level in your config:
22+
23+
`treefmt.toml`:
24+
```toml
25+
on-unmatched = "debug"
26+
```
27+
28+
To later find out what files are unmatched, you can override this setting via the command line:
29+
```console
30+
$ treefmt --on-unmatched warn
31+
```
32+
33+
### Enforcing Strict Matching
34+
Another stricter policy approach is to fail the run if any unmatched files are found.
35+
This can be paired with an `excludes` list to ignore specific files:
36+
37+
`treefmt.toml`:
38+
```toml
39+
# Fail if any unmatched files are found
40+
on-unmatched = "fatal"
41+
42+
# List files to explicitly ignore
43+
excludes = [
44+
"LICENCE",
45+
"go.sum",
46+
]
47+
```

0 commit comments

Comments
 (0)
Please sign in to comment.