-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from numtide/document-missing-formatter
docs: add guide on handling unmatched formatters
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
nav: | ||
- getting-started | ||
- guides | ||
- contributing | ||
- reference | ||
- reference |
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,47 @@ | ||
# Handling Unmatched Files | ||
|
||
By default, treefmt lists all files that aren't matched by any formatter: | ||
|
||
```console | ||
$ treefmt | ||
WARN no formatter for path: .gitignore | ||
WARN no formatter for path: LICENSE | ||
WARN no formatter for path: README.md | ||
WARN no formatter for path: go.mod | ||
WARN no formatter for path: go.sum | ||
WARN no formatter for path: build/build.go | ||
# ... | ||
``` | ||
|
||
This helps you decide whether to add formatters for specific files or ignore them entirely. | ||
|
||
## Customizing Notifications | ||
|
||
### Reducing Log Verbosity | ||
If you find the unmatched file warnings too noisy, you can lower the logging level in your config: | ||
|
||
`treefmt.toml`: | ||
```toml | ||
on-unmatched = "debug" | ||
``` | ||
|
||
To later find out what files are unmatched, you can override this setting via the command line: | ||
```console | ||
$ treefmt --on-unmatched warn | ||
``` | ||
|
||
### Enforcing Strict Matching | ||
Another stricter policy approach is to fail the run if any unmatched files are found. | ||
This can be paired with an `excludes` list to ignore specific files: | ||
|
||
`treefmt.toml`: | ||
```toml | ||
# Fail if any unmatched files are found | ||
on-unmatched = "fatal" | ||
|
||
# List files to explicitly ignore | ||
excludes = [ | ||
"LICENCE", | ||
"go.sum", | ||
] | ||
``` |