.pre-commit-config.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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
  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: |
  20. (?x)^(
  21. website/jekyll/site/_includes|
  22. bazel-(clang-toolchain|execroot)
  23. )$
  24. - id: check-yaml
  25. - id: detect-private-key
  26. - id: end-of-file-fixer
  27. - id: mixed-line-ending
  28. args: ['--fix=lf']
  29. - id: trailing-whitespace
  30. exclude: '^(.*/testdata/.*\.golden)$'
  31. - repo: https://github.com/google/pre-commit-tool-hooks
  32. rev: 1d04a2848ac54d64bd6474ccec69aac45fa88414 # frozen: v1.1.1
  33. hooks:
  34. - id: check-copyright
  35. args:
  36. - --copyright
  37. - |+
  38. Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  39. Exceptions. See /LICENSE for license information.
  40. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  41. - --custom_format
  42. - '\.carbon$'
  43. - ''
  44. - '// '
  45. - ''
  46. - --custom_format
  47. - '\.lpp$'
  48. - '/*'
  49. - ''
  50. - '*/'
  51. - --custom_format
  52. - '\.ypp$'
  53. - ''
  54. - '// '
  55. - ''
  56. - --custom_format
  57. - '\.l$'
  58. - '/*'
  59. - ''
  60. - '*/'
  61. - --custom_format
  62. - '\.y$'
  63. - '/*'
  64. - ''
  65. - '*/'
  66. exclude: |
  67. (?x)^(
  68. .bazelversion|
  69. compile_flags.txt|
  70. third_party/examples/.*/compile_flags.carbon.txt|
  71. website/(firebase/.firebaserc|jekyll/(Gemfile.lock|theme/.*))|
  72. .*\.def|
  73. .*\.svg|
  74. .*/testdata/.*\.golden
  75. )$
  76. - id: check-google-doc-style
  77. - id: markdown-toc
  78. - repo: https://github.com/codespell-project/codespell
  79. rev: 01da43d753cdff4ea7dff952b4f5317450af31e3 # frozen: v2.1.0
  80. hooks:
  81. - id: codespell
  82. args: ['-I', '.codespell_ignore', '--uri-ignore-words-list', '*']
  83. exclude: '^website/jekyll/Gemfile.lock$'
  84. - repo: local
  85. hooks:
  86. - id: executable-semantics-tests
  87. name: Update list of executable_semantics tests
  88. description: Updates executable_semantics/test_list.bzl
  89. entry: executable_semantics/tests.py
  90. language: python
  91. files: ^executable_semantics/(test_list.bzl|testdata/.*\.carbon)$
  92. pass_filenames: false
  93. args: ['--update_list', '--use_git_ls_files']
  94. - id: proposal-list
  95. name: Update list of proposals
  96. description: Updates the list of proposals in proposals/README.md
  97. entry: proposals/scripts/update_proposal_list.py
  98. language: python
  99. files: ^proposals/(README|p.*)\.md$
  100. pass_filenames: false
  101. # Formatters should be run late so that they can re-format any prior changes.
  102. - repo: https://github.com/psf/black
  103. rev: 93c10bf9ebccf8d7cc686b0b9579f2e5e41c5328 # frozen: 21.6b0
  104. hooks:
  105. - id: black
  106. - repo: https://github.com/jlebar/pre-commit-hooks.git
  107. rev: 07a539b8db43298f124ace23c90b4b871911b8c4
  108. hooks:
  109. - id: bazel-buildifier
  110. - id: clang-format-whole-file
  111. types: [c++]
  112. - repo: https://github.com/pre-commit/mirrors-prettier
  113. rev: bc48c541add1551be726f23c4294c773442341cb # frozen: v2.3.2
  114. hooks:
  115. - id: prettier
  116. exclude: ^website/jekyll/theme/
  117. # Run linters last, as formatters and other checks may fix issues.
  118. - repo: https://gitlab.com/PyCQA/flake8
  119. rev: dcd740bc0ebaf2b3d43e59a0060d157c97de13f3 # frozen: 3.9.2
  120. hooks:
  121. - id: flake8
  122. # Most third-party code is in submodules; local commits are excluded here.
  123. # We fully exclude fuzzer corpus directories as they are generated binary data.
  124. exclude: |
  125. (?x)^(
  126. third_party/examples/.*/carbon/.*|
  127. .*/fuzzer_corpus/.*
  128. )$