.pre-commit-config.yaml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. - id: prevent-push
  76. name: prevent pushing master
  77. stages: [pre-push]
  78. entry: bash -c 'test "$PRE_COMMIT_REMOTE_BRANCH" != "refs/heads/master"'
  79. always_run: true
  80. pass_filenames: false
  81. language: system
  82. - repo: https://github.com/pre-commit/pygrep-hooks
  83. rev: v1.10.0
  84. hooks:
  85. - id: python-use-type-annotations
  86. - repo: https://github.com/python-jsonschema/check-jsonschema
  87. rev: 0.24.1
  88. hooks:
  89. - id: check-github-actions
  90. - id: check-github-workflows
  91. args: [--verbose]
  92. - repo: https://github.com/pre-commit/pre-commit-hooks
  93. rev: v4.3.0
  94. hooks:
  95. - id: check-case-conflict
  96. - id: check-executables-have-shebangs
  97. - id: check-merge-conflict
  98. - id: check-symlinks
  99. - id: check-yaml
  100. - id: end-of-file-fixer
  101. exclude_types: [svg]
  102. exclude: ^fixtures/
  103. - id: trailing-whitespace
  104. exclude_types: [svg]
  105. exclude: ^(fixtures/|scripts/patches/)
  106. - id: debug-statements
  107. - id: name-tests-test
  108. args: [--pytest-test-first]
  109. - repo: https://github.com/pre-commit/mirrors-prettier
  110. rev: 'v3.0.3' # Use the sha or tag you want to point at
  111. hooks:
  112. - id: prettier
  113. name: prettier (yaml, json, markdown)
  114. types_or:
  115. - json
  116. - yaml
  117. - markdown
  118. # https://pre-commit.com/#regular-expressions
  119. exclude: |
  120. (?x)^($^
  121. # prettier crashes on some of these, by intent:
  122. |fixtures/.*
  123. # these have enormous diffs when formatted:
  124. |api-docs/paths/events/issue-hashes\.json
  125. |api-docs/paths/events/latest-event\.json
  126. |api-docs/paths/events/oldest-event\.json
  127. |api-docs/paths/events/project-event-details\.json
  128. |src/sentry/issues/event\.schema\.json
  129. |static/app/data/world\.json
  130. |static/app/utils/profiling/profile/formats/android/trace\.json
  131. |static/app/utils/profiling/profile/formats/ios/trace\.json
  132. |static/app/utils/profiling/profile/formats/node/trace\.json
  133. |static/app/utils/profiling/profile/formats/typescript/trace\.json
  134. )$