.eslintrc.js 2.2 KB

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