.pre-commit-config.yaml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.8.4
  50. hooks:
  51. - id: ruff
  52. args: [--fix]
  53. files: (\.py|SConstruct|SCsub)$
  54. types_or: [text]
  55. - id: ruff-format
  56. files: (\.py|SConstruct|SCsub)$
  57. types_or: [text]
  58. - repo: https://github.com/pre-commit/mirrors-mypy
  59. rev: v1.13.0
  60. hooks:
  61. - id: mypy
  62. files: \.py$
  63. types_or: [text]
  64. - repo: https://github.com/codespell-project/codespell
  65. rev: v2.3.0
  66. hooks:
  67. - id: codespell
  68. exclude: |
  69. (?x)^(
  70. platform/android/java/editor/src/main/java/com/android/.*|
  71. platform/android/java/lib/src/com/.*
  72. )
  73. additional_dependencies: [tomli]
  74. ### Requires Docker; look into alternative implementation.
  75. # - repo: https://github.com/comkieffer/pre-commit-xmllint.git
  76. # rev: 1.0.0
  77. # hooks:
  78. # - id: xmllint
  79. # language: docker
  80. # types_or: [text]
  81. # files: ^(doc/classes|.*/doc_classes)/.*\.xml$
  82. # args: [--schema, doc/class.xsd]
  83. - repo: local
  84. hooks:
  85. - id: make-rst
  86. name: make-rst
  87. language: python
  88. entry: python doc/tools/make_rst.py
  89. args: [doc/classes, modules, platform, --dry-run, --color]
  90. pass_filenames: false
  91. files: ^(doc/classes|.*/doc_classes)/.*\.xml$
  92. - id: doc-status
  93. name: doc-status
  94. language: python
  95. entry: python doc/tools/doc_status.py
  96. args: [doc/classes, modules/*/doc_classes, platform/*/doc_classes, -c]
  97. pass_filenames: false
  98. files: ^(doc/classes|.*/doc_classes)/.*\.xml$
  99. - id: eslint
  100. name: eslint
  101. language: node
  102. entry: eslint
  103. files: ^(platform/web/js/|modules/|misc/dist/html/).*\.(js|html)$
  104. args:
  105. - --fix
  106. - --no-warn-ignored
  107. - --no-config-lookup
  108. - --config
  109. - platform/web/eslint.config.cjs
  110. additional_dependencies:
  111. - '@eslint/js@^9.3.0'
  112. - '@html-eslint/eslint-plugin@^0.24.1'
  113. - '@html-eslint/parser@^0.24.1'
  114. - '@stylistic/eslint-plugin@^2.1.0'
  115. - eslint@^9.3.0
  116. - eslint-plugin-html@^8.1.1
  117. - globals@^15.3.0
  118. - espree@^10.0.1
  119. - id: jsdoc
  120. name: jsdoc
  121. language: node
  122. entry: jsdoc
  123. files: ^platform/web/js/engine/(engine|config|features)\.js$
  124. args:
  125. - --template
  126. - platform/web/js/jsdoc2rst/
  127. - platform/web/js/engine/engine.js
  128. - platform/web/js/engine/config.js
  129. - platform/web/js/engine/features.js
  130. - --destination
  131. - ''
  132. - -d
  133. - dry-run
  134. pass_filenames: false
  135. additional_dependencies: [jsdoc@^4.0.3]
  136. - id: svgo
  137. name: svgo
  138. language: node
  139. entry: svgo
  140. files: \.svg$
  141. args: [--quiet, --config, misc/utility/svgo.config.mjs]
  142. additional_dependencies: [[email protected]]
  143. - id: copyright-headers
  144. name: copyright-headers
  145. language: python
  146. entry: python misc/scripts/copyright_headers.py
  147. files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java)$
  148. exclude: |
  149. (?x)^(
  150. core/math/bvh_.*\.inc$|
  151. platform/(?!android|ios|linuxbsd|macos|web|windows)\w+/.*|
  152. platform/android/java/editor/src/main/java/com/android/.*|
  153. platform/android/java/lib/src/com/.*|
  154. platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView\.java$|
  155. platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper\.java$|
  156. platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix\.java$
  157. )
  158. - id: header-guards
  159. name: header-guards
  160. language: python
  161. entry: python misc/scripts/header_guards.py
  162. files: \.(h|hpp|hh|hxx)$
  163. exclude: ^.*/(dummy|thread|platform_config|platform_gl)\.h$
  164. - id: file-format
  165. name: file-format
  166. language: python
  167. entry: python misc/scripts/file_format.py
  168. types_or: [text]
  169. exclude: |
  170. (?x)^(
  171. .*\.test\.txt$|
  172. .*\.svg$|
  173. .*\.patch$|
  174. .*\.out$|
  175. modules/gdscript/tests/scripts/parser/features/mixed_indentation_on_blank_lines\.gd$|
  176. modules/gdscript/tests/scripts/parser/warnings/empty_file_newline_comment\.norun\.gd$|
  177. modules/gdscript/tests/scripts/parser/warnings/empty_file_newline\.norun\.gd$|
  178. platform/android/java/editor/src/main/java/com/android/.*|
  179. platform/android/java/lib/src/com/google/.*|
  180. tests/data/.*\.bin$
  181. )
  182. - id: dotnet-format
  183. name: dotnet-format
  184. language: python
  185. entry: python misc/scripts/dotnet_format.py
  186. types_or: [c#]
  187. #
  188. # End of upstream Godot pre-commit hooks.
  189. #
  190. # Keep this separation to let downstream forks add their own hooks to this file,
  191. # without running into merge conflicts when rebasing on latest upstream.
  192. #
  193. # Start of downstream pre-commit hooks.
  194. #
  195. # This is still the "repo: local" scope, so new local hooks can be defined directly at this indentation:
  196. # - id: new-local-hook
  197. # To add external repo hooks, bring the indentation back to:
  198. # - repo: my-remote-hook