Browse Source

lint: Remove special-case for `react-hooks/exhaustive-deps` in CI rules (#66736)

This popped up as an issue in CI. I'm ignoring the warning because the
team selector is a bit complex, and can have long lists. I'd rather not
break it by adding dependencies and causing additional unexpected
re-renders.

So just silencing the warning for now to make CI happy.
Ryan Albrecht 1 year ago
parent
commit
34e0417345
2 changed files with 2 additions and 11 deletions
  1. 1 10
      .eslintrc.js
  2. 1 1
      static/app/components/teamSelector.tsx

+ 1 - 10
.eslintrc.js

@@ -1,19 +1,11 @@
 /* eslint-env node */
 
 const isRelaxed = !!process.env.SENTRY_ESLINT_RELAXED;
-const isCi = !!process.env.CI;
 
 // Strict ruleset that runs on pre-commit and in local environments
 const ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR =
   '(useEffectAfterFirstRender|useMemoWithPrevious)';
 
-const strictRulesNotCi = {
-  'react-hooks/exhaustive-deps': [
-    'error',
-    {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
-  ],
-};
-
 module.exports = {
   root: true,
   extends: [isRelaxed ? 'sentry-app' : 'sentry-app/strict'],
@@ -27,10 +19,9 @@ module.exports = {
   },
   rules: {
     'react-hooks/exhaustive-deps': [
-      'warn',
+      'error',
       {additionalHooks: ADDITIONAL_HOOKS_TO_CHECK_DEPS_FOR},
     ],
-    ...(!isRelaxed && !isCi ? strictRulesNotCi : {}),
 
     // TODO(@anonrig): Remove this from eslint-sentry-config
     'space-infix-ops': 'off',

+ 1 - 1
static/app/components/teamSelector.tsx

@@ -377,7 +377,7 @@ function TeamSelector(props: Props) {
     }
     // We only want to do this once when the component is finished loading for teams and mounted.
     // If the user decides they do not want the default, we should not add the default value back.
-  }, [fetching, useTeamDefaultIfOnlyOne]);
+  }, [fetching, useTeamDefaultIfOnlyOne]); // eslint-disable-line react-hooks/exhaustive-deps
 
   return (
     <SelectControl