.eslintrc.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* eslint-env node */
  2. const isRelaxed = !!process.env.SENTRY_ESLINT_RELAXED;
  3. // Strict ruleset that runs on pre-commit and in local environments
  4. const ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR =
  5. '(useEffectAfterFirstRender|useMemoWithPrevious)';
  6. module.exports = {
  7. root: true,
  8. extends: [isRelaxed ? 'sentry-app' : 'sentry-app/strict'],
  9. globals: {
  10. require: false,
  11. expect: false,
  12. sinon: false,
  13. MockApiClient: true,
  14. tick: true,
  15. jest: true,
  16. },
  17. rules: {
  18. 'react-hooks/exhaustive-deps': [
  19. 'error',
  20. {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
  21. ],
  22. // TODO(@anonrig): Remove this from eslint-sentry-config
  23. 'space-infix-ops': 'off',
  24. 'object-shorthand': 'off',
  25. 'object-curly-spacing': 'off',
  26. 'import/no-amd': 'off',
  27. 'no-danger-with-children': 'off',
  28. 'no-fallthrough': 'off',
  29. 'no-obj-calls': 'off',
  30. 'array-bracket-spacing': 'off',
  31. 'computed-property-spacing': 'off',
  32. 'react/no-danger-with-children': 'off',
  33. },
  34. // JSON file formatting is handled by Biome. ESLint should not be linting
  35. // and formatting these files.
  36. ignorePatterns: ['*.json'],
  37. overrides: [
  38. {
  39. files: ['tests/js/**/*.{ts,js}'],
  40. extends: ['plugin:testing-library/react', 'sentry-app/strict'],
  41. rules: {
  42. // TODO(@anonrig): Remove this from eslint-sentry-config
  43. 'space-infix-ops': 'off',
  44. 'object-shorthand': 'off',
  45. 'object-curly-spacing': 'off',
  46. 'import/no-amd': 'off',
  47. 'no-danger-with-children': 'off',
  48. 'no-fallthrough': 'off',
  49. 'no-obj-calls': 'off',
  50. 'array-bracket-spacing': 'off',
  51. 'computed-property-spacing': 'off',
  52. 'react/no-danger-with-children': 'off',
  53. },
  54. },
  55. {
  56. // We specify rules explicitly for the sdk-loader here so we do not have
  57. // eslint ignore comments included in the source file, which is consumed
  58. // by users.
  59. files: ['**/js-sdk-loader.ts'],
  60. rules: {
  61. 'no-console': 'off',
  62. },
  63. },
  64. ],
  65. };