From 6ec9ce2f8554f06eb3b6588bd74e4e5e3b770ef3 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 5 Jan 2018 13:06:43 -0800 Subject: [PATCH 1/6] enhance(lints): Be explicit re which lint is disabled --- app/components/LndSyncing/LndSyncing.js | 8 ++++---- app/reducers/channels.js | 4 ++-- app/reducers/transaction.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/components/LndSyncing/LndSyncing.js b/app/components/LndSyncing/LndSyncing.js index 1697d63e..aefeb8e2 100644 --- a/app/components/LndSyncing/LndSyncing.js +++ b/app/components/LndSyncing/LndSyncing.js @@ -9,19 +9,19 @@ class LndSyncing extends Component { facts: [ { title: 'The Lightning Network', - description: 'The Lightning Network is a second layer solution built on top of the Bitcoin block chain that attempts to increase Bitcoin\'s scalability and privacy' // eslint-disable-line + description: 'The Lightning Network is a second layer solution built on top of the Bitcoin block chain that attempts to increase Bitcoin\'s scalability and privacy' // eslint-disable-line max-len }, { title: 'Payment Channel', - description: 'A payment channel is a class of techniques designed to allow users to make multiple Bitcoin transactions without commiting all of the transactions to the Bitcoin block chain. You can think of payment channels like tubes of money' // eslint-disable-line + description: 'A payment channel is a class of techniques designed to allow users to make multiple Bitcoin transactions without commiting all of the transactions to the Bitcoin block chain. You can think of payment channels like tubes of money' // eslint-disable-line max-len }, { title: 'HTLC', - description: 'Hashed TimeLock Contracts is a class of payments that use hashlocks and timelocks to require the receiver of a payment either acknowledge receiving the payment before a deadline or forfeit the ability to claim the payment. HTLCs are useful within the Lightning Network for routing payments across two or more payment channels' // eslint-disable-line + description: 'Hashed TimeLock Contracts is a class of payments that use hashlocks and timelocks to require the receiver of a payment either acknowledge receiving the payment before a deadline or forfeit the ability to claim the payment. HTLCs are useful within the Lightning Network for routing payments across two or more payment channels' // eslint-disable-line max-len }, { title: 'Onion Routing', - description: 'Onion routing is a technique for anonymous communication over a computer network. In an onion network, messages are encapsulated in layers of encryption, analogous to layers of an onion.' // eslint-disable-line + description: 'Onion routing is a technique for anonymous communication over a computer network. In an onion network, messages are encapsulated in layers of encryption, analogous to layers of an onion.' // eslint-disable-line max-len } ], currentFact: 0 diff --git a/app/reducers/channels.js b/app/reducers/channels.js index d82e76bf..1527eff8 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -178,7 +178,7 @@ export const pushchannelupdated = (event, { pubkey }) => (dispatch) => { } // Receive IPC event for channel end -export const pushchannelend = event => (dispatch) => { // eslint-disable-line +export const pushchannelend = event => (dispatch) => { // eslint-disable-line no-unused-vars dispatch(fetchChannels()) } @@ -190,7 +190,7 @@ export const pushchannelerror = (event, { pubkey, error }) => (dispatch) => { } // Receive IPC event for channel status -export const pushchannelstatus = (event, data) => (dispatch) => { // eslint-disable-line +export const pushchannelstatus = (event, data) => (dispatch) => { // eslint-disable-line no-unused-vars dispatch(fetchChannels()) } diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index c32ae56f..9a987586 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -85,7 +85,7 @@ export const newTransaction = (event, { transaction }) => (dispatch) => { // HTML 5 desktop notification for the new transaction const notifTitle = transaction.amount > 0 ? 'On-chain Transaction Received!' : 'On-chain Transaction Sent!' - const notifBody = transaction.amount > 0 ? 'Lucky you, you just received a new on-chain transaction. I\'m jealous.' : 'Hate to see \'em go but love to watch \'em leave. Your on-chain transaction successfully sent.' // eslint-disable-line + const notifBody = transaction.amount > 0 ? 'Lucky you, you just received a new on-chain transaction. I\'m jealous.' : 'Hate to see \'em go but love to watch \'em leave. Your on-chain transaction successfully sent.' // eslint-disable-line max-len showNotification(notifTitle, notifBody) From 2e5ca3da686755078132b8f99255635177a421d5 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 12 Jan 2018 16:48:06 -0800 Subject: [PATCH 2/6] fix(lints): Run eslint --fix over the currently disabled lints --- app/lnd/subscribe/transactions.js | 2 +- app/main.dev.js | 76 ++++++++++++++-------------- app/menu.js | 84 +++++++++++++++---------------- app/reducers/channels.js | 2 +- test/e2e/e2e.spec.js | 59 +++++++++++----------- webpack.config.renderer.dev.js | 20 ++++---- 6 files changed, 121 insertions(+), 122 deletions(-) diff --git a/app/lnd/subscribe/transactions.js b/app/lnd/subscribe/transactions.js index de7bfb4b..e369731c 100644 --- a/app/lnd/subscribe/transactions.js +++ b/app/lnd/subscribe/transactions.js @@ -2,7 +2,7 @@ export default function subscribeToTransactions(mainWindow, lnd, meta) { const call = lnd.subscribeTransactions({}, meta) - call.on('data', transaction => { + call.on('data', (transaction) => { console.log('TRANSACTION: ', transaction) mainWindow.send('newTransaction', { transaction }) }) diff --git a/app/main.dev.js b/app/main.dev.js index 6e243307..89f9aeae 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -34,29 +34,29 @@ let certInterval if (process.env.NODE_ENV === 'production') { - const sourceMapSupport = require('source-map-support'); - sourceMapSupport.install(); + const sourceMapSupport = require('source-map-support') + sourceMapSupport.install() } if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { - require('electron-debug')(); - const path = require('path'); - const p = path.join(__dirname, '..', 'app', 'node_modules'); - require('module').globalPaths.push(p); + require('electron-debug')() + const path = require('path') + const p = path.join(__dirname, '..', 'app', 'node_modules') + require('module').globalPaths.push(p) } const installExtensions = async () => { - const installer = require('electron-devtools-installer'); - const forceDownload = !!process.env.UPGRADE_EXTENSIONS; + const installer = require('electron-devtools-installer') + const forceDownload = !!process.env.UPGRADE_EXTENSIONS const extensions = [ 'REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS' - ]; + ] return Promise .all(extensions.map(name => installer.default(installer[name], forceDownload))) - .catch(console.log); -}; + .catch(console.log) +} /** @@ -74,10 +74,10 @@ app.on('window-all-closed', () => { app.on('ready', async () => { if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { - await installExtensions(); + await installExtensions() } - let icon = path.join(__dirname, '..', 'resources', 'icon.icns') + const icon = path.join(__dirname, '..', 'resources', 'icon.icns') console.log('icon: ', icon) mainWindow = new BrowserWindow({ show: false, @@ -86,7 +86,7 @@ app.on('ready', async () => { height: 1100, minHeight: 700, minWidth: 1100, - icon: icon + icon }) mainWindow.loadURL(`file://${__dirname}/app.html`) @@ -106,17 +106,17 @@ app.on('ready', async () => { }) mainWindow.on('closed', () => { - mainWindow = null; + mainWindow = null }) - const menuBuilder = new MenuBuilder(mainWindow); + const menuBuilder = new MenuBuilder(mainWindow) menuBuilder.buildMenu() sendGrpcDisconnected() // Check to see if and LND process is running lookup({ command: 'lnd' }, (err, results) => { // There was an error checking for the LND process - if (err) { throw new Error( err ) } + if (err) { throw new Error(err) } // No LND process was found if (!results.length) { @@ -145,11 +145,11 @@ app.on('ready', async () => { startGrpc() } }) -}); +}) app.setAsDefaultProtocolClient('lightning') -app.on('open-url', function (event, url) { +app.on('open-url', (event, url) => { event.preventDefault() if (!mainWindow) { @@ -166,29 +166,29 @@ export const startLnd = () => { const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd') const neutrino = spawn(lndPath, - [ - '--bitcoin.active', - '--bitcoin.testnet', - '--neutrino.active', - '--neutrino.connect=btcd0.lightning.computer:18333', - '--autopilot.active', - '--debuglevel=debug', - '--noencryptwallet' - ] - ) - .on('error', error => console.log(`lnd error: ${error}`)) - .on('close', code => console.log(`lnd shutting down ${code}`)) + [ + '--bitcoin.active', + '--bitcoin.testnet', + '--neutrino.active', + '--neutrino.connect=btcd0.lightning.computer:18333', + '--autopilot.active', + '--debuglevel=debug', + '--noencryptwallet' + ] + ) + .on('error', error => console.log(`lnd error: ${error}`)) + .on('close', code => console.log(`lnd shutting down ${code}`)) // Listen for when neutrino prints out data - neutrino.stdout.on('data', data => { + neutrino.stdout.on('data', (data) => { // Data stored in variable line, log line to the console - let line = data.toString('utf8') + const line = data.toString('utf8') if (process.env.NODE_ENV === 'development') { console.log(line) } // If the gRPC proxy has started we can start ours if (line.includes('gRPC proxy started')) { - let certInterval = setInterval(() => { + const certInterval = setInterval(() => { if (fs.existsSync(certPath)) { clearInterval(certInterval) @@ -233,7 +233,7 @@ const startGrpc = () => { // Send the front end event letting them know LND is synced to the blockchain const sendLndSyncing = () => { - let sendLndSyncingInterval = setInterval(() => { + const sendLndSyncingInterval = setInterval(() => { if (didFinishLoad) { clearInterval(sendLndSyncingInterval) @@ -248,7 +248,7 @@ const sendLndSyncing = () => { // Send the front end event letting them know LND is synced to the blockchain const sendLndSynced = () => { - let sendLndSyncedInterval = setInterval(() => { + const sendLndSyncedInterval = setInterval(() => { if (didFinishLoad && startedSync) { clearInterval(sendLndSyncedInterval) @@ -262,7 +262,7 @@ const sendLndSynced = () => { // Send the front end event letting them know the gRPC connection has started const sendGrpcDisconnected = () => { - let sendGrpcDisonnectedInterval = setInterval(() => { + const sendGrpcDisonnectedInterval = setInterval(() => { if (didFinishLoad) { clearInterval(sendGrpcDisonnectedInterval) @@ -276,7 +276,7 @@ const sendGrpcDisconnected = () => { // Send the front end event letting them know the gRPC connection has started const sendGrpcConnected = () => { - let sendGrpcConnectedInterval = setInterval(() => { + const sendGrpcConnectedInterval = setInterval(() => { if (didFinishLoad && sentGrpcDisconnect) { clearInterval(sendGrpcConnectedInterval) diff --git a/app/menu.js b/app/menu.js index b5a6a093..06860bfc 100644 --- a/app/menu.js +++ b/app/menu.js @@ -1,48 +1,48 @@ /* eslint-disable */ // @flow -import { app, Menu, shell, BrowserWindow } from 'electron'; +import { app, Menu, shell, BrowserWindow } from 'electron' export default class MenuBuilder { mainWindow: BrowserWindow; constructor(mainWindow: BrowserWindow) { - this.mainWindow = mainWindow; + this.mainWindow = mainWindow } buildMenu() { if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { - this.setupDevelopmentEnvironment(); + this.setupDevelopmentEnvironment() } - let template; + let template if (process.platform === 'darwin') { - template = this.buildDarwinTemplate(); + template = this.buildDarwinTemplate() } else { - template = this.buildDefaultTemplate(); + template = this.buildDefaultTemplate() } - const menu = Menu.buildFromTemplate(template); - Menu.setApplicationMenu(menu); + const menu = Menu.buildFromTemplate(template) + Menu.setApplicationMenu(menu) - return menu; + return menu } setupDevelopmentEnvironment() { - this.mainWindow.openDevTools(); + this.mainWindow.openDevTools() this.mainWindow.webContents.on('context-menu', (e, props) => { - const { x, y } = props; + const { x, y } = props Menu .buildFromTemplate([{ label: 'Inspect element', click: () => { - this.mainWindow.inspectElement(x, y); + this.mainWindow.inspectElement(x, y) } }]) - .popup(this.mainWindow); - }); + .popup(this.mainWindow) + }) } buildDarwinTemplate() { @@ -57,9 +57,9 @@ export default class MenuBuilder { { label: 'Hide Others', accelerator: 'Command+Shift+H', selector: 'hideOtherApplications:' }, { label: 'Show All', selector: 'unhideAllApplications:' }, { type: 'separator' }, - { label: 'Quit', accelerator: 'Command+Q', click: () => { app.quit(); } } + { label: 'Quit', accelerator: 'Command+Q', click: () => { app.quit() } } ] - }; + } const subMenuEdit = { label: 'Edit', submenu: [ @@ -71,21 +71,21 @@ export default class MenuBuilder { { label: 'Paste', accelerator: 'Command+V', selector: 'paste:' }, { label: 'Select All', accelerator: 'Command+A', selector: 'selectAll:' } ] - }; + } const subMenuViewDev = { label: 'View', submenu: [ - { label: 'Reload', accelerator: 'Command+R', click: () => { this.mainWindow.webContents.reload(); } }, - { label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); } }, - { label: 'Toggle Developer Tools', accelerator: 'Alt+Command+I', click: () => { this.mainWindow.toggleDevTools(); } } + { label: 'Reload', accelerator: 'Command+R', click: () => { this.mainWindow.webContents.reload() } }, + { label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } }, + { label: 'Toggle Developer Tools', accelerator: 'Alt+Command+I', click: () => { this.mainWindow.toggleDevTools() } } ] - }; + } const subMenuViewProd = { label: 'View', submenu: [ - { label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); } } + { label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } } ] - }; + } const subMenuWindow = { label: 'Window', submenu: [ @@ -94,20 +94,20 @@ export default class MenuBuilder { { type: 'separator' }, { label: 'Bring All to Front', selector: 'arrangeInFront:' } ] - }; + } const subMenuHelp = { label: 'Help', submenu: [ - { label: 'Learn More', click() { shell.openExternal('http://electron.atom.io'); } }, - { label: 'Documentation', click() { shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme'); } }, - { label: 'Community Discussions', click() { shell.openExternal('https://discuss.atom.io/c/electron'); } }, - { label: 'Search Issues', click() { shell.openExternal('https://github.com/atom/electron/issues'); } } + { label: 'Learn More', click() { shell.openExternal('http://electron.atom.io') } }, + { label: 'Documentation', click() { shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme') } }, + { label: 'Community Discussions', click() { shell.openExternal('https://discuss.atom.io/c/electron') } }, + { label: 'Search Issues', click() { shell.openExternal('https://github.com/atom/electron/issues') } } ] - }; + } const subMenuView = process.env.NODE_ENV === 'development' ? subMenuViewDev - : subMenuViewProd; + : subMenuViewProd return [ subMenuAbout, @@ -115,7 +115,7 @@ export default class MenuBuilder { subMenuView, subMenuWindow, subMenuHelp - ]; + ] } buildDefaultTemplate() { @@ -128,7 +128,7 @@ export default class MenuBuilder { label: '&Close', accelerator: 'Ctrl+W', click: () => { - this.mainWindow.close(); + this.mainWindow.close() } }] }, { @@ -137,25 +137,25 @@ export default class MenuBuilder { label: '&Reload', accelerator: 'Ctrl+R', click: () => { - this.mainWindow.webContents.reload(); + this.mainWindow.webContents.reload() } }, { label: 'Toggle &Full Screen', accelerator: 'F11', click: () => { - this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); + this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } }, { label: 'Toggle &Developer Tools', accelerator: 'Alt+Ctrl+I', click: () => { - this.mainWindow.toggleDevTools(); + this.mainWindow.toggleDevTools() } }] : [{ label: 'Toggle &Full Screen', accelerator: 'F11', click: () => { - this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); + this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } }] }, { @@ -163,26 +163,26 @@ export default class MenuBuilder { submenu: [{ label: 'Learn More', click() { - shell.openExternal('http://electron.atom.io'); + shell.openExternal('http://electron.atom.io') } }, { label: 'Documentation', click() { - shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme'); + shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme') } }, { label: 'Community Discussions', click() { - shell.openExternal('https://discuss.atom.io/c/electron'); + shell.openExternal('https://discuss.atom.io/c/electron') } }, { label: 'Search Issues', click() { - shell.openExternal('https://github.com/atom/electron/issues'); + shell.openExternal('https://github.com/atom/electron/issues') } }] - }]; + }] - return templateDefault; + return templateDefault } } diff --git a/app/reducers/channels.js b/app/reducers/channels.js index 1527eff8..41f620d8 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -271,7 +271,7 @@ export const channelGraphData = (event, data) => (dispatch, getState) => { // Construct the notification const otherParty = info.data.identity_pubkey === advertising_node ? connecting_node : advertising_node - let notifBody = `No new friends, just new channels. Your channel with ${otherParty}` // eslint-disable-line + const notifBody = `No new friends, just new channels. Your channel with ${otherParty}` const notifTitle = 'New channel detected' // HTML 5 notification for channel updates involving our node diff --git a/test/e2e/e2e.spec.js b/test/e2e/e2e.spec.js index 369bb748..227f692b 100644 --- a/test/e2e/e2e.spec.js +++ b/test/e2e/e2e.spec.js @@ -1,54 +1,53 @@ /* eslint-disable */ +import { Application } from 'spectron' +import electronPath from 'electron' +import path from 'path' -import { Application } from 'spectron'; -import electronPath from 'electron'; -import path from 'path'; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000 -jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000; - -const delay = time => new Promise(resolve => setTimeout(resolve, time)); +const delay = time => new Promise(resolve => setTimeout(resolve, time)) describe('main window', function spec() { beforeAll(async () => { this.app = new Application({ path: electronPath, args: [path.join(__dirname, '..', '..', 'app')] - }); + }) - return this.app.start(); - }); + return this.app.start() + }) afterAll(() => { if (this.app && this.app.isRunning()) { - return this.app.stop(); + return this.app.stop() } - }); + }) - const findCounter = () => this.app.client.element('[data-tid="counter"]'); + const findCounter = () => this.app.client.element('[data-tid="counter"]') const findButtons = async () => { - const { value } = await this.app.client.elements('[data-tclass="btn"]'); - return value.map(btn => btn.ELEMENT); - }; + const { value } = await this.app.client.elements('[data-tclass="btn"]') + return value.map(btn => btn.ELEMENT) + } it('should open window', async () => { - const { client, browserWindow } = this.app; + const { client, browserWindow } = this.app - await client.waitUntilWindowLoaded(); - await delay(500); - const title = await browserWindow.getTitle(); - expect(title).toBe('Zap'); - }); + await client.waitUntilWindowLoaded() + await delay(500) + const title = await browserWindow.getTitle() + expect(title).toBe('Zap') + }) it('should haven\'t any logs in console of main window', async () => { - const { client } = this.app; - const logs = await client.getRenderProcessLogs(); + const { client } = this.app + const logs = await client.getRenderProcessLogs() // Print renderer process logs logs.forEach((log) => { - console.log(log.message); - console.log(log.source); - console.log(log.level); - }); - expect(logs).toHaveLength(0); - }); -}); + console.log(log.message) + console.log(log.source) + console.log(log.level) + }) + expect(logs).toHaveLength(0) + }) +}) diff --git a/webpack.config.renderer.dev.js b/webpack.config.renderer.dev.js index 02625bed..dfa7b6c7 100644 --- a/webpack.config.renderer.dev.js +++ b/webpack.config.renderer.dev.js @@ -18,12 +18,12 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin' import baseConfig from './webpack.config.base' import CheckNodeEnv from './internals/scripts/CheckNodeEnv' -CheckNodeEnv('development'); +CheckNodeEnv('development') -const port = process.env.PORT || 1212; -const publicPath = `http://localhost:${port}/dist`; -const dll = path.resolve(process.cwd(), 'dll'); -const manifest = path.resolve(dll, 'renderer.json'); +const port = process.env.PORT || 1212 +const publicPath = `http://localhost:${port}/dist` +const dll = path.resolve(process.cwd(), 'dll') +const manifest = path.resolve(dll, 'renderer.json') /** * Warn if the DLL is not built @@ -31,8 +31,8 @@ const manifest = path.resolve(dll, 'renderer.json'); if (!(fs.existsSync(dll) && fs.existsSync(manifest))) { console.log(chalk.black.bgYellow.bold( 'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"' - )); - execSync('npm run build-dll'); + )) + execSync('npm run build-dll') } export default merge.smart(baseConfig, { @@ -267,15 +267,15 @@ export default merge.smart(baseConfig, { }, setup() { if (process.env.START_HOT) { - console.log('Starting Main Process...'); + console.log('Starting Main Process...') spawn( 'npm', ['run', 'start-main-dev'], { shell: true, env: process.env, stdio: 'inherit' } ) .on('close', code => process.exit(code)) - .on('error', spawnError => console.error(spawnError)); + .on('error', spawnError => console.error(spawnError)) } } } -}); +}) From 412528358799c4af32fc49bc613fd7d18e9a054d Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 12 Jan 2018 16:49:44 -0800 Subject: [PATCH 3/6] enhance(lints): Enable currenly disabled lints --- .eslintignore | 1 + app/components/Form/PayForm.js | 2 +- app/lnd/methods/paymentsController.js | 4 ++-- app/lnd/subscribe/invoices.js | 2 -- app/lnd/subscribe/transactions.js | 2 -- app/main.dev.js | 1 - app/menu.js | 2 -- app/reducers/channels.js | 12 ++++++------ app/reducers/lnd.js | 4 ++-- app/utils/bech32.js | 3 --- internals/scripts/CheckNodeEnv.js | 2 -- test/e2e/e2e.spec.js | 1 - webpack.config.renderer.dev.js | 1 - 13 files changed, 12 insertions(+), 25 deletions(-) diff --git a/.eslintignore b/.eslintignore index 3f90da49..6432ddbc 100644 --- a/.eslintignore +++ b/.eslintignore @@ -43,6 +43,7 @@ app/renderer.prod.js app/renderer.prod.js.map app/style.css app/style.css.map +app/utils/bech32.js dist dll main.js diff --git a/app/components/Form/PayForm.js b/app/components/Form/PayForm.js index 00fc6bc6..c8e06cca 100644 --- a/app/components/Form/PayForm.js +++ b/app/components/Form/PayForm.js @@ -55,7 +55,7 @@ class PayForm extends Component { this.amountInput = input} // eslint-disable-line + ref={input => this.amountInput = input} size='' style={ isLn ? diff --git a/app/lnd/methods/paymentsController.js b/app/lnd/methods/paymentsController.js index b79b8cb0..e9afd981 100644 --- a/app/lnd/methods/paymentsController.js +++ b/app/lnd/methods/paymentsController.js @@ -8,11 +8,11 @@ export function sendPaymentSync(lnd, meta, { paymentRequest }) { return new Promise((resolve, reject) => { lnd.sendPaymentSync({ payment_request: paymentRequest }, meta, (error, data) => { if (error) { - reject({ error }) // eslint-disable-line + reject({ error }) return } - if (!data || !data.payment_route) { reject({ error: data.payment_error }) } // eslint-disable-line + if (!data || !data.payment_route) { reject({ error: data.payment_error }) } resolve(data) }) diff --git a/app/lnd/subscribe/invoices.js b/app/lnd/subscribe/invoices.js index 63e238f8..db614238 100644 --- a/app/lnd/subscribe/invoices.js +++ b/app/lnd/subscribe/invoices.js @@ -1,5 +1,3 @@ -/* eslint-disable */ - export default function subscribeToInvoices(mainWindow, lnd, meta) { const call = lnd.subscribeInvoices({}, meta) diff --git a/app/lnd/subscribe/transactions.js b/app/lnd/subscribe/transactions.js index e369731c..a6bf5ff8 100644 --- a/app/lnd/subscribe/transactions.js +++ b/app/lnd/subscribe/transactions.js @@ -1,5 +1,3 @@ -/* eslint-disable */ - export default function subscribeToTransactions(mainWindow, lnd, meta) { const call = lnd.subscribeTransactions({}, meta) call.on('data', (transaction) => { diff --git a/app/main.dev.js b/app/main.dev.js index 89f9aeae..97c4a332 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -1,4 +1,3 @@ -/* eslint-disable */ /* eslint global-require: 1, flowtype-errors/show-errors: 0 */ /** diff --git a/app/menu.js b/app/menu.js index 06860bfc..e7f6339a 100644 --- a/app/menu.js +++ b/app/menu.js @@ -1,5 +1,3 @@ -/* eslint-disable */ - // @flow import { app, Menu, shell, BrowserWindow } from 'electron' diff --git a/app/reducers/channels.js b/app/reducers/channels.js index 41f620d8..8416f175 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -423,15 +423,15 @@ const allChannels = createSelector( pendingForceClosedChannelsSelector, channelSearchQuerySelector, (activeChannels, nonActiveChannels, pendingOpenChannels, pendingClosedChannels, pendingForcedClosedChannels, searchQuery) => { - const filteredActiveChannels = activeChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) // eslint-disable-line - const filteredNonActiveChannels = nonActiveChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) // eslint-disable-line + const filteredActiveChannels = activeChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) + const filteredNonActiveChannels = nonActiveChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) - const filteredPendingOpenChannels = pendingOpenChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) // eslint-disable-line - const filteredPendingClosedChannels = pendingClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) // eslint-disable-line - const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) // eslint-disable-line + const filteredPendingOpenChannels = pendingOpenChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) + const filteredPendingClosedChannels = pendingClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) + const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) - return [...filteredActiveChannels, ...filteredPendingOpenChannels, ...filteredPendingClosedChannels, ...filteredPendingForcedClosedChannels, ...filteredNonActiveChannels] // eslint-disable-line + return [...filteredActiveChannels, ...filteredPendingOpenChannels, ...filteredPendingClosedChannels, ...filteredPendingForcedClosedChannels, ...filteredNonActiveChannels] } ) diff --git a/app/reducers/lnd.js b/app/reducers/lnd.js index 6643beb8..eaa19de3 100644 --- a/app/reducers/lnd.js +++ b/app/reducers/lnd.js @@ -52,12 +52,12 @@ export const lndStdout = (event, line) => (dispatch) => { if (line.includes('Caught up to height')) { trimmed = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim() - height = trimmed.split(' ')[0].split(/(\r\n|\n|\r)/gm)[0] // eslint-disable-line + height = trimmed.split(' ')[0].split(/(\r\n|\n|\r)/gm)[0] } if (line.includes('Catching up block hashes to height')) { trimmed = line.slice(line.indexOf('Catching up block hashes to height') + 'Catching up block hashes to height'.length).trim() - height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0] // eslint-disable-line + height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0] } dispatch({ type: RECEIVE_LINE, lndBlockHeight: height }) diff --git a/app/utils/bech32.js b/app/utils/bech32.js index 54665300..a5892888 100644 --- a/app/utils/bech32.js +++ b/app/utils/bech32.js @@ -1,7 +1,5 @@ // Using bech32 here just without the 90 char length: https://github.com/bitcoinjs/bech32/blob/master/index.js -/* eslint-disable */ - 'use strict' let ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l' @@ -147,4 +145,3 @@ export default { toWords, fromWords } - diff --git a/internals/scripts/CheckNodeEnv.js b/internals/scripts/CheckNodeEnv.js index 23df8a81..7a6d6d50 100644 --- a/internals/scripts/CheckNodeEnv.js +++ b/internals/scripts/CheckNodeEnv.js @@ -7,11 +7,9 @@ export default function CheckNodeEnv(expectedEnv: string) { } if (process.env.NODE_ENV !== expectedEnv) { - /* eslint-disable */ console.log(chalk.whiteBright.bgRed.bold( `"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config` )) - /* eslint-enable */ process.exit(2) } } diff --git a/test/e2e/e2e.spec.js b/test/e2e/e2e.spec.js index 227f692b..e67bc094 100644 --- a/test/e2e/e2e.spec.js +++ b/test/e2e/e2e.spec.js @@ -1,4 +1,3 @@ -/* eslint-disable */ import { Application } from 'spectron' import electronPath from 'electron' import path from 'path' diff --git a/webpack.config.renderer.dev.js b/webpack.config.renderer.dev.js index dfa7b6c7..7549d793 100644 --- a/webpack.config.renderer.dev.js +++ b/webpack.config.renderer.dev.js @@ -1,4 +1,3 @@ -/* eslint-disable */ /* eslint global-require: 0, import/no-dynamic-require: 0 */ /** From acbf786c0af0b52275a098a416d3dcfb6090cea3 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 12 Jan 2018 16:55:10 -0800 Subject: [PATCH 4/6] fix(lints): Manually fix some trivial lints --- app/components/Form/PayForm.js | 2 +- app/menu.js | 12 ++++++++++-- internals/scripts/CheckNodeEnv.js | 4 +--- test/e2e/e2e.spec.js | 13 +------------ webpack.config.renderer.dev.js | 4 +--- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/app/components/Form/PayForm.js b/app/components/Form/PayForm.js index c8e06cca..83ca3733 100644 --- a/app/components/Form/PayForm.js +++ b/app/components/Form/PayForm.js @@ -55,7 +55,7 @@ class PayForm extends Component { this.amountInput = input} + ref={(input) => { this.amountInput = input }} size='' style={ isLn ? diff --git a/app/menu.js b/app/menu.js index e7f6339a..0b31d242 100644 --- a/app/menu.js +++ b/app/menu.js @@ -74,14 +74,22 @@ export default class MenuBuilder { label: 'View', submenu: [ { label: 'Reload', accelerator: 'Command+R', click: () => { this.mainWindow.webContents.reload() } }, - { label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } }, + { + label: 'Toggle Full Screen', + accelerator: 'Ctrl+Command+F', + click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } + }, { label: 'Toggle Developer Tools', accelerator: 'Alt+Command+I', click: () => { this.mainWindow.toggleDevTools() } } ] } const subMenuViewProd = { label: 'View', submenu: [ - { label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } } + { + label: 'Toggle Full Screen', + accelerator: 'Ctrl+Command+F', + click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) } + } ] } const subMenuWindow = { diff --git a/internals/scripts/CheckNodeEnv.js b/internals/scripts/CheckNodeEnv.js index 7a6d6d50..62bda0c8 100644 --- a/internals/scripts/CheckNodeEnv.js +++ b/internals/scripts/CheckNodeEnv.js @@ -7,9 +7,7 @@ export default function CheckNodeEnv(expectedEnv: string) { } if (process.env.NODE_ENV !== expectedEnv) { - console.log(chalk.whiteBright.bgRed.bold( - `"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config` - )) + console.log(chalk.whiteBright.bgRed.bold(`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`)) process.exit(2) } } diff --git a/test/e2e/e2e.spec.js b/test/e2e/e2e.spec.js index e67bc094..b0cf0be0 100644 --- a/test/e2e/e2e.spec.js +++ b/test/e2e/e2e.spec.js @@ -16,18 +16,7 @@ describe('main window', function spec() { return this.app.start() }) - afterAll(() => { - if (this.app && this.app.isRunning()) { - return this.app.stop() - } - }) - - const findCounter = () => this.app.client.element('[data-tid="counter"]') - - const findButtons = async () => { - const { value } = await this.app.client.elements('[data-tclass="btn"]') - return value.map(btn => btn.ELEMENT) - } + afterAll(() => this.app && this.app.isRunning() && this.app.stop()) it('should open window', async () => { const { client, browserWindow } = this.app diff --git a/webpack.config.renderer.dev.js b/webpack.config.renderer.dev.js index 7549d793..a8ab8717 100644 --- a/webpack.config.renderer.dev.js +++ b/webpack.config.renderer.dev.js @@ -28,9 +28,7 @@ const manifest = path.resolve(dll, 'renderer.json') * Warn if the DLL is not built */ if (!(fs.existsSync(dll) && fs.existsSync(manifest))) { - console.log(chalk.black.bgYellow.bold( - 'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"' - )) + console.log(chalk.black.bgYellow.bold('The DLL files are missing. Sit back while we build them for you with "npm run build-dll"')) execSync('npm run build-dll') } From a6393f2f6715751cb2d982819bfedf4a8980bc01 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 12 Jan 2018 17:06:20 -0800 Subject: [PATCH 5/6] fix(lints): Fix lints in main.dev.js Mostly this involves reordering the functions so they are not used before they are defined. --- app/main.dev.js | 255 ++++++++++++++++++++++++------------------------ 1 file changed, 126 insertions(+), 129 deletions(-) diff --git a/app/main.dev.js b/app/main.dev.js index 97c4a332..6819a007 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -29,8 +29,6 @@ let startedSync = false let sentGrpcDisconnect = false let certPath -let certInterval - if (process.env.NODE_ENV === 'production') { const sourceMapSupport = require('source-map-support') @@ -39,7 +37,6 @@ if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { require('electron-debug')() - const path = require('path') const p = path.join(__dirname, '..', 'app', 'node_modules') require('module').globalPaths.push(p) } @@ -57,6 +54,130 @@ const installExtensions = async () => { .catch(console.log) } +// Send the front end event letting them know the gRPC connection has started +const sendGrpcDisconnected = () => { + const sendGrpcDisonnectedInterval = setInterval(() => { + if (didFinishLoad) { + clearInterval(sendGrpcDisonnectedInterval) + + if (mainWindow) { + sentGrpcDisconnect = true + mainWindow.webContents.send('grpcDisconnected') + } + } + }, 1000) +} + +// Send the front end event letting them know LND is synced to the blockchain +const sendLndSyncing = () => { + const sendLndSyncingInterval = setInterval(() => { + if (didFinishLoad) { + clearInterval(sendLndSyncingInterval) + + if (mainWindow) { + console.log('SENDING SYNCING') + startedSync = true + mainWindow.webContents.send('lndSyncing') + } + } + }, 1000) +} + +// Send the front end event letting them know the gRPC connection has started +const sendGrpcConnected = () => { + const sendGrpcConnectedInterval = setInterval(() => { + if (didFinishLoad && sentGrpcDisconnect) { + clearInterval(sendGrpcConnectedInterval) + + if (mainWindow) { + mainWindow.webContents.send('grpcConnected') + } + } + }, 1000) +} + +// Create and subscribe the grpc object +const startGrpc = () => { + lnd((lndSubscribe, lndMethods) => { + // Subscribe to bi-directional streams + lndSubscribe(mainWindow) + + // Listen for all gRPC restful methods + ipcMain.on('lnd', (event, { msg, data }) => { + lndMethods(event, msg, data) + }) + + sendGrpcConnected() + }) +} + +// Send the front end event letting them know LND is synced to the blockchain +const sendLndSynced = () => { + const sendLndSyncedInterval = setInterval(() => { + if (didFinishLoad && startedSync) { + clearInterval(sendLndSyncedInterval) + + if (mainWindow) { + console.log('SENDING SYNCED') + mainWindow.webContents.send('lndSynced') + } + } + }, 1000) +} + +// Starts the LND node +const startLnd = () => { + const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd') + + const neutrino = spawn(lndPath, + [ + '--bitcoin.active', + '--bitcoin.testnet', + '--neutrino.active', + '--neutrino.connect=btcd0.lightning.computer:18333', + '--autopilot.active', + '--debuglevel=debug', + '--noencryptwallet' + ] + ) + .on('error', error => console.log(`lnd error: ${error}`)) + .on('close', code => console.log(`lnd shutting down ${code}`)) + + // Listen for when neutrino prints out data + neutrino.stdout.on('data', (data) => { + // Data stored in variable line, log line to the console + const line = data.toString('utf8') + + if (process.env.NODE_ENV === 'development') { console.log(line) } + + // If the gRPC proxy has started we can start ours + if (line.includes('gRPC proxy started')) { + const certInterval = setInterval(() => { + if (fs.existsSync(certPath)) { + clearInterval(certInterval) + + console.log('CERT EXISTS, STARTING GRPC') + startGrpc() + } + }, 1000) + } + + // Pass current clock height progress to front end for loading state UX + if (mainWindow && (line.includes('Caught up to height') || line.includes('Catching up block hashes to height'))) { + // const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim() + mainWindow.webContents.send('lndStdout', line) + } + + // When LND is all caught up to the blockchain + if (line.includes('Chain backend is fully synced')) { + // Log that LND is caught up to the current block height + console.log('NEUTRINO IS SYNCED') + + // Let the front end know we have stopped syncing LND + sendLndSynced() + } + }) +} /** * Add event listeners... @@ -124,7 +245,7 @@ app.on('ready', async () => { switch (os.platform()) { case 'darwin': - certPath = path.join(homedir, 'Library/Application\ Support/Lnd/tls.cert') + certPath = path.join(homedir, 'Library/Application Support/Lnd/tls.cert') break case 'linux': certPath = path.join(homedir, '.lnd/tls.cert') @@ -160,128 +281,4 @@ app.on('open-url', (event, url) => { mainWindow.show() }) -// Starts the LND node -export const startLnd = () => { - const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd') - - const neutrino = spawn(lndPath, - [ - '--bitcoin.active', - '--bitcoin.testnet', - '--neutrino.active', - '--neutrino.connect=btcd0.lightning.computer:18333', - '--autopilot.active', - '--debuglevel=debug', - '--noencryptwallet' - ] - ) - .on('error', error => console.log(`lnd error: ${error}`)) - .on('close', code => console.log(`lnd shutting down ${code}`)) - - // Listen for when neutrino prints out data - neutrino.stdout.on('data', (data) => { - // Data stored in variable line, log line to the console - const line = data.toString('utf8') - - if (process.env.NODE_ENV === 'development') { console.log(line) } - - // If the gRPC proxy has started we can start ours - if (line.includes('gRPC proxy started')) { - const certInterval = setInterval(() => { - if (fs.existsSync(certPath)) { - clearInterval(certInterval) - - console.log('CERT EXISTS, STARTING GRPC') - startGrpc() - } - }, 1000) - } - - // Pass current clock height progress to front end for loading state UX - if (mainWindow && (line.includes('Caught up to height') || line.includes('Catching up block hashes to height'))) { - // const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim() - const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim() - mainWindow.webContents.send('lndStdout', line) - } - - // When LND is all caught up to the blockchain - if (line.includes('Chain backend is fully synced')) { - // Log that LND is caught up to the current block height - console.log('NEUTRINO IS SYNCED') - - // Let the front end know we have stopped syncing LND - sendLndSynced() - } - }) -} - -// Create and subscribe the grpc object -const startGrpc = () => { - lnd((lndSubscribe, lndMethods) => { - // Subscribe to bi-directional streams - lndSubscribe(mainWindow) - - // Listen for all gRPC restful methods - ipcMain.on('lnd', (event, { msg, data }) => { - lndMethods(event, msg, data) - }) - - sendGrpcConnected() - }) -} - -// Send the front end event letting them know LND is synced to the blockchain -const sendLndSyncing = () => { - const sendLndSyncingInterval = setInterval(() => { - if (didFinishLoad) { - clearInterval(sendLndSyncingInterval) - - if (mainWindow) { - console.log('SENDING SYNCING') - startedSync = true - mainWindow.webContents.send('lndSyncing') - } - } - }, 1000) -} - -// Send the front end event letting them know LND is synced to the blockchain -const sendLndSynced = () => { - const sendLndSyncedInterval = setInterval(() => { - if (didFinishLoad && startedSync) { - clearInterval(sendLndSyncedInterval) - - if (mainWindow) { - console.log('SENDING SYNCED') - mainWindow.webContents.send('lndSynced') - } - } - }, 1000) -} - -// Send the front end event letting them know the gRPC connection has started -const sendGrpcDisconnected = () => { - const sendGrpcDisonnectedInterval = setInterval(() => { - if (didFinishLoad) { - clearInterval(sendGrpcDisonnectedInterval) - - if (mainWindow) { - sentGrpcDisconnect = true - mainWindow.webContents.send('grpcDisconnected') - } - } - }, 1000) -} - -// Send the front end event letting them know the gRPC connection has started -const sendGrpcConnected = () => { - const sendGrpcConnectedInterval = setInterval(() => { - if (didFinishLoad && sentGrpcDisconnect) { - clearInterval(sendGrpcConnectedInterval) - - if (mainWindow) { - mainWindow.webContents.send('grpcConnected') - } - } - }, 1000) -} +export default { startLnd } From 0674065d1884856294fb4b455c1f3d3a39700072 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Fri, 12 Jan 2018 17:06:56 -0800 Subject: [PATCH 6/6] fix(line-length): Extract helpers for DRY channel filtering These were linted for excessive line length --- app/reducers/channels.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/reducers/channels.js b/app/reducers/channels.js index 8416f175..f38c4ae3 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -423,15 +423,26 @@ const allChannels = createSelector( pendingForceClosedChannelsSelector, channelSearchQuerySelector, (activeChannels, nonActiveChannels, pendingOpenChannels, pendingClosedChannels, pendingForcedClosedChannels, searchQuery) => { - const filteredActiveChannels = activeChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) - const filteredNonActiveChannels = nonActiveChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) + const filterChannel = channel => + channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery) - const filteredPendingOpenChannels = pendingOpenChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) - const filteredPendingClosedChannels = pendingClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) - const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) + const filteredActiveChannels = activeChannels.filter(filterChannel) + const filteredNonActiveChannels = nonActiveChannels.filter(filterChannel) + const filterPendingChannel = channel => + channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery) - return [...filteredActiveChannels, ...filteredPendingOpenChannels, ...filteredPendingClosedChannels, ...filteredPendingForcedClosedChannels, ...filteredNonActiveChannels] + const filteredPendingOpenChannels = pendingOpenChannels.filter(filterPendingChannel) + const filteredPendingClosedChannels = pendingClosedChannels.filter(filterPendingChannel) + const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(filterPendingChannel) + + return [ + ...filteredActiveChannels, + ...filteredPendingOpenChannels, + ...filteredPendingClosedChannels, + ...filteredPendingForcedClosedChannels, + ...filteredNonActiveChannels + ] } )