.eslintrc.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. },
  31. // JSON file formatting is handled by Biome. ESLint should not be linting
  32. // and formatting these files.
  33. ignorePatterns: ['*.json'],
  34. overrides: [
  35. {
  36. files: ['tests/js/**/*.{ts,js}'],
  37. extends: ['plugin:testing-library/react', 'sentry-app/strict'],
  38. },
  39. {
  40. files: ['*.ts', '*.tsx'],
  41. rules: {},
  42. },
  43. {
  44. // We specify rules explicitly for the sdk-loader here so we do not have
  45. // eslint ignore comments included in the source file, which is consumed
  46. // by users.
  47. files: ['**/js-sdk-loader.ts'],
  48. rules: {
  49. 'no-console': 'off',
  50. },
  51. },
  52. ],
  53. };