From 2c52eb7e1c61aa1ae5e91b4ad062dc7d67fb764e Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 24 Jul 2023 12:32:54 +0200 Subject: [PATCH] refactor: replace .indexOf() with .includes() (#39195) --- lib/browser/api/menu.ts | 2 +- script/release/prepare-release.js | 2 +- script/release/release.js | 2 +- spec/api-menu-spec.ts | 2 +- spec/security-warnings-spec.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/browser/api/menu.ts b/lib/browser/api/menu.ts index b4beee823063..3cd17a8ce7a7 100644 --- a/lib/browser/api/menu.ts +++ b/lib/browser/api/menu.ts @@ -82,7 +82,7 @@ Menu.prototype.popup = function (options = {}) { // find which window to use const wins = BaseWindow.getAllWindows(); - if (!wins || wins.indexOf(window as any) === -1) { + if (!wins || !wins.includes(window as any)) { window = BaseWindow.getFocusedWindow() as any; if (!window && wins && wins.length > 0) { window = wins[0] as any; diff --git a/script/release/prepare-release.js b/script/release/prepare-release.js index 49e4d1b94727..8ad1bfc72d21 100755 --- a/script/release/prepare-release.js +++ b/script/release/prepare-release.js @@ -117,7 +117,7 @@ async function createRelease (branchToTarget, isBeta) { name: `electron ${newVersion}`, body: releaseBody, prerelease: releaseIsPrelease, - target_commitish: newVersion.indexOf('nightly') !== -1 ? 'main' : branchToTarget + target_commitish: newVersion.includes('nightly') ? 'main' : branchToTarget }).catch(err => { console.log(`${fail} Error creating new release: `, err); process.exit(1); diff --git a/script/release/release.js b/script/release/release.js index a856cf9d8aed..148909e0fd40 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -50,7 +50,7 @@ async function getDraftRelease (version, skipValidation) { if (!skipValidation) { failureCount = 0; check(drafts.length === 1, 'one draft exists', true); - if (versionToCheck.indexOf('beta') > -1) { + if (versionToCheck.includes('beta')) { check(draft.prerelease, 'draft is a prerelease'); } check(draft.body.length > 50 && !draft.body.includes('(placeholder)'), 'draft has release notes'); diff --git a/spec/api-menu-spec.ts b/spec/api-menu-spec.ts index 95d7cc197047..a6a6243a6088 100644 --- a/spec/api-menu-spec.ts +++ b/spec/api-menu-spec.ts @@ -948,7 +948,7 @@ describe('Menu module', function () { await new Promise((resolve) => { appProcess.stdout.on('data', data => { output += data; - if (data.indexOf('Window has') > -1) { + if (data.includes('Window has')) { resolve(); } }); diff --git a/spec/security-warnings-spec.ts b/spec/security-warnings-spec.ts index e1d72be976b9..de5905fb24e7 100644 --- a/spec/security-warnings-spec.ts +++ b/spec/security-warnings-spec.ts @@ -12,7 +12,7 @@ import { listen } from './lib/spec-helpers'; import { setTimeout } from 'node:timers/promises'; const messageContainsSecurityWarning = (event: Event, level: number, message: string) => { - return message.indexOf('Electron Security Warning') > -1; + return message.includes('Electron Security Warning'); }; const isLoaded = (event: Event, level: number, message: string) => {