Skip to content

Commit 96b65d9

Browse files
ayusharmajuanpicado
authored andcommitted
refactor: corrects eslint and variable name spacing (conventional-changelog#31)
* refactor: corrects eslint and variable namespacing * chore: fixes git conflict * chore: fixes eslint
1 parent f000438 commit 96b65d9

File tree

10 files changed

+78
-103
lines changed

10 files changed

+78
-103
lines changed

src/webui/components/ActionBar/index.js

+9-31
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
/* eslint-disable react/jsx-max-depth */
21
/**
32
* @prettier
43
*/
54

65
import React, { Component } from 'react';
76

8-
import { DetailContextConsumer } from '../../pages/version/index';
9-
import List from '@material-ui/core/List/index';
10-
11-
import DownloadIcon from '@material-ui/icons/CloudDownload';
127
import BugReportIcon from '@material-ui/icons/BugReport';
8+
import DownloadIcon from '@material-ui/icons/CloudDownload';
139
import HomeIcon from '@material-ui/icons/Home';
10+
import List from '@material-ui/core/List/index';
1411
import Tooltip from '@material-ui/core/Tooltip/index';
1512

13+
import { DetailContextConsumer } from '../../pages/version/index';
1614
import { Fab, ActionListItem } from './styles';
1715

1816
const ACTIONS = {
@@ -46,24 +44,14 @@ class ActionBar extends Component<any, any> {
4644
return null;
4745
}
4846
return (
49-
<a href={link} target={"_blank"}>
47+
<a href={link} target={'_blank'}>
5048
{component}
5149
</a>
5250
);
5351
}
5452

55-
renderActionBarListItems = (packageMeta) => {
56-
const {
57-
latest: {
58-
bugs: {
59-
url: issue,
60-
} = {},
61-
homepage,
62-
dist: {
63-
tarball,
64-
} = {},
65-
} = {},
66-
} = packageMeta;
53+
renderActionBarListItems = packageMeta => {
54+
const { latest: { bugs: { url: issue } = {}, homepage, dist: { tarball } = {} } = {} } = packageMeta;
6755

6856
const actionsMap = {
6957
homepage,
@@ -74,11 +62,7 @@ class ActionBar extends Component<any, any> {
7462
const renderList = Object.keys(actionsMap).reduce((component, value, key) => {
7563
const link = actionsMap[value];
7664
if (link) {
77-
const fab = (
78-
<Fab size={'small'}>
79-
{ACTIONS[value]['icon']}
80-
</Fab>
81-
);
65+
const fab = <Fab size={'small'}>{ACTIONS[value]['icon']}</Fab>;
8266
component.push(
8367
<Tooltip key={key} title={ACTIONS[value]['title']}>
8468
{this.renderIconsWithLink(link, fab)}
@@ -90,19 +74,13 @@ class ActionBar extends Component<any, any> {
9074

9175
return (
9276
<>
93-
<ActionListItem alignItems={'flex-start'}>
94-
{renderList}
95-
</ActionListItem>
77+
<ActionListItem alignItems={'flex-start'}>{renderList}</ActionListItem>
9678
</>
9779
);
9880
};
9981

10082
renderActionBar = ({ packageMeta = {} }) => {
101-
return (
102-
<List>
103-
{this.renderActionBarListItems(packageMeta)}
104-
</List>
105-
);
83+
return <List>{this.renderActionBarListItems(packageMeta)}</List>;
10684
};
10785
}
10886

src/webui/components/CopyToClipBoard/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
*/
55

66
import React from 'react';
7+
import type { Node } from 'react';
8+
79
import FileCopy from '@material-ui/icons/FileCopy';
810
import Tooltip from '@material-ui/core/Tooltip/index';
911

10-
import type { Node } from 'react';
11-
import { IProps } from './types';
12-
1312
import { ClipBoardCopy, ClipBoardCopyText, CopyIcon } from './styles';
1413
import { copyToClipBoardUtility } from '../../utils/cli-utils';
1514
import { TEXT } from '../../utils/constants';
15+
import { IProps } from './types';
1616

1717
const CopyToClipBoard = ({ text, children }: IProps): Node => {
1818
const renderToolTipFileCopy = () => (

src/webui/components/Dependencies/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* @flow
44
*/
55

6-
/* eslint react/jsx-max-depth: 0 */
7-
86
import React, { Component, Fragment } from 'react';
97
import { withRouter } from 'react-router-dom';
108
import CardContent from '@material-ui/core/CardContent/index';
@@ -40,7 +38,7 @@ class DepDetail extends Component<any, any> {
4038
};
4139
}
4240

43-
const WrappDepDetail = withRouter(DepDetail);
41+
const WrapperDependencyDetail = withRouter(DepDetail);
4442

4543
class DependencyBlock extends Component<any, any> {
4644
render() {
@@ -68,7 +66,7 @@ class DependencyBlock extends Component<any, any> {
6866
deps.map(dep => {
6967
const [name, version] = dep;
7068

71-
return <WrappDepDetail key={name} name={name} onLoading={enableLoading} version={version} />;
69+
return <WrapperDependencyDetail key={name} name={name} onLoading={enableLoading} version={version} />;
7270
});
7371
}
7472

src/webui/components/DetailSidebar/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Card from '@material-ui/core/Card/index';
44
import CardContent from '@material-ui/core/CardContent/index';
55
import List from '@material-ui/core/List/index';
66

7-
import ActtionBar from '../ActionBar';
7+
import ActionBar from '../ActionBar';
88
import Author from '../Author';
99
import Developers from '../Developers';
1010
import Dist from '../Dist';
@@ -88,7 +88,7 @@ class DetailSidebar extends Component {
8888
}
8989

9090
renderActionBar = () => {
91-
return <ActtionBar />;
91+
return <ActionBar />;
9292
}
9393
}
9494

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import React, {Component} from 'react';
1+
/**
2+
* @prettier
3+
*/
4+
5+
import React, { Component } from 'react';
26

37
import Avatar from '@material-ui/core/Avatar';
4-
import Tooltip from '@material-ui/core/Tooltip';
58
import Add from '@material-ui/icons/Add';
9+
import Tooltip from '@material-ui/core/Tooltip';
610

711
import { DetailContextConsumer } from '../../pages/version';
8-
912
import { Details, Heading, Content, Fab } from './styles';
1013

1114
interface Props {
12-
type: 'contributors' | 'maintainers'
15+
type: 'contributors' | 'maintainers';
1316
}
1417

1518
class Developers extends Component<Props, any> {
@@ -28,11 +31,11 @@ class Developers extends Component<Props, any> {
2831
}}
2932
</DetailContextConsumer>
3033
);
31-
};
34+
}
3235

3336
handleLoadMore = () => {
34-
this.setState((prev) => ({ visibleDevs: prev.visibleDevs + 6 }));
35-
}
37+
this.setState(prev => ({ visibleDevs: prev.visibleDevs + 6 }));
38+
};
3639

3740
renderDevelopers = (developers, packageMeta) => {
3841
const { type } = this.props;
@@ -44,40 +47,33 @@ class Developers extends Component<Props, any> {
4447
{developers.slice(0, visibleDevs).map(developer => (
4548
<Details key={developer.email}>{this.renderDeveloperDetails(developer, packageMeta)}</Details>
4649
))}
47-
{visibleDevs < developers.length &&
48-
<Fab onClick={this.handleLoadMore} size={'small'}><Add /></Fab>
49-
}
50+
{visibleDevs < developers.length && (
51+
<Fab onClick={this.handleLoadMore} size={'small'}>
52+
<Add />
53+
</Fab>
54+
)}
5055
</Content>
5156
</>
5257
);
53-
}
58+
};
5459

5560
renderLinkForMail(email, avatarComponent, packageName, version) {
56-
if(!email) {
61+
if (!email) {
5762
return avatarComponent;
5863
}
5964
return (
60-
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={"_top"}>
65+
<a href={`mailto:${email}?subject=${packageName}@${version}`} target={'_top'}>
6166
{avatarComponent}
6267
</a>
6368
);
6469
}
6570

6671
renderDeveloperDetails = ({ name, avatar, email }, packageMeta) => {
67-
const {
68-
name: packageName,
69-
version,
70-
} = packageMeta.latest;
71-
72-
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
73-
return (
74-
<Tooltip title={name}>
75-
{this.renderLinkForMail(email, avatarComponent, packageName, version)}
76-
</Tooltip>
77-
);
78-
}
72+
const { name: packageName, version } = packageMeta.latest;
7973

74+
const avatarComponent = <Avatar aria-label={name} src={avatar} />;
75+
return <Tooltip title={name}>{this.renderLinkForMail(email, avatarComponent, packageName, version)}</Tooltip>;
76+
};
8077
}
8178

82-
8379
export default Developers;

src/webui/components/Dist/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
* @prettier
33
*/
44

5-
/* eslint-disable */
65
import React, { Component } from 'react';
6+
77
import List from '@material-ui/core/List/index';
88

99
import { DetailContextConsumer } from '../../pages/version/index';
10-
11-
import { Heading, DistListItem, DistChips, DownloadButton } from './styles';
10+
import { Heading, DistListItem, DistChips } from './styles';
1211
import fileSizeSI from '../../utils/file-size';
1312

1413
class Dist extends Component<any, any> {
@@ -34,10 +33,11 @@ class Dist extends Component<any, any> {
3433
if (value) {
3534
const label = (
3635
<span>
37-
<b>{title.split('-').join(' ')}</b>: {value}
36+
{/* eslint-disable-next-line */}
37+
<b>{title.split('-').join(' ')}</b>:{value}
3838
</span>
3939
);
40-
componentList.push(<DistChips label={label} key={key} />);
40+
componentList.push(<DistChips key={key} label={label} />);
4141
}
4242
return componentList;
4343
}, []);

src/webui/components/Engines/index.js

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
1-
/* eslint-disable */
2-
import React, {Component} from 'react';
1+
/**
2+
* @prettier
3+
*/
4+
5+
import React, { Component } from 'react';
36

47
import Avatar from '@material-ui/core/Avatar/index';
58
import Grid from '@material-ui/core/Grid/index';
69
import List from '@material-ui/core/List/index';
710
import ListItemText from '@material-ui/core/ListItemText/index';
811

912
import { DetailContextConsumer } from '../../pages/version/index';
10-
1113
import { Heading, EngineListItem } from './styles';
1214
import node from './img/node.png';
13-
import npm from '../Install/img/npm.svg'
14-
15+
import npm from '../Install/img/npm.svg';
1516

1617
const ICONS = {
1718
'node-JS': <Avatar src={node} />,
1819
'NPM-version': <Avatar src={npm} />,
19-
}
20+
};
2021

2122
class Engine extends Component {
2223
render() {
2324
return (
2425
<DetailContextConsumer>
25-
{(context) => {
26+
{context => {
2627
return this.renderEngine(context);
2728
}}
2829
</DetailContextConsumer>
2930
);
30-
};
31+
}
3132

32-
renderEngine = ({packageMeta}) => {
33+
renderEngine = ({ packageMeta }) => {
3334
const { engines } = packageMeta.latest;
3435
if (!engines) {
3536
return null;
3637
}
3738

3839
const engineDict = {
3940
'node-JS': engines.node,
40-
'NPM-version': engines.npm
41-
}
41+
'NPM-version': engines.npm,
42+
};
4243

4344
const items = Object.keys(engineDict).reduce((markup, text, key) => {
44-
const heading = engineDict[text]
45-
if (heading){
45+
const heading = engineDict[text];
46+
if (heading) {
4647
markup.push(
47-
<Grid item={true} xs={6} key={key}>
48+
<Grid item={true} key={key} xs={6}>
4849
{this.renderListItems(heading, text)}
4950
</Grid>
5051
);
@@ -56,23 +57,19 @@ class Engine extends Component {
5657
return null;
5758
}
5859

59-
return (
60-
<Grid container={true}>
61-
{items}
62-
</Grid>
63-
);
64-
}
60+
return <Grid container={true}>{items}</Grid>;
61+
};
6562

6663
renderListItems = (heading, text) => {
6764
return (
68-
<List subheader={<Heading variant={"subheading"}>{text.split('-').join(' ')}</Heading>}>
65+
<List subheader={<Heading variant={'subheading'}>{text.split('-').join(' ')}</Heading>}>
6966
<EngineListItem>
70-
{ ICONS[text] }
67+
{ICONS[text]}
7168
<ListItemText primary={heading} />
7269
</EngineListItem>
7370
</List>
7471
);
75-
}
72+
};
7673
}
7774

7875
export default Engine;

0 commit comments

Comments
 (0)