Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# How to install:
# pre-commit install --install-hooks && pre-commit install --install-hooks -t commit-msg
# How temporary skip one of hooks: https://pre-commit.com/#temporarily-disabling-hooks
repos:
#######
# ALL #
#######
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
# Git style
- id: check-added-large-files
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: forbid-new-submodules
- id: no-commit-to-branch
# Common errors
- id: check-yaml
args: [--allow-multiple-documents]
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: check-executables-have-shebangs
# Cross platform
- id: check-case-conflict
# Security
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- id: detect-private-key
# Git style
# You can simplify this process, installing commitizen globally and then add alias:
# sudo pip3 install -U Commitizen
# gcz='cz commit'
# https://github.com/commitizen-tools/commitizen#installation
- repo: https://github.com/commitizen-tools/commitizen
rev: master
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/milin/giticket
rev: '868d937'
hooks:
- id: giticket
args: ['--format={ticket}: {commit_msg}']
- repo: https://github.com/jorisroovers/gitlint
rev: v0.12.0
hooks:
- id: gitlint
# More security
- repo: https://github.com/mattlqx/pre-commit-sign
rev: v1.1.1
hooks:
- id: sign-commit
#############
# TERRAFORM #
#############
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.31.0
hooks:
- id: terraform_fmt
- id: terraform_docs
- id: terraform_validate
########
# CHEF #
########
# - repo: https://github.com/belminf/pre-commit-chef # Need installed 'gem'. sudo apt install ruby. And then fail
# rev: v0.1.1
# hooks:
# - id: cookstyle
# - id: foodcritic
# args:
# - --tags ~chef15
# - --epic-fail chef14
- repo: https://github.com/mattlqx/pre-commit-ruby
rev: v1.2.6
hooks:
- id: rubocop
- id: foodcritic
- id: rspec
- id: chef-cookbook-version
- repo: https://github.com/pre-commit/mirrors-ruby-lint # Need installed 'gem'. sudo apt install ruby
rev: v2.3.1-1
hooks:
- id: ruby-lint
##########
# PYTHON #
##########
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.2.0
hooks:
- id: reorder-python-imports
language_version: python3
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.0.1
hooks:
- id: add-trailing-comma
language_version: python3
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.2
hooks:
- id: autopep8
language_version: python3
args:
- -i
- --max-line-length=100
# Usage: http://pylint.pycqa.org/en/latest/user_guide/message-control.html
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.2
hooks:
- id: pylint
language_version: python3
args:
- --disable=import-error # E0401. Locally you could not have all imports.
- --disable=fixme # W0511. 'TODO' notations.
- --disable=bad-continuation # Will be removed in pylint-2.6.0. Use wemake-python-styleguide.
- --disable=logging-fstring-interpolation # Conflict with "use a single formatting" WPS323
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.770
hooks:
- id: mypy
language_version: python3
args: [
--ignore-missing-imports,
--disallow-untyped-calls,
--warn-redundant-casts,
]
- repo: https://gitlab.com/pycqa/flake8.git
rev: 3.8.2
hooks:
- id: flake8
language_version: python3
additional_dependencies:
- flake8-2020
- flake8-docstrings
- flake8-pytest-style
- wemake-python-styleguide
args:
- --max-returns=2 # Default settings
- --max-arguments=4 # Default settings
# https://www.flake8rules.com/
# https://wemake-python-stylegui.de/en/latest/pages/usage/violations/index.html
- --extend-ignore=
WPS305, <!-- Found `f` string -->
E501, <!-- line too long (> 79 characters). Use 100 -->
I, <!-- opt out of using isort in favor of reorder-python-imports -->
RST, <!-- Conflict with DAR -->
#########
# SHELL # (AND OTHER)
#########
# - repo: https://github.com/jumanjihouse/pre-commit-hooks # Also ruby, also fail
# rev: 1.11.0
# hooks:
# - id: git-check # Configure in .gitattributes
# - id: git-dirty # Configure in .gitignore
# - id: markdownlint # Configure in .mdlrc
# - id: require-ascii
# - id: script-must-have-extension
# - id: script-must-not-have-extension
# - id: shellcheck
# - id: shfmt
- repo: git://github.com/detailyang/pre-commit-shell
rev: v1.0.6
hooks:
- id: shell-lint
args: [--format=json]
- repo: https://github.com/syntaqx/git-hooks
rev: v0.0.16
hooks:
- id: forbid-binary
- id: shellcheck
- id: shfmt
- repo: https://github.com/openstack/bashate
rev: 2.0.0
hooks:
- id: bashate
language_version: python3
args:
- --max-line-length=100
@MaxymVlasov

This comment has been minimized.

Copy link
Owner Author

@MaxymVlasov MaxymVlasov commented Aug 10, 2019

Install pre-commit hooks globally

DIR=~/.git-template
git config --global init.templateDir ${DIR}
pre-commit init-templatedir -t pre-commit ${DIR}
pre-commit init-templatedir -t commit-msg ${DIR}

=====

Starting from pre-commit > 0.18.3 (now have no tag, pip install git+) can be used next installation syntax:

pre-commit install --install-hooks -t pre-commit -t commit-msg

via pre-commit/pre-commit#1139

@MaxymVlasov

This comment has been minimized.

Copy link
Owner Author

@MaxymVlasov MaxymVlasov commented Aug 10, 2019

Universal hooks for Terraform

# See more at https://tinyurl.com/pre-commit-config

repos:
#######
# ALL #
#######
- repo: git://github.com/pre-commit/pre-commit-hooks
  rev: v2.5.0
  hooks:
    # Git style
    - id: check-added-large-files
    - id: check-merge-conflict
    - id: check-vcs-permalinks
    - id: forbid-new-submodules
    - id: no-commit-to-branch

    # Common errors
    - id: end-of-file-fixer
    - id: trailing-whitespace
      args: [--markdown-linebreak-ext=md]

    # Cross platform
    - id: check-case-conflict

    # Security
    - id: detect-aws-credentials
      args: ['--allow-missing-credentials']
    - id: detect-private-key


#############
# TERRAFORM #
#############
- repo: git://github.com/antonbabenko/pre-commit-terraform
  rev: v1.31.0
  hooks:
    - id: terraform_fmt
    - id: terraform_docs
    - id: terraform_validate
@MaxymVlasov

This comment has been minimized.

Copy link
Owner Author

@MaxymVlasov MaxymVlasov commented Mar 18, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.