Skip to content

Commit

Permalink
Add support for markdownlint-cli2 (#879)
Browse files Browse the repository at this point in the history
This pull request introduces a new linter, `markdownlint-cli2`, and
updates the documentation and configuration files accordingly. The most
important changes include adding the new linter to the `README.md`,
creating configuration and test files for `markdownlint-cli2`, and
updating existing linter configurations.

### Introduction of `markdownlint-cli2`:

* **Configuration and Test Files:**
- Created a basic test for `markdownlint-cli2` in
`linters/markdownlint-cli2/markdownlint.test.ts`.
- Defined the `markdownlint-cli2` tool and its configurations in
`linters/markdownlint-cli2/plugin.yaml`.
- Added a JSON configuration file for `markdownlint-cli2` in
`linters/markdownlint-cli2/test_data/.markdownlint-cli2.jsonc`.
- Provided test data and expected output for `markdownlint-cli2` in
`linters/markdownlint-cli2/test_data/basic.in.md` and
`linters/markdownlint-cli2/test_data/markdownlint_cli2_v0.14.0_basic.check.shot`.
[[1]](diffhunk://#diff-6d06de89ac9581b3de417feab835ac7b52f10e532843efb099cc4b01d3434177R1-R11)
[[2]](diffhunk://#diff-ca893877499930e4cb50e87128752a099619bfca0015eeb580efa09f525a2578R1-R43)

### Documentation Updates:

* **README.md:**
- Updated the Markdown linters list to include `markdownlint-cli2` in
`README.md`.

### Removal of Old Configurations:

* **Old Linter Configurations:**
- Removed outdated `markdownlint-cli2` configurations from
`linters/markdownlint/plugin.yaml`.
  • Loading branch information
det authored Sep 27, 2024
1 parent 0f4799e commit 512ca70
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 56 deletions.
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
107 changes: 54 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] |
| 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 Expand Up @@ -137,6 +137,7 @@ trunk check enable {linter}
[ktlint]: https://github.com/pinterest/ktlint#readme
[kube-linter]: https://github.com/stackrox/kube-linter#readme
[markdownlint]: https://github.com/DavidAnson/markdownlint#readme
[markdownlint-cli2]: https://github.com/DavidAnson/markdownlint-cli2#readme
[markdown-table-prettify]: https://github.com/darkriszty/MarkdownTablePrettify-VSCodeExt#readme
[markdown-link-check]: https://github.com/tcort/markdown-link-check#readme
[mypy]: https://github.com/python/mypy#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

0 comments on commit 512ca70

Please sign in to comment.