.pre-commit-config.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. # Update versions with:
  5. # pre-commit autoupdate --freeze && pre-commit run -a
  6. # See https://pre-commit.com for more information
  7. # See https://pre-commit.com/hooks.html for more hooks
  8. default_language_version:
  9. python: python3 # Defaults to python2, so override it.
  10. repos:
  11. - repo: https://github.com/pre-commit/pre-commit-hooks
  12. rev: 38b88246ccc552bffaaf54259d064beeee434539 # frozen: v4.0.1
  13. hooks:
  14. - id: check-added-large-files
  15. - id: check-case-conflict
  16. - id: check-executables-have-shebangs
  17. - id: check-merge-conflict
  18. - id: check-symlinks
  19. exclude: ^bazel-(clang-toolchain|execroot)$
  20. - id: check-yaml
  21. - id: detect-private-key
  22. - id: end-of-file-fixer
  23. - id: mixed-line-ending
  24. args: ['--fix=lf']
  25. - id: trailing-whitespace
  26. exclude: '^(.*/testdata/.*\.golden)$'
  27. - repo: https://github.com/mattlqx/pre-commit-search-and-replace
  28. rev: 417c99dafb534d7517d9abc17f0293de3c915a72 # frozen: v1.0.5
  29. hooks:
  30. - id: search-and-replace
  31. files: '\.md$'
  32. - repo: https://github.com/google/pre-commit-tool-hooks
  33. rev: 26cc20f971cad7dee54e1fcccb960b4e19b2bdce # frozen: v1.2.1
  34. hooks:
  35. - id: check-copyright
  36. args:
  37. - --copyright
  38. - |+
  39. Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  40. Exceptions. See /LICENSE for license information.
  41. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  42. - --custom_format
  43. - '\.carbon$'
  44. - ''
  45. - '// '
  46. - ''
  47. - --custom_format
  48. - '\.lpp$'
  49. - '/*'
  50. - ''
  51. - '*/'
  52. - --custom_format
  53. - '\.ypp$'
  54. - ''
  55. - '// '
  56. - ''
  57. - --custom_format
  58. - '\.l$'
  59. - '/*'
  60. - ''
  61. - '*/'
  62. - --custom_format
  63. - '\.y$'
  64. - '/*'
  65. - ''
  66. - '*/'
  67. exclude: |
  68. (?x)^(
  69. .bazelversion|
  70. compile_flags.txt|
  71. third_party/examples/.*/compile_flags.carbon.txt|
  72. .*\.def|
  73. .*\.svg|
  74. .*/testdata/.*\.golden
  75. )$
  76. - id: check-google-doc-style
  77. - id: check-links
  78. name: Check links in non-proposal files
  79. exclude: ^proposals/.*$
  80. - id: check-links
  81. name: Check links in proposal files
  82. args: ['--anchors-only']
  83. files: ^proposals/.*$
  84. - id: markdown-toc
  85. - repo: https://github.com/codespell-project/codespell
  86. rev: 01da43d753cdff4ea7dff952b4f5317450af31e3 # frozen: v2.1.0
  87. hooks:
  88. - id: codespell
  89. args: ['-I', '.codespell_ignore', '--uri-ignore-words-list', '*']
  90. - repo: local
  91. hooks:
  92. - id: executable-semantics-format-grammar
  93. name: Format the executable_semantics grammar file
  94. entry: executable_semantics/syntax/format_grammar.py
  95. language: python
  96. files: ^executable_semantics/syntax/(lexer.lpp|parser.ypp)$
  97. pass_filenames: false
  98. - id: fix-cc-deps
  99. name: Fix missing C++ deps
  100. entry: scripts/fix_cc_deps.py
  101. language: python
  102. files: ^.*/(BUILD|[^/]+\.(h|cpp))$
  103. pass_filenames: false
  104. # Formatters should be run late so that they can re-format any prior changes.
  105. - repo: https://github.com/psf/black
  106. rev: 19f6aa8208154de4560ee1e4a3e638e120dcdba5 # frozen: 21.11b1
  107. hooks:
  108. - id: black
  109. - repo: https://github.com/jlebar/pre-commit-hooks.git
  110. rev: fb5e481f35f5a9b32a06ccfc28b8d6dda4525f75
  111. hooks:
  112. - id: bazel-buildifier
  113. - id: clang-format-whole-file
  114. types: [c++]
  115. - repo: https://github.com/pre-commit/mirrors-prettier
  116. rev: f69d0a4007f48ad4f144089973c56f6ecf53a5b5 # frozen: v2.5.0
  117. hooks:
  118. - id: prettier
  119. # Run linters last, as formatters and other checks may fix issues.
  120. - repo: https://github.com/PyCQA/flake8
  121. rev: cbeb4c9c4137cff1568659fcc48e8b85cddd0c8d # frozen: 4.0.1
  122. hooks:
  123. - id: flake8
  124. # Most third-party code is in submodules; local commits are excluded here.
  125. # We fully exclude fuzzer corpus directories as they are generated binary data.
  126. exclude: |
  127. (?x)^(
  128. third_party/examples/.*/carbon/.*|
  129. .*/fuzzer_corpus/.*
  130. )$