Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tools): add support for semistandard #790

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ jobs:
run: ( ( which xmllint ) || ( ( which apt-get && sudo apt-get install -y libxml2-utils ) ) || ( echo "Unable to install tool" ) )
- name: pycln
run: ( ( which pycln ) || ( ( which pipx && pipx install pycln ) ) || ( echo "Unable to install tool" ) )
- name: semistandard
run: ( ( which semistandard ) || ( ( which npm && npm i -g semistandard ) ) || ( echo "Unable to install tool" ) )
- name: dotnet
run: ( ( which csharpier ) || ( ( which dotnet && dotnet tool install -g csharpier ) ) || ( echo "Unable to install tool" ) )
- name: black
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ mdsf init

<!-- START_SECTION:supported-tools -->

`mdsf` currently supports 275 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
`mdsf` currently supports 276 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃

| Name | Description | Categories | Languages |
| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -604,6 +604,7 @@ mdsf init
| [scalafmt](https://github.com/scalameta/scalafmt) | Code formatter for Scala | `formatter` | `scala` |
| [scalariform](https://github.com/scala-ide/scalariform) | Scala source code formatter | `formatter` | `scala` |
| [selene](https://github.com/kampfkarren/selene) | A blazing-fast modern Lua linter written in Rust | `linter` | `lua` |
| [semistandard](https://github.com/standard/semistandard) | All the goodness of standardjs with semicolons sprinkled on top | `formatter`, `linter` | `javascript` |
| [shellcheck](https://github.com/koalaman/shellcheck) | ShellCheck, a static analysis tool for shell scripts | `linter` | `bash`, `shell` |
| [shellharden](https://github.com/anordal/shellharden) | The corrective bash syntax highlighter | `linter` | `bash`, `shell` |
| [shfmt](https://github.com/mvdan/sh) | Shell script formatter | `formatter` | `shell` |
Expand Down Expand Up @@ -675,7 +676,7 @@ mdsf init

<!-- START_SECTION:supported-commands -->

`mdsf` currently supports 300 commands. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
`mdsf` currently supports 301 commands. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃

| Name | Command |
| ------------------------ | --------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -909,6 +910,7 @@ mdsf init
| `scalafmt` | `scalafmt --quiet --mode any $PATH` |
| `scalariform` | `scalariform $PATH` |
| `selene` | `selene $PATH` |
| `semistandard` | `semistandard --fix --stdin` |
| `shellcheck` | `shellcheck $PATH` |
| `shellharden` | `shellharden --transform --replace $PATH` |
| `shfmt` | `shfmt --write $PATH` |
Expand Down
15 changes: 15 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ pub mod salt_lint;
pub mod scalafmt;
pub mod scalariform;
pub mod selene;
pub mod semistandard;
pub mod shellcheck;
pub mod shellharden;
pub mod shfmt;
Expand Down Expand Up @@ -2145,6 +2146,14 @@ pub enum Tooling {
/// `selene $PATH`
Selene,

#[serde(rename = "semistandard")]
/// All the goodness of standardjs with semicolons sprinkled on top
///
/// [https://github.com/standard/semistandard](https://github.com/standard/semistandard)
///
/// `semistandard --fix --stdin`
Semistandard,

#[serde(rename = "shellcheck")]
/// ShellCheck, a static analysis tool for shell scripts
///
Expand Down Expand Up @@ -3439,6 +3448,11 @@ impl Tooling {
scalariform::IS_STDIN,
),
Self::Selene => (&selene::COMMANDS, selene::set_args, selene::IS_STDIN),
Self::Semistandard => (
&semistandard::COMMANDS,
semistandard::set_args,
semistandard::IS_STDIN,
),
Self::Shellcheck => (
&shellcheck::COMMANDS,
shellcheck::set_args,
Expand Down Expand Up @@ -3886,6 +3900,7 @@ impl AsRef<str> for Tooling {
Self::Scalafmt => "scalafmt",
Self::Scalariform => "scalariform",
Self::Selene => "selene",
Self::Semistandard => "semistandard",
Self::Shellcheck => "shellcheck",
Self::Shellharden => "shellharden",
Self::Shfmt => "shfmt",
Expand Down
61 changes: 61 additions & 0 deletions mdsf/src/tools/semistandard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
///
/// THIS FILE IS GENERATED USING CODE - DO NOT EDIT MANUALLY
///
use crate::runners::CommandType;

#[inline]
pub fn set_args(
mut cmd: std::process::Command,
_file_path: &std::path::Path,
) -> std::process::Command {
cmd.arg("--fix");
cmd.arg("--stdin");
cmd
}

pub const COMMANDS: [CommandType; 3] = [
CommandType::NodeModules("semistandard"),
CommandType::Direct("semistandard"),
CommandType::Npm("semistandard"),
];

pub const IS_STDIN: bool = true;

#[cfg(test)]
mod test_semistandard {
#[test_with::executable(npx)]
fn test_semistandard_javascript_dd13bf6b8d6e09a1() {
let input = r#" async function asyncAddition(a,b )
{
return a+b
}

console.info(asyncAddition(1, 2));
"#;

let output = r#"async function asyncAddition (a, b) {
return a + b;
}

console.info(asyncAddition(1, 2));
"#;

let file_ext = crate::fttype::get_file_extension("javascript");

let snippet =
crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");

let result = crate::tools::Tooling::Semistandard
.format_snippet(
snippet.path(),
crate::testing::DEFAULT_TEST_FORMATTER_TIMEOUT,
crate::testing::DEFAULT_TEST_DEBUG_ENABLED,
crate::runners::JavaScriptRuntime::default(),
)
.expect("it to be successful")
.1
.expect("it to be some");

assert_eq!(result, output);
}
}
5 changes: 5 additions & 0 deletions schemas/development/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,11 @@
"type": "string",
"enum": ["selene"]
},
{
"description": "All the goodness of standardjs with semicolons sprinkled on top\n\n[https://github.com/standard/semistandard](https://github.com/standard/semistandard)\n\n`semistandard --fix --stdin`",
"type": "string",
"enum": ["semistandard"]
},
{
"description": "ShellCheck, a static analysis tool for shell scripts\n\n[https://github.com/koalaman/shellcheck](https://github.com/koalaman/shellcheck)\n\n`shellcheck $PATH`",
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.7.0-next/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,11 @@
"type": "string",
"enum": ["selene"]
},
{
"description": "All the goodness of standardjs with semicolons sprinkled on top\n\n[https://github.com/standard/semistandard](https://github.com/standard/semistandard)\n\n`semistandard --fix --stdin`",
"type": "string",
"enum": ["semistandard"]
},
{
"description": "ShellCheck, a static analysis tool for shell scripts\n\n[https://github.com/koalaman/shellcheck](https://github.com/koalaman/shellcheck)\n\n`shellcheck $PATH`",
"type": "string",
Expand Down
24 changes: 24 additions & 0 deletions tools/semistandard/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "../tool.schema.json",
"binary": "semistandard",
"categories": ["formatter", "linter"],
"commands": {
"": {
"arguments": ["--fix", "--stdin"],
"stdin": true,
"tests": [
{
"language": "javascript",
"test_input": " async function asyncAddition(a,b )\n {\n return a+b\n }\n\nconsole.info(asyncAddition(1, 2));\n ",
"test_output": "async function asyncAddition (a, b) {\n return a + b;\n}\n\nconsole.info(asyncAddition(1, 2));\n"
}
]
}
},
"description": "All the goodness of standardjs with semicolons sprinkled on top",
"homepage": "https://github.com/standard/semistandard",
"languages": ["javascript"],
"packages": {
"npm": "semistandard"
}
}
Loading