Merge branch 'benpai-js-modern' into 'main'

Benpai JS Modernization

See merge request PronounsPage/PronounsPage!556
This commit is contained in:
Benjamin 2025-01-16 22:24:08 +00:00
commit 8cc8ab4b95
33 changed files with 29 additions and 54 deletions

View File

@ -91,7 +91,7 @@ export default {
if (this.validateUserHandle) {
clearTimeout(this.validateUserHandle);
}
if (!v || this.validateUserCache.hasOwnProperty(v)) {
if (!v || Object.hasOwn(this.validateUserCache, v)) {
return;
}
this.validateUserHandle = setTimeout(async () => {

View File

@ -49,7 +49,7 @@ export default defineComponent({
new window.L.GridLayer.TinyWorld({ maxZoom: 19 }).addTo(map);
for (const walsLanguage of walsLanguages) {
if (!localesByWalsCode.hasOwnProperty(walsLanguage.id)) {
if (!Object.hasOwn(localesByWalsCode, walsLanguage.id)) {
continue;
}
const locale = localesByWalsCode[walsLanguage.id];

View File

@ -95,7 +95,7 @@ export default {
return this.validation && this.validation(val.value);
},
getIcon(opinion) {
if (opinions.hasOwnProperty(opinion)) {
if (Object.hasOwn(opinions, opinion)) {
return opinions[opinion].icon;
}
for (const op of this.customOpinions) {

View File

@ -31,7 +31,7 @@ const setSpelling = (spelling: string) => {
<template>
<div class="pt-1">
<div v-if="spellings.hasOwnProperty(config.locale)" class="btn-group m-2">
<div v-if="Object.hasOwn(spellings, config.locale)" class="btn-group m-2">
<button
v-for="(display, code) in spellings[config.locale]"
:class="['btn btn-sm', getSpelling() === code ? 'btn-secondary disabled' : 'btn-outline-secondary', code === 'sitelen' ? 'sitelen' : '']"

View File

@ -60,7 +60,7 @@ export default {
return {
pronouns: buildDict(function* () {
for (const name in that.t) {
if (!that.t.hasOwnProperty(name)) {
if (!Object.hasOwn(that.t, name)) {
continue;
}
yield [name, getPronoun(pronouns, name)];

View File

@ -67,7 +67,7 @@ export default {
return {
pronouns: buildDict(function* () {
for (const name in that.t) {
if (!that.t.hasOwnProperty(name)) {
if (!Object.hasOwn(that.t, name)) {
continue;
}
yield [name, getPronoun(pronouns, name)];

View File

@ -67,7 +67,7 @@ export default {
return {
pronouns: buildDict(function* () {
for (const name in that.t) {
if (!that.t.hasOwnProperty(name)) {
if (!Object.hasOwn(that.t, name)) {
continue;
}
yield [name, getPronoun(pronouns, name)];

View File

@ -62,7 +62,6 @@
"memorystore": "^1.6.7",
"minisearch": "^7.1.1",
"nepali-calendar-js": "https://github.com/pixunil/nepali-calendar-js",
"node-fetch": "^2.6.12",
"nodemailer": "^6.7.8",
"nuxt": "^3.15.1",
"pageres": "^8.1.0",
@ -108,7 +107,6 @@
"@types/markdown-it": "^14.0.1",
"@types/multer": "1.4.5",
"@types/node": "^20.16.5",
"@types/node-fetch": "^2.6.11",
"@types/nodemailer": "^6.4.14",
"@types/papaparse": "^5.3.14",
"@types/rtlcss": "^3.1.2",

View File

@ -58,7 +58,7 @@ const hoursSummary = computed((): Record<string, number> => {
const hoursSum = computed(() => {
let sum = 0;
for (const username in hoursSummary.value) {
if (!hoursSummary.value.hasOwnProperty(username) || timesheets.value[username].transfer === 'skip') {
if (!Object.hasOwn(hoursSummary.value, username) || timesheets.value[username].transfer === 'skip') {
continue;
}
sum += hoursSummary.value[username];

View File

@ -20,7 +20,7 @@ onMounted(() => {
const supportedLocaleCodes = browserLocales
.map((code) => code.includes('-') ? code.split('-')[0] : code)
.filter((code) => locales.hasOwnProperty(code));
.filter((code) => Object.hasOwn(locales, code));
suggestedLocales.value = Object.fromEntries(
Array.from(new Set(supportedLocaleCodes))

View File

@ -77,7 +77,7 @@ const buildProfile = (
): ProfileFormData => {
// card in this locale exists
for (const locale in profiles) {
if (!profiles.hasOwnProperty(locale)) {
if (!Object.hasOwn(profiles, locale)) {
continue;
}
if (locale === config.locale) {
@ -111,7 +111,7 @@ const buildProfile = (
// card in this locale doesn't exist yet, but we can copy some non-language-specific fields from another card
for (const locale in profiles) {
if (!profiles.hasOwnProperty(locale)) {
if (!Object.hasOwn(profiles, locale)) {
continue;
}
const profile = profiles[locale];

View File

@ -8,7 +8,7 @@ export default defineNuxtPlugin(() => {
},
});
}
if (!Object.prototype.hasOwnProperty.call(window, 'BroadcastChannel')) {
if (!Object.hasOwn(window, 'BroadcastChannel')) {
Object.defineProperty(window, 'BroadcastChannel', {
value: class {
postMessage() {}

14
pnpm-lock.yaml generated
View File

@ -149,9 +149,6 @@ importers:
nepali-calendar-js:
specifier: https://github.com/pixunil/nepali-calendar-js
version: https://codeload.github.com/pixunil/nepali-calendar-js/tar.gz/a6e12cb1db54c508c49dc0c619cef0674e7c1cde
node-fetch:
specifier: ^2.6.12
version: 2.7.0(encoding@0.1.13)
nodemailer:
specifier: ^6.7.8
version: 6.9.15
@ -282,9 +279,6 @@ importers:
'@types/node':
specifier: ^20.16.5
version: 20.16.5
'@types/node-fetch':
specifier: ^2.6.11
version: 2.6.11
'@types/nodemailer':
specifier: ^6.4.14
version: 6.4.16
@ -2820,9 +2814,6 @@ packages:
'@types/multer@1.4.5':
resolution: {integrity: sha512-9b/0a8JyrR0r2nQhL73JR86obWL7cogfX12augvlrvcpciCo/hkvEsgu80Z4S2g2DHGVXHr8pUIi1VhqFJ8Ufw==}
'@types/node-fetch@2.6.11':
resolution: {integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==}
'@types/node@20.16.5':
resolution: {integrity: sha512-VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA==}
@ -12014,11 +12005,6 @@ snapshots:
dependencies:
'@types/express': 4.17.21
'@types/node-fetch@2.6.11':
dependencies:
'@types/node': 20.16.5
form-data: 4.0.0
'@types/node@20.16.5':
dependencies:
undici-types: 6.19.8

View File

@ -63,7 +63,7 @@ const dumpNameDays = async (): Promise<void> => {
const current = buildCalendar(process.env.BASE_URL!).buildSummary();
const changedYears = new Set();
for (const day in current) {
if (!current.hasOwnProperty(day)) {
if (!Object.hasOwn(current, day)) {
continue;
}
const year = day.substring(0, 4);

View File

@ -5,7 +5,6 @@ import fs from 'fs';
import { AtpAgent, RichText } from '@atproto/api';
import * as Sentry from '@sentry/node';
import Mastodon from 'mastodon';
import fetch from 'node-fetch';
import Twitter from 'twitter';
import buildLocaleList from '../src/buildLocaleList.ts';

View File

@ -1,5 +1,3 @@
import fetch from 'node-fetch';
export const validateCaptcha = async (token: string): Promise<boolean> => {
const res = await fetch('https://challenges.cloudflare.com/turnstile/v0/siteverify', {
method: 'POST',

View File

@ -26,7 +26,7 @@ const renderEvents = (yearEvents: Record<number, Event[]>, res: Response, onlyFi
const events = [];
let i = 1;
for (const year in yearEvents) {
if (!yearEvents.hasOwnProperty(year)) {
if (!Object.hasOwn(yearEvents, year)) {
continue;
}
for (const event of yearEvents[year]) {

View File

@ -4,7 +4,6 @@
import assert from 'assert';
import { Router } from 'express';
import fetch from 'node-fetch';
import { handleErrorAsync } from '../../src/helpers.ts';
import type { Database } from '../db.ts';

View File

@ -462,7 +462,7 @@ const fetchCircles = async (db: Database, profileId: string, userId: string): Pr
const circle: Record<string, Omit<RelatedPerson, 'locale'> & { locale: string[] }> = {};
for (const connection of connections) {
if (!circle.hasOwnProperty(connection.username)) {
if (!Object.hasOwn(circle, connection.username)) {
circle[connection.username] = {
username: connection.username,
avatar: await avatar(db, connection),
@ -575,7 +575,7 @@ const findCircleMentions = async (db: Database, userId: string) => {
const mentionsGrouped: Record<string, Record<string, string>> = {};
for (const { username, locale, relationship } of mentionsRaw) {
if (!mentionsGrouped.hasOwnProperty(username)) {
if (!Object.hasOwn(mentionsGrouped, username)) {
mentionsGrouped[username] = {};
}

View File

@ -1,7 +1,6 @@
import assert from 'assert';
import { Router } from 'express';
import fetch from 'node-fetch';
import type { PronounExamplesData } from '../../locale/data.ts';
import { buildPronoun, buildPronounUsage, parsePronounGroups, parsePronouns } from '../../src/buildPronoun.ts';

View File

@ -692,7 +692,7 @@ router.post('/user/:id/set-roles', handleErrorAsync(async (req, res) => {
// happens on home
router.get('/user/social-redirect/:provider/:locale', handleErrorAsync(async (req, res) => {
assert(req.locales.hasOwnProperty(req.params.locale));
assert(Object.hasOwn(req.locales, req.params.locale));
req.session.socialRedirect = req.params.locale;
if (req.query.token) {
res.cookie('token', req.query.token, longtimeCookieSetting);

View File

@ -1,7 +1,6 @@
import { S3 } from '@aws-sdk/client-s3';
import { loadImage, createCanvas } from 'canvas';
import md5 from 'js-md5';
import fetch from 'node-fetch';
import { awsConfig, awsParams } from './aws.ts';

View File

@ -5,7 +5,6 @@ import fs from 'fs';
import * as Sentry from '@sentry/node';
import { createEvents } from 'ics';
import { JSDOM } from 'jsdom';
import fetch from 'node-fetch';
import { Day } from '../src/calendar/helpers.ts';
import type { MiastamaszerujaceEvent } from '../src/calendar/helpers.ts';

View File

@ -54,7 +54,7 @@ async function notify() {
console.log('Entries awaiting moderation: ', count);
for (const email in awaitingModerationGrouped) {
if (!awaitingModerationGrouped.hasOwnProperty(email)) {
if (!Object.hasOwn(awaitingModerationGrouped, email)) {
continue;
}
const stats = awaitingModerationGrouped[email];

View File

@ -13,7 +13,7 @@ const _each = (obj, callable) => {
const ret = [];
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
if (Object.hasOwn(obj, key)) {
ret.push(callable(obj[key], key));
}
}

View File

@ -12,14 +12,14 @@ import dbConnection from './db.ts';
terms[term.locale][term.key] = term;
}
for (const locale in terms) {
if (!terms.hasOwnProperty(locale)) {
if (!Object.hasOwn(terms, locale)) {
continue;
}
if (locale === 'pl') {
continue;
}
for (const key in terms[locale]) {
if (!terms[locale].hasOwnProperty(key)) {
if (!Object.hasOwn(terms[locale], key)) {
continue;
}
const term = terms[locale][key];

View File

@ -91,7 +91,7 @@ export default (locale: string): Record<string, (Ad & { chance: number })[]> =>
}
for (const placeholder of ad.placeholders) {
if (!adsInternalPerPlaceholder.hasOwnProperty(placeholder)) {
if (!Object.hasOwn(adsInternalPerPlaceholder, placeholder)) {
adsInternalPerPlaceholder[placeholder] = [];
}
adsInternalPerPlaceholder[placeholder].push({ chance: 0.25, ...ad });

View File

@ -365,7 +365,7 @@ export class Year {
}
}
for (const date in this.eventsByDate) {
if (!this.eventsByDate.hasOwnProperty(date)) {
if (!Object.hasOwn(this.eventsByDate, date)) {
continue;
}
this.eventsByDate[date].sort((a, b) => b.level - a.level);
@ -383,7 +383,7 @@ export class Year {
}
}
for (const term in this.eventsByTerm) {
if (!this.eventsByTerm.hasOwnProperty(term)) {
if (!Object.hasOwn(this.eventsByTerm, term)) {
continue;
}
this.eventsByTerm[term].sort((a, b) => a.getDays(this.year)[0].toInt() - b.getDays(this.year)[0].toInt());

View File

@ -1086,7 +1086,7 @@ export class NounDeclension {
this.singular = {};
this.plural = {};
for (const k in endings) {
if (!endings.hasOwnProperty(k)) {
if (!Object.hasOwn(endings, k)) {
continue;
}
const value = endings[k] ? endings[k].split('/') : null;

View File

@ -110,7 +110,7 @@ export interface DictEntry<K extends string | number | symbol, V> {
export const dictToList = <K extends string | number | symbol, V>(dict: Record<K, V>): DictEntry<K, V>[] => {
const list = [];
for (const key in dict) {
if (dict.hasOwnProperty(key)) {
if (Object.hasOwn(dict, key)) {
list.push({ key, value: dict[key] });
}
}
@ -381,7 +381,7 @@ export class ImmutableArray<T> extends Array<T> {
const grouped: ImmutableArray<[string | number, ImmutableArray<T>]> = new ImmutableArray();
for (const el of this) {
const key = m(el);
if (!keys.hasOwnProperty(key)) {
if (!Object.hasOwn(keys, key)) {
keys[key] = grouped.length;
grouped.push([key, new ImmutableArray()]);
}

View File

@ -1,6 +1,5 @@
import AbortController from 'abort-controller';
import { JSDOM, VirtualConsole } from 'jsdom';
import fetch from 'node-fetch';
export const normaliseUrl = (url: string): string | null => {
try {

View File

@ -1,6 +1,5 @@
import fs from 'fs';
import fetch from 'node-fetch';
import Plausible from 'plausible-api';
import { decodeTime, ulid } from 'ulid';
@ -175,7 +174,7 @@ export const calculateStats = async (
const baseTranslations = loadSumlFromBase('locale/_base/translations') as Translations;
for (const locale in allLocales) {
if (!allLocales.hasOwnProperty(locale)) {
if (!Object.hasOwn(allLocales, locale)) {
continue;
}

View File

@ -105,7 +105,7 @@ export const useMainStore = defineStore('main', {
} else {
this.translationChanges = buildDict(function* (that) {
for (const k in that) {
if (!that.hasOwnProperty(k)) {
if (!Object.hasOwn(that, k)) {
continue;
}
if (k !== key) {