From 6a0a8053a5e0d40b8d0e770386275ff619b2cf16 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Wed, 21 Aug 2024 11:48:42 -0400 Subject: [PATCH] update prettier and clang-format cli options in format.py --- justfile | 4 ++++ tools/cross/format.py | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index 0e280b45fdb..5bfb5173643 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,6 @@ alias b := build alias t := test +alias f := format default: @just --list @@ -26,3 +27,6 @@ test *args="//...": test-asan *args="//...": just test {{args}} --config=asan + +format: + python3 tools/cross/format.py diff --git a/tools/cross/format.py b/tools/cross/format.py index 5825a06e190..c76f248e04a 100644 --- a/tools/cross/format.py +++ b/tools/cross/format.py @@ -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: @@ -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") @@ -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 ]