diff --git a/lib/browser/api/dialog.ts b/lib/browser/api/dialog.ts index e155ab3074..3ec49b8bc2 100644 --- a/lib/browser/api/dialog.ts +++ b/lib/browser/api/dialog.ts @@ -194,8 +194,8 @@ const messageBox = (sync: boolean, window: BrowserWindow | null, options?: Messa if (cancelId == null) { // If the defaultId is set to 0, ensure the cancel button is a different index (1) cancelId = (defaultId === 0 && buttons.length > 1) ? 1 : 0; - for (let i = 0; i < buttons.length; i++) { - const text = buttons[i].toLowerCase(); + for (const [i, button] of buttons.entries()) { + const text = button.toLowerCase(); if (text === 'cancel' || text === 'no') { cancelId = i; break; diff --git a/spec/api-desktop-capturer-spec.ts b/spec/api-desktop-capturer-spec.ts index 55dcaf4205..b7729ac748 100644 --- a/spec/api-desktop-capturer-spec.ts +++ b/spec/api-desktop-capturer-spec.ts @@ -60,8 +60,8 @@ ifdescribe(!process.arch.includes('arm') && process.platform !== 'win32')('deskt const sources = await desktopCapturer.getSources({ types: ['screen'] }); expect(sources).to.be.an('array').of.length(displays.length); - for (let i = 0; i < sources.length; i++) { - expect(sources[i].display_id).to.equal(displays[i].id.toString()); + for (const [i, source] of sources.entries()) { + expect(source.display_id).to.equal(displays[i].id.toString()); } }); diff --git a/spec/api-subframe-spec.ts b/spec/api-subframe-spec.ts index c5e5b50302..1a56612695 100644 --- a/spec/api-subframe-spec.ts +++ b/spec/api-subframe-spec.ts @@ -133,14 +133,14 @@ describe('renderer nodeIntegrationInSubFrames', () => { const generateConfigs = (webPreferences: any, ...permutations: {name: string, webPreferences: any}[]) => { const configs = [{ webPreferences, names: [] as string[] }]; - for (let i = 0; i < permutations.length; i++) { + for (const permutation of permutations) { const length = configs.length; for (let j = 0; j < length; j++) { const newConfig = Object.assign({}, configs[j]); newConfig.webPreferences = Object.assign({}, - newConfig.webPreferences, permutations[i].webPreferences); + newConfig.webPreferences, permutation.webPreferences); newConfig.names = newConfig.names.slice(0); - newConfig.names.push(permutations[i].name); + newConfig.names.push(permutation.name); configs.push(newConfig); } } diff --git a/spec/lib/video-helpers.js b/spec/lib/video-helpers.js index c376b1598d..b2ff78a6de 100644 --- a/spec/lib/video-helpers.js +++ b/spec/lib/video-helpers.js @@ -313,16 +313,16 @@ function bitsToBuffer (bits) { function generateEBML (json) { const ebml = []; - for (let i = 0; i < json.length; i++) { - if (!('id' in json[i])) { + for (const item of json) { + if (!('id' in item)) { // already encoded blob or byteArray - ebml.push(json[i]); + ebml.push(item); continue; } - let data = json[i].data; + let data = item.data; if (typeof data === 'object') data = generateEBML(data); - if (typeof data === 'number') data = ('size' in json[i]) ? numToFixedBuffer(data, json[i].size) : bitsToBuffer(data.toString(2)); + if (typeof data === 'number') data = ('size' in item) ? numToFixedBuffer(data, item.size) : bitsToBuffer(data.toString(2)); if (typeof data === 'string') data = strToBuffer(data); const len = data.size || data.byteLength || data.length; @@ -335,7 +335,7 @@ function generateEBML (json) { // going to fix this, i'm probably just going to write some hacky thing which // converts that string into a buffer-esque thing - ebml.push(numToBuffer(json[i].id)); + ebml.push(numToBuffer(item.id)); ebml.push(bitsToBuffer(size)); ebml.push(data); } @@ -349,13 +349,13 @@ function toFlatArray (arr, outBuffer) { if (outBuffer == null) { outBuffer = []; } - for (let i = 0; i < arr.length; i++) { - if (typeof arr[i] === 'object') { + for (const item of arr) { + if (typeof item === 'object') { // an array - toFlatArray(arr[i], outBuffer); + toFlatArray(item, outBuffer); } else { // a simple element - outBuffer.push(arr[i]); + outBuffer.push(item); } } return outBuffer; diff --git a/spec/ts-smoke/electron/renderer.ts b/spec/ts-smoke/electron/renderer.ts index 8fc55790d0..16d0f9c02b 100644 --- a/spec/ts-smoke/electron/renderer.ts +++ b/spec/ts-smoke/electron/renderer.ts @@ -74,14 +74,14 @@ crashReporter.start({ // https://github.com/electron/electron/blob/main/docs/api/desktop-capturer.md getSources({ types: ['window', 'screen'] }).then(sources => { - for (let i = 0; i < sources.length; ++i) { - if (sources[i].name === 'Electron') { + for (const source of sources) { + if (source.name === 'Electron') { (navigator as any).webkitGetUserMedia({ audio: false, video: { mandatory: { chromeMediaSource: 'desktop', - chromeMediaSourceId: sources[i].id, + chromeMediaSourceId: source.id, minWidth: 1280, maxWidth: 1280, minHeight: 720,