From ffb809bbca73fd5a9b81dac422c91532688b6fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 10 Oct 2018 21:21:29 +0200 Subject: [PATCH] Prefer const over let --- bin/extra-lint.js | 2 +- src/main/index.js | 2 +- src/renderer/controllers/torrent-list-controller.js | 2 +- src/renderer/lib/state.js | 2 +- src/renderer/lib/telemetry.js | 2 +- src/renderer/lib/torrent-poster.js | 2 +- src/renderer/main.js | 2 +- src/renderer/pages/player-page.js | 8 ++++---- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/extra-lint.js b/bin/extra-lint.js index 30b9c9edf6..18a2915a01 100755 --- a/bin/extra-lint.js +++ b/bin/extra-lint.js @@ -35,7 +35,7 @@ files.forEach(function (file) { } if (error) { - let name = path.basename(file) + const name = path.basename(file) console.log('%s:%d - %s:\n%s', name, i + 1, error, line) hasErrors = true } diff --git a/src/main/index.js b/src/main/index.js index f3e88d2bdb..2b61eeaf5e 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -192,7 +192,7 @@ function sliceArgv (argv) { } function processArgv (argv) { - let torrentIds = [] + const torrentIds = [] argv.forEach(function (arg) { if (arg === '-n' || arg === '-o' || arg === '-u') { // Critical path: Only load the 'dialog' package if it is needed diff --git a/src/renderer/controllers/torrent-list-controller.js b/src/renderer/controllers/torrent-list-controller.js index f726c800f2..e32cfcbc0d 100644 --- a/src/renderer/controllers/torrent-list-controller.js +++ b/src/renderer/controllers/torrent-list-controller.js @@ -318,7 +318,7 @@ module.exports = class TorrentListController { function findFilesRecursive (paths, cb_) { if (paths.length > 1) { let numComplete = 0 - let ret = [] + const ret = [] paths.forEach(function (path) { findFilesRecursive([path], function (fileObjs) { ret.push(...fileObjs) diff --git a/src/renderer/lib/state.js b/src/renderer/lib/state.js index e42bf8f222..0a5547721e 100644 --- a/src/renderer/lib/state.js +++ b/src/renderer/lib/state.js @@ -236,7 +236,7 @@ function saveImmediate (state, cb) { .filter((x) => x.infoHash) .map(function (x) { const torrent = {} - for (let key in x) { + for (const key in x) { if (key === 'progress' || key === 'torrentKey') { continue // Don't save progress info or key for the webtorrent process } diff --git a/src/renderer/lib/telemetry.js b/src/renderer/lib/telemetry.js index 31e2130364..d0e400a209 100644 --- a/src/renderer/lib/telemetry.js +++ b/src/renderer/lib/telemetry.js @@ -98,7 +98,7 @@ function getSystemInfo () { function getTorrentStats (state) { const count = state.saved.torrents.length let sizeMB = 0 - let byStatus = { + const byStatus = { new: { count: 0, sizeMB: 0 }, downloading: { count: 0, sizeMB: 0 }, seeding: { count: 0, sizeMB: 0 }, diff --git a/src/renderer/lib/torrent-poster.js b/src/renderer/lib/torrent-poster.js index b67d66f534..b4d72869d5 100644 --- a/src/renderer/lib/torrent-poster.js +++ b/src/renderer/lib/torrent-poster.js @@ -98,7 +98,7 @@ function scoreAudioCoverFile (imgFile) { spectrogram: -80 } - for (let keyword in relevanceScore) { + for (const keyword in relevanceScore) { if (fileName === keyword) { return relevanceScore[keyword] } diff --git a/src/renderer/main.js b/src/renderer/main.js index 9beab04c85..ae333be7d2 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -5,7 +5,7 @@ * actually used because auto-prefixing is disabled with * `darkBaseTheme.userAgent = false`. Return a fake object. */ -let Module = require('module') +const Module = require('module') const _require = Module.prototype.require Module.prototype.require = function (id) { if (id === 'inline-style-prefixer') return {} diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 5996241bd7..6cb1f86339 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -734,14 +734,14 @@ function formatTime (time, total) { return '0:00' } - let totalHours = Math.floor(total / 3600) - let totalMinutes = Math.floor(total % 3600 / 60) - let hours = Math.floor(time / 3600) + const totalHours = Math.floor(total / 3600) + const totalMinutes = Math.floor(total % 3600 / 60) + const hours = Math.floor(time / 3600) let minutes = Math.floor(time % 3600 / 60) if (totalMinutes > 9) { minutes = zeroFill(2, minutes) } - let seconds = zeroFill(2, Math.floor(time % 60)) + const seconds = zeroFill(2, Math.floor(time % 60)) return (totalHours > 0 ? hours + ':' : '') + minutes + ':' + seconds }