.pre-commit-config.yaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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: lint-requirements
  50. name: lint-requirements
  51. entry: python -m tools.lint_requirements
  52. language: python
  53. files: requirements-.*\.txt$
  54. # exclude the overrides file from this linter -- it doesn't apply at all
  55. exclude: ^requirements-getsentry-overrides\.txt$
  56. additional_dependencies: [packaging==21.3]
  57. - id: requirements-overrides
  58. name: use pinned archives (see comment in file)
  59. stages: [commit]
  60. language: pygrep
  61. entry: |
  62. (?x)
  63. ^
  64. # it's a comment line
  65. (?!\#.*$)
  66. # it's a blank line
  67. (?!$)
  68. # it's a pinned archive
  69. (?![a-z-]+[ ]@[ ]https://github\.com/getsentry/[^/]+/archive/[a-f0-9]{40}\.zip$)
  70. files: ^requirements-getsentry-overrides\.txt$
  71. - id: check-mypy-bypass
  72. name: do not bypass the type checker
  73. entry: '(^# *mypy: *ignore-errors|^# *type: *ignore|\bno_type_check\b)'
  74. language: pygrep
  75. types: [python]
  76. - id: prevent-push
  77. name: prevent pushing master
  78. stages: [pre-push]
  79. entry: bash -c 'test "$PRE_COMMIT_REMOTE_BRANCH" != "refs/heads/master"'
  80. always_run: true
  81. pass_filenames: false
  82. language: system
  83. - repo: https://github.com/pre-commit/pygrep-hooks
  84. rev: v1.10.0
  85. hooks:
  86. - id: python-use-type-annotations
  87. - repo: https://github.com/python-jsonschema/check-jsonschema
  88. rev: 0.24.1
  89. hooks:
  90. - id: check-github-actions
  91. - id: check-github-workflows
  92. args: [--verbose]
  93. - repo: https://github.com/pre-commit/pre-commit-hooks
  94. rev: v4.3.0
  95. hooks:
  96. - id: check-case-conflict
  97. - id: check-executables-have-shebangs
  98. - id: check-merge-conflict
  99. - id: check-symlinks
  100. - id: check-yaml
  101. - id: end-of-file-fixer
  102. exclude_types: [svg]
  103. exclude: ^fixtures/
  104. - id: trailing-whitespace
  105. exclude_types: [svg]
  106. exclude: ^(fixtures/|scripts/patches/)
  107. - id: debug-statements
  108. - id: name-tests-test
  109. args: [--pytest-test-first]
  110. - repo: https://github.com/biomejs/pre-commit
  111. rev: v0.1.0
  112. hooks:
  113. - id: biome-check
  114. name: biome (javascript, typescript, json)
  115. additional_dependencies: ['@biomejs/biome@1.5.3']
  116. - repo: https://github.com/pre-commit/mirrors-prettier
  117. rev: 'v3.0.3' # Use the sha or tag you want to point at
  118. hooks:
  119. - id: prettier
  120. name: prettier (yaml, markdown)
  121. types_or: [yaml, markdown]
  122. # https://pre-commit.com/#regular-expressions
  123. exclude: |
  124. (?x)^($^
  125. # prettier crashes on some of these, by intent:
  126. |fixtures/.*
  127. # these have enormous diffs when formatted:
  128. |api-docs/paths/events/issue-hashes\.json
  129. |api-docs/paths/events/latest-event\.json
  130. |api-docs/paths/events/oldest-event\.json
  131. |api-docs/paths/events/project-event-details\.json
  132. |src/sentry/issues/event\.schema\.json
  133. |static/app/data/world\.json
  134. |static/app/utils/profiling/profile/formats/android/trace\.json
  135. |static/app/utils/profiling/profile/formats/ios/trace\.json
  136. |static/app/utils/profiling/profile/formats/node/trace\.json
  137. |static/app/utils/profiling/profile/formats/typescript/trace\.json
  138. )$
  139. - repo: https://github.com/shellcheck-py/shellcheck-py
  140. rev: v0.9.0.6
  141. hooks:
  142. - id: shellcheck
  143. types: [file]
  144. files: ^\.envrc$
  145. args: [--external-sources]