From d0dc2380eaab4a0972f29898d6a5025d870c2ec7 Mon Sep 17 00:00:00 2001 From: Sam Schloegel Date: Mon, 3 Jan 2022 14:48:13 -0500 Subject: [PATCH] eslint fix prefer-arrow-callback errors --- main.js | 4 ++-- preload.js | 16 ++++++++-------- src/device.js | 29 ++++++++++++----------------- src/plugins.js | 2 +- src/search.js | 38 +++++++++++++++++--------------------- 5 files changed, 40 insertions(+), 49 deletions(-) diff --git a/main.js b/main.js index b612d84..3edb624 100644 --- a/main.js +++ b/main.js @@ -50,7 +50,7 @@ const createWindow = () => { app.whenReady().then(() => { createWindow(); - app.on('activate', function () { + app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); }); }); @@ -78,7 +78,7 @@ ipcMain.on('disableSearchAll', (event, arg) => { menu.getMenuItemById('deviceSearch').enabled = false; }); -ipcMain.on('setDevicePin', function (event, arg) { +ipcMain.on('setDevicePin', (event, arg) => { menu.getMenuItemById('devicePin').checked = arg; }); diff --git a/preload.js b/preload.js index 128b41f..30fa12c 100644 --- a/preload.js +++ b/preload.js @@ -20,7 +20,7 @@ window.init = function () { ipcRenderer.send('enableDeviceDropdown'); ipcRenderer.send('enableSearchAll'); - PLUGINS.init(function () { + PLUGINS.init(() => { VIEW.init(); SAVESLOTS.loadDevices(); SAVESLOTS.loadSlot(1); @@ -138,7 +138,7 @@ window.init = function () { }; }; -ipcRenderer.on('setActiveDevicePinned', function (event, message) { +ipcRenderer.on('setActiveDevicePinned', (event, message) => { if (!message) { VIEW.unpinActiveDevice(); } else { @@ -146,25 +146,25 @@ ipcRenderer.on('setActiveDevicePinned', function (event, message) { } }); -ipcRenderer.on('doSearch', function (event, message) { +ipcRenderer.on('doSearch', (event, message) => { window.searchAll(); }); -ipcRenderer.on('doDelete', function (event, message) { +ipcRenderer.on('doDelete', (event, message) => { DEVICE.deleteActive(); }); -ipcRenderer.on('resetViews', function (event, message) { +ipcRenderer.on('resetViews', (event, message) => { SAVESLOTS.resetSlots(); }); -ipcRenderer.on('doSlots1', function (event, message) { +ipcRenderer.on('doSlots1', (event, message) => { SAVESLOTS.loadSlot(1); }); -ipcRenderer.on('doSlots2', function (event, message) { +ipcRenderer.on('doSlots2', (event, message) => { SAVESLOTS.loadSlot(2); }); -ipcRenderer.on('doSlots3', function (event, message) { +ipcRenderer.on('doSlots3', (event, message) => { SAVESLOTS.loadSlot(3); }); diff --git a/src/device.js b/src/device.js index 95a954c..8c8ce3f 100644 --- a/src/device.js +++ b/src/device.js @@ -91,17 +91,17 @@ initDeviceConnection = function (id) { port: device.port, }); device.connection.open(); - device.connection.on('error', function (error) { + device.connection.on('error', (error) => { // console.error(error) device.connection.close(); }); - device.connection.on('ready', function () { + device.connection.on('ready', () => { plugins[type].ready(device); if (Object.keys(devices).length == 1) { VIEW.switchDevice(device.id); } }); - device.connection.on('message', function (message) { + device.connection.on('message', (message) => { // log("OSC IN", message.address); plugins[type].data(device, message); device.lastMessage = Date.now(); @@ -115,19 +115,19 @@ initDeviceConnection = function (id) { device.connection.connect( { port: device.port, host: device.addresses[0] }, - function () {} + () => {} ); - device.connection.on('error', function (error) { + device.connection.on('error', (error) => { // console.error(error) }); - device.connection.on('ready', function () { + device.connection.on('ready', () => { plugins[type].ready(device); if (Object.keys(devices).length == 1) { VIEW.switchDevice(device.id); } }); - device.connection.on('data', function (message) { + device.connection.on('data', (message) => { // log("SOCK IN", message); plugins[type].data(device, message); device.lastMessage = Date.now(); @@ -140,24 +140,19 @@ initDeviceConnection = function (id) { } else if (plugins[type].connectionType == 'UDPsocket') { device.connection = udp.createSocket('udp4'); - device.connection.bind(function () { + device.connection.bind(() => { plugins[type].ready(device); - device.connection.on('message', function (msg, info) { + device.connection.on('message', (msg, info) => { plugins[type].data(device, msg); infoUpdate(device, 'status', 'ok'); }); }); device.send = function (data) { - device.connection.send( - data, - device.port, - device.addresses[0], - function (err) { - // console.log(err); - } - ); + device.connection.send(data, device.port, device.addresses[0], (err) => { + // console.log(err); + }); }; } }; diff --git a/src/plugins.js b/src/plugins.js index b3a0672..fcff015 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -8,7 +8,7 @@ module.exports.all = allPlugins; module.exports.init = function (callback) { console.log(`Loading plugin files... ${__dirname}/../plugins`); - fs.readdir(`${__dirname}/../plugins`, function (err, files) { + fs.readdir(`${__dirname}/../plugins`, (err, files) => { for (var i in files) { var plugin = files[i]; diff --git a/src/search.js b/src/search.js index b0241f4..4159498 100644 --- a/src/search.js +++ b/src/search.js @@ -66,7 +66,7 @@ searchAll = function () { // searchTCP(); // searchUDP(); - setTimeout(function () { + setTimeout(() => { searching = false; document.getElementById('search-button').style.opacity = ''; @@ -91,7 +91,7 @@ module.exports.searchAll = searchAll; // |__/ newSearchBonjour = function (pluginType, plugin) { - bonjour.find({ type: plugin.searchOptions.bonjourName }, function (e) { + bonjour.find({ type: plugin.searchOptions.bonjourName }, (e) => { console.log(pluginType); var validAddresses = []; @@ -141,19 +141,15 @@ newSearchTCP = function (pluginType, plugin) { }; TCPtest = function (ip, pluginType, plugin) { - var client = net.createConnection( - plugin.searchOptions.testPort, - ip, - function () { - client.write(plugin.searchOptions.searchBuffer); - // DEVICE.registerDevice({ - // type: pluginType, - // defaultName: plugin.defaultName, - // port: plugin.defaultPort, - // addresses: [ip] - // }) - } - ); + var client = net.createConnection(plugin.searchOptions.testPort, ip, () => { + client.write(plugin.searchOptions.searchBuffer); + // DEVICE.registerDevice({ + // type: pluginType, + // defaultName: plugin.defaultName, + // port: plugin.defaultPort, + // addresses: [ip] + // }) + }); client.on('data', (data) => { if (plugin.searchOptions.validateResponse(data)) { DEVICE.registerDevice({ @@ -165,7 +161,7 @@ TCPtest = function (ip, pluginType, plugin) { } client.end(); }); - client.on('error', function (err) { + client.on('error', (err) => { // no device here }); }; @@ -295,7 +291,7 @@ var searchSockets = []; newSearchUDP = function (pluginType, plugin) { var i = searchSockets.push(dgram.createSocket('udp4')) - 1; - searchSockets[i].bind(plugin.searchOptions.listenPort, function () { + searchSockets[i].bind(plugin.searchOptions.listenPort, () => { searchSockets[i].send( plugin.searchOptions.searchBuffer, plugin.searchOptions.devicePort, @@ -304,7 +300,7 @@ newSearchUDP = function (pluginType, plugin) { // console.log(err) } ); - setTimeout(function () { + setTimeout(() => { searchSockets[i].send( plugin.searchOptions.searchBuffer, plugin.searchOptions.devicePort, @@ -314,7 +310,7 @@ newSearchUDP = function (pluginType, plugin) { } ); }, 100); - setTimeout(function () { + setTimeout(() => { searchSockets[i].send( plugin.searchOptions.searchBuffer, plugin.searchOptions.devicePort, @@ -325,7 +321,7 @@ newSearchUDP = function (pluginType, plugin) { ); }, 400); - searchSockets[i].on('message', function (msg, info) { + searchSockets[i].on('message', (msg, info) => { if (plugin.searchOptions.validateResponse(msg, info)) { DEVICE.registerDevice({ type: pluginType, @@ -336,7 +332,7 @@ newSearchUDP = function (pluginType, plugin) { } }); }); - searchSockets[i].on('listening', function () { + searchSockets[i].on('listening', () => { searchSockets[i].setBroadcast(true); }); };