Skip to content

Commit

Permalink
feat: add support for salt-lint (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jan 12, 2025
1 parent 447dccf commit 02a85f0
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

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

- feat: add support for salt-lint [`#601`](https://github.com/hougesen/mdsf/pull/601)
- feat: add support for regal [`#600`](https://github.com/hougesen/mdsf/pull/600)
- feat: add support for quick-lint-js [`#599`](https://github.com/hougesen/mdsf/pull/599)
- feat: add support for oelint-adv [`#598`](https://github.com/hougesen/mdsf/pull/598)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ mdsf init
<!-- START_SECTION:supported-tools -->

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

| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
Expand Down Expand Up @@ -395,6 +395,7 @@ mdsf init
| [rune](https://github.com/rune-rs/rune) | Tools for the Rune programming language | `formatter` | `rune` |
| [rustfmt](https://github.com/rust-lang/rustfmt) | The official code formatter for Rust | `formatter` | `rust` |
| [rustywind](https://github.com/avencera/rustywind) | CLI for organizing Tailwind CSS classes | `formatter` | `html` |
| [salt-lint](https://github.com/warpnet/salt-lint) | A command-line utility that checks for best practices in SaltStack | `linter` | `salt` |
| [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` |
| [shellharden](https://github.com/anordal/shellharden) | The corrective bash syntax highlighter | `linter` | `bash`, `shell` |
Expand Down
7 changes: 7 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ pub mod rufo;
pub mod rune_fmt;
pub mod rustfmt;
pub mod rustywind;
pub mod salt_lint;
pub mod scalafmt;
pub mod scalariform;
pub mod shellharden;
Expand Down Expand Up @@ -990,6 +991,10 @@ pub enum Tooling {
/// `rustywind --write $PATH`
Rustywind,

#[serde(rename = "salt-lint")]
/// `salt-lint $PATH`
SaltLint,

#[serde(rename = "scalafmt")]
/// `scalafmt --quiet --mode any $PATH`
Scalafmt,
Expand Down Expand Up @@ -1413,6 +1418,7 @@ impl Tooling {
Self::RuneFmt => rune_fmt::run(snippet_path),
Self::Rustfmt => rustfmt::run(snippet_path),
Self::Rustywind => rustywind::run(snippet_path),
Self::SaltLint => salt_lint::run(snippet_path),
Self::Scalafmt => scalafmt::run(snippet_path),
Self::Scalariform => scalariform::run(snippet_path),
Self::Shellharden => shellharden::run(snippet_path),
Expand Down Expand Up @@ -1665,6 +1671,7 @@ impl AsRef<str> for Tooling {
Self::RuneFmt => "rune_fmt",
Self::Rustfmt => "rustfmt",
Self::Rustywind => "rustywind",
Self::SaltLint => "salt_lint",
Self::Scalafmt => "scalafmt",
Self::Scalariform => "scalariform",
Self::Shellharden => "shellharden",
Expand Down
34 changes: 34 additions & 0 deletions mdsf/src/tools/salt_lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::process::Command;

use crate::{error::MdsfError, execution::execute_command, runners::CommandType};

#[inline]
fn set_salt_lint_args(mut cmd: Command, file_path: &std::path::Path) -> Command {
cmd.arg(file_path);
cmd
}

#[inline]
pub fn run(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let commands = [CommandType::Direct("salt-lint")];

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_salt_lint_args(cmd.build(), file_path);
let execution_result = execute_command(cmd, file_path);

if index == commands.len() - 1 {
return execution_result;
}

if let Ok(r) = execution_result {
if !r.0 {
return Ok(r);
}
}
}

Ok((true, None))
}

#[cfg(test)]
mod test_salt_lint {}
5 changes: 5 additions & 0 deletions schemas/v0.3.3-dev/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,11 @@
"type": "string",
"enum": ["rustywind"]
},
{
"description": "`salt-lint $PATH`",
"type": "string",
"enum": ["salt-lint"]
},
{
"description": "`scalafmt --quiet --mode any $PATH`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/salt-lint/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "salt-lint",
"categories": ["linter"],
"commands": {
"": ["$PATH"]
},
"description": "A command-line utility that checks for best practices in SaltStack",
"homepage": "https://github.com/warpnet/salt-lint",
"languages": ["salt"],
"name": null,
"npm": null,
"php": null,
"tests": []
}

0 comments on commit 02a85f0

Please sign in to comment.