Browse Source

fix(lints): Run eslint --fix over the currently disabled lints

renovate/lint-staged-8.x
Ben Woosley 7 years ago
parent
commit
2e5ca3da68
  1. 2
      app/lnd/subscribe/transactions.js
  2. 52
      app/main.dev.js
  3. 84
      app/menu.js
  4. 2
      app/reducers/channels.js
  5. 59
      test/e2e/e2e.spec.js
  6. 20
      webpack.config.renderer.dev.js

2
app/lnd/subscribe/transactions.js

@ -2,7 +2,7 @@
export default function subscribeToTransactions(mainWindow, lnd, meta) { export default function subscribeToTransactions(mainWindow, lnd, meta) {
const call = lnd.subscribeTransactions({}, meta) const call = lnd.subscribeTransactions({}, meta)
call.on('data', transaction => { call.on('data', (transaction) => {
console.log('TRANSACTION: ', transaction) console.log('TRANSACTION: ', transaction)
mainWindow.send('newTransaction', { transaction }) mainWindow.send('newTransaction', { transaction })
}) })

52
app/main.dev.js

@ -34,29 +34,29 @@ let certInterval
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
const sourceMapSupport = require('source-map-support'); const sourceMapSupport = require('source-map-support')
sourceMapSupport.install(); sourceMapSupport.install()
} }
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
require('electron-debug')(); require('electron-debug')()
const path = require('path'); const path = require('path')
const p = path.join(__dirname, '..', 'app', 'node_modules'); const p = path.join(__dirname, '..', 'app', 'node_modules')
require('module').globalPaths.push(p); require('module').globalPaths.push(p)
} }
const installExtensions = async () => { const installExtensions = async () => {
const installer = require('electron-devtools-installer'); const installer = require('electron-devtools-installer')
const forceDownload = !!process.env.UPGRADE_EXTENSIONS; const forceDownload = !!process.env.UPGRADE_EXTENSIONS
const extensions = [ const extensions = [
'REACT_DEVELOPER_TOOLS', 'REACT_DEVELOPER_TOOLS',
'REDUX_DEVTOOLS' 'REDUX_DEVTOOLS'
]; ]
return Promise return Promise
.all(extensions.map(name => installer.default(installer[name], forceDownload))) .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 () => { app.on('ready', async () => {
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { 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) console.log('icon: ', icon)
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
show: false, show: false,
@ -86,7 +86,7 @@ app.on('ready', async () => {
height: 1100, height: 1100,
minHeight: 700, minHeight: 700,
minWidth: 1100, minWidth: 1100,
icon: icon icon
}) })
mainWindow.loadURL(`file://${__dirname}/app.html`) mainWindow.loadURL(`file://${__dirname}/app.html`)
@ -106,17 +106,17 @@ app.on('ready', async () => {
}) })
mainWindow.on('closed', () => { mainWindow.on('closed', () => {
mainWindow = null; mainWindow = null
}) })
const menuBuilder = new MenuBuilder(mainWindow); const menuBuilder = new MenuBuilder(mainWindow)
menuBuilder.buildMenu() menuBuilder.buildMenu()
sendGrpcDisconnected() sendGrpcDisconnected()
// Check to see if and LND process is running // Check to see if and LND process is running
lookup({ command: 'lnd' }, (err, results) => { lookup({ command: 'lnd' }, (err, results) => {
// There was an error checking for the LND process // 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 // No LND process was found
if (!results.length) { if (!results.length) {
@ -145,11 +145,11 @@ app.on('ready', async () => {
startGrpc() startGrpc()
} }
}) })
}); })
app.setAsDefaultProtocolClient('lightning') app.setAsDefaultProtocolClient('lightning')
app.on('open-url', function (event, url) { app.on('open-url', (event, url) => {
event.preventDefault() event.preventDefault()
if (!mainWindow) { if (!mainWindow) {
@ -180,15 +180,15 @@ export const startLnd = () => {
.on('close', code => console.log(`lnd shutting down ${code}`)) .on('close', code => console.log(`lnd shutting down ${code}`))
// Listen for when neutrino prints out data // 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 // 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 (process.env.NODE_ENV === 'development') { console.log(line) }
// If the gRPC proxy has started we can start ours // If the gRPC proxy has started we can start ours
if (line.includes('gRPC proxy started')) { if (line.includes('gRPC proxy started')) {
let certInterval = setInterval(() => { const certInterval = setInterval(() => {
if (fs.existsSync(certPath)) { if (fs.existsSync(certPath)) {
clearInterval(certInterval) clearInterval(certInterval)
@ -233,7 +233,7 @@ const startGrpc = () => {
// Send the front end event letting them know LND is synced to the blockchain // Send the front end event letting them know LND is synced to the blockchain
const sendLndSyncing = () => { const sendLndSyncing = () => {
let sendLndSyncingInterval = setInterval(() => { const sendLndSyncingInterval = setInterval(() => {
if (didFinishLoad) { if (didFinishLoad) {
clearInterval(sendLndSyncingInterval) clearInterval(sendLndSyncingInterval)
@ -248,7 +248,7 @@ const sendLndSyncing = () => {
// Send the front end event letting them know LND is synced to the blockchain // Send the front end event letting them know LND is synced to the blockchain
const sendLndSynced = () => { const sendLndSynced = () => {
let sendLndSyncedInterval = setInterval(() => { const sendLndSyncedInterval = setInterval(() => {
if (didFinishLoad && startedSync) { if (didFinishLoad && startedSync) {
clearInterval(sendLndSyncedInterval) clearInterval(sendLndSyncedInterval)
@ -262,7 +262,7 @@ const sendLndSynced = () => {
// Send the front end event letting them know the gRPC connection has started // Send the front end event letting them know the gRPC connection has started
const sendGrpcDisconnected = () => { const sendGrpcDisconnected = () => {
let sendGrpcDisonnectedInterval = setInterval(() => { const sendGrpcDisonnectedInterval = setInterval(() => {
if (didFinishLoad) { if (didFinishLoad) {
clearInterval(sendGrpcDisonnectedInterval) clearInterval(sendGrpcDisonnectedInterval)
@ -276,7 +276,7 @@ const sendGrpcDisconnected = () => {
// Send the front end event letting them know the gRPC connection has started // Send the front end event letting them know the gRPC connection has started
const sendGrpcConnected = () => { const sendGrpcConnected = () => {
let sendGrpcConnectedInterval = setInterval(() => { const sendGrpcConnectedInterval = setInterval(() => {
if (didFinishLoad && sentGrpcDisconnect) { if (didFinishLoad && sentGrpcDisconnect) {
clearInterval(sendGrpcConnectedInterval) clearInterval(sendGrpcConnectedInterval)

84
app/menu.js

@ -1,48 +1,48 @@
/* eslint-disable */ /* eslint-disable */
// @flow // @flow
import { app, Menu, shell, BrowserWindow } from 'electron'; import { app, Menu, shell, BrowserWindow } from 'electron'
export default class MenuBuilder { export default class MenuBuilder {
mainWindow: BrowserWindow; mainWindow: BrowserWindow;
constructor(mainWindow: BrowserWindow) { constructor(mainWindow: BrowserWindow) {
this.mainWindow = mainWindow; this.mainWindow = mainWindow
} }
buildMenu() { buildMenu() {
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') { if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
this.setupDevelopmentEnvironment(); this.setupDevelopmentEnvironment()
} }
let template; let template
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
template = this.buildDarwinTemplate(); template = this.buildDarwinTemplate()
} else { } else {
template = this.buildDefaultTemplate(); template = this.buildDefaultTemplate()
} }
const menu = Menu.buildFromTemplate(template); const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu); Menu.setApplicationMenu(menu)
return menu; return menu
} }
setupDevelopmentEnvironment() { setupDevelopmentEnvironment() {
this.mainWindow.openDevTools(); this.mainWindow.openDevTools()
this.mainWindow.webContents.on('context-menu', (e, props) => { this.mainWindow.webContents.on('context-menu', (e, props) => {
const { x, y } = props; const { x, y } = props
Menu Menu
.buildFromTemplate([{ .buildFromTemplate([{
label: 'Inspect element', label: 'Inspect element',
click: () => { click: () => {
this.mainWindow.inspectElement(x, y); this.mainWindow.inspectElement(x, y)
} }
}]) }])
.popup(this.mainWindow); .popup(this.mainWindow)
}); })
} }
buildDarwinTemplate() { buildDarwinTemplate() {
@ -57,9 +57,9 @@ export default class MenuBuilder {
{ label: 'Hide Others', accelerator: 'Command+Shift+H', selector: 'hideOtherApplications:' }, { label: 'Hide Others', accelerator: 'Command+Shift+H', selector: 'hideOtherApplications:' },
{ label: 'Show All', selector: 'unhideAllApplications:' }, { label: 'Show All', selector: 'unhideAllApplications:' },
{ type: 'separator' }, { type: 'separator' },
{ label: 'Quit', accelerator: 'Command+Q', click: () => { app.quit(); } } { label: 'Quit', accelerator: 'Command+Q', click: () => { app.quit() } }
] ]
}; }
const subMenuEdit = { const subMenuEdit = {
label: 'Edit', label: 'Edit',
submenu: [ submenu: [
@ -71,21 +71,21 @@ export default class MenuBuilder {
{ label: 'Paste', accelerator: 'Command+V', selector: 'paste:' }, { label: 'Paste', accelerator: 'Command+V', selector: 'paste:' },
{ label: 'Select All', accelerator: 'Command+A', selector: 'selectAll:' } { label: 'Select All', accelerator: 'Command+A', selector: 'selectAll:' }
] ]
}; }
const subMenuViewDev = { const subMenuViewDev = {
label: 'View', label: 'View',
submenu: [ submenu: [
{ label: 'Reload', accelerator: 'Command+R', click: () => { this.mainWindow.webContents.reload(); } }, { 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(); } } { label: 'Toggle Developer Tools', accelerator: 'Alt+Command+I', click: () => { this.mainWindow.toggleDevTools() } }
] ]
}; }
const subMenuViewProd = { const subMenuViewProd = {
label: 'View', label: 'View',
submenu: [ 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 = { const subMenuWindow = {
label: 'Window', label: 'Window',
submenu: [ submenu: [
@ -94,20 +94,20 @@ export default class MenuBuilder {
{ type: 'separator' }, { type: 'separator' },
{ label: 'Bring All to Front', selector: 'arrangeInFront:' } { label: 'Bring All to Front', selector: 'arrangeInFront:' }
] ]
}; }
const subMenuHelp = { const subMenuHelp = {
label: 'Help', label: 'Help',
submenu: [ submenu: [
{ label: 'Learn More', click() { shell.openExternal('http://electron.atom.io'); } }, { 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: '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: 'Community Discussions', click() { shell.openExternal('https://discuss.atom.io/c/electron') } },
{ label: 'Search Issues', click() { shell.openExternal('https://github.com/atom/electron/issues'); } } { label: 'Search Issues', click() { shell.openExternal('https://github.com/atom/electron/issues') } }
] ]
}; }
const subMenuView = process.env.NODE_ENV === 'development' const subMenuView = process.env.NODE_ENV === 'development'
? subMenuViewDev ? subMenuViewDev
: subMenuViewProd; : subMenuViewProd
return [ return [
subMenuAbout, subMenuAbout,
@ -115,7 +115,7 @@ export default class MenuBuilder {
subMenuView, subMenuView,
subMenuWindow, subMenuWindow,
subMenuHelp subMenuHelp
]; ]
} }
buildDefaultTemplate() { buildDefaultTemplate() {
@ -128,7 +128,7 @@ export default class MenuBuilder {
label: '&Close', label: '&Close',
accelerator: 'Ctrl+W', accelerator: 'Ctrl+W',
click: () => { click: () => {
this.mainWindow.close(); this.mainWindow.close()
} }
}] }]
}, { }, {
@ -137,25 +137,25 @@ export default class MenuBuilder {
label: '&Reload', label: '&Reload',
accelerator: 'Ctrl+R', accelerator: 'Ctrl+R',
click: () => { click: () => {
this.mainWindow.webContents.reload(); this.mainWindow.webContents.reload()
} }
}, { }, {
label: 'Toggle &Full Screen', label: 'Toggle &Full Screen',
accelerator: 'F11', accelerator: 'F11',
click: () => { click: () => {
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen())
} }
}, { }, {
label: 'Toggle &Developer Tools', label: 'Toggle &Developer Tools',
accelerator: 'Alt+Ctrl+I', accelerator: 'Alt+Ctrl+I',
click: () => { click: () => {
this.mainWindow.toggleDevTools(); this.mainWindow.toggleDevTools()
} }
}] : [{ }] : [{
label: 'Toggle &Full Screen', label: 'Toggle &Full Screen',
accelerator: 'F11', accelerator: 'F11',
click: () => { click: () => {
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen())
} }
}] }]
}, { }, {
@ -163,26 +163,26 @@ export default class MenuBuilder {
submenu: [{ submenu: [{
label: 'Learn More', label: 'Learn More',
click() { click() {
shell.openExternal('http://electron.atom.io'); shell.openExternal('http://electron.atom.io')
} }
}, { }, {
label: 'Documentation', label: 'Documentation',
click() { 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', label: 'Community Discussions',
click() { click() {
shell.openExternal('https://discuss.atom.io/c/electron'); shell.openExternal('https://discuss.atom.io/c/electron')
} }
}, { }, {
label: 'Search Issues', label: 'Search Issues',
click() { click() {
shell.openExternal('https://github.com/atom/electron/issues'); shell.openExternal('https://github.com/atom/electron/issues')
} }
}] }]
}]; }]
return templateDefault; return templateDefault
} }
} }

2
app/reducers/channels.js

@ -271,7 +271,7 @@ export const channelGraphData = (event, data) => (dispatch, getState) => {
// Construct the notification // Construct the notification
const otherParty = info.data.identity_pubkey === advertising_node ? connecting_node : advertising_node 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' const notifTitle = 'New channel detected'
// HTML 5 notification for channel updates involving our node // HTML 5 notification for channel updates involving our node

59
test/e2e/e2e.spec.js

@ -1,54 +1,53 @@
/* eslint-disable */ /* eslint-disable */
import { Application } from 'spectron'
import electronPath from 'electron'
import path from 'path'
import { Application } from 'spectron'; jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000
import electronPath from 'electron';
import path from 'path';
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() { describe('main window', function spec() {
beforeAll(async () => { beforeAll(async () => {
this.app = new Application({ this.app = new Application({
path: electronPath, path: electronPath,
args: [path.join(__dirname, '..', '..', 'app')] args: [path.join(__dirname, '..', '..', 'app')]
}); })
return this.app.start(); return this.app.start()
}); })
afterAll(() => { afterAll(() => {
if (this.app && this.app.isRunning()) { 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 findButtons = async () => {
const { value } = await this.app.client.elements('[data-tclass="btn"]'); const { value } = await this.app.client.elements('[data-tclass="btn"]')
return value.map(btn => btn.ELEMENT); return value.map(btn => btn.ELEMENT)
}; }
it('should open window', async () => { it('should open window', async () => {
const { client, browserWindow } = this.app; const { client, browserWindow } = this.app
await client.waitUntilWindowLoaded(); await client.waitUntilWindowLoaded()
await delay(500); await delay(500)
const title = await browserWindow.getTitle(); const title = await browserWindow.getTitle()
expect(title).toBe('Zap'); expect(title).toBe('Zap')
}); })
it('should haven\'t any logs in console of main window', async () => { it('should haven\'t any logs in console of main window', async () => {
const { client } = this.app; const { client } = this.app
const logs = await client.getRenderProcessLogs(); const logs = await client.getRenderProcessLogs()
// Print renderer process logs // Print renderer process logs
logs.forEach((log) => { logs.forEach((log) => {
console.log(log.message); console.log(log.message)
console.log(log.source); console.log(log.source)
console.log(log.level); console.log(log.level)
}); })
expect(logs).toHaveLength(0); expect(logs).toHaveLength(0)
}); })
}); })

20
webpack.config.renderer.dev.js

@ -18,12 +18,12 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin'
import baseConfig from './webpack.config.base' import baseConfig from './webpack.config.base'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv' import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('development'); CheckNodeEnv('development')
const port = process.env.PORT || 1212; const port = process.env.PORT || 1212
const publicPath = `http://localhost:${port}/dist`; const publicPath = `http://localhost:${port}/dist`
const dll = path.resolve(process.cwd(), 'dll'); const dll = path.resolve(process.cwd(), 'dll')
const manifest = path.resolve(dll, 'renderer.json'); const manifest = path.resolve(dll, 'renderer.json')
/** /**
* Warn if the DLL is not built * 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))) { if (!(fs.existsSync(dll) && fs.existsSync(manifest))) {
console.log(chalk.black.bgYellow.bold( console.log(chalk.black.bgYellow.bold(
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"' '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, { export default merge.smart(baseConfig, {
@ -267,15 +267,15 @@ export default merge.smart(baseConfig, {
}, },
setup() { setup() {
if (process.env.START_HOT) { if (process.env.START_HOT) {
console.log('Starting Main Process...'); console.log('Starting Main Process...')
spawn( spawn(
'npm', 'npm',
['run', 'start-main-dev'], ['run', 'start-main-dev'],
{ shell: true, env: process.env, stdio: 'inherit' } { shell: true, env: process.env, stdio: 'inherit' }
) )
.on('close', code => process.exit(code)) .on('close', code => process.exit(code))
.on('error', spawnError => console.error(spawnError)); .on('error', spawnError => console.error(spawnError))
} }
} }
} }
}); })

Loading…
Cancel
Save