How multiple formatters interact on a single file
mainWhen multiple formatters match a single file based on includes and excludes rules, treefmt follows these steps:
- Sorting: The list of applicable formatters is sorted first by
priority(lower numbers have higher precedence) and secondly by formatter name (lexicographically). - Execution:
treefmtguarantees that only one formatter will be operating on a given file at any point in time. - Batching: Files are grouped into batches based on their unique sequence of formatters. Once a batch is full, the files are passed to the formatters in the sorted sequence.
This ensures that formatting is deterministic and that priority settings correctly control the order of operations for files that match multiple formatters.