.pre-commit-config.yaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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: ^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: 1d04a2848ac54d64bd6474ccec69aac45fa88414 # frozen: v1.1.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: 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. - repo: local
  84. hooks:
  85. - id: executable-semantics-format-grammar
  86. name: Format the executable_semantics grammar file
  87. entry: executable_semantics/syntax/format_grammar.py
  88. language: python
  89. files: ^executable_semantics/syntax/parser.ypp$
  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: 911470a610e47d9da5ea938b0887c3df62819b85 # frozen: 21.9b0
  94. hooks:
  95. - id: black
  96. - repo: https://github.com/jlebar/pre-commit-hooks.git
  97. rev: a0f1c385f6a50581983008c8737ca72473ecf3ad
  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: 6e24ff01ab7d5e64045599b81c4cd34d6a6a7159 # frozen: v2.4.1
  104. hooks:
  105. - id: prettier
  106. # Run linters last, as formatters and other checks may fix issues.
  107. - repo: https://github.com/PyCQA/flake8
  108. rev: dcd740bc0ebaf2b3d43e59a0060d157c97de13f3 # frozen: 3.9.2
  109. hooks:
  110. - id: flake8
  111. # Most third-party code is in submodules; local commits are excluded here.
  112. # We fully exclude fuzzer corpus directories as they are generated binary data.
  113. exclude: |
  114. (?x)^(
  115. third_party/examples/.*/carbon/.*|
  116. .*/fuzzer_corpus/.*
  117. )$