.eslintrc.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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-hooks/exhaustive-deps': [
  28. 'warn',
  29. {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
  30. ],
  31. ...(!isRelaxed && !isCi ? strictRulesNotCi : {}),
  32. },
  33. overrides: [
  34. {
  35. files: ['*.ts', '*.tsx'],
  36. rules: {},
  37. },
  38. {
  39. // We specify rules explicitly for the sdk-loader here so we do not have
  40. // eslint ignore comments included in the source file, which is consumed
  41. // by users.
  42. files: ['**/js-sdk-loader.ts'],
  43. rules: {
  44. 'no-console': 'off',
  45. },
  46. },
  47. ],
  48. };