diff --git a/src/components/AutoComplete/AutoComplete.tsx b/src/components/AutoComplete/AutoComplete.tsx index 350c332..ba9c6a2 100644 --- a/src/components/AutoComplete/AutoComplete.tsx +++ b/src/components/AutoComplete/AutoComplete.tsx @@ -26,7 +26,7 @@ export interface Props { onBlur?: (event: KeyboardEvent) => void; } -const renderInputComponent = inputProps => { +const renderInputComponent = (inputProps): JSX.Element => { const { ref, startAdornment, disableUnderline, onKeyDown, ...others } = inputProps; return ( { 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 (
{message}
@@ -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 ( {suggestionsLoaded && children === null && query && renderMessage(SUGGESTIONS_RESPONSE.NO_RESULT)} diff --git a/src/components/Developers/Developers.tsx b/src/components/Developers/Developers.tsx index 7913d7c..9ca8f6e 100644 --- a/src/components/Developers/Developers.tsx +++ b/src/components/Developers/Developers.tsx @@ -17,7 +17,7 @@ class Developers extends Component { visibleDevs: 6, }; - public render() { + public render(): JSX.Element { return ( {({ packageMeta }: any) => { @@ -54,7 +54,7 @@ class Developers extends Component { ); }; - private renderLinkForMail(email, avatarComponent, packageName, version) { + private renderLinkForMail(email, avatarComponent, packageName, version): JSX.Element { if (!email || isEmail(email) === false) { return avatarComponent; } diff --git a/src/components/Dist/Dist.tsx b/src/components/Dist/Dist.tsx index 381fff0..bb30498 100644 --- a/src/components/Dist/Dist.tsx +++ b/src/components/Dist/Dist.tsx @@ -7,7 +7,7 @@ import { Heading, DistListItem, DistChips } from './styles'; import fileSizeSI from '../../utils/file-size'; class Dist extends Component { - public render() { + public render(): JSX.Element { return ( {(context: any) => { @@ -17,7 +17,7 @@ class Dist extends Component { ); } - 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), diff --git a/src/components/NotFound/NotFound.tsx b/src/components/NotFound/NotFound.tsx index da91ff0..6350558 100644 --- a/src/components/NotFound/NotFound.tsx +++ b/src/components/NotFound/NotFound.tsx @@ -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 = ({ history, width }) => { - const handleGoTo = (to: string) => () => { + const handleGoTo = (to: string): (() => void | undefined) => () => { history.push(to); }; - const handleGoBack = () => () => { + const handleGoBack = (): ((e: React.MouseEvent) => void | undefined) => () => { history.goBack(); }; - const renderList = () => ( + const renderList = (): JSX.Element => ( {'Home'} @@ -31,7 +31,7 @@ const NotFound: React.FC = ({ history, width }) => { ); - const renderSubTitle = () => ( + const renderSubTitle = (): JSX.Element => (
{"The page you're looking for doesn't exist."}
{'Perhaps these links will help find what you are looking for:'}
diff --git a/src/components/Package/Package.test.tsx b/src/components/Package/Package.test.tsx index 99ee5fe..bc29297 100644 --- a/src/components/Package/Package.test.tsx +++ b/src/components/Package/Package.test.tsx @@ -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(' component', () => { test.skip('should load the component', () => { diff --git a/src/components/RegistryInfoContent/RegistryInfoContent.tsx b/src/components/RegistryInfoContent/RegistryInfoContent.tsx index 7ea2b9a..3444cd3 100644 --- a/src/components/RegistryInfoContent/RegistryInfoContent.tsx +++ b/src/components/RegistryInfoContent/RegistryInfoContent.tsx @@ -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 ( @@ -26,11 +26,16 @@ class RegistryInfoContent extends Component { tabPosition: 0, }; - public render() { + public render(): JSX.Element { return
{this.renderTabs()}
; } - 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 { ); } - private renderNpmTab(scope: string, registryUrl: string) { + private renderNpmTab(scope: string, registryUrl: string): JSX.Element { return ( @@ -58,7 +63,7 @@ class RegistryInfoContent extends Component { ); } - private renderPNpmTab(scope: string, registryUrl: string) { + private renderPNpmTab(scope: string, registryUrl: string): JSX.Element { return ( @@ -68,18 +73,13 @@ class RegistryInfoContent extends Component { ); } - private renderYarnTab(scope: string, registryUrl: string) { + private renderYarnTab(scope: string, registryUrl: string): JSX.Element { return ( ); } - - private handleChange = (event: any, tabPosition: number) => { - event.preventDefault(); - this.setState({ tabPosition }); - }; } export default RegistryInfoContent; diff --git a/src/index.tsx b/src/index.tsx index 610762a..7c1c83d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -8,7 +8,7 @@ import App from './App'; const rootNode = document.getElementById('root'); -const renderApp = Component => { +const renderApp = (Component): void => { ReactDOM.render( diff --git a/src/utils/asyncComponent.tsx b/src/utils/asyncComponent.tsx index b687f6b..9789aa0 100644 --- a/src/utils/asyncComponent.tsx +++ b/src/utils/asyncComponent.tsx @@ -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 diff --git a/src/utils/file-size.ts b/src/utils/file-size.ts index 28f20ea..8f547ce 100644 --- a/src/utils/file-size.ts +++ b/src/utils/file-size.ts @@ -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'); }