Skip to content

Commit 2795da8

Browse files
feat(eslint): enable @typescript-eslint/no-unnecessary-type-parameters
1 parent df89359 commit 2795da8

File tree

36 files changed

+124
-118
lines changed

36 files changed

+124
-118
lines changed

eslint.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ export default typescript.config([
608608
'@typescript-eslint/no-for-in-array': 'error',
609609
'@typescript-eslint/no-unnecessary-template-expression': 'error',
610610
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
611+
'@typescript-eslint/no-unnecessary-type-parameters': 'error',
611612
'@typescript-eslint/switch-exhaustiveness-check': [
612613
'error',
613614
{considerDefaultExhaustiveForUnions: true},

static/app/components/core/compactSelect/utils.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function getSearchConfig<Value extends SelectKey>(
3636
return search;
3737
}
3838

39-
export function getEscapedKey<Value extends SelectKey | undefined>(value: Value): string {
39+
export function getEscapedKey(value: SelectKey): string {
4040
return CSS.escape(String(value));
4141
}
4242

@@ -287,8 +287,8 @@ export function getSortedItems<Value extends SelectKey>(
287287
* selected, then this function selects all of them. If all of the options are selected,
288288
* then this function unselects all of them.
289289
*/
290-
function toggleOptions<Value extends SelectKey>(
291-
optionKeys: Value[],
290+
function toggleOptions(
291+
optionKeys: SelectKey[],
292292
selectionManager: ListState<any>['selectionManager']
293293
) {
294294
const {selectedKeys} = selectionManager;

static/app/components/events/autofix/preferences/hooks/useOrganizationRepositories.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ interface Props {
1717
/**
1818
* @deprecated Use organizationRepositoriesInfiniteOptions instead.
1919
*/
20-
export function useOrganizationRepositories<T extends Repository = Repository>(
21-
{query = {}} = {} as Props
22-
) {
20+
export function useOrganizationRepositories({query = {}} = {} as Props) {
2321
const queryRef = useRef<Record<string, string>>(query);
2422
useEffect(() => {
2523
queryRef.current = query;
@@ -39,15 +37,15 @@ export function useOrganizationRepositories<T extends Repository = Repository>(
3937
[organization.slug]
4038
);
4139

42-
const {pages, isFetching, ...rest} = useFetchSequentialPages<T[]>({
40+
const {pages, isFetching, ...rest} = useFetchSequentialPages<Repository[]>({
4341
getQueryKey,
4442
perPage: 100,
4543
enabled: true,
4644
});
4745

4846
const data = useMemo(() => {
4947
const flattenedRepos = pages.flat();
50-
const uniqueReposMap = new Map<string, T>();
48+
const uniqueReposMap = new Map<string, Repository>();
5149
flattenedRepos.forEach(repo => {
5250
if (repo.externalId && !uniqueReposMap.has(repo.externalId)) {
5351
uniqueReposMap.set(repo.externalId, repo);

static/app/components/events/contexts/utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export function getRelativeTimeFromEventDateCreated(
133133

134134
type KnownDataDetails = Omit<KeyValueListDataItem, 'key'> | undefined;
135135

136+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
136137
export function getKnownData<Data, DataType>({
137138
data,
138139
knownDataTypes,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ export class WaterfallModel {
200200
threshold: 0.6,
201201
location: 0,
202202
distance: 100,
203-
maxPatternLength: 32,
204203
});
205204
}
206205

static/app/components/issues/groupList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export function GroupList({
176176
const hasLogicBoolean = useMemo(
177177
() =>
178178
parsedQuery
179-
? treeResultLocator<boolean>({
179+
? treeResultLocator({
180180
tree: parsedQuery,
181181
noResultValue: false,
182182
visitorTest: ({token, returnResult}) => {

static/app/components/pipeline/types.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ export interface PipelineStepProps<
4949
}
5050

5151
/**
52-
* Identity function that casts the raw completion data to a typed shape.
52+
* Identity function that asserts the raw completion data to a typed shape.
5353
* Avoids the verbose `(data: Record<string, unknown>) => data as unknown as T`
5454
* boilerplate in every pipeline definition.
5555
*/
56+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
5657
export function pipelineComplete<T>(data: Record<string, unknown>): T {
5758
return data as unknown as T;
5859
}

static/app/components/searchQueryBuilder/tokens/combobox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ function menuIsOpen({
177177
return openState && totalOptions > hiddenOptions.size;
178178
}
179179

180-
function useHiddenItems<T extends SelectOptionOrSectionWithKey<string>>({
180+
function useHiddenItems({
181181
items,
182182
filterValue,
183183
maxOptions,
184184
shouldFilterResults,
185185
showAskSeerOption,
186186
}: {
187187
filterValue: string;
188-
items: T[];
188+
items: Array<SelectOptionOrSectionWithKey<string>>;
189189
showAskSeerOption: boolean;
190190
maxOptions?: number;
191191
shouldFilterResults?: boolean;

static/app/components/searchSyntax/parser.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ export class TokenConverter {
886886
/**
887887
* Checks a filter against some non-grammar validation rules
888888
*/
889-
checkFilterWarning = <T extends FilterType>(key: FilterMap[T]['key']) => {
889+
checkFilterWarning = (key: FilterMap[FilterType]['key']) => {
890890
if (
891891
![
892892
Token.KEY_SIMPLE,
@@ -1513,10 +1513,12 @@ export const defaultConfig: SearchConfig = {
15131513
},
15141514
};
15151515

1516-
function tryParseSearch<T extends {config: SearchConfig}>(
1517-
query: string,
1518-
config: T
1519-
): ParseResult | null {
1516+
interface SearchParseConfig {
1517+
[i: string]: any;
1518+
config: SearchConfig;
1519+
}
1520+
1521+
function tryParseSearch(query: string, config: SearchParseConfig): ParseResult | null {
15201522
try {
15211523
return parse(query, config);
15221524
} catch (e: any) {

static/app/components/searchSyntax/utils.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class TokenResultFoundError extends Error {
2626
*/
2727
const skipTokenMarker = Symbol('Returned to skip visiting a token');
2828

29-
type VisitorFn = (opts: {
29+
type VisitorFn<T> = (opts: {
3030
/**
3131
* Call this to return the provided value as the result of treeResultLocator
3232
*/
33-
returnResult: (result: any) => TokenResultFoundError;
33+
returnResult: (result: T) => TokenResultFoundError;
3434
/**
3535
* Return this to skip visiting any inner tokens
3636
*/
@@ -41,12 +41,12 @@ type VisitorFn = (opts: {
4141
token: TokenResult<Token>;
4242
}) => null | TokenResultFoundError | typeof skipTokenMarker;
4343

44-
type TreeResultLocatorOpts = {
44+
type TreeResultLocatorOpts<T> = {
4545
/**
4646
* The value to return when returnValue was never called and all nodes of the
4747
* search tree were visited.
4848
*/
49-
noResultValue: any;
49+
noResultValue: T;
5050
/**
5151
* The tree to visit
5252
*/
@@ -56,7 +56,7 @@ type TreeResultLocatorOpts = {
5656
* visiting. May also indicate that we want to skip any further traversal of
5757
* inner nodes.
5858
*/
59-
visitorTest: VisitorFn;
59+
visitorTest: VisitorFn<T>;
6060
};
6161

6262
/**
@@ -72,7 +72,7 @@ export function treeResultLocator<T>({
7272
tree,
7373
visitorTest,
7474
noResultValue,
75-
}: TreeResultLocatorOpts): T {
75+
}: TreeResultLocatorOpts<T>): T {
7676
const returnResult = (result: any) => new TokenResultFoundError(result);
7777

7878
const nodeVisitor = (token: TokenResult<Token> | null) => {

0 commit comments

Comments
 (0)