.pre-commit-config.yaml 4.0 KB

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