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

Commit 31c11f2

Browse files
committed
fix: @typescript-eslint/explicit-function-return-type
1 parent 55f50e9 commit 31c11f2

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

src/components/AutoComplete/AutoComplete.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface Props {
2626
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
2727
}
2828

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

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

49-
const renderSuggestion = (suggestion, { query, isHighlighted }) => {
49+
const renderSuggestion = (suggestion, { query, isHighlighted }): JSX.Element => {
5050
const matches = match(suggestion.name, query);
5151
const parts = parse(suggestion.name, matches);
5252
return (
@@ -68,7 +68,7 @@ const renderSuggestion = (suggestion, { query, isHighlighted }) => {
6868
);
6969
};
7070

71-
const renderMessage = message => {
71+
const renderMessage = (message): JSX.Element => {
7272
return (
7373
<MenuItem component="div" selected={false}>
7474
<div>{message}</div>
@@ -98,7 +98,7 @@ const AutoComplete = ({
9898
suggestionsLoading = false,
9999
suggestionsLoaded = false,
100100
suggestionsError = false,
101-
}: Props) => {
101+
}: Props): JSX.Element => {
102102
const autosuggestProps = {
103103
renderInputComponent,
104104
suggestions,
@@ -119,7 +119,7 @@ const AutoComplete = ({
119119
};
120120

121121
// this format avoid arrow function eslint rule
122-
function renderSuggestionsContainer({ containerProps, children, query }) {
122+
function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
123123
return (
124124
<SuggestionContainer {...containerProps} square={true}>
125125
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}

src/components/Developers/Developers.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Developers extends Component<Props, any> {
1717
visibleDevs: 6,
1818
};
1919

20-
public render() {
20+
public render(): JSX.Element {
2121
return (
2222
<DetailContextConsumer>
2323
{({ packageMeta }: any) => {
@@ -54,7 +54,7 @@ class Developers extends Component<Props, any> {
5454
);
5555
};
5656

57-
private renderLinkForMail(email, avatarComponent, packageName, version) {
57+
private renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element {
5858
if (!email || isEmail(email) === false) {
5959
return avatarComponent;
6060
}

src/components/Dist/Dist.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Heading, DistListItem, DistChips } from './styles';
77
import fileSizeSI from '../../utils/file-size';
88

99
class Dist extends Component<any, any> {
10-
public render() {
10+
public render(): JSX.Element {
1111
return (
1212
<DetailContextConsumer>
1313
{(context: any) => {
@@ -17,7 +17,7 @@ class Dist extends Component<any, any> {
1717
);
1818
}
1919

20-
private renderChips(dist: any, license: string) {
20+
private renderChips(dist: any, license: string): JSX.Element | never[] {
2121
const distDict = {
2222
'file-count': dist.fileCount,
2323
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),

src/components/NotFound/NotFound.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";
1212
export type NotFoundProps = RouteComponentProps & { width: any; history: any };
1313

1414
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
15-
const handleGoTo = (to: string) => () => {
15+
const handleGoTo = (to: string): (() => void | undefined) => () => {
1616
history.push(to);
1717
};
1818

19-
const handleGoBack = () => () => {
19+
const handleGoBack = (): ((e: React.MouseEvent<HTMLElement, MouseEvent>) => void | undefined) => () => {
2020
history.goBack();
2121
};
2222

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

34-
const renderSubTitle = () => (
34+
const renderSubTitle = (): JSX.Element => (
3535
<Typography variant="subtitle1">
3636
<div>{"The page you're looking for doesn't exist."}</div>
3737
<div>{'Perhaps these links will help find what you are looking for:'}</div>

src/components/Package/Package.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { WrapperLink, Description, OverviewItem } from './styles';
88
* Generates one month back date from current time
99
* @return {object} date object
1010
*/
11-
const dateOneMonthAgo = () => new Date(1544377770747);
11+
const dateOneMonthAgo = (): Date => new Date(1544377770747);
1212

1313
describe('<Package /> component', () => {
1414
test.skip('should load the component', () => {

src/components/RegistryInfoContent/RegistryInfoContent.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getCLISetRegistry, getCLIChangePassword, getCLISetConfigRegistry } from
1111
import { NODE_MANAGER } from '../../utils/constants';
1212

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

29-
public render() {
29+
public render(): JSX.Element {
3030
return <div>{this.renderTabs()}</div>;
3131
}
3232

33-
private renderTabs() {
33+
private handleChange = (event: any, tabPosition: number) => {
34+
event.preventDefault();
35+
this.setState({ tabPosition });
36+
};
37+
38+
private renderTabs(): JSX.Element {
3439
const { scope, registryUrl } = this.props;
3540
const { tabPosition } = this.state;
3641

@@ -48,7 +53,7 @@ class RegistryInfoContent extends Component<Props, State> {
4853
);
4954
}
5055

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

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

71-
private renderYarnTab(scope: string, registryUrl: string) {
76+
private renderYarnTab(scope: string, registryUrl: string): JSX.Element {
7277
return (
7378
<React.Fragment>
7479
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)} />
7580
</React.Fragment>
7681
);
7782
}
78-
79-
private handleChange = (event: any, tabPosition: number) => {
80-
event.preventDefault();
81-
this.setState({ tabPosition });
82-
};
8383
}
8484

8585
export default RegistryInfoContent;

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import App from './App';
88

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

11-
const renderApp = Component => {
11+
const renderApp = (Component): void => {
1212
ReactDOM.render(
1313
<AppContainer>
1414
<Component />

src/utils/asyncComponent.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react';
1+
import React, { ComponentClass } from 'react';
22

3-
export function asyncComponent(getComponent) {
3+
export function asyncComponent(getComponent): ComponentClass {
44
return class AsyncComponent extends React.Component {
55
public static Component = null;
66
public state = { Component: AsyncComponent.Component };
77

8-
public componentDidMount() {
8+
public componentDidMount(): void {
99
const { Component } = this.state;
1010
if (!Component) {
1111
getComponent()
@@ -20,7 +20,7 @@ export function asyncComponent(getComponent) {
2020
}
2121
}
2222

23-
public render() {
23+
public render(): JSX.Element | null {
2424
const { Component } = this.state;
2525
if (Component) {
2626
// eslint-disable-next-line verdaccio/jsx-spread

src/utils/file-size.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/* @ts-ignore */
2-
export default function fileSizeSI(a?: any, b?: any, c?: any, d?: any, e?: any) {
2+
export default function fileSizeSI(a?: any, b?: any, c?: any, d?: any, e?: any): string {
33
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');
44
}

0 commit comments

Comments
 (0)