From 96b65d969a4f4aa8d94ae1833c3bcc51185790cc Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Mon, 8 Apr 2019 22:29:20 +0200 Subject: [PATCH] refactor: corrects eslint and variable name spacing (#31) * refactor: corrects eslint and variable namespacing * chore: fixes git conflict * chore: fixes eslint --- src/webui/components/ActionBar/index.js | 40 ++++------------ src/webui/components/CopyToClipBoard/index.js | 6 +-- src/webui/components/Dependencies/index.js | 6 +-- src/webui/components/DetailSidebar/index.js | 4 +- src/webui/components/Developers/index.js | 48 +++++++++---------- src/webui/components/Dist/index.js | 10 ++-- src/webui/components/Engines/index.js | 43 ++++++++--------- src/webui/components/Footer/styles.js | 13 ++--- src/webui/utils/styles/colors.js | 1 + tools/verdaccio.js | 10 ++-- 10 files changed, 78 insertions(+), 103 deletions(-) diff --git a/src/webui/components/ActionBar/index.js b/src/webui/components/ActionBar/index.js index a1a771a..8a0362e 100644 --- a/src/webui/components/ActionBar/index.js +++ b/src/webui/components/ActionBar/index.js @@ -1,18 +1,16 @@ -/* eslint-disable react/jsx-max-depth */ /** * @prettier */ import React, { Component } from 'react'; -import { DetailContextConsumer } from '../../pages/version/index'; -import List from '@material-ui/core/List/index'; - -import DownloadIcon from '@material-ui/icons/CloudDownload'; import BugReportIcon from '@material-ui/icons/BugReport'; +import DownloadIcon from '@material-ui/icons/CloudDownload'; import HomeIcon from '@material-ui/icons/Home'; +import List from '@material-ui/core/List/index'; import Tooltip from '@material-ui/core/Tooltip/index'; +import { DetailContextConsumer } from '../../pages/version/index'; import { Fab, ActionListItem } from './styles'; const ACTIONS = { @@ -46,24 +44,14 @@ class ActionBar extends Component { return null; } return ( - + {component} ); } - renderActionBarListItems = (packageMeta) => { - const { - latest: { - bugs: { - url: issue, - } = {}, - homepage, - dist: { - tarball, - } = {}, - } = {}, - } = packageMeta; + renderActionBarListItems = packageMeta => { + const { latest: { bugs: { url: issue } = {}, homepage, dist: { tarball } = {} } = {} } = packageMeta; const actionsMap = { homepage, @@ -74,11 +62,7 @@ class ActionBar extends Component { const renderList = Object.keys(actionsMap).reduce((component, value, key) => { const link = actionsMap[value]; if (link) { - const fab = ( - - {ACTIONS[value]['icon']} - - ); + const fab = {ACTIONS[value]['icon']}; component.push( {this.renderIconsWithLink(link, fab)} @@ -90,19 +74,13 @@ class ActionBar extends Component { return ( <> - - {renderList} - + {renderList} ); }; renderActionBar = ({ packageMeta = {} }) => { - return ( - - {this.renderActionBarListItems(packageMeta)} - - ); + return {this.renderActionBarListItems(packageMeta)}; }; } diff --git a/src/webui/components/CopyToClipBoard/index.js b/src/webui/components/CopyToClipBoard/index.js index 0209665..e127c47 100644 --- a/src/webui/components/CopyToClipBoard/index.js +++ b/src/webui/components/CopyToClipBoard/index.js @@ -4,15 +4,15 @@ */ import React from 'react'; +import type { Node } from 'react'; + import FileCopy from '@material-ui/icons/FileCopy'; import Tooltip from '@material-ui/core/Tooltip/index'; -import type { Node } from 'react'; -import { IProps } from './types'; - import { ClipBoardCopy, ClipBoardCopyText, CopyIcon } from './styles'; import { copyToClipBoardUtility } from '../../utils/cli-utils'; import { TEXT } from '../../utils/constants'; +import { IProps } from './types'; const CopyToClipBoard = ({ text, children }: IProps): Node => { const renderToolTipFileCopy = () => ( diff --git a/src/webui/components/Dependencies/index.js b/src/webui/components/Dependencies/index.js index eebb66b..ce3175d 100644 --- a/src/webui/components/Dependencies/index.js +++ b/src/webui/components/Dependencies/index.js @@ -3,8 +3,6 @@ * @flow */ -/* eslint react/jsx-max-depth: 0 */ - import React, { Component, Fragment } from 'react'; import { withRouter } from 'react-router-dom'; import CardContent from '@material-ui/core/CardContent/index'; @@ -40,7 +38,7 @@ class DepDetail extends Component { }; } -const WrappDepDetail = withRouter(DepDetail); +const WrapperDependencyDetail = withRouter(DepDetail); class DependencyBlock extends Component { render() { @@ -68,7 +66,7 @@ class DependencyBlock extends Component { deps.map(dep => { const [name, version] = dep; - return ; + return ; }); } diff --git a/src/webui/components/DetailSidebar/index.js b/src/webui/components/DetailSidebar/index.js index eb7e42a..0b9fcb7 100644 --- a/src/webui/components/DetailSidebar/index.js +++ b/src/webui/components/DetailSidebar/index.js @@ -4,7 +4,7 @@ import Card from '@material-ui/core/Card/index'; import CardContent from '@material-ui/core/CardContent/index'; import List from '@material-ui/core/List/index'; -import ActtionBar from '../ActionBar'; +import ActionBar from '../ActionBar'; import Author from '../Author'; import Developers from '../Developers'; import Dist from '../Dist'; @@ -88,7 +88,7 @@ class DetailSidebar extends Component { } renderActionBar = () => { - return ; + return ; } } diff --git a/src/webui/components/Developers/index.js b/src/webui/components/Developers/index.js index 31aad5f..f8b1c67 100644 --- a/src/webui/components/Developers/index.js +++ b/src/webui/components/Developers/index.js @@ -1,15 +1,18 @@ -import React, {Component} from 'react'; +/** + * @prettier + */ + +import React, { Component } from 'react'; import Avatar from '@material-ui/core/Avatar'; -import Tooltip from '@material-ui/core/Tooltip'; import Add from '@material-ui/icons/Add'; +import Tooltip from '@material-ui/core/Tooltip'; import { DetailContextConsumer } from '../../pages/version'; - import { Details, Heading, Content, Fab } from './styles'; interface Props { - type: 'contributors' | 'maintainers' + type: 'contributors' | 'maintainers'; } class Developers extends Component { @@ -28,11 +31,11 @@ class Developers extends Component { }} ); - }; + } handleLoadMore = () => { - this.setState((prev) => ({ visibleDevs: prev.visibleDevs + 6 })); - } + this.setState(prev => ({ visibleDevs: prev.visibleDevs + 6 })); + }; renderDevelopers = (developers, packageMeta) => { const { type } = this.props; @@ -44,40 +47,33 @@ class Developers extends Component { {developers.slice(0, visibleDevs).map(developer => (
{this.renderDeveloperDetails(developer, packageMeta)}
))} - {visibleDevs < developers.length && - - } + {visibleDevs < developers.length && ( + + + + )} ); - } + }; renderLinkForMail(email, avatarComponent, packageName, version) { - if(!email) { + if (!email) { return avatarComponent; } return ( - + {avatarComponent} ); } renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => { - const { - name: packageName, - version, - } = packageMeta.latest; - - const avatarComponent = ; - return ( - - {this.renderLinkForMail(email, avatarComponent, packageName, version)} - - ); - } + const { name: packageName, version } = packageMeta.latest; + const avatarComponent = ; + return {this.renderLinkForMail(email, avatarComponent, packageName, version)}; + }; } - export default Developers; diff --git a/src/webui/components/Dist/index.js b/src/webui/components/Dist/index.js index 27463a6..976f77f 100644 --- a/src/webui/components/Dist/index.js +++ b/src/webui/components/Dist/index.js @@ -2,13 +2,12 @@ * @prettier */ -/* eslint-disable */ import React, { Component } from 'react'; + import List from '@material-ui/core/List/index'; import { DetailContextConsumer } from '../../pages/version/index'; - -import { Heading, DistListItem, DistChips, DownloadButton } from './styles'; +import { Heading, DistListItem, DistChips } from './styles'; import fileSizeSI from '../../utils/file-size'; class Dist extends Component { @@ -34,10 +33,11 @@ class Dist extends Component { if (value) { const label = ( - {title.split('-').join(' ')}: {value} + {/* eslint-disable-next-line */} + {title.split('-').join(' ')}:{value} ); - componentList.push(); + componentList.push(); } return componentList; }, []); diff --git a/src/webui/components/Engines/index.js b/src/webui/components/Engines/index.js index 000d850..2233225 100644 --- a/src/webui/components/Engines/index.js +++ b/src/webui/components/Engines/index.js @@ -1,5 +1,8 @@ -/* eslint-disable */ -import React, {Component} from 'react'; +/** + * @prettier + */ + +import React, { Component } from 'react'; import Avatar from '@material-ui/core/Avatar/index'; import Grid from '@material-ui/core/Grid/index'; @@ -7,29 +10,27 @@ import List from '@material-ui/core/List/index'; import ListItemText from '@material-ui/core/ListItemText/index'; import { DetailContextConsumer } from '../../pages/version/index'; - import { Heading, EngineListItem } from './styles'; import node from './img/node.png'; -import npm from '../Install/img/npm.svg' - +import npm from '../Install/img/npm.svg'; const ICONS = { 'node-JS': , 'NPM-version': , -} +}; class Engine extends Component { render() { return ( - {(context) => { + {context => { return this.renderEngine(context); }} ); - }; + } - renderEngine = ({packageMeta}) => { + renderEngine = ({ packageMeta }) => { const { engines } = packageMeta.latest; if (!engines) { return null; @@ -37,14 +38,14 @@ class Engine extends Component { const engineDict = { 'node-JS': engines.node, - 'NPM-version': engines.npm - } + 'NPM-version': engines.npm, + }; const items = Object.keys(engineDict).reduce((markup, text, key) => { - const heading = engineDict[text] - if (heading){ + const heading = engineDict[text]; + if (heading) { markup.push( - + {this.renderListItems(heading, text)} ); @@ -56,23 +57,19 @@ class Engine extends Component { return null; } - return ( - - {items} - - ); - } + return {items}; + }; renderListItems = (heading, text) => { return ( - {text.split('-').join(' ')}}> + {text.split('-').join(' ')}}> - { ICONS[text] } + {ICONS[text]} ); - } + }; } export default Engine; diff --git a/src/webui/components/Footer/styles.js b/src/webui/components/Footer/styles.js index 846c2da..50e3b8a 100644 --- a/src/webui/components/Footer/styles.js +++ b/src/webui/components/Footer/styles.js @@ -6,12 +6,13 @@ import styled, { css } from 'react-emotion'; import mq from '../../utils/styles/media'; import Icon from '../Icon'; +import colors from '../../utils/styles/colors'; export const Wrapper = styled.div` && { - background: #f9f9f9; - border-top: 1px solid #e3e3e3; - color: #999999; + background: ${colors.snow}; + border-top: 1px solid ${colors.greyGainsboro}; + color: ${colors.nobel01}; font-size: 14px; padding: 20px; } @@ -67,7 +68,7 @@ export const Earth = styled(Icon)` export const Flags = styled.span` && { position: absolute; - background: #d3dddd; + background: ${colors.greyAthens}; padding: 1px 4px; border-radius: 3px; height: 20px; @@ -82,7 +83,7 @@ export const Flags = styled.span` left: -4px; margin-left: -5px; border: 5px solid; - border-color: #d3dddd transparent transparent transparent; + border-color: ${colors.greyAthens} transparent transparent transparent; transform: rotate(90deg); } ${ToolTip}:hover & { @@ -93,7 +94,7 @@ export const Flags = styled.span` export const Love = styled.span` && { - color: #e25555; + color: ${colors.love}; padding: 0 5px; } `; diff --git a/src/webui/utils/styles/colors.js b/src/webui/utils/styles/colors.js index fecfa9c..43e5d0b 100644 --- a/src/webui/utils/styles/colors.js +++ b/src/webui/utils/styles/colors.js @@ -22,6 +22,7 @@ const colors = { paleNavy: '#e4e8f1', saltpan: '#f7f8f6', snow: '#f9f9f9', + love: '#e25555', nobel01: '#999999', nobel02: '#9f9f9f', diff --git a/tools/verdaccio.js b/tools/verdaccio.js index 9ae7698..a86b7d8 100644 --- a/tools/verdaccio.js +++ b/tools/verdaccio.js @@ -1,3 +1,7 @@ +/** + * @prettier + */ + const fs = require('fs'); const startServer = require('verdaccio').default; const yalm = require('js-yaml'); @@ -11,9 +15,9 @@ const handler = function(webServer, addr, pkgName, pkgVersion) { process.on('SIGTERM', () => { webServer.close(() => { - console.log('Process terminated') - }) - }) + console.log('Process terminated'); + }); + }); }; startServer(configJsonFormat, 8080, '', '1.0.0', 'verdaccio', handler);