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 yamllint #816

Merged
merged 1 commit into from
Mar 9, 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
14 changes: 8 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- name: biome
run: ( ( which biome ) || ( ( which npm && npm i -g @biomejs/biome ) ) || ( echo "Unable to install tool" ) )
- name: black
run: ( ( which black ) || ( ( which pipx && pipx install black ) ) || ( echo "Unable to install tool" ) )
run: ( ( which black ) || ( ( which brew && brew install black ) || ( which pipx && pipx install black ) ) || ( echo "Unable to install tool" ) )
- name: blade-formatter
run: ( ( which blade-formatter ) || ( ( which npm && npm i -g blade-formatter ) ) || ( echo "Unable to install tool" ) )
- name: blue
Expand All @@ -88,7 +88,7 @@ jobs:
- name: buf
run: ( ( which buf ) || ( ( which npm && npm i -g @bufbuild/buf ) || ( which brew && brew install bufbuild/buf/buf ) ) || ( echo "Unable to install tool" ) )
- name: clang-format
run: ( ( which clang-format ) || ( ( which pipx && pipx install clang-format ) ) || ( echo "Unable to install tool" ) )
run: ( ( which clang-format ) || ( ( which brew && brew install clang-format ) || ( which pipx && pipx install clang-format ) ) || ( echo "Unable to install tool" ) )
- name: css-beautify
run: ( ( which css-beautify ) || ( ( which npm && npm i -g js-beautify ) ) || ( echo "Unable to install tool" ) )
- name: csscomb
Expand All @@ -102,7 +102,7 @@ jobs:
- name: fantomas
run: ( ( which fantomas ) || ( ( which dotnet && dotnet tool install -g fantomas ) ) || ( echo "Unable to install tool" ) )
- name: fortitude
run: ( ( which fortitude ) || ( ( which pipx && pipx install fortitude-lint ) ) || ( echo "Unable to install tool" ) )
run: ( ( which fortitude ) || ( ( which brew && brew install fortitude ) || ( which pipx && pipx install fortitude-lint ) ) || ( echo "Unable to install tool" ) )
- name: fortran-linter
run: ( ( which fortran-linter ) || ( ( which brew && brew install fprettify ) || ( which pipx && pipx install fortran-linter ) ) || ( echo "Unable to install tool" ) )
- name: fprettify
Expand Down Expand Up @@ -220,11 +220,13 @@ jobs:
- name: xq
run: ( ( which xq ) || ( ( which brew && brew install xq ) || ( which apt-get && sudo apt-get install -y xq ) ) || ( echo "Unable to install tool" ) )
- name: yamlfix
run: ( ( which yamlfix ) || ( ( which pipx && pipx install yamlfix ) ) || ( echo "Unable to install tool" ) )
run: ( ( which yamlfix ) || ( ( which brew && brew install yamlfix ) || ( which pipx && pipx install yamlfix ) ) || ( echo "Unable to install tool" ) )
- name: yamlfmt
run: ( ( which yamlfmt ) || ( ( which go && go install github.com/google/yamlfmt/cmd/yamlfmt@latest ) ) || ( echo "Unable to install tool" ) )
run: ( ( which yamlfmt ) || ( ( which brew && brew install yamlfmt ) || ( which go && go install github.com/google/yamlfmt/cmd/yamlfmt@latest ) ) || ( echo "Unable to install tool" ) )
- name: yamllint
run: ( ( which yamllint ) || ( ( which brew && brew install yamllint ) || ( which pipx && pipx install yamllint ) ) || ( echo "Unable to install tool" ) )
- name: yapf
run: ( ( which yapf ) || ( ( which pipx && pipx install yapf ) ) || ( echo "Unable to install tool" ) )
run: ( ( which yapf ) || ( ( which brew && brew install yapf ) || ( which pipx && pipx install yapf ) ) || ( echo "Unable to install tool" ) )
- name: yew-fmt
run: ( ( which yew-fmt ) || ( ( which cargo && ( cargo binstall yew-fmt || cargo install yew-fmt ) ) ) || ( echo "Unable to install tool" ) )
- name: Run tests
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased](https://github.com/hougesen/mdsf/compare/v0.8.0...HEAD)

- feat: support running packages using yarn dlx [`#815`](https://github.com/hougesen/mdsf/pull/815)

#### [v0.8.0](https://github.com/hougesen/mdsf/compare/v0.7.0...v0.8.0)

> 8 March 2025
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 278 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
`mdsf` currently supports 279 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃

| Name | Description | Categories | Languages |
| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -665,6 +665,7 @@ mdsf init
| [xq](https://github.com/sibprogrammer/xq) | Command-line XML and HTML beautifier and content extractor | `formatter` | `html`, `xml` |
| [yamlfix](https://github.com/lyz-code/yamlfix) | A simple opinionated yaml formatter that keeps your comments | `formatter` | `yaml` |
| [yamlfmt](https://github.com/google/yamlfmt) | An extensible command line tool or library to format yaml files | `formatter` | `yaml` |
| [yamllint](https://github.com/adrienverge/yamllint) | A linter for YAML files | `linter` | `yaml` |
| [yapf](https://github.com/google/yapf) | A formatter for Python files | `formatter` | `python` |
| [yew-fmt](https://github.com/its-the-shrimp/yew-fmt) | Code formatter for the Yew framework | `formatter` | `rust` |
| [yq](https://github.com/mikefarah/yq) | yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor | `formatter` | `yaml` |
Expand All @@ -678,7 +679,7 @@ mdsf init

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

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

| Name | Command |
| ---------------------------- | --------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -981,6 +982,7 @@ mdsf init
| `xq` | `xq ` |
| `yamlfix` | `yamlfix $PATH` |
| `yamlfmt` | `yamlfmt -quiet $PATH` |
| `yamllint` | `yamllint $PATH` |
| `yapf` | `yapf --in-place $PATH` |
| `yew-fmt` | `yew-fmt --edition 2021 $PATH` |
| `yq` | `yq --inplace $PATH` |
Expand Down
6 changes: 5 additions & 1 deletion mdsf/src/tools/clang_tidy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pub fn set_args(
cmd
}

pub const COMMANDS: [CommandType; 1] = [CommandType::Direct("clang-tidy")];
pub const COMMANDS: [CommandType; 3] = [
CommandType::Direct("clang-tidy"),
CommandType::Uv("clang-tidy"),
CommandType::Pipx("clang-tidy"),
];

pub const IS_STDIN: bool = false;
11 changes: 11 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ pub mod xq;
pub mod xq_html;
pub mod yamlfix;
pub mod yamlfmt;
pub mod yamllint;
pub mod yapf;
pub mod yew_fmt;
pub mod yq;
Expand Down Expand Up @@ -2702,6 +2703,14 @@ pub enum Tooling {
/// `yamlfmt -quiet $PATH`
Yamlfmt,

#[serde(rename = "yamllint")]
/// A linter for YAML files
///
/// [https://github.com/adrienverge/yamllint](https://github.com/adrienverge/yamllint)
///
/// `yamllint $PATH`
Yamllint,

#[serde(rename = "yapf")]
/// A formatter for Python files
///
Expand Down Expand Up @@ -3697,6 +3706,7 @@ impl Tooling {
Self::XqHtml => (&xq_html::COMMANDS, xq_html::set_args, xq_html::IS_STDIN),
Self::Yamlfix => (&yamlfix::COMMANDS, yamlfix::set_args, yamlfix::IS_STDIN),
Self::Yamlfmt => (&yamlfmt::COMMANDS, yamlfmt::set_args, yamlfmt::IS_STDIN),
Self::Yamllint => (&yamllint::COMMANDS, yamllint::set_args, yamllint::IS_STDIN),
Self::Yapf => (&yapf::COMMANDS, yapf::set_args, yapf::IS_STDIN),
Self::YewFmt => (&yew_fmt::COMMANDS, yew_fmt::set_args, yew_fmt::IS_STDIN),
Self::Yq => (&yq::COMMANDS, yq::set_args, yq::IS_STDIN),
Expand Down Expand Up @@ -4025,6 +4035,7 @@ impl AsRef<str> for Tooling {
Self::XqHtml => "xq:html",
Self::Yamlfix => "yamlfix",
Self::Yamlfmt => "yamlfmt",
Self::Yamllint => "yamllint",
Self::Yapf => "yapf",
Self::YewFmt => "yew-fmt",
Self::Yq => "yq",
Expand Down
65 changes: 65 additions & 0 deletions mdsf/src/tools/yamllint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
///
/// 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(file_path);
cmd
}

pub const COMMANDS: [CommandType; 3] = [
CommandType::Direct("yamllint"),
CommandType::Uv("yamllint"),
CommandType::Pipx("yamllint"),
];

pub const IS_STDIN: bool = false;

#[cfg(test)]
mod test_yamllint {
#[test_with::executable(yamllint || pipx || uv)]
fn test_yamllint_yaml_e7ca97ee9ae56e12() {
let input = r#"---
name: action
on: [push]
jobs:
format:
runs-on: ubuntu-latest
steps:
- run: mdsf format .
"#;

let output = r#"---
name: action
on: [push]
jobs:
format:
runs-on: ubuntu-latest
steps:
- run: mdsf format .
"#;

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

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

let result = crate::tools::Tooling::Yamllint
.format_snippet(
snippet.path(),
crate::testing::DEFAULT_TEST_FORMATTER_TIMEOUT,
crate::testing::DEFAULT_TEST_DEBUG_ENABLED,
&crate::config::MdsfConfigRunners::all(),
)
.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 @@ -1590,6 +1590,11 @@
"type": "string",
"enum": ["yamlfmt"]
},
{
"description": "A linter for YAML files\n\n[https://github.com/adrienverge/yamllint](https://github.com/adrienverge/yamllint)\n\n`yamllint $PATH`",
"type": "string",
"enum": ["yamllint"]
},
{
"description": "A formatter for Python files\n\n[https://github.com/google/yapf](https://github.com/google/yapf)\n\n`yapf --in-place $PATH`",
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.8.0-next/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,11 @@
"type": "string",
"enum": ["yamlfmt"]
},
{
"description": "A linter for YAML files\n\n[https://github.com/adrienverge/yamllint](https://github.com/adrienverge/yamllint)\n\n`yamllint $PATH`",
"type": "string",
"enum": ["yamllint"]
},
{
"description": "A formatter for Python files\n\n[https://github.com/google/yapf](https://github.com/google/yapf)\n\n`yapf --in-place $PATH`",
"type": "string",
Expand Down
3 changes: 3 additions & 0 deletions tools/ansible-lint/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"languages": ["ansible"],
"packages": {
"apt": "ansible-lint",
"brew": {
"name": "ansible-lint"
},
"pip": "ansible-dev-tools"
}
}
3 changes: 3 additions & 0 deletions tools/autocorrect/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"homepage": "https://github.com/huacnlee/autocorrect",
"languages": [],
"packages": {
"brew": {
"name": "autocorrect"
},
"cargo": "autocorrect",
"npm": "autocorrect-node"
}
Expand Down
3 changes: 3 additions & 0 deletions tools/black/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"homepage": "https://github.com/psf/black",
"languages": ["python"],
"packages": {
"brew": {
"name": "black"
},
"pip": "black"
}
}
7 changes: 6 additions & 1 deletion tools/buildifier/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
"description": "A bazel BUILD file formatter and",
"homepage": "https://github.com/bazelbuild/buildtools",
"languages": ["bazel"],
"packages": {}
"packages": {
"brew": {
"name": "buildifier"
},
"go": "github.com/bazelbuild/buildtools/buildifier@latest"
}
}
3 changes: 3 additions & 0 deletions tools/checkmake/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"homepage": "https://github.com/mrtazz/checkmake",
"languages": ["makefile"],
"packages": {
"brew": {
"name": "checkmake"
},
"go": "github.com/mrtazz/checkmake/cmd/checkmake@latest"
}
}
3 changes: 3 additions & 0 deletions tools/clang-format/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"protobuf"
],
"packages": {
"brew": {
"name": "clang-format"
},
"pip": "clang-format"
}
}
4 changes: 3 additions & 1 deletion tools/clang-tidy/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"description": "clang-tidy is a clang-based C++ “linter” tool",
"homepage": "https://clang.llvm.org/extra/clang-tidy/",
"languages": ["c++"],
"packages": {}
"packages": {
"pip": "clang-tidy"
}
}
3 changes: 3 additions & 0 deletions tools/cmake-lint/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"homepage": "https://cmake-format.readthedocs.io/en/latest/lint-usage.html",
"languages": ["cmake"],
"packages": {
"brew": {
"name": "cmake-lint"
},
"pip": "cmakelang"
}
}
3 changes: 3 additions & 0 deletions tools/cpplint/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"languages": ["c++"],
"packages": {
"apt": "cpplint",
"brew": {
"name": "cpplint"
},
"pip": "cpplint"
}
}
3 changes: 3 additions & 0 deletions tools/djlint/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"homepage": "https://www.djlint.com/",
"languages": ["handlebars", "html", "jinja", "mustache", "nunjucks", "twig"],
"packages": {
"brew": {
"name": "djlint"
},
"pip": "djlint"
}
}
3 changes: 3 additions & 0 deletions tools/fortitude/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"homepage": "https://github.com/plasmafair/fortitude",
"languages": [],
"packages": {
"brew": {
"name": "fortitude"
},
"pip": "fortitude-lint"
}
}
3 changes: 3 additions & 0 deletions tools/yamlfix/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"homepage": "https://github.com/lyz-code/yamlfix",
"languages": ["yaml"],
"packages": {
"brew": {
"name": "yamlfix"
},
"pip": "yamlfix"
}
}
3 changes: 3 additions & 0 deletions tools/yamlfmt/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"homepage": "https://github.com/google/yamlfmt",
"languages": ["yaml"],
"packages": {
"brew": {
"name": "yamlfmt"
},
"go": "github.com/google/yamlfmt/cmd/yamlfmt@latest"
}
}
26 changes: 26 additions & 0 deletions tools/yamllint/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "../tool.schema.json",
"binary": "yamllint",
"categories": ["linter"],
"commands": {
"": {
"arguments": ["$PATH"],
"tests": [
{
"language": "yaml",
"test_input": "---\nname: action\non: [push]\njobs:\n format:\n runs-on: ubuntu-latest\n steps:\n - run: mdsf format .\n",
"test_output": "---\nname: action\non: [push]\njobs:\n format:\n runs-on: ubuntu-latest\n steps:\n - run: mdsf format .\n"
}
]
}
},
"description": "A linter for YAML files",
"homepage": "https://github.com/adrienverge/yamllint",
"languages": ["yaml"],
"packages": {
"brew": {
"name": "yamllint"
},
"pip": "yamllint"
}
}
3 changes: 3 additions & 0 deletions tools/yapf/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"homepage": "https://github.com/google/yapf",
"languages": ["python"],
"packages": {
"brew": {
"name": "yapf"
},
"pip": "yapf"
}
}
Loading