Skip to content

Commit

Permalink
feat: add support for quick-lint-js
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Jan 12, 2025
1 parent 7da8146 commit 604e0a9
Show file tree
Hide file tree
Showing 6 changed files with 68 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 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)
- feat: add support for mypy [`#597`](https://github.com/hougesen/mdsf/pull/597)
- feat: add support for luacheck [`#596`](https://github.com/hougesen/mdsf/pull/596)
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 230 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
`mdsf` currently supports 231 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃

| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
Expand Down Expand Up @@ -379,6 +379,7 @@ mdsf init
| [pyink](https://github.com/google/pyink) | Pyink is a Python formatter, forked from Black with a few different formatting behaviors | `formatter` | `python` |
| [pyment](https://github.com/dadadel/pyment) | Format and convert Python docstrings and generates patches | `formatter` | `python` |
| [qmlfmt](https://github.com/jesperhh/qmlfmt) | qmlfmt - command line application that formats QML files | `formatter` | `qml` |
| [quick-lint-js](https://github.com/quick-lint/quick-lint-js) | quick-lint-js finds bugs in JavaScript programs | `linter` | `javascript` |
| [raco](https://docs.racket-lang.org/fmt/) | An extensible code formatter for Racket | `formatter` | `racket` |
| [refmt](https://reasonml.github.io/docs/en/refmt) | refmt stands by Reason Formatter and it formats Reason programs, is a parser and pretty-printer for Reason | `formatter` | `reason` |
| [reformat-gherkin](https://github.com/ducminh-phan/reformat-gherkin) | Reformat-gherkin automatically formats Gherkin files | `formatter` | `gherkin` |
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 @@ -166,6 +166,7 @@ pub mod pycln;
pub mod pyink;
pub mod pyment;
pub mod qmlfmt;
pub mod quick_lint_js;
pub mod raco_fmt;
pub mod refmt;
pub mod reformat_gherkin;
Expand Down Expand Up @@ -915,6 +916,10 @@ pub enum Tooling {
/// `qmlfmt -w $PATH`
Qmlfmt,

#[serde(rename = "quick-lint-js")]
/// `quick-lint-js $PATH`
QuickLintJs,

#[serde(rename = "raco:fmt")]
/// `raco fmt -i $PATH`
RacoFmt,
Expand Down Expand Up @@ -1380,6 +1385,7 @@ impl Tooling {
Self::Pyink => pyink::run(snippet_path),
Self::Pyment => pyment::run(snippet_path),
Self::Qmlfmt => qmlfmt::run(snippet_path),
Self::QuickLintJs => quick_lint_js::run(snippet_path),
Self::RacoFmt => raco_fmt::run(snippet_path),
Self::Refmt => refmt::run(snippet_path),
Self::ReformatGherkin => reformat_gherkin::run(snippet_path),
Expand Down Expand Up @@ -1629,6 +1635,7 @@ impl AsRef<str> for Tooling {
Self::Pyink => "pyink",
Self::Pyment => "pyment",
Self::Qmlfmt => "qmlfmt",
Self::QuickLintJs => "quick_lint_js",
Self::RacoFmt => "raco_fmt",
Self::Refmt => "refmt",
Self::ReformatGherkin => "reformat_gherkin",
Expand Down
38 changes: 38 additions & 0 deletions mdsf/src/tools/quick_lint_js.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use std::process::Command;

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

#[inline]
fn set_quick_lint_js_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::NodeModules("quick-lint-js"),
CommandType::Direct("quick-lint-js"),
CommandType::Npm("quick-lint-js"),
];

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_quick_lint_js_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_quick_lint_js {}
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 @@ -898,6 +898,11 @@
"type": "string",
"enum": ["qmlfmt"]
},
{
"description": "`quick-lint-js $PATH`",
"type": "string",
"enum": ["quick-lint-js"]
},
{
"description": "`raco fmt -i $PATH`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/quick-lint-js/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "quick-lint-js",
"categories": ["linter"],
"commands": {
"": ["$PATH"]
},
"description": "quick-lint-js finds bugs in JavaScript programs",
"homepage": "https://github.com/quick-lint/quick-lint-js",
"languages": ["javascript"],
"name": null,
"npm": "quick-lint-js",
"php": null,
"tests": []
}

0 comments on commit 604e0a9

Please sign in to comment.