.pre-commit-config.yaml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/lovesegfault/beautysh.git
  30. rev: v6.2.1
  31. hooks:
  32. - id: beautysh
  33. exclude: (?x)^(dev/setup/git/hooks/pre-commit)$
  34. args: [--tab]
  35. # Run local script
  36. #
  37. # For instance to update the license in edited files, you could add to local.sh:
  38. #
  39. # ```shell
  40. # #!/bin/bash
  41. # MYDIR=$(dirname "$0")
  42. # CHANGED_INTERNALS=$(git diff --name-only | grep -v includes)
  43. # "$MYDIR/dev/tools/updatelicense.php" $CHANGED_INTERNALS
  44. # ```
  45. - repo: local
  46. hooks:
  47. - id: local-precommit-script
  48. name: Run local script before commit if it exists
  49. language: system
  50. entry: bash -c '[ ! -x local.sh ] || ./local.sh'
  51. pass_filenames: false
  52. # Check PHP syntax
  53. - repo: https://github.com/mdeweerd/pre-commit-php
  54. rev: v1.6.5
  55. hooks:
  56. - id: php-cbf
  57. files: \.(php)$
  58. args: [--standard=dev/setup/codesniffer/ruleset.xml]
  59. - id: php-cs
  60. files: \.(php)$
  61. args:
  62. [
  63. --standard=dev/setup/codesniffer/ruleset.xml,
  64. --report=emacs,
  65. --severity=5,
  66. ]
  67. - alias: php-cs-with-cache
  68. id: php-cs
  69. # Configuration for ci - run on all files with cache
  70. stages: [manual]
  71. args:
  72. [
  73. --standard=dev/setup/codesniffer/ruleset.xml,
  74. --report=emacs,
  75. --severity=5,
  76. --cache=.cache/pre-commit/dolibarr-php-cs.cache,
  77. .,
  78. ]
  79. pass_filenames: false # Run on all files
  80. - id: php-lint
  81. - id: php-stan
  82. stages: [manual]
  83. files: \.(php)$
  84. # Prettier (format code, only for non common files)
  85. - repo: https://github.com/pre-commit/mirrors-prettier
  86. rev: v3.0.3
  87. hooks:
  88. - id: prettier
  89. stages: [manual]
  90. exclude:
  91. (?x)^( .*\.(phar |min\.css |lock) |htdocs/(includes|theme/common)/.*
  92. )$
  93. exclude_types:
  94. - php
  95. - executable
  96. - binary
  97. - shell
  98. - javascript
  99. - markdown
  100. - html
  101. - less
  102. - plain-text
  103. - scss
  104. - css
  105. - yaml
  106. # Check format of yaml files
  107. - repo: https://github.com/adrienverge/yamllint.git
  108. rev: v1.33.0
  109. hooks:
  110. - id: yamllint
  111. args:
  112. - --no-warnings
  113. - -d
  114. - "{extends: relaxed, rules: {line-length: {max: 120}}}"
  115. # Execute codespell to fix typo errors (setup of codespell into dev/tools/codespell/)
  116. - repo: https://github.com/codespell-project/codespell
  117. rev: v2.2.6
  118. hooks:
  119. - id: codespell
  120. # Due to a current limitation of configuration files,
  121. # we can specify two dicts only on the CLI.
  122. # You can update the contents of the exclude-file codespell-lines-ignore with the script
  123. # dev/tools/codespell/addCodespellIgnores.sh
  124. args:
  125. - -D
  126. - "-"
  127. - -D
  128. - dev/tools/codespell/codespell-dict.txt
  129. - -I
  130. - dev/tools/codespell/codespell-ignore.txt
  131. - -x
  132. - dev/tools/codespell/codespell-lines-ignore.txt
  133. - --uri-ignore-words-list
  134. - ned
  135. exclude_types: [image]
  136. exclude: (?x)^(.phan/stubs/.*)$
  137. additional_dependencies: [tomli]
  138. - alias: codespell-lang-en_US
  139. # Only for translations with specialised exceptions
  140. # -D contains predefined conversion dictionaries
  141. # -L is to ignore some words
  142. id: codespell
  143. files: ^htdocs/langs/en_US/.*$
  144. args:
  145. - -D
  146. - "-"
  147. - -D
  148. - dev/tools/codespell/codespell-dict.txt
  149. - -L
  150. - informations,medias,uptodate,reenable,crypted,developpers
  151. - -L
  152. - creat,unitl,alltime,datas,referers
  153. - -I
  154. - dev/tools/codespell/codespell-ignore.txt
  155. - -x
  156. - dev/tools/codespell/codespell-lines-ignore.txt
  157. - --uri-ignore-words-list
  158. - ned
  159. # Check some shell scripts
  160. - repo: https://github.com/shellcheck-py/shellcheck-py
  161. rev: v0.9.0.6
  162. hooks:
  163. - id: shellcheck
  164. args: [-W, "100"]