From e562479eaa7f0dba831dc75e6dc56f1c9814ad4a Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 19:52:52 +0100 Subject: [PATCH 01/45] [DDW-595] Fix lint warnings Adding fixes for es linter --- features/support/electron.js | 8 +++-- features/support/helpers/app-helpers.js | 2 +- .../support/helpers/cardano-node-helpers.js | 2 +- features/support/helpers/i18n-helpers.js | 2 +- features/support/helpers/screenshot.js | 1 + features/support/helpers/shared-helpers.js | 4 +-- features/support/helpers/wallets-helpers.js | 2 +- flow/mappers/CSSModule.js.flow | 2 +- scripts/package.js | 4 ++- source/common/ipc/lib/IpcChannel.js | 6 ++-- source/main/cardano/CardanoNode.js | 34 ++++++++----------- source/main/cardano/config.js | 2 +- source/main/cardano/setupCardanoNodeMode.js | 2 +- source/main/cardano/setupFrontendOnlyMode.js | 6 ++-- source/main/config.js | 2 +- source/main/utils/config.js | 1 + source/renderer/app/api/utils/apiHelpers.js | 2 ++ .../settings/ChangeSpendingPasswordDialog.js | 8 +++-- source/renderer/app/stores/WalletsStore.js | 1 + storybook/stories/Sidebar.stories.js | 4 ++- storybook/stories/WalletScreens.stories.js | 1 + storybook/stories/Widgets.stories.js | 4 ++- storybook/stories/support/StoryLayout.js | 4 ++- storybook/stories/support/StoryProvider.js | 4 ++- 24 files changed, 63 insertions(+), 45 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index 95fc91ea20..e8e204aec2 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -22,8 +22,11 @@ let scenariosCount = 0; const printMainProcessLogs = () => context.app.client.getMainProcessLogs().then(logs => { + // eslint-disable-next-line console.log('========= DAEDALUS LOGS ========='); + // eslint-disable-next-line logs.forEach(log => console.log(log)); + // eslint-disable-next-line console.log('================================='); return true; }); @@ -123,17 +126,18 @@ After(async function({ sourceLocation, result }) { }); // eslint-disable-next-line prefer-arrow-callback -AfterAll(async function() { +AfterAll(async () => { const allWindowsClosed = (await context.app.client.getWindowCount()) === 0; if (allWindowsClosed || !context.app.running) return; if (scenariosCount === 0) { await printMainProcessLogs(); } if (process.env.KEEP_APP_AFTER_TESTS === 'true') { + // eslint-disable-next-line console.log( 'Keeping the app running since KEEP_APP_AFTER_TESTS env var is true' ); return; } - return context.app.stop(); + await context.app.stop(); }); diff --git a/features/support/helpers/app-helpers.js b/features/support/helpers/app-helpers.js index 20a35e13a8..1d296d0c85 100644 --- a/features/support/helpers/app-helpers.js +++ b/features/support/helpers/app-helpers.js @@ -8,7 +8,7 @@ export const waitForDaedalusToExit = async ( ) => { const daedalusProcessName = process.platform === 'linux' ? 'electron' : 'Electron'; - return await client.waitUntil( + return client.waitUntil( async () => (await getProcessesByName(daedalusProcessName)).length === 0, timeout ); diff --git a/features/support/helpers/cardano-node-helpers.js b/features/support/helpers/cardano-node-helpers.js index 1dcf045dca..b07a93c950 100644 --- a/features/support/helpers/cardano-node-helpers.js +++ b/features/support/helpers/cardano-node-helpers.js @@ -9,7 +9,7 @@ export const getCardanoNodeState = async (client: WebdriverClient) => .value; export const waitForCardanoNodeToExit = async (client: WebdriverClient) => - await client.waitUntil( + client.waitUntil( async () => (await getProcessesByName('cardano-node')).length === 0, 61000 ); diff --git a/features/support/helpers/i18n-helpers.js b/features/support/helpers/i18n-helpers.js index 75b9857239..d331cf4e17 100644 --- a/features/support/helpers/i18n-helpers.js +++ b/features/support/helpers/i18n-helpers.js @@ -21,7 +21,7 @@ export default { return translation.value; }, setActiveLanguage: async (client, { language } = {}) => - await client.execute(locale => { + client.execute(locale => { daedalus.actions.profile.updateLocale.trigger({ locale }); }, language || DEFAULT_LANGUAGE), }; diff --git a/features/support/helpers/screenshot.js b/features/support/helpers/screenshot.js index e458771906..94e3a40937 100644 --- a/features/support/helpers/screenshot.js +++ b/features/support/helpers/screenshot.js @@ -18,6 +18,7 @@ export const saveScreenshot = async (context, file) => { .capturePage() .then(imageBuffer => fs.writeFile(file, imageBuffer)) .catch(err => { + // eslint-disable-next-line console.log(err); }); }; diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index abda367b45..5e4813b619 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - await client.waitUntil(async () => { + client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return await client.elements(selectSelector); + return client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index 57e8465d2e..ab9df8a927 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - await client.executeAsync( + client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/flow/mappers/CSSModule.js.flow b/flow/mappers/CSSModule.js.flow index 3daeb8989d..023d00a59e 100644 --- a/flow/mappers/CSSModule.js.flow +++ b/flow/mappers/CSSModule.js.flow @@ -1,2 +1,2 @@ // @flow -declare export default { [key: string]: string } +declare export default { [key]: string } diff --git a/scripts/package.js b/scripts/package.js index 429cc1b497..74bae12e1d 100755 --- a/scripts/package.js +++ b/scripts/package.js @@ -59,6 +59,7 @@ if (version) { /** @desc Build, clear previous releases and pack new versions */ async function startPack() { + // eslint-disable-next-line console.log('start pack...'); try { @@ -126,8 +127,9 @@ function pack(plat, arch, cb) { * @return {Function} */ function log(plat, arch) { - return (err, filepath) => { + return (err) => { if (err) return console.error(err); + // eslint-disable-next-line console.log(`${plat}-${arch} finished!`); }; } diff --git a/source/common/ipc/lib/IpcChannel.js b/source/common/ipc/lib/IpcChannel.js index e1bfe9bca1..73c1b18bed 100644 --- a/source/common/ipc/lib/IpcChannel.js +++ b/source/common/ipc/lib/IpcChannel.js @@ -60,9 +60,9 @@ export class IpcChannel { if (existingChannel) return existingChannel; IpcChannel._instances[channelName] = this; - this._broadcastChannel = channelName + '-broadcast'; - this._requestChannel = channelName + '-request'; - this._responseChannel = channelName + '-response'; + this._broadcastChannel = `${channelName}-broadcast`; + this._requestChannel = `${channelName}-request`; + this._responseChannel = `${channelName}-response`; } /** diff --git a/source/main/cardano/CardanoNode.js b/source/main/cardano/CardanoNode.js index 88477d54a4..9a06b51236 100644 --- a/source/main/cardano/CardanoNode.js +++ b/source/main/cardano/CardanoNode.js @@ -225,10 +225,10 @@ export class CardanoNode { const nodeCanBeStarted = await this._canBeStarted(); if (!nodeCanBeStarted) { - return Promise.reject('CardanoNode: Cannot be started'); + return Promise.reject(new Error('CardanoNode: Cannot be started')); } if (this._isUnrecoverable(config) && !isForced) { - return Promise.reject('CardanoNode: Too many startup retries'); + return Promise.reject(new Error('CardanoNode: Too many startup retries')); } // Setup const { _log } = this; @@ -272,7 +272,9 @@ export class CardanoNode { ); resolve(); } catch (_) { - reject('CardanoNode#start: Error while spawning cardano-node'); + reject( + new Error('CardanoNode#start: Error while spawning cardano-node') + ); } }); }); @@ -336,7 +338,7 @@ export class CardanoNode { _log.info('CardanoNode#kill: could not kill cardano-node'); await this._storeProcessStates(); this._reset(); - reject('Could not kill cardano-node.'); + reject(new Error('Could not kill cardano-node.')); } }); } @@ -422,7 +424,7 @@ export class CardanoNode { }); } catch (error) { return Promise.reject( - `cardano-node did not inject the fault "${fault}" correctly.` + new Error(`cardano-node did not inject the fault "${fault}" correctly.`) ); } }; @@ -480,9 +482,9 @@ export class CardanoNode { const { _actions } = this; const { tlsPath } = this._config; this._tlsConfig = { - ca: _actions.readFileSync(tlsPath + '/client/ca.crt'), - key: _actions.readFileSync(tlsPath + '/client/client.key'), - cert: _actions.readFileSync(tlsPath + '/client/client.pem'), + ca: _actions.readFileSync(`${tlsPath}/client/ca.crt`), + key: _actions.readFileSync(`${tlsPath}/client/client.key`), + cert: _actions.readFileSync(`${tlsPath}/client/client.pem`), hostname: 'localhost', port, }; @@ -603,7 +605,7 @@ export class CardanoNode { * @returns {boolean} */ _isDead = async (): Promise => - !this._isConnected() && (await this._isNodeProcessNotRunningAnymore()); + !this._isConnected() && this._isNodeProcessNotRunningAnymore(); /** * Checks if current cardano-node child_process is "awake" (created, connected, stateful) @@ -661,10 +663,7 @@ export class CardanoNode { if (_node == null) { return Promise.resolve(); } - return await this._ensureProcessIsNotRunning( - _node.pid, - CARDANO_PROCESS_NAME - ); + return this._ensureProcessIsNotRunning(_node.pid, CARDANO_PROCESS_NAME); }; _ensurePreviousCardanoNodeIsNotRunning = async (): Promise => { @@ -677,10 +676,7 @@ export class CardanoNode { if (previousPID == null) { return Promise.resolve(); } - return await this._ensureProcessIsNotRunning( - previousPID, - CARDANO_PROCESS_NAME - ); + return this._ensureProcessIsNotRunning(previousPID, CARDANO_PROCESS_NAME); }; _isProcessRunning = async ( @@ -793,13 +789,13 @@ export class CardanoNode { _isNodeProcessStillRunning = async (): Promise => this._node != null && - (await this._isProcessRunning(this._node.pid, CARDANO_PROCESS_NAME)); + this._isProcessRunning(this._node.pid, CARDANO_PROCESS_NAME); _isNodeProcessNotRunningAnymore = async () => (await this._isNodeProcessStillRunning()) === false; _waitForNodeProcessToExit = async (timeout: number) => - await promisedCondition(this._isNodeProcessNotRunningAnymore, timeout); + promisedCondition(this._isNodeProcessNotRunningAnymore, timeout); _waitForCardanoToExitOrKillIt = async () => { const { _config } = this; diff --git a/source/main/cardano/config.js b/source/main/cardano/config.js index c3cc254a73..020637ec45 100644 --- a/source/main/cardano/config.js +++ b/source/main/cardano/config.js @@ -5,7 +5,7 @@ const isDev = process.env.NODE_ENV === 'development'; export const ensureXDGDataIsSet = () => { if (process.env.HOME && process.env.XDG_DATA_HOME === undefined) { - process.env.XDG_DATA_HOME = process.env.HOME + '/.local/share/'; + process.env.XDG_DATA_HOME = `${process.env.HOME}/.local/share/`; } }; diff --git a/source/main/cardano/setupCardanoNodeMode.js b/source/main/cardano/setupCardanoNodeMode.js index dac54ed1c4..0c4cc89dc2 100644 --- a/source/main/cardano/setupCardanoNodeMode.js +++ b/source/main/cardano/setupCardanoNodeMode.js @@ -32,7 +32,7 @@ import { safeExitWithCode } from '../utils/safeExitWithCode'; const startCardanoNode = (node: CardanoNode, launcherConfig: Object) => { const { nodePath, tlsPath, logsPrefix } = launcherConfig; const nodeArgs = prepareArgs(launcherConfig); - const logFilePath = logsPrefix + '/cardano-node.log'; + const logFilePath = `${logsPrefix}/cardano-node.log`; const config = { nodePath, logFilePath, diff --git a/source/main/cardano/setupFrontendOnlyMode.js b/source/main/cardano/setupFrontendOnlyMode.js index 88fe880f08..0cdb6d2eee 100644 --- a/source/main/cardano/setupFrontendOnlyMode.js +++ b/source/main/cardano/setupFrontendOnlyMode.js @@ -26,9 +26,9 @@ export const setupFrontendOnlyMode = (mainWindow: BrowserWindow) => { const cardanoHost = CARDANO_HOST || 'localhost'; const cardanoPort = parseInt(CARDANO_PORT, 10) || 8090; const tlsConfig = { - ca: readFileSync(cardanoTlsPath + '/client/ca.crt'), - key: readFileSync(cardanoTlsPath + '/client/client.key'), - cert: readFileSync(cardanoTlsPath + '/client/client.pem'), + ca: readFileSync(`${cardanoTlsPath}/client/ca.crt`), + key: readFileSync(`${cardanoTlsPath}/client/client.key`), + cert: readFileSync(`${cardanoTlsPath}/client/client.pem`), hostname: cardanoHost, port: cardanoPort, }; diff --git a/source/main/config.js b/source/main/config.js index bf31c895f1..3d8ab31b00 100644 --- a/source/main/config.js +++ b/source/main/config.js @@ -59,7 +59,7 @@ export const launcherConfig: LauncherConfig = readLauncherConfig( export const appLogsFolderPath = launcherConfig.logsPrefix; export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub'); export const appFolderPath = launcherConfig.workingDir; -export const nodeDbPath = launcherConfig.nodeDbPath; +export const { nodeDbPath } = launcherConfig; export const ALLOWED_LOGS = ['Daedalus.json', 'System-info.json']; export const ALLOWED_NODE_LOGS = new RegExp(/(node.json-)(\d{14}$)/); export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/); diff --git a/source/main/utils/config.js b/source/main/utils/config.js index 7d25ea503b..2126418668 100644 --- a/source/main/utils/config.js +++ b/source/main/utils/config.js @@ -14,6 +14,7 @@ export const readLauncherConfig = (configPath: ?string): LauncherConfig => { if (process.env[b]) { return process.env[b]; } + // eslint-disable-next-line console.log('readLauncherConfig: warning var undefined:', b); return ''; }); diff --git a/source/renderer/app/api/utils/apiHelpers.js b/source/renderer/app/api/utils/apiHelpers.js index 3fd593a9f2..3626d6999c 100644 --- a/source/renderer/app/api/utils/apiHelpers.js +++ b/source/renderer/app/api/utils/apiHelpers.js @@ -9,6 +9,7 @@ export const notYetImplemented = async () => // helper code for testing async APIs export const testAsync = async (apiMethod: Function) => { const result = await apiMethod(); + // eslint-disable-next-line console.log(`testAsync result: ${result}`); return result; }; @@ -16,6 +17,7 @@ export const testAsync = async (apiMethod: Function) => { // helper code for testing sync APIs export const testSync = (apiMethod: Function) => { const result = apiMethod(); + // eslint-disable-next-line console.log(`testSync result: ${result}`); return result; }; diff --git a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js index 704c1c96a9..85ea395cbf 100644 --- a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js +++ b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js @@ -232,6 +232,8 @@ export default class ChangeSpendingPasswordDialog extends Component< this.props.onDataChange({ [key]: value }); }; + submitOnEnter = submitOnEnter.bind(this, this.submit); + render() { const { form } = this; const { intl } = this.context; @@ -314,7 +316,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="currentPassword" label={currentPasswordField.label} value={currentPasswordValue} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={submitOnEnter} onChange={value => this.handleDataChange('currentPasswordValue', value) } @@ -331,7 +333,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className={newPasswordClasses} label={newPasswordField.label} value={newPasswordValue} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={submitOnEnter} onChange={value => this.handleDataChange('newPasswordValue', value)} {...newPasswordField.bind()} error={newPasswordField.error} @@ -343,7 +345,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="repeatedPassword" label={repeatedPasswordField.label} value={repeatedPasswordValue} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={submitOnEnter} onChange={value => this.handleDataChange('repeatedPasswordValue', value) } diff --git a/source/renderer/app/stores/WalletsStore.js b/source/renderer/app/stores/WalletsStore.js index 09ed5c61e2..7303940ba9 100644 --- a/source/renderer/app/stores/WalletsStore.js +++ b/source/renderer/app/stores/WalletsStore.js @@ -607,6 +607,7 @@ export default class WalletsStore extends Store { this._updateCertificateStep(); }); } catch (error) { + // eslint-disable-next-line console.log(error); runInAction('handle failed certificate download', () => { // Reset progress diff --git a/storybook/stories/Sidebar.stories.js b/storybook/stories/Sidebar.stories.js index 22a3d7d2d2..9044fee42a 100644 --- a/storybook/stories/Sidebar.stories.js +++ b/storybook/stories/Sidebar.stories.js @@ -32,7 +32,9 @@ const sidebarMenus = observable({ actions: { onAddWallet: action('toggleAddWallet'), onWalletItemClick: (walletId: string) => { - runInAction(() => (sidebarMenus.wallets.activeWalletId = walletId)); + runInAction(() => { + sidebarMenus.wallets.activeWalletId = walletId; + }); }, }, }, diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 0cfbe83660..59e6b84656 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,6 +188,7 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } + return false; }} isInvalid={false} isSubmitting={false} diff --git a/storybook/stories/Widgets.stories.js b/storybook/stories/Widgets.stories.js index a00b703a1a..8429c0b6b4 100644 --- a/storybook/stories/Widgets.stories.js +++ b/storybook/stories/Widgets.stories.js @@ -65,7 +65,9 @@ storiesOf('Widgets', module) (tokens[index] = token)} + onTokenChanged={(index, token) => { + tokens[index] = token; + }} /> ); }) diff --git a/storybook/stories/support/StoryLayout.js b/storybook/stories/support/StoryLayout.js index c62c0dfd90..7cb1e3a743 100644 --- a/storybook/stories/support/StoryLayout.js +++ b/storybook/stories/support/StoryLayout.js @@ -156,7 +156,9 @@ export default class StoryLayout extends Component { ) => ( { - runInAction(() => (this.isShowingSubMenus = !this.isShowingSubMenus)); + runInAction(() => { + this.isShowingSubMenus = !this.isShowingSubMenus; + }); }} formattedWalletAmount={formattedWalletAmount} currentRoute={`/wallets/${activeWallet.id}/${activeNavItem}`} diff --git a/storybook/stories/support/StoryProvider.js b/storybook/stories/support/StoryProvider.js index 7619d928ff..90d1d2c83b 100644 --- a/storybook/stories/support/StoryProvider.js +++ b/storybook/stories/support/StoryProvider.js @@ -61,7 +61,9 @@ export default class StoryProvider extends Component { } setActiveWalletId = (walletId: string) => - runInAction(() => (this.activeWalletId = walletId)); + runInAction(() => { + this.activeWalletId = walletId; + }); render() { return ( From 1c02c20137f5bb945fb967b97921a494be80133f Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 22:56:40 +0100 Subject: [PATCH 02/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/step_definitions/app-steps.js | 3 ++- features/step_definitions/cardano-steps.js | 2 +- features/step_definitions/settings-steps.js | 6 ++--- source/renderer/app/App.js | 2 +- .../renderer/app/stores/TransactionsStore.js | 26 +++++++++---------- source/renderer/app/stores/WalletsStore.js | 8 +++--- source/renderer/app/utils/crypto.js | 2 +- source/renderer/app/utils/logging.js | 2 +- source/renderer/app/utils/routing.js | 4 +-- source/renderer/app/utils/strings.js | 2 +- 10 files changed, 29 insertions(+), 28 deletions(-) diff --git a/features/step_definitions/app-steps.js b/features/step_definitions/app-steps.js index f64d7b84ef..fd227008dc 100644 --- a/features/step_definitions/app-steps.js +++ b/features/step_definitions/app-steps.js @@ -12,7 +12,8 @@ import { declare var daedalus: Daedalus; Given(/^Daedalus is running$/, function() { - expect(this.app.isRunning()).to.be.true; + const appIsRunning = this.app.isRunning(); + expect(appIsRunning).to.be.true(); }); When(/^I refresh the main window$/, async function() { diff --git a/features/step_definitions/cardano-steps.js b/features/step_definitions/cardano-steps.js index 55cb5d4dd6..b091a0e316 100644 --- a/features/step_definitions/cardano-steps.js +++ b/features/step_definitions/cardano-steps.js @@ -7,7 +7,7 @@ import { } from '../support/helpers/cardano-node-helpers'; Given(/^cardano-node is running$/, async function() { - return await this.client.waitUntil( + return this.client.waitUntil( async () => (await getCardanoNodeState(this.client)) === CardanoNodeStates.RUNNING ); diff --git a/features/step_definitions/settings-steps.js b/features/step_definitions/settings-steps.js index 00b115c7a7..c70c2626d0 100644 --- a/features/step_definitions/settings-steps.js +++ b/features/step_definitions/settings-steps.js @@ -14,12 +14,12 @@ Given(/^I am on the settings screen$/, async function() { Given(/^I should see the "([^"]*)" wallet password dialog$/, function( dialogType ) { - const selector = '.' + dialogType + 'PasswordDialog'; + const selector = `.${dialogType}PasswordDialog`; return this.client.waitForVisible(selector); }); When(/^I click on the "([^"]*)" password label$/, function(label) { - const selector = '.' + label + 'Label button'; + const selector = `.${label}Label button`; return this.client.click(selector); }); @@ -127,7 +127,7 @@ Then(/^I should see new wallet name "([^"]*)"$/, async function(walletName) { }); Then(/^I should see "([^"]*)" label in password field$/, function(label) { - const selector = '.' + label + 'Label'; + const selector = `.${label}Label`; return this.client.waitForVisible(selector); }); diff --git a/source/renderer/app/App.js b/source/renderer/app/App.js index c7be602bd1..4a5898a32e 100755 --- a/source/renderer/app/App.js +++ b/source/renderer/app/App.js @@ -31,7 +31,7 @@ export default class App extends Component<{ const { isAboutDialogOpen, isNetworkStatusDialogOpen } = app; const locale = stores.profile.currentLocale; const mobxDevTools = global.environment.mobxDevTools ? : null; - const currentTheme = stores.profile.currentTheme; + const { currentTheme } = stores.profile; const themeVars = require(`./themes/daedalus/${currentTheme}.js`).default; return ( diff --git a/source/renderer/app/stores/TransactionsStore.js b/source/renderer/app/stores/TransactionsStore.js index 8a9f6d7356..e514c3441f 100644 --- a/source/renderer/app/stores/TransactionsStore.js +++ b/source/renderer/app/stores/TransactionsStore.js @@ -92,36 +92,36 @@ export default class TransactionsStore extends Store { @computed get recent(): Array { const wallet = this.stores.wallets.active; if (!wallet) return []; - const result = this._getTransactionsRecentRequest(wallet.id).result; - return result ? result.transactions : []; + const results = this._getTransactionsRecentRequest(wallet.id).result; + return results ? results.transactions : []; } @computed get hasAnyFiltered(): boolean { const wallet = this.stores.wallets.active; if (!wallet) return false; - const result = this._getTransactionsAllRequest(wallet.id).result; - return result ? result.transactions.length > 0 : false; + const results = this._getTransactionsAllRequest(wallet.id).result; + return results ? results.transactions.length > 0 : false; } @computed get hasAny(): boolean { const wallet = this.stores.wallets.active; if (!wallet) return false; - const result = this._getTransactionsRecentRequest(wallet.id).result; - return result ? result.total > 0 : false; + const results = this._getTransactionsRecentRequest(wallet.id).result; + return results ? results.total > 0 : false; } @computed get totalAvailable(): number { const wallet = this.stores.wallets.active; if (!wallet) return 0; - const result = this._getTransactionsAllRequest(wallet.id).result; - return result ? result.total : 0; + const results = this._getTransactionsAllRequest(wallet.id).result; + return results ? results.total : 0; } @computed get totalFilteredAvailable(): number { const wallet = this.stores.wallets.active; if (!wallet) return 0; - const result = this._getTransactionsAllRequest(wallet.id).result; - return result ? result.transactions.length : 0; + const results = this._getTransactionsAllRequest(wallet.id).result; + return results ? results.transactions.length : 0; } @action _refreshTransactionData = async (restoredWalletId: ?string) => { @@ -248,12 +248,12 @@ export default class TransactionsStore extends Store { const wallet = this.stores.wallets.active; if (!wallet) return this._resetUnconfirmedAmount(); // Reset when no transactions - const result = this._getTransactionsAllRequest(wallet.id).result; - if (!result || !result.transactions) return this._resetUnconfirmedAmount(); + const results = this._getTransactionsAllRequest(wallet.id).result; + if (!results || !results.transactions) return this._resetUnconfirmedAmount(); // We have some results, lets compute and update const unconfirmedAmount = this._getEmptyUnconfirmedAmount(); - for (const transaction of result.transactions) { + for (const transaction of results.transactions) { if (transaction.numberOfConfirmations <= TX_UNCONFIRMED_THRESHOLD) { unconfirmedAmount.total = unconfirmedAmount.total.plus( transaction.amount.absoluteValue() diff --git a/source/renderer/app/stores/WalletsStore.js b/source/renderer/app/stores/WalletsStore.js index 7303940ba9..78c3c57f54 100644 --- a/source/renderer/app/stores/WalletsStore.js +++ b/source/renderer/app/stores/WalletsStore.js @@ -249,7 +249,7 @@ export default class WalletsStore extends Store { @computed get isWalletRoute(): boolean { const { currentRoute } = this.stores.app; - return matchRoute(ROUTES.WALLETS.ROOT + '(/*rest)', currentRoute); + return matchRoute(`${ROUTES.WALLETS.ROOT}(/*rest)`, currentRoute); } getWalletById = (id: string): ?Wallet => this.all.find(w => w.id === id); @@ -270,7 +270,7 @@ export default class WalletsStore extends Store { // =================== PRIVATE API ==================== // @computed get _canRedirectToWallet(): boolean { - const currentRoute = this.stores.app.currentRoute; + const { currentRoute } = this.stores.app; const isRootRoute = matchRoute(ROUTES.WALLETS.ROOT, currentRoute); const isAddWalletRoute = matchRoute(ROUTES.WALLETS.ADD, currentRoute); return isRootRoute || isAddWalletRoute; @@ -285,11 +285,11 @@ export default class WalletsStore extends Store { _pollRefresh = async () => { const { isSynced } = this.stores.networkStatus; - return isSynced && (await this.refreshWalletsData()); + return isSynced && this.refreshWalletsData(); }; _updateActiveWalletOnRouteChanges = () => { - const currentRoute = this.stores.app.currentRoute; + const { currentRoute } = this.stores.app; const hasAnyWalletLoaded = this.hasAnyLoaded; const isWalletAddPage = matchRoute(ROUTES.WALLETS.ADD, currentRoute); runInAction('WalletsStore::_updateActiveWalletOnRouteChanges', () => { diff --git a/source/renderer/app/utils/crypto.js b/source/renderer/app/utils/crypto.js index 70ba901e16..b05af3cc6c 100644 --- a/source/renderer/app/utils/crypto.js +++ b/source/renderer/app/utils/crypto.js @@ -71,7 +71,7 @@ export const unscramblePaperWalletMnemonic = ( export const mnemonicToSeedHex = (mnemonic: string, password: ?string) => { const mnemonicBuffer = Buffer.from(unorm.nfkd(mnemonic), 'utf8'); - const salt = 'mnemonic' + (unorm.nfkd(password) || ''); + const salt = `mnemonic${(unorm.nfkd(password) || '')}`; const saltBuffer = Buffer.from(salt, 'utf8'); return pbkdf2(mnemonicBuffer, saltBuffer, 2048, 32, 'sha512').toString('hex'); }; diff --git a/source/renderer/app/utils/logging.js b/source/renderer/app/utils/logging.js index c7615aa6ea..7c073ae329 100644 --- a/source/renderer/app/utils/logging.js +++ b/source/renderer/app/utils/logging.js @@ -3,7 +3,7 @@ import { formatContext } from '../../../common/utils/logging'; import type { FormatMessageContextParams } from '../../../common/types/logging.types'; const log = global.electronLog; -const environment = global.environment; +const { environment } = global; const appName = 'daedalus'; const electronProcess = 'ipcRenderer'; diff --git a/source/renderer/app/utils/routing.js b/source/renderer/app/utils/routing.js index 94299d29b4..2f95f62c95 100644 --- a/source/renderer/app/utils/routing.js +++ b/source/renderer/app/utils/routing.js @@ -67,7 +67,7 @@ export const buildRoute = (pattern, params) => { // - '/path/:param(/:another_param)' // - '/path(/:param/:another_param)' const paramRegex = new RegExp( - '(/|\\(|\\)|^):' + paramName + '(/|\\)|\\(|$)' + `(/|\\(|\\)|^):${paramName}(/|)|(|$)` ); routePath = routePath.replace(paramRegex, (match, g1, g2) => { tokens[paramName] = encodeURIComponent(paramValue); @@ -107,7 +107,7 @@ export const buildRoute = (pattern, params) => { export const getUrlParameterByName = (name, url) => { if (!url) url = window.location.href; name = name.replace(/[[\]]/g, '\\$&'); - const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'); + const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`); const results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; diff --git a/source/renderer/app/utils/strings.js b/source/renderer/app/utils/strings.js index c275459883..d59a561f80 100644 --- a/source/renderer/app/utils/strings.js +++ b/source/renderer/app/utils/strings.js @@ -13,5 +13,5 @@ export const ellipsis = ( minCharsEnd && shouldHaveEndStr() ? str.substr(str.length - minCharsEnd) : ''; - return initStr + '\u2026' + endStr; + return `${initStr}\u2026${endStr}`; }; From 362753a51019a7af972122ad60fd11ad6cd6d57e Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 23:10:55 +0100 Subject: [PATCH 03/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- .../app/components/wallet/WalletSendForm.js | 9 ++++++--- .../widgets/forms/MnemonicInputWidget.js | 2 +- source/renderer/app/index.js | 2 +- source/renderer/app/stores/AddressesStore.js | 18 +++++++++--------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index eff6e13f04..6db8bfeba1 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,6 +159,7 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); + return true; }; isDisabled = () => @@ -174,7 +175,7 @@ export default class WalletSendForm extends Component { value: '', validators: [ async ({ field, form }) => { - const value = field.value; + const { value } = field; if (value === '') { this._resetTransactionFee(); return [ @@ -243,6 +244,8 @@ export default class WalletSendForm extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit); + render() { const { form } = this; const { intl } = this.context; @@ -297,7 +300,7 @@ export default class WalletSendForm extends Component { receiverField.onChange(value || ''); }} skin={InputSkin} - onKeyPress={submitOnEnter.bind(this, this.handleOnSubmit)} + onKeyPress={submitOnEnter} /> @@ -318,7 +321,7 @@ export default class WalletSendForm extends Component { fees={fees} total={total} skin={AmountInputSkin} - onKeyPress={submitOnEnter.bind(this, this.handleOnSubmit)} + onKeyPress={submitOnEnter} /> diff --git a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js index a943b57dc4..833e105f9a 100644 --- a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js +++ b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js @@ -26,7 +26,7 @@ export default class MnemonicInputWidget extends Component { onTokenChanged(index, value)} diff --git a/source/renderer/app/index.js b/source/renderer/app/index.js index 58d08d1831..144bb27b3d 100755 --- a/source/renderer/app/index.js +++ b/source/renderer/app/index.js @@ -26,7 +26,7 @@ configure({ // https://github.com/yahoo/react-intl/wiki#loading-locale-data addLocaleData([...en, ...de, ...hr, ...ja]); -const environment = global.environment; +const { environment } = global; const { isTest, network } = environment; const initializeDaedalus = () => { diff --git a/source/renderer/app/stores/AddressesStore.js b/source/renderer/app/stores/AddressesStore.js index f72597e163..299c745f53 100644 --- a/source/renderer/app/stores/AddressesStore.js +++ b/source/renderer/app/stores/AddressesStore.js @@ -63,30 +63,30 @@ export default class AddressesStore extends Store { @computed get all(): Addresses { const wallet = this.stores.wallets.active; if (!wallet) return []; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses : []; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses : []; } @computed get hasAny(): boolean { const wallet = this.stores.wallets.active; if (!wallet) return false; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses.length > 0 : false; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses.length > 0 : false; } @computed get active(): ?Address { if (this.lastGeneratedAddress) return this.lastGeneratedAddress; const wallet = this.stores.wallets.active; - if (!wallet) return; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses[result.addresses.length - 1] : null; + if (!wallet) return null; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses[results.addresses.length - 1] : null; } @computed get totalAvailable(): number { const wallet = this.stores.wallets.active; if (!wallet) return 0; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses.length : 0; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses.length : 0; } @action _refreshAddresses = () => { From 9b6022132e4f9887845abfe679e82b672b2e5b43 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 14:05:04 +0100 Subject: [PATCH 04/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/main/cardano/CardanoNode.js | 10 ++++++++-- source/main/ipc/download-logs.js | 2 +- source/main/utils/setupLogging.js | 3 ++- source/renderer/app/api/utils/request.js | 2 +- source/renderer/app/api/utils/requestV0.js | 2 +- .../renderer/app/components/loading/Loading.js | 4 ++-- .../profile/terms-of-use/TermsOfUseForm.js | 2 +- .../renderer/app/components/sidebar/Sidebar.js | 4 ++-- .../app/components/staking/StakingChart.js | 6 +++--- .../app/components/wallet/WalletSendForm.js | 1 - .../wallet/ada-redemption/AdaRedemptionForm.js | 2 +- .../WalletRecoveryPhraseEntryDialog.js | 2 +- .../paper-wallet-certificate/PrintDialog.js | 6 +++--- .../SecuringPasswordDialog.js | 6 +++--- .../VerificationDialog.js | 12 ++++++------ .../app/components/wallet/receive/Address.js | 2 +- .../wallet/receive/VirtualAddressesList.js | 2 +- .../components/wallet/receive/WalletReceive.js | 2 +- .../wallet/transactions/Transaction.js | 8 ++++---- .../transactions/WalletTransactionsList.js | 4 ++-- .../render-strategies/SimpleTransactionList.js | 4 ++-- .../VirtualTransactionList.js | 11 ++++------- .../wallet/PaperWalletCreateCertificatePage.js | 2 +- .../app/containers/wallet/WalletReceivePage.js | 2 +- .../renderer/app/stores/AdaRedemptionStore.js | 18 +++++++++--------- .../renderer/app/stores/NetworkStatusStore.js | 6 +++--- source/renderer/app/stores/lib/Request.js | 2 +- storybook/stories/WalletScreens.stories.js | 1 - 31 files changed, 69 insertions(+), 67 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index e8e204aec2..c8a6bf7776 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - await context.app.stop(); + return context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index 5e4813b619..abda367b45 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - client.waitUntil(async () => { + await client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return client.elements(selectSelector); + return await client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index ab9df8a927..57e8465d2e 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - client.executeAsync( + await client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/main/cardano/CardanoNode.js b/source/main/cardano/CardanoNode.js index 9a06b51236..d94d9f2323 100644 --- a/source/main/cardano/CardanoNode.js +++ b/source/main/cardano/CardanoNode.js @@ -663,7 +663,10 @@ export class CardanoNode { if (_node == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(_node.pid, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + _node.pid, + CARDANO_PROCESS_NAME + ); }; _ensurePreviousCardanoNodeIsNotRunning = async (): Promise => { @@ -676,7 +679,10 @@ export class CardanoNode { if (previousPID == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(previousPID, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + previousPID, + CARDANO_PROCESS_NAME + ); }; _isProcessRunning = async ( diff --git a/source/main/ipc/download-logs.js b/source/main/ipc/download-logs.js index 9cc2dc539c..05d44bf491 100644 --- a/source/main/ipc/download-logs.js +++ b/source/main/ipc/download-logs.js @@ -17,7 +17,7 @@ export default () => { const { compressedLogsFilePath, destinationPath } = request; if (!fs.existsSync(compressedLogsFilePath)) { - return Promise.reject('File does not exist'); + return Promise.reject(new Error('File does not exist')); } const file = fs.readFileSync(compressedLogsFilePath); diff --git a/source/main/utils/setupLogging.js b/source/main/utils/setupLogging.js index 146353da5d..0aad4328d6 100644 --- a/source/main/utils/setupLogging.js +++ b/source/main/utils/setupLogging.js @@ -20,7 +20,7 @@ const isTest = process.env.NODE_ENV === 'test'; const isDev = process.env.NODE_ENV === 'development'; export const setupLogging = () => { - const logFilePath = path.join(pubLogsFolderPath, APP_NAME + '.json'); + const logFilePath = path.join(pubLogsFolderPath, `${APP_NAME}.json`); ensureDirectoryExists(pubLogsFolderPath); log.transports.console.level = isTest ? 'error' : 'info'; log.transports.rendererConsole.level = isDev ? 'info' : 'error'; @@ -60,6 +60,7 @@ export const setupLogging = () => { try { fs.unlinkSync(logFile); } catch (error) { + // eslint-disable-next-line console.error( `Compressed log file "${logFile}" deletion failed: ${error}` ); diff --git a/source/renderer/app/api/utils/request.js b/source/renderer/app/api/utils/request.js index 18ccfc236d..e4a4c190d7 100644 --- a/source/renderer/app/api/utils/request.js +++ b/source/renderer/app/api/utils/request.js @@ -72,7 +72,7 @@ function typedRequest( httpsRequest.on('response', response => { let body = ''; // Cardano-sl returns chunked requests, so we need to concat them - response.on('data', chunk => (body += chunk)); + response.on('data', chunk => {body += chunk}); // Reject errors response.on('error', error => reject(error)); // Resolve JSON results and handle backend errors diff --git a/source/renderer/app/api/utils/requestV0.js b/source/renderer/app/api/utils/requestV0.js index e7ba262645..85b390b68f 100644 --- a/source/renderer/app/api/utils/requestV0.js +++ b/source/renderer/app/api/utils/requestV0.js @@ -70,7 +70,7 @@ function typedRequest( httpsRequest.on('response', response => { let body = ''; // Cardano-sl returns chunked requests, so we need to concat them - response.on('data', chunk => (body += chunk)); + response.on('data', chunk => {body += chunk}); // Reject errors response.on('error', error => reject(error)); // Resolve JSON results and handle weird backend behavior diff --git a/source/renderer/app/components/loading/Loading.js b/source/renderer/app/components/loading/Loading.js index 84b7ba742d..bf38df5185 100644 --- a/source/renderer/app/components/loading/Loading.js +++ b/source/renderer/app/components/loading/Loading.js @@ -230,14 +230,14 @@ export default class Loading extends Component { }; _incrementConnectingTime = () => { - this.setState({ connectingTime: this.state.connectingTime + 1 }); + this.setState(prevState => ({connectingTime: prevState.connectingTime + 1})); }; _incrementSyncingTime = () => { const syncPercentage = this.props.syncPercentage.toFixed(2); if (syncPercentage === this.state.syncPercentage) { // syncPercentage not increased, increase syncing time - this.setState({ syncingTime: this.state.syncingTime + 1 }); + this.setState(prevState => ({syncingTime: prevState.syncingTime + 1})); } else { // reset syncingTime and set new max percentage this.setState({ syncingTime: 0, syncPercentage }); diff --git a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js index ecd3328b64..d5c35eb851 100644 --- a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js +++ b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js @@ -53,7 +53,7 @@ export default class TermsOfUseForm extends Component { }; toggleAcceptance() { - this.setState({ areTermsOfUseAccepted: !this.state.areTermsOfUseAccepted }); + this.setState(prevState => ({areTermsOfUseAccepted: !prevState.areTermsOfUseAccepted})); } submit = () => { diff --git a/source/renderer/app/components/sidebar/Sidebar.js b/source/renderer/app/components/sidebar/Sidebar.js index f28d541676..761decae5e 100644 --- a/source/renderer/app/components/sidebar/Sidebar.js +++ b/source/renderer/app/components/sidebar/Sidebar.js @@ -83,11 +83,11 @@ export default class Sidebar extends Component { return (
- {categories.map((category, index) => { + {categories.map((category) => { const categoryClassName = kebabCase(category.name); return ( { minPointSize={2} isAnimationActive={false} > - {data.slice().map((entry, index) => { + {data.slice().map((entry) => { let fillColor = '#c2cad4'; let cursor = 'pointer'; - if (index === activeIndex) fillColor = '#445b7c'; + if (entry.id === activeIndex) fillColor = '#445b7c'; if (entry.numberOfTransactions === 0) { fillColor = '#e7eaee'; cursor = 'default'; } return ( - + ); })} diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 6db8bfeba1..071110f57a 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,7 +159,6 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); - return true; }; isDisabled = () => diff --git a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js index 39cd2a3e9f..b1d5a8d739 100644 --- a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js +++ b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js @@ -301,7 +301,7 @@ export default class AdaRedemptionForm extends Component { validators: ({ field }) => { if (this.props.redemptionType !== ADA_REDEMPTION_TYPES.PAPER_VENDED) return [true]; - const value = field.value; + const { value } = field; if (value === '') return [ false, diff --git a/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js b/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js index 45ac8753cf..c7dd4d8675 100644 --- a/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js +++ b/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js @@ -148,7 +148,7 @@ export default class WalletRecoveryPhraseEntryDialog extends Component { return ( { } onConfirmCorrectPrinting = () => { - this.setState({ isPrintedCorrectly: !this.state.isPrintedCorrectly }); + this.setState(prevState => ({isPrintedCorrectly: !prevState.isPrintedCorrectly})); }; onConfirmReadable = () => { - this.setState({ isReadable: !this.state.isReadable }); + this.setState(prevState => ({isReadable: !prevState.isReadable})); }; onConfirmScannable = () => { - this.setState({ isScannable: !this.state.isScannable }); + this.setState(prevState => ({isScannable: !prevState.isScannable})); }; } diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js index b4dc2e894a..d9d336c92f 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js @@ -125,8 +125,8 @@ export default class SecuringPasswordDialog extends Component { } onSecurePasswordConfirmationChange = () => { - this.setState({ - securePasswordConfirmed: !this.state.securePasswordConfirmed, - }); + this.setState( + prevState => ({securePasswordConfirmed: !prevState.securePasswordConfirmed}) + ); }; } diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js index 36a75fad36..0f265c9c21 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js @@ -311,14 +311,14 @@ export default class VerificationDialog extends Component { } onStoringConfirmationChange = () => { - this.setState({ - storingConfirmed: !this.state.storingConfirmed, - }); + this.setState( + prevState => ({storingConfirmed: !prevState.storingConfirmed}) + ); }; onRecoveringConfirmationChange = () => { - this.setState({ - recoveringConfirmed: !this.state.recoveringConfirmed, - }); + this.setState( + prevState => ({recoveringConfirmed: !prevState.recoveringConfirmed}) + ); }; } diff --git a/source/renderer/app/components/wallet/receive/Address.js b/source/renderer/app/components/wallet/receive/Address.js index f2fc236df0..3e7a49d3e6 100644 --- a/source/renderer/app/components/wallet/receive/Address.js +++ b/source/renderer/app/components/wallet/receive/Address.js @@ -20,7 +20,7 @@ export class Address extends Component { render() { const { address, onCopyAddress, copyAddressLabel, index } = this.props; const addressClasses = classnames([ - 'generatedAddress-' + (index + 1), + `generatedAddress-${index + 1}`, styles.component, address.used ? styles.usedWalletAddress : null, ]); diff --git a/source/renderer/app/components/wallet/receive/VirtualAddressesList.js b/source/renderer/app/components/wallet/receive/VirtualAddressesList.js index 8de5d750ce..fd1a08f4b7 100644 --- a/source/renderer/app/components/wallet/receive/VirtualAddressesList.js +++ b/source/renderer/app/components/wallet/receive/VirtualAddressesList.js @@ -109,7 +109,7 @@ export class VirtualAddressesList extends Component { {({ width, height }) => ( (this.list = list)} + ref={list => {this.list = list}} width={width} height={height} rowCount={rows.length} diff --git a/source/renderer/app/components/wallet/receive/WalletReceive.js b/source/renderer/app/components/wallet/receive/WalletReceive.js index 95139b743e..52d24ed526 100644 --- a/source/renderer/app/components/wallet/receive/WalletReceive.js +++ b/source/renderer/app/components/wallet/receive/WalletReceive.js @@ -100,7 +100,7 @@ export default class WalletReceive extends Component { passwordField: Input; toggleUsedAddresses = () => { - this.setState({ showUsed: !this.state.showUsed }); + this.setState(prevState => ({showUsed: !prevState.showUsed})); }; form = new ReactToolboxMobxForm( diff --git a/source/renderer/app/components/wallet/transactions/Transaction.js b/source/renderer/app/components/wallet/transactions/Transaction.js index d175141f3c..9d91b0bd08 100644 --- a/source/renderer/app/components/wallet/transactions/Transaction.js +++ b/source/renderer/app/components/wallet/transactions/Transaction.js @@ -284,11 +284,11 @@ export default class Transaction extends Component { >

{intl.formatMessage(messages.fromAddresses)}

- {data.addresses.from.map((address, addressIndex) => ( + {data.addresses.from.map((address) => ( { ))}

{intl.formatMessage(messages.toAddresses)}

- {data.addresses.to.map((address, addressIndex) => ( + {data.addresses.to.map((address) => ( { {isRenderingAsVirtualList ? ( (this.virtualList = list)} + ref={list => {this.virtualList = list}} renderRow={this.renderItem} rows={rows} isLoadingSpinnerShown={loadingSpinner !== null} @@ -300,7 +300,7 @@ export default class WalletTransactionsList extends Component { /> ) : ( (this.simpleList = list)} + ref={list => {this.simpleList = list}} renderRow={this.renderItem} rows={rows} /> diff --git a/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js b/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js index 9ebad148f2..458c84228a 100644 --- a/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js +++ b/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js @@ -20,8 +20,8 @@ export class SimpleTransactionList extends Component { const { rows, renderRow } = this.props; return (
- {rows.map((row, index) => ( -
{renderRow(row)}
+ {rows.map((row) => ( +
{renderRow(row)}
))}
); diff --git a/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js b/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js index 6110994607..fb58f4ebfe 100644 --- a/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js +++ b/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js @@ -91,7 +91,7 @@ export class VirtualTransactionList extends Component { estimateHeightOfTxExpandedRow = (row: Row, tx: WalletTransaction): number => { if (!this.txAddressHeight) this.updateAddressesAndIdHeights(); const txSingleAddressHeight = this.txAddressHeight; - const txIdHeight = this.txIdHeight; + const txIdHeightValue = this.txIdHeight; const { addresses } = tx; const txAddressesCount = addresses.from.length + addresses.to.length; const txAddressesHeight = txAddressesCount * txSingleAddressHeight; @@ -99,7 +99,7 @@ export class VirtualTransactionList extends Component { return ( TX_EXPANDED_ROW_BASE_HEIGHT + txAddressesHeight + - txIdHeight + + txIdHeightValue + txBottomMargin ); }; @@ -181,10 +181,7 @@ export class VirtualTransactionList extends Component { checkIfTxContentIsFullyExpanded = (tx: WalletTransaction): boolean => { const txRow = this.getTxRowElementById(tx.id); const txElement = txRow && txRow.firstChild; - const isFullyExpanded = - txElement instanceof HTMLElement && - txElement.classList.contains('Transaction_expanded'); - return isFullyExpanded; + return ((txElement instanceof HTMLElement) && (txElement.classList.contains('Transaction_expanded'))); }; /** @@ -296,7 +293,7 @@ export class VirtualTransactionList extends Component { {({ width, height }) => ( (this.list = list)} + ref={list => {this.list = list}} width={width} height={height} onRowsRendered={throttle(this.onRowsRendered, 100, { diff --git a/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js b/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js index 1d79bcc940..3b7c56ffe7 100644 --- a/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js +++ b/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js @@ -117,7 +117,7 @@ export default class PaperWalletCreateCertificatePage extends Component< }; onBack = () => { - const prevStep = this.state.currentStep ? this.state.currentStep - 1 : 0; + const prevStep = this.state.currentStep ? this.state.currentStep - 1 : 0; const prevDialog = this.CREATE_CERTIFICATE_DIALOGS[prevStep]; this.setState({ currentStep: prevStep }); this.switchDialog(prevDialog); diff --git a/source/renderer/app/containers/wallet/WalletReceivePage.js b/source/renderer/app/containers/wallet/WalletReceivePage.js index ffa7febd52..b56964519b 100755 --- a/source/renderer/app/containers/wallet/WalletReceivePage.js +++ b/source/renderer/app/containers/wallet/WalletReceivePage.js @@ -68,7 +68,7 @@ export default class WalletReceivePage extends Component { render() { const { copiedAddress } = this.state; - const actions = this.props.actions; + const { actions } = this.props; const { sidebar, uiNotifications, wallets, addresses } = this.props.stores; const wallet = wallets.active; diff --git a/source/renderer/app/stores/AdaRedemptionStore.js b/source/renderer/app/stores/AdaRedemptionStore.js index ca1ce5dbd5..7c35fb4655 100644 --- a/source/renderer/app/stores/AdaRedemptionStore.js +++ b/source/renderer/app/stores/AdaRedemptionStore.js @@ -182,32 +182,32 @@ export default class AdaRedemptionStore extends Store { 'AdaRedemptionStore: Parsing ADA Redemption code from certificate', { path } ); - let decryptionKey = null; + let decryptionKeyValue = null; if ( (this.redemptionType === ADA_REDEMPTION_TYPES.REGULAR || this.redemptionType === ADA_REDEMPTION_TYPES.RECOVERY_REGULAR) && this.isCertificateEncrypted ) { - decryptionKey = this.passPhrase; + decryptionKeyValue = this.passPhrase; } if ( this.redemptionType === ADA_REDEMPTION_TYPES.FORCE_VENDED && this.isCertificateEncrypted ) { - decryptionKey = [this.email, this.adaPasscode, this.adaAmount]; + decryptionKeyValue = [this.email, this.adaPasscode, this.adaAmount]; } if ( this.redemptionType === ADA_REDEMPTION_TYPES.RECOVERY_FORCE_VENDED && this.isCertificateEncrypted ) { - decryptionKey = this.decryptionKey; + decryptionKeyValue = this.decryptionKey; } // PARSING try { const redemptionCode = await parseRedemptionCodeChannel.request({ certificateFilePath: path, redemptionType: this.redemptionType, - decryptionKey, + decryptionKey: decryptionKeyValue, }); this._setRedemptionCode({ redemptionCode }); } catch (e) { @@ -231,7 +231,7 @@ export default class AdaRedemptionStore extends Store { walletId: string, spendingPassword: ?string, }) => { - runInAction(() => (this.walletId = walletId)); + runInAction(() => {this.walletId = walletId}); const accountIndex = await this.stores.addresses.getAccountIndexByWalletId( walletId @@ -254,7 +254,7 @@ export default class AdaRedemptionStore extends Store { amount: transaction.amount.toFormat(DECIMAL_PLACES_IN_ADA), }); } catch (error) { - runInAction(() => (this.error = error)); + runInAction(() => {this.error = error}); } }; @@ -267,7 +267,7 @@ export default class AdaRedemptionStore extends Store { shieldedRedemptionKey: string, spendingPassword: ?string, }) => { - runInAction(() => (this.walletId = walletId)); + runInAction(() => {this.walletId = walletId}); const accountIndex = await this.stores.addresses.getAccountIndexByWalletId( walletId @@ -291,7 +291,7 @@ export default class AdaRedemptionStore extends Store { amount: transaction.amount.toFormat(DECIMAL_PLACES_IN_ADA), }); } catch (error) { - runInAction(() => (this.error = error)); + runInAction(() => {this.error = error}); } }; diff --git a/source/renderer/app/stores/NetworkStatusStore.js b/source/renderer/app/stores/NetworkStatusStore.js index 440984037e..7c1df541fe 100644 --- a/source/renderer/app/stores/NetworkStatusStore.js +++ b/source/renderer/app/stores/NetworkStatusStore.js @@ -277,7 +277,7 @@ export default class NetworkStatusStore extends Store { case CardanoNodeStates.STOPPING: case CardanoNodeStates.EXITING: case CardanoNodeStates.UPDATING: - runInAction('reset _tlsConfig', () => (this._tlsConfig = null)); + runInAction('reset _tlsConfig', () => {this._tlsConfig = null}); this._setDisconnected(wasConnected); break; default: @@ -534,7 +534,7 @@ export default class NetworkStatusStore extends Store { if (!this.hasBeenConnected) { runInAction( 'update hasBeenConnected', - () => (this.hasBeenConnected = true) + () => {this.hasBeenConnected = true} ); } Logger.debug('NetworkStatusStore: Connection Lost. Reconnecting...'); @@ -565,7 +565,7 @@ export default class NetworkStatusStore extends Store { if (!this.hasBeenConnected) { runInAction( 'update hasBeenConnected', - () => (this.hasBeenConnected = true) + () => {this.hasBeenConnected = true} ); } Logger.debug('NetworkStatusStore: Connection Lost. Reconnecting...'); diff --git a/source/renderer/app/stores/lib/Request.js b/source/renderer/app/stores/lib/Request.js index 760373f757..e9b5ec636f 100644 --- a/source/renderer/app/stores/lib/Request.js +++ b/source/renderer/app/stores/lib/Request.js @@ -45,7 +45,7 @@ export default class Request { // Issue api call & save it as promise that is handled to update the results of the operation this.promise = new Promise((resolve, reject) => { - if (!this._method) reject('Request method not defined'); + if (!this._method) reject(new Error('Request method not defined')); this._method(...callArgs) .then(result => { setTimeout( diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 59e6b84656..0cfbe83660 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,7 +188,6 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } - return false; }} isInvalid={false} isSubmitting={false} From 62fd5b7ea7f0126c22dad3a8b370fcc84e3494f2 Mon Sep 17 00:00:00 2001 From: Nikola Glumac Date: Wed, 20 Mar 2019 16:18:54 +0100 Subject: [PATCH 05/45] [DDW-595] Fix regex issue --- source/renderer/app/utils/routing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/renderer/app/utils/routing.js b/source/renderer/app/utils/routing.js index 2f95f62c95..617daeb004 100644 --- a/source/renderer/app/utils/routing.js +++ b/source/renderer/app/utils/routing.js @@ -67,7 +67,7 @@ export const buildRoute = (pattern, params) => { // - '/path/:param(/:another_param)' // - '/path(/:param/:another_param)' const paramRegex = new RegExp( - `(/|\\(|\\)|^):${paramName}(/|)|(|$)` + `(/|\\(|\\)|^):${paramName}(/|\\)|\\(|$)` ); routePath = routePath.replace(paramRegex, (match, g1, g2) => { tokens[paramName] = encodeURIComponent(paramValue); From 527127151b939f505301ec25e4d34b7b55e48b13 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 19:52:52 +0100 Subject: [PATCH 06/45] [DDW-595] Fix lint warnings Adding fixes for es linter --- features/support/electron.js | 8 +++-- features/support/helpers/app-helpers.js | 2 +- .../support/helpers/cardano-node-helpers.js | 2 +- features/support/helpers/i18n-helpers.js | 2 +- features/support/helpers/screenshot.js | 1 + features/support/helpers/shared-helpers.js | 4 +-- features/support/helpers/wallets-helpers.js | 2 +- flow/mappers/CSSModule.js.flow | 2 +- scripts/package.js | 4 ++- source/common/ipc/lib/IpcChannel.js | 6 ++-- source/main/cardano/CardanoNode.js | 34 ++++++++----------- source/main/cardano/config.js | 2 +- source/main/cardano/setupCardanoNodeMode.js | 2 +- source/main/cardano/setupFrontendOnlyMode.js | 6 ++-- source/main/config.js | 2 +- source/main/utils/config.js | 1 + source/renderer/app/api/utils/apiHelpers.js | 2 ++ .../settings/ChangeSpendingPasswordDialog.js | 8 +++-- source/renderer/app/stores/WalletsStore.js | 1 + storybook/stories/Sidebar.stories.js | 4 ++- storybook/stories/WalletScreens.stories.js | 1 + storybook/stories/Widgets.stories.js | 4 ++- storybook/stories/support/StoryLayout.js | 4 ++- storybook/stories/support/StoryProvider.js | 4 ++- 24 files changed, 63 insertions(+), 45 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index 95fc91ea20..e8e204aec2 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -22,8 +22,11 @@ let scenariosCount = 0; const printMainProcessLogs = () => context.app.client.getMainProcessLogs().then(logs => { + // eslint-disable-next-line console.log('========= DAEDALUS LOGS ========='); + // eslint-disable-next-line logs.forEach(log => console.log(log)); + // eslint-disable-next-line console.log('================================='); return true; }); @@ -123,17 +126,18 @@ After(async function({ sourceLocation, result }) { }); // eslint-disable-next-line prefer-arrow-callback -AfterAll(async function() { +AfterAll(async () => { const allWindowsClosed = (await context.app.client.getWindowCount()) === 0; if (allWindowsClosed || !context.app.running) return; if (scenariosCount === 0) { await printMainProcessLogs(); } if (process.env.KEEP_APP_AFTER_TESTS === 'true') { + // eslint-disable-next-line console.log( 'Keeping the app running since KEEP_APP_AFTER_TESTS env var is true' ); return; } - return context.app.stop(); + await context.app.stop(); }); diff --git a/features/support/helpers/app-helpers.js b/features/support/helpers/app-helpers.js index 20a35e13a8..1d296d0c85 100644 --- a/features/support/helpers/app-helpers.js +++ b/features/support/helpers/app-helpers.js @@ -8,7 +8,7 @@ export const waitForDaedalusToExit = async ( ) => { const daedalusProcessName = process.platform === 'linux' ? 'electron' : 'Electron'; - return await client.waitUntil( + return client.waitUntil( async () => (await getProcessesByName(daedalusProcessName)).length === 0, timeout ); diff --git a/features/support/helpers/cardano-node-helpers.js b/features/support/helpers/cardano-node-helpers.js index 1dcf045dca..b07a93c950 100644 --- a/features/support/helpers/cardano-node-helpers.js +++ b/features/support/helpers/cardano-node-helpers.js @@ -9,7 +9,7 @@ export const getCardanoNodeState = async (client: WebdriverClient) => .value; export const waitForCardanoNodeToExit = async (client: WebdriverClient) => - await client.waitUntil( + client.waitUntil( async () => (await getProcessesByName('cardano-node')).length === 0, 61000 ); diff --git a/features/support/helpers/i18n-helpers.js b/features/support/helpers/i18n-helpers.js index 75b9857239..d331cf4e17 100644 --- a/features/support/helpers/i18n-helpers.js +++ b/features/support/helpers/i18n-helpers.js @@ -21,7 +21,7 @@ export default { return translation.value; }, setActiveLanguage: async (client, { language } = {}) => - await client.execute(locale => { + client.execute(locale => { daedalus.actions.profile.updateLocale.trigger({ locale }); }, language || DEFAULT_LANGUAGE), }; diff --git a/features/support/helpers/screenshot.js b/features/support/helpers/screenshot.js index e458771906..94e3a40937 100644 --- a/features/support/helpers/screenshot.js +++ b/features/support/helpers/screenshot.js @@ -18,6 +18,7 @@ export const saveScreenshot = async (context, file) => { .capturePage() .then(imageBuffer => fs.writeFile(file, imageBuffer)) .catch(err => { + // eslint-disable-next-line console.log(err); }); }; diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index abda367b45..5e4813b619 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - await client.waitUntil(async () => { + client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return await client.elements(selectSelector); + return client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index 57e8465d2e..ab9df8a927 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - await client.executeAsync( + client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/flow/mappers/CSSModule.js.flow b/flow/mappers/CSSModule.js.flow index 3daeb8989d..023d00a59e 100644 --- a/flow/mappers/CSSModule.js.flow +++ b/flow/mappers/CSSModule.js.flow @@ -1,2 +1,2 @@ // @flow -declare export default { [key: string]: string } +declare export default { [key]: string } diff --git a/scripts/package.js b/scripts/package.js index 429cc1b497..74bae12e1d 100755 --- a/scripts/package.js +++ b/scripts/package.js @@ -59,6 +59,7 @@ if (version) { /** @desc Build, clear previous releases and pack new versions */ async function startPack() { + // eslint-disable-next-line console.log('start pack...'); try { @@ -126,8 +127,9 @@ function pack(plat, arch, cb) { * @return {Function} */ function log(plat, arch) { - return (err, filepath) => { + return (err) => { if (err) return console.error(err); + // eslint-disable-next-line console.log(`${plat}-${arch} finished!`); }; } diff --git a/source/common/ipc/lib/IpcChannel.js b/source/common/ipc/lib/IpcChannel.js index e1bfe9bca1..73c1b18bed 100644 --- a/source/common/ipc/lib/IpcChannel.js +++ b/source/common/ipc/lib/IpcChannel.js @@ -60,9 +60,9 @@ export class IpcChannel { if (existingChannel) return existingChannel; IpcChannel._instances[channelName] = this; - this._broadcastChannel = channelName + '-broadcast'; - this._requestChannel = channelName + '-request'; - this._responseChannel = channelName + '-response'; + this._broadcastChannel = `${channelName}-broadcast`; + this._requestChannel = `${channelName}-request`; + this._responseChannel = `${channelName}-response`; } /** diff --git a/source/main/cardano/CardanoNode.js b/source/main/cardano/CardanoNode.js index 88477d54a4..9a06b51236 100644 --- a/source/main/cardano/CardanoNode.js +++ b/source/main/cardano/CardanoNode.js @@ -225,10 +225,10 @@ export class CardanoNode { const nodeCanBeStarted = await this._canBeStarted(); if (!nodeCanBeStarted) { - return Promise.reject('CardanoNode: Cannot be started'); + return Promise.reject(new Error('CardanoNode: Cannot be started')); } if (this._isUnrecoverable(config) && !isForced) { - return Promise.reject('CardanoNode: Too many startup retries'); + return Promise.reject(new Error('CardanoNode: Too many startup retries')); } // Setup const { _log } = this; @@ -272,7 +272,9 @@ export class CardanoNode { ); resolve(); } catch (_) { - reject('CardanoNode#start: Error while spawning cardano-node'); + reject( + new Error('CardanoNode#start: Error while spawning cardano-node') + ); } }); }); @@ -336,7 +338,7 @@ export class CardanoNode { _log.info('CardanoNode#kill: could not kill cardano-node'); await this._storeProcessStates(); this._reset(); - reject('Could not kill cardano-node.'); + reject(new Error('Could not kill cardano-node.')); } }); } @@ -422,7 +424,7 @@ export class CardanoNode { }); } catch (error) { return Promise.reject( - `cardano-node did not inject the fault "${fault}" correctly.` + new Error(`cardano-node did not inject the fault "${fault}" correctly.`) ); } }; @@ -480,9 +482,9 @@ export class CardanoNode { const { _actions } = this; const { tlsPath } = this._config; this._tlsConfig = { - ca: _actions.readFileSync(tlsPath + '/client/ca.crt'), - key: _actions.readFileSync(tlsPath + '/client/client.key'), - cert: _actions.readFileSync(tlsPath + '/client/client.pem'), + ca: _actions.readFileSync(`${tlsPath}/client/ca.crt`), + key: _actions.readFileSync(`${tlsPath}/client/client.key`), + cert: _actions.readFileSync(`${tlsPath}/client/client.pem`), hostname: 'localhost', port, }; @@ -603,7 +605,7 @@ export class CardanoNode { * @returns {boolean} */ _isDead = async (): Promise => - !this._isConnected() && (await this._isNodeProcessNotRunningAnymore()); + !this._isConnected() && this._isNodeProcessNotRunningAnymore(); /** * Checks if current cardano-node child_process is "awake" (created, connected, stateful) @@ -661,10 +663,7 @@ export class CardanoNode { if (_node == null) { return Promise.resolve(); } - return await this._ensureProcessIsNotRunning( - _node.pid, - CARDANO_PROCESS_NAME - ); + return this._ensureProcessIsNotRunning(_node.pid, CARDANO_PROCESS_NAME); }; _ensurePreviousCardanoNodeIsNotRunning = async (): Promise => { @@ -677,10 +676,7 @@ export class CardanoNode { if (previousPID == null) { return Promise.resolve(); } - return await this._ensureProcessIsNotRunning( - previousPID, - CARDANO_PROCESS_NAME - ); + return this._ensureProcessIsNotRunning(previousPID, CARDANO_PROCESS_NAME); }; _isProcessRunning = async ( @@ -793,13 +789,13 @@ export class CardanoNode { _isNodeProcessStillRunning = async (): Promise => this._node != null && - (await this._isProcessRunning(this._node.pid, CARDANO_PROCESS_NAME)); + this._isProcessRunning(this._node.pid, CARDANO_PROCESS_NAME); _isNodeProcessNotRunningAnymore = async () => (await this._isNodeProcessStillRunning()) === false; _waitForNodeProcessToExit = async (timeout: number) => - await promisedCondition(this._isNodeProcessNotRunningAnymore, timeout); + promisedCondition(this._isNodeProcessNotRunningAnymore, timeout); _waitForCardanoToExitOrKillIt = async () => { const { _config } = this; diff --git a/source/main/cardano/config.js b/source/main/cardano/config.js index c3cc254a73..020637ec45 100644 --- a/source/main/cardano/config.js +++ b/source/main/cardano/config.js @@ -5,7 +5,7 @@ const isDev = process.env.NODE_ENV === 'development'; export const ensureXDGDataIsSet = () => { if (process.env.HOME && process.env.XDG_DATA_HOME === undefined) { - process.env.XDG_DATA_HOME = process.env.HOME + '/.local/share/'; + process.env.XDG_DATA_HOME = `${process.env.HOME}/.local/share/`; } }; diff --git a/source/main/cardano/setupCardanoNodeMode.js b/source/main/cardano/setupCardanoNodeMode.js index dac54ed1c4..0c4cc89dc2 100644 --- a/source/main/cardano/setupCardanoNodeMode.js +++ b/source/main/cardano/setupCardanoNodeMode.js @@ -32,7 +32,7 @@ import { safeExitWithCode } from '../utils/safeExitWithCode'; const startCardanoNode = (node: CardanoNode, launcherConfig: Object) => { const { nodePath, tlsPath, logsPrefix } = launcherConfig; const nodeArgs = prepareArgs(launcherConfig); - const logFilePath = logsPrefix + '/cardano-node.log'; + const logFilePath = `${logsPrefix}/cardano-node.log`; const config = { nodePath, logFilePath, diff --git a/source/main/cardano/setupFrontendOnlyMode.js b/source/main/cardano/setupFrontendOnlyMode.js index 88fe880f08..0cdb6d2eee 100644 --- a/source/main/cardano/setupFrontendOnlyMode.js +++ b/source/main/cardano/setupFrontendOnlyMode.js @@ -26,9 +26,9 @@ export const setupFrontendOnlyMode = (mainWindow: BrowserWindow) => { const cardanoHost = CARDANO_HOST || 'localhost'; const cardanoPort = parseInt(CARDANO_PORT, 10) || 8090; const tlsConfig = { - ca: readFileSync(cardanoTlsPath + '/client/ca.crt'), - key: readFileSync(cardanoTlsPath + '/client/client.key'), - cert: readFileSync(cardanoTlsPath + '/client/client.pem'), + ca: readFileSync(`${cardanoTlsPath}/client/ca.crt`), + key: readFileSync(`${cardanoTlsPath}/client/client.key`), + cert: readFileSync(`${cardanoTlsPath}/client/client.pem`), hostname: cardanoHost, port: cardanoPort, }; diff --git a/source/main/config.js b/source/main/config.js index bf31c895f1..3d8ab31b00 100644 --- a/source/main/config.js +++ b/source/main/config.js @@ -59,7 +59,7 @@ export const launcherConfig: LauncherConfig = readLauncherConfig( export const appLogsFolderPath = launcherConfig.logsPrefix; export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub'); export const appFolderPath = launcherConfig.workingDir; -export const nodeDbPath = launcherConfig.nodeDbPath; +export const { nodeDbPath } = launcherConfig; export const ALLOWED_LOGS = ['Daedalus.json', 'System-info.json']; export const ALLOWED_NODE_LOGS = new RegExp(/(node.json-)(\d{14}$)/); export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/); diff --git a/source/main/utils/config.js b/source/main/utils/config.js index 7d25ea503b..2126418668 100644 --- a/source/main/utils/config.js +++ b/source/main/utils/config.js @@ -14,6 +14,7 @@ export const readLauncherConfig = (configPath: ?string): LauncherConfig => { if (process.env[b]) { return process.env[b]; } + // eslint-disable-next-line console.log('readLauncherConfig: warning var undefined:', b); return ''; }); diff --git a/source/renderer/app/api/utils/apiHelpers.js b/source/renderer/app/api/utils/apiHelpers.js index 3fd593a9f2..3626d6999c 100644 --- a/source/renderer/app/api/utils/apiHelpers.js +++ b/source/renderer/app/api/utils/apiHelpers.js @@ -9,6 +9,7 @@ export const notYetImplemented = async () => // helper code for testing async APIs export const testAsync = async (apiMethod: Function) => { const result = await apiMethod(); + // eslint-disable-next-line console.log(`testAsync result: ${result}`); return result; }; @@ -16,6 +17,7 @@ export const testAsync = async (apiMethod: Function) => { // helper code for testing sync APIs export const testSync = (apiMethod: Function) => { const result = apiMethod(); + // eslint-disable-next-line console.log(`testSync result: ${result}`); return result; }; diff --git a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js index 704c1c96a9..85ea395cbf 100644 --- a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js +++ b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js @@ -232,6 +232,8 @@ export default class ChangeSpendingPasswordDialog extends Component< this.props.onDataChange({ [key]: value }); }; + submitOnEnter = submitOnEnter.bind(this, this.submit); + render() { const { form } = this; const { intl } = this.context; @@ -314,7 +316,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="currentPassword" label={currentPasswordField.label} value={currentPasswordValue} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={submitOnEnter} onChange={value => this.handleDataChange('currentPasswordValue', value) } @@ -331,7 +333,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className={newPasswordClasses} label={newPasswordField.label} value={newPasswordValue} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={submitOnEnter} onChange={value => this.handleDataChange('newPasswordValue', value)} {...newPasswordField.bind()} error={newPasswordField.error} @@ -343,7 +345,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="repeatedPassword" label={repeatedPasswordField.label} value={repeatedPasswordValue} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={submitOnEnter} onChange={value => this.handleDataChange('repeatedPasswordValue', value) } diff --git a/source/renderer/app/stores/WalletsStore.js b/source/renderer/app/stores/WalletsStore.js index 09ed5c61e2..7303940ba9 100644 --- a/source/renderer/app/stores/WalletsStore.js +++ b/source/renderer/app/stores/WalletsStore.js @@ -607,6 +607,7 @@ export default class WalletsStore extends Store { this._updateCertificateStep(); }); } catch (error) { + // eslint-disable-next-line console.log(error); runInAction('handle failed certificate download', () => { // Reset progress diff --git a/storybook/stories/Sidebar.stories.js b/storybook/stories/Sidebar.stories.js index 22a3d7d2d2..9044fee42a 100644 --- a/storybook/stories/Sidebar.stories.js +++ b/storybook/stories/Sidebar.stories.js @@ -32,7 +32,9 @@ const sidebarMenus = observable({ actions: { onAddWallet: action('toggleAddWallet'), onWalletItemClick: (walletId: string) => { - runInAction(() => (sidebarMenus.wallets.activeWalletId = walletId)); + runInAction(() => { + sidebarMenus.wallets.activeWalletId = walletId; + }); }, }, }, diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 0cfbe83660..59e6b84656 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,6 +188,7 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } + return false; }} isInvalid={false} isSubmitting={false} diff --git a/storybook/stories/Widgets.stories.js b/storybook/stories/Widgets.stories.js index a00b703a1a..8429c0b6b4 100644 --- a/storybook/stories/Widgets.stories.js +++ b/storybook/stories/Widgets.stories.js @@ -65,7 +65,9 @@ storiesOf('Widgets', module) (tokens[index] = token)} + onTokenChanged={(index, token) => { + tokens[index] = token; + }} /> ); }) diff --git a/storybook/stories/support/StoryLayout.js b/storybook/stories/support/StoryLayout.js index c62c0dfd90..7cb1e3a743 100644 --- a/storybook/stories/support/StoryLayout.js +++ b/storybook/stories/support/StoryLayout.js @@ -156,7 +156,9 @@ export default class StoryLayout extends Component { ) => ( { - runInAction(() => (this.isShowingSubMenus = !this.isShowingSubMenus)); + runInAction(() => { + this.isShowingSubMenus = !this.isShowingSubMenus; + }); }} formattedWalletAmount={formattedWalletAmount} currentRoute={`/wallets/${activeWallet.id}/${activeNavItem}`} diff --git a/storybook/stories/support/StoryProvider.js b/storybook/stories/support/StoryProvider.js index 7619d928ff..90d1d2c83b 100644 --- a/storybook/stories/support/StoryProvider.js +++ b/storybook/stories/support/StoryProvider.js @@ -61,7 +61,9 @@ export default class StoryProvider extends Component { } setActiveWalletId = (walletId: string) => - runInAction(() => (this.activeWalletId = walletId)); + runInAction(() => { + this.activeWalletId = walletId; + }); render() { return ( From 94ab75fe9771f510486d302a8c56dbfc4c115a9f Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 22:56:40 +0100 Subject: [PATCH 07/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/step_definitions/app-steps.js | 3 ++- features/step_definitions/cardano-steps.js | 2 +- features/step_definitions/settings-steps.js | 6 ++--- source/renderer/app/App.js | 2 +- .../renderer/app/stores/TransactionsStore.js | 26 +++++++++---------- source/renderer/app/stores/WalletsStore.js | 8 +++--- source/renderer/app/utils/crypto.js | 2 +- source/renderer/app/utils/logging.js | 2 +- source/renderer/app/utils/routing.js | 4 +-- source/renderer/app/utils/strings.js | 2 +- 10 files changed, 29 insertions(+), 28 deletions(-) diff --git a/features/step_definitions/app-steps.js b/features/step_definitions/app-steps.js index f64d7b84ef..fd227008dc 100644 --- a/features/step_definitions/app-steps.js +++ b/features/step_definitions/app-steps.js @@ -12,7 +12,8 @@ import { declare var daedalus: Daedalus; Given(/^Daedalus is running$/, function() { - expect(this.app.isRunning()).to.be.true; + const appIsRunning = this.app.isRunning(); + expect(appIsRunning).to.be.true(); }); When(/^I refresh the main window$/, async function() { diff --git a/features/step_definitions/cardano-steps.js b/features/step_definitions/cardano-steps.js index 55cb5d4dd6..b091a0e316 100644 --- a/features/step_definitions/cardano-steps.js +++ b/features/step_definitions/cardano-steps.js @@ -7,7 +7,7 @@ import { } from '../support/helpers/cardano-node-helpers'; Given(/^cardano-node is running$/, async function() { - return await this.client.waitUntil( + return this.client.waitUntil( async () => (await getCardanoNodeState(this.client)) === CardanoNodeStates.RUNNING ); diff --git a/features/step_definitions/settings-steps.js b/features/step_definitions/settings-steps.js index 00b115c7a7..c70c2626d0 100644 --- a/features/step_definitions/settings-steps.js +++ b/features/step_definitions/settings-steps.js @@ -14,12 +14,12 @@ Given(/^I am on the settings screen$/, async function() { Given(/^I should see the "([^"]*)" wallet password dialog$/, function( dialogType ) { - const selector = '.' + dialogType + 'PasswordDialog'; + const selector = `.${dialogType}PasswordDialog`; return this.client.waitForVisible(selector); }); When(/^I click on the "([^"]*)" password label$/, function(label) { - const selector = '.' + label + 'Label button'; + const selector = `.${label}Label button`; return this.client.click(selector); }); @@ -127,7 +127,7 @@ Then(/^I should see new wallet name "([^"]*)"$/, async function(walletName) { }); Then(/^I should see "([^"]*)" label in password field$/, function(label) { - const selector = '.' + label + 'Label'; + const selector = `.${label}Label`; return this.client.waitForVisible(selector); }); diff --git a/source/renderer/app/App.js b/source/renderer/app/App.js index c7be602bd1..4a5898a32e 100755 --- a/source/renderer/app/App.js +++ b/source/renderer/app/App.js @@ -31,7 +31,7 @@ export default class App extends Component<{ const { isAboutDialogOpen, isNetworkStatusDialogOpen } = app; const locale = stores.profile.currentLocale; const mobxDevTools = global.environment.mobxDevTools ? : null; - const currentTheme = stores.profile.currentTheme; + const { currentTheme } = stores.profile; const themeVars = require(`./themes/daedalus/${currentTheme}.js`).default; return ( diff --git a/source/renderer/app/stores/TransactionsStore.js b/source/renderer/app/stores/TransactionsStore.js index 8a9f6d7356..e514c3441f 100644 --- a/source/renderer/app/stores/TransactionsStore.js +++ b/source/renderer/app/stores/TransactionsStore.js @@ -92,36 +92,36 @@ export default class TransactionsStore extends Store { @computed get recent(): Array { const wallet = this.stores.wallets.active; if (!wallet) return []; - const result = this._getTransactionsRecentRequest(wallet.id).result; - return result ? result.transactions : []; + const results = this._getTransactionsRecentRequest(wallet.id).result; + return results ? results.transactions : []; } @computed get hasAnyFiltered(): boolean { const wallet = this.stores.wallets.active; if (!wallet) return false; - const result = this._getTransactionsAllRequest(wallet.id).result; - return result ? result.transactions.length > 0 : false; + const results = this._getTransactionsAllRequest(wallet.id).result; + return results ? results.transactions.length > 0 : false; } @computed get hasAny(): boolean { const wallet = this.stores.wallets.active; if (!wallet) return false; - const result = this._getTransactionsRecentRequest(wallet.id).result; - return result ? result.total > 0 : false; + const results = this._getTransactionsRecentRequest(wallet.id).result; + return results ? results.total > 0 : false; } @computed get totalAvailable(): number { const wallet = this.stores.wallets.active; if (!wallet) return 0; - const result = this._getTransactionsAllRequest(wallet.id).result; - return result ? result.total : 0; + const results = this._getTransactionsAllRequest(wallet.id).result; + return results ? results.total : 0; } @computed get totalFilteredAvailable(): number { const wallet = this.stores.wallets.active; if (!wallet) return 0; - const result = this._getTransactionsAllRequest(wallet.id).result; - return result ? result.transactions.length : 0; + const results = this._getTransactionsAllRequest(wallet.id).result; + return results ? results.transactions.length : 0; } @action _refreshTransactionData = async (restoredWalletId: ?string) => { @@ -248,12 +248,12 @@ export default class TransactionsStore extends Store { const wallet = this.stores.wallets.active; if (!wallet) return this._resetUnconfirmedAmount(); // Reset when no transactions - const result = this._getTransactionsAllRequest(wallet.id).result; - if (!result || !result.transactions) return this._resetUnconfirmedAmount(); + const results = this._getTransactionsAllRequest(wallet.id).result; + if (!results || !results.transactions) return this._resetUnconfirmedAmount(); // We have some results, lets compute and update const unconfirmedAmount = this._getEmptyUnconfirmedAmount(); - for (const transaction of result.transactions) { + for (const transaction of results.transactions) { if (transaction.numberOfConfirmations <= TX_UNCONFIRMED_THRESHOLD) { unconfirmedAmount.total = unconfirmedAmount.total.plus( transaction.amount.absoluteValue() diff --git a/source/renderer/app/stores/WalletsStore.js b/source/renderer/app/stores/WalletsStore.js index 7303940ba9..78c3c57f54 100644 --- a/source/renderer/app/stores/WalletsStore.js +++ b/source/renderer/app/stores/WalletsStore.js @@ -249,7 +249,7 @@ export default class WalletsStore extends Store { @computed get isWalletRoute(): boolean { const { currentRoute } = this.stores.app; - return matchRoute(ROUTES.WALLETS.ROOT + '(/*rest)', currentRoute); + return matchRoute(`${ROUTES.WALLETS.ROOT}(/*rest)`, currentRoute); } getWalletById = (id: string): ?Wallet => this.all.find(w => w.id === id); @@ -270,7 +270,7 @@ export default class WalletsStore extends Store { // =================== PRIVATE API ==================== // @computed get _canRedirectToWallet(): boolean { - const currentRoute = this.stores.app.currentRoute; + const { currentRoute } = this.stores.app; const isRootRoute = matchRoute(ROUTES.WALLETS.ROOT, currentRoute); const isAddWalletRoute = matchRoute(ROUTES.WALLETS.ADD, currentRoute); return isRootRoute || isAddWalletRoute; @@ -285,11 +285,11 @@ export default class WalletsStore extends Store { _pollRefresh = async () => { const { isSynced } = this.stores.networkStatus; - return isSynced && (await this.refreshWalletsData()); + return isSynced && this.refreshWalletsData(); }; _updateActiveWalletOnRouteChanges = () => { - const currentRoute = this.stores.app.currentRoute; + const { currentRoute } = this.stores.app; const hasAnyWalletLoaded = this.hasAnyLoaded; const isWalletAddPage = matchRoute(ROUTES.WALLETS.ADD, currentRoute); runInAction('WalletsStore::_updateActiveWalletOnRouteChanges', () => { diff --git a/source/renderer/app/utils/crypto.js b/source/renderer/app/utils/crypto.js index 70ba901e16..b05af3cc6c 100644 --- a/source/renderer/app/utils/crypto.js +++ b/source/renderer/app/utils/crypto.js @@ -71,7 +71,7 @@ export const unscramblePaperWalletMnemonic = ( export const mnemonicToSeedHex = (mnemonic: string, password: ?string) => { const mnemonicBuffer = Buffer.from(unorm.nfkd(mnemonic), 'utf8'); - const salt = 'mnemonic' + (unorm.nfkd(password) || ''); + const salt = `mnemonic${(unorm.nfkd(password) || '')}`; const saltBuffer = Buffer.from(salt, 'utf8'); return pbkdf2(mnemonicBuffer, saltBuffer, 2048, 32, 'sha512').toString('hex'); }; diff --git a/source/renderer/app/utils/logging.js b/source/renderer/app/utils/logging.js index c7615aa6ea..7c073ae329 100644 --- a/source/renderer/app/utils/logging.js +++ b/source/renderer/app/utils/logging.js @@ -3,7 +3,7 @@ import { formatContext } from '../../../common/utils/logging'; import type { FormatMessageContextParams } from '../../../common/types/logging.types'; const log = global.electronLog; -const environment = global.environment; +const { environment } = global; const appName = 'daedalus'; const electronProcess = 'ipcRenderer'; diff --git a/source/renderer/app/utils/routing.js b/source/renderer/app/utils/routing.js index 94299d29b4..2f95f62c95 100644 --- a/source/renderer/app/utils/routing.js +++ b/source/renderer/app/utils/routing.js @@ -67,7 +67,7 @@ export const buildRoute = (pattern, params) => { // - '/path/:param(/:another_param)' // - '/path(/:param/:another_param)' const paramRegex = new RegExp( - '(/|\\(|\\)|^):' + paramName + '(/|\\)|\\(|$)' + `(/|\\(|\\)|^):${paramName}(/|)|(|$)` ); routePath = routePath.replace(paramRegex, (match, g1, g2) => { tokens[paramName] = encodeURIComponent(paramValue); @@ -107,7 +107,7 @@ export const buildRoute = (pattern, params) => { export const getUrlParameterByName = (name, url) => { if (!url) url = window.location.href; name = name.replace(/[[\]]/g, '\\$&'); - const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'); + const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`); const results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; diff --git a/source/renderer/app/utils/strings.js b/source/renderer/app/utils/strings.js index c275459883..d59a561f80 100644 --- a/source/renderer/app/utils/strings.js +++ b/source/renderer/app/utils/strings.js @@ -13,5 +13,5 @@ export const ellipsis = ( minCharsEnd && shouldHaveEndStr() ? str.substr(str.length - minCharsEnd) : ''; - return initStr + '\u2026' + endStr; + return `${initStr}\u2026${endStr}`; }; From 428b768f58f703c089e2985c92a1113b9b8034c5 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 23:10:55 +0100 Subject: [PATCH 08/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- .../app/components/wallet/WalletSendForm.js | 9 ++++++--- .../widgets/forms/MnemonicInputWidget.js | 2 +- source/renderer/app/index.js | 2 +- source/renderer/app/stores/AddressesStore.js | 18 +++++++++--------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index eff6e13f04..6db8bfeba1 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,6 +159,7 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); + return true; }; isDisabled = () => @@ -174,7 +175,7 @@ export default class WalletSendForm extends Component { value: '', validators: [ async ({ field, form }) => { - const value = field.value; + const { value } = field; if (value === '') { this._resetTransactionFee(); return [ @@ -243,6 +244,8 @@ export default class WalletSendForm extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit); + render() { const { form } = this; const { intl } = this.context; @@ -297,7 +300,7 @@ export default class WalletSendForm extends Component { receiverField.onChange(value || ''); }} skin={InputSkin} - onKeyPress={submitOnEnter.bind(this, this.handleOnSubmit)} + onKeyPress={submitOnEnter} />
@@ -318,7 +321,7 @@ export default class WalletSendForm extends Component { fees={fees} total={total} skin={AmountInputSkin} - onKeyPress={submitOnEnter.bind(this, this.handleOnSubmit)} + onKeyPress={submitOnEnter} />
diff --git a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js index a943b57dc4..833e105f9a 100644 --- a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js +++ b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js @@ -26,7 +26,7 @@ export default class MnemonicInputWidget extends Component { onTokenChanged(index, value)} diff --git a/source/renderer/app/index.js b/source/renderer/app/index.js index 58d08d1831..144bb27b3d 100755 --- a/source/renderer/app/index.js +++ b/source/renderer/app/index.js @@ -26,7 +26,7 @@ configure({ // https://github.com/yahoo/react-intl/wiki#loading-locale-data addLocaleData([...en, ...de, ...hr, ...ja]); -const environment = global.environment; +const { environment } = global; const { isTest, network } = environment; const initializeDaedalus = () => { diff --git a/source/renderer/app/stores/AddressesStore.js b/source/renderer/app/stores/AddressesStore.js index f72597e163..299c745f53 100644 --- a/source/renderer/app/stores/AddressesStore.js +++ b/source/renderer/app/stores/AddressesStore.js @@ -63,30 +63,30 @@ export default class AddressesStore extends Store { @computed get all(): Addresses { const wallet = this.stores.wallets.active; if (!wallet) return []; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses : []; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses : []; } @computed get hasAny(): boolean { const wallet = this.stores.wallets.active; if (!wallet) return false; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses.length > 0 : false; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses.length > 0 : false; } @computed get active(): ?Address { if (this.lastGeneratedAddress) return this.lastGeneratedAddress; const wallet = this.stores.wallets.active; - if (!wallet) return; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses[result.addresses.length - 1] : null; + if (!wallet) return null; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses[results.addresses.length - 1] : null; } @computed get totalAvailable(): number { const wallet = this.stores.wallets.active; if (!wallet) return 0; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses.length : 0; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses.length : 0; } @action _refreshAddresses = () => { From 429e18926528988c1cf197494af06f9fff86a1ac Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 14:05:04 +0100 Subject: [PATCH 09/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/main/cardano/CardanoNode.js | 10 ++++++++-- source/main/ipc/download-logs.js | 2 +- source/main/utils/setupLogging.js | 3 ++- source/renderer/app/api/utils/request.js | 2 +- source/renderer/app/api/utils/requestV0.js | 2 +- .../renderer/app/components/loading/Loading.js | 4 ++-- .../profile/terms-of-use/TermsOfUseForm.js | 2 +- .../renderer/app/components/sidebar/Sidebar.js | 4 ++-- .../app/components/staking/StakingChart.js | 6 +++--- .../app/components/wallet/WalletSendForm.js | 1 - .../wallet/ada-redemption/AdaRedemptionForm.js | 2 +- .../WalletRecoveryPhraseEntryDialog.js | 2 +- .../paper-wallet-certificate/PrintDialog.js | 6 +++--- .../SecuringPasswordDialog.js | 6 +++--- .../VerificationDialog.js | 12 ++++++------ .../app/components/wallet/receive/Address.js | 2 +- .../wallet/receive/VirtualAddressesList.js | 2 +- .../components/wallet/receive/WalletReceive.js | 2 +- .../wallet/transactions/Transaction.js | 8 ++++---- .../transactions/WalletTransactionsList.js | 4 ++-- .../render-strategies/SimpleTransactionList.js | 4 ++-- .../VirtualTransactionList.js | 11 ++++------- .../wallet/PaperWalletCreateCertificatePage.js | 2 +- .../app/containers/wallet/WalletReceivePage.js | 2 +- .../renderer/app/stores/AdaRedemptionStore.js | 18 +++++++++--------- .../renderer/app/stores/NetworkStatusStore.js | 6 +++--- source/renderer/app/stores/lib/Request.js | 2 +- storybook/stories/WalletScreens.stories.js | 1 - 31 files changed, 69 insertions(+), 67 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index e8e204aec2..c8a6bf7776 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - await context.app.stop(); + return context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index 5e4813b619..abda367b45 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - client.waitUntil(async () => { + await client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return client.elements(selectSelector); + return await client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index ab9df8a927..57e8465d2e 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - client.executeAsync( + await client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/main/cardano/CardanoNode.js b/source/main/cardano/CardanoNode.js index 9a06b51236..d94d9f2323 100644 --- a/source/main/cardano/CardanoNode.js +++ b/source/main/cardano/CardanoNode.js @@ -663,7 +663,10 @@ export class CardanoNode { if (_node == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(_node.pid, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + _node.pid, + CARDANO_PROCESS_NAME + ); }; _ensurePreviousCardanoNodeIsNotRunning = async (): Promise => { @@ -676,7 +679,10 @@ export class CardanoNode { if (previousPID == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(previousPID, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + previousPID, + CARDANO_PROCESS_NAME + ); }; _isProcessRunning = async ( diff --git a/source/main/ipc/download-logs.js b/source/main/ipc/download-logs.js index 9cc2dc539c..05d44bf491 100644 --- a/source/main/ipc/download-logs.js +++ b/source/main/ipc/download-logs.js @@ -17,7 +17,7 @@ export default () => { const { compressedLogsFilePath, destinationPath } = request; if (!fs.existsSync(compressedLogsFilePath)) { - return Promise.reject('File does not exist'); + return Promise.reject(new Error('File does not exist')); } const file = fs.readFileSync(compressedLogsFilePath); diff --git a/source/main/utils/setupLogging.js b/source/main/utils/setupLogging.js index 146353da5d..0aad4328d6 100644 --- a/source/main/utils/setupLogging.js +++ b/source/main/utils/setupLogging.js @@ -20,7 +20,7 @@ const isTest = process.env.NODE_ENV === 'test'; const isDev = process.env.NODE_ENV === 'development'; export const setupLogging = () => { - const logFilePath = path.join(pubLogsFolderPath, APP_NAME + '.json'); + const logFilePath = path.join(pubLogsFolderPath, `${APP_NAME}.json`); ensureDirectoryExists(pubLogsFolderPath); log.transports.console.level = isTest ? 'error' : 'info'; log.transports.rendererConsole.level = isDev ? 'info' : 'error'; @@ -60,6 +60,7 @@ export const setupLogging = () => { try { fs.unlinkSync(logFile); } catch (error) { + // eslint-disable-next-line console.error( `Compressed log file "${logFile}" deletion failed: ${error}` ); diff --git a/source/renderer/app/api/utils/request.js b/source/renderer/app/api/utils/request.js index 18ccfc236d..e4a4c190d7 100644 --- a/source/renderer/app/api/utils/request.js +++ b/source/renderer/app/api/utils/request.js @@ -72,7 +72,7 @@ function typedRequest( httpsRequest.on('response', response => { let body = ''; // Cardano-sl returns chunked requests, so we need to concat them - response.on('data', chunk => (body += chunk)); + response.on('data', chunk => {body += chunk}); // Reject errors response.on('error', error => reject(error)); // Resolve JSON results and handle backend errors diff --git a/source/renderer/app/api/utils/requestV0.js b/source/renderer/app/api/utils/requestV0.js index e7ba262645..85b390b68f 100644 --- a/source/renderer/app/api/utils/requestV0.js +++ b/source/renderer/app/api/utils/requestV0.js @@ -70,7 +70,7 @@ function typedRequest( httpsRequest.on('response', response => { let body = ''; // Cardano-sl returns chunked requests, so we need to concat them - response.on('data', chunk => (body += chunk)); + response.on('data', chunk => {body += chunk}); // Reject errors response.on('error', error => reject(error)); // Resolve JSON results and handle weird backend behavior diff --git a/source/renderer/app/components/loading/Loading.js b/source/renderer/app/components/loading/Loading.js index c4c13bd76d..572a88cc2b 100644 --- a/source/renderer/app/components/loading/Loading.js +++ b/source/renderer/app/components/loading/Loading.js @@ -235,14 +235,14 @@ export default class Loading extends Component { }; _incrementConnectingTime = () => { - this.setState({ connectingTime: this.state.connectingTime + 1 }); + this.setState(prevState => ({connectingTime: prevState.connectingTime + 1})); }; _incrementSyncingTime = () => { const syncPercentage = this.props.syncPercentage.toFixed(2); if (syncPercentage === this.state.syncPercentage) { // syncPercentage not increased, increase syncing time - this.setState({ syncingTime: this.state.syncingTime + 1 }); + this.setState(prevState => ({syncingTime: prevState.syncingTime + 1})); } else { // reset syncingTime and set new max percentage this.setState({ syncingTime: 0, syncPercentage }); diff --git a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js index ecd3328b64..d5c35eb851 100644 --- a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js +++ b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js @@ -53,7 +53,7 @@ export default class TermsOfUseForm extends Component { }; toggleAcceptance() { - this.setState({ areTermsOfUseAccepted: !this.state.areTermsOfUseAccepted }); + this.setState(prevState => ({areTermsOfUseAccepted: !prevState.areTermsOfUseAccepted})); } submit = () => { diff --git a/source/renderer/app/components/sidebar/Sidebar.js b/source/renderer/app/components/sidebar/Sidebar.js index f28d541676..761decae5e 100644 --- a/source/renderer/app/components/sidebar/Sidebar.js +++ b/source/renderer/app/components/sidebar/Sidebar.js @@ -83,11 +83,11 @@ export default class Sidebar extends Component { return (
- {categories.map((category, index) => { + {categories.map((category) => { const categoryClassName = kebabCase(category.name); return ( { minPointSize={2} isAnimationActive={false} > - {data.slice().map((entry, index) => { + {data.slice().map((entry) => { let fillColor = '#c2cad4'; let cursor = 'pointer'; - if (index === activeIndex) fillColor = '#445b7c'; + if (entry.id === activeIndex) fillColor = '#445b7c'; if (entry.numberOfTransactions === 0) { fillColor = '#e7eaee'; cursor = 'default'; } return ( - + ); })} diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 6db8bfeba1..071110f57a 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,7 +159,6 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); - return true; }; isDisabled = () => diff --git a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js index 39cd2a3e9f..b1d5a8d739 100644 --- a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js +++ b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js @@ -301,7 +301,7 @@ export default class AdaRedemptionForm extends Component { validators: ({ field }) => { if (this.props.redemptionType !== ADA_REDEMPTION_TYPES.PAPER_VENDED) return [true]; - const value = field.value; + const { value } = field; if (value === '') return [ false, diff --git a/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js b/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js index 45ac8753cf..c7dd4d8675 100644 --- a/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js +++ b/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js @@ -148,7 +148,7 @@ export default class WalletRecoveryPhraseEntryDialog extends Component { return ( { } onConfirmCorrectPrinting = () => { - this.setState({ isPrintedCorrectly: !this.state.isPrintedCorrectly }); + this.setState(prevState => ({isPrintedCorrectly: !prevState.isPrintedCorrectly})); }; onConfirmReadable = () => { - this.setState({ isReadable: !this.state.isReadable }); + this.setState(prevState => ({isReadable: !prevState.isReadable})); }; onConfirmScannable = () => { - this.setState({ isScannable: !this.state.isScannable }); + this.setState(prevState => ({isScannable: !prevState.isScannable})); }; } diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js index b4dc2e894a..d9d336c92f 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js @@ -125,8 +125,8 @@ export default class SecuringPasswordDialog extends Component { } onSecurePasswordConfirmationChange = () => { - this.setState({ - securePasswordConfirmed: !this.state.securePasswordConfirmed, - }); + this.setState( + prevState => ({securePasswordConfirmed: !prevState.securePasswordConfirmed}) + ); }; } diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js index 36a75fad36..0f265c9c21 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js @@ -311,14 +311,14 @@ export default class VerificationDialog extends Component { } onStoringConfirmationChange = () => { - this.setState({ - storingConfirmed: !this.state.storingConfirmed, - }); + this.setState( + prevState => ({storingConfirmed: !prevState.storingConfirmed}) + ); }; onRecoveringConfirmationChange = () => { - this.setState({ - recoveringConfirmed: !this.state.recoveringConfirmed, - }); + this.setState( + prevState => ({recoveringConfirmed: !prevState.recoveringConfirmed}) + ); }; } diff --git a/source/renderer/app/components/wallet/receive/Address.js b/source/renderer/app/components/wallet/receive/Address.js index f2fc236df0..3e7a49d3e6 100644 --- a/source/renderer/app/components/wallet/receive/Address.js +++ b/source/renderer/app/components/wallet/receive/Address.js @@ -20,7 +20,7 @@ export class Address extends Component { render() { const { address, onCopyAddress, copyAddressLabel, index } = this.props; const addressClasses = classnames([ - 'generatedAddress-' + (index + 1), + `generatedAddress-${index + 1}`, styles.component, address.used ? styles.usedWalletAddress : null, ]); diff --git a/source/renderer/app/components/wallet/receive/VirtualAddressesList.js b/source/renderer/app/components/wallet/receive/VirtualAddressesList.js index 8de5d750ce..fd1a08f4b7 100644 --- a/source/renderer/app/components/wallet/receive/VirtualAddressesList.js +++ b/source/renderer/app/components/wallet/receive/VirtualAddressesList.js @@ -109,7 +109,7 @@ export class VirtualAddressesList extends Component { {({ width, height }) => ( (this.list = list)} + ref={list => {this.list = list}} width={width} height={height} rowCount={rows.length} diff --git a/source/renderer/app/components/wallet/receive/WalletReceive.js b/source/renderer/app/components/wallet/receive/WalletReceive.js index 95139b743e..52d24ed526 100644 --- a/source/renderer/app/components/wallet/receive/WalletReceive.js +++ b/source/renderer/app/components/wallet/receive/WalletReceive.js @@ -100,7 +100,7 @@ export default class WalletReceive extends Component { passwordField: Input; toggleUsedAddresses = () => { - this.setState({ showUsed: !this.state.showUsed }); + this.setState(prevState => ({showUsed: !prevState.showUsed})); }; form = new ReactToolboxMobxForm( diff --git a/source/renderer/app/components/wallet/transactions/Transaction.js b/source/renderer/app/components/wallet/transactions/Transaction.js index d175141f3c..9d91b0bd08 100644 --- a/source/renderer/app/components/wallet/transactions/Transaction.js +++ b/source/renderer/app/components/wallet/transactions/Transaction.js @@ -284,11 +284,11 @@ export default class Transaction extends Component { >

{intl.formatMessage(messages.fromAddresses)}

- {data.addresses.from.map((address, addressIndex) => ( + {data.addresses.from.map((address) => ( { ))}

{intl.formatMessage(messages.toAddresses)}

- {data.addresses.to.map((address, addressIndex) => ( + {data.addresses.to.map((address) => ( { {isRenderingAsVirtualList ? ( (this.virtualList = list)} + ref={list => {this.virtualList = list}} renderRow={this.renderItem} rows={rows} isLoadingSpinnerShown={loadingSpinner !== null} @@ -300,7 +300,7 @@ export default class WalletTransactionsList extends Component { /> ) : ( (this.simpleList = list)} + ref={list => {this.simpleList = list}} renderRow={this.renderItem} rows={rows} /> diff --git a/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js b/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js index 9ebad148f2..458c84228a 100644 --- a/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js +++ b/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js @@ -20,8 +20,8 @@ export class SimpleTransactionList extends Component { const { rows, renderRow } = this.props; return (
- {rows.map((row, index) => ( -
{renderRow(row)}
+ {rows.map((row) => ( +
{renderRow(row)}
))}
); diff --git a/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js b/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js index 6110994607..fb58f4ebfe 100644 --- a/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js +++ b/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js @@ -91,7 +91,7 @@ export class VirtualTransactionList extends Component { estimateHeightOfTxExpandedRow = (row: Row, tx: WalletTransaction): number => { if (!this.txAddressHeight) this.updateAddressesAndIdHeights(); const txSingleAddressHeight = this.txAddressHeight; - const txIdHeight = this.txIdHeight; + const txIdHeightValue = this.txIdHeight; const { addresses } = tx; const txAddressesCount = addresses.from.length + addresses.to.length; const txAddressesHeight = txAddressesCount * txSingleAddressHeight; @@ -99,7 +99,7 @@ export class VirtualTransactionList extends Component { return ( TX_EXPANDED_ROW_BASE_HEIGHT + txAddressesHeight + - txIdHeight + + txIdHeightValue + txBottomMargin ); }; @@ -181,10 +181,7 @@ export class VirtualTransactionList extends Component { checkIfTxContentIsFullyExpanded = (tx: WalletTransaction): boolean => { const txRow = this.getTxRowElementById(tx.id); const txElement = txRow && txRow.firstChild; - const isFullyExpanded = - txElement instanceof HTMLElement && - txElement.classList.contains('Transaction_expanded'); - return isFullyExpanded; + return ((txElement instanceof HTMLElement) && (txElement.classList.contains('Transaction_expanded'))); }; /** @@ -296,7 +293,7 @@ export class VirtualTransactionList extends Component { {({ width, height }) => ( (this.list = list)} + ref={list => {this.list = list}} width={width} height={height} onRowsRendered={throttle(this.onRowsRendered, 100, { diff --git a/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js b/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js index 1d79bcc940..3b7c56ffe7 100644 --- a/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js +++ b/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js @@ -117,7 +117,7 @@ export default class PaperWalletCreateCertificatePage extends Component< }; onBack = () => { - const prevStep = this.state.currentStep ? this.state.currentStep - 1 : 0; + const prevStep = this.state.currentStep ? this.state.currentStep - 1 : 0; const prevDialog = this.CREATE_CERTIFICATE_DIALOGS[prevStep]; this.setState({ currentStep: prevStep }); this.switchDialog(prevDialog); diff --git a/source/renderer/app/containers/wallet/WalletReceivePage.js b/source/renderer/app/containers/wallet/WalletReceivePage.js index ffa7febd52..b56964519b 100755 --- a/source/renderer/app/containers/wallet/WalletReceivePage.js +++ b/source/renderer/app/containers/wallet/WalletReceivePage.js @@ -68,7 +68,7 @@ export default class WalletReceivePage extends Component { render() { const { copiedAddress } = this.state; - const actions = this.props.actions; + const { actions } = this.props; const { sidebar, uiNotifications, wallets, addresses } = this.props.stores; const wallet = wallets.active; diff --git a/source/renderer/app/stores/AdaRedemptionStore.js b/source/renderer/app/stores/AdaRedemptionStore.js index ca1ce5dbd5..7c35fb4655 100644 --- a/source/renderer/app/stores/AdaRedemptionStore.js +++ b/source/renderer/app/stores/AdaRedemptionStore.js @@ -182,32 +182,32 @@ export default class AdaRedemptionStore extends Store { 'AdaRedemptionStore: Parsing ADA Redemption code from certificate', { path } ); - let decryptionKey = null; + let decryptionKeyValue = null; if ( (this.redemptionType === ADA_REDEMPTION_TYPES.REGULAR || this.redemptionType === ADA_REDEMPTION_TYPES.RECOVERY_REGULAR) && this.isCertificateEncrypted ) { - decryptionKey = this.passPhrase; + decryptionKeyValue = this.passPhrase; } if ( this.redemptionType === ADA_REDEMPTION_TYPES.FORCE_VENDED && this.isCertificateEncrypted ) { - decryptionKey = [this.email, this.adaPasscode, this.adaAmount]; + decryptionKeyValue = [this.email, this.adaPasscode, this.adaAmount]; } if ( this.redemptionType === ADA_REDEMPTION_TYPES.RECOVERY_FORCE_VENDED && this.isCertificateEncrypted ) { - decryptionKey = this.decryptionKey; + decryptionKeyValue = this.decryptionKey; } // PARSING try { const redemptionCode = await parseRedemptionCodeChannel.request({ certificateFilePath: path, redemptionType: this.redemptionType, - decryptionKey, + decryptionKey: decryptionKeyValue, }); this._setRedemptionCode({ redemptionCode }); } catch (e) { @@ -231,7 +231,7 @@ export default class AdaRedemptionStore extends Store { walletId: string, spendingPassword: ?string, }) => { - runInAction(() => (this.walletId = walletId)); + runInAction(() => {this.walletId = walletId}); const accountIndex = await this.stores.addresses.getAccountIndexByWalletId( walletId @@ -254,7 +254,7 @@ export default class AdaRedemptionStore extends Store { amount: transaction.amount.toFormat(DECIMAL_PLACES_IN_ADA), }); } catch (error) { - runInAction(() => (this.error = error)); + runInAction(() => {this.error = error}); } }; @@ -267,7 +267,7 @@ export default class AdaRedemptionStore extends Store { shieldedRedemptionKey: string, spendingPassword: ?string, }) => { - runInAction(() => (this.walletId = walletId)); + runInAction(() => {this.walletId = walletId}); const accountIndex = await this.stores.addresses.getAccountIndexByWalletId( walletId @@ -291,7 +291,7 @@ export default class AdaRedemptionStore extends Store { amount: transaction.amount.toFormat(DECIMAL_PLACES_IN_ADA), }); } catch (error) { - runInAction(() => (this.error = error)); + runInAction(() => {this.error = error}); } }; diff --git a/source/renderer/app/stores/NetworkStatusStore.js b/source/renderer/app/stores/NetworkStatusStore.js index 440984037e..7c1df541fe 100644 --- a/source/renderer/app/stores/NetworkStatusStore.js +++ b/source/renderer/app/stores/NetworkStatusStore.js @@ -277,7 +277,7 @@ export default class NetworkStatusStore extends Store { case CardanoNodeStates.STOPPING: case CardanoNodeStates.EXITING: case CardanoNodeStates.UPDATING: - runInAction('reset _tlsConfig', () => (this._tlsConfig = null)); + runInAction('reset _tlsConfig', () => {this._tlsConfig = null}); this._setDisconnected(wasConnected); break; default: @@ -534,7 +534,7 @@ export default class NetworkStatusStore extends Store { if (!this.hasBeenConnected) { runInAction( 'update hasBeenConnected', - () => (this.hasBeenConnected = true) + () => {this.hasBeenConnected = true} ); } Logger.debug('NetworkStatusStore: Connection Lost. Reconnecting...'); @@ -565,7 +565,7 @@ export default class NetworkStatusStore extends Store { if (!this.hasBeenConnected) { runInAction( 'update hasBeenConnected', - () => (this.hasBeenConnected = true) + () => {this.hasBeenConnected = true} ); } Logger.debug('NetworkStatusStore: Connection Lost. Reconnecting...'); diff --git a/source/renderer/app/stores/lib/Request.js b/source/renderer/app/stores/lib/Request.js index 760373f757..e9b5ec636f 100644 --- a/source/renderer/app/stores/lib/Request.js +++ b/source/renderer/app/stores/lib/Request.js @@ -45,7 +45,7 @@ export default class Request { // Issue api call & save it as promise that is handled to update the results of the operation this.promise = new Promise((resolve, reject) => { - if (!this._method) reject('Request method not defined'); + if (!this._method) reject(new Error('Request method not defined')); this._method(...callArgs) .then(result => { setTimeout( diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 59e6b84656..0cfbe83660 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,7 +188,6 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } - return false; }} isInvalid={false} isSubmitting={false} From 29d9cc4cc00f1d4ca3ccca7b9658d36c79906085 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 19:52:52 +0100 Subject: [PATCH 10/45] [DDW-595] Fix lint warnings Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- storybook/stories/WalletScreens.stories.js | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index c8a6bf7776..e8e204aec2 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - return context.app.stop(); + await context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index abda367b45..5e4813b619 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - await client.waitUntil(async () => { + client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return await client.elements(selectSelector); + return client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index 57e8465d2e..ab9df8a927 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - await client.executeAsync( + client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 0cfbe83660..59e6b84656 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,6 +188,7 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } + return false; }} isInvalid={false} isSubmitting={false} From a0653a58f2f407ff768839c6d8410b8bf00a3c07 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 23:10:55 +0100 Subject: [PATCH 11/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- source/renderer/app/components/wallet/WalletSendForm.js | 1 + 1 file changed, 1 insertion(+) diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 071110f57a..6db8bfeba1 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,6 +159,7 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); + return true; }; isDisabled = () => From 893528d2ad26c37ce19314b54de64645858a337d Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 14:05:04 +0100 Subject: [PATCH 12/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/renderer/app/components/wallet/WalletSendForm.js | 1 - storybook/stories/WalletScreens.stories.js | 1 - 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index e8e204aec2..c8a6bf7776 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - await context.app.stop(); + return context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index 5e4813b619..abda367b45 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - client.waitUntil(async () => { + await client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return client.elements(selectSelector); + return await client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index ab9df8a927..57e8465d2e 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - client.executeAsync( + await client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 6db8bfeba1..071110f57a 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,7 +159,6 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); - return true; }; isDisabled = () => diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 59e6b84656..0cfbe83660 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,7 +188,6 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } - return false; }} isInvalid={false} isSubmitting={false} From 73749aa960fdb0519e8008630584e477d1f12586 Mon Sep 17 00:00:00 2001 From: Nikola Glumac Date: Wed, 20 Mar 2019 16:18:54 +0100 Subject: [PATCH 13/45] [DDW-595] Fix regex issue --- source/renderer/app/utils/routing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/renderer/app/utils/routing.js b/source/renderer/app/utils/routing.js index 2f95f62c95..617daeb004 100644 --- a/source/renderer/app/utils/routing.js +++ b/source/renderer/app/utils/routing.js @@ -67,7 +67,7 @@ export const buildRoute = (pattern, params) => { // - '/path/:param(/:another_param)' // - '/path(/:param/:another_param)' const paramRegex = new RegExp( - `(/|\\(|\\)|^):${paramName}(/|)|(|$)` + `(/|\\(|\\)|^):${paramName}(/|\\)|\\(|$)` ); routePath = routePath.replace(paramRegex, (match, g1, g2) => { tokens[paramName] = encodeURIComponent(paramValue); From eaf0f6c47a2753309af904c0937c577c0e10aa2f Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 17:22:06 +0100 Subject: [PATCH 14/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- flow/mappers/CSSModule.js.flow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow/mappers/CSSModule.js.flow b/flow/mappers/CSSModule.js.flow index 023d00a59e..c98cc4de57 100644 --- a/flow/mappers/CSSModule.js.flow +++ b/flow/mappers/CSSModule.js.flow @@ -1,2 +1,2 @@ // @flow -declare export default { [key]: string } +declare export default { [string]: string } From df9c8b9cc5e3a0c5b79c72714b6b64ef5be0ccd4 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 18:29:54 +0100 Subject: [PATCH 15/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- source/renderer/app/components/sidebar/Sidebar.js | 5 +++-- .../backup-recovery/WalletRecoveryPhraseEntryDialog.js | 3 ++- .../app/components/wallet/transactions/Transaction.js | 10 ++++++---- .../render-strategies/SimpleTransactionList.js | 5 +++-- .../components/widgets/forms/MnemonicInputWidget.js | 3 ++- source/renderer/app/stores/lib/Request.js | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/source/renderer/app/components/sidebar/Sidebar.js b/source/renderer/app/components/sidebar/Sidebar.js index 761decae5e..b1a5e02135 100644 --- a/source/renderer/app/components/sidebar/Sidebar.js +++ b/source/renderer/app/components/sidebar/Sidebar.js @@ -83,11 +83,12 @@ export default class Sidebar extends Component { return (
- {categories.map((category) => { + {categories.map((category, index) => { const categoryClassName = kebabCase(category.name); return ( { return ( { >

{intl.formatMessage(messages.fromAddresses)}

- {data.addresses.from.map((address) => ( + {data.addresses.from.map((address, addressIndex) => ( { ))}

{intl.formatMessage(messages.toAddresses)}

- {data.addresses.to.map((address) => ( + {data.addresses.to.map((address, addressIndex) => ( { const { rows, renderRow } = this.props; return (
- {rows.map((row) => ( -
{renderRow(row)}
+ {rows.map((row, index) => ( + // eslint-disable-next-line +
{renderRow(row)}
))}
); diff --git a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js index 833e105f9a..631c7cec09 100644 --- a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js +++ b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js @@ -26,7 +26,8 @@ export default class MnemonicInputWidget extends Component { onTokenChanged(index, value)} diff --git a/source/renderer/app/stores/lib/Request.js b/source/renderer/app/stores/lib/Request.js index e9b5ec636f..76b3bbbf65 100644 --- a/source/renderer/app/stores/lib/Request.js +++ b/source/renderer/app/stores/lib/Request.js @@ -45,7 +45,7 @@ export default class Request { // Issue api call & save it as promise that is handled to update the results of the operation this.promise = new Promise((resolve, reject) => { - if (!this._method) reject(new Error('Request method not defined')); + if (!this._method) reject(new ReferenceError('Request method not defined')); this._method(...callArgs) .then(result => { setTimeout( From 250098ceda36e7bf8a267ae740dbe09c9c9c33b1 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 22:37:22 +0100 Subject: [PATCH 16/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/main/ipc/index.js | 1 + source/main/ipc/load-asset.js | 6 +++++- source/main/menus/osx.js | 8 +++++--- source/main/menus/win-linux.js | 8 +++++--- source/main/utils/rendererErrorHandler.js | 1 + source/renderer/app/ThemeManager.js | 2 ++ .../profile/terms-of-use/TermsOfUseForm.js | 4 +++- .../app/components/wallet/WalletCreateDialog.js | 8 +++++--- .../app/components/wallet/WalletRestoreDialog.js | 8 +++++--- .../app/components/wallet/WalletSendForm.js | 7 +++---- .../wallet/ada-redemption/AdaRedemptionForm.js | 16 +++++++++------- .../wallet/backup-recovery/MnemonicWord.js | 1 + .../paper-wallet-certificate/PrintDialog.js | 13 ++++++++++--- .../SecuringPasswordDialog.js | 7 ++++++- .../VerificationDialog.js | 10 ++++++++-- .../app/components/wallet/receive/Address.js | 1 + .../components/wallet/receive/WalletReceive.js | 6 +++++- .../settings/ChangeSpendingPasswordDialog.js | 10 +++++----- .../settings/DeleteWalletConfirmationDialog.js | 1 + .../wallet/settings/ExportWalletToFileDialog.js | 4 +++- .../transactions/WalletTransactionsList.js | 1 + .../widgets/forms/InlineEditingInput.js | 1 + .../wallet/PaperWalletCreateCertificatePage.js | 1 + source/renderer/app/utils/form.js | 2 ++ 26 files changed, 92 insertions(+), 41 deletions(-) diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index abda367b45..5e4813b619 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - await client.waitUntil(async () => { + client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return await client.elements(selectSelector); + return client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index 57e8465d2e..ab9df8a927 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - await client.executeAsync( + client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/main/ipc/index.js b/source/main/ipc/index.js index aeb2741635..eaf3bc69f8 100644 --- a/source/main/ipc/index.js +++ b/source/main/ipc/index.js @@ -20,6 +20,7 @@ export default (window: BrowserWindow) => { getGpuStatus(); handleBugReportRequests(); handlePaperWalletRequests(); + // eslint-disable-next-line openExternalUrlChannel; setupParseRedemptionCodeHandler(); }; diff --git a/source/main/ipc/load-asset.js b/source/main/ipc/load-asset.js index bf3c0e4dd7..8767852d59 100644 --- a/source/main/ipc/load-asset.js +++ b/source/main/ipc/load-asset.js @@ -18,7 +18,11 @@ export default () => { const asset = path.resolve(__dirname, `../renderer/${request.fileName}`); return new Promise((resolve, reject) => fs.readFile(asset, 'base64', (error, data) => { - error ? reject(error) : resolve(data); + if (error) { + reject(error); + } else { + resolve(data); + } }) ); }); diff --git a/source/main/menus/osx.js b/source/main/menus/osx.js index 2b38be6cd4..45b856cc84 100644 --- a/source/main/menus/osx.js +++ b/source/main/menus/osx.js @@ -34,9 +34,11 @@ export const osxMenu = ( type: 'checkbox', checked: isInSafeMode, click() { - isInSafeMode - ? actions.restartWithoutSafeMode() - : actions.restartInSafeMode(); + if (isInSafeMode) { + actions.restartWithoutSafeMode(); + } else { + actions.restartInSafeMode(); + } }, }, { diff --git a/source/main/menus/win-linux.js b/source/main/menus/win-linux.js index 9cc0e08962..dc7cae0549 100644 --- a/source/main/menus/win-linux.js +++ b/source/main/menus/win-linux.js @@ -35,9 +35,11 @@ export const winLinuxMenu = ( type: 'checkbox', checked: isInSafeMode, click() { - isInSafeMode - ? actions.restartWithoutSafeMode() - : actions.restartInSafeMode(); + if (isInSafeMode) { + actions.restartWithoutSafeMode(); + } else { + actions.restartInSafeMode(); + } }, }, { diff --git a/source/main/utils/rendererErrorHandler.js b/source/main/utils/rendererErrorHandler.js index 0f09b16324..207fdb8546 100644 --- a/source/main/utils/rendererErrorHandler.js +++ b/source/main/utils/rendererErrorHandler.js @@ -25,6 +25,7 @@ export default class RendererErrorHandler { if (this.count < this.maxReloads) { this.count++; + // eslint-disable-next-line this.createMainWindow && this.createMainWindow(); } else { this.count = 0; diff --git a/source/renderer/app/ThemeManager.js b/source/renderer/app/ThemeManager.js index 4ee9887514..410d32d519 100644 --- a/source/renderer/app/ThemeManager.js +++ b/source/renderer/app/ThemeManager.js @@ -3,6 +3,7 @@ import { map } from 'lodash'; export default class ThemeManager extends Component { componentDidMount() { + // eslint-disable-next-line this.updateCSSVariables(this.props.variables); } @@ -18,6 +19,7 @@ export default class ThemeManager extends Component { }); } render() { + // eslint-disable-next-line return {this.props.children}; } } diff --git a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js index d5c35eb851..8a2910a769 100644 --- a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js +++ b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js @@ -52,6 +52,8 @@ export default class TermsOfUseForm extends Component { areTermsOfUseAccepted: false, }; + toggleAcceptance = this.toggleAcceptance.bind(this); + toggleAcceptance() { this.setState(prevState => ({areTermsOfUseAccepted: !prevState.areTermsOfUseAccepted})); } @@ -77,7 +79,7 @@ export default class TermsOfUseForm extends Component {
diff --git a/source/renderer/app/components/wallet/WalletCreateDialog.js b/source/renderer/app/components/wallet/WalletCreateDialog.js index 1934d07e79..11612650a9 100644 --- a/source/renderer/app/components/wallet/WalletCreateDialog.js +++ b/source/renderer/app/components/wallet/WalletCreateDialog.js @@ -177,6 +177,8 @@ export default class WalletCreateDialog extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -234,7 +236,7 @@ export default class WalletCreateDialog extends Component { > { this.walletNameInput = input; }} @@ -260,14 +262,14 @@ export default class WalletCreateDialog extends Component {
{ this.setState({ createPassword: value }); }; + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -384,7 +386,7 @@ export default class WalletRestoreDialog extends Component { {
{ componentWillUnmount() { this._isMounted = false; } + submitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit); handleOnSubmit = () => { if (this.isDisabled()) { @@ -243,8 +244,6 @@ export default class WalletSendForm extends Component { } ); - submitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit); - render() { const { form } = this; const { intl } = this.context; @@ -299,7 +298,7 @@ export default class WalletSendForm extends Component { receiverField.onChange(value || ''); }} skin={InputSkin} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} />
@@ -320,7 +319,7 @@ export default class WalletSendForm extends Component { fees={fees} total={total} skin={AmountInputSkin} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} />
diff --git a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js index b1d5a8d739..d29d881cb6 100644 --- a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js +++ b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js @@ -424,6 +424,8 @@ export default class AdaRedemptionForm extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -609,7 +611,7 @@ export default class AdaRedemptionForm extends Component {
{redemptionType !== ADA_REDEMPTION_TYPES.PAPER_VENDED ? ( { /> ) : ( { {walletHasPassword ? (
{ {showInputForDecryptionKey ? (
{ {showInputsForDecryptingForceVendedCertificate ? (
{ {showInputsForDecryptingForceVendedCertificate ? (
{ {showInputsForDecryptingForceVendedCertificate ? (
{ themeOverrides={styles} disabled={!isActive} label={word} + // eslint-disable-next-line onClick={handleClick} skin={ButtonSkin} /> diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js index d488eabb3b..ee3fb16876 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js @@ -82,6 +82,13 @@ export default class PrintDialog extends Component { isScannable: false, }; + constructor(props: Props) { + super(props); + this.onConfirmReadable = this.onConfirmReadable.bind(this); + this.onConfirmScannable = this.onConfirmScannable.bind(this); + this.onConfirmCorrectPrinting = this.onConfirmCorrectPrinting.bind(this); + } + render() { const { intl } = this.context; const { onContinue, onClose } = this.props; @@ -139,7 +146,7 @@ export default class PrintDialog extends Component { label={intl.formatMessage( messages.certificatePrintedConfirmationLabel )} - onChange={this.onConfirmCorrectPrinting.bind(this)} + onChange={this.onConfirmCorrectPrinting} checked={isPrintedCorrectly} skin={CheckboxSkin} /> @@ -152,7 +159,7 @@ export default class PrintDialog extends Component { paperWalletPrintedWordsCount: PAPER_WALLET_PRINTED_WORDS_COUNT, } )} - onChange={this.onConfirmReadable.bind(this)} + onChange={this.onConfirmReadable} checked={isReadable} skin={CheckboxSkin} /> @@ -160,7 +167,7 @@ export default class PrintDialog extends Component { diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js index d9d336c92f..6e220a9925 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js @@ -63,6 +63,11 @@ export default class SecuringPasswordDialog extends Component { securePasswordConfirmed: false, }; + constructor(props: Props) { + super(props); + this.onSecurePasswordConfirmationChange = this.onSecurePasswordConfirmationChange.bind(this); + } + render() { const { intl } = this.context; const { securePasswordConfirmed } = this.state; @@ -114,7 +119,7 @@ export default class SecuringPasswordDialog extends Component { label={intl.formatMessage(messages.securingPasswordConfirmation, { paperWalletWrittenWordsCount: PAPER_WALLET_WRITTEN_WORDS_COUNT, })} - onChange={this.onSecurePasswordConfirmationChange.bind(this)} + onChange={this.onSecurePasswordConfirmationChange} checked={securePasswordConfirmed} skin={CheckboxSkin} /> diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js index 0f265c9c21..1556a2e805 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js @@ -113,6 +113,12 @@ export default class VerificationDialog extends Component { isRecoveryPhraseValid: false, }; + constructor(props: Props) { + super(props); + this.onRecoveringConfirmationChange = this.onRecoveringConfirmationChange.bind(this); + this.onStoringConfirmationChange = this.onStoringConfirmationChange.bind(this); + } + recoveryPhraseAutocomplete: Autocomplete; form = new ReactToolboxMobxForm( @@ -290,7 +296,7 @@ export default class VerificationDialog extends Component { { {
diff --git a/source/renderer/app/components/wallet/receive/WalletReceive.js b/source/renderer/app/components/wallet/receive/WalletReceive.js index 52d24ed526..f8589a4bfc 100644 --- a/source/renderer/app/components/wallet/receive/WalletReceive.js +++ b/source/renderer/app/components/wallet/receive/WalletReceive.js @@ -147,6 +147,8 @@ export default class WalletReceive extends Component { /> ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -159,6 +161,7 @@ export default class WalletReceive extends Component { onError: () => {}, }); + // eslint-disable-next-line this.passwordField && this.passwordField.focus(); }; @@ -211,7 +214,7 @@ export default class WalletReceive extends Component { }} error={passwordField.error} skin={InputSkin} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={this.submitOnEnter} /> )} @@ -255,6 +258,7 @@ export default class WalletReceive extends Component { {walletAddress} diff --git a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js index 85ea395cbf..dde8e532b4 100644 --- a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js +++ b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js @@ -208,6 +208,8 @@ export default class ChangeSpendingPasswordDialog extends Component< } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -232,8 +234,6 @@ export default class ChangeSpendingPasswordDialog extends Component< this.props.onDataChange({ [key]: value }); }; - submitOnEnter = submitOnEnter.bind(this, this.submit); - render() { const { form } = this; const { intl } = this.context; @@ -316,7 +316,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="currentPassword" label={currentPasswordField.label} value={currentPasswordValue} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} onChange={value => this.handleDataChange('currentPasswordValue', value) } @@ -333,7 +333,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className={newPasswordClasses} label={newPasswordField.label} value={newPasswordValue} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} onChange={value => this.handleDataChange('newPasswordValue', value)} {...newPasswordField.bind()} error={newPasswordField.error} @@ -345,7 +345,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="repeatedPassword" label={repeatedPasswordField.label} value={repeatedPasswordValue} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} onChange={value => this.handleDataChange('repeatedPasswordValue', value) } diff --git a/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js b/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js index 10dd032243..575f5c63ee 100644 --- a/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js +++ b/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js @@ -143,6 +143,7 @@ export default class DeleteWalletConfirmationDialog extends Component { className={styles.confirmationInput} label={intl.formatMessage(messages.enterRecoveryWordLabel)} value={confirmationValue} + // eslint-disable-next-line onKeyPress={submitOnEnter.bind(this, handleSubmit)} onChange={onConfirmationValueChange} skin={InputSkin} diff --git a/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js b/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js index 7dc44684d8..18b2246d33 100644 --- a/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js +++ b/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js @@ -123,6 +123,8 @@ export default class ExportWalletToFileDialog extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -203,7 +205,7 @@ export default class ExportWalletToFileDialog extends Component { {...spendingPasswordField.bind()} error={spendingPasswordField.error} skin={InputSkin} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={this.submitOnEnter} /> ) : null} diff --git a/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js b/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js index 0b6f5103b4..7174ef1619 100644 --- a/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js +++ b/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js @@ -281,6 +281,7 @@ export default class WalletTransactionsList extends Component {
@@ -318,7 +321,7 @@ export default class WalletSendForm extends Component { fees={fees} total={total} skin={AmountInputSkin} - onKeyPress={submitOnEnter.bind(this, this.handleOnSubmit)} + onKeyPress={submitOnEnter} />
diff --git a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js index a943b57dc4..833e105f9a 100644 --- a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js +++ b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js @@ -26,7 +26,7 @@ export default class MnemonicInputWidget extends Component { onTokenChanged(index, value)} diff --git a/source/renderer/app/index.js b/source/renderer/app/index.js index 58d08d1831..144bb27b3d 100755 --- a/source/renderer/app/index.js +++ b/source/renderer/app/index.js @@ -26,7 +26,7 @@ configure({ // https://github.com/yahoo/react-intl/wiki#loading-locale-data addLocaleData([...en, ...de, ...hr, ...ja]); -const environment = global.environment; +const { environment } = global; const { isTest, network } = environment; const initializeDaedalus = () => { diff --git a/source/renderer/app/stores/AddressesStore.js b/source/renderer/app/stores/AddressesStore.js index f72597e163..299c745f53 100644 --- a/source/renderer/app/stores/AddressesStore.js +++ b/source/renderer/app/stores/AddressesStore.js @@ -63,30 +63,30 @@ export default class AddressesStore extends Store { @computed get all(): Addresses { const wallet = this.stores.wallets.active; if (!wallet) return []; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses : []; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses : []; } @computed get hasAny(): boolean { const wallet = this.stores.wallets.active; if (!wallet) return false; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses.length > 0 : false; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses.length > 0 : false; } @computed get active(): ?Address { if (this.lastGeneratedAddress) return this.lastGeneratedAddress; const wallet = this.stores.wallets.active; - if (!wallet) return; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses[result.addresses.length - 1] : null; + if (!wallet) return null; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses[results.addresses.length - 1] : null; } @computed get totalAvailable(): number { const wallet = this.stores.wallets.active; if (!wallet) return 0; - const result = this._getAddressesAllRequest(wallet.id).result; - return result ? result.addresses.length : 0; + const results = this._getAddressesAllRequest(wallet.id).result; + return results ? results.addresses.length : 0; } @action _refreshAddresses = () => { From 39687b056de4297ea13e54bd95cfb81e26130dc0 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 14:05:04 +0100 Subject: [PATCH 20/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/main/cardano/CardanoNode.js | 10 ++++++++-- source/main/ipc/download-logs.js | 2 +- source/main/utils/setupLogging.js | 3 ++- source/renderer/app/api/utils/request.js | 2 +- source/renderer/app/api/utils/requestV0.js | 2 +- .../renderer/app/components/loading/Loading.js | 4 ++-- .../profile/terms-of-use/TermsOfUseForm.js | 2 +- .../renderer/app/components/sidebar/Sidebar.js | 4 ++-- .../app/components/staking/StakingChart.js | 6 +++--- .../app/components/wallet/WalletSendForm.js | 1 - .../wallet/ada-redemption/AdaRedemptionForm.js | 2 +- .../WalletRecoveryPhraseEntryDialog.js | 2 +- .../paper-wallet-certificate/PrintDialog.js | 6 +++--- .../SecuringPasswordDialog.js | 6 +++--- .../VerificationDialog.js | 12 ++++++------ .../app/components/wallet/receive/Address.js | 2 +- .../wallet/receive/VirtualAddressesList.js | 2 +- .../components/wallet/receive/WalletReceive.js | 2 +- .../wallet/transactions/Transaction.js | 8 ++++---- .../transactions/WalletTransactionsList.js | 4 ++-- .../render-strategies/SimpleTransactionList.js | 4 ++-- .../VirtualTransactionList.js | 11 ++++------- .../wallet/PaperWalletCreateCertificatePage.js | 2 +- .../app/containers/wallet/WalletReceivePage.js | 2 +- .../renderer/app/stores/AdaRedemptionStore.js | 18 +++++++++--------- .../renderer/app/stores/NetworkStatusStore.js | 6 +++--- source/renderer/app/stores/lib/Request.js | 2 +- storybook/stories/WalletScreens.stories.js | 1 - 31 files changed, 69 insertions(+), 67 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index e8e204aec2..c8a6bf7776 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - await context.app.stop(); + return context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index 5e4813b619..abda367b45 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - client.waitUntil(async () => { + await client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return client.elements(selectSelector); + return await client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index ab9df8a927..57e8465d2e 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - client.executeAsync( + await client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/main/cardano/CardanoNode.js b/source/main/cardano/CardanoNode.js index 9a06b51236..d94d9f2323 100644 --- a/source/main/cardano/CardanoNode.js +++ b/source/main/cardano/CardanoNode.js @@ -663,7 +663,10 @@ export class CardanoNode { if (_node == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(_node.pid, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + _node.pid, + CARDANO_PROCESS_NAME + ); }; _ensurePreviousCardanoNodeIsNotRunning = async (): Promise => { @@ -676,7 +679,10 @@ export class CardanoNode { if (previousPID == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(previousPID, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + previousPID, + CARDANO_PROCESS_NAME + ); }; _isProcessRunning = async ( diff --git a/source/main/ipc/download-logs.js b/source/main/ipc/download-logs.js index 9cc2dc539c..05d44bf491 100644 --- a/source/main/ipc/download-logs.js +++ b/source/main/ipc/download-logs.js @@ -17,7 +17,7 @@ export default () => { const { compressedLogsFilePath, destinationPath } = request; if (!fs.existsSync(compressedLogsFilePath)) { - return Promise.reject('File does not exist'); + return Promise.reject(new Error('File does not exist')); } const file = fs.readFileSync(compressedLogsFilePath); diff --git a/source/main/utils/setupLogging.js b/source/main/utils/setupLogging.js index 146353da5d..0aad4328d6 100644 --- a/source/main/utils/setupLogging.js +++ b/source/main/utils/setupLogging.js @@ -20,7 +20,7 @@ const isTest = process.env.NODE_ENV === 'test'; const isDev = process.env.NODE_ENV === 'development'; export const setupLogging = () => { - const logFilePath = path.join(pubLogsFolderPath, APP_NAME + '.json'); + const logFilePath = path.join(pubLogsFolderPath, `${APP_NAME}.json`); ensureDirectoryExists(pubLogsFolderPath); log.transports.console.level = isTest ? 'error' : 'info'; log.transports.rendererConsole.level = isDev ? 'info' : 'error'; @@ -60,6 +60,7 @@ export const setupLogging = () => { try { fs.unlinkSync(logFile); } catch (error) { + // eslint-disable-next-line console.error( `Compressed log file "${logFile}" deletion failed: ${error}` ); diff --git a/source/renderer/app/api/utils/request.js b/source/renderer/app/api/utils/request.js index 18ccfc236d..e4a4c190d7 100644 --- a/source/renderer/app/api/utils/request.js +++ b/source/renderer/app/api/utils/request.js @@ -72,7 +72,7 @@ function typedRequest( httpsRequest.on('response', response => { let body = ''; // Cardano-sl returns chunked requests, so we need to concat them - response.on('data', chunk => (body += chunk)); + response.on('data', chunk => {body += chunk}); // Reject errors response.on('error', error => reject(error)); // Resolve JSON results and handle backend errors diff --git a/source/renderer/app/api/utils/requestV0.js b/source/renderer/app/api/utils/requestV0.js index e7ba262645..85b390b68f 100644 --- a/source/renderer/app/api/utils/requestV0.js +++ b/source/renderer/app/api/utils/requestV0.js @@ -70,7 +70,7 @@ function typedRequest( httpsRequest.on('response', response => { let body = ''; // Cardano-sl returns chunked requests, so we need to concat them - response.on('data', chunk => (body += chunk)); + response.on('data', chunk => {body += chunk}); // Reject errors response.on('error', error => reject(error)); // Resolve JSON results and handle weird backend behavior diff --git a/source/renderer/app/components/loading/Loading.js b/source/renderer/app/components/loading/Loading.js index c4c13bd76d..572a88cc2b 100644 --- a/source/renderer/app/components/loading/Loading.js +++ b/source/renderer/app/components/loading/Loading.js @@ -235,14 +235,14 @@ export default class Loading extends Component { }; _incrementConnectingTime = () => { - this.setState({ connectingTime: this.state.connectingTime + 1 }); + this.setState(prevState => ({connectingTime: prevState.connectingTime + 1})); }; _incrementSyncingTime = () => { const syncPercentage = this.props.syncPercentage.toFixed(2); if (syncPercentage === this.state.syncPercentage) { // syncPercentage not increased, increase syncing time - this.setState({ syncingTime: this.state.syncingTime + 1 }); + this.setState(prevState => ({syncingTime: prevState.syncingTime + 1})); } else { // reset syncingTime and set new max percentage this.setState({ syncingTime: 0, syncPercentage }); diff --git a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js index ecd3328b64..d5c35eb851 100644 --- a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js +++ b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js @@ -53,7 +53,7 @@ export default class TermsOfUseForm extends Component { }; toggleAcceptance() { - this.setState({ areTermsOfUseAccepted: !this.state.areTermsOfUseAccepted }); + this.setState(prevState => ({areTermsOfUseAccepted: !prevState.areTermsOfUseAccepted})); } submit = () => { diff --git a/source/renderer/app/components/sidebar/Sidebar.js b/source/renderer/app/components/sidebar/Sidebar.js index f28d541676..761decae5e 100644 --- a/source/renderer/app/components/sidebar/Sidebar.js +++ b/source/renderer/app/components/sidebar/Sidebar.js @@ -83,11 +83,11 @@ export default class Sidebar extends Component { return (
- {categories.map((category, index) => { + {categories.map((category) => { const categoryClassName = kebabCase(category.name); return ( { minPointSize={2} isAnimationActive={false} > - {data.slice().map((entry, index) => { + {data.slice().map((entry) => { let fillColor = '#c2cad4'; let cursor = 'pointer'; - if (index === activeIndex) fillColor = '#445b7c'; + if (entry.id === activeIndex) fillColor = '#445b7c'; if (entry.numberOfTransactions === 0) { fillColor = '#e7eaee'; cursor = 'default'; } return ( - + ); })} diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 6db8bfeba1..071110f57a 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,7 +159,6 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); - return true; }; isDisabled = () => diff --git a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js index 39cd2a3e9f..b1d5a8d739 100644 --- a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js +++ b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js @@ -301,7 +301,7 @@ export default class AdaRedemptionForm extends Component { validators: ({ field }) => { if (this.props.redemptionType !== ADA_REDEMPTION_TYPES.PAPER_VENDED) return [true]; - const value = field.value; + const { value } = field; if (value === '') return [ false, diff --git a/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js b/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js index 45ac8753cf..c7dd4d8675 100644 --- a/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js +++ b/source/renderer/app/components/wallet/backup-recovery/WalletRecoveryPhraseEntryDialog.js @@ -148,7 +148,7 @@ export default class WalletRecoveryPhraseEntryDialog extends Component { return ( { } onConfirmCorrectPrinting = () => { - this.setState({ isPrintedCorrectly: !this.state.isPrintedCorrectly }); + this.setState(prevState => ({isPrintedCorrectly: !prevState.isPrintedCorrectly})); }; onConfirmReadable = () => { - this.setState({ isReadable: !this.state.isReadable }); + this.setState(prevState => ({isReadable: !prevState.isReadable})); }; onConfirmScannable = () => { - this.setState({ isScannable: !this.state.isScannable }); + this.setState(prevState => ({isScannable: !prevState.isScannable})); }; } diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js index b4dc2e894a..d9d336c92f 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js @@ -125,8 +125,8 @@ export default class SecuringPasswordDialog extends Component { } onSecurePasswordConfirmationChange = () => { - this.setState({ - securePasswordConfirmed: !this.state.securePasswordConfirmed, - }); + this.setState( + prevState => ({securePasswordConfirmed: !prevState.securePasswordConfirmed}) + ); }; } diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js index 36a75fad36..0f265c9c21 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js @@ -311,14 +311,14 @@ export default class VerificationDialog extends Component { } onStoringConfirmationChange = () => { - this.setState({ - storingConfirmed: !this.state.storingConfirmed, - }); + this.setState( + prevState => ({storingConfirmed: !prevState.storingConfirmed}) + ); }; onRecoveringConfirmationChange = () => { - this.setState({ - recoveringConfirmed: !this.state.recoveringConfirmed, - }); + this.setState( + prevState => ({recoveringConfirmed: !prevState.recoveringConfirmed}) + ); }; } diff --git a/source/renderer/app/components/wallet/receive/Address.js b/source/renderer/app/components/wallet/receive/Address.js index f2fc236df0..3e7a49d3e6 100644 --- a/source/renderer/app/components/wallet/receive/Address.js +++ b/source/renderer/app/components/wallet/receive/Address.js @@ -20,7 +20,7 @@ export class Address extends Component { render() { const { address, onCopyAddress, copyAddressLabel, index } = this.props; const addressClasses = classnames([ - 'generatedAddress-' + (index + 1), + `generatedAddress-${index + 1}`, styles.component, address.used ? styles.usedWalletAddress : null, ]); diff --git a/source/renderer/app/components/wallet/receive/VirtualAddressesList.js b/source/renderer/app/components/wallet/receive/VirtualAddressesList.js index 8de5d750ce..fd1a08f4b7 100644 --- a/source/renderer/app/components/wallet/receive/VirtualAddressesList.js +++ b/source/renderer/app/components/wallet/receive/VirtualAddressesList.js @@ -109,7 +109,7 @@ export class VirtualAddressesList extends Component { {({ width, height }) => ( (this.list = list)} + ref={list => {this.list = list}} width={width} height={height} rowCount={rows.length} diff --git a/source/renderer/app/components/wallet/receive/WalletReceive.js b/source/renderer/app/components/wallet/receive/WalletReceive.js index 95139b743e..52d24ed526 100644 --- a/source/renderer/app/components/wallet/receive/WalletReceive.js +++ b/source/renderer/app/components/wallet/receive/WalletReceive.js @@ -100,7 +100,7 @@ export default class WalletReceive extends Component { passwordField: Input; toggleUsedAddresses = () => { - this.setState({ showUsed: !this.state.showUsed }); + this.setState(prevState => ({showUsed: !prevState.showUsed})); }; form = new ReactToolboxMobxForm( diff --git a/source/renderer/app/components/wallet/transactions/Transaction.js b/source/renderer/app/components/wallet/transactions/Transaction.js index d175141f3c..9d91b0bd08 100644 --- a/source/renderer/app/components/wallet/transactions/Transaction.js +++ b/source/renderer/app/components/wallet/transactions/Transaction.js @@ -284,11 +284,11 @@ export default class Transaction extends Component { >

{intl.formatMessage(messages.fromAddresses)}

- {data.addresses.from.map((address, addressIndex) => ( + {data.addresses.from.map((address) => ( { ))}

{intl.formatMessage(messages.toAddresses)}

- {data.addresses.to.map((address, addressIndex) => ( + {data.addresses.to.map((address) => ( { {isRenderingAsVirtualList ? ( (this.virtualList = list)} + ref={list => {this.virtualList = list}} renderRow={this.renderItem} rows={rows} isLoadingSpinnerShown={loadingSpinner !== null} @@ -300,7 +300,7 @@ export default class WalletTransactionsList extends Component { /> ) : ( (this.simpleList = list)} + ref={list => {this.simpleList = list}} renderRow={this.renderItem} rows={rows} /> diff --git a/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js b/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js index 9ebad148f2..458c84228a 100644 --- a/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js +++ b/source/renderer/app/components/wallet/transactions/render-strategies/SimpleTransactionList.js @@ -20,8 +20,8 @@ export class SimpleTransactionList extends Component { const { rows, renderRow } = this.props; return (
- {rows.map((row, index) => ( -
{renderRow(row)}
+ {rows.map((row) => ( +
{renderRow(row)}
))}
); diff --git a/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js b/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js index 6110994607..fb58f4ebfe 100644 --- a/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js +++ b/source/renderer/app/components/wallet/transactions/render-strategies/VirtualTransactionList.js @@ -91,7 +91,7 @@ export class VirtualTransactionList extends Component { estimateHeightOfTxExpandedRow = (row: Row, tx: WalletTransaction): number => { if (!this.txAddressHeight) this.updateAddressesAndIdHeights(); const txSingleAddressHeight = this.txAddressHeight; - const txIdHeight = this.txIdHeight; + const txIdHeightValue = this.txIdHeight; const { addresses } = tx; const txAddressesCount = addresses.from.length + addresses.to.length; const txAddressesHeight = txAddressesCount * txSingleAddressHeight; @@ -99,7 +99,7 @@ export class VirtualTransactionList extends Component { return ( TX_EXPANDED_ROW_BASE_HEIGHT + txAddressesHeight + - txIdHeight + + txIdHeightValue + txBottomMargin ); }; @@ -181,10 +181,7 @@ export class VirtualTransactionList extends Component { checkIfTxContentIsFullyExpanded = (tx: WalletTransaction): boolean => { const txRow = this.getTxRowElementById(tx.id); const txElement = txRow && txRow.firstChild; - const isFullyExpanded = - txElement instanceof HTMLElement && - txElement.classList.contains('Transaction_expanded'); - return isFullyExpanded; + return ((txElement instanceof HTMLElement) && (txElement.classList.contains('Transaction_expanded'))); }; /** @@ -296,7 +293,7 @@ export class VirtualTransactionList extends Component { {({ width, height }) => ( (this.list = list)} + ref={list => {this.list = list}} width={width} height={height} onRowsRendered={throttle(this.onRowsRendered, 100, { diff --git a/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js b/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js index 1d79bcc940..3b7c56ffe7 100644 --- a/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js +++ b/source/renderer/app/containers/wallet/PaperWalletCreateCertificatePage.js @@ -117,7 +117,7 @@ export default class PaperWalletCreateCertificatePage extends Component< }; onBack = () => { - const prevStep = this.state.currentStep ? this.state.currentStep - 1 : 0; + const prevStep = this.state.currentStep ? this.state.currentStep - 1 : 0; const prevDialog = this.CREATE_CERTIFICATE_DIALOGS[prevStep]; this.setState({ currentStep: prevStep }); this.switchDialog(prevDialog); diff --git a/source/renderer/app/containers/wallet/WalletReceivePage.js b/source/renderer/app/containers/wallet/WalletReceivePage.js index ffa7febd52..b56964519b 100755 --- a/source/renderer/app/containers/wallet/WalletReceivePage.js +++ b/source/renderer/app/containers/wallet/WalletReceivePage.js @@ -68,7 +68,7 @@ export default class WalletReceivePage extends Component { render() { const { copiedAddress } = this.state; - const actions = this.props.actions; + const { actions } = this.props; const { sidebar, uiNotifications, wallets, addresses } = this.props.stores; const wallet = wallets.active; diff --git a/source/renderer/app/stores/AdaRedemptionStore.js b/source/renderer/app/stores/AdaRedemptionStore.js index ca1ce5dbd5..7c35fb4655 100644 --- a/source/renderer/app/stores/AdaRedemptionStore.js +++ b/source/renderer/app/stores/AdaRedemptionStore.js @@ -182,32 +182,32 @@ export default class AdaRedemptionStore extends Store { 'AdaRedemptionStore: Parsing ADA Redemption code from certificate', { path } ); - let decryptionKey = null; + let decryptionKeyValue = null; if ( (this.redemptionType === ADA_REDEMPTION_TYPES.REGULAR || this.redemptionType === ADA_REDEMPTION_TYPES.RECOVERY_REGULAR) && this.isCertificateEncrypted ) { - decryptionKey = this.passPhrase; + decryptionKeyValue = this.passPhrase; } if ( this.redemptionType === ADA_REDEMPTION_TYPES.FORCE_VENDED && this.isCertificateEncrypted ) { - decryptionKey = [this.email, this.adaPasscode, this.adaAmount]; + decryptionKeyValue = [this.email, this.adaPasscode, this.adaAmount]; } if ( this.redemptionType === ADA_REDEMPTION_TYPES.RECOVERY_FORCE_VENDED && this.isCertificateEncrypted ) { - decryptionKey = this.decryptionKey; + decryptionKeyValue = this.decryptionKey; } // PARSING try { const redemptionCode = await parseRedemptionCodeChannel.request({ certificateFilePath: path, redemptionType: this.redemptionType, - decryptionKey, + decryptionKey: decryptionKeyValue, }); this._setRedemptionCode({ redemptionCode }); } catch (e) { @@ -231,7 +231,7 @@ export default class AdaRedemptionStore extends Store { walletId: string, spendingPassword: ?string, }) => { - runInAction(() => (this.walletId = walletId)); + runInAction(() => {this.walletId = walletId}); const accountIndex = await this.stores.addresses.getAccountIndexByWalletId( walletId @@ -254,7 +254,7 @@ export default class AdaRedemptionStore extends Store { amount: transaction.amount.toFormat(DECIMAL_PLACES_IN_ADA), }); } catch (error) { - runInAction(() => (this.error = error)); + runInAction(() => {this.error = error}); } }; @@ -267,7 +267,7 @@ export default class AdaRedemptionStore extends Store { shieldedRedemptionKey: string, spendingPassword: ?string, }) => { - runInAction(() => (this.walletId = walletId)); + runInAction(() => {this.walletId = walletId}); const accountIndex = await this.stores.addresses.getAccountIndexByWalletId( walletId @@ -291,7 +291,7 @@ export default class AdaRedemptionStore extends Store { amount: transaction.amount.toFormat(DECIMAL_PLACES_IN_ADA), }); } catch (error) { - runInAction(() => (this.error = error)); + runInAction(() => {this.error = error}); } }; diff --git a/source/renderer/app/stores/NetworkStatusStore.js b/source/renderer/app/stores/NetworkStatusStore.js index 440984037e..7c1df541fe 100644 --- a/source/renderer/app/stores/NetworkStatusStore.js +++ b/source/renderer/app/stores/NetworkStatusStore.js @@ -277,7 +277,7 @@ export default class NetworkStatusStore extends Store { case CardanoNodeStates.STOPPING: case CardanoNodeStates.EXITING: case CardanoNodeStates.UPDATING: - runInAction('reset _tlsConfig', () => (this._tlsConfig = null)); + runInAction('reset _tlsConfig', () => {this._tlsConfig = null}); this._setDisconnected(wasConnected); break; default: @@ -534,7 +534,7 @@ export default class NetworkStatusStore extends Store { if (!this.hasBeenConnected) { runInAction( 'update hasBeenConnected', - () => (this.hasBeenConnected = true) + () => {this.hasBeenConnected = true} ); } Logger.debug('NetworkStatusStore: Connection Lost. Reconnecting...'); @@ -565,7 +565,7 @@ export default class NetworkStatusStore extends Store { if (!this.hasBeenConnected) { runInAction( 'update hasBeenConnected', - () => (this.hasBeenConnected = true) + () => {this.hasBeenConnected = true} ); } Logger.debug('NetworkStatusStore: Connection Lost. Reconnecting...'); diff --git a/source/renderer/app/stores/lib/Request.js b/source/renderer/app/stores/lib/Request.js index 760373f757..e9b5ec636f 100644 --- a/source/renderer/app/stores/lib/Request.js +++ b/source/renderer/app/stores/lib/Request.js @@ -45,7 +45,7 @@ export default class Request { // Issue api call & save it as promise that is handled to update the results of the operation this.promise = new Promise((resolve, reject) => { - if (!this._method) reject('Request method not defined'); + if (!this._method) reject(new Error('Request method not defined')); this._method(...callArgs) .then(result => { setTimeout( diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 59e6b84656..0cfbe83660 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,7 +188,6 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } - return false; }} isInvalid={false} isSubmitting={false} From bed680dcd965d9449f55937b036e0f5066000d9f Mon Sep 17 00:00:00 2001 From: Nikola Glumac Date: Wed, 20 Mar 2019 16:18:54 +0100 Subject: [PATCH 21/45] [DDW-595] Fix regex issue --- source/renderer/app/utils/routing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/renderer/app/utils/routing.js b/source/renderer/app/utils/routing.js index 2f95f62c95..617daeb004 100644 --- a/source/renderer/app/utils/routing.js +++ b/source/renderer/app/utils/routing.js @@ -67,7 +67,7 @@ export const buildRoute = (pattern, params) => { // - '/path/:param(/:another_param)' // - '/path(/:param/:another_param)' const paramRegex = new RegExp( - `(/|\\(|\\)|^):${paramName}(/|)|(|$)` + `(/|\\(|\\)|^):${paramName}(/|\\)|\\(|$)` ); routePath = routePath.replace(paramRegex, (match, g1, g2) => { tokens[paramName] = encodeURIComponent(paramValue); From eac81d21fd2baa6d6fdd7c443ece003c3f4c69de Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 19:52:52 +0100 Subject: [PATCH 22/45] [DDW-595] Fix lint warnings Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/main/cardano/CardanoNode.js | 10 ++-------- storybook/stories/WalletScreens.stories.js | 1 + 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index c8a6bf7776..e8e204aec2 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - return context.app.stop(); + await context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index abda367b45..5e4813b619 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - await client.waitUntil(async () => { + client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return await client.elements(selectSelector); + return client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index 57e8465d2e..ab9df8a927 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - await client.executeAsync( + client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/main/cardano/CardanoNode.js b/source/main/cardano/CardanoNode.js index d94d9f2323..9a06b51236 100644 --- a/source/main/cardano/CardanoNode.js +++ b/source/main/cardano/CardanoNode.js @@ -663,10 +663,7 @@ export class CardanoNode { if (_node == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning( - _node.pid, - CARDANO_PROCESS_NAME - ); + return this._ensureProcessIsNotRunning(_node.pid, CARDANO_PROCESS_NAME); }; _ensurePreviousCardanoNodeIsNotRunning = async (): Promise => { @@ -679,10 +676,7 @@ export class CardanoNode { if (previousPID == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning( - previousPID, - CARDANO_PROCESS_NAME - ); + return this._ensureProcessIsNotRunning(previousPID, CARDANO_PROCESS_NAME); }; _isProcessRunning = async ( diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 0cfbe83660..59e6b84656 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,6 +188,7 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } + return false; }} isInvalid={false} isSubmitting={false} From e83ac7d798d3c66968a639baa6fb353b1d19734a Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 23:10:55 +0100 Subject: [PATCH 23/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- source/renderer/app/components/wallet/WalletSendForm.js | 1 + 1 file changed, 1 insertion(+) diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 071110f57a..6db8bfeba1 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,6 +159,7 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); + return true; }; isDisabled = () => From 87d1f123a4221e20e4344978bb7c4a204663c0a2 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 14:05:04 +0100 Subject: [PATCH 24/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/main/cardano/CardanoNode.js | 10 ++++++++-- .../renderer/app/components/wallet/WalletSendForm.js | 1 - storybook/stories/WalletScreens.stories.js | 1 - 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index e8e204aec2..c8a6bf7776 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - await context.app.stop(); + return context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index 5e4813b619..abda367b45 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - client.waitUntil(async () => { + await client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return client.elements(selectSelector); + return await client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index ab9df8a927..57e8465d2e 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - client.executeAsync( + await client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/main/cardano/CardanoNode.js b/source/main/cardano/CardanoNode.js index 9a06b51236..d94d9f2323 100644 --- a/source/main/cardano/CardanoNode.js +++ b/source/main/cardano/CardanoNode.js @@ -663,7 +663,10 @@ export class CardanoNode { if (_node == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(_node.pid, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + _node.pid, + CARDANO_PROCESS_NAME + ); }; _ensurePreviousCardanoNodeIsNotRunning = async (): Promise => { @@ -676,7 +679,10 @@ export class CardanoNode { if (previousPID == null) { return Promise.resolve(); } - return this._ensureProcessIsNotRunning(previousPID, CARDANO_PROCESS_NAME); + return this._ensureProcessIsNotRunning( + previousPID, + CARDANO_PROCESS_NAME + ); }; _isProcessRunning = async ( diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 6db8bfeba1..071110f57a 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,7 +159,6 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); - return true; }; isDisabled = () => diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 59e6b84656..0cfbe83660 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,7 +188,6 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } - return false; }} isInvalid={false} isSubmitting={false} From acdde185c6eebc2d4d7e7cfabecac774bcddc5e0 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 19:52:52 +0100 Subject: [PATCH 25/45] [DDW-595] Fix lint warnings Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- storybook/stories/WalletScreens.stories.js | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index c8a6bf7776..e8e204aec2 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - return context.app.stop(); + await context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index abda367b45..5e4813b619 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - await client.waitUntil(async () => { + client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return await client.elements(selectSelector); + return client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index 57e8465d2e..ab9df8a927 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - await client.executeAsync( + client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 0cfbe83660..59e6b84656 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,6 +188,7 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } + return false; }} isInvalid={false} isSubmitting={false} From 8a4b392f05c5f24da30a622c6e5e6a19aac29bc0 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Tue, 19 Mar 2019 23:10:55 +0100 Subject: [PATCH 26/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- source/renderer/app/components/wallet/WalletSendForm.js | 1 + 1 file changed, 1 insertion(+) diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 071110f57a..6db8bfeba1 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,6 +159,7 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); + return true; }; isDisabled = () => From 662bf430a037a56b4de705a44f2d3eecbe314fe2 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 14:05:04 +0100 Subject: [PATCH 27/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/electron.js | 2 +- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/renderer/app/components/wallet/WalletSendForm.js | 1 - storybook/stories/WalletScreens.stories.js | 1 - 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/features/support/electron.js b/features/support/electron.js index e8e204aec2..c8a6bf7776 100644 --- a/features/support/electron.js +++ b/features/support/electron.js @@ -139,5 +139,5 @@ AfterAll(async () => { ); return; } - await context.app.stop(); + return context.app.stop(); }); diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index 5e4813b619..abda367b45 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - client.waitUntil(async () => { + await client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return client.elements(selectSelector); + return await client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index ab9df8a927..57e8465d2e 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - client.executeAsync( + await client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/renderer/app/components/wallet/WalletSendForm.js b/source/renderer/app/components/wallet/WalletSendForm.js index 6db8bfeba1..071110f57a 100755 --- a/source/renderer/app/components/wallet/WalletSendForm.js +++ b/source/renderer/app/components/wallet/WalletSendForm.js @@ -159,7 +159,6 @@ export default class WalletSendForm extends Component { this.props.openDialogAction({ dialog: WalletSendConfirmationDialog, }); - return true; }; isDisabled = () => diff --git a/storybook/stories/WalletScreens.stories.js b/storybook/stories/WalletScreens.stories.js index 59e6b84656..0cfbe83660 100644 --- a/storybook/stories/WalletScreens.stories.js +++ b/storybook/stories/WalletScreens.stories.js @@ -188,7 +188,6 @@ storiesOf('WalletScreens', module) if (dialog === ExportWalletToFileDialog) { return boolean('Export Wallet - Show dialog', false); } - return false; }} isInvalid={false} isSubmitting={false} From e901ab3a29b3eb1ddc56721afaf80e9c807d2f24 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 17:22:06 +0100 Subject: [PATCH 28/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- flow/mappers/CSSModule.js.flow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow/mappers/CSSModule.js.flow b/flow/mappers/CSSModule.js.flow index 023d00a59e..c98cc4de57 100644 --- a/flow/mappers/CSSModule.js.flow +++ b/flow/mappers/CSSModule.js.flow @@ -1,2 +1,2 @@ // @flow -declare export default { [key]: string } +declare export default { [string]: string } From 9beb59456041f2e9213fcb5129eaab50cf79d324 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 18:29:54 +0100 Subject: [PATCH 29/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- source/renderer/app/components/sidebar/Sidebar.js | 5 +++-- .../backup-recovery/WalletRecoveryPhraseEntryDialog.js | 3 ++- .../app/components/wallet/transactions/Transaction.js | 10 ++++++---- .../render-strategies/SimpleTransactionList.js | 5 +++-- .../components/widgets/forms/MnemonicInputWidget.js | 3 ++- source/renderer/app/stores/lib/Request.js | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/source/renderer/app/components/sidebar/Sidebar.js b/source/renderer/app/components/sidebar/Sidebar.js index 761decae5e..b1a5e02135 100644 --- a/source/renderer/app/components/sidebar/Sidebar.js +++ b/source/renderer/app/components/sidebar/Sidebar.js @@ -83,11 +83,12 @@ export default class Sidebar extends Component { return (
- {categories.map((category) => { + {categories.map((category, index) => { const categoryClassName = kebabCase(category.name); return ( { return ( { >

{intl.formatMessage(messages.fromAddresses)}

- {data.addresses.from.map((address) => ( + {data.addresses.from.map((address, addressIndex) => ( { ))}

{intl.formatMessage(messages.toAddresses)}

- {data.addresses.to.map((address) => ( + {data.addresses.to.map((address, addressIndex) => ( { const { rows, renderRow } = this.props; return (
- {rows.map((row) => ( -
{renderRow(row)}
+ {rows.map((row, index) => ( + // eslint-disable-next-line +
{renderRow(row)}
))}
); diff --git a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js index 833e105f9a..631c7cec09 100644 --- a/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js +++ b/source/renderer/app/components/widgets/forms/MnemonicInputWidget.js @@ -26,7 +26,8 @@ export default class MnemonicInputWidget extends Component { onTokenChanged(index, value)} diff --git a/source/renderer/app/stores/lib/Request.js b/source/renderer/app/stores/lib/Request.js index e9b5ec636f..76b3bbbf65 100644 --- a/source/renderer/app/stores/lib/Request.js +++ b/source/renderer/app/stores/lib/Request.js @@ -45,7 +45,7 @@ export default class Request { // Issue api call & save it as promise that is handled to update the results of the operation this.promise = new Promise((resolve, reject) => { - if (!this._method) reject(new Error('Request method not defined')); + if (!this._method) reject(new ReferenceError('Request method not defined')); this._method(...callArgs) .then(result => { setTimeout( From 8862b5dcaed043368d0e81a21853e6308a386cb2 Mon Sep 17 00:00:00 2001 From: Aleksandar Djordjevic Date: Wed, 20 Mar 2019 22:37:22 +0100 Subject: [PATCH 30/45] [DDW-595] Fix lint warnings - Adding fixes for es linter --- features/support/helpers/shared-helpers.js | 4 ++-- features/support/helpers/wallets-helpers.js | 2 +- source/main/ipc/index.js | 1 + source/main/ipc/load-asset.js | 6 +++++- source/main/menus/osx.js | 8 +++++--- source/main/menus/win-linux.js | 8 +++++--- source/main/utils/rendererErrorHandler.js | 1 + source/renderer/app/ThemeManager.js | 2 ++ .../profile/terms-of-use/TermsOfUseForm.js | 4 +++- .../app/components/wallet/WalletCreateDialog.js | 8 +++++--- .../app/components/wallet/WalletRestoreDialog.js | 8 +++++--- .../app/components/wallet/WalletSendForm.js | 7 +++---- .../wallet/ada-redemption/AdaRedemptionForm.js | 16 +++++++++------- .../wallet/backup-recovery/MnemonicWord.js | 1 + .../paper-wallet-certificate/PrintDialog.js | 13 ++++++++++--- .../SecuringPasswordDialog.js | 7 ++++++- .../VerificationDialog.js | 10 ++++++++-- .../app/components/wallet/receive/Address.js | 1 + .../components/wallet/receive/WalletReceive.js | 6 +++++- .../settings/ChangeSpendingPasswordDialog.js | 10 +++++----- .../settings/DeleteWalletConfirmationDialog.js | 1 + .../wallet/settings/ExportWalletToFileDialog.js | 4 +++- .../transactions/WalletTransactionsList.js | 1 + .../widgets/forms/InlineEditingInput.js | 1 + .../wallet/PaperWalletCreateCertificatePage.js | 1 + source/renderer/app/utils/form.js | 2 ++ 26 files changed, 92 insertions(+), 41 deletions(-) diff --git a/features/support/helpers/shared-helpers.js b/features/support/helpers/shared-helpers.js index abda367b45..5e4813b619 100644 --- a/features/support/helpers/shared-helpers.js +++ b/features/support/helpers/shared-helpers.js @@ -16,7 +16,7 @@ export const expectTextInSelector = async (client, { selector, text }) => { }; export const waitUntilTextInSelector = async (client, { selector, text }) => - await client.waitUntil(async () => { + client.waitUntil(async () => { await client.waitForText(selector); let textOnScreen = await client.getText(selector); // The selector could exist multiple times in the DOM @@ -32,7 +32,7 @@ export const getVisibleElementsForSelector = async ( ...waitArgs ) => { await client.waitForVisible(waitSelector, ...waitArgs); - return await client.elements(selectSelector); + return client.elements(selectSelector); }; export const getVisibleElementsCountForSelector = async ( diff --git a/features/support/helpers/wallets-helpers.js b/features/support/helpers/wallets-helpers.js index 57e8465d2e..ab9df8a927 100644 --- a/features/support/helpers/wallets-helpers.js +++ b/features/support/helpers/wallets-helpers.js @@ -77,7 +77,7 @@ export const importWalletWithFunds = async ( client, { keyFilePath, password } ) => - await client.executeAsync( + client.executeAsync( (filePath, spendingPassword, done) => { daedalus.api.ada .importWalletFromKey({ filePath, spendingPassword }) diff --git a/source/main/ipc/index.js b/source/main/ipc/index.js index aeb2741635..eaf3bc69f8 100644 --- a/source/main/ipc/index.js +++ b/source/main/ipc/index.js @@ -20,6 +20,7 @@ export default (window: BrowserWindow) => { getGpuStatus(); handleBugReportRequests(); handlePaperWalletRequests(); + // eslint-disable-next-line openExternalUrlChannel; setupParseRedemptionCodeHandler(); }; diff --git a/source/main/ipc/load-asset.js b/source/main/ipc/load-asset.js index bf3c0e4dd7..8767852d59 100644 --- a/source/main/ipc/load-asset.js +++ b/source/main/ipc/load-asset.js @@ -18,7 +18,11 @@ export default () => { const asset = path.resolve(__dirname, `../renderer/${request.fileName}`); return new Promise((resolve, reject) => fs.readFile(asset, 'base64', (error, data) => { - error ? reject(error) : resolve(data); + if (error) { + reject(error); + } else { + resolve(data); + } }) ); }); diff --git a/source/main/menus/osx.js b/source/main/menus/osx.js index 2b38be6cd4..45b856cc84 100644 --- a/source/main/menus/osx.js +++ b/source/main/menus/osx.js @@ -34,9 +34,11 @@ export const osxMenu = ( type: 'checkbox', checked: isInSafeMode, click() { - isInSafeMode - ? actions.restartWithoutSafeMode() - : actions.restartInSafeMode(); + if (isInSafeMode) { + actions.restartWithoutSafeMode(); + } else { + actions.restartInSafeMode(); + } }, }, { diff --git a/source/main/menus/win-linux.js b/source/main/menus/win-linux.js index 9cc0e08962..dc7cae0549 100644 --- a/source/main/menus/win-linux.js +++ b/source/main/menus/win-linux.js @@ -35,9 +35,11 @@ export const winLinuxMenu = ( type: 'checkbox', checked: isInSafeMode, click() { - isInSafeMode - ? actions.restartWithoutSafeMode() - : actions.restartInSafeMode(); + if (isInSafeMode) { + actions.restartWithoutSafeMode(); + } else { + actions.restartInSafeMode(); + } }, }, { diff --git a/source/main/utils/rendererErrorHandler.js b/source/main/utils/rendererErrorHandler.js index 0f09b16324..207fdb8546 100644 --- a/source/main/utils/rendererErrorHandler.js +++ b/source/main/utils/rendererErrorHandler.js @@ -25,6 +25,7 @@ export default class RendererErrorHandler { if (this.count < this.maxReloads) { this.count++; + // eslint-disable-next-line this.createMainWindow && this.createMainWindow(); } else { this.count = 0; diff --git a/source/renderer/app/ThemeManager.js b/source/renderer/app/ThemeManager.js index 4ee9887514..410d32d519 100644 --- a/source/renderer/app/ThemeManager.js +++ b/source/renderer/app/ThemeManager.js @@ -3,6 +3,7 @@ import { map } from 'lodash'; export default class ThemeManager extends Component { componentDidMount() { + // eslint-disable-next-line this.updateCSSVariables(this.props.variables); } @@ -18,6 +19,7 @@ export default class ThemeManager extends Component { }); } render() { + // eslint-disable-next-line return {this.props.children}; } } diff --git a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js index d5c35eb851..8a2910a769 100644 --- a/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js +++ b/source/renderer/app/components/profile/terms-of-use/TermsOfUseForm.js @@ -52,6 +52,8 @@ export default class TermsOfUseForm extends Component { areTermsOfUseAccepted: false, }; + toggleAcceptance = this.toggleAcceptance.bind(this); + toggleAcceptance() { this.setState(prevState => ({areTermsOfUseAccepted: !prevState.areTermsOfUseAccepted})); } @@ -77,7 +79,7 @@ export default class TermsOfUseForm extends Component {
diff --git a/source/renderer/app/components/wallet/WalletCreateDialog.js b/source/renderer/app/components/wallet/WalletCreateDialog.js index 1934d07e79..11612650a9 100644 --- a/source/renderer/app/components/wallet/WalletCreateDialog.js +++ b/source/renderer/app/components/wallet/WalletCreateDialog.js @@ -177,6 +177,8 @@ export default class WalletCreateDialog extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -234,7 +236,7 @@ export default class WalletCreateDialog extends Component { > { this.walletNameInput = input; }} @@ -260,14 +262,14 @@ export default class WalletCreateDialog extends Component {
{ this.setState({ createPassword: value }); }; + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -384,7 +386,7 @@ export default class WalletRestoreDialog extends Component { {
{ componentWillUnmount() { this._isMounted = false; } + submitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit); handleOnSubmit = () => { if (this.isDisabled()) { @@ -243,8 +244,6 @@ export default class WalletSendForm extends Component { } ); - submitOnEnter = submitOnEnter.bind(this, this.handleOnSubmit); - render() { const { form } = this; const { intl } = this.context; @@ -299,7 +298,7 @@ export default class WalletSendForm extends Component { receiverField.onChange(value || ''); }} skin={InputSkin} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} />
@@ -320,7 +319,7 @@ export default class WalletSendForm extends Component { fees={fees} total={total} skin={AmountInputSkin} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} />
diff --git a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js index b1d5a8d739..d29d881cb6 100644 --- a/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js +++ b/source/renderer/app/components/wallet/ada-redemption/AdaRedemptionForm.js @@ -424,6 +424,8 @@ export default class AdaRedemptionForm extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -609,7 +611,7 @@ export default class AdaRedemptionForm extends Component {
{redemptionType !== ADA_REDEMPTION_TYPES.PAPER_VENDED ? ( { /> ) : ( { {walletHasPassword ? (
{ {showInputForDecryptionKey ? (
{ {showInputsForDecryptingForceVendedCertificate ? (
{ {showInputsForDecryptingForceVendedCertificate ? (
{ {showInputsForDecryptingForceVendedCertificate ? (
{ themeOverrides={styles} disabled={!isActive} label={word} + // eslint-disable-next-line onClick={handleClick} skin={ButtonSkin} /> diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js index d488eabb3b..ee3fb16876 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/PrintDialog.js @@ -82,6 +82,13 @@ export default class PrintDialog extends Component { isScannable: false, }; + constructor(props: Props) { + super(props); + this.onConfirmReadable = this.onConfirmReadable.bind(this); + this.onConfirmScannable = this.onConfirmScannable.bind(this); + this.onConfirmCorrectPrinting = this.onConfirmCorrectPrinting.bind(this); + } + render() { const { intl } = this.context; const { onContinue, onClose } = this.props; @@ -139,7 +146,7 @@ export default class PrintDialog extends Component { label={intl.formatMessage( messages.certificatePrintedConfirmationLabel )} - onChange={this.onConfirmCorrectPrinting.bind(this)} + onChange={this.onConfirmCorrectPrinting} checked={isPrintedCorrectly} skin={CheckboxSkin} /> @@ -152,7 +159,7 @@ export default class PrintDialog extends Component { paperWalletPrintedWordsCount: PAPER_WALLET_PRINTED_WORDS_COUNT, } )} - onChange={this.onConfirmReadable.bind(this)} + onChange={this.onConfirmReadable} checked={isReadable} skin={CheckboxSkin} /> @@ -160,7 +167,7 @@ export default class PrintDialog extends Component { diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js index d9d336c92f..6e220a9925 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/SecuringPasswordDialog.js @@ -63,6 +63,11 @@ export default class SecuringPasswordDialog extends Component { securePasswordConfirmed: false, }; + constructor(props: Props) { + super(props); + this.onSecurePasswordConfirmationChange = this.onSecurePasswordConfirmationChange.bind(this); + } + render() { const { intl } = this.context; const { securePasswordConfirmed } = this.state; @@ -114,7 +119,7 @@ export default class SecuringPasswordDialog extends Component { label={intl.formatMessage(messages.securingPasswordConfirmation, { paperWalletWrittenWordsCount: PAPER_WALLET_WRITTEN_WORDS_COUNT, })} - onChange={this.onSecurePasswordConfirmationChange.bind(this)} + onChange={this.onSecurePasswordConfirmationChange} checked={securePasswordConfirmed} skin={CheckboxSkin} /> diff --git a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js index 0f265c9c21..1556a2e805 100644 --- a/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js +++ b/source/renderer/app/components/wallet/paper-wallet-certificate/VerificationDialog.js @@ -113,6 +113,12 @@ export default class VerificationDialog extends Component { isRecoveryPhraseValid: false, }; + constructor(props: Props) { + super(props); + this.onRecoveringConfirmationChange = this.onRecoveringConfirmationChange.bind(this); + this.onStoringConfirmationChange = this.onStoringConfirmationChange.bind(this); + } + recoveryPhraseAutocomplete: Autocomplete; form = new ReactToolboxMobxForm( @@ -290,7 +296,7 @@ export default class VerificationDialog extends Component { { {
diff --git a/source/renderer/app/components/wallet/receive/WalletReceive.js b/source/renderer/app/components/wallet/receive/WalletReceive.js index 52d24ed526..f8589a4bfc 100644 --- a/source/renderer/app/components/wallet/receive/WalletReceive.js +++ b/source/renderer/app/components/wallet/receive/WalletReceive.js @@ -147,6 +147,8 @@ export default class WalletReceive extends Component { /> ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -159,6 +161,7 @@ export default class WalletReceive extends Component { onError: () => {}, }); + // eslint-disable-next-line this.passwordField && this.passwordField.focus(); }; @@ -211,7 +214,7 @@ export default class WalletReceive extends Component { }} error={passwordField.error} skin={InputSkin} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={this.submitOnEnter} /> )} @@ -255,6 +258,7 @@ export default class WalletReceive extends Component { {walletAddress} diff --git a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js index 85ea395cbf..dde8e532b4 100644 --- a/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js +++ b/source/renderer/app/components/wallet/settings/ChangeSpendingPasswordDialog.js @@ -208,6 +208,8 @@ export default class ChangeSpendingPasswordDialog extends Component< } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -232,8 +234,6 @@ export default class ChangeSpendingPasswordDialog extends Component< this.props.onDataChange({ [key]: value }); }; - submitOnEnter = submitOnEnter.bind(this, this.submit); - render() { const { form } = this; const { intl } = this.context; @@ -316,7 +316,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="currentPassword" label={currentPasswordField.label} value={currentPasswordValue} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} onChange={value => this.handleDataChange('currentPasswordValue', value) } @@ -333,7 +333,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className={newPasswordClasses} label={newPasswordField.label} value={newPasswordValue} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} onChange={value => this.handleDataChange('newPasswordValue', value)} {...newPasswordField.bind()} error={newPasswordField.error} @@ -345,7 +345,7 @@ export default class ChangeSpendingPasswordDialog extends Component< className="repeatedPassword" label={repeatedPasswordField.label} value={repeatedPasswordValue} - onKeyPress={submitOnEnter} + onKeyPress={this.submitOnEnter} onChange={value => this.handleDataChange('repeatedPasswordValue', value) } diff --git a/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js b/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js index 10dd032243..575f5c63ee 100644 --- a/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js +++ b/source/renderer/app/components/wallet/settings/DeleteWalletConfirmationDialog.js @@ -143,6 +143,7 @@ export default class DeleteWalletConfirmationDialog extends Component { className={styles.confirmationInput} label={intl.formatMessage(messages.enterRecoveryWordLabel)} value={confirmationValue} + // eslint-disable-next-line onKeyPress={submitOnEnter.bind(this, handleSubmit)} onChange={onConfirmationValueChange} skin={InputSkin} diff --git a/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js b/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js index 7dc44684d8..18b2246d33 100644 --- a/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js +++ b/source/renderer/app/components/wallet/settings/ExportWalletToFileDialog.js @@ -123,6 +123,8 @@ export default class ExportWalletToFileDialog extends Component { } ); + submitOnEnter = submitOnEnter.bind(this, this.submit); + submit = () => { this.form.submit({ onSuccess: form => { @@ -203,7 +205,7 @@ export default class ExportWalletToFileDialog extends Component { {...spendingPasswordField.bind()} error={spendingPasswordField.error} skin={InputSkin} - onKeyPress={submitOnEnter.bind(this, this.submit)} + onKeyPress={this.submitOnEnter} /> ) : null} diff --git a/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js b/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js index 0b6f5103b4..7174ef1619 100644 --- a/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js +++ b/source/renderer/app/components/wallet/transactions/WalletTransactionsList.js @@ -281,6 +281,7 @@ export default class WalletTransactionsList extends Component {