1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::{io, path::Path, process::Command};

use crate::typescript::FormatterFn;

/// Format the specified file using [ESLint](https://eslint.org).
pub fn eslint(file: &Path) -> io::Result<()> {
    Command::new("eslint")
        .arg("--fix")
        .arg(file)
        .output()
        .map(|_| ())
        .map_err(|e| io::Error::new(io::ErrorKind::Other, e))
}

// Assert that the function signature matches the expected type.
const _: FormatterFn = eslint;

/// Format the specified file using [Prettier](https://prettier.io).
pub fn prettier(file: &Path) -> io::Result<()> {
    Command::new("prettier")
        .arg("--write")
        .arg(file)
        .output()
        .map(|_| ())
        .map_err(|e| io::Error::new(io::ErrorKind::Other, e))
}

// Assert that the function signature matches the expected type.
const _: FormatterFn = prettier;

/// Format the specified file using [Biome](https://prettier.io).
pub fn biome(file: &Path) -> io::Result<()> {
    Command::new("biome")
        .arg("format")
        .arg(file)
        .output()
        .map(|_| ())
        .map_err(|e| io::Error::new(io::ErrorKind::Other, e))
}

// Assert that the function signature matches the expected type.
const _: FormatterFn = biome;