Skip to content

Commit

Permalink
update prettier and clang-format cli options in format.py
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Aug 21, 2024
1 parent a95796b commit 6a0a805
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
alias b := build
alias t := test
alias f := format

default:
@just --list
Expand All @@ -26,3 +27,6 @@ test *args="//...":

test-asan *args="//...":
just test {{args}} --config=asan

format:
python3 tools/cross/format.py
9 changes: 5 additions & 4 deletions tools/cross/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def filter_files_by_exts(


def clang_format(files: List[str], check: bool = False) -> bool:
cmd = [CLANG_FORMAT, "--verbose"]
cmd = [CLANG_FORMAT]
if check:
cmd += ["--dry-run", "--Werror"]
else:
Expand All @@ -95,8 +95,10 @@ def clang_format(files: List[str], check: bool = False) -> bool:


def prettier(files: List[str], check: bool = False) -> bool:
cmd = [PRETTIER]
cmd = [PRETTIER, "--log-level=warn"]
if check:
# This flag will only print files that require formatting
# and change exit code of the process depending on state.
cmd.append("--check")
else:
cmd.append("--write")
Expand Down Expand Up @@ -164,10 +166,9 @@ class FormatConfig:
),
FormatConfig(
directory="src",
extensions=(".js", ".ts", ".cjs", ".ejs", ".mjs"),
extensions=(".js", ".ts", ".cjs", ".ejs", ".mjs", ".json"),
formatter=prettier,
),
FormatConfig(directory="src", extensions=(".json",), formatter=prettier),
FormatConfig(directory=".", extensions=(".py",), formatter=ruff),
# TODO: lint bazel files
]
Expand Down

0 comments on commit 6a0a805

Please sign in to comment.