Skip to content

Commit

Permalink
Fix linter errors automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Feb 1, 2022
1 parent 80f4df0 commit 9da40e3
Show file tree
Hide file tree
Showing 82 changed files with 292 additions and 321 deletions.
2 changes: 1 addition & 1 deletion src/components/AeAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
},
mode: {
type: String,
validator: value => ['full', 'three-columns', 'three-columns-short'].includes(value),
validator: (value) => ['full', 'three-columns', 'three-columns-short'].includes(value),
default: 'full',
},
disableCopyOnClick: Boolean,
Expand Down
4 changes: 2 additions & 2 deletions src/components/AeButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
props: {
fill: {
type: String,
validator: value => [
validator: (value) => [
'primary',
'secondary',
'alternative',
Expand All @@ -33,7 +33,7 @@ export default {
},
size: {
type: String,
validator: value => ['small', 'medium'].includes(value),
validator: (value) => ['small', 'medium'].includes(value),
default: 'medium',
},
plain: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/components/AeCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
props: {
fill: {
type: String,
validator: value => [
validator: (value) => [
'',
'primary',
'secondary',
Expand Down
16 changes: 7 additions & 9 deletions src/components/AeInputMnemonic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import AeTextarea from './AeTextarea.vue';
export default {
components: {
AeTextareaFormatted: withFormatting(
AeTextarea, {
formatDisplayValue: value => value
.toLowerCase()
.replace(/\s+/g, ' ')
.replace(/[^a-z ]/g, ''),
formatEmitValue: mnemonic => mnemonic.trim(),
},
),
AeTextareaFormatted: withFormatting(AeTextarea, {
formatDisplayValue: (value) => value
.toLowerCase()
.replace(/\s+/g, ' ')
.replace(/[^a-z ]/g, ''),
formatEmitValue: (mnemonic) => mnemonic.trim(),
}),
},
props: {
value: { type: String, required: true },
Expand Down
2 changes: 1 addition & 1 deletion src/components/AeInputRange.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
value: { type: [String, Number], default: '' },
fill: {
type: String,
validator: value => [
validator: (value) => [
'primary',
'light',
].includes(value),
Expand Down
2 changes: 1 addition & 1 deletion src/components/AeToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
props: {
fill: {
type: String,
validator: value => [
validator: (value) => [
'',
'primary',
'secondary',
Expand Down
6 changes: 3 additions & 3 deletions src/components/Guide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
const renderNodeContent = (createElement, node, slots) => (!node.childNodes.length
? node.textContent
: Array.from(node.childNodes)
.filter(n => [Node.ELEMENT_NODE, Node.TEXT_NODE].includes(n.nodeType))
.filter((n) => [Node.ELEMENT_NODE, Node.TEXT_NODE].includes(n.nodeType))
.map((n) => {
switch (n.tagName) {
case 'primary':
Expand Down Expand Up @@ -69,7 +69,7 @@ export default {
props: {
fill: {
type: String,
validator: value => [
validator: (value) => [
'primary',
'alternative',
'neutral',
Expand All @@ -78,7 +78,7 @@ export default {
},
size: {
type: String,
validator: value => ['small', 'medium', 'big'].includes(value),
validator: (value) => ['small', 'medium', 'big'].includes(value),
default: 'medium',
},
template: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ListItemAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
.$watchAsObservable(() => this.balance && this.subtitle === 'balance', { immediate: true })
.pipe(
pluck('newValue'),
switchMap(shouldSubscribe => (shouldSubscribe
switchMap((shouldSubscribe) => (shouldSubscribe
? this.$store.state.observables.convertAmount(() => this.balance)
: Promise.resolve(''))),
),
Expand Down
6 changes: 3 additions & 3 deletions src/components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
props: {
headerFill: {
type: String,
validator: value => [
validator: (value) => [
'primary',
'alternative',
'neutral',
Expand All @@ -60,7 +60,7 @@ export default {
},
fill: {
type: String,
validator: value => [
validator: (value) => [
'primary',
'alternative',
'neutral',
Expand All @@ -74,7 +74,7 @@ export default {
},
async mounted() {
if (process.env.IS_CORDOVA && process.env.IS_IOS) {
await new Promise(resolve => document.addEventListener('deviceready', resolve));
await new Promise((resolve) => document.addEventListener('deviceready', resolve));
this.$watch(({ headerFill, fill }) => headerFill || fill, (fill) => {
const style = ['primary', 'alternative', 'dark']
.includes(fill) ? 'LightContent' : 'Default';
Expand Down
4 changes: 2 additions & 2 deletions src/components/PageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
const buttonColorType = {
type: String,
validator: value => ['primary', ''].includes(value),
validator: (value) => ['primary', ''].includes(value),
default: '',
};
Expand All @@ -57,7 +57,7 @@ export default {
rightButtonColor: buttonColorType,
fill: {
type: String,
validator: value => [
validator: (value) => [
'primary',
'secondary',
'alternative',
Expand Down
52 changes: 25 additions & 27 deletions src/components/__tests__/AeInputAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const store = new Vuex.Store({
},
},
});
const mountComponent = options => mount(AeInputAccount, { localVue, store, ...options });
const mountComponent = (options) => mount(AeInputAccount, { localVue, store, ...options });
const testAddress = 'ak_12345678912345678912345678912345678912345678912345';
const testAddressFormatted = 'ak_ 123 456 789 123 456 789 123 456 789 123 456 789 123 456 789 123 45';
const testAddress51 = 'ak_xXRgaNBuFudv8QHVX52BYmfFyBEZDSWrdMWt2PNk8Mo2ZgHQ';
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('AeInputAccount', () => {
displayed: '',
emmited: '',
},
}].forEach(test => it(test.name, () => {
}].forEach((test) => it(test.name, () => {
const inputListener = jest.fn();
const wrapper = mountComponent({
listeners: { input: inputListener },
Expand All @@ -166,30 +166,28 @@ describe('AeInputAccount', () => {
{ name: 'ak_12', backspace: true },
{ name: testName, backspace: true },
{ name: testName, backspace: false },
].forEach(({ name, backspace }) => it(
`removes ${name} value with ${backspace ? 'backspace' : 'delete'} button`, () => {
const inputListener = jest.fn();
const wrapper = mountComponent({
propsData: { value: name },
listeners: { input: inputListener },
});
].forEach(({ name, backspace }) => it(`removes ${name} value with ${backspace ? 'backspace' : 'delete'} button`, () => {
const inputListener = jest.fn();
const wrapper = mountComponent({
propsData: { value: name },
listeners: { input: inputListener },
});

const textarea = wrapper.find('textarea');
const cursor = backspace ? textarea.element.value.length : 0;
textarea.element.setSelectionRange(cursor, cursor);
let n = 0;
while (textarea.element.value) {
const { value } = textarea.element;
if (backspace) {
const c = textarea.element.selectionStart - 1;
textarea.element.value = value.slice(0, c) + value.slice(c + 1);
textarea.element.setSelectionRange(c, c);
} else textarea.element.value = value.slice(1);
textarea.trigger('input');
wrapper.setProps({ value: inputListener.mock.calls.pop()[0] });
expect(textarea.element.value.length).toBeLessThanOrEqual(value.length);
expect(n += 1).toBeLessThan(15);
}
},
));
const textarea = wrapper.find('textarea');
const cursor = backspace ? textarea.element.value.length : 0;
textarea.element.setSelectionRange(cursor, cursor);
let n = 0;
while (textarea.element.value) {
const { value } = textarea.element;
if (backspace) {
const c = textarea.element.selectionStart - 1;
textarea.element.value = value.slice(0, c) + value.slice(c + 1);
textarea.element.setSelectionRange(c, c);
} else textarea.element.value = value.slice(1);
textarea.trigger('input');
wrapper.setProps({ value: inputListener.mock.calls.pop()[0] });
expect(textarea.element.value.length).toBeLessThanOrEqual(value.length);
expect(n += 1).toBeLessThan(15);
}
}));
});
2 changes: 1 addition & 1 deletion src/components/desktop/AccountTypeMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
props: {
accountType: {
type: String,
validator: value => ['hd-wallet-desktop', 'hd-wallet', 'ledger'].includes(value),
validator: (value) => ['hd-wallet-desktop', 'hd-wallet', 'ledger'].includes(value),
default: 'local',
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/desktop/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
.$watchAsObservable(() => this.account, { immediate: true })
.pipe(
pluck('newValue'),
switchMap(shouldSubscribe => (shouldSubscribe
switchMap((shouldSubscribe) => (shouldSubscribe
? this.$store.state.observables.convertAmount(() => this.account.balance)
: Promise.resolve(''))),
),
Expand Down
2 changes: 1 addition & 1 deletion src/components/desktop/LedgerModalNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
props: {
fill: {
type: String,
validator: value => [
validator: (value) => [
'neutral',
'dark',
].includes(value),
Expand Down
2 changes: 1 addition & 1 deletion src/components/desktop/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
}),
currentTab() {
return (this.accountTypes.includes('hd-wallet-desktop') && this.selectedTab === 'hd-wallet-desktop')
|| (this.accountTypes.some(type => !['hd-wallet-desktop', 'ledger'].includes(type)) && this.selectedTab === 'hd-wallet')
|| (this.accountTypes.some((type) => !['hd-wallet-desktop', 'ledger'].includes(type)) && this.selectedTab === 'hd-wallet')
|| (this.accountTypes.includes('ledger') && this.selectedTab === 'ledger')
? 'account-switcher' : {
'hd-wallet-desktop': 'create-or-recover',
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/AccountSwitcherModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
...mapState('accounts', ['activeIdx']),
...mapState('names', {
accountsWithNamePending(state, { get, isPending }) {
return this.accounts.map(account => ({
return this.accounts.map((account) => ({
...account,
namePending: isPending(get(account.address)),
}));
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/ConfirmTransactionSignModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default {
},
computed: {
...mapState({
stepFraction: state => (process.env.IS_MOBILE_DEVICE ? state.mobile.stepFraction : null),
stepFraction: (state) => (process.env.IS_MOBILE_DEVICE ? state.mobile.stepFraction : null),
}),
txType() {
return SCHEMA.OBJECT_ID_TX_TYPE[this.transaction.tag];
Expand Down
4 changes: 2 additions & 2 deletions src/components/mobile/DetailsFeeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import DetailsRow from './DetailsRow.vue';
import AeInputRange from '../AeInputRange.vue';
import { MAGNITUDE_MICRO } from '../../lib/constants';
const toMicroString = value => value.shiftedBy(-MAGNITUDE_MICRO).toFixed();
const toBigNumber = value => BigNumber(value).shiftedBy(MAGNITUDE_MICRO);
const toMicroString = (value) => value.shiftedBy(-MAGNITUDE_MICRO).toFixed();
const toBigNumber = (value) => BigNumber(value).shiftedBy(MAGNITUDE_MICRO);
export default {
components: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/ListItemAuction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {
switchMap(({ subtitleWinningBid, winningBid, expiration }) => (subtitleWinningBid
? convertAmount(() => BigNumber(winningBid).shiftedBy(-MAGNITUDE))
: topBlockHeight.pipe(
map(value => `${this.$t('name.expiration')} ${blocksToRelativeTime(expiration - value)}`),
map((value) => `${this.$t('name.expiration')} ${blocksToRelativeTime(expiration - value)}`),
))),
),
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/ListItemBid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
.$watchAsObservable(({ nameFee }) => nameFee, { immediate: true })
.pipe(
pluck('newValue'),
switchMap(nameFee => this.$store.state.observables.convertAmount(() => nameFee)),
switchMap((nameFee) => this.$store.state.observables.convertAmount(() => nameFee)),
),
};
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/TooltipsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {
const padding = 5;
this.anchorRects = this.tooltips
.map(({ selector }) => document.querySelector(selector).getBoundingClientRect())
.map(rect => new DOMRect(
.map((rect) => new DOMRect(
rect.left - padding,
rect.top - padding,
rect.width + padding * 2,
Expand Down
2 changes: 1 addition & 1 deletion src/components/mobile/VaultSignModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default {
reject: { type: Function, required: true },
},
computed: mapState({
stepFraction: state => state.mobile.stepFraction,
stepFraction: (state) => state.mobile.stepFraction,
}),
methods: {
closeHandler() {
Expand Down
2 changes: 1 addition & 1 deletion src/directives/removeSpacesOnCopy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
inserted: el => el.addEventListener('copy', (event) => {
inserted: (el) => el.addEventListener('copy', (event) => {
event.clipboardData.setData(
'text/plain',
getSelection().toString().replace(/\s/g, ''),
Expand Down
2 changes: 1 addition & 1 deletion src/filters/currencyAmount.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const toFiatFixedValue = v => (v.e < -2 ? '0.01' : v.toFixed(2));
const toFiatFixedValue = (v) => (v.e < -2 ? '0.01' : v.toFixed(2));

export default (value, { symbol, isCrypto = true }) => {
let v;
Expand Down
6 changes: 3 additions & 3 deletions src/filters/prefixedAmount.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const prefixes = [
{ name: 'Pico', magnitude: MAGNITUDE_PICO },
];

const getNearestPrefix = exponent => prefixes.reduce((p, n) => (
const getNearestPrefix = (exponent) => prefixes.reduce((p, n) => (
Math.abs(n.magnitude - exponent) < Math.abs(p.magnitude - exponent) ? n : p));

const getLowerBoundPrefix = exponent => prefixes
.find(p => p.magnitude <= exponent) || prefixes[prefixes.length - 1];
const getLowerBoundPrefix = (exponent) => prefixes
.find((p) => p.magnitude <= exponent) || prefixes[prefixes.length - 1];

export default (value) => {
const { name, magnitude } = (value.e < 0 ? getNearestPrefix : getLowerBoundPrefix)(value.e);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/__tests__/aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (window.crypto && window.crypto.subtle) {
throw new Error('This tests should be rewritten using provided Web Crypto API');
}

const getTestArray = length => Buffer.alloc(length).map((_, idx) => idx);
const getTestArray = (length) => Buffer.alloc(length).map((_, idx) => idx);

const testKey = getTestArray(16);
const testData = getTestArray(24);
Expand All @@ -19,7 +19,7 @@ const unMockCryptMethod = () => {
delete window.crypto;
};

const genCryptTest = methodName => () => {
const genCryptTest = (methodName) => () => {
mockCryptMethod(methodName);
const aes = new AES(testKey);
expect(aes[methodName](testData)).resolves.toBe(testResult);
Expand All @@ -31,7 +31,7 @@ const genCryptTest = methodName => () => {
unMockCryptMethod();
};

const genCryptCounterTest = methodName => async () => {
const genCryptCounterTest = (methodName) => async () => {
mockCryptMethod(methodName);
const aes = new AES(testKey);
await aes[methodName](testData);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/localStorageCall.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const KEY = 'local-storage-call';

export const send = data => localStorage.setItem(KEY, data);
export const send = (data) => localStorage.setItem(KEY, data);

export const receive = () => new Promise((resolve) => {
const storageHandler = ({ key }) => {
Expand Down
Loading

0 comments on commit 9da40e3

Please sign in to comment.