lint: decrease max-len

This commit is contained in:
George Lima 2018-12-15 12:10:39 -03:00
parent 0ee42e2bb6
commit ec6422bf75
20 changed files with 238 additions and 65 deletions

View File

@ -34,7 +34,7 @@
"max-len": [
"error",
{
"code": 120,
"code": 80,
"tabWidth": 2,
"ignoreUrls": true,
"ignoreComments": true,

View File

@ -4,6 +4,7 @@ import React from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable max-len */
// $FlowFixMe
import { darken } from 'polished';

View File

@ -11,7 +11,10 @@ import { TextComponent } from './text';
/* eslint-disable max-len */
const MenuWrapper = styled.div`
background-image: ${props => `linear-gradient(to right, ${darken(0.05, props.theme.colors.activeItem)}, ${props.theme.colors.activeItem})`};
background-image: ${props => `linear-gradient(to right, ${darken(
0.05,
props.theme.colors.activeItem,
)}, ${props.theme.colors.activeItem})`};
padding: 10px 20px;
border-radius: 10px;
margin-left: -10px;
@ -77,7 +80,9 @@ export class DropdownComponent extends Component<Props, State> {
preferPlace='below'
enterExitTransitionDurationMs={0}
body={[
<ClickOutside onClickOutside={() => this.setState(() => ({ isOpen: false }))}>
<ClickOutside
onClickOutside={() => this.setState(() => ({ isOpen: false }))}
>
<MenuWrapper>
{label && (
<MenuItem disabled>
@ -94,7 +99,10 @@ export class DropdownComponent extends Component<Props, State> {
]}
tipSize={7}
>
{renderTrigger(() => this.setState(state => ({ isOpen: !state.isOpen })), isOpen)}
{renderTrigger(
() => this.setState(state => ({ isOpen: !state.isOpen })),
isOpen,
)}
</PopoverWithStyle>
);
}

View File

@ -36,8 +36,12 @@ type Props = {
export const InputComponent = ({ inputType, onChange, ...props }: Props) => {
const inputTypes = {
input: () => <Input onChange={evt => onChange(evt.target.value)} {...props} />,
textarea: () => <Textarea onChange={evt => onChange(evt.target.value)} {...props} />,
input: () => (
<Input onChange={evt => onChange(evt.target.value)} {...props} />
),
textarea: () => (
<Textarea onChange={evt => onChange(evt.target.value)} {...props} />
),
dropdown: () => null,
};

View File

@ -8,7 +8,9 @@ type Props = {
size?: number,
};
export const QRCode = ({ value, size }: Props) => <QR value={value} size={size} />;
export const QRCode = ({ value, size }: Props) => (
<QR value={value} size={size} />
);
QRCode.defaultProps = {
size: 128,

View File

@ -16,10 +16,14 @@ const Wrapper = styled.div`
`;
const StyledLink = styled(Link)`
color: ${props => (props.isActive ? props.theme.colors.sidebarItemActive : props.theme.colors.sidebarItem)};
color: ${props => (props.isActive
? props.theme.colors.sidebarItemActive
: props.theme.colors.sidebarItem)};
font-size: ${props => `${props.theme.fontSize.text}em`};
text-decoration: none;
font-weight: ${props => (props.isActive ? props.theme.fontWeight.bold : props.theme.fontWeight.default)};
font-weight: ${props => (props.isActive
? props.theme.fontWeight.bold
: props.theme.fontWeight.default)};
padding: 0 20px;
height: 35px;
width: 100%;
@ -27,11 +31,15 @@ const StyledLink = styled(Link)`
display: flex;
align-items: center;
outline: none;
border-right: ${props => (props.isActive ? `1px solid ${props.theme.colors.sidebarItemActive}` : 'none')};
border-right: ${props => (props.isActive
? `1px solid ${props.theme.colors.sidebarItemActive}`
: 'none')};
&:hover {
color: ${/* eslint-disable-next-line max-len */
props => (props.isActive ? props.theme.colors.sidebarItemActive : props.theme.colors.sidebarHoveredItemLabel)};
props => (props.isActive
? props.theme.colors.sidebarItemActive
: props.theme.colors.sidebarHoveredItemLabel)};
background-color: ${props => props.theme.colors.sidebarHoveredItem};
}
`;

View File

@ -10,7 +10,9 @@ const Text = styled.p`
color: ${props => props.color || props.theme.colors.text};
margin: 0;
padding: 0;
font-weight: ${props => (props.isBold ? props.theme.fontWeight.bold : props.theme.fontWeight.default)};
font-weight: ${props => (props.isBold
? props.theme.fontWeight.bold
: props.theme.fontWeight.default)};
text-align: ${props => props.align};
`;
@ -24,9 +26,20 @@ type Props = {
};
export const TextComponent = ({
value, isBold, color, className, size, align,
value,
isBold,
color,
className,
size,
align,
}: Props) => (
<Text className={className} isBold={isBold} color={color} size={`${String(size)}em`} align={align}>
<Text
className={className}
isBold={isBold}
color={color}
size={`${String(size)}em`}
align={align}
>
{value}
</Text>
);

View File

@ -38,7 +38,11 @@ type Props = {
zecPrice: number,
};
export const TransactionDailyComponent = ({ transactionsDate, transactions, zecPrice }: Props) => (
export const TransactionDailyComponent = ({
transactionsDate,
transactions,
zecPrice,
}: Props) => (
<Wrapper>
<Day value={transactionsDate} />
<TransactionsWrapper>

View File

@ -13,6 +13,7 @@ import { TextComponent } from './text';
import theme from '../theme';
import formatNumber from '../utils/formatNumber';
import truncateAddress from '../utils/truncateAddress';
const Wrapper = styled(RowComponent)`
background-color: ${props => props.theme.colors.cardBackgroundColor};
@ -25,7 +26,9 @@ const Icon = styled.img`
`;
const TransactionTypeLabel = styled(TextComponent)`
color: ${props => (props.isReceived ? props.theme.colors.transactionReceived : props.theme.colors.transactionSent)};
color: ${props => (props.isReceived
? props.theme.colors.transactionReceived
: props.theme.colors.transactionSent)};
text-transform: capitalize;
`;
@ -47,32 +50,51 @@ export type Transaction = {
zecPrice: number,
};
/* eslint-disable-next-line max-len */
const truncateAddress = (address: string) => `${address.substr(0, 20)}...${address.substr(address.length - 10, address.length)}`;
export const TransactionItemComponent = ({
type, date, address, amount, zecPrice,
type,
date,
address,
amount,
zecPrice,
}: Transaction) => {
const isReceived = type === 'receive';
const transactionTime = dateFns.format(new Date(date), 'HH:mm A');
const transactionValueInZec = formatNumber({
value: amount,
append: `${isReceived ? '+' : '-'}ZEC `,
});
const transactionValueInUsd = formatNumber({
value: amount * zecPrice,
append: `${isReceived ? '+' : '-'}USD $`,
});
const transactionAddress = truncateAddress(address);
return (
<Wrapper alignItems='center' justifyContent='space-between'>
<RowComponent alignItems='center'>
<RowComponent alignItems='center'>
<Icon src={isReceived ? ReceivedIcon : SentIcon} alt='Transaction Type Icon' />
<Icon
src={isReceived ? ReceivedIcon : SentIcon}
alt='Transaction Type Icon'
/>
<TransactionColumn>
<TransactionTypeLabel isReceived={isReceived} value={type} />
<TransactionTime value={dateFns.format(new Date(date), 'HH:mm A')} />
<TransactionTime value={transactionTime} />
</TransactionColumn>
</RowComponent>
<TextComponent value={truncateAddress(address)} align='left' />
<TextComponent value={transactionAddress} align='left' />
</RowComponent>
<ColumnComponent alignItems='flex-end'>
<TextComponent
value={formatNumber({ value: amount, append: `${isReceived ? '+' : '-'}ZEC ` })}
color={isReceived ? theme.colors.transactionReceived : theme.colors.transactionSent}
value={transactionValueInZec}
color={
isReceived
? theme.colors.transactionReceived
: theme.colors.transactionSent
}
/>
<TextComponent
value={formatNumber({ value: amount * zecPrice, append: `${isReceived ? '+' : '-'}USD $` })}
value={transactionValueInUsd}
color={theme.colors.inactiveItem}
/>
</ColumnComponent>

View File

@ -53,7 +53,9 @@ const SeeMoreButton = styled.button`
border-style: solid;
border-radius: 100%;
border-width: 1px;
border-color: ${props => (props.isOpen ? props.theme.colors.activeItem : props.theme.colors.inactiveItem)};
border-color: ${props => (props.isOpen
? props.theme.colors.activeItem
: props.theme.colors.inactiveItem)};
background-color: transparent;
padding: 5px;
cursor: pointer;
@ -80,7 +82,11 @@ type Props = {
};
export const WalletSummaryComponent = ({
total, shielded, transparent, zecPrice, addresses,
total,
shielded,
transparent,
zecPrice,
addresses,
}: Props) => (
<Wrapper>
<DropdownComponent
@ -94,23 +100,46 @@ export const WalletSummaryComponent = ({
/>
<AllAddresses value='ALL ADDRESSES' isBold />
<ValueBox>
<TextComponent size={theme.fontSize.zecValueBase * 2.5} value={`ZEC ${formatNumber({ value: total })}`} isBold />
<USDValue value={`USD $${formatNumber({ value: total * zecPrice })}`} size={theme.fontSize.zecValueBase * 2} />
<TextComponent
size={theme.fontSize.zecValueBase * 2.5}
value={`ZEC ${formatNumber({ value: total })}`}
isBold
/>
<USDValue
value={`USD $${formatNumber({ value: total * zecPrice })}`}
size={theme.fontSize.zecValueBase * 2}
/>
</ValueBox>
<RowComponent>
<ValueBox>
<ShieldedValue value='&#9679; SHIELDED' isBold size={theme.fontSize.text * 0.8} />
<TextComponent value={`ZEC ${formatNumber({ value: shielded })}`} isBold size={theme.fontSize.zecValueBase} />
<USDValue value={`USD $${formatNumber({ value: shielded * zecPrice })}`} />
<ShieldedValue
value='&#9679; SHIELDED'
isBold
size={theme.fontSize.text * 0.8}
/>
<TextComponent
value={`ZEC ${formatNumber({ value: shielded })}`}
isBold
size={theme.fontSize.zecValueBase}
/>
<USDValue
value={`USD $${formatNumber({ value: shielded * zecPrice })}`}
/>
</ValueBox>
<ValueBox>
<Label value='&#9679; TRANSPARENT' isBold size={theme.fontSize.text * 0.8} />
<Label
value='&#9679; TRANSPARENT'
isBold
size={theme.fontSize.text * 0.8}
/>
<TextComponent
value={`ZEC ${formatNumber({ value: transparent })}`}
isBold
size={theme.fontSize.zecValueBase}
/>
<USDValue value={`USD $${formatNumber({ value: transparent * zecPrice })}`} />
<USDValue
value={`USD $${formatNumber({ value: transparent * zecPrice })}`}
/>
</ValueBox>
</RowComponent>
</Wrapper>

View File

@ -9,6 +9,7 @@ type State = {
type Props = {};
/* eslint-disable max-len */
export const withDaemonStatusCheck = <PassedProps: {}>(
WrappedComponent: ComponentType<PassedProps>,
): ComponentType<$Diff<PassedProps, Props>> => class extends Component<PassedProps, State> {

View File

@ -25,7 +25,8 @@ export const MENU_OPTIONS = [
{
label: 'Dashboard',
route: DASHBOARD_ROUTE,
icon: (isActive: boolean) => (isActive ? DashboardIconActive : DashboardIcon),
// eslint-disable-next-line
icon: (isActive: boolean) => isActive ? DashboardIconActive : DashboardIcon,
},
{
label: 'Send',
@ -40,7 +41,8 @@ export const MENU_OPTIONS = [
{
label: 'Transactions',
route: TRANSACTIONS_ROUTE,
icon: (isActive: boolean) => (isActive ? TransactionsIconActive : TransactionsIcon),
// eslint-disable-next-line
icon: (isActive: boolean) => isActive ? TransactionsIconActive : TransactionsIcon,
},
{
label: 'Settings',

View File

@ -9,7 +9,9 @@ import { createRootReducer } from './modules/reducer';
export const history = createBrowserHistory();
const shouldEnableDevTools = (process.env.NODE_ENV !== 'production' || process.env.NODE_ENV !== 'staging') && window.devToolsExtension;
const shouldEnableDevTools = (process.env.NODE_ENV !== 'production'
|| process.env.NODE_ENV !== 'staging')
&& window.devToolsExtension;
export const configureStore = (initialState: Object) => {
const middleware = applyMiddleware(thunk, routerMiddleware(history));

View File

@ -16,7 +16,11 @@ import { LayoutComponent } from '../components/layout';
import { HeaderComponent } from '../components/header';
import {
DASHBOARD_ROUTE, SEND_ROUTE, RECEIVE_ROUTE, SETTINGS_ROUTE, CONSOLE_ROUTE,
DASHBOARD_ROUTE,
SEND_ROUTE,
RECEIVE_ROUTE,
SETTINGS_ROUTE,
CONSOLE_ROUTE,
} from '../constants/routes';
const FullWrapper = styled.div`
@ -46,7 +50,11 @@ export const RouterComponent = ({ location }: { location: Location }) => (
{/* $FlowFixMe */}
<LayoutComponent>
<Switch>
<Route exact path={DASHBOARD_ROUTE} component={DashboardContainer} />
<Route
exact
path={DASHBOARD_ROUTE}
component={DashboardContainer}
/>
<Route path={SEND_ROUTE} component={SendView} />
<Route path={RECEIVE_ROUTE} component={ReceiveView} />
<Route path={SETTINGS_ROUTE} component={SettingsView} />

View File

@ -28,7 +28,14 @@ export class Dashboard extends React.Component<Props> {
render() {
const {
error, isLoading, total, shielded, transparent, zecPrice, addresses, transactions,
error,
isLoading,
total,
shielded,
transparent,
zecPrice,
addresses,
transactions,
} = this.props;
const days = Object.keys(transactions);
@ -51,7 +58,11 @@ export class Dashboard extends React.Component<Props> {
addresses={addresses}
/>
{days.map(day => (
<TransactionDailyComponent transactionsDate={day} transactions={transactions[day]} zecPrice={zecPrice} />
<TransactionDailyComponent
transactionsDate={day}
transactions={transactions[day]}
zecPrice={zecPrice}
/>
))}
</div>
)}

View File

@ -19,16 +19,36 @@ import log from './logger';
const queue = new Queue({ concurrency: 1, autoStart: false });
const httpClient = got.extend({ baseUrl: 'https://z.cash/downloads/', retry: 3, useElectronNet: true });
const httpClient = got.extend({
baseUrl: 'https://z.cash/downloads/',
retry: 3,
useElectronNet: true,
});
const FILES: Array<{ name: string, hash: string }> = [
{ name: 'sprout-proving.key', hash: '8bc20a7f013b2b58970cddd2e7ea028975c88ae7ceb9259a5344a16bc2c0eef7' },
{ name: 'sprout-verifying.key', hash: '4bd498dae0aacfd8e98dc306338d017d9c08dd0918ead18172bd0aec2fc5df82' },
{ name: 'sapling-spend.params', hash: '8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13' },
{ name: 'sapling-output.params', hash: '2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4' },
{ name: 'sprout-groth16.params', hash: 'b685d700c60328498fbde589c8c7c484c722b788b265b72af448a5bf0ee55b50' },
{
name: 'sprout-proving.key',
hash: '8bc20a7f013b2b58970cddd2e7ea028975c88ae7ceb9259a5344a16bc2c0eef7',
},
{
name: 'sprout-verifying.key',
hash: '4bd498dae0aacfd8e98dc306338d017d9c08dd0918ead18172bd0aec2fc5df82',
},
{
name: 'sapling-spend.params',
hash: '8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13',
},
{
name: 'sapling-output.params',
hash: '2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4',
},
{
name: 'sprout-groth16.params',
hash: 'b685d700c60328498fbde589c8c7c484c722b788b265b72af448a5bf0ee55b50',
},
];
// eslint-disable-next-line max-len
const checkSha256 = (pathToFile: string, expectedHash: string) => new Promise((resolve, reject) => {
fs.readFile(pathToFile, (err, file) => {
if (err) return reject(new Error(err));
@ -39,6 +59,7 @@ const checkSha256 = (pathToFile: string, expectedHash: string) => new Promise((r
});
});
// eslint-disable-next-line max-len
const downloadFile = ({ file, pathToSave }): Promise<*> => new Promise((resolve, reject) => {
log(`Downloading ${file.name}...`);
@ -50,7 +71,9 @@ const downloadFile = ({ file, pathToSave }): Promise<*> => new Promise((resolve,
log(`SHA256 validation for file ${file.name} succeeded!`);
resolve(file.name);
} else {
reject(new Error(`SHA256 validation failed for file: ${file.name}`));
reject(
new Error(`SHA256 validation failed for file: ${file.name}`),
);
}
});
})
@ -61,7 +84,9 @@ const downloadFile = ({ file, pathToSave }): Promise<*> => new Promise((resolve,
let missingDownloadParam = false;
export default (): Promise<*> => new Promise((resolve, reject) => {
const firstRunProcess = cp.spawn(path.join(getBinariesPath(), 'win', 'first-run.bat'));
const firstRunProcess = cp.spawn(
path.join(getBinariesPath(), 'win', 'first-run.bat'),
);
firstRunProcess.stdout.on('data', data => log(data.toString()));
firstRunProcess.stderr.on('data', data => reject(data.toString()));
@ -70,20 +95,33 @@ export default (): Promise<*> => new Promise((resolve, reject) => {
await Promise.all(
FILES.map(async (file) => {
const pathToSave = path.join(app.getPath('userData'), '..', 'ZcashParams', file.name);
const pathToSave = path.join(
app.getPath('userData'),
'..',
'ZcashParams',
file.name,
);
const [cannotAccess] = await eres(util.promisify(fs.access)(pathToSave, fs.constants.F_OK));
const [cannotAccess] = await eres(
util.promisify(fs.access)(pathToSave, fs.constants.F_OK),
);
if (cannotAccess) {
missingDownloadParam = true;
// eslint-disable-next-line max-len
queue.add(() => downloadFile({ file, pathToSave }).then(() => log(`Download ${file.name} finished!`)));
} else {
const isValid = await checkSha256(pathToSave, file.hash);
if (isValid) {
log(`${file.name} already is in ${pathToSave}...`);
} else {
log(`File: ${file.name} failed in the SHASUM validation, downloading again...`);
log(
`File: ${
file.name
} failed in the SHASUM validation, downloading again...`,
);
queue.add(() => {
// eslint-disable-next-line max-len
downloadFile({ file, pathToSave }).then(() => log(`Download ${file.name} finished!`));
});
}

View File

@ -3,5 +3,8 @@ import path from 'path';
/* eslint-disable-next-line import/no-extraneous-dependencies */
import isDev from 'electron-is-dev';
// $FlowFixMe
export default () => (isDev ? path.join(__dirname, '..', '..', './bin') : path.join(process.resourcesPath, 'bin'));
/* eslint-disable operator-linebreak */
export default () => (isDev
? path.join(__dirname, '..', '..', './bin')
: // $FlowFixMe
path.join(process.resourcesPath, 'bin'));

View File

@ -8,5 +8,7 @@ import runUnixFetchParams from './fetch-unix-params';
export default (): Promise<*> => {
log('Fetching params');
return os.platform() === 'win32' ? fetchWindowsParams() : runUnixFetchParams();
return os.platform() === 'win32'
? fetchWindowsParams()
: runUnixFetchParams();
};

View File

@ -35,13 +35,20 @@ const getDaemonOptions = ({ username, password }) => {
`-rpcuser=${username}`,
`-rpcpassword=${password}`,
];
return isDev ? defaultOptions.concat(['-testnet', '-addnode=testnet.z.cash']) : defaultOptions;
return isDev
? defaultOptions.concat(['-testnet', '-addnode=testnet.z.cash'])
: defaultOptions;
};
let resolved = false;
// eslint-disable-next-line
const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve, reject) => {
const processName = path.join(getBinariesPath(), getOsFolder(), getDaemonName());
const processName = path.join(
getBinariesPath(),
getOsFolder(),
getDaemonName(),
);
const [err] = await eres(fetchParams());
@ -76,9 +83,13 @@ const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve
store.set('rpcpassword', rpcCredentials.password);
}
const childProcess = cp.spawn(processName, getDaemonOptions(rpcCredentials), {
stdio: ['ignore', 'pipe', 'pipe'],
});
const childProcess = cp.spawn(
processName,
getDaemonOptions(rpcCredentials),
{
stdio: ['ignore', 'pipe', 'pipe'],
},
);
childProcess.stdout.on('data', (data) => {
if (mainWindow) mainWindow.webContents.send('zcashd-log', data.toString());

View File

@ -39,9 +39,9 @@ const createWindow = () => {
autoUpdater.on('download-progress', progress => showStatus(
/* eslint-disable-next-line max-len */
`Download speed: ${progress.bytesPerSecond} - Downloaded ${progress.percent}% (${progress.transferred}/${
progress.total
})`,
`Download speed: ${progress.bytesPerSecond} - Downloaded ${
progress.percent
}% (${progress.transferred}/${progress.total})`,
));
autoUpdater.on('update-downloaded', () => {
updateAvailable = true;
@ -67,7 +67,11 @@ const createWindow = () => {
mainWindow.setVisibleOnAllWorkspaces(true);
registerDebugShortcut(app, mainWindow);
mainWindow.loadURL(isDev ? 'http://0.0.0.0:8080/' : `file://${path.join(__dirname, '../build/index.html')}`);
mainWindow.loadURL(
isDev
? 'http://0.0.0.0:8080/'
: `file://${path.join(__dirname, '../build/index.html')}`,
);
exports.app = app;
exports.mainWindow = mainWindow;