.pre-commit-config.yaml 5.0 KB

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