daml/.pre-commit-config.yaml
Claudio Bley ca1453ee8c
Add pre-commit config and install hook in dev-env (#15637)
* Add `pre-commit` tool to dev-env

* Add pre-commit configuration

Fixes #15522

* Install pre-commit hooks inside the nix shell

* Limit buildifier hook to files to be comitted

The `:buildifier-fix` tool always runs on all Bazel files (by calling `find`),
which is not useful when using pre-commit.

* Install pre-commit hook only when `DADE_NO_PRE_COMMIT` is unset

Since direnv does not execute the shellHook, install in `.envrc` too.
2022-12-07 13:09:50 +00:00

48 lines
1.3 KiB
YAML

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: hlint
name: hlint
language: system
entry: "hlint -j"
require_serial: true
types: [haskell]
- id: scalafmt
name: scalafmt
language: system
require_serial: true
entry: "scalafmt --respect-project-filters"
types: [scala]
- id: javafmt
name: javafmt
language: system
require_serial: true
entry: "javafmt --set-exit-if-changed --replace"
types: [java]
- id: buildifier
name: buildifier
language: system
require_serial: true
entry: "bazel run //:buildifier-pre-commit -- -mode=fix -v=true"
types: [bazel]
- id: pprettier
name: pprettier
language: system
require_serial: true
entry: "bash -c 'yarn install --silent && yarn run pprettier --write \"$@\"'"
types: [ts]
- id: copyrights
name: copyright headers
description: Idempotently add DA copyright headers to source files.
language: system
pass_filenames: false
entry: "dade-copyright-headers update"
types: [text]