From e4e605199948481875ae240ca60495e9ccb376d2 Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Sun, 25 Jun 2023 20:59:43 -0700 Subject: [PATCH] Run linter --- app/common/util.mjs | 90 +++++++++---------- app/data/DataArchiver.mjs | 2 +- app/screenshots/ScreenshotHelper.mjs | 2 +- app/social/StatusGeneratorManager.mjs | 38 ++++---- app/social/clients/BlueskyClient.mjs | 2 +- app/social/generators/ChallengeStatus.mjs | 2 +- app/social/generators/EggstraWorkStatus.mjs | 2 +- .../generators/SalmonRunUpcomingStatus.mjs | 2 +- app/splatnet/SplatNet3Client.mjs | 2 +- src/components/RuleIcon.vue | 2 +- .../challenge/ChallengeScheduleBox.vue | 4 +- src/components/splats/Splat1.vue | 4 +- src/components/splats/Splat2.vue | 4 +- src/components/splats/Splat3.vue | 4 +- src/components/splats/Splat4.vue | 4 +- src/components/splats/Splat5.vue | 4 +- src/components/splats/Splat6.vue | 4 +- src/router/index.js | 8 +- src/router/screenshots.js | 2 +- src/stores/data.mjs | 2 +- src/stores/splatfests.mjs | 2 +- src/views/screenshots/SplatfestView.vue | 2 +- tailwind.config.js | 6 +- vite.config.js | 14 +-- 24 files changed, 104 insertions(+), 104 deletions(-) diff --git a/app/common/util.mjs b/app/common/util.mjs index faca79f..1cb30f6 100644 --- a/app/common/util.mjs +++ b/app/common/util.mjs @@ -1,84 +1,84 @@ import crypto from 'crypto'; export function getTopOfCurrentHour(date = null) { - date ??= new Date; + date ??= new Date; - date.setUTCMinutes(0); - date.setUTCSeconds(0); - date.setUTCMilliseconds(0); + date.setUTCMinutes(0); + date.setUTCSeconds(0); + date.setUTCMilliseconds(0); - return date; + return date; } function leadingZero(value) { - return value.toString().padStart(2, '0'); + return value.toString().padStart(2, '0'); } export function getDateParts(date = null) { - date ??= new Date; + date ??= new Date; - return { - year: date.getUTCFullYear(), - month: leadingZero(date.getUTCMonth() + 1), - day: leadingZero(date.getUTCDate()), - hour: leadingZero(date.getUTCHours()), - minute: leadingZero(date.getUTCMinutes()), - second: leadingZero(date.getUTCSeconds()), - }; + return { + year: date.getUTCFullYear(), + month: leadingZero(date.getUTCMonth() + 1), + day: leadingZero(date.getUTCDate()), + hour: leadingZero(date.getUTCHours()), + minute: leadingZero(date.getUTCMinutes()), + second: leadingZero(date.getUTCSeconds()), + }; } export function getGearIcon(gear) { - switch (gear.gear.__typename) { - case 'HeadGear': return '๐Ÿงข'; - case 'ClothingGear': return '๐Ÿ‘•'; - case 'ShoesGear': return '๐Ÿ‘Ÿ'; - default: return null; - } + switch (gear.gear.__typename) { + case 'HeadGear': return '๐Ÿงข'; + case 'ClothingGear': return '๐Ÿ‘•'; + case 'ShoesGear': return '๐Ÿ‘Ÿ'; + default: return null; + } } export function normalizeSplatnetResourcePath(url) { - // Parse the URL - let u = new URL(url); + // Parse the URL + let u = new URL(url); - // Get just the pathname (without the host, query string, etc.) - let result = u.pathname; + // Get just the pathname (without the host, query string, etc.) + let result = u.pathname; - // Remove "/resources/prod" from the beginning if it exists - result = result.replace(/^\/resources\/prod/, ''); + // Remove "/resources/prod" from the beginning if it exists + result = result.replace(/^\/resources\/prod/, ''); - // Remove the leading slash - result = result.replace(/^\//, ''); + // Remove the leading slash + result = result.replace(/^\//, ''); - return result; + return result; } export function deriveId(node) { - // Unfortunately, SplatNet doesn't return IDs for a lot of gear properties. - // Derive IDs from image URLs instead. + // Unfortunately, SplatNet doesn't return IDs for a lot of gear properties. + // Derive IDs from image URLs instead. - let path = normalizeSplatnetResourcePath(node.image.url); + let path = normalizeSplatnetResourcePath(node.image.url); - let hash = crypto.createHash('shake256', { outputLength: 8 }); - let id = hash.update(path).digest('hex'); + let hash = crypto.createHash('shake256', { outputLength: 8 }); + let id = hash.update(path).digest('hex'); - return { - '__splatoon3ink_id': id, - ...node, - }; + return { + '__splatoon3ink_id': id, + ...node, + }; } export function getFestId(id) { - return Buffer.from(id, 'base64').toString().match(/^Fest-[A-Z]+:(.+)$/)?.[1] ?? id; + return Buffer.from(id, 'base64').toString().match(/^Fest-[A-Z]+:(.+)$/)?.[1] ?? id; } export function getFestTeamId(id) { - return Buffer.from(id, 'base64').toString().match(/^FestTeam-[A-Z]+:((.+):(.+))$/)?.[1] ?? id; + return Buffer.from(id, 'base64').toString().match(/^FestTeam-[A-Z]+:((.+):(.+))$/)?.[1] ?? id; } export function getXRankSeasonId(id) { - let parts = Buffer.from(id, 'base64').toString().match(/^XRankingSeason-([A-Z]+):(.+)$/i); + let parts = Buffer.from(id, 'base64').toString().match(/^XRankingSeason-([A-Z]+):(.+)$/i); - return parts - ? `${parts[1]}-${parts[2]}` - : id; + return parts + ? `${parts[1]}-${parts[2]}` + : id; } diff --git a/app/data/DataArchiver.mjs b/app/data/DataArchiver.mjs index 25fd727..57f0f36 100644 --- a/app/data/DataArchiver.mjs +++ b/app/data/DataArchiver.mjs @@ -50,7 +50,7 @@ export default class DataArchiver credentials: { accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, - } + }, }); } diff --git a/app/screenshots/ScreenshotHelper.mjs b/app/screenshots/ScreenshotHelper.mjs index 025f7ae..733833a 100644 --- a/app/screenshots/ScreenshotHelper.mjs +++ b/app/screenshots/ScreenshotHelper.mjs @@ -84,7 +84,7 @@ export default class ScreenshotHelper } await this.#page.goto(url, { - waitUntil: 'networkidle0', // Wait until the network is idle + waitUntil: 'networkidle0', // Wait until the network is idle }); // Wait an additional 1000ms diff --git a/app/social/StatusGeneratorManager.mjs b/app/social/StatusGeneratorManager.mjs index 13a6427..f536798 100644 --- a/app/social/StatusGeneratorManager.mjs +++ b/app/social/StatusGeneratorManager.mjs @@ -39,28 +39,28 @@ export default class StatusGeneratorManager async #generateAndSend(generator, force) { let clientsToPost = []; - for (let client of this.clients) { - if (force || await generator.shouldPost(client)) { - clientsToPost.push(client); - } + for (let client of this.clients) { + if (force || await generator.shouldPost(client)) { + clientsToPost.push(client); } + } - if (clientsToPost.length === 0) { - this.console(generator).info('No status to post, skipping'); + if (clientsToPost.length === 0) { + this.console(generator).info('No status to post, skipping'); - return; - } - - let status = await generator.getStatus(this.screenshotHelper); - - for (let client of clientsToPost) { - this.console(generator, client).info('Posting...'); - try { - await client.send(status, generator); - await generator.updatelastPostCache(client); - } catch (e) { - this.console(generator, client).error(`Error posting: ${e}`); - } + return; + } + + let status = await generator.getStatus(this.screenshotHelper); + + for (let client of clientsToPost) { + this.console(generator, client).info('Posting...'); + try { + await client.send(status, generator); + await generator.updatelastPostCache(client); + } catch (e) { + this.console(generator, client).error(`Error posting: ${e}`); } + } } } diff --git a/app/social/clients/BlueskyClient.mjs b/app/social/clients/BlueskyClient.mjs index e63b474..ae953db 100644 --- a/app/social/clients/BlueskyClient.mjs +++ b/app/social/clients/BlueskyClient.mjs @@ -29,7 +29,7 @@ export default class BlueskyClient extends Client this.#loggedIn = true; } -} + } async send(status, generator) { await this.login(); diff --git a/app/social/generators/ChallengeStatus.mjs b/app/social/generators/ChallengeStatus.mjs index f6f34ee..f046056 100644 --- a/app/social/generators/ChallengeStatus.mjs +++ b/app/social/generators/ChallengeStatus.mjs @@ -28,7 +28,7 @@ export default class ChallengeStatus extends StatusGenerator return [ `A challenge event is now open! ${schedule.settings.leagueMatchEvent.name} โ€“ ${schedule.settings.leagueMatchEvent.desc}`, '', - `Play ${schedule.settings.vsRule.name} on ${schedule.settings.vsStages[0].name} and ${schedule.settings.vsStages[1].name}! #splatoon3` + `Play ${schedule.settings.vsRule.name} on ${schedule.settings.vsStages[0].name} and ${schedule.settings.vsStages[1].name}! #splatoon3`, ].join('\n'); } diff --git a/app/social/generators/EggstraWorkStatus.mjs b/app/social/generators/EggstraWorkStatus.mjs index f149637..86862be 100644 --- a/app/social/generators/EggstraWorkStatus.mjs +++ b/app/social/generators/EggstraWorkStatus.mjs @@ -40,7 +40,7 @@ export default class EggstraWorkStatus extends StatusGenerator async _getMedia(screenshotHelper) { let media = new Media; media.file = await screenshotHelper.capture('salmonrun', { - params: {eggstra: "true"} + params: {eggstra: "true"}, }); return media; diff --git a/app/social/generators/SalmonRunUpcomingStatus.mjs b/app/social/generators/SalmonRunUpcomingStatus.mjs index 1038ced..4158ef3 100644 --- a/app/social/generators/SalmonRunUpcomingStatus.mjs +++ b/app/social/generators/SalmonRunUpcomingStatus.mjs @@ -15,7 +15,7 @@ export default class SalmonRunUpcomingStatus extends StatusGenerator return useSalmonRunSchedulesStore().upcomingSchedules.find( s => s.isBigRun || s.isMystery - || s.isGrizzcoMystery + || s.isGrizzcoMystery, ); } diff --git a/app/splatnet/SplatNet3Client.mjs b/app/splatnet/SplatNet3Client.mjs index ce6df94..36d2b4a 100644 --- a/app/splatnet/SplatNet3Client.mjs +++ b/app/splatnet/SplatNet3Client.mjs @@ -64,7 +64,7 @@ export default class SplatNet3Client 'X-NACOUNTRY': 'US', // TODO 'X-GameWebToken': webServiceToken, 'Accept-Language': this.acceptLanguage, - } + }, }); if (!response.ok) { diff --git a/src/components/RuleIcon.vue b/src/components/RuleIcon.vue index 12f76bf..4f391ee 100644 --- a/src/components/RuleIcon.vue +++ b/src/components/RuleIcon.vue @@ -14,7 +14,7 @@ import ruleYaguraSvg from '@/assets/img/rules/yagura.svg'; const props = defineProps({ rule: { required: true, - } + }, }); const img = computed(() => { diff --git a/src/components/challenge/ChallengeScheduleBox.vue b/src/components/challenge/ChallengeScheduleBox.vue index c53eb71..63c2233 100644 --- a/src/components/challenge/ChallengeScheduleBox.vue +++ b/src/components/challenge/ChallengeScheduleBox.vue @@ -98,8 +98,8 @@ const props = defineProps({ required: true, }, event: { - required: true - } + required: true, + }, }); const { types } = useScheduleTypes(); diff --git a/src/components/splats/Splat1.vue b/src/components/splats/Splat1.vue index 7fd57e9..f2ded20 100644 --- a/src/components/splats/Splat1.vue +++ b/src/components/splats/Splat1.vue @@ -2,8 +2,8 @@ const props = defineProps({ fill: { type: String, - default: 'fill-splatoon-yellow' - } + default: 'fill-splatoon-yellow', + }, }); diff --git a/src/components/splats/Splat2.vue b/src/components/splats/Splat2.vue index 5a6ae8d..d9b1029 100644 --- a/src/components/splats/Splat2.vue +++ b/src/components/splats/Splat2.vue @@ -2,8 +2,8 @@ const props = defineProps({ fill: { type: String, - default: 'fill-splatoon-yellow' - } + default: 'fill-splatoon-yellow', + }, }); diff --git a/src/components/splats/Splat3.vue b/src/components/splats/Splat3.vue index 6f7082c..e23a50b 100644 --- a/src/components/splats/Splat3.vue +++ b/src/components/splats/Splat3.vue @@ -2,8 +2,8 @@ const props = defineProps({ fill: { type: String, - default: 'fill-splatoon-yellow' - } + default: 'fill-splatoon-yellow', + }, }); diff --git a/src/components/splats/Splat4.vue b/src/components/splats/Splat4.vue index ed72703..5a89ebd 100644 --- a/src/components/splats/Splat4.vue +++ b/src/components/splats/Splat4.vue @@ -2,8 +2,8 @@ const props = defineProps({ fill: { type: String, - default: 'fill-splatoon-yellow' - } + default: 'fill-splatoon-yellow', + }, }); diff --git a/src/components/splats/Splat5.vue b/src/components/splats/Splat5.vue index da69f81..e6833df 100644 --- a/src/components/splats/Splat5.vue +++ b/src/components/splats/Splat5.vue @@ -2,8 +2,8 @@ const props = defineProps({ fill: { type: String, - default: 'fill-splatoon-yellow' - } + default: 'fill-splatoon-yellow', + }, }); diff --git a/src/components/splats/Splat6.vue b/src/components/splats/Splat6.vue index fa4dd13..77a4763 100644 --- a/src/components/splats/Splat6.vue +++ b/src/components/splats/Splat6.vue @@ -2,8 +2,8 @@ const props = defineProps({ fill: { type: String, - default: 'fill-splatoon-yellow' - } + default: 'fill-splatoon-yellow', + }, }); diff --git a/src/router/index.js b/src/router/index.js index ee7a222..83fcc1b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -12,12 +12,12 @@ const router = createRouter({ { path: '/', name: 'home', - component: HomeView + component: HomeView, }, { path: '/salmonrun', name: 'salmonrun', - component: SalmonRunView + component: SalmonRunView, }, { path: '/gear', @@ -37,13 +37,13 @@ const router = createRouter({ { path: '/about', name: 'about', - component: AboutView + component: AboutView, }, { path: '/faq', redirect: { name: 'about' }, }, - ] + ], }) export default router diff --git a/src/router/screenshots.js b/src/router/screenshots.js index 7629ea2..3e174b2 100644 --- a/src/router/screenshots.js +++ b/src/router/screenshots.js @@ -48,7 +48,7 @@ const router = createRouter({ path: '/splatfest', component: SplatfestView, }, - ] + ], }) export default router diff --git a/src/stores/data.mjs b/src/stores/data.mjs index 98032aa..087e254 100644 --- a/src/stores/data.mjs +++ b/src/stores/data.mjs @@ -71,7 +71,7 @@ export const useDataStore = defineStore('data', () => { // If we're more than 20 seconds past the current hour, schedule the update for the next hour if (date.getMinutes() !== 0 || date.getSeconds() >= 20) - date.setHours(date.getHours() + 1); + date.setHours(date.getHours() + 1); date.setMinutes(0); // Random number of seconds past the hour (so all open browsers don't hit the server at the same time) diff --git a/src/stores/splatfests.mjs b/src/stores/splatfests.mjs index dd3ef2d..77f2586 100644 --- a/src/stores/splatfests.mjs +++ b/src/stores/splatfests.mjs @@ -38,7 +38,7 @@ function defineSplatfestRegionStore(region) { // A "recent festival" is one that ended within the past 3 days const recentFestival = computed(() => festivals.value?.find(f => f.status === STATUS_PAST && - time.now - Date.parse(f.endTime) < 3 * 24 * 60 * 60 * 1000 + time.now - Date.parse(f.endTime) < 3 * 24 * 60 * 60 * 1000, )); // TODO: Eventually this needs to be handled on a per-region basis. diff --git a/src/views/screenshots/SplatfestView.vue b/src/views/screenshots/SplatfestView.vue index 9dbaecd..1bbcfd0 100644 --- a/src/views/screenshots/SplatfestView.vue +++ b/src/views/screenshots/SplatfestView.vue @@ -26,6 +26,6 @@ const usSplatfests = useUSSplatfestsStore(); const festival = computed(() => usSplatfests.upcomingFestival ?? usSplatfests.activeFestival - ?? usSplatfests.recentFestival + ?? usSplatfests.recentFestival, ); diff --git a/tailwind.config.js b/tailwind.config.js index e69e559..da365d1 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -26,7 +26,7 @@ module.exports = { salmonRun: '#ff5600', bigRun: '#b322ff', - eggstraWork: '#be8800' + eggstraWork: '#be8800', }, }, fontFamily: { @@ -42,6 +42,6 @@ module.exports = { plugin(function({ addVariant }) { addVariant('mobile', 'body.is-mobile &'); addVariant('ss', 'body.for-screenshots &'); - }) - ] + }), + ], } diff --git a/vite.config.js b/vite.config.js index 77206e6..73db7c5 100644 --- a/vite.config.js +++ b/vite.config.js @@ -15,7 +15,7 @@ export default defineConfig({ plugins: [ vue(), vueI18n({ - include: resolve(__dirname, './src/assets/i18n/**') + include: resolve(__dirname, './src/assets/i18n/**'), }), { // Quick hack to redirect dynamic assets to the /dist/ directory @@ -32,16 +32,16 @@ export default defineConfig({ ], resolve: { alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)) - } + '@': fileURLToPath(new URL('./src', import.meta.url)), + }, }, build: { emptyOutDir: false, rollupOptions: { input: { main: resolve(__dirname, 'index.html'), - screenshots: resolve(__dirname, 'screenshots/index.html') - } - } - } + screenshots: resolve(__dirname, 'screenshots/index.html'), + }, + }, + }, })