mirror of
https://github.com/SomboChea/ui
synced 2024-11-28 00:44:30 +07:00
fix: @typescript-eslint/explicit-function-return-type
This commit is contained in:
parent
55f50e9f4d
commit
31c11f2b5b
@ -26,7 +26,7 @@ export interface Props {
|
|||||||
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
onBlur?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderInputComponent = inputProps => {
|
const renderInputComponent = (inputProps): JSX.Element => {
|
||||||
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
|
const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps;
|
||||||
return (
|
return (
|
||||||
<InputField
|
<InputField
|
||||||
@ -46,7 +46,7 @@ const renderInputComponent = inputProps => {
|
|||||||
|
|
||||||
const getSuggestionValue = (suggestion): string => suggestion.name;
|
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 matches = match(suggestion.name, query);
|
||||||
const parts = parse(suggestion.name, matches);
|
const parts = parse(suggestion.name, matches);
|
||||||
return (
|
return (
|
||||||
@ -68,7 +68,7 @@ const renderSuggestion = (suggestion, { query, isHighlighted }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderMessage = message => {
|
const renderMessage = (message): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<MenuItem component="div" selected={false}>
|
<MenuItem component="div" selected={false}>
|
||||||
<div>{message}</div>
|
<div>{message}</div>
|
||||||
@ -98,7 +98,7 @@ const AutoComplete = ({
|
|||||||
suggestionsLoading = false,
|
suggestionsLoading = false,
|
||||||
suggestionsLoaded = false,
|
suggestionsLoaded = false,
|
||||||
suggestionsError = false,
|
suggestionsError = false,
|
||||||
}: Props) => {
|
}: Props): JSX.Element => {
|
||||||
const autosuggestProps = {
|
const autosuggestProps = {
|
||||||
renderInputComponent,
|
renderInputComponent,
|
||||||
suggestions,
|
suggestions,
|
||||||
@ -119,7 +119,7 @@ const AutoComplete = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// this format avoid arrow function eslint rule
|
// this format avoid arrow function eslint rule
|
||||||
function renderSuggestionsContainer({ containerProps, children, query }) {
|
function renderSuggestionsContainer({ containerProps, children, query }): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<SuggestionContainer {...containerProps} square={true}>
|
<SuggestionContainer {...containerProps} square={true}>
|
||||||
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
|
{suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)}
|
||||||
|
@ -17,7 +17,7 @@ class Developers extends Component<Props, any> {
|
|||||||
visibleDevs: 6,
|
visibleDevs: 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
public render() {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
{({ packageMeta }: any) => {
|
{({ 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) {
|
if (!email || isEmail(email) === false) {
|
||||||
return avatarComponent;
|
return avatarComponent;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { Heading, DistListItem, DistChips } from './styles';
|
|||||||
import fileSizeSI from '../../utils/file-size';
|
import fileSizeSI from '../../utils/file-size';
|
||||||
|
|
||||||
class Dist extends Component<any, any> {
|
class Dist extends Component<any, any> {
|
||||||
public render() {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<DetailContextConsumer>
|
<DetailContextConsumer>
|
||||||
{(context: any) => {
|
{(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 = {
|
const distDict = {
|
||||||
'file-count': dist.fileCount,
|
'file-count': dist.fileCount,
|
||||||
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),
|
size: dist.unpackedSize && fileSizeSI(dist.unpackedSize),
|
||||||
|
@ -12,15 +12,15 @@ export const NOT_FOUND_TEXT = "Sorry, we couldn't find it...";
|
|||||||
export type NotFoundProps = RouteComponentProps & { width: any; history: any };
|
export type NotFoundProps = RouteComponentProps & { width: any; history: any };
|
||||||
|
|
||||||
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
||||||
const handleGoTo = (to: string) => () => {
|
const handleGoTo = (to: string): (() => void | undefined) => () => {
|
||||||
history.push(to);
|
history.push(to);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGoBack = () => () => {
|
const handleGoBack = (): ((e: React.MouseEvent<HTMLElement, MouseEvent>) => void | undefined) => () => {
|
||||||
history.goBack();
|
history.goBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderList = () => (
|
const renderList = (): JSX.Element => (
|
||||||
<List>
|
<List>
|
||||||
<ListItem button={true} divider={true} onClick={handleGoTo('/')}>
|
<ListItem button={true} divider={true} onClick={handleGoTo('/')}>
|
||||||
{'Home'}
|
{'Home'}
|
||||||
@ -31,7 +31,7 @@ const NotFound: React.FC<NotFoundProps> = ({ history, width }) => {
|
|||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderSubTitle = () => (
|
const renderSubTitle = (): JSX.Element => (
|
||||||
<Typography variant="subtitle1">
|
<Typography variant="subtitle1">
|
||||||
<div>{"The page you're looking for doesn't exist."}</div>
|
<div>{"The page you're looking for doesn't exist."}</div>
|
||||||
<div>{'Perhaps these links will help find what you are looking for:'}</div>
|
<div>{'Perhaps these links will help find what you are looking for:'}</div>
|
||||||
|
@ -8,7 +8,7 @@ import { WrapperLink, Description, OverviewItem } from './styles';
|
|||||||
* Generates one month back date from current time
|
* Generates one month back date from current time
|
||||||
* @return {object} date object
|
* @return {object} date object
|
||||||
*/
|
*/
|
||||||
const dateOneMonthAgo = () => new Date(1544377770747);
|
const dateOneMonthAgo = (): Date => new Date(1544377770747);
|
||||||
|
|
||||||
describe('<Package /> component', () => {
|
describe('<Package /> component', () => {
|
||||||
test.skip('should load the component', () => {
|
test.skip('should load the component', () => {
|
||||||
|
@ -11,7 +11,7 @@ import { getCLISetRegistry, getCLIChangePassword, getCLISetConfigRegistry } from
|
|||||||
import { NODE_MANAGER } from '../../utils/constants';
|
import { NODE_MANAGER } from '../../utils/constants';
|
||||||
|
|
||||||
/* eslint react/prop-types:0 */
|
/* eslint react/prop-types:0 */
|
||||||
function TabContainer({ children }) {
|
function TabContainer({ children }): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<CommandContainer>
|
<CommandContainer>
|
||||||
<Typography component="div" style={{ padding: 0, minHeight: 170 }}>
|
<Typography component="div" style={{ padding: 0, minHeight: 170 }}>
|
||||||
@ -26,11 +26,16 @@ class RegistryInfoContent extends Component<Props, State> {
|
|||||||
tabPosition: 0,
|
tabPosition: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
public render() {
|
public render(): JSX.Element {
|
||||||
return <div>{this.renderTabs()}</div>;
|
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 { scope, registryUrl } = this.props;
|
||||||
const { tabPosition } = this.state;
|
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 (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.npm} set`, scope, registryUrl)} />
|
<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 (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.pnpm} set`, scope, registryUrl)} />
|
<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 (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)} />
|
<CopyToClipBoard text={getCLISetConfigRegistry(`${NODE_MANAGER.yarn} config set`, scope, registryUrl)} />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleChange = (event: any, tabPosition: number) => {
|
|
||||||
event.preventDefault();
|
|
||||||
this.setState({ tabPosition });
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RegistryInfoContent;
|
export default RegistryInfoContent;
|
||||||
|
@ -8,7 +8,7 @@ import App from './App';
|
|||||||
|
|
||||||
const rootNode = document.getElementById('root');
|
const rootNode = document.getElementById('root');
|
||||||
|
|
||||||
const renderApp = Component => {
|
const renderApp = (Component): void => {
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<AppContainer>
|
<AppContainer>
|
||||||
<Component />
|
<Component />
|
||||||
|
@ -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 {
|
return class AsyncComponent extends React.Component {
|
||||||
public static Component = null;
|
public static Component = null;
|
||||||
public state = { Component: AsyncComponent.Component };
|
public state = { Component: AsyncComponent.Component };
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount(): void {
|
||||||
const { Component } = this.state;
|
const { Component } = this.state;
|
||||||
if (!Component) {
|
if (!Component) {
|
||||||
getComponent()
|
getComponent()
|
||||||
@ -20,7 +20,7 @@ export function asyncComponent(getComponent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render(): JSX.Element | null {
|
||||||
const { Component } = this.state;
|
const { Component } = this.state;
|
||||||
if (Component) {
|
if (Component) {
|
||||||
// eslint-disable-next-line verdaccio/jsx-spread
|
// eslint-disable-next-line verdaccio/jsx-spread
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* @ts-ignore */
|
/* @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');
|
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');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user