Skip to content

Commit

Permalink
dapp: fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andrevmatos committed Oct 31, 2020
1 parent 95df1b8 commit 2076fe1
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 182 deletions.
46 changes: 23 additions & 23 deletions raiden-dapp/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
RaidenChannel,
RaidenChannels,
RaidenConfig,
RaidenTransfer
RaidenTransfer,
} from 'raiden-ts';
import {
AccTokenModel,
Expand All @@ -17,7 +17,7 @@ import {
PlaceHolderNetwork,
Token,
TokenModel,
Presences
Presences,
} from '@/model/types';
import map from 'lodash/map';
import flatMap from 'lodash/flatMap';
Expand Down Expand Up @@ -49,12 +49,12 @@ const _defaultState: RootState = {
stateBackup: '',
settings: {
isFirstTimeConnect: true,
useRaidenAccount: true
useRaidenAccount: true,
},
config: {},
userDepositTokenAddress: '',
disclaimerAccepted: false,
persistDisclaimerAcceptance: false
persistDisclaimerAcceptance: false,
};

export function defaultState(): RootState {
Expand All @@ -71,19 +71,19 @@ const hasNonZeroBalance = (a: Token, b: Token) =>
(!(a.balance as BigNumber).isZero() || !(b.balance as BigNumber).isZero());

const settingsLocalStorage = new VuexPersistence<RootState>({
reducer: state => ({ settings: state.settings }),
filter: mutation => mutation.type == 'updateSettings',
key: 'raiden_dapp_settings'
reducer: (state) => ({ settings: state.settings }),
filter: (mutation) => mutation.type == 'updateSettings',
key: 'raiden_dapp_settings',
});

const disclaimerAcceptedLocalStorage = new VuexPersistence<RootState>({
reducer: state => ({
reducer: (state) => ({
disclaimerAccepted: state.persistDisclaimerAcceptance
? state.disclaimerAccepted
: false
: false,
}),
filter: mutation => mutation.type === 'acceptDisclaimer',
key: 'raiden_dapp_disclaimer_accepted'
filter: (mutation) => mutation.type === 'acceptDisclaimer',
key: 'raiden_dapp_disclaimer_accepted',
});

const store: StoreOptions<RootState> = {
Expand Down Expand Up @@ -138,7 +138,7 @@ const store: StoreOptions<RootState> = {
...defaultState(),
settings,
disclaimerAccepted,
stateBackup
stateBackup,
});
},
updateTransfers(state: RootState, transfer: RaidenTransfer) {
Expand All @@ -159,11 +159,11 @@ const store: StoreOptions<RootState> = {
acceptDisclaimer(state: RootState, persistDecision: boolean) {
state.disclaimerAccepted = true;
state.persistDisclaimerAcceptance = persistDecision;
}
},
},
actions: {},
getters: {
tokens: function(state: RootState): TokenModel[] {
tokens: function (state: RootState): TokenModel[] {
const reducer = (
acc: AccTokenModel,
channel: RaidenChannel
Expand All @@ -174,8 +174,8 @@ const store: StoreOptions<RootState> = {
};

return map(
filter(flatMap(state.channels), channels => !isEmpty(channels)),
tokenChannels => {
filter(flatMap(state.channels), (channels) => !isEmpty(channels)),
(tokenChannels) => {
const model = reduce(tokenChannels, reducer, emptyTokenModel());
const tokenInfo = state.tokens[model.address];
if (tokenInfo) {
Expand All @@ -189,7 +189,7 @@ const store: StoreOptions<RootState> = {
},
allTokens: (state: RootState): Token[] =>
Object.values(state.tokens)
.filter(token => state.tokenAddresses.includes(token.address))
.filter((token) => state.tokenAddresses.includes(token.address))
.sort((a: Token, b: Token) => {
if (hasNonZeroBalance(a, b)) {
return (b.balance! as BigNumber).gt(a.balance! as BigNumber)
Expand Down Expand Up @@ -225,13 +225,13 @@ const store: StoreOptions<RootState> = {
channelWithBiggestCapacity: (_, getters) => (tokenAddress: string) => {
const channels: RaidenChannel[] = getters.channels(tokenAddress);
const openChannels = channels.filter(
value => value.state === ChannelState.open
(value) => value.state === ChannelState.open
);
return orderBy(openChannels, ['capacity'], ['desc'])[0];
},
pendingTransfers: ({ transfers }: RootState) =>
Object.keys(transfers)
.filter(key => {
.filter((key) => {
const { completed } = transfers[key];

// return whether transfer is pending or not
Expand All @@ -242,7 +242,7 @@ const store: StoreOptions<RootState> = {
return pendingTransfers;
}, {}),
transfer: (state: RootState) => (paymentId: BigNumber) => {
return Object.values(state.transfers).find(transfer =>
return Object.values(state.transfers).find((transfer) =>
transfer.paymentId.eq(paymentId)
);
},
Expand All @@ -257,12 +257,12 @@ const store: StoreOptions<RootState> = {
},
usingRaidenAccount: (state: RootState): boolean => {
return !!state.settings.useRaidenAccount;
}
},
},
plugins: [settingsLocalStorage.plugin, disclaimerAcceptedLocalStorage.plugin],
modules: {
notifications
}
notifications,
},
};

export default new Vuex.Store(store);
2 changes: 1 addition & 1 deletion raiden-dapp/tests/unit/balance-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('BalanceUtils', () => {
balance: BigNumber.from(0),
decimals: 18,
name: '',
symbol: ''
symbol: '',
};

test('return true when the number of decimal places is greater than what the token supports', () => {
Expand Down
12 changes: 6 additions & 6 deletions raiden-dapp/tests/unit/components/account/withdrawal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ function createWrapper(
): Wrapper<Withdrawal> {
$raiden = {
getTokenBalance: jest.fn().mockResolvedValue(tokenBalance),
transferOnChainTokens: jest.fn()
transferOnChainTokens: jest.fn(),
};

const state = {
raidenAccountBalance
raidenAccountBalance,
};

const getters = {
udcToken: () => {
return {
address: '0xuserdeposittoken',
balance: BigNumber.from('0')
balance: BigNumber.from('0'),
};
},
allTokens: () => []
allTokens: () => [],
};

const store = new Vuex.Store({ state, getters });
Expand All @@ -52,8 +52,8 @@ function createWrapper(
mocks: {
$identicon: $identicon(),
$t: (msg: string) => msg,
$raiden
}
$raiden,
},
});
}

Expand Down
6 changes: 3 additions & 3 deletions raiden-dapp/tests/unit/components/amount-display.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ describe('AmountDisplay.vue', () => {
balance: constants.One,
decimals: 18,
symbol: 'TTT',
name: 'Test Token'
name: 'Test Token',
};

const createWrapper = (exactAmount: boolean) => {
return mount(AmountDisplay, {
propsData: {
exactAmount: exactAmount,
amount: token.balance,
token: token
}
token: token,
},
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ describe('ChannelWithdraw.vue', () => {
expect(messages.exists()).toBe(true);
expect(messages.text()).toEqual('amount-input.error.not-enough-funds');

mockInput(wrapper, utils.formatUnits(channel.capacity, TestData.token.decimals));
mockInput(
wrapper,
utils.formatUnits(channel.capacity, TestData.token.decimals)
);
await wrapper.vm.$nextTick();
expect(wrapper.find('.v-messages__message').exists()).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ describe('TransferProgressDialog.vue', () => {
const transferPending = {
key: 'sent:0x1',
paymentId: BigNumber.from('0x1'),
status: 'PENDING'
status: 'PENDING',
};
const transferRequested = {
key: 'sent:0x1',
paymentId: BigNumber.from('0x1'),
status: 'REQUESTED'
status: 'REQUESTED',
};

beforeEach(() => {
Expand All @@ -29,14 +29,14 @@ describe('TransferProgressDialog.vue', () => {
store,
stubs: ['v-dialog'],
mocks: {
$t: (msg: string) => msg
$t: (msg: string) => msg,
},
propsData: {
visible: true,
inProgress: true,
error: false,
identifier: transferPending.paymentId
}
identifier: transferPending.paymentId,
},
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ describe('UdcDepositDialog.vue', () => {
depositToUDC: jest.fn(),
getMainAccount: jest.fn(),
getAccount: jest.fn(),
getTokenBalance: jest.fn()
getTokenBalance: jest.fn(),
};

const token = {
address: '0x3a989D97388a39A0B5796306C615d10B7416bE77',
name: 'Test Token',
symbol: 'TTT',
decimals: 18,
balance: constants.Zero
balance: constants.Zero,
} as Token;

function createWrapper(): Wrapper<UdcDepositDialog> {
Expand All @@ -38,11 +38,11 @@ describe('UdcDepositDialog.vue', () => {
stubs: ['v-dialog'],
mocks: {
$t: (msg: string) => msg,
$raiden
$raiden,
},
propsData: {
visible: true
}
visible: true,
},
});
}

Expand All @@ -53,7 +53,7 @@ describe('UdcDepositDialog.vue', () => {
'0x3a989D97388a39A0B5796306C615d10B7416bE77'
);
store.commit('updateTokens', {
'0x3a989D97388a39A0B5796306C615d10B7416bE77': token
'0x3a989D97388a39A0B5796306C615d10B7416bE77': token,
});
wrapper = createWrapper();
jest.resetAllMocks();
Expand Down Expand Up @@ -86,8 +86,8 @@ describe('UdcDepositDialog.vue', () => {
store.commit('updateTokens', {
'0x3a989D97388a39A0B5796306C615d10B7416bE77': {
...token,
balance: BigNumber.from('10000000000000000000')
}
balance: BigNumber.from('10000000000000000000'),
},
});

wrapper.find('.udc-deposit-dialog__action button').trigger('click');
Expand All @@ -107,8 +107,8 @@ describe('UdcDepositDialog.vue', () => {
store.commit('updateTokens', {
'0x3a989D97388a39A0B5796306C615d10B7416bE77': {
...token,
balance: BigNumber.from('10000000000000000000')
}
balance: BigNumber.from('10000000000000000000'),
},
});
store.commit('network', { name: 'mainnet', chainId: 1 });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Mocked = jest.Mocked;
import UdcWithdrawalDialog from '@/components/dialogs/UdcWithdrawalDialog.vue';

Vue.use(Vuetify);
describe('UdcWithdrawalDialog.vue', function() {
describe('UdcWithdrawalDialog.vue', function () {
let wrapper: Wrapper<UdcWithdrawalDialog>;
let $raiden: Mocked<RaidenService>;

Expand All @@ -22,7 +22,7 @@ describe('UdcWithdrawalDialog.vue', function() {
name: 'ServiceToken',
symbol: 'SVT',
decimals: 18,
balance: constants.One
balance: constants.One,
};
function createWrapper() {
const vuetify = new Vuetify();
Expand All @@ -34,13 +34,13 @@ describe('UdcWithdrawalDialog.vue', function() {
visible: true,
accountBalance: '0.23',
token,
capacity: utils.parseEther('10')
capacity: utils.parseEther('10'),
},
mocks: {
$identicon: $identicon(),
$t: (msg: string) => msg,
$raiden
}
$raiden,
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ describe('TransferInputs.vue', () => {
mocks: {
$router: router,
$route: TestData.mockRoute({
token
token,
}),
$t: (msg: string) => msg
$t: (msg: string) => msg,
},
propsData: {
token,
capacity: constants.One
}
capacity: constants.One,
},
});

test('navigates to transfer steps if target and amount is valid', async () => {
Expand All @@ -47,7 +47,7 @@ describe('TransferInputs.vue', () => {
await wrapper.vm.$nextTick();

wrapper.setData({
valid: true
valid: true,
});
await wrapper.vm.$nextTick();

Expand Down
Loading

0 comments on commit 2076fe1

Please sign in to comment.