.pre-commit-config.yaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. # See https://pre-commit.com for more information
  5. # See https://pre-commit.com/hooks.html for more hooks
  6. default_language_version:
  7. python: python3 # Defaults to python2, so override it.
  8. repos:
  9. - repo: https://github.com/pre-commit/pre-commit-hooks
  10. rev: 6e2418c5521b7d606e72914dced3253f9ace1205 # frozen: v3.4.0
  11. hooks:
  12. - id: check-added-large-files
  13. - id: check-case-conflict
  14. - id: check-executables-have-shebangs
  15. - id: check-merge-conflict
  16. - id: check-symlinks
  17. exclude: |
  18. (?x)^(
  19. website/jekyll/site/_includes|
  20. bazel-(clang-toolchain|execroot)
  21. )$
  22. - id: check-yaml
  23. - id: detect-private-key
  24. - id: end-of-file-fixer
  25. - id: mixed-line-ending
  26. args: ['--fix=lf']
  27. - id: trailing-whitespace
  28. exclude: '^(.*/testdata/.*\.golden)$'
  29. - repo: https://github.com/google/pre-commit-tool-hooks
  30. rev: 1d04a2848ac54d64bd6474ccec69aac45fa88414 # frozen: v1.1.1
  31. hooks:
  32. - id: check-copyright
  33. args:
  34. - --copyright
  35. - |+
  36. Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  37. Exceptions. See /LICENSE for license information.
  38. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  39. - --custom_format
  40. - '\.carbon$'
  41. - ''
  42. - '// '
  43. - ''
  44. - --custom_format
  45. - '\.lpp$'
  46. - '/*'
  47. - ''
  48. - '*/'
  49. - --custom_format
  50. - '\.ypp$'
  51. - ''
  52. - '// '
  53. - ''
  54. - --custom_format
  55. - '\.l$'
  56. - '/*'
  57. - ''
  58. - '*/'
  59. - --custom_format
  60. - '\.y$'
  61. - '/*'
  62. - ''
  63. - '*/'
  64. exclude: |
  65. (?x)^(
  66. .bazelversion|
  67. compile_flags.txt|
  68. third_party/examples/.*/compile_flags.carbon.txt|
  69. website/(firebase/.firebaserc|jekyll/(Gemfile.lock|theme/.*))|
  70. .*\.def|
  71. .*\.svg|
  72. .*/testdata/.*\.golden
  73. )$
  74. - id: check-google-doc-style
  75. - id: markdown-toc
  76. - repo: https://github.com/codespell-project/codespell
  77. rev: 67c489d36dd4c52cbb9e4755d90c35c6231842ef # frozen: v2.0.0
  78. hooks:
  79. - id: codespell
  80. args: ['-I', '.codespell_ignore']
  81. exclude: '^website/jekyll/Gemfile.lock$'
  82. - repo: local
  83. hooks:
  84. - id: proposal-list
  85. name: Update list of proposals
  86. description: Updates the list of proposals in proposals/README.md
  87. entry: proposals/scripts/update_proposal_list.py
  88. language: python
  89. files: ^proposals/(README|p.*)\.md$
  90. pass_filenames: false
  91. # Formatters should be run late so that they can re-format any prior changes.
  92. - repo: https://github.com/psf/black
  93. rev: e66be67b9b6811913470f70c28b4d50f94d05b22 # frozen: 20.8b1
  94. hooks:
  95. - id: black
  96. - repo: https://github.com/jlebar/pre-commit-hooks.git
  97. rev: 07a539b8db43298f124ace23c90b4b871911b8c4
  98. hooks:
  99. - id: bazel-buildifier
  100. - id: clang-format-whole-file
  101. types: [c++]
  102. - repo: https://github.com/pre-commit/mirrors-prettier
  103. rev: 8e0d199f4004a7f226ed7974fc3883d9c702bded # frozen: v2.2.1
  104. hooks:
  105. - id: prettier
  106. exclude: ^website/jekyll/theme/
  107. # Run linters last, as formatters and other checks may fix issues.
  108. - repo: https://gitlab.com/PyCQA/flake8
  109. rev: 56370aae451722f9d77a5ccd6fb6e231a4a8e651 # frozen: 3.9.0
  110. hooks:
  111. - id: flake8
  112. # Most third-party code is in submodules; local commits are excluded here.
  113. # We fully exclude fuzzer corpus directories as they are generated binary data.
  114. exclude: |
  115. (?x)^(
  116. third_party/examples/.*/carbon/.*|
  117. .*/fuzzer_corpus/.*
  118. )$