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/explicit-function-return-type
Browse files Browse the repository at this point in the history
  • Loading branch information
griffithtp committed Jun 24, 2019
1 parent 55f50e9 commit 31c11f2
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
10 changes: 5 additions & 5 deletions src/components/AutoComplete/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface Props {
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
}

const renderInputComponent = inputProps => {
const renderInputComponent = (inputProps): JSX.Element => {
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
return (
<InputField
Expand All @@ -46,7 +46,7 @@ const renderInputComponent = inputProps => {

const getSuggestionValue = (suggestion): string => suggestion.name;

const renderSuggestion = (suggestion, { query, isHighlighted }) => {
const renderSuggestion = (suggestion, { query, isHighlighted }): JSX.Element => {
const matches = match(suggestion.name, query);
const parts = parse(suggestion.name, matches);
return (
Expand All @@ -68,7 +68,7 @@ const renderSuggestion = (suggestion, { query, isHighlighted }) => {
);
};

const renderMessage = message => {
const renderMessage = (message): JSX.Element => {
return (
<MenuItem component="div" selected={false}>
<div>{message}</div>
Expand Down Expand Up @@ -98,7 +98,7 @@ const AutoComplete = ({
suggestionsLoading = false,
suggestionsLoaded = false,
suggestionsError = false,
}: Props) => {
}: Props): JSX.Element => {
const autosuggestProps = {
renderInputComponent,
suggestions,
Expand All @@ -119,7 +119,7 @@ const AutoComplete = ({
};

// this format avoid arrow function eslint rule
function renderSuggestionsContainer({ containerProps, children, query }) {
function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
return (
<SuggestionContainer {...containerProps} square={true}>
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Developers/Developers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Developers extends Component<Props, any> {
visibleDevs: 6,
};

public render() {
public render(): JSX.Element {
return (
<DetailContextConsumer>
{({ packageMeta }: any) => {
Expand Down Expand Up @@ -54,7 +54,7 @@ class Developers extends Component<Props, any> {
);
};

private renderLinkForMail(email, avatarComponent, packageName, version) {
private renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element {
if (!email || isEmail(email) === false) {
return avatarComponent;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dist/Dist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Heading, DistListItem, DistChips } from './styles';
import fileSizeSI from '../../utils/file-size';

class Dist extends Component<any, any> {
public render() {
public render(): JSX.Element {
return (
<DetailContextConsumer>
{(context: any) => {
Expand All @@ -17,7 +17,7 @@ class Dist extends Component<any, any> {
);
}

private renderChips(dist: any, license: string) {
private renderChips(dist: any, license: string): JSX.Element | never[] {
const distDict = {
'file-count': dist.fileCount,
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),
Expand Down
8 changes: 4 additions & 4 deletions src/components/NotFound/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";
export type NotFoundProps = RouteComponentProps & { width: any; history: any };

const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
const handleGoTo = (to: string) => () => {
const handleGoTo = (to: string): (() => void | undefined) => () => {
history.push(to);
};

const handleGoBack = () => () => {
const handleGoBack = (): ((e: React.MouseEvent<HTMLElement, MouseEvent>) => void | undefined) => () => {
history.goBack();
};

const renderList = () => (
const renderList = (): JSX.Element => (
<List>
<ListItem button={true} divider={true} onClick={handleGoTo('/')}>
{'Home'}
Expand All @@ -31,7 +31,7 @@ const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
</List>
);

const renderSubTitle = () => (
const renderSubTitle = (): JSX.Element => (
<Typography variant="subtitle1">
<div>{"The page you're looking for doesn't exist."}</div>
<div>{'Perhaps these links will help find what you are looking for:'}</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Package/Package.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { WrapperLink, Description, OverviewItem } from './styles';
* Generates one month back date from current time
* @return {object} date object
*/
const dateOneMonthAgo = () => new Date(1544377770747);
const dateOneMonthAgo = (): Date => new Date(1544377770747);

describe('<Package /> component', () => {
test.skip('should load the component', () => {
Expand Down
22 changes: 11 additions & 11 deletions src/components/RegistryInfoContent/RegistryInfoContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getCLISetRegistry, getCLIChangePassword, getCLISetConfigRegistry } from
import { NODE_MANAGER } from '../../utils/constants';

/* eslint react/prop-types:0 */
function TabContainer({ children }) {
function TabContainer({ children }): JSX.Element {
return (
<CommandContainer>
<Typography component="div" style={{ padding: 0, minHeight: 170 }}>
Expand All @@ -26,11 +26,16 @@ class RegistryInfoContent extends Component<Props, State> {
tabPosition: 0,
};

public render() {
public render(): JSX.Element {
return <div>{this.renderTabs()}</div>;
}

private renderTabs() {
private handleChange = (event: any, tabPosition: number) => {
event.preventDefault();
this.setState({ tabPosition });
};

private renderTabs(): JSX.Element {
const { scope, registryUrl } = this.props;
const { tabPosition } = this.state;

Expand All @@ -48,7 +53,7 @@ class RegistryInfoContent extends Component<Props, State> {
);
}

private renderNpmTab(scope: string, registryUrl: string) {
private renderNpmTab(scope: string, registryUrl: string): JSX.Element {
return (
<React.Fragment>
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.npm} set`, scope, registryUrl)} />
Expand All @@ -58,7 +63,7 @@ class RegistryInfoContent extends Component<Props, State> {
);
}

private renderPNpmTab(scope: string, registryUrl: string) {
private renderPNpmTab(scope: string, registryUrl: string): JSX.Element {
return (
<React.Fragment>
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.pnpm} set`, scope, registryUrl)} />
Expand All @@ -68,18 +73,13 @@ class RegistryInfoContent extends Component<Props, State> {
);
}

private renderYarnTab(scope: string, registryUrl: string) {
private renderYarnTab(scope: string, registryUrl: string): JSX.Element {
return (
<React.Fragment>
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)} />
</React.Fragment>
);
}

private handleChange = (event: any, tabPosition: number) => {
event.preventDefault();
this.setState({ tabPosition });
};
}

export default RegistryInfoContent;
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import App from './App';

const rootNode = document.getElementById('root');

const renderApp = Component => {
const renderApp = (Component): void => {
ReactDOM.render(
<AppContainer>
<Component />
Expand Down
8 changes: 4 additions & 4 deletions src/utils/asyncComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import React, { ComponentClass } from 'react';

export function asyncComponent(getComponent) {
export function asyncComponent(getComponent): ComponentClass {
return class AsyncComponent extends React.Component {
public static Component = null;
public state = { Component: AsyncComponent.Component };

public componentDidMount() {
public componentDidMount(): void {
const { Component } = this.state;
if (!Component) {
getComponent()
Expand All @@ -20,7 +20,7 @@ export function asyncComponent(getComponent) {
}
}

public render() {
public render(): JSX.Element | null {
const { Component } = this.state;
if (Component) {
// eslint-disable-next-line verdaccio/jsx-spread
Expand Down
2 changes: 1 addition & 1 deletion src/utils/file-size.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* @ts-ignore */
export default function fileSizeSI(a?: any, b?: any, c?: any, d?: any, e?: any) {
export default function fileSizeSI(a?: any, b?: any, c?: any, d?: any, e?: any): string {
return ((b = Math), (c = b.log), (d = 1e3), (e = (c(a) / c(d)) | 0), a / b.pow(d, e)).toFixed(2) + ' ' + (e ? 'kMGTPEZY'[--e] + 'B' : 'Bytes');
}

0 comments on commit 31c11f2

Please sign in to comment.