Skip to content

Commit

Permalink
feat: add support for curlylint
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Jan 12, 2025
1 parent 54975e9 commit b4202ad
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
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 curlylint [`#591`](https://github.com/hougesen/mdsf/pull/591)
- feat: add support for toml-sort [`#590`](https://github.com/hougesen/mdsf/pull/590)
- feat: add support for statix [`#589`](https://github.com/hougesen/mdsf/pull/589)
- feat: add support for odinfmt [`#588`](https://github.com/hougesen/mdsf/pull/588)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mdsf

Format markdown code snippets using your favorite code formatters.
Format, and lint, markdown code snippets using your favorite code tools.

<a href="https://crates.io/crates/mdsf"><img src="https://img.shields.io/crates/v/mdsf.svg"></a>
<a href="https://github.com/hougesen/mdsf/actions/workflows/validate.yml"><img src="https://github.com/hougesen/mdsf/actions/workflows/validate.yml/badge.svg"></a>
Expand Down Expand Up @@ -214,7 +214,7 @@ mdsf init
<!-- START_SECTION:supported-tools -->

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

| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
Expand Down Expand Up @@ -259,6 +259,7 @@ mdsf init
| [csharpier](https://csharpier.com/) | An Opinionated Code Formatter for C# | `formatter` | `c#` |
| [css-beautify](https://github.com/beautifier/js-beautify?tab=readme-ov-file#css--html) | A css formatter | `formatter` | `css` |
| [csscomb](https://github.com/csscomb/csscomb.js) | CSS coding style formatter | `formatter` | `css` |
| [curlylint](https://github.com/thibaudcolas/curlylint) | Experimental HTML templates linting for Jinja, Nunjucks, Django templates, Twig, Liquid | `linter` | `django`, `jinja`, `liquid`, `nunjucks`, `twig` |
| [d2](https://d2lang.com/) | Formatter for the d2 language | `formatter` | `d2` |
| [dart](https://dart.dev/tools) | Formatter and linter for Dart | `formatter`, `linter` | `dart`, `flutter` |
| [dcm](https://dcm.dev/) | Code Quality Tool for Flutter Developers | `formatter`, `linter` | `dart`, `flutter` |
Expand Down
35 changes: 35 additions & 0 deletions mdsf/src/tools/curlylint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::process::Command;

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

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

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

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_curlylint_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_curlylint {}
7 changes: 7 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub mod crystal_format;
pub mod csharpier;
pub mod css_beautify;
pub mod csscomb;
pub mod curlylint;
pub mod d_2_fmt;
pub mod dart_fix;
pub mod dart_format;
Expand Down Expand Up @@ -407,6 +408,10 @@ pub enum Tooling {
/// `csscomb -t $PATH`
Csscomb,

#[serde(rename = "curlylint")]
/// `curlylint -q $PATH`
Curlylint,

#[serde(rename = "d2:fmt")]
/// `d2 fmt $PATH`
D2Fmt,
Expand Down Expand Up @@ -1215,6 +1220,7 @@ impl Tooling {
Self::Csharpier => csharpier::run(snippet_path),
Self::CssBeautify => css_beautify::run(snippet_path),
Self::Csscomb => csscomb::run(snippet_path),
Self::Curlylint => curlylint::run(snippet_path),
Self::D2Fmt => d_2_fmt::run(snippet_path),
Self::DartFix => dart_fix::run(snippet_path),
Self::DartFormat => dart_format::run(snippet_path),
Expand Down Expand Up @@ -1456,6 +1462,7 @@ impl AsRef<str> for Tooling {
Self::Csharpier => "csharpier",
Self::CssBeautify => "css_beautify",
Self::Csscomb => "csscomb",
Self::Curlylint => "curlylint",
Self::D2Fmt => "d_2_fmt",
Self::DartFix => "dart_fix",
Self::DartFormat => "dart_format",
Expand Down
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 @@ -273,6 +273,11 @@
"type": "string",
"enum": ["csscomb"]
},
{
"description": "`curlylint -q $PATH`",
"type": "string",
"enum": ["curlylint"]
},
{
"description": "`d2 fmt $PATH`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/curlylint/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "curlylint",
"categories": ["linter"],
"commands": {
"": ["-q", "$PATH"]
},
"description": "Experimental HTML templates linting for Jinja, Nunjucks, Django templates, Twig, Liquid",
"homepage": "https://github.com/thibaudcolas/curlylint",
"languages": ["nunjucks", "jinja", "django", "twig", "liquid"],
"name": null,
"npm": null,
"php": null,
"tests": []
}

0 comments on commit b4202ad

Please sign in to comment.