1
0
mirror of https://github.com/SomboChea/ui synced 2024-12-25 05:34:26 +07:00

fix: @typescript-eslint/explicit-function-return-type

This commit is contained in:
Griffithtp 2019-06-24 23:01:13 +01:00
parent 55f50e9f4d
commit 31c11f2b5b
9 changed files with 31 additions and 31 deletions

View File

@ -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
@ -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 (
@ -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>
@ -98,7 +98,7 @@ const AutoComplete = ({
suggestionsLoading = false,
suggestionsLoaded = false,
suggestionsError = false,
}: Props) => {
}: Props): JSX.Element => {
const autosuggestProps = {
renderInputComponent,
suggestions,
@ -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)}

View File

@ -17,7 +17,7 @@ class Developers extends Component<Props, any> {
visibleDevs: 6,
};
public render() {
public render(): JSX.Element {
return (
<DetailContextConsumer>
{({ packageMeta }: any) => {
@ -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;
}

View File

@ -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) => {
@ -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),

View File

@ -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'}
@ -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>

View File

@ -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', () => {

View File

@ -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 }}>
@ -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;
@ -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)} />
@ -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)} />
@ -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;

View File

@ -8,7 +8,7 @@ import App from './App';
const rootNode = document.getElementById('root');
const renderApp = Component => {
const renderApp = (Component): void => {
ReactDOM.render(
<AppContainer>
<Component />

View File

@ -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()
@ -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

View File

@ -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');
}