Pre-commit is a tool to simplify the use of linter when working on a multi-language environment.

The most general .pre-commit-config.yaml file I use is:

repos:
  # General
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.3.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-added-large-files
  # Commitizen
  - repo: https://github.com/commitizen-tools/commitizen
    rev: v2.35.0
    hooks:
      - id: commitizen
        stages: [commit-msg]
  # Docker
  - repo: https://github.com/hadolint/hadolint
    rev: v2.10.0
    hooks:
      - id: hadolint
        types: [file]
        files: "Dockerfile.*"
        args: ["--ignore=DL3008"]
        # DL3008: Pin versions in apt-get install.
  # Python
  - repo: https://github.com/asottile/pyupgrade
    rev: v2.38.0
    hooks:
      - id: pyupgrade
        args: ["--py310-plus"]
  - repo: https://github.com/pycqa/isort
    rev: 5.10.1
    hooks:
      - id: isort
        name: isort (python)
        args:
          - --profile=black
          - --line-length=120
        # isort can't find local imports if the path of the local packages are not relative from the root of the repo.
        # In this case, packages need to be added here
        # - --known-local-folder=
  - repo: https://github.com/psf/black
    rev: 22.8.0
    hooks:
      - id: black-jupyter
        args:
          - --line-length=120
          - --target-version=py310
  - repo: https://github.com/PyCQA/flake8
    rev: 5.0.4
    hooks:
      - id: flake8
        additional_dependencies:
          - flake8-bugbear
          - flake8-implicit-str-concat
          - flake8-annotations
        args: ["--max-line-length=120", "--ignore=ANN204,ANN101,ANN102,ANN002,ANN003,E203,W503"]
        # we ignore errors
        # -ANN204: "Missing return type annotation for special method"
        # -ANN101: "Missing type annotation for self in method"
        # -ANN102 "Missing type annotation for cls in classmethod"
        # -ANN002 "Missing type annotation for *args"
        # -ANN003 "Missing type annotation for *kwargs"
        # -W503 "Line break occurred before a binary operator" See https://www.flake8rules.com/rules/W503.html
        # -E203:  whitespace before ':' because pep8 is wrong here. See https://github.com/psf/black/issues/315
  - repo: https://github.com/dosisod/refurb
    rev: v1.3.0
    hooks:
      - id: refurb
  # C/C++
  - repo: https://github.com/pre-commit/mirrors-clang-format
    rev: "v14.0.3"
    hooks:
      - id: clang-format
        args: [--style=Google, -i]
  # JS
  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v3.0.0-alpha.0
    hooks:
      - id: prettier
        args: ["--print-width=120"]
        stages: [commit]
  - repo: https://github.com/pre-commit/mirrors-eslint
    rev: v8.16.0
    hooks:
      - id: eslint
        additional_dependencies:
          - eslint@8.16.0
          - eslint-config-google@0.7.1
          - eslint-loader@1.6.1
          - eslint-plugin-react@6.10.3
          - babel-eslint@6.1.2
          - eslint-config-prettier@8.5.0

for es-lint you also need this file .eslintrc:

{
  "extends": ["eslint:recommended", "prettier"],
  "env": {
    "browser": true,
    "node": true,
    "es2021": true
  },
  "rules": {
    "no-console": 0
  },
  "parserOptions": {
    "sourceType": "module"
  }
}