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

Commit

Permalink
fix: @typescript-eslint/no-explicit-any
Browse files Browse the repository at this point in the history
  • Loading branch information
griffithtp committed Jun 24, 2019
1 parent 31c11f2 commit 2f28ade
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/App/App.tsx
Expand Up @@ -15,7 +15,7 @@ import '../styles/main.scss';
import 'normalize.css';
import Footer from '../components/Footer';

export const AppContext = React.createContext<null>(null);
export const AppContext = React.createContext<{}>({});
export const AppContextProvider = AppContext.Provider;
export const AppContextConsumer = AppContext.Consumer;

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

const context: any = { isUserLoggedIn, packages, logoUrl, user, scope };
const context = { isUserLoggedIn, packages, logoUrl, user, scope };

return (
// @ts-ignore
Expand Down
4 changes: 2 additions & 2 deletions src/components/ActionBar/ActionBar.tsx
Expand Up @@ -25,7 +25,7 @@ const ACTIONS = {
},
};

class ActionBar extends Component<any, any> {
class ActionBar extends Component {
public render(): ReactElement<HTMLElement> {
return (
<DetailContextConsumer>
Expand All @@ -36,7 +36,7 @@ class ActionBar extends Component<any, any> {
);
}

private renderIconsWithLink(link: string, component: any): ReactElement<HTMLElement> {
private renderIconsWithLink(link: string, component: JSX.Element): ReactElement<HTMLElement> {
return (
<a href={link} target={'_blank'}>
{component}
Expand Down
8 changes: 4 additions & 4 deletions src/components/AutoComplete/AutoComplete.tsx
Expand Up @@ -7,21 +7,21 @@ import MenuItem from '@material-ui/core/MenuItem';
import { fontWeight } from '../../utils/styles/sizes';
import { Wrapper, InputField, SuggestionContainer } from './styles';

export interface Props {
suggestions: any[];
interface Props {
suggestions: unknown[];
suggestionsLoading?: boolean;
suggestionsLoaded?: boolean;
suggestionsError?: boolean;
apiLoading?: boolean;
color?: string;
value?: string;
placeholder?: string;
startAdornment?: any;
startAdornment?: JSX.Element;
disableUnderline?: boolean;
onChange?: (event: KeyboardEvent<HTMLInputElement>, { newValue, method }: { newValue: string; method: string }) => void;
onSuggestionsFetch?: ({ value: string }) => Promise<void>;
onCleanSuggestions?: () => void;
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: any[]; method: string }) => void;
onClick?: (event: KeyboardEvent<HTMLInputElement>, { suggestionValue, method }: { suggestionValue: string[]; method: string }) => void;
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/CopyToClipBoard/CopyToClipBoard.tsx
Expand Up @@ -12,7 +12,7 @@ interface Props {
children?: React.ReactNode;
}

const renderText: React.FC<any> = (text: string, children: React.ReactNode): React.ReactElement<HTMLElement> => {
const renderText = (text, children): JSX.Element => {
if (children) {
return <ClipBoardCopyText>{children}</ClipBoardCopyText>;
}
Expand Down
33 changes: 22 additions & 11 deletions src/components/Dependencies/Dependencies.tsx
@@ -1,14 +1,25 @@
import React, { Component, Fragment, ReactElement } from 'react';
import { withRouter } from 'react-router-dom';
import { withRouter, RouteProps } from 'react-router-dom';
import CardContent from '@material-ui/core/CardContent';

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

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

class DepDetail extends Component<any, any> {
constructor(props: any) {
interface DepDetailProps {
name: string;
version: string;
onLoading: () => void;
history: string[];
}
interface DepDetailState {
name: string;
version: string;
}

class DepDetail extends Component<DepDetailProps & RouteProps, DepDetailState> {
constructor(props: DepDetailProps) {
super(props);
const { name, version } = this.props;

Expand All @@ -33,16 +44,16 @@ class DepDetail extends Component<any, any> {
};
}

const WrapperDependencyDetail = withRouter(DepDetail);
const WrapperDependencyDetail = withRouter<any>(DepDetail);

class DependencyBlock extends Component<any, any> {
class DependencyBlock extends Component<{ title: string; dependencies: [] }> {
public render(): ReactElement<HTMLElement> {
const { dependencies, title } = this.props;
const deps = Object.entries(dependencies);
const deps = Object.entries(dependencies) as [];

return (
<DetailContextConsumer>
{({ enableLoading }: any) => {
{({ enableLoading }) => {
return (
<CardWrap>
<CardContent>
Expand All @@ -56,15 +67,15 @@ class DependencyBlock extends Component<any, any> {
);
}

private renderTags = (deps: any, enableLoading: any) =>
private renderTags = (deps: [], enableLoading?: () => void) =>
deps.map(dep => {
const [name, version] = dep;
const [name, version] = dep as [string, string];

return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
});
}

class Dependencies extends Component<any, any> {
class Dependencies extends Component {
public state = {
tabPosition: 0,
};
Expand All @@ -79,7 +90,7 @@ class Dependencies extends Component<any, any> {
);
}

private checkDependencyLength(dependency: Record<string, any> = {}): boolean {
private checkDependencyLength<T>(dependency: Record<string, T> = {}): boolean {
return Object.keys(dependency).length > 0;
}

Expand Down
9 changes: 6 additions & 3 deletions src/components/Developers/Developers.tsx
Expand Up @@ -11,18 +11,21 @@ import { isEmail } from '../../utils/url';
interface Props {
type: 'contributors' | 'maintainers';
}
interface State {
visibleDevs: number;
}

class Developers extends Component<Props, any> {
class Developers extends Component<Props, State> {
public state = {
visibleDevs: 6,
};

public render(): JSX.Element {
return (
<DetailContextConsumer>
{({ packageMeta }: any) => {
{({ packageMeta }) => {
const { type } = this.props;
const developerType = packageMeta.latest[type];
const developerType = packageMeta && packageMeta.latest[type];
if (!developerType || developerType.length === 0) return null;
return this.renderDevelopers(developerType, packageMeta);
}}
Expand Down
15 changes: 8 additions & 7 deletions src/components/Dist/Dist.tsx
Expand Up @@ -2,22 +2,23 @@ import React, { Component } from 'react';

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

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

class Dist extends Component<any, any> {
class Dist extends Component {
public render(): JSX.Element {
return (
<DetailContextConsumer>
{(context: any) => {
return this.renderDist(context);
{(context: Partial<VersionPageConsumerProps>) => {
return context && context.packageMeta && this.renderDist(context.packageMeta);
}}
</DetailContextConsumer>
);
}

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

private renderDist = ({ packageMeta }: any) => {
const { dist = {}, license } = packageMeta.latest;
private renderDist = (packageMeta: PackageMetaInterface) => {
const { dist, license } = packageMeta && packageMeta.latest;

return (
<List subheader={<Heading variant="subheading">{'Latest Distribution'}</Heading>}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Expand Up @@ -31,7 +31,7 @@ interface Props {
}

interface State {
anchorEl?: any;
anchorEl?: null | HTMLElement | ((element: HTMLElement) => HTMLElement);
openInfoDialog: boolean;
registryUrl: string;
showMobileNavBar: boolean;
Expand Down
5 changes: 3 additions & 2 deletions src/components/Icon/Icon.tsx
@@ -1,5 +1,6 @@
import React, { MouseEvent } from 'react';
import capitalize from 'lodash/capitalize';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';

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

Expand Down Expand Up @@ -57,10 +58,10 @@ export interface Props {
name: keyof IconsMap;
className?: string;
onClick?: (event: MouseEvent<SVGElement | HTMLSpanElement>) => void;
size?: 'sm' | 'md';
size?: Breakpoint;
pointer?: boolean;
img?: boolean;
modifiers?: any;
modifiers?: null | undefined;
}

const Icon: React.FC<Props> = ({ className, name, size = 'sm', img = false, pointer = false, ...props }) => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/Icon/styles.ts
@@ -1,6 +1,7 @@
import styled, { css } from 'react-emotion';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';

const getSize = (size: 'md' | 'sm' | string): string => {
const getSize = (size: Breakpoint): string => {
switch (size) {
case 'md':
return `
Expand All @@ -15,7 +16,7 @@ const getSize = (size: 'md' | 'sm' | string): string => {
}
};

const commonStyle = ({ size = 'sm' as 'md' | 'sm' | string, pointer, modifiers = null }): string => css`
const commonStyle = ({ size = 'sm' as Breakpoint, pointer, modifiers = null }): string => css`
&& {
display: inline-block;
cursor: ${pointer ? 'pointer' : 'default'};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Label/Label.tsx
Expand Up @@ -6,7 +6,7 @@ interface Props {
text: string;
capitalize?: boolean;
weight?: string;
modifiers?: any;
modifiers?: null | undefined;
}

const Wrapper = styled('div')`
Expand Down
3 changes: 2 additions & 1 deletion src/components/NotFound/NotFound.tsx
Expand Up @@ -6,10 +6,11 @@ import { RouteComponentProps, withRouter } from 'react-router-dom';

import PackageImg from './img/package.svg';
import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles';
import { Breakpoint } from '@material-ui/core/styles/createBreakpoints';

export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";

export type NotFoundProps = RouteComponentProps & { width: any; history: any };
export type NotFoundProps = RouteComponentProps & { width: Breakpoint; history };

const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
const handleGoTo = (to: string): (() => void | undefined) => () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/RegistryInfoContent/RegistryInfoContent.tsx
Expand Up @@ -30,7 +30,7 @@ class RegistryInfoContent extends Component<Props, State> {
return <div>{this.renderTabs()}</div>;
}

private handleChange = (event: any, tabPosition: number) => {
private handleChange = (event: React.ChangeEvent<{}>, tabPosition: number) => {
event.preventDefault();
this.setState({ tabPosition });
};
Expand Down
17 changes: 12 additions & 5 deletions src/components/Search/Search.tsx
Expand Up @@ -11,11 +11,15 @@ import colors from '../../utils/styles/colors';

export interface State {
search: string;
suggestions: any[];
suggestions: unknown[];
loading: boolean;
loaded: boolean;
error: boolean;
}
interface AbortControllerInterface {
signal: () => void;
abort: () => void;
}

export type cancelAllSearchRequests = () => void;
export type handlePackagesClearRequested = () => void;
Expand All @@ -31,8 +35,6 @@ const CONSTANTS = {
};

export class Search extends Component<RouteComponentProps<{}>, State> {
private requestList: any[];

constructor(props: RouteComponentProps<{}>) {
super(props);
this.state = {
Expand Down Expand Up @@ -96,7 +98,10 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
/**
* When an user select any package by clicking or pressing return key.
*/
private handleClickSearch: handleClickSearch = (event, { suggestionValue, method }: any) => {
private handleClickSearch = (
event: React.KeyboardEvent<HTMLInputElement>,
{ suggestionValue, method }: { suggestionValue: string[]; method: string }
): void | undefined => {
const { history } = this.props;
// stops event bubbling
event.stopPropagation();
Expand Down Expand Up @@ -163,7 +168,9 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
);
}

public getAdorment(): ReactElement<HTMLElement> {
private requestList: AbortControllerInterface[];

public getAdorment(): JSX.Element {
return (
<InputAdornment position={'start'} style={{ color: colors.white }}>
<IconSearch />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Versions/Versions.tsx
Expand Up @@ -8,7 +8,7 @@ import { DIST_TAGS } from '../../../lib/constants';

const NOT_AVAILABLE = 'Not available';

class Versions extends React.PureComponent<any> {
class Versions extends React.PureComponent {
public render(): ReactElement<HTMLDivElement> {
return (
<DetailContextConsumer>
Expand Down
5 changes: 5 additions & 0 deletions types/packageMeta.ts
@@ -1,6 +1,11 @@
export interface PackageMetaInterface {
latest: {
name: string;
dist: {
fileCount: number;
unpackedSize: number;
};
license: string;
};
_uplinks: {};
}

0 comments on commit 2f28ade

Please sign in to comment.