diff --git a/.gitignore b/.gitignore index 003c57f6f..026fd7db3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ node_modules/ # Typescript out/ + +junit.xml diff --git a/README.md b/README.md index a1e2c41c3..ad42f489a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/linters/markdownlint-cli2/markdownlint.test.ts b/linters/markdownlint-cli2/markdownlint.test.ts new file mode 100644 index 000000000..91b33f474 --- /dev/null +++ b/linters/markdownlint-cli2/markdownlint.test.ts @@ -0,0 +1,3 @@ +import { linterCheckTest } from "tests"; + +linterCheckTest({ linterName: "markdownlint-cli2" }); diff --git a/linters/markdownlint-cli2/plugin.yaml b/linters/markdownlint-cli2/plugin.yaml new file mode 100644 index 000000000..1b662a8d4 --- /dev/null +++ b/linters/markdownlint-cli2/plugin.yaml @@ -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[^:]+):(?P[\\d+]+)(?::(?P[\\d+]+))? (?P[^ ]+) + (?P.*)\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 diff --git a/linters/markdownlint-cli2/test_data/.markdownlint-cli2.jsonc b/linters/markdownlint-cli2/test_data/.markdownlint-cli2.jsonc new file mode 100644 index 000000000..5ecf259c3 --- /dev/null +++ b/linters/markdownlint-cli2/test_data/.markdownlint-cli2.jsonc @@ -0,0 +1,5 @@ +{ + "config": { + "extends": "markdownlint/style/prettier" + } +} diff --git a/linters/markdownlint-cli2/test_data/basic.in.md b/linters/markdownlint-cli2/test_data/basic.in.md new file mode 100644 index 000000000..9163e8372 --- /dev/null +++ b/linters/markdownlint-cli2/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/markdownlint-cli2/test_data/markdownlint_cli2_v0.14.0_basic.check.shot b/linters/markdownlint-cli2/test_data/markdownlint_cli2_v0.14.0_basic.check.shot new file mode 100644 index 000000000..a0471cf50 --- /dev/null +++ b/linters/markdownlint-cli2/test_data/markdownlint_cli2_v0.14.0_basic.check.shot @@ -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": [], +} +`; diff --git a/linters/markdownlint/plugin.yaml b/linters/markdownlint/plugin.yaml index 978bbdd0c..1aa1515d5 100644 --- a/linters/markdownlint/plugin.yaml +++ b/linters/markdownlint/plugin.yaml @@ -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: