diff --git a/src/components/settings_modal/admin_tabs/mailer_tab.js b/src/components/settings_modal/admin_tabs/mailer_tab.js index 44b2f33df..f6cd854b4 100644 --- a/src/components/settings_modal/admin_tabs/mailer_tab.js +++ b/src/components/settings_modal/admin_tabs/mailer_tab.js @@ -57,7 +57,7 @@ const MailerTab = { const descriptions = this.$store.state.adminSettings.descriptions const mailerStuff = descriptions[':pleroma']['Pleroma.Emails.Mailer'] const adapterStuff = mailerStuff[':subgroup,' + this.adapter] - return Object.prototype.hasOwnProperty.call(adapterStuff, key) + return Object.hasOwn(adapterStuff, key) } } } diff --git a/src/components/status/status.js b/src/components/status/status.js index eebae459b..4112ed44e 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -397,7 +397,7 @@ const Status = { }, tags () { // eslint-disable-next-line no-prototype-builtins - return this.status.tags.filter(tagObj => tagObj.hasOwnProperty('name')).map(tagObj => tagObj.name).join(' ') + return this.status.tags.filter(tagObj => Object.hasOwn(tagObj, 'name')).map(tagObj => tagObj.name).join(' ') }, hidePostStats () { return this.mergedConfig.hidePostStats diff --git a/src/modules/notifications.js b/src/modules/notifications.js index c5c607922..f1c39b180 100644 --- a/src/modules/notifications.js +++ b/src/modules/notifications.js @@ -109,7 +109,7 @@ export const notifications = { // Only add a new notification if we don't have one for the same action // eslint-disable-next-line no-prototype-builtins - if (!state.idStore.hasOwnProperty(notification.id)) { + if (!Object.hasOwn(state.idStore, notification.id)) { commit('updateNotificationsMinMaxId', notification.id) commit('addNewNotifications', { notifications: [notification] }) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 28f1bc2aa..1e60e2272 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -39,9 +39,9 @@ const qvitterStatusType = (status) => { export const parseUser = (data) => { const output = {} - const masto = Object.prototype.hasOwnProperty.call(data, 'acct') + const masto = Object.hasOwn(data, 'acct') // case for users in "mentions" property for statuses in MastoAPI - const mastoShort = masto && !Object.prototype.hasOwnProperty.call(data, 'avatar') + const mastoShort = masto && !Object.hasOwn(data, 'avatar') output.inLists = null output.id = String(data.id) @@ -269,7 +269,7 @@ export const parseUser = (data) => { export const parseAttachment = (data) => { const output = {} - const masto = !Object.prototype.hasOwnProperty.call(data, 'oembed') + const masto = !Object.hasOwn(data, 'oembed') if (masto) { // Not exactly same... @@ -300,7 +300,7 @@ export const parseSource = (data) => { export const parseStatus = (data) => { const output = {} - const masto = Object.prototype.hasOwnProperty.call(data, 'account') + const masto = Object.hasOwn(data, 'account') if (masto) { output.favorited = data.favourited @@ -432,7 +432,7 @@ export const parseStatus = (data) => { output.favoritedBy = [] output.rebloggedBy = [] - if (Object.prototype.hasOwnProperty.call(data, 'originalStatus')) { + if (Object.hasOwn(data, 'originalStatus')) { Object.assign(output, data.originalStatus) } @@ -444,7 +444,7 @@ export const parseNotification = (data) => { favourite: 'like', reblog: 'repeat' } - const masto = !Object.prototype.hasOwnProperty.call(data, 'ntype') + const masto = !Object.hasOwn(data, 'ntype') const output = {} if (masto) { diff --git a/src/services/errors/errors.js b/src/services/errors/errors.js index f0cc6dad7..ef18c36ed 100644 --- a/src/services/errors/errors.js +++ b/src/services/errors/errors.js @@ -37,7 +37,7 @@ export class RegistrationError extends Error { if (typeof error === 'string') { error = JSON.parse(error) // eslint-disable-next-line - if (error.hasOwnProperty('error')) { + if (Object.hasOwn(error, 'error')) { error = JSON.parse(error.error) } } diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js index 90c6180f4..29392610a 100644 --- a/src/services/style_setter/style_setter.js +++ b/src/services/style_setter/style_setter.js @@ -254,7 +254,7 @@ export const applyConfig = (input) => { styleSheet.addRule(`:root { ${rules} }`) // TODO find a way to make this not apply to theme previews - if (Object.prototype.hasOwnProperty.call(config, 'forcedRoundness')) { + if (Object.hasOwn(config, 'forcedRoundness')) { styleSheet.addRule(` *:not(.preview-block) { --roundness: var(--forcedRoundness) !important; }`) diff --git a/src/stores/interface.js b/src/stores/interface.js index 5148daa4c..a5631ab17 100644 --- a/src/stores/interface.js +++ b/src/stores/interface.js @@ -668,16 +668,16 @@ export const normalizeThemeData = (input) => { // this might not be even used at all, some leftover of unimplemented code in V2 editor return generatePreset(input).theme } else if ( - Object.prototype.hasOwnProperty.call(input, '_pleroma_theme_version') || - Object.prototype.hasOwnProperty.call(input, 'source') || - Object.prototype.hasOwnProperty.call(input, 'theme') + Object.hasOwn(input, '_pleroma_theme_version') || + Object.hasOwn(input, 'source') || + Object.hasOwn(input, 'theme') ) { // We got passed a full theme file themeData = input.theme themeSource = input.source } else if ( - Object.prototype.hasOwnProperty.call(input, 'themeEngineVersion') || - Object.prototype.hasOwnProperty.call(input, 'colors') + Object.hasOwn(input, 'themeEngineVersion') || + Object.hasOwn(input, 'colors') ) { // We got passed a source/snapshot themeData = input diff --git a/src/stores/serverSideStorage.js b/src/stores/serverSideStorage.js index 40f69c7c2..78bac1259 100644 --- a/src/stores/serverSideStorage.js +++ b/src/stores/serverSideStorage.js @@ -170,10 +170,10 @@ const _mergeJournal = (...journals) => { const allJournals = flatten( journals.map(j => Array.isArray(j) ? j : []) ).filter(entry => - Object.prototype.hasOwnProperty.call(entry, 'path') && - Object.prototype.hasOwnProperty.call(entry, 'operation') && - Object.prototype.hasOwnProperty.call(entry, 'args') && - Object.prototype.hasOwnProperty.call(entry, 'timestamp') + Object.hasOwn(entry, 'path') && + Object.hasOwn(entry, 'operation') && + Object.hasOwn(entry, 'args') && + Object.hasOwn(entry, 'timestamp') ) const grouped = groupBy(allJournals, 'path') const trimmedGrouped = Object.entries(grouped).map(([path, journal]) => { diff --git a/test/unit/specs/boot/routes.spec.js b/test/unit/specs/boot/routes.spec.js index ff246d2b3..2029eca10 100644 --- a/test/unit/specs/boot/routes.spec.js +++ b/test/unit/specs/boot/routes.spec.js @@ -20,7 +20,7 @@ describe('routes', () => { const matchedComponents = router.currentRoute.value.matched // eslint-disable-next-line no-prototype-builtins - expect(matchedComponents[0].components.default.components.hasOwnProperty('Timeline')).to.eql(true) + expect(Object.hasOwn(matchedComponents[0].components.default.components, 'Timeline')).to.eql(true) }) it('user\'s profile', async () => { @@ -29,7 +29,7 @@ describe('routes', () => { const matchedComponents = router.currentRoute.value.matched // eslint-disable-next-line no-prototype-builtins - expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true) + expect(Object.hasOwn(matchedComponents[0].components.default.components, 'UserCard')).to.eql(true) }) it('user\'s profile at /users', async () => { @@ -38,7 +38,7 @@ describe('routes', () => { const matchedComponents = router.currentRoute.value.matched // eslint-disable-next-line no-prototype-builtins - expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true) + expect(Object.hasOwn(matchedComponents[0].components.default.components, 'UserCard')).to.eql(true) }) it('list view', async () => { @@ -46,7 +46,7 @@ describe('routes', () => { const matchedComponents = router.currentRoute.value.matched - expect(Object.prototype.hasOwnProperty.call(matchedComponents[0].components.default.components, 'ListsCard')).to.eql(true) + expect(Object.hasOwn(matchedComponents[0].components.default.components, 'ListsCard')).to.eql(true) }) it('list timeline', async () => { @@ -54,7 +54,7 @@ describe('routes', () => { const matchedComponents = router.currentRoute.value.matched - expect(Object.prototype.hasOwnProperty.call(matchedComponents[0].components.default.components, 'Timeline')).to.eql(true) + expect(Object.hasOwn(matchedComponents[0].components.default.components, 'Timeline')).to.eql(true) }) it('list edit', async () => { @@ -62,6 +62,6 @@ describe('routes', () => { const matchedComponents = router.currentRoute.value.matched - expect(Object.prototype.hasOwnProperty.call(matchedComponents[0].components.default.components, 'BasicUserCard')).to.eql(true) + expect(Object.hasOwn(matchedComponents[0].components.default.components, 'BasicUserCard')).to.eql(true) }) }) diff --git a/test/unit/specs/services/theme_data/sanity_checks.spec.js b/test/unit/specs/services/theme_data/sanity_checks.spec.js index b9053f377..bb47653db 100644 --- a/test/unit/specs/services/theme_data/sanity_checks.spec.js +++ b/test/unit/specs/services/theme_data/sanity_checks.spec.js @@ -6,7 +6,7 @@ const checkColors = (output) => { expect(v, key).to.be.an('object') expect(v, key).to.include.all.keys('r', 'g', 'b') 'rgba'.split('').forEach(k => { - if ((k === 'a' && Object.prototype.hasOwnProperty.call(v, 'a')) || k !== 'a') { + if ((k === 'a' && Object.hasOwn(v, 'a')) || k !== 'a') { expect(v[k], key + '.' + k).to.be.a('number') expect(v[k], key + '.' + k).to.be.least(0) expect(v[k], key + '.' + k).to.be.most(k === 'a' ? 1 : 255)