.pre-commit-config.yaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. - id: python-check-blanket-type-ignore
  95. - repo: https://github.com/python-jsonschema/check-jsonschema
  96. rev: 0.24.1
  97. hooks:
  98. - id: check-github-actions
  99. - id: check-github-workflows
  100. args: [--verbose]
  101. - repo: https://github.com/pre-commit/pre-commit-hooks
  102. rev: v4.3.0
  103. hooks:
  104. - id: check-case-conflict
  105. - id: check-executables-have-shebangs
  106. - id: check-merge-conflict
  107. - id: check-symlinks
  108. - id: check-yaml
  109. - id: end-of-file-fixer
  110. exclude_types: [svg]
  111. exclude: ^fixtures/
  112. - id: trailing-whitespace
  113. exclude_types: [svg]
  114. exclude: ^(fixtures/|scripts/patches/)
  115. - id: debug-statements
  116. - id: name-tests-test
  117. args: [--pytest-test-first]
  118. - repo: https://github.com/biomejs/pre-commit
  119. rev: v0.1.0
  120. hooks:
  121. - id: biome-check
  122. name: biome (javascript, typescript, json)
  123. additional_dependencies: ['@biomejs/biome@1.6.0']
  124. - repo: https://github.com/pre-commit/mirrors-prettier
  125. rev: 'v3.1.0' # Use the sha or tag you want to point at
  126. hooks:
  127. - id: prettier
  128. name: prettier (yaml, markdown, tsx, jsx, css)
  129. # TODO: Remove tsx and jsx when Biome supports styled CSS formatting.
  130. types_or: [yaml, markdown, tsx, jsx, css]
  131. # Override the default version of prettier since there isn't a tag with 3.2.5
  132. additional_dependencies: ['prettier@3.2.5']
  133. # https://pre-commit.com/#regular-expressions
  134. exclude: |
  135. (?x)^($^
  136. # prettier crashes on some of these, by intent:
  137. |fixtures/.*
  138. # these have enormous diffs when formatted:
  139. |api-docs/paths/events/issue-hashes\.json
  140. |api-docs/paths/events/latest-event\.json
  141. |api-docs/paths/events/oldest-event\.json
  142. |api-docs/paths/events/project-event-details\.json
  143. |src/sentry/issues/event\.schema\.json
  144. |static/app/data/world\.json
  145. |static/app/utils/profiling/profile/formats/android/trace\.json
  146. |static/app/utils/profiling/profile/formats/ios/trace\.json
  147. |static/app/utils/profiling/profile/formats/node/trace\.json
  148. |static/app/utils/profiling/profile/formats/typescript/trace\.json
  149. )$
  150. - repo: https://github.com/shellcheck-py/shellcheck-py
  151. rev: v0.9.0.6
  152. hooks:
  153. - id: shellcheck
  154. types: [file]
  155. files: ^\.envrc$
  156. args: [--external-sources]