Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint basic rules #2236

Merged
merged 5 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ module.exports = {
"array-bracket-spacing": ["error", "never"],
"indent": ["error", 2, { "SwitchCase": 1 }],
"no-console": "off",
"semi": ["error", "never"]
"brace-style": ["error", "1tbs"],
"semi": ["error", "never"],
"no-tabs": ["error"],
"max-len": ["error", { "code": 80, "ignoreStrings": true, "ignoreComments": true, "ignoreTemplateLiterals": true }],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i miss prettier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, basically prettier is enforcing a set of preconfigured rules, I'm picking the easy ones piece by piece, but some take time where those are quick to add

"no-trailing-spaces": ["error", { "skipBlankLines": false }]
}
}
2 changes: 2 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### Changed

- [#\2202](https://github.com/cosmos/voyager/pull/2202) Fix circle configuration for publishing @sabau
- [#\2236](https://github.com/cosmos/voyager/pull/2236) ES lint no tabs @sabau
- [\#1805](https://github.com/cosmos/voyager/issues/1805) support all transaction types @fedekunze
- [#\2211](https://github.com/cosmos/voyager/pull/2211) simplified sidebar and mobile menu, cleaned up css, fixed tests @jbibla

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/components/common/FundraiserWarning.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<p class="fundraiser-warning">
Warning – Do not enter your actual 12 or 24 word fundraiser seed. This feature is only for testing Voyager and is considered highly insecure.
Warning – Do not enter your actual 12 or 24 word fundraiser seed.
This feature is only for testing Voyager and is considered highly insecure.
</p>
</template>

Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/components/common/TextBlock.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<!-- TODO:SECURITY try to add a malicious block and see how is rendered, like <script>alert('danger')</script> -->
<!-- TODO:SECURITY try to add a malicious block and see how is rendered,
like <script>alert('danger')</script> -->
<!-- eslint-disable vue/no-v-html -->
<div class="text-block" v-html="htmlContent" />
</template>
Expand Down
5 changes: 4 additions & 1 deletion app/src/renderer/components/common/TmConnectedNetwork.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
<img class="tm-connected-network-loader" src="~assets/images/loader.svg" />
<div
v-tooltip.top="networkTooltip"
class="tm-connected-network__string tm-connected-network__string--connecting"
class="
tm-connected-network__string
tm-connected-network__string--connecting
"
>
Connecting to {{ lastHeader.chain_id }}…
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/components/common/TmField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
<div class="tm-toggle-wrapper" @click.prevent="toggle">
<span>
{{
currentToggleState ? resolvedOptions.checked : resolvedOptions.unchecked
currentToggleState ?
resolvedOptions.checked : resolvedOptions.unchecked
}}
</span>
<div class="toggle-option-checked">
Expand Down
5 changes: 4 additions & 1 deletion app/src/renderer/components/common/TmFormGroup.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<template>
<div :class="cssClass">
<span v-if="subLabel" class="tm-form-group__sub-label">{{ subLabel }}</span><label
<span v-if="subLabel" class="tm-form-group__sub-label">
{{ subLabel }}
</span>
<label
v-if="fieldId && fieldLabel"
:for="fieldId"
class="tm-form-group__label"
Expand Down
12 changes: 8 additions & 4 deletions app/src/renderer/components/common/TmListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
<div v-else class="tm-li-dd">{{ dd }}</div>
</div>
<div class="tm-li-icon">
<i class="material-icons inactive">chevron_right</i><i class="material-icons active">my_location</i>
<i class="material-icons inactive">chevron_right</i>
<i class="material-icons active">my_location</i>
</div>
</div>
</a>
Expand Down Expand Up @@ -81,7 +82,8 @@
</div>
</div>
<div class="tm-li-icon">
<i class="material-icons inactive">chevron_right</i><i class="material-icons active">my_location</i>
<i class="material-icons inactive">chevron_right</i>
<i class="material-icons active">my_location</i>
</div>
</div>
</router-link>
Expand Down Expand Up @@ -167,7 +169,8 @@
<div class="tm-li-subtitle">{{ subtitle }}</div>
</div>
<div class="tm-li-icon">
<i class="material-icons inactive">chevron_right</i><i class="material-icons active">my_location</i>
<i class="material-icons inactive">chevron_right</i>
<i class="material-icons active">my_location</i>
</div>
</div>
</a>
Expand Down Expand Up @@ -195,7 +198,8 @@
</div>
</div>
<div class="tm-li-icon">
<i class="material-icons inactive">chevron_right</i><i class="material-icons active">my_location</i>
<i class="material-icons inactive">chevron_right</i>
<i class="material-icons active">my_location</i>
</div>
</div>
</router-link>
Expand Down
6 changes: 4 additions & 2 deletions app/src/renderer/components/common/TmSession.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<session-account-delete
v-else-if="session.modals.session.state == 'delete'"
/>
<session-hardware v-else-if="session.modals.session.state == 'hardware'" />
<session-hardware
v-else-if="session.modals.session.state == 'hardware'"
/>
<session-import v-else-if="session.modals.session.state == 'import'" />
</div>
<connected-network />
Expand Down Expand Up @@ -37,7 +39,7 @@ export default {
SessionAccountDelete,
ConnectedNetwork
},
computed: {
computed: {
...mapGetters([`session`]),
active() {
return this.session.modals.session.active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export default {
TmFormMsg,
TmFormStruct
},
data: () => ({
data: () => ({
deletionPassword: ``,
deletionWarning: false
deletionWarning: false
}),
mounted() {
this.$el.querySelector(`#sign-in-password`).focus()
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/components/common/TmSessionSignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
<tm-form-msg
class="sm"
type="custom"
msg="Please back up the seed phrase for this account. This seed phrase
cannot be recovered."
msg="Please back up the seed phrase for this account.
This seed phrase cannot be recovered."
/>
</tm-form-group>
<tm-form-group
Expand Down
6 changes: 5 additions & 1 deletion app/src/renderer/components/common/ToolBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
<router-link v-if="session.signedIn" id="settings" to="/preferences">
<i v-tooltip.bottom="'Preferences'" class="material-icons">settings</i>
</router-link>
<a v-if="session.signedIn" id="signOut-btn" @click="signOut()">
<a
v-if="session.signedIn"
id="signOut-btn"
@click="signOut()"
>
<i
v-tooltip.bottom.end="'Sign Out'"
class="material-icons"
Expand Down
4 changes: 3 additions & 1 deletion app/src/renderer/components/governance/PageProposal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@
<dl class="info_dl colored_dl">
<dt>No with Veto</dt>
<dd>
{{ num.atoms(tally.no_with_veto) }} / {{ noWithVetoPercentage }}
{{
num.atoms(tally.no_with_veto) }} / {{ noWithVetoPercentage
}}
</dd>
</dl>
<dl class="info_dl colored_dl">
Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/components/governance/TabProposals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<tm-data-empty
v-else-if="Object.keys(proposals.proposals).length === 0"
title="No Governance Proposals"
subtitle="There are currently no governance proposals to display. Click the 'Create Proposal' button to submit a proposal."
subtitle="There are currently no governance proposals to display.
Click the 'Create Proposal' button to submit a proposal."
/>
<table-proposals
v-else
Expand Down
7 changes: 4 additions & 3 deletions app/src/renderer/components/network/PageBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
<dl class="info_dl colored_dl">
<dt>Transactions</dt>
<dd>
{{ (block.block && block.block.data.txs) || `No Transactions` }}
{{
block.block && block.block.data.txs || `No Transactions`
}}
</dd>
</dl>
</div>
Expand All @@ -48,8 +50,7 @@
<dt>Evidence</dt>
<dd>
{{
(block.block && block.block.evidence.evidence) ||
`No Evidence`
block.block && block.block.evidence.evidence || `No Evidence`
}}
</dd>
</dl>
Expand Down
5 changes: 4 additions & 1 deletion app/src/renderer/components/staking/LiValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
>
<img
v-else
class="data-table__row__info__image data-table__row__info__image--no-img"
class="
data-table__row__info__image
data-table__row__info__image--no-img
"
src="~assets/images/validator-icon.svg"
width="48"
height="48"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
>
<template v-if="sent">
<div slot="caption">
Sent&nbsp;<b>{{ full(atoms(coins.amount)) }}</b><span>&nbsp;{{ coins.denom.toUpperCase() }}</span>
Sent&nbsp;
<b>{{ full(atoms(coins.amount)) }}</b>
<span>&nbsp;{{ coins.denom.toUpperCase() }}</span>
</div>
<span slot="details">
<template v-if="sentSelf">
Expand All @@ -17,7 +19,10 @@
</span>
</template><template v-else>
<div slot="caption">
Received&nbsp;<b>{{ full(atoms(coins.amount)) }}</b><span>&nbsp;{{ coins.denom.toUpperCase() }}</span>

Received&nbsp;
<b>{{ full(atoms(coins.amount)) }}</b>
<span>&nbsp;{{ coins.denom.toUpperCase() }}</span>
</div>
<span slot="details">From {{ sender }}</span>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
To {{ tx.withdraw_address }}
</div>
</template>
<template v-else-if="txType === `cosmos-sdk/MsgWithdrawValidatorCommission`">
<template
v-else-if="txType === `cosmos-sdk/MsgWithdrawValidatorCommission`"
>
<div slot="caption">
Withdraw validator commission
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
>
<template v-if="txType === `cosmos-sdk/MsgSubmitProposal`">
<div slot="caption">
Submit {{ tx.proposal_type.toLowerCase() }} proposal&nbsp;<b>{{ full(atoms(tx.initial_deposit[0].amount)) }}</b><span>&nbsp;{{ tx.initial_deposit[0].denom }}s</span>
Submit {{ tx.proposal_type.toLowerCase() }} proposal&nbsp;
<b>{{ full(atoms(tx.initial_deposit[0].amount)) }}</b>
<span>&nbsp;{{ tx.initial_deposit[0].denom }}s</span>
</div>
<div slot="details">
Title:&nbsp;<i>{{ tx.title }}</i>
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/vuex/modules/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function({ node }) {
},
({ header }) => {
dispatch(`setLastHeader`, header)

if (rootState.session.signedIn) {
dispatch(`getTotalRewards`)
}
Expand Down
35 changes: 21 additions & 14 deletions app/src/renderer/vuex/modules/distribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ export default ({ node }) => {
loaded: false,
error: null,
/* totalRewards use the following format:
{
{
denom1: amount1,
... ,
denomN: amountN
denomN: amountN
}
*/
totalRewards: {},
/* rewards use the following format:
{
validatorAddr1: {
{
validatorAddr1: {
denom1: amount1,
... ,
denomN: amountN
denomN: amountN
},
... ,
validatorAddrN: {
validatorAddrN: {
denom1: amount1,
... ,
denomN: amountN
}
}
denomN: amountN
}
}
*/
rewards: {},
parameters: {},
/* outstandingRewards use the following format:
{
{
denom1: amount1,
... ,
denomN: amountN
denomN: amountN
}
*/
outstandingRewards: {}
Expand Down Expand Up @@ -106,10 +106,16 @@ export default ({ node }) => {
state.loading = false
state.loaded = true
},
async getRewardsFromValidator({ state, rootState: { session }, commit }, validatorAddr) {
async getRewardsFromValidator(
{ state, rootState: { session }, commit },
validatorAddr
) {
state.loading = true
try {
const rewardsArray = await node.getDelegatorRewardsFromValidator(session.address, validatorAddr)
const rewardsArray = await node.getDelegatorRewardsFromValidator(
session.address,
validatorAddr
)
const rewards = coinsToObject(rewardsArray)
commit(`setDelegationRewards`, { validatorAddr, rewards })
commit(`setDistributionError`, null)
Expand Down Expand Up @@ -137,7 +143,8 @@ export default ({ node }) => {
async getOutstandingRewards({ commit }) {
state.loading = true
try {
const oustandingRewardsArray = await node.getDistributionOutstandingRewards()
const oustandingRewardsArray =
await node.getDistributionOutstandingRewards()
const oustandingRewards = coinsToObject(oustandingRewardsArray)
commit(`setOutstandingRewards`, oustandingRewards)
commit(`setDistributionError`, null)
Expand Down
5 changes: 3 additions & 2 deletions app/src/renderer/vuex/modules/governance/deposits.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ export default ({ node }) => {
password,
submitType
})

// optimistic update
deposit.forEach(({ amount, denom }) => {
const oldBalance = wallet.balances.find(balance => balance.denom === denom)
const oldBalance = wallet.balances
.find(balance => balance.denom === denom)
commit(`updateWalletBalance`, {
denom,
amount: oldBalance.amount - amount
Expand Down
5 changes: 3 additions & 2 deletions app/src/renderer/vuex/modules/governance/proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ export default ({ node }) => {
password,
submitType
})

// optimistic updates
initial_deposit.forEach(({ amount, denom }) => {
const oldBalance = wallet.balances.find(balance => balance.denom === denom)
const oldBalance = wallet.balances
.find(balance => balance.denom === denom)
commit(`updateWalletBalance`, {
denom,
amount: BigNumber(oldBalance.amount).minus(amount).toNumber()
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/vuex/modules/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default ({ node }) => {
const signatureBuffer = state.externals.signatureImport(
signatureByteArray
)
/*
/*
NOTE: message is not hashed since Ledger needs to display it on screen
and then internally hashes the json before signing it
*/
Expand Down
3 changes: 2 additions & 1 deletion app/src/renderer/vuex/modules/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export default () => {
default:
// local keyStore
state.localKeyPairName = localKeyPairName
accountAddress = (await state.externals.loadKeys()).find(({ name }) => name === localKeyPairName).address
accountAddress = (await state.externals.loadKeys())
.find(({ name }) => name === localKeyPairName).address
}
commit(`setSignIn`, true)
dispatch(`setErrorCollection`, {
Expand Down
Loading