Add "No Unused Params and Locals" Linting Rule (#297)

Add "No Unused Params and Locals" Linting Rule
This commit is contained in:
HenryNguyen5 2017-10-18 22:29:49 -04:00 committed by Daniel Ternyak
parent 804f986cb5
commit b94bede473
22 changed files with 37 additions and 58 deletions

View File

@ -1,5 +1,3 @@
import * as constants from './constants';
/*** Resolve ENS name ***/
export interface ResolveEnsNameAction {
type: 'ENS_RESOLVE';

View File

@ -1,6 +1,6 @@
import * as interfaces from './actionTypes';
import { TypeKeys } from './constants';
import { fetchRates, CCResponse } from './actionPayloads';
import { fetchRates } from './actionPayloads';
export type TFetchCCRates = typeof fetchCCRates;
export function fetchCCRates(): interfaces.FetchCCRates {

View File

@ -1,6 +1,6 @@
import logo from 'assets/images/logo-myetherwallet.svg';
import { bityReferralURL, donationAddressMap } from 'config/data';
import React, { Component } from 'react';
import React from 'react';
import translate from 'translations';
import './index.scss';
import PreFooter from './PreFooter';

View File

@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import NavigationLink from './NavigationLink';

View File

@ -7,7 +7,7 @@ import {
SetDesiredTokenAction
} from 'actions/deterministicWallets';
import Modal, { IButton } from 'components/ui/Modal';
import { NetworkConfig, Token } from 'config/data';
import { NetworkConfig } from 'config/data';
import { isValidPath } from 'libs/validators';
import React from 'react';
import { connect } from 'react-redux';
@ -123,20 +123,21 @@ class DeterministicWalletsModal extends React.Component<Props, State> {
onChange={this.handleChangePath}
value={isCustomPath ? 'custom' : dPath}
>
{dPaths.map(dp =>
{dPaths.map(dp => (
<option key={dp.value} value={dp.value}>
{dp.label}
</option>
)}
))}
<option value="custom">Custom path...</option>
</select>
{isCustomPath &&
{isCustomPath && (
<input
className={`form-control ${validPathClass}`}
value={customPath}
placeholder="m/44'/60'/0'/0"
onChange={this.handleChangeCustomPath}
/>}
/>
)}
</form>
<div className="DWModal-addresses">
@ -145,9 +146,7 @@ class DeterministicWalletsModal extends React.Component<Props, State> {
<tr>
<td>#</td>
<td>Address</td>
<td>
{network.unit}
</td>
<td>{network.unit}</td>
<td>
<select
className="DWModal-addresses-table-token"
@ -155,11 +154,11 @@ class DeterministicWalletsModal extends React.Component<Props, State> {
onChange={this.handleChangeToken}
>
<option value="">-Token-</option>
{tokens.map(t =>
{tokens.map(t => (
<option key={t.symbol} value={t.symbol}>
{t.symbol}
</option>
)}
))}
</select>
</td>
<td>More</td>
@ -280,9 +279,7 @@ class DeterministicWalletsModal extends React.Component<Props, State> {
key={wallet.address}
onClick={this.selectAddress.bind(this, wallet.address, wallet.index)}
>
<td>
{wallet.index + 1}
</td>
<td>{wallet.index + 1}</td>
<td className="DWModal-addresses-table-address">
<input
type="radio"

View File

@ -31,9 +31,7 @@ export default class MnemonicDecrypt extends Component<Props, State> {
return (
<section className="col-md-4 col-sm-6">
<div id="selectedTypeKey">
<h4>
{translate('ADD_Radio_5')}
</h4>
<h4>{translate('ADD_Radio_5')}</h4>
<div className="form-group">
<textarea
id="aria-private-key"
@ -56,7 +54,7 @@ export default class MnemonicDecrypt extends Component<Props, State> {
type="password"
/>
</div>
{isValidMnemonic &&
{isValidMnemonic && (
<div className="form-group">
<button
style={{ width: '100%' }}
@ -65,7 +63,8 @@ export default class MnemonicDecrypt extends Component<Props, State> {
>
{translate('Choose Address')}
</button>
</div>}
</div>
)}
</div>
<DeterministicWalletsModal
@ -90,7 +89,7 @@ export default class MnemonicDecrypt extends Component<Props, State> {
this.setState({ phrase: (e.target as HTMLTextAreaElement).value });
};
public onDWModalOpen = (e: React.SyntheticEvent<HTMLButtonElement>) => {
public onDWModalOpen = () => {
const { phrase, pass } = this.state;
if (!validateMnemonic(phrase)) {

View File

@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React from 'react';
import './Code.scss';
const Code = ({ children }) => (

View File

@ -52,8 +52,6 @@ export default class ColorDropdown<T> extends Component<Props<T>, {}> {
private renderOptions = () => {
const { options, value, menuAlign, extra } = this.props;
const activeOption = this.getActiveOption();
const listItems = options.reduce((prev: any[], opt) => {
const prevOpt = prev.length ? prev[prev.length - 1] : null;
if (prevOpt && !prevOpt.divider && prevOpt.color !== opt.color) {

View File

@ -34,7 +34,7 @@ export default class DropdownComponent<T> extends Component<Props<T>, {}> {
}
private renderLabel = () => {
const { label, value } = this.props;
const { value } = this.props;
const labelStr = this.props.label ? `${this.props.label}:` : '';
return (
<span>

View File

@ -1,6 +1,5 @@
import React from 'react';
import helpIcon from 'assets/images/icon-help.svg';
import translate, { translateRaw } from 'translations';
type sizeType = 'small' | 'medium' | 'large';

View File

@ -1,6 +1,6 @@
import { connect } from 'react-redux';
import ENS from './components/ENS';
const mapStateToProps = state => ({});
const mapStateToProps = _ => ({});
export default connect(mapStateToProps)(ENS);

View File

@ -1,4 +1,4 @@
import Big, {BigNumber} from 'bignumber.js';
import { BigNumber } from 'bignumber.js';
import { toChecksumAddress } from 'ethereumjs-util';
import Contract, { ABI } from 'libs/contract';

View File

@ -1,4 +1,3 @@
import Big from 'bignumber.js';
import { randomBytes } from 'crypto';
import RPCClient from '../rpc/client';

View File

@ -9,7 +9,7 @@ import { Ether, toTokenUnit, UnitKey, Wei } from 'libs/units';
import { isValidETHAddress } from 'libs/validators';
import { stripHexPrefixAndLower, valueToHex } from 'libs/values';
import { IWallet } from 'libs/wallet';
import translate, { translateRaw } from 'translations';
import { translateRaw } from 'translations';
import Big, { BigNumber } from 'bignumber.js';
export interface TransactionInput {

View File

@ -1,4 +1,4 @@
import Big, { BigNumber } from 'bignumber.js';
import Big from 'bignumber.js';
import EthTx from 'ethereumjs-tx';
import { addHexPrefix } from 'ethereumjs-util';
import { RawTransaction } from 'libs/transaction';

View File

@ -2,9 +2,7 @@ import {
ChangeGasPriceAction,
ChangeLanguageAction,
ChangeNodeAction,
ConfigAction,
ToggleOfflineAction,
ForceOfflineAction
ConfigAction
} from 'actions/config';
import { TypeKeys } from 'actions/config/constants';
import { NODES } from '../config/data';
@ -47,14 +45,14 @@ function changeGasPrice(state: State, action: ChangeGasPriceAction): State {
};
}
function toggleOffline(state: State, action: ToggleOfflineAction): State {
function toggleOffline(state: State): State {
return {
...state,
offline: !state.offline
};
}
function forceOffline(state: State, action: ForceOfflineAction): State {
function forceOffline(state: State): State {
return {
...state,
forceOffline: !state.forceOffline
@ -73,9 +71,9 @@ export function config(
case TypeKeys.CONFIG_GAS_PRICE:
return changeGasPrice(state, action);
case TypeKeys.CONFIG_TOGGLE_OFFLINE:
return toggleOffline(state, action);
return toggleOffline(state);
case TypeKeys.CONFIG_FORCE_OFFLINE:
return forceOffline(state, action);
return forceOffline(state);
default:
return state;
}

View File

@ -1,9 +1,4 @@
import {
FetchCCRatesSucceeded,
FetchCCRatesFailed,
RatesAction,
CCResponse
} from 'actions/rates';
import { FetchCCRatesSucceeded, RatesAction, CCResponse } from 'actions/rates';
import { TypeKeys } from 'actions/rates/constants';
import { Optional } from 'utils/types';
@ -22,7 +17,7 @@ function fetchCCRatesSucceeded(
return { ...state, rates: action.payload };
}
function fetchCCRatesFailed(state: State, action: FetchCCRatesFailed): State {
function fetchCCRatesFailed(state: State): State {
// TODO: Make library for error messages
return {
...state,
@ -38,7 +33,7 @@ export function rates(
case TypeKeys.RATES_FETCH_CC_SUCCEEDED:
return fetchCCRatesSucceeded(state, action);
case TypeKeys.RATES_FETCH_CC_FAILED:
return fetchCCRatesFailed(state, action);
return fetchCCRatesFailed(state);
default:
return state;
}

View File

@ -13,11 +13,7 @@ import { NODES } from 'config/data';
import { getNodeConfig } from 'selectors/config';
import { AppState } from 'reducers';
import { TypeKeys } from 'actions/config/constants';
import {
toggleOfflineConfig,
TToggleOfflineConfig,
changeNode
} from 'actions/config';
import { toggleOfflineConfig, changeNode } from 'actions/config';
import { State as ConfigState } from 'reducers/config';
export const getConfig = (state: AppState): ConfigState => state.config;

View File

@ -4,7 +4,7 @@ import { getAllRates } from 'api/bity';
import { delay, SagaIterator } from 'redux-saga';
import { call, cancel, fork, put, take, takeLatest } from 'redux-saga/effects';
export function* loadBityRates(action?: any): SagaIterator {
export function* loadBityRates(): SagaIterator {
while (true) {
try {
const data = yield call(getAllRates);

View File

@ -1,4 +1,4 @@
import Big, { BigNumber } from 'bignumber.js';
import { BigNumber } from 'bignumber.js';
export function toFixedIfLarger(num: number, fixedSize: number = 6): string {
return parseFloat(num.toFixed(fixedSize)).toString();

View File

@ -1,5 +1,4 @@
export const REDUX_STATE = 'REDUX_STATE';
import { State as CustomTokenState } from 'reducers/customTokens';
import { State as SwapState } from 'reducers/swap';
export function loadState<T>(): T | undefined {

View File

@ -11,7 +11,9 @@
"lib": ["es2017", "dom"],
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"noEmitOnError": false
"noEmitOnError": false,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"./common/",