.pre-commit-config.yaml 5.9 KB

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