Skip to content

Commit 9952d7f

Browse files
feat: enable typescript biome rules (#69534)
We weren't leveraging enough Typescript rules. Adding these caught some... --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent f928193 commit 9952d7f

File tree

25 files changed

+83
-87
lines changed

25 files changed

+83
-87
lines changed

biome.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@
2121
"noUnreachable": "error",
2222
"useHookAtTopLevel": "error",
2323
"useIsNan": "error",
24-
"noUnusedPrivateClassMembers": "error"
24+
"noUnusedPrivateClassMembers": "error",
25+
"noInvalidUseBeforeDeclaration": "error"
2526
},
2627
"complexity": {
2728
"useFlatMap": "error",
2829
"useOptionalChain": "error",
2930
"noEmptyTypeParameters": "error",
30-
"noUselessLoneBlockStatements": "error"
31+
"noUselessLoneBlockStatements": "error",
32+
"noUselessEmptyExport": "error",
33+
"noUselessConstructor": "error",
34+
"noUselessTypeConstraint": "error"
3135
},
3236
"nursery": {
3337
"noDuplicateJsonKeys": "error",
@@ -53,7 +57,9 @@
5357
"noUnsafeNegation": "error",
5458
"useIsArray": "error",
5559
"noApproximativeNumericConstant": "error",
56-
"noMisrefactoredShorthandAssign": "error"
60+
"noMisrefactoredShorthandAssign": "error",
61+
"useAwait": "error",
62+
"useNamespaceKeyword": "error"
5763
},
5864
"style": {
5965
"noCommaOperator": "error",
@@ -64,7 +70,10 @@
6470
"useShorthandFunctionType": "error",
6571
"useExportType": "error",
6672
"useImportType": "error",
67-
"useNodejsImportProtocol": "error"
73+
"useNodejsImportProtocol": "error",
74+
"useLiteralEnumMembers": "error",
75+
"useEnumInitializers": "error",
76+
"useAsConstAssertion": "error"
6877
}
6978
}
7079
},
@@ -108,12 +117,7 @@
108117
},
109118
"overrides": [
110119
{
111-
"include": [
112-
"biome.json",
113-
"config/tsconfig.*",
114-
"tsconfig.json",
115-
".vscode/*"
116-
],
120+
"include": ["biome.json", "config/tsconfig.*", "tsconfig.json", ".vscode/*"],
117121
"json": {
118122
"parser": {
119123
"allowComments": true,

static/app/components/customIgnoreCountModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CustomIgnoreCountModal extends Component<Props, State> {
6666
label={countLabel}
6767
name="count"
6868
value={count}
69-
onChange={val => this.handleChange('count' as 'count', Number(val))}
69+
onChange={val => this.handleChange('count' as const, Number(val))}
7070
required
7171
placeholder={t('e.g. 100')}
7272
/>

static/app/components/events/interfaces/spans/dragManager.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import {setBodyUserSelect} from 'sentry/utils/userselect';
1010
const MINIMUM_WINDOW_SIZE = 0.5 / 100; // 0.5% window size
1111

1212
enum ViewHandleType {
13-
LEFT,
14-
RIGHT,
13+
LEFT = 0,
14+
RIGHT = 1,
1515
}
1616

1717
export type DragManagerChildrenProps = {

static/app/components/events/interfaces/spans/types.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ export type ParsedTraceType = {
208208
};
209209

210210
export enum TickAlignment {
211-
LEFT,
212-
RIGHT,
213-
CENTER,
211+
LEFT = 0,
212+
RIGHT = 1,
213+
CENTER = 2,
214214
}
215215

216216
export type TraceContextType = {
@@ -263,15 +263,15 @@ export type DescendantGroup = {
263263
};
264264

265265
export enum GroupType {
266-
DESCENDANTS,
267-
SIBLINGS,
266+
DESCENDANTS = 0,
267+
SIBLINGS = 1,
268268
}
269269

270270
export enum SpanTreeNodeType {
271-
SPAN,
272-
DESCENDANT_GROUP,
273-
SIBLING_GROUP,
274-
MESSAGE,
271+
SPAN = 0,
272+
DESCENDANT_GROUP = 1,
273+
SIBLING_GROUP = 2,
274+
MESSAGE = 3,
275275
}
276276

277277
type SpanBarNode = {

static/app/data/platformCategories.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type {PlatformKey} from 'sentry/types/project';
22

33
export enum PlatformCategory {
4-
FRONTEND,
5-
MOBILE,
6-
BACKEND,
7-
SERVERLESS,
8-
DESKTOP,
9-
OTHER,
4+
FRONTEND = 0,
5+
MOBILE = 1,
6+
BACKEND = 2,
7+
SERVERLESS = 3,
8+
DESKTOP = 4,
9+
OTHER = 5,
1010
}
1111

1212
// Mirrors `FRONTEND` in src/sentry/utils/platform_categories.py

static/app/gettingStartedDocs/dotnet/dotnet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ dotnet add package Sentry.Profiling -v ${getPackageVersion(
5454
)}`;
5555

5656
enum DotNetPlatform {
57-
WINDOWS,
58-
IOS_MACCATALYST,
57+
WINDOWS = 0,
58+
IOS_MACCATALYST = 1,
5959
}
6060

6161
const getConfigureSnippet = (params: Params, platform?: DotNetPlatform) => `

static/app/gettingStartedDocs/dotnet/maui.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ dotnet add package Sentry.Profiling -v ${getPackageVersion(
5050
)}`;
5151

5252
enum DotNetPlatform {
53-
WINDOWS,
54-
IOS_MACCATALYST,
53+
WINDOWS = 0,
54+
IOS_MACCATALYST = 1,
5555
}
5656

5757
const getConfigureSnippet = (params: Params, platform?: DotNetPlatform) => `

static/app/utils/crashReports.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export function formatStoreCrashReports(
2323
}
2424

2525
export enum SettingScope {
26-
ORGANIZATION,
27-
PROJECT,
26+
ORGANIZATION = 0,
27+
PROJECT = 1,
2828
}
2929
export function getStoreCrashReportsValues(settingScope: SettingScope) {
3030
const values: Array<number | null> = [

static/app/utils/performance/contexts/pageAlert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {useLocalStorageState} from 'sentry/utils/useLocalStorageState';
99
type PageAlertType = keyof Theme['alert'];
1010

1111
export enum DismissId {
12-
RESOURCE_SIZE_ALERT,
12+
RESOURCE_SIZE_ALERT = 0,
1313
}
1414

1515
export type PageAlertOptions = {

static/app/utils/profiling/fzf/fzf.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ const bonusConsecutive = -(scoreGapStart + scoreGapExtention);
4141
const bonusFirstCharMultiplier = 2;
4242

4343
enum CharTypes {
44-
CHAR_LOWER,
45-
CHAR_UPPER,
46-
CHAR_NUMBER,
47-
CHAR_NON_WORD,
44+
CHAR_LOWER = 0,
45+
CHAR_UPPER = 1,
46+
CHAR_NUMBER = 2,
47+
CHAR_NON_WORD = 3,
4848
}
4949

5050
const CharCodes = {

static/app/utils/replays/timer.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ export class Timer extends EventTarget {
1010
private _additionalTime: number = 0;
1111
private _callbacks: Map<number, (() => void)[]> = new Map();
1212

13-
constructor() {
14-
super();
15-
}
16-
1713
step = () => {
1814
if (!this._active) {
1915
return;

static/app/utils/tokenizeSearch.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export const ALLOWED_WILDCARD_FIELDS = [
88
export const EMPTY_OPTION_VALUE = '(empty)' as const;
99

1010
export enum TokenType {
11-
OPERATOR,
12-
FILTER,
13-
FREE_TEXT,
11+
OPERATOR = 0,
12+
FILTER = 1,
13+
FREE_TEXT = 2,
1414
}
1515

1616
export type Token = {

static/app/views/alerts/rules/metric/types.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type {SchemaFormConfig} from 'sentry/views/settings/organizationIntegrati
66
import type {Incident} from '../../types';
77

88
export enum AlertRuleThresholdType {
9-
ABOVE,
10-
BELOW,
9+
ABOVE = 0,
10+
BELOW = 1,
1111
}
1212

1313
export enum AlertRuleTriggerType {

static/app/views/discover/table/columnEditCollection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ const GHOST_PADDING = 4;
7171
const MAX_COL_COUNT = 20;
7272

7373
enum PlaceholderPosition {
74-
TOP,
75-
BOTTOM,
74+
TOP = 0,
75+
BOTTOM = 1,
7676
}
7777

7878
class ColumnEditCollection extends Component<Props, State> {

static/app/views/issueList/utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {Organization} from 'sentry/types/organization';
55

66
export enum Query {
77
FOR_REVIEW = 'is:unresolved is:for_review assigned_or_suggested:[me, my_teams, none]',
8+
// biome-ignore lint/style/useLiteralEnumMembers: Disable for maintenance cost.
89
PRIORITIZED = NEW_DEFAULT_QUERY,
910
UNRESOLVED = 'is:unresolved',
1011
IGNORED = 'is:ignored',
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
const PREFIX = `api.performance.cache`;
2-
31
export enum Referrer {
4-
LANDING_CACHE_HIT_MISS_CHART = `${PREFIX}.landing-cache-hit-miss-chart`,
5-
LANDING_CACHE_THROUGHPUT_CHART = `${PREFIX}.landing-cache-throughput-chart`,
2+
LANDING_CACHE_HIT_MISS_CHART = `api.performance.cache.landing-cache-hit-miss-chart`,
3+
LANDING_CACHE_THROUGHPUT_CHART = `api.performance.cache.landing-cache-throughput-chart`,
64
}

static/app/views/performance/newTraceDetails/traceModels/traceTree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ export class TraceTreeNode<T extends TraceTree.NodeValue = TraceTree.NodeValue>
13561356

13571357
profiles: TraceTree.Profile[] = [];
13581358

1359-
private unit: 'milliseconds' = 'milliseconds';
1359+
private unit = 'milliseconds' as const;
13601360
private _depth: number | undefined;
13611361
private _children: TraceTreeNode[] = [];
13621362
private _spanChildren: TraceTreeNode[] = [];

static/app/views/projectInstall/issueAlertOptions.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import type {Organization} from 'sentry/types/organization';
1515
import withOrganization from 'sentry/utils/withOrganization';
1616

1717
export enum MetricValues {
18-
ERRORS,
19-
USERS,
18+
ERRORS = 0,
19+
USERS = 1,
2020
}
2121

2222
export enum RuleAction {
23-
DEFAULT_ALERT,
24-
CUSTOMIZED_ALERTS,
25-
CREATE_ALERT_LATER,
23+
DEFAULT_ALERT = 0,
24+
CUSTOMIZED_ALERTS = 1,
25+
CREATE_ALERT_LATER = 2,
2626
}
2727

2828
const ISSUE_ALERT_DEFAULT_ACTION: Omit<

static/app/views/relocation/relocation.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ function getRelocationOnboardingSteps(): StepDescriptor[] {
7272
}
7373

7474
enum LoadingState {
75-
FETCHED,
76-
FETCHING,
77-
ERROR,
75+
FETCHED = 0,
76+
FETCHING = 1,
77+
ERROR = 2,
7878
}
7979

8080
function RelocationOnboarding(props: Props) {

static/app/views/settings/projectSourceMaps/projectSourceMaps.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ enum SortBy {
4343
}
4444

4545
enum SourceMapsBundleType {
46-
RELEASE,
47-
DEBUG_ID,
46+
RELEASE = 0,
47+
DEBUG_ID = 1,
4848
}
4949

5050
function SourceMapsTableRow({

static/app/views/starfish/components/chart.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export const STARFISH_FIELDS: Record<string, {outputType: AggregationOutputType}
7272
};
7373

7474
export enum ChartType {
75-
BAR,
76-
LINE,
77-
AREA,
75+
BAR = 0,
76+
LINE = 1,
77+
AREA = 2,
7878
}
7979

8080
type Props = {

static/app/views/starfish/utils/sqlish/SQLishParser.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import type {Token} from 'sentry/views/starfish/utils/sqlish/types';
33
import grammar from './sqlish.pegjs';
44

55
export class SQLishParser {
6-
constructor() {}
7-
86
parse(sql: string) {
97
return grammar.parse(sql) as Token[];
108
}

static/app/views/starfish/views/screens/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ import {
4949
} from 'sentry/views/starfish/views/screens/utils';
5050

5151
export enum YAxis {
52-
WARM_START,
53-
COLD_START,
54-
TTID,
55-
TTFD,
56-
SLOW_FRAME_RATE,
57-
FROZEN_FRAME_RATE,
58-
THROUGHPUT,
59-
COUNT,
52+
WARM_START = 0,
53+
COLD_START = 1,
54+
TTID = 2,
55+
TTFD = 3,
56+
SLOW_FRAME_RATE = 4,
57+
FROZEN_FRAME_RATE = 5,
58+
THROUGHPUT = 6,
59+
COUNT = 7,
6060
}
6161

6262
export const TOP_SCREENS = 5;

static/app/views/starfish/views/screens/screenLoadSpans/charts.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ import {
4646
} from 'sentry/views/starfish/views/screens/utils';
4747

4848
export enum YAxis {
49-
WARM_START,
50-
COLD_START,
51-
TTID,
52-
TTFD,
53-
SLOW_FRAME_RATE,
54-
FROZEN_FRAME_RATE,
55-
THROUGHPUT,
56-
COUNT,
49+
WARM_START = 0,
50+
COLD_START = 1,
51+
TTID = 2,
52+
TTFD = 3,
53+
SLOW_FRAME_RATE = 4,
54+
FROZEN_FRAME_RATE = 5,
55+
THROUGHPUT = 6,
56+
COUNT = 7,
5757
}
5858

5959
type Props = {

tests/js/setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ window.IntersectionObserver = class IntersectionObserver {
226226
thresholds = [];
227227
takeRecords = jest.fn();
228228

229-
constructor() {}
230229
observe() {}
231230
unobserve() {}
232231
disconnect() {}

0 commit comments

Comments
 (0)