diff --git a/.prettierignore b/.prettierignore index 3736a388fcb..c594a7c06cf 100644 --- a/.prettierignore +++ b/.prettierignore @@ -30,3 +30,7 @@ version_expansions.yml # Ignore all formatting in third_party/* src/third_party + +# Ignore anything in the build output directories +build +bazel-* diff --git a/bazel/format/format.py b/bazel/format/format.py index 396d3f0b3a5..4226ac7b09f 100644 --- a/bazel/format/format.py +++ b/bazel/format/format.py @@ -5,8 +5,12 @@ import subprocess def run_prettier(prettier: pathlib.Path, check: bool) -> int: + # Explicitly ignore anything in the output directories to prevent bad symlinks from failing the run, + # see https://github.com/prettier/prettier/issues/11568 as to why it the paths being present in + # .prettierignore isn't sufficient + force_exclude_dirs = ["!./build", "!./bazel-bin", "!./bazel-out", "!./bazel-mongo"] try: - command = [prettier, "."] + command = [prettier, "."] + force_exclude_dirs if check: command.append("--check") else: