.pre-commit-config.yaml 5.7 KB

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