.pre-commit-config.yaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. default_language_version:
  2. python: python3
  3. exclude: |
  4. (?x)^(
  5. .*thirdparty/.*|
  6. .*-so_wrap\.(h|c)$
  7. )
  8. repos:
  9. - repo: https://github.com/pre-commit/mirrors-clang-format
  10. rev: v19.1.3
  11. hooks:
  12. - id: clang-format
  13. files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java)$
  14. types_or: [text]
  15. exclude: |
  16. (?x)^(
  17. tests/python_build/.*|
  18. platform/android/java/editor/src/main/java/com/android/.*|
  19. platform/android/java/lib/src/com/.*
  20. )
  21. - id: clang-format
  22. name: clang-format-glsl
  23. files: \.glsl$
  24. types_or: [text]
  25. exclude: |
  26. (?x)^(
  27. tests/python_build/.*|
  28. platform/android/java/editor/src/main/java/com/android/.*|
  29. platform/android/java/lib/src/com/.*
  30. )
  31. args: ['-style=file:misc/utility/.clang-format-glsl']
  32. - repo: https://github.com/pocc/pre-commit-hooks
  33. rev: v1.3.5
  34. hooks:
  35. - id: clang-tidy
  36. files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java|glsl)$
  37. args: [--fix, --quiet, --use-color]
  38. types_or: [text]
  39. exclude: |
  40. (?x)^(
  41. tests/python_build/.*|
  42. platform/android/java/editor/src/main/java/com/android/.*|
  43. platform/android/java/lib/src/com/.*
  44. )
  45. additional_dependencies: [clang-tidy==19.1.0]
  46. require_serial: true
  47. stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy`
  48. - repo: https://github.com/astral-sh/ruff-pre-commit
  49. rev: v0.7.3
  50. hooks:
  51. - id: ruff
  52. args: [--fix]
  53. - id: ruff-format
  54. - repo: https://github.com/pre-commit/mirrors-mypy
  55. rev: v1.13.0
  56. hooks:
  57. - id: mypy
  58. files: \.py$
  59. types_or: [text]
  60. - repo: https://github.com/codespell-project/codespell
  61. rev: v2.3.0
  62. hooks:
  63. - id: codespell
  64. exclude: |
  65. (?x)^(
  66. platform/android/java/editor/src/main/java/com/android/.*|
  67. platform/android/java/lib/src/com/.*
  68. )
  69. additional_dependencies: [tomli]
  70. ### Requires Docker; look into alternative implementation.
  71. # - repo: https://github.com/comkieffer/pre-commit-xmllint.git
  72. # rev: 1.0.0
  73. # hooks:
  74. # - id: xmllint
  75. # language: docker
  76. # types_or: [text]
  77. # files: ^(doc/classes|.*/doc_classes)/.*\.xml$
  78. # args: [--schema, doc/class.xsd]
  79. - repo: local
  80. hooks:
  81. - id: make-rst
  82. name: make-rst
  83. language: python
  84. entry: python doc/tools/make_rst.py
  85. args: [doc/classes, modules, platform, --dry-run, --color]
  86. pass_filenames: false
  87. files: ^(doc/classes|.*/doc_classes)/.*\.xml$
  88. - id: doc-status
  89. name: doc-status
  90. language: python
  91. entry: python doc/tools/doc_status.py
  92. args: [doc/classes, modules/*/doc_classes, platform/*/doc_classes]
  93. pass_filenames: false
  94. files: ^(doc/classes|.*/doc_classes)/.*\.xml$
  95. - id: eslint
  96. name: eslint
  97. language: node
  98. entry: eslint
  99. files: ^(platform/web/js/|modules/|misc/dist/html/).*\.(js|html)$
  100. args:
  101. - --fix
  102. - --no-warn-ignored
  103. - --no-config-lookup
  104. - --config
  105. - platform/web/eslint.config.cjs
  106. additional_dependencies:
  107. - '@eslint/js@^9.3.0'
  108. - '@html-eslint/eslint-plugin@^0.24.1'
  109. - '@html-eslint/parser@^0.24.1'
  110. - '@stylistic/eslint-plugin@^2.1.0'
  111. - eslint@^9.3.0
  112. - eslint-plugin-html@^8.1.1
  113. - globals@^15.3.0
  114. - espree@^10.0.1
  115. - id: jsdoc
  116. name: jsdoc
  117. language: node
  118. entry: jsdoc
  119. files: ^platform/web/js/engine/(engine|config|features)\.js$
  120. args:
  121. - --template
  122. - platform/web/js/jsdoc2rst/
  123. - platform/web/js/engine/engine.js
  124. - platform/web/js/engine/config.js
  125. - platform/web/js/engine/features.js
  126. - --destination
  127. - ''
  128. - -d
  129. - dry-run
  130. pass_filenames: false
  131. additional_dependencies: [jsdoc@^4.0.3]
  132. - id: svgo
  133. name: svgo
  134. language: node
  135. entry: svgo
  136. files: \.svg$
  137. args: [--quiet, --config, misc/utility/svgo.config.mjs]
  138. additional_dependencies: [svgo@3.3.2]
  139. - id: copyright-headers
  140. name: copyright-headers
  141. language: python
  142. entry: python misc/scripts/copyright_headers.py
  143. files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java)$
  144. exclude: |
  145. (?x)^(
  146. core/math/bvh_.*\.inc$|
  147. platform/(?!android|ios|linuxbsd|macos|web|windows)\w+/.*|
  148. platform/android/java/editor/src/main/java/com/android/.*|
  149. platform/android/java/lib/src/com/.*|
  150. platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView\.java$|
  151. platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper\.java$|
  152. platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix\.java$
  153. )
  154. - id: header-guards
  155. name: header-guards
  156. language: python
  157. entry: python misc/scripts/header_guards.py
  158. files: \.(h|hpp|hh|hxx)$
  159. exclude: ^.*/(thread|platform_config|platform_gl)\.h$
  160. - id: file-format
  161. name: file-format
  162. language: python
  163. entry: python misc/scripts/file_format.py
  164. types_or: [text]
  165. exclude: |
  166. (?x)^(
  167. .*\.test\.txt$|
  168. .*\.svg$|
  169. .*\.patch$|
  170. .*\.out$|
  171. modules/gdscript/tests/scripts/parser/features/mixed_indentation_on_blank_lines\.gd$|
  172. modules/gdscript/tests/scripts/parser/warnings/empty_file_newline_comment\.norun\.gd$|
  173. modules/gdscript/tests/scripts/parser/warnings/empty_file_newline\.norun\.gd$|
  174. platform/android/java/editor/src/main/java/com/android/.*|
  175. platform/android/java/lib/src/com/google/.*|
  176. tests/data/.*\.bin$
  177. )
  178. - id: dotnet-format
  179. name: dotnet-format
  180. language: python
  181. entry: python misc/scripts/dotnet_format.py
  182. types_or: [c#]
  183. #
  184. # End of upstream Godot pre-commit hooks.
  185. #
  186. # Keep this separation to let downstream forks add their own hooks to this file,
  187. # without running into merge conflicts when rebasing on latest upstream.
  188. #
  189. # Start of downstream pre-commit hooks.
  190. #
  191. # This is still the "repo: local" scope, so new local hooks can be defined directly at this indentation:
  192. # - id: new-local-hook
  193. # To add external repo hooks, bring the indentation back to:
  194. # - repo: my-remote-hook