diff --git a/lib/browser/api/dialog.ts b/lib/browser/api/dialog.ts index c71fde0f86dc..e155ab307496 100644 --- a/lib/browser/api/dialog.ts +++ b/lib/browser/api/dialog.ts @@ -59,7 +59,7 @@ const checkAppInitialized = function () { const setupOpenDialogProperties = (properties: (keyof typeof OpenFileDialogProperties)[]): number => { let dialogProperties = 0; for (const property of properties) { - if (Object.prototype.hasOwnProperty.call(OpenFileDialogProperties, property)) { dialogProperties |= OpenFileDialogProperties[property]; } + if (Object.hasOwn(OpenFileDialogProperties, property)) { dialogProperties |= OpenFileDialogProperties[property]; } } return dialogProperties; }; @@ -67,7 +67,7 @@ const setupOpenDialogProperties = (properties: (keyof typeof OpenFileDialogPrope const setupSaveDialogProperties = (properties: (keyof typeof SaveFileDialogProperties)[]): number => { let dialogProperties = 0; for (const property of properties) { - if (Object.prototype.hasOwnProperty.call(SaveFileDialogProperties, property)) { dialogProperties |= SaveFileDialogProperties[property]; } + if (Object.hasOwn(SaveFileDialogProperties, property)) { dialogProperties |= SaveFileDialogProperties[property]; } } return dialogProperties; }; diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts index 5f39e9b014e0..8fcc528271aa 100644 --- a/lib/browser/api/menu-item-roles.ts +++ b/lib/browser/api/menu-item-roles.ts @@ -311,7 +311,7 @@ export const roleList: Record = { }; const hasRole = (role: keyof typeof roleList) => { - return Object.prototype.hasOwnProperty.call(roleList, role); + return Object.hasOwn(roleList, role); }; const canExecuteRole = (role: keyof typeof roleList) => { @@ -336,7 +336,7 @@ export function getCheckStatus (role: RoleId) { } export function shouldOverrideCheckStatus (role: RoleId) { - return hasRole(role) && Object.prototype.hasOwnProperty.call(roleList[role], 'checked'); + return hasRole(role) && Object.hasOwn(roleList[role], 'checked'); } export function getDefaultAccelerator (role: RoleId) { diff --git a/lib/browser/api/menu.ts b/lib/browser/api/menu.ts index 1499ce7e42d7..5133d24443a8 100644 --- a/lib/browser/api/menu.ts +++ b/lib/browser/api/menu.ts @@ -213,9 +213,7 @@ function areValidTemplateItems (template: (MenuItemConstructorOptions | MenuItem return template.every(item => item != null && typeof item === 'object' && - (Object.prototype.hasOwnProperty.call(item, 'label') || - Object.prototype.hasOwnProperty.call(item, 'role') || - item.type === 'separator')); + (Object.hasOwn(item, 'label') || Object.hasOwn(item, 'role') || item.type === 'separator')); } function sortTemplate (template: (MenuItemConstructorOptions | MenuItem)[]) { diff --git a/lib/browser/api/net-client-request.ts b/lib/browser/api/net-client-request.ts index cf37d608265a..f4948b26cac1 100644 --- a/lib/browser/api/net-client-request.ts +++ b/lib/browser/api/net-client-request.ts @@ -270,7 +270,7 @@ function parseOptions (optionsIn: ClientRequestConstructorOptions | string): Nod origin: options.origin, referrerPolicy: options.referrerPolicy, cache: options.cache, - allowNonHttpProtocols: Object.prototype.hasOwnProperty.call(options, kAllowNonHttpProtocols) + allowNonHttpProtocols: Object.hasOwn(options, kAllowNonHttpProtocols) }; const headers: Record = options.headers || {}; for (const [name, value] of Object.entries(headers)) { diff --git a/lib/browser/api/protocol.ts b/lib/browser/api/protocol.ts index 286bb570f73c..79e5f7c60e9b 100644 --- a/lib/browser/api/protocol.ts +++ b/lib/browser/api/protocol.ts @@ -66,7 +66,7 @@ function validateResponse (res: Response) { if (res.type === 'error') return true; - const exists = (key: string) => Object.prototype.hasOwnProperty.call(res, key); + const exists = (key: string) => Object.hasOwn(res, key); if (exists('status') && typeof res.status !== 'number') return false; if (exists('statusText') && typeof res.statusText !== 'string') return false; diff --git a/lib/renderer/security-warnings.ts b/lib/renderer/security-warnings.ts index 0aadfb632d19..619641d20edc 100644 --- a/lib/renderer/security-warnings.ts +++ b/lib/renderer/security-warnings.ts @@ -219,7 +219,7 @@ const warnAboutExperimentalFeatures = function (webPreferences?: Electron.WebPre */ const warnAboutEnableBlinkFeatures = function (webPreferences?: Electron.WebPreferences) { if (!webPreferences || - !Object.prototype.hasOwnProperty.call(webPreferences, 'enableBlinkFeatures') || + !Object.hasOwn(webPreferences, 'enableBlinkFeatures') || (webPreferences.enableBlinkFeatures != null && webPreferences.enableBlinkFeatures.length === 0)) { return; } diff --git a/lib/sandboxed_renderer/init.ts b/lib/sandboxed_renderer/init.ts index 555c7d35cdcd..cf16e33344fa 100644 --- a/lib/sandboxed_renderer/init.ts +++ b/lib/sandboxed_renderer/init.ts @@ -21,7 +21,7 @@ v8Util.setHiddenValue(global, 'Buffer', Buffer); // The process object created by webpack is not an event emitter, fix it so // the API is more compatible with non-sandboxed renderers. for (const prop of Object.keys(EventEmitter.prototype) as (keyof typeof process)[]) { - if (Object.prototype.hasOwnProperty.call(process, prop)) { + if (Object.hasOwn(process, prop)) { delete process[prop]; } } diff --git a/spec/api-net-spec.ts b/spec/api-net-spec.ts index a42a00c72781..501dc6307a2b 100644 --- a/spec/api-net-spec.ts +++ b/spec/api-net-spec.ts @@ -81,7 +81,7 @@ let routeFailure = false; respondNTimes.toRoutes = (routes: Record, n: number) => { return respondNTimes((request, response) => { - if (Object.prototype.hasOwnProperty.call(routes, request.url || '')) { + if (Object.hasOwn(routes, request.url || '')) { (async () => { await Promise.resolve(routes[request.url || ''](request, response)); })().catch((err) => { diff --git a/spec/asar-spec.ts b/spec/asar-spec.ts index 9d67cab39f54..b15a3d314978 100644 --- a/spec/asar-spec.ts +++ b/spec/asar-spec.ts @@ -1312,7 +1312,6 @@ describe('asar package', function () { itremote('can promisify all fs functions', function () { const originalFs = require('original-fs'); const util = require('node:util'); - const { hasOwnProperty } = Object.prototype; for (const [propertyName, originalValue] of Object.entries(originalFs)) { // Some properties exist but have a value of `undefined` on some platforms. @@ -1321,7 +1320,7 @@ describe('asar package', function () { // Also check for `null`s, `hasOwnProperty()` can't handle them. if (typeof originalValue === 'undefined' || originalValue === null) continue; - if (hasOwnProperty.call(originalValue, util.promisify.custom)) { + if (Object.hasOwn(originalValue, util.promisify.custom)) { expect(fs).to.have.own.property(propertyName) .that.has.own.property(util.promisify.custom); } diff --git a/spec/lib/spec-helpers.ts b/spec/lib/spec-helpers.ts index fc87337727fe..72a8e27d9ce8 100644 --- a/spec/lib/spec-helpers.ts +++ b/spec/lib/spec-helpers.ts @@ -55,7 +55,7 @@ class RemoteControlApp { res.on('data', chunk => { chunks.push(chunk); }); res.on('end', () => { const ret = v8.deserialize(Buffer.concat(chunks)); - if (Object.prototype.hasOwnProperty.call(ret, 'error')) { + if (Object.hasOwn(ret, 'error')) { reject(new Error(`remote error: ${ret.error}\n\nTriggered at:`)); } else { resolve(ret.result); diff --git a/tsconfig.json b/tsconfig.json index f233f2c0f940..0386154f71c1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,7 @@ "module": "commonjs", "target": "es2020", "lib": [ - "es2019", - "esnext.weakref", + "es2022", "dom", "dom.iterable" ],