From 69efa33de1c9cb9ba0c5c219f3b4628840f98745 Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Tue, 4 Jun 2024 15:09:50 +0100 Subject: [PATCH] Switch from `Object.prototype.hasOwnProperty.call` to `Object.hasOwn` Change-type: patch --- src/translations/v6/hooks.ts | 4 ++-- test/21_fleet-target-state.ts | 2 +- test/test-lib/device-type.ts | 5 +---- test/test-lib/fixtures.ts | 5 +---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/translations/v6/hooks.ts b/src/translations/v6/hooks.ts index 72608e798..22df9f045 100644 --- a/src/translations/v6/hooks.ts +++ b/src/translations/v6/hooks.ts @@ -19,7 +19,7 @@ const addReadOnlyHook = ( const translateDeviceTypeTo = (toField: string) => async ({ request, api }: sbvrUtils.HookArgs) => { - if (Object.prototype.hasOwnProperty.call(request.values, 'device_type')) { + if (Object.hasOwn(request.values, 'device_type')) { const resinApi = sbvrUtils.api.resin.clone({ passthrough: api.passthrough, }); @@ -87,7 +87,7 @@ addReadOnlyHook(['PUT', 'POST', 'PATCH'], 'release', { addReadOnlyHook(['PUT', 'POST', 'PATCH'], 'release', { async POSTPARSE({ request }) { - if (!Object.prototype.hasOwnProperty.call(request.values, 'contract')) { + if (!Object.hasOwn(request.values, 'contract')) { return; } try { diff --git a/test/21_fleet-target-state.ts b/test/21_fleet-target-state.ts index 7cd603aff..ea7c6eb4c 100644 --- a/test/21_fleet-target-state.ts +++ b/test/21_fleet-target-state.ts @@ -14,7 +14,7 @@ config.TEST_MOCK_ONLY.API_HEARTBEAT_STATE_TIMEOUT_SECONDS = TIMEOUT_SEC; // test fleet default state helper const appMatcherFunc = (svc: AnyObject, fxProp: AnyObject) => - Object.prototype.hasOwnProperty.call(svc, 'environment') && !!fxProp; + Object.hasOwn(svc, 'environment') && !!fxProp; const svcMatcherFunc = (svc: AnyObject, fxProp: AnyObject) => svc.id === fxProp.service.__id; const imgMatcherFunc = (svc: AnyObject, fxProp: AnyObject) => diff --git a/test/test-lib/device-type.ts b/test/test-lib/device-type.ts index d20aae2d3..33c590cab 100644 --- a/test/test-lib/device-type.ts +++ b/test/test-lib/device-type.ts @@ -11,10 +11,7 @@ export const loadDefaultFixtures = () => {} as Dictionary>>, { get: (obj, slug) => { - if ( - typeof slug === 'string' && - !Object.prototype.hasOwnProperty.call(obj, slug) - ) { + if (typeof slug === 'string' && !Object.hasOwn(obj, slug)) { if (slug === 'then') { // Something is checking if we're a thenable return; diff --git a/test/test-lib/fixtures.ts b/test/test-lib/fixtures.ts index 29c02a746..1708fbbb7 100644 --- a/test/test-lib/fixtures.ts +++ b/test/test-lib/fixtures.ts @@ -599,10 +599,7 @@ export const load = async (fixtureName?: string): Promise => { .filter( (file) => file.endsWith('.json') && - Object.prototype.hasOwnProperty.call( - loaders, - file.slice(0, -'.json'.length), - ), + Object.hasOwn(loaders, file.slice(0, -'.json'.length)), ) .map((file) => file.slice(0, -'.json'.length).trim());