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
An optional list of [glob patterns](#glob-patterns-format) used to exclude files from all formatters.
@@ -450,6 +474,11 @@ command = "deadnix"
450
474
options = ["-e"]
451
475
includes = ["*.nix"]
452
476
priority = 2
477
+
478
+
[formatter.shfmt]
479
+
command = "shfmt"
480
+
options = ["-i", "2", "-w"]
481
+
allowed-mimetypes = ["text/x-shellscript"]
453
482
```
454
483
455
484
### `command`
@@ -462,19 +491,27 @@ An optional list of args to be passed to `command`.
462
491
463
492
### `includes`
464
493
465
-
A list of [glob patterns](#glob-patterns-format) used to determine whether the formatter should be applied against a given path.
494
+
An optional list of [glob patterns](#glob-patterns-format) used to determine whether the formatter should be applied against a given path.
466
495
467
496
### `excludes`
468
497
469
498
An optional list of [glob patterns](#glob-patterns-format) used to exclude certain files from this formatter.
470
499
500
+
### `allowed-mimetypes`
501
+
502
+
An optional list of [MIME types][] used to determine whether the formatter should be applied against a given path.
503
+
504
+
### `disallowed-mimetypes`
505
+
506
+
An optional list of [MIME types][] used to exclude certain files from this formatter.
507
+
471
508
### `priority`
472
509
473
510
Influences the order of execution. Greater precedence is given to lower numbers, with the default being `0`.
474
511
475
512
## Same file, multiple formatters?
476
513
477
-
For each file, `treefmt` determines a list of formatters based on the configured `includes` / `excludes` rules. This list is
514
+
For each file, `treefmt` determines a list of formatters based on the configured `includes` / `excludes`and `allowed-mimetypes` / `disallowed-mimetypes`rules. This list is
478
515
then sorted, first by priority (lower the value, higher the precedence) and secondly by formatter name (lexicographically).
479
516
480
517
The resultant sequence of formatters is used to create a batch key, and similarly matched files get added to that batch
@@ -486,6 +523,10 @@ Another consequence is that formatting is deterministic for a given file and a g
486
523
By setting the priority fields appropriately, you can control the order in which those formatters are applied for any
487
524
files they _both happen to match on_.
488
525
526
+
## Required settings
527
+
528
+
Each formatter must have at least one entry in the `includes` list **or** the `allowed-mimetypes` list. This is the minimal requirement for `treefmt` to identify which files are subject to a given formatter.
529
+
489
530
## Glob patterns format
490
531
491
532
This is a variant of the Unix glob pattern. It supports all the usual
0 commit comments