Skip to content

Commit

Permalink
refactor: replace .indexOf() with .includes() (electron#39195)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored Jul 24, 2023
1 parent 9cd5de7 commit 2c52eb7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/browser/api/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion script/release/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion script/release/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion spec/api-menu-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ describe('Menu module', function () {
await new Promise<void>((resolve) => {
appProcess.stdout.on('data', data => {
output += data;
if (data.indexOf('Window has') > -1) {
if (data.includes('Window has')) {
resolve();
}
});
Expand Down
2 changes: 1 addition & 1 deletion spec/security-warnings-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 2c52eb7

Please sign in to comment.