Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for markdownlint-cli2 #879

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules/

# Typescript
out/

junit.xml
106 changes: 53 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,59 +38,59 @@ Enable the following tools via:
trunk check enable {linter}
```

| Technology | Linters |
| --------------- | -------------------------------------------------------------------------------------------------------------------- |
| All | [codespell], [cspell], [gitleaks], [git-diff-check], [pre-commit-hooks], [trunk-toolbox], [vale] |
| Ansible | [ansible-lint] |
| Apex | [pmd] |
| Bash | [shellcheck], [shfmt] |
| Bazel, Starlark | [buildifier] |
| C, C++ | [clang-format], [clang-tidy], [include-what-you-use], [pragma-once] |
| C# | [dotnet-format] |
| CircleCI Config | [circleci] |
| Cloudformation | [cfnlint], [checkov] |
| CMake | [cmake-format] |
| CSS, SCSS | [stylelint], [prettier] |
| Cue | [cue-fmt] |
| Dart | [dart] |
| Docker | [hadolint], [checkov] |
| Dotenv | [dotenv-linter] |
| GitHub | [actionlint] |
| Go | [gofmt], [gofumpt], [goimports], [gokart], [golangci-lint], [golines], [semgrep] |
| GraphQL | [graphql-schema-linter], [prettier] |
| HAML | [haml-lint] |
| HTML Templates | [djlint] |
| Java | [google-java-format], [pmd], [semgrep] |
| Javascript | [biome], [deno], [eslint], [prettier], [rome], [semgrep] |
| JSON | [biome], [deno], [eslint], [prettier], [semgrep] |
| Kotlin | [detekt], [ktlint] |
| Kubernetes | [kube-linter] |
| Lua | [stylua] |
| Markdown | [deno], [markdownlint], [markdown-link-check], [markdown-table-prettify], [prettier], [remark-lint] |
| Nix | [nixpkgs-fmt] |
| package.json | [sort-package-json] |
| Perl | [perlcritic], [perltidy] |
| PHP | [php-cs-fixer], [phpstan] |
| PNG | [oxipng] |
| PowerShell | [psscriptanalyzer] |
| Prisma | [prisma] |
| Protobuf | [buf] (breaking, lint, and format), [clang-format], [clang-tidy] |
| Python | [autopep8], [bandit], [black], [flake8], [isort], [mypy], [pylint], [pyright], [semgrep], [yapf], [ruff], [sourcery] |
| Rego | [regal], [opa] |
| Renovate | [renovate] |
| Ruby | [brakeman], [rubocop], [rufo], [semgrep], [standardrb] |
| Rust | [clippy], [rustfmt] |
| Scala | [scalafmt] |
| Security | [checkov], [dustilock], [nancy], [osv-scanner], [tfsec], [trivy], [trufflehog], [terrascan] |
| SQL | [sqlfluff], [sqlfmt], [sql-formatter], [squawk] |
| SVG | [svgo] |
| Swift | [stringslint], [swiftlint], [swiftformat] |
| Terraform | [terraform] (validate and fmt), [checkov], [tflint], [tfsec], [terrascan], [tofu] |
| Terragrunt | [terragrunt] |
| Textproto | [txtpbfmt] |
| TOML | [taplo] |
| Typescript | [deno], [eslint], [prettier], [rome], [semgrep] |
| YAML | [prettier], [semgrep], [yamllint] |
| Technology | Linters |
| --------------- | ------------------------------------------------------------------------------------------------------------------------ |
| All | [codespell], [cspell], [gitleaks], [git-diff-check], [pre-commit-hooks], [trunk-toolbox], [vale] |
| Ansible | [ansible-lint] |
| Apex | [pmd] |
| Bash | [shellcheck], [shfmt] |
| Bazel, Starlark | [buildifier] |
| C, C++ | [clang-format], [clang-tidy], [include-what-you-use], [pragma-once] |
| C# | [dotnet-format] |
| CircleCI Config | [circleci] |
| Cloudformation | [cfnlint], [checkov] |
| CMake | [cmake-format] |
| CSS, SCSS | [stylelint], [prettier] |
| Cue | [cue-fmt] |
| Dart | [dart] |
| Docker | [hadolint], [checkov] |
| Dotenv | [dotenv-linter] |
| GitHub | [actionlint] |
| Go | [gofmt], [gofumpt], [goimports], [gokart], [golangci-lint], [golines], [semgrep] |
| GraphQL | [graphql-schema-linter], [prettier] |
| HAML | [haml-lint] |
| HTML Templates | [djlint] |
| Java | [google-java-format], [pmd], [semgrep] |
| Javascript | [biome], [deno], [eslint], [prettier], [rome], [semgrep] |
| JSON | [biome], [deno], [eslint], [prettier], [semgrep] |
| Kotlin | [detekt], [ktlint] |
| Kubernetes | [kube-linter] |
| Lua | [stylua] |
| Markdown | [deno], [markdownlint], [markdownlint-cli2], [markdown-link-check], [markdown-table-prettify], [prettier], [remark-lint] |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a link for this below the table

| Nix | [nixpkgs-fmt] |
| package.json | [sort-package-json] |
| Perl | [perlcritic], [perltidy] |
| PHP | [php-cs-fixer], [phpstan] |
| PNG | [oxipng] |
| PowerShell | [psscriptanalyzer] |
| Prisma | [prisma] |
| Protobuf | [buf] (breaking, lint, and format), [clang-format], [clang-tidy] |
| Python | [autopep8], [bandit], [black], [flake8], [isort], [mypy], [pylint], [pyright], [semgrep], [yapf], [ruff], [sourcery] |
| Rego | [regal], [opa] |
| Renovate | [renovate] |
| Ruby | [brakeman], [rubocop], [rufo], [semgrep], [standardrb] |
| Rust | [clippy], [rustfmt] |
| Scala | [scalafmt] |
| Security | [checkov], [dustilock], [nancy], [osv-scanner], [tfsec], [trivy], [trufflehog], [terrascan] |
| SQL | [sqlfluff], [sqlfmt], [sql-formatter], [squawk] |
| SVG | [svgo] |
| Swift | [stringslint], [swiftlint], [swiftformat] |
| Terraform | [terraform] (validate and fmt), [checkov], [tflint], [tfsec], [terrascan], [tofu] |
| Terragrunt | [terragrunt] |
| Textproto | [txtpbfmt] |
| TOML | [taplo] |
| Typescript | [deno], [eslint], [prettier], [rome], [semgrep] |
| YAML | [prettier], [semgrep], [yamllint] |

[actionlint]: https://trunk.io/linters/infra/actionlint
[ansible-lint]: https://github.com/ansible/ansible-lint#readme
Expand Down
3 changes: 3 additions & 0 deletions linters/markdownlint-cli2/markdownlint.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { linterCheckTest } from "tests";

linterCheckTest({ linterName: "markdownlint-cli2" });
46 changes: 46 additions & 0 deletions linters/markdownlint-cli2/plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 0.1
tools:
definitions:
- name: markdownlint-cli2
runtime: node
package: markdownlint-cli2
shims: [markdownlint-cli2]
known_good_version: 0.14.0

lint:
definitions:
- name: markdownlint-cli2
files: [markdown]
tools: [markdownlint-cli2]
description: A style checker and lint tool for markdown files
commands:
- name: lint
# Custom parser type defined in the trunk cli to handle markdownlint's JSON output.
output: regex
read_output_from: stderr
parse_regex:
"(?P<path>[^:]+):(?P<line>[\\d+]+)(?::(?P<col>[\\d+]+))? (?P<code>[^ ]+)
(?P<message>.*)\n"
run: markdownlint-cli2 ${target} --json
success_codes: [0, 1]
batch: true
cache_results: true
suggest_if: config_present
direct_configs:
- .markdownlint-cli2.jsonc
- .markdownlint-cli2.yaml
- .markdownlint-cli2.cjs
- .markdownlint-cli2.mjs
affects_cache:
- package.json
- .markdownlint.jsonc
- .markdownlint.json
- .markdownlint.yaml
- .markdownlint.yml
- .markdownlint.cjs
- .markdownlint.mjs
issue_url_format: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#{}
known_good_version: 0.14.0
version_command:
parse_regex: ${semver}
run: markdownlint --version
5 changes: 5 additions & 0 deletions linters/markdownlint-cli2/test_data/.markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"config": {
"extends": "markdownlint/style/prettier"
}
}
11 changes: 11 additions & 0 deletions linters/markdownlint-cli2/test_data/basic.in.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing linter markdownlint-cli2 test basic 1`] = `
{
"issues": [
{
"code": "MD025/single-title/single-h1",
"column": "1",
"file": "test_data/basic.in.md",
"issueClass": "ISSUE_CLASS_EXISTING",
"issueUrl": "https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#MD025/single-title/single-h1",
"level": "LEVEL_HIGH",
"line": "3",
"linter": "markdownlint-cli2",
"message": "Multiple top-level headings in the same document [Context: "This file fails some rules"]",
"targetType": "markdown",
},
],
"lintActions": [
{
"command": "lint",
"fileGroupName": "markdown",
"linter": "markdownlint-cli2",
"paths": [
"test_data/basic.in.md",
],
"verb": "TRUNK_VERB_CHECK",
},
{
"command": "lint",
"fileGroupName": "markdown",
"linter": "markdownlint-cli2",
"paths": [
"test_data/basic.in.md",
],
"upstream": true,
"verb": "TRUNK_VERB_CHECK",
},
],
"taskFailures": [],
"unformattedFiles": [],
}
`;
3 changes: 0 additions & 3 deletions linters/markdownlint/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ lint:
- .markdownlint.yaml
- .markdownlint.yml
- .markdownlintrc
- .markdownlint-cli2.json
- .markdownlint-cli2.yaml
- .markdownlint-cli2.jsonc
issue_url_format: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#{}
known_good_version: 0.33.0
version_command:
Expand Down
Loading