.eslintrc.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* eslint-env node */
  2. /* eslint import/no-nodejs-modules:0 */
  3. const isRelaxed = !!process.env.SENTRY_ESLINT_RELAXED;
  4. const isCi = !!process.env.CI;
  5. // Strict ruleset that runs on pre-commit and in local environments
  6. const ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR =
  7. '(useEffectAfterFirstRender|useMemoWithPrevious)';
  8. const strictRulesNotCi = {
  9. 'react-hooks/exhaustive-deps': [
  10. 'error',
  11. {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
  12. ],
  13. };
  14. module.exports = {
  15. root: true,
  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. // TODO(@anonrig): Move this to eslint-config-sentry-app
  32. '@typescript-eslint/consistent-type-imports': [
  33. 'error',
  34. {fixStyle: 'separate-type-imports', prefer: 'type-imports'},
  35. ],
  36. },
  37. overrides: [
  38. {
  39. files: ['tests/js/**/*.{ts,js}'],
  40. extends: ['plugin:testing-library/react', 'sentry-app/strict'],
  41. },
  42. {
  43. files: ['*.ts', '*.tsx'],
  44. rules: {},
  45. },
  46. {
  47. // We specify rules explicitly for the sdk-loader here so we do not have
  48. // eslint ignore comments included in the source file, which is consumed
  49. // by users.
  50. files: ['**/js-sdk-loader.ts'],
  51. rules: {
  52. 'no-console': 'off',
  53. },
  54. },
  55. ],
  56. };