.eslintrc.js 1.7 KB

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