Skip to content

Commit

Permalink
chore: add inline to formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Mar 8, 2024
1 parent 8648d8c commit 0f5e6b5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/formatters/biome.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{execute_command, read_snippet};

#[inline]
pub fn format_using_biome(file_path: &std::path::Path) -> std::io::Result<Option<String>> {
// TODO: use installed biome instead
let mut cmd = std::process::Command::new("npx");
Expand Down Expand Up @@ -27,13 +28,13 @@ mod test_biome {

#[test]
fn it_should_format_json() {
let input = "
let input = "
{
// comments are allowed
\"key\": \"value\",
\"key\": \"value\",
\"key2\": [
\"value2\",
\"value3\",
\"value2\",
\"value3\",
1
, null]
}
Expand All @@ -58,11 +59,11 @@ mod test_biome {

#[test]
fn it_should_format_javascript() {
let input = "
let input = "
async function asyncAddition(
a,b
) {
return a+b
return a+b
}
";
Expand All @@ -84,13 +85,13 @@ mod test_biome {

#[test]
fn it_should_format_typescript() {
let input = "
let input = "
async function asyncAddition(
a:number,b:number
) :Promise<
number>
number>
{
return a+b
return a+b
}
";
Expand Down
1 change: 1 addition & 0 deletions src/formatters/nimpretty.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{execute_command, read_snippet};

#[inline]
pub fn format_using_nimpretty(file_path: &std::path::Path) -> std::io::Result<Option<String>> {
let mut cmd = std::process::Command::new("nimpretty");

Expand Down
1 change: 1 addition & 0 deletions src/formatters/ruff.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{execute_command, read_snippet};

#[inline]
pub fn format_using_ruff(file_path: &std::path::Path) -> std::io::Result<Option<String>> {
let mut cmd = std::process::Command::new("ruff");

Expand Down
7 changes: 4 additions & 3 deletions src/formatters/rustfmt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{execute_command, read_snippet};

#[inline]
pub fn format_using_rustfmt(file_path: &std::path::Path) -> std::io::Result<Option<String>> {
let mut cmd = std::process::Command::new("rustfmt");

Expand All @@ -23,9 +24,9 @@ mod test_rustfmt {

#[test]
fn it_should_format_rust() {
let input = "pub
async
fn add( a: i32,
let input = "pub
async
fn add( a: i32,
b:i32 )-> i32 {a+b}
";

Expand Down
1 change: 1 addition & 0 deletions src/formatters/stylua.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{execute_command, read_snippet};

#[inline]
pub fn format_using_stylua(file_path: &std::path::Path) -> std::io::Result<Option<String>> {
let mut cmd = std::process::Command::new("stylua");

Expand Down
3 changes: 2 additions & 1 deletion src/formatters/taplo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{execute_command, read_snippet};

#[inline]
pub fn format_using_taplo(file_path: &std::path::Path) -> std::io::Result<Option<String>> {
let mut cmd = std::process::Command::new("taplo");

Expand All @@ -23,7 +24,7 @@ mod test_taplo {
#[test]
fn it_should_format_toml() {
let input = " package = \"mdsf\"
author = \"Mads Hougesen\"
author = \"Mads Hougesen\"
";

let expected_output = "package = \"mdsf\"
Expand Down
1 change: 1 addition & 0 deletions src/formatters/zigfmt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{execute_command, read_snippet};

#[inline]
pub fn format_using_zigfmt(file_path: &std::path::Path) -> std::io::Result<Option<String>> {
let mut cmd = std::process::Command::new("zig");

Expand Down

0 comments on commit 0f5e6b5

Please sign in to comment.