Browse Source

lint(eslint): Enable array-type rule & auto-fix violations (#83804)

Ryan Albrecht 1 month ago
parent
commit
abb16b9f97

+ 0 - 1
eslint.config.mjs

@@ -434,7 +434,6 @@ export default typescript.config([
       '@typescript-eslint/unified-signatures': 'off', // TODO(ryan953): Fix violations and delete this line
 
       // Stylistic overrides
-      '@typescript-eslint/array-type': 'off', // TODO(ryan953): Fix violations and delete this line
       '@typescript-eslint/class-literal-property-style': 'off', // TODO(ryan953): Fix violations and delete this line
       '@typescript-eslint/consistent-generic-constructors': 'off', // TODO(ryan953): Fix violations and delete this line
       '@typescript-eslint/consistent-indexed-object-style': 'off', // TODO(ryan953): Fix violations and delete this line

+ 3 - 3
static/app/actionCreators/events.tsx

@@ -39,7 +39,7 @@ type Options = {
   comparisonDelta?: number;
   dataset?: DiscoverDatasets;
   end?: DateString;
-  environment?: Readonly<string[]>;
+  environment?: readonly string[];
   excludeOther?: boolean;
   field?: string[];
   generatePathname?: (org: OrganizationSummary) => string;
@@ -48,7 +48,7 @@ type Options = {
   limit?: number;
   orderby?: string;
   period?: string | null;
-  project?: Readonly<number[]>;
+  project?: readonly number[];
   query?: string;
   queryBatching?: QueryBatching;
   queryExtras?: Record<string, string | boolean | number>;
@@ -192,7 +192,7 @@ export type TagSegment = {
 
 export type Tag = {
   key: string;
-  topValues: Array<TagSegment>;
+  topValues: TagSegment[];
 };
 
 /**

+ 8 - 8
static/app/actionCreators/group.tsx

@@ -120,17 +120,17 @@ type UpdateParams = ParamsType & {
 type QueryArgs =
   | {
       query: string;
-      environment?: string | Array<string>;
-      project?: Array<number | string>;
+      environment?: string | string[];
+      project?: (number | string)[];
     }
   | {
-      id: Array<number> | Array<string>;
-      environment?: string | Array<string>;
-      project?: Array<number | string>;
+      id: number[] | string[];
+      environment?: string | string[];
+      project?: (number | string)[];
     }
   | {
-      environment?: string | Array<string>;
-      project?: Array<number | string>;
+      environment?: string | string[];
+      project?: (number | string)[];
     };
 
 /**
@@ -175,7 +175,7 @@ function getUpdateUrl({projectId, orgId}: UpdateParams) {
 }
 
 function chainUtil<Args extends any[]>(
-  ...funcs: Array<((...args: Args) => any) | undefined>
+  ...funcs: (((...args: Args) => any) | undefined)[]
 ) {
   const filteredFuncs = funcs.filter(
     (f): f is (...args: Args) => any => typeof f === 'function'

+ 2 - 2
static/app/actionCreators/metrics.tsx

@@ -11,7 +11,7 @@ export type DoReleaseHealthRequestOptions = {
   orgSlug: Organization['slug'];
   cursor?: string;
   end?: DateString;
-  environment?: Readonly<string[]>;
+  environment?: readonly string[];
   groupBy?: string[];
   includeAllArgs?: boolean;
   includeSeries?: number;
@@ -19,7 +19,7 @@ export type DoReleaseHealthRequestOptions = {
   interval?: string;
   limit?: number;
   orderBy?: string;
-  project?: Readonly<number[]>;
+  project?: readonly number[];
   query?: string;
   start?: DateString;
   statsPeriod?: string | null;

+ 2 - 2
static/app/actionCreators/sessions.tsx

@@ -10,7 +10,7 @@ export type DoSessionsRequestOptions = {
   orgSlug: Organization['slug'];
   cursor?: string;
   end?: DateString;
-  environment?: Readonly<string[]>;
+  environment?: readonly string[];
   groupBy?: string[];
   includeAllArgs?: boolean;
   includeSeries?: boolean;
@@ -18,7 +18,7 @@ export type DoSessionsRequestOptions = {
   interval?: string;
   limit?: number;
   orderBy?: string;
-  project?: Readonly<number[]>;
+  project?: readonly number[];
   query?: string;
   start?: DateString;
   statsPeriod?: string | null;

+ 3 - 3
static/app/components/acl/feature.tsx

@@ -105,9 +105,9 @@ interface ChildRenderProps extends FeatureRenderProps {
 export type ChildrenRenderFn = (props: ChildRenderProps) => React.ReactNode;
 
 type AllFeatures = {
-  configFeatures: ReadonlyArray<string>;
-  organization: ReadonlyArray<string>;
-  project: ReadonlyArray<string>;
+  configFeatures: readonly string[];
+  organization: readonly string[];
+  project: readonly string[];
 };
 
 /**

+ 6 - 6
static/app/components/arithmeticInput/parser.tsx

@@ -41,9 +41,9 @@ class Term {
 
 export class TokenConverter {
   numOperations: number;
-  errors: Array<string>;
-  fields: Array<Term>;
-  functions: Array<Term>;
+  errors: string[];
+  fields: Term[];
+  functions: Term[];
 
   constructor() {
     this.numOperations = 0;
@@ -52,7 +52,7 @@ export class TokenConverter {
     this.functions = [];
   }
 
-  tokenTerm = (maybeFactor: Expression, remainingAdds: Array<Operation>): Expression => {
+  tokenTerm = (maybeFactor: Expression, remainingAdds: Operation[]): Expression => {
     if (remainingAdds.length > 0) {
       remainingAdds[0]!.lhs = maybeFactor;
       return flatten(remainingAdds);
@@ -74,7 +74,7 @@ export class TokenConverter {
     return new Operation({operator, rhs});
   };
 
-  tokenFactor = (primary: Expression, remaining: Array<Operation>): Operation => {
+  tokenFactor = (primary: Expression, remaining: Operation[]): Operation => {
     remaining[0]!.lhs = primary;
     return flatten(remaining);
   };
@@ -93,7 +93,7 @@ export class TokenConverter {
 }
 
 // Assumes an array with at least one element
-function flatten(remaining: Array<Operation>): Operation {
+function flatten(remaining: Operation[]): Operation {
   let term = remaining.shift();
   while (remaining.length > 0) {
     const nextTerm = remaining.shift();

+ 4 - 4
static/app/components/autoComplete.tsx

@@ -129,10 +129,10 @@ export interface AutoCompleteProps<T> extends DefaultProps {
   inputValue?: string;
   isOpen?: boolean;
   itemToString?: (item?: T) => string;
-  onClose?: (...args: Array<any>) => void;
+  onClose?: (...args: any[]) => void;
   onInputValueChange?: (value: string) => void;
   onMenuOpen?: () => void;
-  onOpen?: (...args: Array<any>) => void;
+  onOpen?: (...args: any[]) => void;
   onSelect?: (
     item: T,
     state?: State<T>,
@@ -416,7 +416,7 @@ class AutoComplete<T extends Item> extends Component<AutoCompleteProps<T>, State
    *
    * This is exposed to render function
    */
-  openMenu = (...args: Array<any>) => {
+  openMenu = (...args: any[]) => {
     const {onOpen, disabled} = this.props;
 
     onOpen?.(...args);
@@ -436,7 +436,7 @@ class AutoComplete<T extends Item> extends Component<AutoCompleteProps<T>, State
    *
    * This is exposed to render function
    */
-  closeMenu = (...args: Array<any>) => {
+  closeMenu = (...args: any[]) => {
     const {onClose, resetInputOnClose} = this.props;
 
     onClose?.(...args);

+ 1 - 1
static/app/components/avatar/avatarList.tsx

@@ -26,7 +26,7 @@ type Props = {
   teams?: Team[];
   tooltipOptions?: UserAvatarProps['tooltipOptions'];
   typeAvatars?: string;
-  users?: Array<Actor | AvatarUser>;
+  users?: (Actor | AvatarUser)[];
 };
 
 export const CollapsedAvatars = forwardRef(function CollapsedAvatars(

+ 2 - 2
static/app/components/charts/eventsRequest.tsx

@@ -144,7 +144,7 @@ type EventsRequestPartialProps = {
   /**
    * List of environments to query
    */
-  environment?: Readonly<string[]>;
+  environment?: readonly string[];
   /**
    * Is query out of retention
    */
@@ -181,7 +181,7 @@ type EventsRequestPartialProps = {
   /**
    * List of project ids to query
    */
-  project?: Readonly<number[]>;
+  project?: readonly number[];
   /**
    * A container for query batching data and functions.
    */

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