Skip to content

Commit 70ae3bf

Browse files
committed
fix: improve pre-commit configuration robustness
- Make prettier optional and skip if not installed globally - Make docs build check optional (only run when PRE_COMMIT_DOCS_BUILD=1) - Make Bazel build test optional (only run when PRE_COMMIT_BAZEL_BUILD=1) - Reduce pre-commit hook failures for missing optional tools
1 parent 0fff08e commit 70ae3bf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ repos:
3939
hooks:
4040
- id: go-fmt
4141

42-
# JavaScript/TypeScript/Documentation formatting
43-
- repo: https://github.com/pre-commit/mirrors-prettier
44-
rev: v4.0.0-alpha.8
42+
# JavaScript/TypeScript/Documentation formatting (optional)
43+
- repo: local
4544
hooks:
4645
- id: prettier
46+
name: Prettier (optional)
47+
description: Format JS/TS/MD files if prettier is available
48+
entry: bash -c 'if command -v prettier >/dev/null 2>&1; then prettier --write "$@"; else echo "Prettier not installed globally, skipping formatting"; fi'
49+
language: system
4750
files: '\.(js|ts|jsx|tsx|json|yaml|yml|md|mdx|astro|css)$'
48-
exclude: '(package-lock\.json|\.lock)$'
49-
additional_dependencies:
50-
- 'prettier-plugin-astro@^0.14.0'
51+
exclude: '(package-lock\.json|\.lock|bazel-.*|node_modules)$'
5152

5253
# Markdown linting
5354
- repo: https://github.com/igorshubovych/markdownlint-cli
@@ -104,20 +105,20 @@ repos:
104105
language: system
105106
files: '\.wit$'
106107

107-
# Basic Bazel build test
108+
# Basic Bazel build test (only run on CI or explicit request)
108109
- id: bazel-build-test
109110
name: Bazel Build Test
110111
description: Run basic build test for Bazel files
111-
entry: bash -c 'echo "Testing Bazel build..." && bazel build //tinygo:file_ops_component_binary //rust:file_ops_component || echo "Build test failed, but continuing"'
112+
entry: bash -c 'if [ "$PRE_COMMIT_BAZEL_BUILD" = "1" ]; then echo "Testing Bazel build..." && bazel build //tinygo:file_ops_cli //rust:file_ops_component || echo "Build test failed, but continuing"; else echo "Skipping Bazel build test (set PRE_COMMIT_BAZEL_BUILD=1 to enable)"; fi'
112113
language: system
113114
files: '\.bzl$|\.bazel$|BUILD$'
114115
pass_filenames: false
115116

116-
# Documentation build validation
117+
# Documentation build validation (only on CI or explicit request)
117118
- id: docs-build-check
118119
name: Documentation Build Check
119120
description: Validate documentation builds successfully
120-
entry: bash -c 'cd docs-site && npm run build'
121+
entry: bash -c 'if [ "$PRE_COMMIT_DOCS_BUILD" = "1" ]; then cd docs-site && npm run build; else echo "Skipping docs build (set PRE_COMMIT_DOCS_BUILD=1 to enable)"; fi'
121122
language: system
122123
files: '^docs-site/.*\.(js|ts|astro|mdx|md|json)$'
123124
pass_filenames: false

0 commit comments

Comments
 (0)