.pre-commit-config.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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-tests
  81. name: Update list of executable_semantics tests
  82. description: Updates executable_semantics/test_list.bzl
  83. entry: executable_semantics/tests.py
  84. language: python
  85. files: ^executable_semantics/(test_list.bzl|testdata/.*\.carbon)$
  86. pass_filenames: false
  87. args: ['--update_list', '--use_git_ls_files']
  88. - id: proposal-list
  89. name: Update list of proposals
  90. description: Updates the list of proposals in proposals/README.md
  91. entry: proposals/scripts/update_proposal_list.py
  92. language: python
  93. files: ^proposals/(README|p.*)\.md$
  94. pass_filenames: false
  95. # Formatters should be run late so that they can re-format any prior changes.
  96. - repo: https://github.com/psf/black
  97. rev: e3000ace2fd1fcb1c181bb7a8285f1f976bcbdc7 # frozen: 21.7b0
  98. hooks:
  99. - id: black
  100. - repo: https://github.com/jlebar/pre-commit-hooks.git
  101. rev: 07a539b8db43298f124ace23c90b4b871911b8c4
  102. hooks:
  103. - id: bazel-buildifier
  104. - id: clang-format-whole-file
  105. types: [c++]
  106. - repo: https://github.com/pre-commit/mirrors-prettier
  107. rev: bc48c541add1551be726f23c4294c773442341cb # frozen: v2.3.2
  108. hooks:
  109. - id: prettier
  110. # Run linters last, as formatters and other checks may fix issues.
  111. - repo: https://gitlab.com/PyCQA/flake8
  112. rev: dcd740bc0ebaf2b3d43e59a0060d157c97de13f3 # frozen: 3.9.2
  113. hooks:
  114. - id: flake8
  115. # Most third-party code is in submodules; local commits are excluded here.
  116. # We fully exclude fuzzer corpus directories as they are generated binary data.
  117. exclude: |
  118. (?x)^(
  119. third_party/examples/.*/carbon/.*|
  120. .*/fuzzer_corpus/.*
  121. )$