diff --git a/README.md b/README.md index 8a003b861..8bcb7e73a 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ trunk check enable {linter} | Kotlin | [detekt], [ktlint] | | Kubernetes | [kube-linter] | | Lua | [stylua] | -| Markdown | [deno], [markdownlint], [markdownlint-cli2], [markdown-link-check], [markdown-table-prettify], [prettier], [remark-lint] | +| Markdown | [deno], [markdownlint], [markdownlint-cli2], [markdown-link-check], [markdown-table-prettify], [prettier], [remark-lint], [rumdl] | | Nix | [nixpkgs-fmt] | | package.json | [sort-package-json] | | Perl | [perlcritic], [perltidy] | diff --git a/linters/rumdl/plugin.yaml b/linters/rumdl/plugin.yaml new file mode 100644 index 000000000..dc589fc2c --- /dev/null +++ b/linters/rumdl/plugin.yaml @@ -0,0 +1,55 @@ +version: 0.1 +downloads: + - name: rumdl + downloads: + - os: + linux: unknown-linux-gnu + macos: apple-darwin + cpu: + x86_64: x86_64 + arm_64: aarch64 + url: https://github.com/rvben/rumdl/releases/download/v${version}/rumdl-v${version}-${cpu}-${os}.tar.gz + - os: windows + cpu: x86_64 + url: https://github.com/rvben/rumdl/releases/download/v${version}/rumdl-v${version}-x86_64-pc-windows-msvc.zip +tools: + definitions: + - name: rumdl + download: rumdl + known_good_version: 0.1.42 + shims: [rumdl] + health_checks: + - command: rumdl --version + parse_regex: ${semver} +lint: + definitions: + - name: rumdl + files: [markdown] + tools: [rumdl] + description: A high-performance Markdown linter and formatter written in Rust + commands: + - name: lint + output: regex + parse_regex: (?P.*):(?P\d+):(?P\d+):\s+\[(?P[^\]]+)\]\s+(?P.*) + run: rumdl check ${target} + success_codes: [0, 1] + batch: true + cache_results: true + read_output_from: stdout + - name: fmt + output: rewrite + run: rumdl fmt ${target} + success_codes: [0] + batch: true + cache_results: true + formatter: true + in_place: true + suggest_if: config_present + direct_configs: + - .rumdl.toml + - rumdl.toml + issue_url_format: https://rumdl.dev/rules/{} + known_good_version: 0.1.42 + version_command: + parse_regex: ${semver} + run: rumdl version diff --git a/linters/rumdl/rumdl.test.ts b/linters/rumdl/rumdl.test.ts new file mode 100644 index 000000000..d69727907 --- /dev/null +++ b/linters/rumdl/rumdl.test.ts @@ -0,0 +1,4 @@ +import { linterCheckTest, linterFmtTest } from "tests"; + +linterCheckTest({ linterName: "rumdl" }); +linterFmtTest({ linterName: "rumdl" }); diff --git a/linters/rumdl/test_data/basic.in.md b/linters/rumdl/test_data/basic.in.md new file mode 100644 index 000000000..9163e8372 --- /dev/null +++ b/linters/rumdl/test_data/basic.in.md @@ -0,0 +1,11 @@ +# bad.md + +# This file fails some rules + +Line is OK- Make a realy long line that breaks the layout rules completely. Make a realy long line +that breaks +But this should be ignored because of config + + +Line is too long (over 120) A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G A +B C D E F G A B C D E F G A B C D E F G diff --git a/linters/rumdl/test_data/rumdl_v0.1.42_basic.check.shot b/linters/rumdl/test_data/rumdl_v0.1.42_basic.check.shot new file mode 100644 index 000000000..ac86c04e0 --- /dev/null +++ b/linters/rumdl/test_data/rumdl_v0.1.42_basic.check.shot @@ -0,0 +1,98 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing linter rumdl test basic 1`] = ` +{ + "issues": [ + { + "code": "MD013", + "column": "81", + "file": "test_data/basic.in.md", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://rumdl.dev/rules/MD013", + "level": "LEVEL_HIGH", + "line": "10", + "linter": "rumdl", + "message": "Line length 99 exceeds 80 characters", + "targetType": "markdown", + }, + { + "code": "MD025", + "column": "3", + "file": "test_data/basic.in.md", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://rumdl.dev/rules/MD025", + "level": "LEVEL_HIGH", + "line": "3", + "linter": "rumdl", + "message": "Multiple top-level headings (level 1) in the same document [*]", + "targetType": "markdown", + }, + { + "code": "MD013", + "column": "81", + "file": "test_data/basic.in.md", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://rumdl.dev/rules/MD013", + "level": "LEVEL_HIGH", + "line": "5", + "linter": "rumdl", + "message": "Line length 98 exceeds 80 characters", + "targetType": "markdown", + }, + { + "code": "MD012", + "column": "1", + "file": "test_data/basic.in.md", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://rumdl.dev/rules/MD012", + "level": "LEVEL_HIGH", + "line": "9", + "linter": "rumdl", + "message": "Multiple consecutive blank lines between content [*]", + "targetType": "markdown", + }, + ], + "lintActions": [ + { + "command": "fmt", + "fileGroupName": "markdown", + "linter": "rumdl", + "paths": [ + "test_data/basic.in.md", + ], + "verb": "TRUNK_VERB_FMT", + }, + { + "command": "lint", + "fileGroupName": "markdown", + "linter": "rumdl", + "paths": [ + "test_data/basic.in.md", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "markdown", + "linter": "rumdl", + "paths": [ + "test_data/basic.in.md", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + ], + "taskFailures": [], + "unformattedFiles": [ + { + "column": "1", + "file": "test_data/basic.in.md", + "issueClass": "ISSUE_CLASS_UNFORMATTED", + "level": "LEVEL_HIGH", + "line": "1", + "linter": "rumdl", + "message": "Incorrect formatting, autoformat by running 'trunk fmt'", + }, + ], +} +`; diff --git a/linters/rumdl/test_data/rumdl_v0.1.42_basic.fmt.shot b/linters/rumdl/test_data/rumdl_v0.1.42_basic.fmt.shot new file mode 100644 index 000000000..93599ceb5 --- /dev/null +++ b/linters/rumdl/test_data/rumdl_v0.1.42_basic.fmt.shot @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing formatter rumdl test basic 1`] = ` +"# bad.md + +## This file fails some rules + +Line is OK- Make a realy long line that breaks the layout rules completely. Make a realy long line +that breaks +But this should be ignored because of config + +Line is too long (over 120) A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G A +B C D E F G A B C D E F G A B C D E F G +" +`;