Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Linters which are not language-specific:
| TSX | [Prettier] | [ESLint] |
| TypeScript | [Prettier] | [ESLint] |
| YAML | [yamlfmt] | |
| XML | [prettier/plugin-xml] | |

[prettier]: https://prettier.io
[google-java-format]: https://github.com/google/google-java-format
Expand All @@ -68,6 +69,7 @@ Linters which are not language-specific:
[ktlint]: https://github.com/pinterest/ktlint
[buildifier]: https://github.com/keith/buildifier-prebuilt
[prettier-plugin-sql]: https://github.com/un-ts/prettier
[prettier/plugin-xml]: https://github.com/prettier/plugin-xml
[gofmt]: https://pkg.go.dev/cmd/gofmt
[gofumpt]: https://github.com/mvdan/gofumpt
[jsonnetfmt]: https://github.com/google/go-jsonnet
Expand Down
3 changes: 2 additions & 1 deletion docs/format.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"eslint": "^9.16.0",
"prettier": "^2.8.7",
"prettier-plugin-sql": "^0.14.0",
"@prettier/plugin-xml": "^0.10.0",
"stylelint": "^16",
"stylelint-config-standard": "^36.0.1",
"typescript": "4.9.5",
Expand Down
4 changes: 4 additions & 0 deletions example/src/hello.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<hello>
<world>
todo</world>
</hello>
1 change: 1 addition & 0 deletions example/tools/format/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ format_multirun(
swift = ":swiftformat",
terraform = "@aspect_rules_lint//format:terraform",
visibility = ["//:__subpackages__"],
xml = ":prettier",
yaml = "@aspect_rules_lint//format:yamlfmt",
)

Expand Down
3 changes: 3 additions & 0 deletions format/private/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ function ls-files {
'TypeScript') patterns=('*.ts' '*.cts' '*.mts') ;;
'Vue') patterns=('*.vue') ;;
'YAML') patterns=('*.yml' '*.yaml' '.clang-format' '.clang-tidy' '.gemrc') ;;
# Note: https://github.com/github-linguist/linguist/blob/559a6426942abcae16b6d6b328147476432bf6cb/lib/linguist/languages.yml#L7767-L7882
# has a giant list of patterns. We arbitrarily choose some "common" ones.
'XML') patterns=('*.xml' '*.xsd') ;;

# Note: terraform fmt cannot handle all HCL files such as .terraform.lock
# "Only .tf and .tfvars files can be processed with terraform fmt"
Expand Down
1 change: 1 addition & 0 deletions format/private/formatter_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TOOLS = {
"Cuda": "clang-format",
"YAML": "yamlfmt",
"Rust": "rustfmt",
"XML": "prettier",
}

# Provided to make install more convenient
Expand Down
1 change: 1 addition & 0 deletions format/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ format_multirun(
swift = ":mock_swiftformat.sh",
# TODO: this attribute should be renamed to hcl
terraform = ":mock_terraform-fmt.sh",
xml = ":mock_prettier.sh",
yaml = ":mock_yamlfmt.sh",
)
7 changes: 7 additions & 0 deletions format/test/format_test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ bats_load_library "bats-assert"
assert_output --partial "+ prettier --write .bcr/README.md CONTRIBUTING.md README.md"
}

@test "should run prettier on XML" {
run bazel run //format/test:format_XML_with_prettier
assert_success

assert_output --partial "+ prettier --write example/checkstyle-suppressions.xml"
}

@test "should run prettier on CSS" {
run bazel run //format/test:format_CSS_with_prettier
assert_success
Expand Down