Browse Source

chore(eslint): Set array-type eslint rule to use the array-simple option (#83927)

This was suggested in slack and I really like the
[`array-simple`](https://typescript-eslint.io/rules/array-type/#array-simple)
variation over the default
[`array`](https://typescript-eslint.io/rules/array-type/#array) that we
enabled [yesterday](https://github.com/getsentry/sentry/pull/83804).

TL/DR the `array-simple` variation will prefer `MyType[]` when `MyType`
is a simple, or named type. If there's anything more complex in that
spot, like a union or unnamed object type then we'll see `Array<...>`
instead. This means in practice we wont' see round braces near our
complex array definitions; less syntax for my eyes to parse.
Ryan Albrecht 1 month ago
parent
commit
06abe0c343

+ 1 - 3
api-docs/paths/projects/dsyms.json

@@ -110,9 +110,7 @@
         "auth_token": ["project:write"]
       }
     ],
-    "servers": [
-      {"url": "https://{region}.sentry.io"}
-    ]
+    "servers": [{ "url": "https://{region}.sentry.io" }]
   },
   "delete": {
     "tags": ["Projects"],

+ 1 - 3
api-docs/paths/releases/project-release-files.json

@@ -172,8 +172,6 @@
         "auth_token": ["project:releases"]
       }
     ],
-    "servers": [
-      {"url": "https://{region}.sentry.io"}
-    ]
+    "servers": [{ "url": "https://{region}.sentry.io" }]
   }
 }

+ 1 - 3
api-docs/paths/releases/release-files.json

@@ -136,8 +136,6 @@
         "auth_token": ["project:releases"]
       }
     ],
-    "servers": [
-      {"url": "https://{region}.sentry.io"}
-    ]
+    "servers": [{ "url": "https://{region}.sentry.io" }]
   }
 }

+ 1 - 0
eslint.config.mjs

@@ -431,6 +431,7 @@ export default typescript.config([
       '@typescript-eslint/unified-signatures': 'off', // TODO(ryan953): Fix violations and delete this line
 
       // Stylistic overrides
+      '@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
       '@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

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

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

+ 1 - 1
static/app/actionCreators/modal.tsx

@@ -48,7 +48,7 @@ type EmailVerificationModalOptions = {
 };
 
 type InviteMembersModalOptions = {
-  initialData?: Partial<InviteRow>[];
+  initialData?: Array<Partial<InviteRow>>;
   onClose?: () => void;
   source?: string;
 };

+ 3 - 2
static/app/api.tsx

@@ -125,8 +125,9 @@ const ALLOWED_ANON_PAGES = [
 /**
  * Return true if we should skip calling the normal error handler
  */
-const globalErrorHandlers: ((resp: ResponseMeta, options: RequestOptions) => boolean)[] =
-  [];
+const globalErrorHandlers: Array<
+  (resp: ResponseMeta, options: RequestOptions) => boolean
+> = [];
 
 export const initApiClientErrorHandling = () =>
   globalErrorHandlers.push((resp: ResponseMeta, options: RequestOptions) => {

+ 16 - 11
static/app/chartcuterie/discover.tsx

@@ -20,7 +20,7 @@ const discoverxAxis = XAxis({
   axisLabel: {fontSize: 11, fontFamily: DEFAULT_FONT_FAMILY},
 });
 
-export const discoverCharts: RenderDescriptor<ChartType>[] = [];
+export const discoverCharts: Array<RenderDescriptor<ChartType>> = [];
 
 discoverCharts.push({
   key: ChartType.SLACK_DISCOVER_TOTAL_PERIOD,
@@ -61,7 +61,7 @@ discoverCharts.push({
           name: s.key,
           stack: 'area',
           data: s.data.map(
-            ([timestamp, countsForTimestamp]: [number, {count: number}[]]) => [
+            ([timestamp, countsForTimestamp]: [number, Array<{count: number}>]) => [
               timestamp * 1000,
               countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
             ]
@@ -124,7 +124,7 @@ discoverCharts.push({
           name: s.key,
           stack: 'area',
           data: s.data.map(
-            ([timestamp, countsForTimestamp]: [number, {count: number}[]]) => ({
+            ([timestamp, countsForTimestamp]: [number, Array<{count: number}>]) => ({
               value: [
                 timestamp * 1000,
                 countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
@@ -187,7 +187,7 @@ discoverCharts.push({
         AreaSeries({
           stack: 'area',
           data: topSeries.data.map(
-            ([timestamp, countsForTimestamp]: [number, {count: number}[]]) => [
+            ([timestamp, countsForTimestamp]: [number, Array<{count: number}>]) => [
               timestamp * 1000,
               countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
             ]
@@ -247,7 +247,7 @@ discoverCharts.push({
       .map((topSeries, i) =>
         LineSeries({
           data: topSeries.data.map(
-            ([timestamp, countsForTimestamp]: [number, {count: number}[]]) => [
+            ([timestamp, countsForTimestamp]: [number, Array<{count: number}>]) => [
               timestamp * 1000,
               countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
             ]
@@ -308,7 +308,7 @@ discoverCharts.push({
         BarSeries({
           stack: 'area',
           data: topSeries.data.map(
-            ([timestamp, countsForTimestamp]: [number, {count: number}[]]) => [
+            ([timestamp, countsForTimestamp]: [number, Array<{count: number}>]) => [
               timestamp * 1000,
               countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
             ]
@@ -389,10 +389,12 @@ discoverCharts.push({
             stack: 'area',
             data: s.data
               .slice(dataMiddleIndex)
-              .map(([timestamp, countsForTimestamp]: [number, {count: number}[]]) => [
-                timestamp * 1000,
-                countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
-              ]),
+              .map(
+                ([timestamp, countsForTimestamp]: [number, Array<{count: number}>]) => [
+                  timestamp * 1000,
+                  countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
+                ]
+              ),
             lineStyle: {color: color?.[i], opacity: 1, width: 0.4},
             areaStyle: {color: color?.[i], opacity: 1},
           })
@@ -402,7 +404,10 @@ discoverCharts.push({
             name: t('previous %s', s.key),
             stack: 'previous',
             data: previous.map(
-              ([_, countsForTimestamp]: [number, {count: number}[]], index: number) => [
+              (
+                [_, countsForTimestamp]: [number, Array<{count: number}>],
+                index: number
+              ) => [
                 current[index][0] * 1000,
                 countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
               ]

+ 1 - 1
static/app/chartcuterie/metricAlert.tsx

@@ -58,7 +58,7 @@ function transformAreaSeries(series: AreaChartSeries[]): LineSeriesOption[] {
   });
 }
 
-export const metricAlertCharts: RenderDescriptor<ChartType>[] = [];
+export const metricAlertCharts: Array<RenderDescriptor<ChartType>> = [];
 
 metricAlertCharts.push({
   key: ChartType.SLACK_METRIC_ALERT_EVENTS,

+ 1 - 1
static/app/chartcuterie/performance.tsx

@@ -13,7 +13,7 @@ import {DEFAULT_FONT_FAMILY, slackChartDefaults, slackChartSize} from './slack';
 import type {RenderDescriptor} from './types';
 import {ChartType} from './types';
 
-export const performanceCharts: RenderDescriptor<ChartType>[] = [];
+export const performanceCharts: Array<RenderDescriptor<ChartType>> = [];
 
 export type FunctionRegressionPercentileData = {
   data: EventsStatsSeries<'p95()'>;

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