2
0

.pre-commit-config.yaml 6.0 KB

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