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 all 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 }]
}
}
3 changes: 3 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
### 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
5 changes: 3 additions & 2 deletions app/src/renderer/components/common/ActionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@
</div>

<div v-else-if="step === `sign`" class="action-modal-form">
<hardware-state icon="usb" :loading="sending ? true : false">
<hardware-state icon="usb" :loading="!!sending">
{{
sending
? `Please verify and sign the transaction on your Ledger`
: `Please plug in your Ledger&nbsp;Nano&nbsp;S and open the Cosmos app`
: `Please plug in your Ledger&nbsp;Nano&nbsp;S and open
the Cosmos app`
}}
</hardware-state>
</div>
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,9 @@
</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
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
Redelegation&nbsp;
<b>
{{
calculatePrettifiedTokens(tx.validator_src_address, tx.shares_amount)
calculatePrettifiedTokens(
tx.validator_src_address,
tx.shares_amount
)
}}
</b>
<span>&nbsp;{{ bondingDenom }}s</span>
Expand Down
13 changes: 10 additions & 3 deletions app/src/renderer/scripts/num.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import BigNumber from "bignumber.js"

const language = window.navigator.userLanguage || window.navigator.language
function full(number = 0) {
return new Intl.NumberFormat(language, { minimumFractionDigits: 7 }).format(number)
return new Intl.NumberFormat(language, { minimumFractionDigits: 7 })
.format(number)
}
function shortNumber(number = 0) {
return new Intl.NumberFormat(language, { minimumFractionDigits: 4 }).format(number) + `…`
}
function pretty(number = 0) {
return new Intl.NumberFormat(language, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(Math.round(number * 100) / 100)
return new Intl.NumberFormat(
language,
{ minimumFractionDigits: 2, maximumFractionDigits: 2 }
).format(Math.round(number * 100) / 100)
}
function prettyInt(number = 0) {
return new Intl.NumberFormat(language).format(Math.round(number))
Expand All @@ -23,7 +27,10 @@ function percentInt(number = 0) {
return new Intl.NumberFormat(language).format(Math.round(number * 100)) + `%`
}
function percent(number = 0) {
return new Intl.NumberFormat(language, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(Math.round(number * 10000) / 100) + `%`
return new Intl.NumberFormat(
language,
{ minimumFractionDigits: 2, maximumFractionDigits: 2 }
).format(Math.round(number * 10000) / 100) + `%`
}
function atoms(number = 0) {
return BigNumber(number).div(10e6).toNumber()
Expand Down
6 changes: 4 additions & 2 deletions app/src/renderer/scripts/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
const getUnbondingTime = ({ height, tx }, unbondingDelegations) => {
const { type, value } = tx.value && tx.value.msg && tx.value.msg[0]
if (type === `cosmos-sdk/MsgUndelegate`) {
const validatorUnbondingDelegation = unbondingDelegations[value.validator_address]
const unbondingDelegation = validatorUnbondingDelegation.find(({ creation_height }) => creation_height === String(height))
const validatorUnbondingDelegation =
unbondingDelegations[value.validator_address]
const unbondingDelegation = validatorUnbondingDelegation
.find(({ creation_height }) => creation_height === String(height))
if (
unbondingDelegation
) {
Expand Down
4 changes: 3 additions & 1 deletion app/src/renderer/vuex/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export const oldUnbondingAtoms = state => {
return Object.values(state.delegation.unbondingDelegations).reduce(
// unbondingDelegations can have several active undelegations per validator (key)
(atoms, entries) => {
return BN(atoms).plus(entries.reduce((sum, { balance }) => sum.plus(balance), BN(0)))
return BN(atoms).plus(
entries.reduce((sum, { balance }) => sum.plus(balance), BN(0))
)
},
BN(0)
)
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
Loading