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
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bazel_dep(name = "aspect_rules_py", version = "1.4.0")
bazel_dep(name = "aspect_rules_lint", version = "1.5.3")
bazel_dep(name = "rules_shell", version = "0.5.0")
bazel_dep(name = "rules_java", version = "8.15.1")
bazel_dep(name = "rules_rust", version = "0.61.0")
bazel_dep(name = "rules_multitool", version = "1.9.0")

bazel_dep(name = "bazel_skylib", version = "1.7.1", dev_dependency = True)
Expand Down
23 changes: 13 additions & 10 deletions format_checker/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

# Source Format Targets for Bazel Projects

This module provides reusable Bazel macros for formatting **Starlark**, **Python** and **YAML** files
using [`aspect-build/rules_lint`](https://github.com/aspect-build/rules_lint) and `buildifier`. It enables
consistent formatting enforcement across Bazel-based projects.
This module provides reusable Bazel macros for formatting **Starlark**, **Python**, **YAML**, and **Rust** files using [`aspect-build/rules_lint`](https://github.com/aspect-build/rules_lint) and `buildifier`. By default Rust formatting uses the `@rules_rust//tools/upstream_wrapper:rustfmt` binary.

---

## Features

- ✅ Supports Python (`ruff`), YAML (`yamlfmt`) and Starlark (`buildifier`)
- ✅ Supports Python (`ruff`), YAML (`yamlfmt`), Starlark (`buildifier`) and Rust (via `@rules_rust` upstream wrapper by default)
- ✅ Provides `format.fix` and `format.check` targets
- ✅ Simple macro-based usage for local formatting scope
- ✅ Centralized logic without Bazel module extensions
Expand All @@ -19,9 +17,8 @@ consistent formatting enforcement across Bazel-based projects.
## Directory Structure

```bash
├── BUILD.bazel
├── MODULE.bazel # Bazel module declaration with deps
├── macros.bzl # Contains the reusable macro
├── BUILD.bazel
├── macros.bzl
└── README.md
```

Expand Down Expand Up @@ -89,10 +86,16 @@ This will register two Bazel targets:

---

## Rust support

- Default formatter label: `@rules_rust//tools/upstream_wrapper:rustfmt`.

---

## Benefits

✅ Centralized formatting config with local file scope
✅ Consistent developer experience across repositories
✅ Centralized formatting config with local file scope
✅ Consistent developer experience across repositories
✅ Easily pluggable in CI pipelines or Git pre-commit hooks

---
---
2 changes: 2 additions & 0 deletions format_checker/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def use_format_targets(fix_name = "format.fix", check_name = "format.check"):
format_multirun(
name = fix_name,
python = "@aspect_rules_lint//format:ruff",
rust = "@rules_rust//tools/upstream_wrapper:rustfmt",
starlark = "@buildifier_prebuilt//:buildifier",
yaml = "@aspect_rules_lint//format:yamlfmt",
visibility = ["//visibility:public"],
Expand All @@ -25,6 +26,7 @@ def use_format_targets(fix_name = "format.fix", check_name = "format.check"):
name = check_name,
no_sandbox = True,
python = "@aspect_rules_lint//format:ruff",
rust = "@rules_rust//tools/upstream_wrapper:rustfmt",
starlark = "@buildifier_prebuilt//:buildifier",
yaml = "@aspect_rules_lint//format:yamlfmt",
workspace = "//:MODULE.bazel",
Expand Down
2 changes: 1 addition & 1 deletion tools/sample.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
Expand All @@ -10,7 +11,6 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
#!/usr/bin/env bash
set -euo pipefail

bazel run //docs:ide_support
Expand Down