.eslintrc.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. },
  32. // JSON file formatting is handled by Biome. ESLint should not be linting
  33. // and formatting these files.
  34. ignorePatterns: ['*.json'],
  35. overrides: [
  36. {
  37. files: ['tests/js/**/*.{ts,js}'],
  38. extends: ['plugin:testing-library/react', 'sentry-app/strict'],
  39. },
  40. {
  41. files: ['*.ts', '*.tsx'],
  42. rules: {},
  43. },
  44. {
  45. // We specify rules explicitly for the sdk-loader here so we do not have
  46. // eslint ignore comments included in the source file, which is consumed
  47. // by users.
  48. files: ['**/js-sdk-loader.ts'],
  49. rules: {
  50. 'no-console': 'off',
  51. },
  52. },
  53. ],
  54. };