Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.

Commit 2f28ade

Browse files
committed
fix: @typescript-eslint/no-explicit-any
1 parent 31c11f2 commit 2f28ade

File tree

16 files changed

+74
-44
lines changed

16 files changed

+74
-44
lines changed

src/App/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import '../styles/main.scss';
1515
import 'normalize.css';
1616
import Footer from '../components/Footer';
1717

18-
export const AppContext = React.createContext<null>(null);
18+
export const AppContext = React.createContext<{}>({});
1919
export const AppContextProvider = AppContext.Provider;
2020
export const AppContextConsumer = AppContext.Consumer;
2121

@@ -49,7 +49,7 @@ export default class App extends Component {
4949
public render(): React.ReactElement<HTMLDivElement> {
5050
const { isLoading, isUserLoggedIn, packages, logoUrl, user, scope } = this.state;
5151

52-
const context: any = { isUserLoggedIn, packages, logoUrl, user, scope };
52+
const context = { isUserLoggedIn, packages, logoUrl, user, scope };
5353

5454
return (
5555
// @ts-ignore

src/components/ActionBar/ActionBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ACTIONS = {
2525
},
2626
};
2727

28-
class ActionBar extends Component<any, any> {
28+
class ActionBar extends Component {
2929
public render(): ReactElement<HTMLElement> {
3030
return (
3131
<DetailContextConsumer>
@@ -36,7 +36,7 @@ class ActionBar extends Component<any, any> {
3636
);
3737
}
3838

39-
private renderIconsWithLink(link: string, component: any): ReactElement<HTMLElement> {
39+
private renderIconsWithLink(link: string, component: JSX.Element): ReactElement<HTMLElement> {
4040
return (
4141
<a href={link} target={'_blank'}>
4242
{component}

src/components/AutoComplete/AutoComplete.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import MenuItem from '@material-ui/core/MenuItem';
77
import { fontWeight } from '../../utils/styles/sizes';
88
import { Wrapper, InputField, SuggestionContainer } from './styles';
99

10-
export interface Props {
11-
suggestions: any[];
10+
interface Props {
11+
suggestions: unknown[];
1212
suggestionsLoading?: boolean;
1313
suggestionsLoaded?: boolean;
1414
suggestionsError?: boolean;
1515
apiLoading?: boolean;
1616
color?: string;
1717
value?: string;
1818
placeholder?: string;
19-
startAdornment?: any;
19+
startAdornment?: JSX.Element;
2020
disableUnderline?: boolean;
2121
onChange?: (event: KeyboardEvent<HTMLInputElement>, { newValue, method }: { newValue: string; method: string }) => void;
2222
onSuggestionsFetch?: ({ value: string }) => Promise<void>;
2323
onCleanSuggestions?: () => void;
24-
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: any[]; method: string }) => void;
24+
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: string[]; method: string }) => void;
2525
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
2626
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
2727
}

src/components/CopyToClipBoard/CopyToClipBoard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props {
1212
children?: React.ReactNode;
1313
}
1414

15-
const renderText: React.FC<any> = (text: string, children: React.ReactNode): React.ReactElement<HTMLElement> => {
15+
const renderText = (text, children): JSX.Element => {
1616
if (children) {
1717
return <ClipBoardCopyText>{children}</ClipBoardCopyText>;
1818
}

src/components/Dependencies/Dependencies.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
import React, { Component, Fragment, ReactElement } from 'react';
2-
import { withRouter } from 'react-router-dom';
2+
import { withRouter, RouteProps } from 'react-router-dom';
33
import CardContent from '@material-ui/core/CardContent';
44

55
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
66

77
import { CardWrap, Heading, Tags, Tag } from './styles';
88
import NoItems from '../NoItems';
99

10-
class DepDetail extends Component<any, any> {
11-
constructor(props: any) {
10+
interface DepDetailProps {
11+
name: string;
12+
version: string;
13+
onLoading: () => void;
14+
history: string[];
15+
}
16+
interface DepDetailState {
17+
name: string;
18+
version: string;
19+
}
20+
21+
class DepDetail extends Component<DepDetailProps & RouteProps, DepDetailState> {
22+
constructor(props: DepDetailProps) {
1223
super(props);
1324
const { name, version } = this.props;
1425

@@ -33,16 +44,16 @@ class DepDetail extends Component<any, any> {
3344
};
3445
}
3546

36-
const WrapperDependencyDetail = withRouter(DepDetail);
47+
const WrapperDependencyDetail = withRouter<any>(DepDetail);
3748

38-
class DependencyBlock extends Component<any, any> {
49+
class DependencyBlock extends Component<{ title: string; dependencies: [] }> {
3950
public render(): ReactElement<HTMLElement> {
4051
const { dependencies, title } = this.props;
41-
const deps = Object.entries(dependencies);
52+
const deps = Object.entries(dependencies) as [];
4253

4354
return (
4455
<DetailContextConsumer>
45-
{({ enableLoading }: any) => {
56+
{({ enableLoading }) => {
4657
return (
4758
<CardWrap>
4859
<CardContent>
@@ -56,15 +67,15 @@ class DependencyBlock extends Component<any, any> {
5667
);
5768
}
5869

59-
private renderTags = (deps: any, enableLoading: any) =>
70+
private renderTags = (deps: [], enableLoading?: () => void) =>
6071
deps.map(dep => {
61-
const [name, version] = dep;
72+
const [name, version] = dep as [string, string];
6273

6374
return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
6475
});
6576
}
6677

67-
class Dependencies extends Component<any, any> {
78+
class Dependencies extends Component {
6879
public state = {
6980
tabPosition: 0,
7081
};
@@ -79,7 +90,7 @@ class Dependencies extends Component<any, any> {
7990
);
8091
}
8192

82-
private checkDependencyLength(dependency: Record<string, any> = {}): boolean {
93+
private checkDependencyLength<T>(dependency: Record<string, T> = {}): boolean {
8394
return Object.keys(dependency).length > 0;
8495
}
8596

src/components/Developers/Developers.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ import { isEmail } from '../../utils/url';
1111
interface Props {
1212
type: 'contributors' | 'maintainers';
1313
}
14+
interface State {
15+
visibleDevs: number;
16+
}
1417

15-
class Developers extends Component<Props, any> {
18+
class Developers extends Component<Props, State> {
1619
public state = {
1720
visibleDevs: 6,
1821
};
1922

2023
public render(): JSX.Element {
2124
return (
2225
<DetailContextConsumer>
23-
{({ packageMeta }: any) => {
26+
{({ packageMeta }) => {
2427
const { type } = this.props;
25-
const developerType = packageMeta.latest[type];
28+
const developerType = packageMeta && packageMeta.latest[type];
2629
if (!developerType || developerType.length === 0) return null;
2730
return this.renderDevelopers(developerType, packageMeta);
2831
}}

src/components/Dist/Dist.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@ import React, { Component } from 'react';
22

33
import List from '@material-ui/core/List';
44

5-
import { DetailContextConsumer } from '../../pages/version/Version';
5+
import { DetailContextConsumer, VersionPageConsumerProps } from '../../pages/version/Version';
66
import { Heading, DistListItem, DistChips } from './styles';
77
import fileSizeSI from '../../utils/file-size';
8+
import { PackageMetaInterface } from 'types/packageMeta';
89

9-
class Dist extends Component<any, any> {
10+
class Dist extends Component {
1011
public render(): JSX.Element {
1112
return (
1213
<DetailContextConsumer>
13-
{(context: any) => {
14-
return this.renderDist(context);
14+
{(context: Partial<VersionPageConsumerProps>) => {
15+
return context && context.packageMeta && this.renderDist(context.packageMeta);
1516
}}
1617
</DetailContextConsumer>
1718
);
1819
}
1920

20-
private renderChips(dist: any, license: string): JSX.Element | never[] {
21+
private renderChips(dist, license: string): JSX.Element | never[] {
2122
const distDict = {
2223
'file-count': dist.fileCount,
2324
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),
@@ -43,8 +44,8 @@ class Dist extends Component<any, any> {
4344
return chipsList;
4445
}
4546

46-
private renderDist = ({ packageMeta }: any) => {
47-
const { dist = {}, license } = packageMeta.latest;
47+
private renderDist = (packageMeta: PackageMetaInterface) => {
48+
const { dist, license } = packageMeta && packageMeta.latest;
4849

4950
return (
5051
<List subheader={<Heading variant="subheading">{'Latest Distribution'}</Heading>}>

src/components/Header/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface Props {
3131
}
3232

3333
interface State {
34-
anchorEl?: any;
34+
anchorEl?: null | HTMLElement | ((element: HTMLElement) => HTMLElement);
3535
openInfoDialog: boolean;
3636
registryUrl: string;
3737
showMobileNavBar: boolean;

src/components/Icon/Icon.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { MouseEvent } from 'react';
22
import capitalize from 'lodash/capitalize';
3+
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
34

45
import { Svg, Img, ImgWrapper } from './styles';
56

@@ -57,10 +58,10 @@ export interface Props {
5758
name: keyof IconsMap;
5859
className?: string;
5960
onClick?: (event: MouseEvent<SVGElement | HTMLSpanElement>) => void;
60-
size?: 'sm' | 'md';
61+
size?: Breakpoint;
6162
pointer?: boolean;
6263
img?: boolean;
63-
modifiers?: any;
64+
modifiers?: null | undefined;
6465
}
6566

6667
const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {

src/components/Icon/styles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled, { css } from 'react-emotion';
2+
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';
23

3-
const getSize = (size: 'md' | 'sm' | string): string => {
4+
const getSize = (size: Breakpoint): string => {
45
switch (size) {
56
case 'md':
67
return `
@@ -15,7 +16,7 @@ const getSize = (size: 'md' | 'sm' | string): string => {
1516
}
1617
};
1718

18-
const commonStyle = ({ size = 'sm' as 'md' | 'sm' | string, pointer, modifiers = null }): string => css`
19+
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
1920
&& {
2021
display: inline-block;
2122
cursor: ${pointer ? 'pointer' : 'default'};

0 commit comments

Comments
 (0)