.eslintrc.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. 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. overrides: [
  32. {
  33. files: ['*.ts', '*.tsx'],
  34. rules: {},
  35. },
  36. {
  37. // We specify rules explicitly for the sdk-loader here so we do not have
  38. // eslint ignore comments included in the source file, which is consumed
  39. // by users.
  40. files: ['**/js-sdk-loader.ts'],
  41. rules: {
  42. 'no-console': 'off',
  43. },
  44. },
  45. ],
  46. };