Skip to content

Commit

Permalink
feat: add support for csslint
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Jan 14, 2025
1 parent d526da1 commit 12f3743
Show file tree
Hide file tree
Showing 6 changed files with 69 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.4.0...HEAD)

- feat: add support for csslint [`#611`](https://github.com/hougesen/mdsf/pull/611)
- feat: add support for inko fmt [`#610`](https://github.com/hougesen/mdsf/pull/610)
- feat: add support for futhark fmt [`#609`](https://github.com/hougesen/mdsf/pull/609)
- feat: add support for wa fmt [`#608`](https://github.com/hougesen/mdsf/pull/608)
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 239 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
`mdsf` currently supports 240 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` |
| [csslint](https://github.com/CSSLint/csslint) | Automated linting of Cascading Stylesheets | `linter` | `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` |
Expand Down
39 changes: 39 additions & 0 deletions mdsf/src/tools/csslint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use std::process::Command;

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

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

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

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_csslint_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_csslint {}
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 csslint;
pub mod curlylint;
pub mod d_2_fmt;
pub mod dart_fix;
Expand Down Expand Up @@ -425,6 +426,10 @@ pub enum Tooling {
/// `csscomb -t $PATH`
Csscomb,

#[serde(rename = "csslint")]
/// `csslint --quiet $PATH`
Csslint,

#[serde(rename = "curlylint")]
/// `curlylint -q $PATH`
Curlylint,
Expand Down Expand Up @@ -1305,6 +1310,7 @@ impl Tooling {
Self::Csharpier => csharpier::run(snippet_path),
Self::CssBeautify => css_beautify::run(snippet_path),
Self::Csscomb => csscomb::run(snippet_path),
Self::Csslint => csslint::run(snippet_path),
Self::Curlylint => curlylint::run(snippet_path),
Self::D2Fmt => d_2_fmt::run(snippet_path),
Self::DartFix => dart_fix::run(snippet_path),
Expand Down Expand Up @@ -1564,6 +1570,7 @@ impl AsRef<str> for Tooling {
Self::Csharpier => "csharpier",
Self::CssBeautify => "css_beautify",
Self::Csscomb => "csscomb",
Self::Csslint => "csslint",
Self::Curlylint => "curlylint",
Self::D2Fmt => "d_2_fmt",
Self::DartFix => "dart_fix",
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.4.0-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": "`csslint --quiet $PATH`",
"type": "string",
"enum": ["csslint"]
},
{
"description": "`curlylint -q $PATH`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/csslint/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "csslint",
"categories": ["linter"],
"commands": {
"": ["--quiet", "$PATH"]
},
"description": "Automated linting of Cascading Stylesheets",
"homepage": "https://github.com/CSSLint/csslint",
"languages": ["css"],
"name": null,
"npm": "csslint",
"php": null,
"tests": []
}

0 comments on commit 12f3743

Please sign in to comment.