Skip to content

Commit

Permalink
Merge pull request #1352 from input-output-hk/chore/ddw-595-fix-lint-…
Browse files Browse the repository at this point in the history
…warnings

[DDW-595] Fix lint warnings
  • Loading branch information
nikolaglumac committed Mar 25, 2019
2 parents b11f010 + a6249ff commit a989128
Show file tree
Hide file tree
Showing 85 changed files with 404 additions and 257 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ Changelog
### Chores

- Improved acceptance test coverage for the Loading screen, Block Consolidation screen, and fixed a bug common to multiple other tests which use the mnemonic word selector to identify and click mnemonics ([PR 1318](https://github.com/input-output-hk/daedalus/pull/1318))
- Implemented `pretier` formatting tool and set up automation for basic maintainance tasks ([PR 1335](https://github.com/input-output-hk/daedalus/pull/1335), [PR 1347](https://github.com/input-output-hk/daedalus/pull/1347))
- Implemented `pretier` formatting tool and set up automation for basic maintainance tasks ([PR 1335](https://github.com/input-output-hk/daedalus/pull/1335), [PR 1347](https://github.com/input-output-hk/daedalus/pull/1347), [PR 1352](https://github.com/input-output-hk/daedalus/pull/1352))
- Replaced "Ada" with "ada" ([PR 1317](https://github.com/input-output-hk/daedalus/pull/1317), [PR 1336](https://github.com/input-output-hk/daedalus/pull/1336))
- Improved the internal IPC communication ([PR 1332](https://github.com/input-output-hk/daedalus/pull/1332))
- Improved Webpack 4 build performance ([PR 1320](https://github.com/input-output-hk/daedalus/pull/1320))
- Introduced automated code formatting with prettier ([PR 1335](https://github.com/input-output-hk/daedalus/pull/1335))
- Improved error messages for connecting screen ([PR 1344](https://github.com/input-output-hk/daedalus/pull/1344))

## 0.13.1
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/app-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
declare var daedalus: Daedalus;

Given(/^Daedalus is running$/, function() {
expect(this.app.isRunning()).to.be.true;
expect(this.app.isRunning()).to.equal(true);
});

When(/^I refresh the main window$/, async function() {
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/cardano-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../support/helpers/cardano-node-helpers';

Given(/^cardano-node is running$/, async function() {
return await this.client.waitUntil(
await this.client.waitUntil(
async () =>
(await getCardanoNodeState(this.client)) === CardanoNodeStates.RUNNING
);
Expand All @@ -17,6 +17,6 @@ Then(
/^cardano-node process is not running$/,
{ timeout: 61000 },
async function() {
return waitForCardanoNodeToExit(this.client);
await waitForCardanoNodeToExit(this.client);
}
);
6 changes: 3 additions & 3 deletions features/step_definitions/settings-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down
6 changes: 6 additions & 0 deletions features/support/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ import {
} from './helpers/screenshot';
import { refreshClient } from './helpers/app-helpers';

/* eslint-disable consistent-return */

const context = {};
const DEFAULT_TIMEOUT = 20000;
let scenariosCount = 0;

const printMainProcessLogs = () =>
context.app.client.getMainProcessLogs().then(logs => {
// eslint-disable-next-line no-console
console.log('========= DAEDALUS LOGS =========');
// eslint-disable-next-line no-console
logs.forEach(log => console.log(log));
// eslint-disable-next-line no-console
console.log('=================================');
return true;
});
Expand Down Expand Up @@ -130,6 +135,7 @@ AfterAll(async function() {
await printMainProcessLogs();
}
if (process.env.KEEP_APP_AFTER_TESTS === 'true') {
// eslint-disable-next-line no-console
console.log(
'Keeping the app running since KEEP_APP_AFTER_TESTS env var is true'
);
Expand Down
2 changes: 1 addition & 1 deletion features/support/helpers/app-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion features/support/helpers/cardano-node-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
2 changes: 1 addition & 1 deletion features/support/helpers/i18n-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
2 changes: 1 addition & 1 deletion features/support/helpers/language-selection-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const languageSelection = {
client.waitForVisible(LANGUAGE_SELECTION_FORM, null, isHidden),
ensureLanguageIsSelected: async (client, { language } = {}) => {
await languageSelection.waitForVisible(client);
i18n.setActiveLanguage(client, { language });
await i18n.setActiveLanguage(client, { language });
await languageSelection.waitForVisible(client, { isHidden: true });
},
};
Expand Down
1 change: 1 addition & 0 deletions features/support/helpers/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const saveScreenshot = async (context, file) => {
.capturePage()
.then(imageBuffer => fs.writeFile(file, imageBuffer))
.catch(err => {
// eslint-disable-next-line no-console
console.log(err);
});
};
4 changes: 2 additions & 2 deletions features/support/helpers/shared-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion features/support/helpers/wallets-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
2 changes: 1 addition & 1 deletion flow/mappers/CSSModule.js.flow
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// @flow
declare export default { [key: string]: string }
declare export default { [string]: string }
4 changes: 3 additions & 1 deletion scripts/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ if (version) {

/** @desc Build, clear previous releases and pack new versions */
async function startPack() {
// eslint-disable-next-line no-console
console.log('start pack...');

try {
Expand Down Expand Up @@ -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 no-console
console.log(`${plat}-${arch} finished!`);
};
}
4 changes: 2 additions & 2 deletions source/common/crypto/decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import validWords from './valid-words.en';
const iv = Buffer.alloc(16); // it's iv = 0 simply

function decryptWithAES(aesKey, bytes) {
// eslint-disable-next-line
// eslint-disable-next-line new-cap
return new aesjs.ModeOfOperation.ctr(aesKey, new aesjs.Counter(iv)).decrypt(
bytes
);
Expand All @@ -34,7 +34,7 @@ const hexChar = [

const hexToBytes = s => {
const arr = [];
// eslint-disable-next-line
// eslint-disable-next-line no-self-compare
if (s.length & (1 === 1)) {
throw new Error(`Wrong hex: ${s}`);
}
Expand Down
6 changes: 3 additions & 3 deletions source/common/ipc/lib/IpcChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export class IpcChannel<Incoming, Outgoing> {
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`;
}

/**
Expand Down
36 changes: 17 additions & 19 deletions source/main/cardano/CardanoNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import type {
} from '../../common/types/cardano-node.types';
import { CardanoNodeStates } from '../../common/types/cardano-node.types';

/* eslint-disable consistent-return */

type Logger = {
debug: (string, ?Object) => void,
info: (string, ?Object) => void,
Expand Down Expand Up @@ -225,10 +227,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;
Expand Down Expand Up @@ -272,7 +274,9 @@ export class CardanoNode {
);
resolve();
} catch (_) {
reject('CardanoNode#start: Error while spawning cardano-node');
reject(
new Error('CardanoNode#start: Error while spawning cardano-node')
);
}
});
});
Expand Down Expand Up @@ -336,7 +340,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.'));
}
});
}
Expand Down Expand Up @@ -422,7 +426,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.`)
);
}
};
Expand Down Expand Up @@ -480,9 +484,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,
};
Expand Down Expand Up @@ -603,7 +607,7 @@ export class CardanoNode {
* @returns {boolean}
*/
_isDead = async (): Promise<boolean> =>
!this._isConnected() && (await this._isNodeProcessNotRunningAnymore());
!this._isConnected() && this._isNodeProcessNotRunningAnymore();

/**
* Checks if current cardano-node child_process is "awake" (created, connected, stateful)
Expand Down Expand Up @@ -661,10 +665,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<void> => {
Expand All @@ -677,10 +678,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 (
Expand Down Expand Up @@ -793,13 +791,13 @@ export class CardanoNode {

_isNodeProcessStillRunning = async (): Promise<boolean> =>
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;
Expand Down
2 changes: 1 addition & 1 deletion source/main/cardano/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/`;
}
};

Expand Down
2 changes: 1 addition & 1 deletion source/main/cardano/setupCardanoNodeMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions source/main/cardano/setupFrontendOnlyMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion source/main/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.log', 'System-info.json'];
export const ALLOWED_NODE_LOGS = new RegExp(/(node.json-)(\d{14}$)/);
export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/);
Expand Down
2 changes: 2 additions & 0 deletions source/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { detectSystemLocaleChannel } from './ipc/detect-system-locale';
import { CardanoNodeStates } from '../common/types/cardano-node.types';
import type { CheckDiskSpaceResponse } from '../common/types/no-disk-space.types';

/* eslint-disable consistent-return */

// Global references to windows to prevent them from being garbage collected
let mainWindow: BrowserWindow;
let cardanoNode: ?CardanoNode;
Expand Down
2 changes: 2 additions & 0 deletions source/main/ipc/bugReportRequestChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type {
} from '../../common/ipc/api';
import { Logger } from '../utils/logging';

/* eslint-disable consistent-return */

export const bugReportRequestChannel: // IpcChannel<Incoming, Outgoing>
MainIpcChannel<
SubmitBugReportRequest,
Expand Down
2 changes: 1 addition & 1 deletion source/main/ipc/download-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a989128

Please sign in to comment.