diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..1b8dfdd26 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,41 @@ +# Pre-commit configuration for OPM-tests +# This configuration uses the pre-commit framework to automatically format source files +# before commits, ensuring consistent code style across the project. +# +# Installation: +# ------------- +# 1. Install pre-commit (choose one method): +# - Via pip: pip install pre-commit +# - Via conda: conda install -c conda-forge pre-commit +# - Via homebrew (macOS): brew install pre-commit +# - Via package manager (Ubuntu/Debian): apt install pre-commit +# +# 2. Install the hooks in your local repository: +# pre-commit install +# +# Usage: +# ------ +# - Hooks run automatically on every commit +# - To run manually on all files: pre-commit run --all-files +# - To run on specific files: pre-commit run --files +# - To skip hooks for a commit: git commit --no-verify +# - To update hook versions: pre-commit autoupdate +# +# What these hooks do: +# ------------------- +# - trailing-whitespace: Removes trailing whitespace from lines +# (preserves Markdown hard line breaks with --markdown-linebreak-ext=md) +# - end-of-file-fixer: Ensures files end with exactly one newline +# +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 # Latest release as of August 2025 + hooks: + - id: trailing-whitespace + files: '\.(?:DATA|data|INC|inc|param|sh|SCH|sch(?:[1-6])?|sched|md|yaml)$' + args: [--markdown-linebreak-ext=md] + exclude: '^(\.git/)' + + - id: end-of-file-fixer + files: '\.(?:DATA|data|INC|inc|param|sh|SCH|sch(?:[1-6])?|sched|md|yaml)$' + exclude: '^(\.git/)'