Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

New linter yamlfmt #1011

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

Merged
merged 13 commits into from
Jun 9, 2025
3 changes: 2 additions & 1 deletion 3 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ trunk check enable {linter}
| Textproto | [txtpbfmt] |
| TOML | [taplo] |
| Typescript | [deno], [eslint], [prettier], [rome], [semgrep] |
| YAML | [prettier], [semgrep], [yamllint] |
| YAML | [prettier], [semgrep], [yamlfmt], [yamllint] |

[actionlint]: https://trunk.io/linters/infra/actionlint
[ansible-lint]: https://github.com/ansible/ansible-lint#readme
Expand Down Expand Up @@ -197,6 +197,7 @@ trunk check enable {linter}
[txtpbfmt]: https://github.com/protocolbuffers/txtpbfmt#readme
[ty]: https://github.com/astral-sh/ty#readme
[vale]: https://vale.sh/docs/
[yamlfmt]: https://github.com/google/yamlfmt#readme
[yamllint]: https://trunk.io/linters/yaml/yamllint
[yapf]: https://github.com/google/yapf#readme

Expand Down
45 changes: 45 additions & 0 deletions 45 linters/yamlfmt/plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: 0.1
downloads:
- name: yamlfmt
downloads:
- os:
linux: Linux
macos: Darwin
windows: Windows
cpu:
x86_64: x86_64
arm_64: arm64
url: https://github.com/google/yamlfmt/releases/download/v${version}/yamlfmt_${version}_${os}_${cpu}.tar.gz
tools:
definitions:
- name: yamlfmt
download: yamlfmt
known_good_version: 0.1.0
shims: [yamlfmt]
lint:
definitions:
- name: yamlfmt
files: [yaml]
description: Formats yaml files
commands:
- name: format
output: rewrite
run: yamlfmt ${target}
run_from: ${parent}
success_codes: [0, 1]
cache_results: true
formatter: true
in_place: true
batch: true
tools: [yamlfmt]
direct_configs:
- .yamlfmt
- .yamlfmt.yaml
- .yamlfmt.yml
- yamlfmt.yaml
- yamlfmt.yml
suggest_if: config_present
version_command:
parse_regex: ${semver}
run: yamlfmt -version
known_good_version: 0.1.0
3 changes: 3 additions & 0 deletions 3 linters/yamlfmt/test_data/basic.in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yaml:
array:
- item
8 changes: 8 additions & 0 deletions 8 linters/yamlfmt/test_data/yamlfmt_v0.1.0_basic.fmt.shot
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing formatter yamlfmt test basic 1`] = `
"yaml:
array:
- item
"
`;
9 changes: 9 additions & 0 deletions 9 linters/yamlfmt/yamlfmt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { linterCheckTest, linterFmtTest } from "tests";
import { osTimeoutMultiplier } from "tests/utils";

// This install is quite slow on some Linux machines.
jest.setTimeout(600000 * osTimeoutMultiplier);

linterCheckTest({ linterName: "yamlfmt", namedTestPrefixes: ["empty"] });

linterFmtTest({ linterName: "yamlfmt", namedTestPrefixes: ["basic"] });
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.