.eslintrc.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. TestStubs: true,
  23. tick: true,
  24. jest: true,
  25. },
  26. rules: {
  27. 'react/function-component-definition': [
  28. 'error',
  29. {namedComponents: 'function-declaration'},
  30. ],
  31. 'react-hooks/exhaustive-deps': [
  32. 'warn',
  33. {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
  34. ],
  35. ...(!isRelaxed && !isCi ? strictRulesNotCi : {}),
  36. },
  37. overrides: [
  38. {
  39. files: ['*.ts', '*.tsx'],
  40. rules: {},
  41. },
  42. {
  43. files: ['**/js-sdk-loader.ts'],
  44. rules: {
  45. 'no-console': 'off',
  46. },
  47. },
  48. ],
  49. };