.pre-commit-config.yaml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. default_install_hook_types: ['pre-commit', 'pre-push']
  2. exclude: >
  3. (?x)(
  4. LICENSE.md$|
  5. \.snap$|
  6. \.map$|
  7. \.map\.js$|
  8. ^src/sentry/static/sentry/vendor/|
  9. ^src/.*/locale/|
  10. ^src/sentry/data/
  11. )
  12. repos:
  13. # Many of these hooks are local because people use a variety of IDEs
  14. # with autoformatters that need to call out to things like `black` directly.
  15. # pre-commit run is not the same, and something like pre-commit exec does
  16. # not exist yet.
  17. - repo: local
  18. hooks:
  19. - id: pyupgrade
  20. name: pyupgrade
  21. entry: pyupgrade
  22. args: ['--py38-plus', '--keep-runtime-typing']
  23. language: system
  24. types: [python]
  25. # Configuration for black exists in pyproject.toml,
  26. # but we let pre-commit take care of the file filtering.
  27. - id: black
  28. name: black
  29. entry: black
  30. language: system
  31. types: [python]
  32. require_serial: true
  33. # Configuration for isort exists in pyproject.toml,
  34. # but we let pre-commit take care of the file filtering.
  35. - id: isort
  36. name: isort
  37. entry: isort
  38. language: system
  39. types: [python]
  40. # Configuration for flake8 exists in setup.cfg,
  41. # but we let pre-commit take care of the file filtering.
  42. - id: flake8
  43. name: flake8
  44. entry: flake8
  45. language: system
  46. types: [python]
  47. log_file: '.artifacts/flake8.pycodestyle.log'
  48. - id: lint-requirements
  49. name: lint-requirements
  50. entry: python -m tools.lint_requirements
  51. language: python
  52. files: requirements-.*\.txt$
  53. # exclude the overrides file from this linter -- it doesn't apply at all
  54. exclude: ^requirements-getsentry-overrides\.txt$
  55. additional_dependencies: [packaging==21.3]
  56. - id: requirements-overrides
  57. name: use pinned archives (see comment in file)
  58. stages: [commit]
  59. language: pygrep
  60. entry: |
  61. (?x)
  62. ^
  63. # it's a comment line
  64. (?!\#.*$)
  65. # it's a blank line
  66. (?!$)
  67. # it's a pinned archive
  68. (?![a-z-]+[ ]@[ ]https://github\.com/getsentry/[^/]+/archive/[a-f0-9]{40}\.zip$)
  69. files: ^requirements-getsentry-overrides\.txt$
  70. - id: check-mypy-bypass
  71. name: do not bypass the type checker
  72. entry: '(^# *mypy: *ignore-errors|^# *type: *ignore|\bno_type_check\b)'
  73. language: pygrep
  74. types: [python]
  75. exclude: ^src/sentry/metrics/minimetrics.py$
  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/pre-commit/mirrors-prettier
  111. rev: 'v3.0.3' # Use the sha or tag you want to point at
  112. hooks:
  113. - id: prettier
  114. name: prettier (yaml, json, markdown)
  115. types_or:
  116. - json
  117. - yaml
  118. - markdown
  119. # https://pre-commit.com/#regular-expressions
  120. exclude: |
  121. (?x)^($^
  122. # prettier crashes on some of these, by intent:
  123. |fixtures/.*
  124. # these have enormous diffs when formatted:
  125. |api-docs/paths/events/issue-hashes\.json
  126. |api-docs/paths/events/latest-event\.json
  127. |api-docs/paths/events/oldest-event\.json
  128. |api-docs/paths/events/project-event-details\.json
  129. |src/sentry/issues/event\.schema\.json
  130. |static/app/data/world\.json
  131. |static/app/utils/profiling/profile/formats/android/trace\.json
  132. |static/app/utils/profiling/profile/formats/ios/trace\.json
  133. |static/app/utils/profiling/profile/formats/node/trace\.json
  134. |static/app/utils/profiling/profile/formats/typescript/trace\.json
  135. )$