refactor: replace Object.prototype.hasOwnProperty() with Object.hasOwn() (#38929)
This commit is contained in:
parent
09669f9d21
commit
607e71d563
11 changed files with 13 additions and 17 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -311,7 +311,7 @@ export const roleList: Record<RoleId, Role> = {
|
|||
};
|
||||
|
||||
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) {
|
||||
|
|
|
@ -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)[]) {
|
||||
|
|
|
@ -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<string, string | string[]> = options.headers || {};
|
||||
for (const [name, value] of Object.entries(headers)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue