1- load ("@bazel_skylib//rules:copy_file.bzl" , "copy_file" )
1+ load ("@aspect_rules_lint//format:defs.bzl" , "format_multirun" )
2+ load ("@bazel_skylib//rules:native_binary.bzl" , "native_binary" )
3+ load ("@npm//:prettier/package_json.bzl" , prettier  =  "bin" )
24
35config_setting (
46    name  =  "linux_amd64" ,
@@ -40,7 +42,7 @@ config_setting(
4042    ],
4143)
4244
43- copy_file (
45+ native_binary (
4446    name  =  "clang-format@rule" ,
4547    src  =  select ({
4648        ":linux_amd64" : "@clang-format-linux-amd64//file:file" ,
@@ -52,7 +54,7 @@ copy_file(
5254    visibility  =  ["//visibility:public" ],
5355)
5456
55- copy_file (
57+ native_binary (
5658    name  =  "ruff@rule" ,
5759    src  =  select ({
5860        ":linux_amd64" : "@ruff-linux-amd64//:file" ,
@@ -64,7 +66,7 @@ copy_file(
6466    visibility  =  ["//visibility:public" ],
6567)
6668
67- copy_file (
69+ native_binary (
6870    name  =  "buildifier@rule" ,
6971    src  =  select ({
7072        ":linux_amd64" : "@buildifier-linux-amd64//file:file" ,
@@ -77,3 +79,27 @@ copy_file(
7779    out  =  "buildifier" ,
7880    visibility  =  ["//visibility:public" ],
7981)
82+ 
83+ prettier .prettier_binary (
84+     name  =  "prettier@rule" ,
85+     # Include this js_library and its dependencies in the runfiles (runtime dependencies) 
86+     data  =  ["//:prettierrc" ],
87+     # Allow the binary to be run outside bazel 
88+     env  =  {"BAZEL_BINDIR" : "." },
89+     fixed_args  =  [
90+         # `require` statements in the config file will be resolved relative to its location 
91+         # Therefore to make it hermetic, prettier must be pointed at the copy of the config file 
92+         # in the runfiles folder rather than the one in the source folder. 
93+         "--config=\" $$JS_BINARY__RUNFILES\" /$(rlocationpath //:prettierrc)" ,
94+         "--log-level=warn" ,
95+     ],
96+ )
97+ 
98+ format_multirun (
99+     name  =  "format" ,
100+     cc  =  ":clang-format@rule" ,
101+     javascript  =  ":prettier@rule" ,
102+     python  =  ":ruff@rule" ,
103+     starlark  =  ":buildifier@rule" ,
104+     visibility  =  ["//:__pkg__" ],
105+ )
0 commit comments