.pre-commit-config.yaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ---
  2. exclude: (?x)^( htdocs/includes/ckeditor/.* )
  3. repos:
  4. # Several miscellaneous checks and fix (on yaml files, end of files fix)
  5. - repo: https://github.com/pre-commit/pre-commit-hooks
  6. rev: v4.5.0
  7. hooks:
  8. - id: no-commit-to-branch
  9. args: [--branch, develop, --pattern, \d+.0$]
  10. - id: check-yaml
  11. args: [--unsafe]
  12. - id: check-json
  13. - id: mixed-line-ending
  14. exclude: (?x)^(htdocs/includes/tecnickcom/tcpdf/fonts/.*)$
  15. - id: trailing-whitespace
  16. exclude_types: [markdown]
  17. - id: end-of-file-fixer
  18. - id: check-merge-conflict
  19. - id: check-executables-have-shebangs
  20. - id: check-shebang-scripts-are-executable
  21. exclude:
  22. (?x)^( dev/tools/dolibarr-postgres2mysql.php |test/other/test_serialize.php
  23. |test/phpunit/textutf8.txt |test/phpunit/textiso.txt |htdocs/includes/.*
  24. |htdocs/modulebuilder/template/.* |build/debian/dolibarr.postrm |build/debian/dolibarr.postinst
  25. |build/debian/dolibarr.config )$
  26. - id: fix-byte-order-marker
  27. - id: check-case-conflict
  28. # Beautify shell scripts
  29. - repo: https://github.com/gitleaks/gitleaks.git
  30. rev: v8.16.1
  31. hooks:
  32. - id: gitleaks
  33. # Beautify shell scripts
  34. - repo: https://github.com/lovesegfault/beautysh.git
  35. rev: v6.2.1
  36. hooks:
  37. - id: beautysh
  38. exclude: (?x)^(dev/setup/git/hooks/pre-commit)$
  39. args: [--tab]
  40. # Run local script
  41. #
  42. # For instance to update the license in edited files, you could add to local.sh:
  43. #
  44. # ```shell
  45. # #!/bin/bash
  46. # MYDIR=$(dirname "$0")
  47. # CHANGED_INTERNALS=$(git diff --name-only | grep -v includes)
  48. # "$MYDIR/dev/tools/updatelicense.php" $CHANGED_INTERNALS
  49. # ```
  50. - repo: local
  51. hooks:
  52. - id: local-precommit-script
  53. name: Run local script before commit if it exists
  54. language: system
  55. entry: bash -c '[ ! -x local.sh ] || ./local.sh'
  56. pass_filenames: false
  57. # Check PHP syntax
  58. - repo: https://github.com/mdeweerd/pre-commit-php
  59. rev: v1.6.5
  60. hooks:
  61. - id: php-cbf
  62. files: \.(php)$
  63. args: [--standard=dev/setup/codesniffer/ruleset.xml]
  64. - id: php-cs
  65. files: \.(php)$
  66. args:
  67. [
  68. --standard=dev/setup/codesniffer/ruleset.xml,
  69. --report=emacs,
  70. --severity=5,
  71. ]
  72. - alias: php-cs-with-cache
  73. id: php-cs
  74. # Configuration for ci - run on all files with cache
  75. stages: [manual]
  76. args:
  77. [
  78. --standard=dev/setup/codesniffer/ruleset.xml,
  79. --report=emacs,
  80. --severity=5,
  81. --cache=.cache/pre-commit/dolibarr-php-cs.cache,
  82. .,
  83. ]
  84. pass_filenames: false # Run on all files
  85. - id: php-lint
  86. exclude:
  87. (?x)^(htdocs/includes/symfony/var-dumper/Tests/.*)$
  88. - id: php-stan
  89. stages: [manual]
  90. files: \.(php)$
  91. # Prettier (format code, only for non common files)
  92. - repo: https://github.com/pre-commit/mirrors-prettier
  93. rev: v3.0.3
  94. hooks:
  95. - id: prettier
  96. stages: [manual]
  97. exclude:
  98. (?x)^( .*\.(phar |min\.css |lock) |htdocs/(includes|theme/common)/.*
  99. )$
  100. exclude_types:
  101. - php
  102. - executable
  103. - binary
  104. - shell
  105. - javascript
  106. - markdown
  107. - html
  108. - less
  109. - plain-text
  110. - scss
  111. - css
  112. - yaml
  113. # Check format of yaml files
  114. - repo: https://github.com/adrienverge/yamllint.git
  115. rev: v1.33.0
  116. hooks:
  117. - id: yamllint
  118. args:
  119. - --no-warnings
  120. - -d
  121. - "{extends: relaxed, rules: {line-length: {max: 120}}}"
  122. # Execute codespell to fix typo errors (setup of codespell into dev/tools/codespell/)
  123. - repo: https://github.com/codespell-project/codespell
  124. rev: v2.2.6
  125. hooks:
  126. - id: codespell
  127. # Due to a current limitation of configuration files,
  128. # we can specify two dicts only on the CLI.
  129. # You can update the contents of the exclude-file codespell-lines-ignore with the script
  130. # dev/tools/codespell/addCodespellIgnores.sh
  131. args:
  132. - -D
  133. - "-"
  134. - -D
  135. - dev/tools/codespell/codespell-dict.txt
  136. - -I
  137. - dev/tools/codespell/codespell-ignore.txt
  138. - -x
  139. - dev/tools/codespell/codespell-lines-ignore.txt
  140. - --uri-ignore-words-list
  141. - ned
  142. exclude_types: [image]
  143. exclude: (?x)^(.phan/stubs/.*)$
  144. additional_dependencies: [tomli]
  145. - alias: codespell-lang-en_US
  146. # Only for translations with specialised exceptions
  147. # -D contains predefined conversion dictionaries
  148. # -L is to ignore some words
  149. id: codespell
  150. files: ^htdocs/langs/en_US/.*$
  151. args:
  152. - -D
  153. - "-"
  154. - -D
  155. - dev/tools/codespell/codespell-dict.txt
  156. - -L
  157. - informations,medias,uptodate,reenable,crypted,developpers
  158. - -L
  159. - creat,unitl,alltime,datas,referers
  160. - -I
  161. - dev/tools/codespell/codespell-ignore.txt
  162. - -x
  163. - dev/tools/codespell/codespell-lines-ignore.txt
  164. - --uri-ignore-words-list
  165. - ned
  166. # Check some shell scripts
  167. - repo: https://github.com/shellcheck-py/shellcheck-py
  168. rev: v0.9.0.6
  169. hooks:
  170. - id: shellcheck
  171. args: [-W, "100"]