.pre-commit-config.yaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. default_install_hook_types: ['pre-commit', 'pre-push']
  2. default_stages: [pre-commit]
  3. exclude: >
  4. (?x)(
  5. LICENSE.md$|
  6. \.snap$|
  7. \.map$|
  8. \.map\.js$|
  9. ^src/sentry/static/sentry/vendor/|
  10. ^src/.*/locale/|
  11. ^src/sentry/data/
  12. )
  13. repos:
  14. # Many of these hooks are local because people use a variety of IDEs
  15. # with autoformatters that need to call out to things like `black` directly.
  16. # pre-commit run is not the same, and something like pre-commit exec does
  17. # not exist yet.
  18. - repo: local
  19. hooks:
  20. - id: pyupgrade
  21. name: pyupgrade
  22. entry: pyupgrade
  23. args: ['--py311-plus']
  24. language: system
  25. types: [python]
  26. # Configuration for black exists in pyproject.toml,
  27. # but we let pre-commit take care of the file filtering.
  28. - id: black
  29. name: black
  30. entry: black
  31. language: system
  32. types: [python]
  33. require_serial: true
  34. # Configuration for isort exists in pyproject.toml,
  35. # but we let pre-commit take care of the file filtering.
  36. - id: isort
  37. name: isort
  38. entry: isort
  39. language: system
  40. types: [python]
  41. # Configuration for flake8 exists in setup.cfg,
  42. # but we let pre-commit take care of the file filtering.
  43. - id: flake8
  44. name: flake8
  45. entry: flake8
  46. language: system
  47. types: [python]
  48. log_file: '.artifacts/flake8.pycodestyle.log'
  49. - id: mypy
  50. name: mypy
  51. entry: bash -c 'if [ -n "${SENTRY_MYPY_PRE_PUSH:-}" ]; then exec mypy "$@"; fi' --
  52. language: system
  53. stages: [pre-push]
  54. types: [python]
  55. require_serial: true
  56. - id: lint-requirements
  57. name: lint-requirements
  58. entry: python -m tools.lint_requirements
  59. language: python
  60. files: requirements-.*\.txt$
  61. # exclude the overrides file from this linter -- it doesn't apply at all
  62. exclude: ^requirements-getsentry-overrides\.txt$
  63. additional_dependencies: [packaging==21.3]
  64. - id: requirements-overrides
  65. name: use pinned archives (see comment in file)
  66. stages: [commit]
  67. language: pygrep
  68. entry: |
  69. (?x)
  70. ^
  71. # it's a comment line
  72. (?!\#.*$)
  73. # it's a blank line
  74. (?!$)
  75. # it's a pinned archive
  76. (?![a-z-]+[ ]@[ ]https://github\.com/getsentry/[^/]+/archive/[a-f0-9]{40}\.zip$)
  77. files: ^requirements-getsentry-overrides\.txt$
  78. - id: check-mypy-bypass
  79. name: do not bypass the type checker
  80. entry: '(^# *mypy: *ignore-errors|^# *type: *ignore|\bno_type_check\b)'
  81. language: pygrep
  82. types: [python]
  83. - id: prevent-push
  84. name: prevent pushing master
  85. stages: [pre-push]
  86. entry: bash -c 'test "$PRE_COMMIT_REMOTE_BRANCH" != "refs/heads/master"'
  87. always_run: true
  88. pass_filenames: false
  89. language: system
  90. - repo: https://github.com/pre-commit/pygrep-hooks
  91. rev: v1.10.0
  92. hooks:
  93. - id: python-use-type-annotations
  94. - repo: https://github.com/python-jsonschema/check-jsonschema
  95. rev: 0.24.1
  96. hooks:
  97. - id: check-github-actions
  98. - id: check-github-workflows
  99. args: [--verbose]
  100. - repo: https://github.com/pre-commit/pre-commit-hooks
  101. rev: v4.3.0
  102. hooks:
  103. - id: check-case-conflict
  104. - id: check-executables-have-shebangs
  105. - id: check-merge-conflict
  106. - id: check-symlinks
  107. - id: check-yaml
  108. - id: end-of-file-fixer
  109. exclude_types: [svg]
  110. exclude: ^fixtures/
  111. - id: trailing-whitespace
  112. exclude_types: [svg]
  113. exclude: ^(fixtures/|scripts/patches/)
  114. - id: debug-statements
  115. - id: name-tests-test
  116. args: [--pytest-test-first]
  117. - repo: https://github.com/biomejs/pre-commit
  118. rev: v0.1.0
  119. hooks:
  120. - id: biome-check
  121. name: biome (javascript, typescript, json)
  122. additional_dependencies: ['@biomejs/biome@1.5.3']
  123. - repo: https://github.com/pre-commit/mirrors-prettier
  124. rev: 'v3.1.0' # Use the sha or tag you want to point at
  125. hooks:
  126. - id: prettier
  127. name: prettier (yaml, markdown, tsx, jsx, css)
  128. # TODO: Remove tsx and jsx when Biome supports styled CSS formatting.
  129. types_or: [yaml, markdown, tsx, jsx, css]
  130. # Override the default version of prettier since there isn't a tag with 3.2.5
  131. additional_dependencies: ['prettier@3.2.5']
  132. # https://pre-commit.com/#regular-expressions
  133. exclude: |
  134. (?x)^($^
  135. # prettier crashes on some of these, by intent:
  136. |fixtures/.*
  137. # these have enormous diffs when formatted:
  138. |api-docs/paths/events/issue-hashes\.json
  139. |api-docs/paths/events/latest-event\.json
  140. |api-docs/paths/events/oldest-event\.json
  141. |api-docs/paths/events/project-event-details\.json
  142. |src/sentry/issues/event\.schema\.json
  143. |static/app/data/world\.json
  144. |static/app/utils/profiling/profile/formats/android/trace\.json
  145. |static/app/utils/profiling/profile/formats/ios/trace\.json
  146. |static/app/utils/profiling/profile/formats/node/trace\.json
  147. |static/app/utils/profiling/profile/formats/typescript/trace\.json
  148. )$
  149. - repo: https://github.com/shellcheck-py/shellcheck-py
  150. rev: v0.9.0.6
  151. hooks:
  152. - id: shellcheck
  153. types: [file]
  154. files: ^\.envrc$
  155. args: [--external-sources]