Skip to content
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Linters which are not language-specific:
| Jsonnet | [jsonnetfmt] | |
| Kotlin | [ktfmt] | [ktlint] |
| Markdown | [Prettier] | [Vale] |
| Nickel | [nickel] | |
| Protocol Buffer | [buf] | [buf lint] |
| Python | [ruff] | [flake8], [ruff] |
| Rust | [rustfmt] | |
Expand Down Expand Up @@ -84,13 +85,14 @@ Linters which are not language-specific:
[ruff]: https://docs.astral.sh/ruff/
[shellcheck]: https://www.shellcheck.net/
[shfmt]: https://github.com/mvdan/sh
[taplo] : https://taplo.tamasfe.dev/
[taplo]: https://taplo.tamasfe.dev/
[clang-format]: https://clang.llvm.org/docs/ClangFormat.html
[clang-tidy]: https://clang.llvm.org/extra/clang-tidy/
[vale]: https://vale.sh/
[yamlfmt]: https://github.com/google/yamlfmt
[rustfmt]: https://rust-lang.github.io/rustfmt
[stylelint]: https://stylelint.io
[nickel]: https://github.com/tweag/nickel

1. Non-hermetic: requires that a swift toolchain is installed on the machine.
See https://github.com/bazelbuild/rules_swift#1-install-swift
Expand Down
5 changes: 3 additions & 2 deletions docs/format.md

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

9 changes: 9 additions & 0 deletions example/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ http_file(
],
)

http_file(
name = "nickel",
executable = True,
sha256 = "825657c5139d3b3c0da37da073493e18ef32cbe74afbf726a7dd643a39b4fd8b",
urls = [
"https://github.com/tweag/nickel/releases/download/1.13.0/nickel-x86_64-linux",
],
)

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext")
rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")
Expand Down
9 changes: 9 additions & 0 deletions example/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ http_file(
],
)

http_file(
name = "nickel",
executable = True,
sha256 = "825657c5139d3b3c0da37da073493e18ef32cbe74afbf726a7dd643a39b4fd8b",
urls = [
"https://github.com/tweag/nickel/releases/download/1.13.0/nickel-x86_64-linux",
],
)

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()
Expand Down
6 changes: 6 additions & 0 deletions example/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ kt_jvm_library(
srcs = ["hello.kt"],
)

filegroup(
name = "nickel",
srcs = ["hello.ncl"],
tags = ["nickel"],
)

# Cause a test failure when files are not formatted.
# This is useful when you have no other way to check formatting on CI; see documentation.
format_test(
Expand Down
3 changes: 3 additions & 0 deletions example/src/hello.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
foo {
bar
}
1 change: 1 addition & 0 deletions example/tools/format/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ format_multirun(
jsonnet = "@aspect_rules_lint//format:jsonnetfmt",
kotlin = ":ktfmt",
markdown = ":prettier",
nickel = "@nickel//file",
protocol_buffer = "//tools/lint:buf",
python = "@aspect_rules_lint//format:ruff",
# Note, older rules_rust versions may need
Expand Down
25 changes: 25 additions & 0 deletions format/multitool.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,30 @@
"cpu": "x86_64"
}
]
},
"nickel": {
"binaries": [
{
"kind": "file",
"url": "https://github.com/tweag/nickel/releases/download/1.13.0/nickel-arm64-linux",
"sha256": "6c8b2d9a4bfa24761356302ba21bf9b2f107062bac7c514dc31f40198c40edc0",
"os": "linux",
"cpu": "arm64"
},
{
"kind": "file",
"url": "https://github.com/tweag/nickel/releases/download/1.13.0/nickel-arm64-macos",
"sha256": "30aafb99e4deaf511ea8b2e93e507a9c0ba8bd25b9c116412fb3e6d3e7426e46",
"os": "macos",
"cpu": "arm64"
},
{
"kind": "file",
"url": "https://github.com/tweag/nickel/releases/download/1.13.0/nickel-x86_64-linux",
"sha256": "825657c5139d3b3c0da37da073493e18ef32cbe74afbf726a7dd643a39b4fd8b",
"os": "linux",
"cpu": "x86_64"
}
]
}
}
1 change: 1 addition & 0 deletions format/private/filter.jq
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ with_entries(select(.key | IN(
"CSS",
"Cuda",
"Markdown",
"Nickel",
"Go",
"Gherkin",
"GraphQL",
Expand Down
1 change: 1 addition & 0 deletions format/private/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function ls-files {
# which does support the entire HCL language FWICT
'Terraform') patterns=('*.tf' '*.tfvars') ;;
'TOML') patterns=('*.toml') ;;
'Nickel') patterns=('*.ncl') ;;

*)
echo >&2 "Internal error: unknown language $language"
Expand Down
3 changes: 3 additions & 0 deletions format/private/formatter_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ TOOLS = {
"Rust": "rustfmt",
"XML": "prettier",
"Gherkin": "prettier",
"Nickel": "nickel",
}

# Provided to make install more convenient
Expand Down Expand Up @@ -59,6 +60,7 @@ CHECK_FLAGS = {
"clang-format": "--style=file --fallback-style=none --dry-run -Werror",
"yamlfmt": "-lint",
"rustfmt": "--check",
"nickel": "format --check",
}

# Flags to pass each tool when running in default mode
Expand Down Expand Up @@ -86,6 +88,7 @@ FIX_FLAGS = {
"clang-format": "-style=file --fallback-style=none -i",
"yamlfmt": "",
"rustfmt": "",
"nickel": "format",
}

def to_attribute_name(lang):
Expand Down
1 change: 1 addition & 0 deletions format/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ format_multirun(
jsonnet = ":mock_jsonnetfmt.sh",
kotlin = ":mock_ktfmt.sh",
markdown = ":mock_prettier.sh",
nickel = ":mock_nickel.sh",
protocol_buffer = ":mock_buf.sh",
python = ":mock_ruff.sh",
rust = ":mock_rustfmt.sh",
Expand Down
7 changes: 7 additions & 0 deletions format/test/format_test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,10 @@ bats_load_library "bats-assert"

assert_output --partial "+ prettier --write example/src/hello.feature"
}

@test "should run nickel on ncl" {
run bazel run //format/test:format_Nickel_with_nickel
assert_success

assert_output --partial '+ nickel format example/src/hello.ncl'
}
Loading