.pre-commit-config.yaml 4.0 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. # Update versions with:
  5. # pre-commit autoupdate --freeze && pre-commit run -a
  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: b7dadde912123577a1b5d4bfa279ce51ed06ee49 # frozen: v1.2.0
  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: check-links
  78. - id: markdown-toc
  79. - repo: https://github.com/codespell-project/codespell
  80. rev: 01da43d753cdff4ea7dff952b4f5317450af31e3 # frozen: v2.1.0
  81. hooks:
  82. - id: codespell
  83. args: ['-I', '.codespell_ignore', '--uri-ignore-words-list', '*']
  84. - repo: local
  85. hooks:
  86. - id: executable-semantics-format-grammar
  87. name: Format the executable_semantics grammar file
  88. entry: executable_semantics/syntax/format_grammar.py
  89. language: python
  90. files: ^executable_semantics/syntax/(lexer.lpp|parser.ypp)$
  91. pass_filenames: false
  92. # Formatters should be run late so that they can re-format any prior changes.
  93. - repo: https://github.com/psf/black
  94. rev: 19f6aa8208154de4560ee1e4a3e638e120dcdba5 # frozen: 21.11b1
  95. hooks:
  96. - id: black
  97. - repo: https://github.com/jlebar/pre-commit-hooks.git
  98. rev: fb5e481f35f5a9b32a06ccfc28b8d6dda4525f75
  99. hooks:
  100. - id: bazel-buildifier
  101. - id: clang-format-whole-file
  102. types: [c++]
  103. - repo: https://github.com/pre-commit/mirrors-prettier
  104. rev: f69d0a4007f48ad4f144089973c56f6ecf53a5b5 # frozen: v2.5.0
  105. hooks:
  106. - id: prettier
  107. # Run linters last, as formatters and other checks may fix issues.
  108. - repo: https://github.com/PyCQA/flake8
  109. rev: cbeb4c9c4137cff1568659fcc48e8b85cddd0c8d # frozen: 4.0.1
  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. )$