Browse Source

ref(tsc): ban-ts-comment (#83904)

This PR turns on the
[typescript-eslint/ban-ts-comment](https://typescript-eslint.io/rules/ban-ts-comment)
lint rule and replaces all usages of `ts-ignore` with `ts-expect-error`.

This is a follow up to:
- #83366 

where we had to use `ts-ignore` instead of `ts-expect-error` to stay
compatible with the `getsentry` repo.
Dominik Dorfmeister 1 month ago
parent
commit
3337eb6134

+ 0 - 1
eslint.config.mjs

@@ -412,7 +412,6 @@ export default typescript.config([
       '@typescript-eslint/prefer-enum-initializers': 'error',
 
       // Recommended overrides
-      '@typescript-eslint/ban-ts-comment': 'off', // TODO(ryan953): Fix violations and delete this line
       '@typescript-eslint/no-array-constructor': 'off', // TODO(ryan953): Fix violations and delete this line
       '@typescript-eslint/no-empty-object-type': 'off', // TODO(ryan953): Fix violations and delete this line
       '@typescript-eslint/no-explicit-any': 'off',

+ 1 - 1
static/app/api.tsx

@@ -357,7 +357,7 @@ export class Client {
 
       // Check if API response is a 302 -- means project slug was renamed and user
       // needs to be redirected
-      // @ts-ignore TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
+      // @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
       if (hasProjectBeenRenamed(...args)) {
         return undefined;
       }

+ 2 - 2
static/app/components/charts/baseChart.spec.tsx

@@ -19,7 +19,7 @@ describe('BaseChart', function () {
         ]}
       />
     );
-    // @ts-expect-error
+    // @ts-expect-error TODO: Fix this type
     const series = ReactEchartsCore.mock.calls[0][0].option.series;
     expect(series).toHaveLength(1);
     expect(series[0].lineStyle.color).toEqual(theme.gray200);
@@ -44,7 +44,7 @@ describe('BaseChart', function () {
       />
     );
     const series =
-      // @ts-expect-error
+      // @ts-expect-error TODO: Fix this type
       ReactEchartsCore.mock.calls[ReactEchartsCore.mock.calls.length - 1][0].option
         .series;
     expect(series).toHaveLength(3);

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

@@ -88,7 +88,7 @@ export function CodeSnippet({
   // https://prismjs.com/plugins/line-highlight/
   useEffect(() => {
     if (linesToHighlight) {
-      // @ts-ignore TS(7016): Could not find a declaration file for module 'pris... Remove this comment to see the full error message
+      // @ts-expect-error TS(7016): Could not find a declaration file for module 'pris... Remove this comment to see the full error message
       import('prismjs/plugins/line-highlight/prism-line-highlight');
     }
   }, [linesToHighlight]);

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

@@ -70,7 +70,7 @@ function CreateAlertFromViewButton({
   }
 
   const alertTemplate = alertType
-    ? // @ts-ignore TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
+    ? // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
       AlertWizardRuleTemplates[alertType]
     : DEFAULT_WIZARD_TEMPLATE;
 

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

@@ -1,6 +1,6 @@
 import {Fragment, useRef, useState} from 'react';
 import moment from 'moment-timezone';
-// @ts-ignore TS(7016): Could not find a declaration file for module 'spri... Remove this comment to see the full error message
+// @ts-expect-error TS(7016): Could not find a declaration file for module 'spri... Remove this comment to see the full error message
 import {sprintf} from 'sprintf-js';
 
 import type {ModalRenderProps} from 'sentry/actionCreators/modal';

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

@@ -210,7 +210,7 @@ class DeprecatedAsyncComponent<
     }
 
     endpoints.forEach(([stateKey, _endpoint]) => {
-      // @ts-ignore TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
+      // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
       state[stateKey] = null;
     });
     return state;

+ 1 - 1
static/app/components/deprecatedSmartSearchBar/index.tsx

@@ -297,7 +297,7 @@ type Props = WithRouterProps &
      * A function that returns a warning message for a given filter key
      * will only show a render a warning if the value is truthy
      */
-    // @ts-ignore TS(7006): Parameter 'key' implicitly has an 'any' type.
+    // @ts-expect-error TS(7006): Parameter 'key' implicitly has an 'any' type.
     getFilterWarning?: (key) => React.ReactNode;
     /**
      * List user's recent searches

+ 1 - 1
static/app/components/deprecatedSmartSearchBar/searchDropdown.tsx

@@ -20,7 +20,7 @@ import {SearchInvalidTag} from './searchInvalidTag';
 import type {SearchGroup, SearchItem, Shortcut} from './types';
 import {invalidTypes, ItemType} from './types';
 
-// @ts-ignore TS(7023): 'getDropdownItemKey' implicitly has return type 'a... Remove this comment to see the full error message
+// @ts-expect-error TS(7023): 'getDropdownItemKey' implicitly has return type 'a... Remove this comment to see the full error message
 const getDropdownItemKey = (item: SearchItem) =>
   `${item.value || item.desc || item.title}-${
     item.children && item.children.length > 0 ? getDropdownItemKey(item.children[0]!) : ''

+ 2 - 2
static/app/components/deprecatedSmartSearchBar/utils.tsx

@@ -326,7 +326,7 @@ export function getValidOps(
 
   // Determine any interchangeable filter types for our valid types
   const interchangeableTypes = validTypes.map(
-    // @ts-ignore TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
+    // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
     type => interchangeableFilterOperators[type] ?? []
   );
 
@@ -335,7 +335,7 @@ export function getValidOps(
 
   // Find all valid operations
   const validOps = new Set<TermOperator>(
-    // @ts-ignore TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
+    // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
     allValidTypes.flatMap(type => filterTypeConfig[type].validOps)
   );
 

Some files were not shown because too many files changed in this diff