unguard
unguard copied to clipboard
Add pre-commit hooks to Unguard
We're considering adding pre-commit to our project to help ensure that the code we commit to our repository is high quality. Pre-commit is a tool that allows us to define a set of checks that are run on our code every time we try to commit changes. These checks can include linting, formatting, and testing and help catch issues before they're committed to the repository.
Definition of Done
- [ ] pre-commit hooks check the repository for each commit
- [ ] The documentation explains how to use pre-commit
Tasks
- [ ] Propose pre-commit hooks that are useful
- [ ] Create the pre-commit configuration
- [ ] Update the documentation to describe the usage of pre-commit
- [ ] Test the hooks (
pre-commit run --all-files
)
Additional context
Example .pre-commit-config.yaml
default_install_hook_types:
- pre-commit
- commit-msg
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.1.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
stages: [commit]
name: "Format files with Prettier"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.25.0
hooks:
- id: eslint
stages: [commit]
name: "Lint files with ESLint"
files: \.[jt]sx?$
types: [file]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-case-conflict
- id: check-json
- id: check-xml
- id: check-yaml
args: [--allow-multiple-documents]
- id: detect-aws-credentials
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]