.eslintrc.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* eslint-env node */
  2. /* eslint import/no-nodejs-modules:0 */
  3. const process = require('process');
  4. const isRelaxed = !!process.env.SENTRY_ESLINT_RELAXED;
  5. const isCi = !!process.env.CI;
  6. // Strict ruleset that runs on pre-commit and in local environments
  7. const ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR =
  8. '(useEffectAfterFirstRender|useMemoWithPrevious)';
  9. const strictRulesNotCi = {
  10. 'react-hooks/exhaustive-deps': [
  11. 'error',
  12. {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
  13. ],
  14. };
  15. module.exports = {
  16. extends: [isRelaxed ? 'sentry-app' : 'sentry-app/strict'],
  17. globals: {
  18. require: false,
  19. expect: false,
  20. sinon: false,
  21. MockApiClient: true,
  22. tick: true,
  23. jest: true,
  24. },
  25. rules: {
  26. 'react-hooks/exhaustive-deps': [
  27. 'warn',
  28. {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
  29. ],
  30. ...(!isRelaxed && !isCi ? strictRulesNotCi : {}),
  31. },
  32. overrides: [
  33. {
  34. files: ['*.ts', '*.tsx'],
  35. rules: {},
  36. },
  37. {
  38. // We specify rules explicitly for the sdk-loader here so we do not have
  39. // eslint ignore comments included in the source file, which is consumed
  40. // by users.
  41. files: ['**/js-sdk-loader.ts'],
  42. rules: {
  43. 'no-console': 'off',
  44. },
  45. },
  46. ],
  47. };