.eslintrc.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* eslint-env node */
  2. const detectDeprecations = !!process.env.SENTRY_DETECT_DEPRECATIONS;
  3. module.exports = {
  4. root: true,
  5. extends: detectDeprecations
  6. ? ['sentry-app/strict', 'plugin:deprecation/recommended']
  7. : ['sentry-app/strict'],
  8. parserOptions: detectDeprecations
  9. ? {
  10. project: './tsconfig.json',
  11. }
  12. : {},
  13. globals: {
  14. require: false,
  15. expect: false,
  16. MockApiClient: true,
  17. tick: true,
  18. jest: true,
  19. },
  20. rules: {
  21. 'react-hooks/exhaustive-deps': [
  22. 'error',
  23. {additionalHooks: '(useEffectAfterFirstRender|useMemoWithPrevious)'},
  24. ],
  25. 'no-restricted-imports': [
  26. 'error',
  27. {
  28. patterns: [
  29. {
  30. group: ['sentry/components/devtoolbar/*'],
  31. message: 'Do not depend on toolbar internals',
  32. },
  33. ],
  34. },
  35. ],
  36. // TODO(@anonrig): Remove this from eslint-sentry-config
  37. 'space-infix-ops': 'off',
  38. 'object-shorthand': 'off',
  39. 'object-curly-spacing': 'off',
  40. 'import/no-amd': 'off',
  41. 'no-danger-with-children': 'off',
  42. 'no-fallthrough': 'off',
  43. 'no-obj-calls': 'off',
  44. 'array-bracket-spacing': 'off',
  45. 'computed-property-spacing': 'off',
  46. 'react/no-danger-with-children': 'off',
  47. 'jest/no-disabled-tests': 'off',
  48. },
  49. // JSON file formatting is handled by Biome. ESLint should not be linting
  50. // and formatting these files.
  51. ignorePatterns: ['*.json'],
  52. overrides: [
  53. {
  54. files: ['static/app/components/devtoolbar/**/*.{ts,tsx}'],
  55. rules: {
  56. 'no-restricted-imports': [
  57. 'error',
  58. {
  59. paths: [
  60. {
  61. name: 'sentry/utils/queryClient',
  62. message:
  63. 'Import from `@tanstack/react-query` and `./hooks/useFetchApiData` or `./hooks/useFetchInfiniteApiData` instead.',
  64. },
  65. ],
  66. },
  67. ],
  68. },
  69. },
  70. {
  71. files: ['static/**/*.spec.{ts,js}', 'tests/js/**/*.{ts,js}'],
  72. extends: ['plugin:testing-library/react', 'sentry-app/strict'],
  73. rules: {
  74. // TODO(@anonrig): Remove this from eslint-sentry-config
  75. 'space-infix-ops': 'off',
  76. 'object-shorthand': 'off',
  77. 'object-curly-spacing': 'off',
  78. 'import/no-amd': 'off',
  79. 'no-danger-with-children': 'off',
  80. 'no-fallthrough': 'off',
  81. 'no-obj-calls': 'off',
  82. 'array-bracket-spacing': 'off',
  83. 'computed-property-spacing': 'off',
  84. 'react/no-danger-with-children': 'off',
  85. 'jest/no-disabled-tests': 'off',
  86. },
  87. },
  88. {
  89. // We specify rules explicitly for the sdk-loader here so we do not have
  90. // eslint ignore comments included in the source file, which is consumed
  91. // by users.
  92. files: ['**/js-sdk-loader.ts'],
  93. rules: {
  94. 'no-console': 'off',
  95. },
  96. },
  97. ],
  98. };