Run linter

This commit is contained in:
Matt Isenhower
2023-06-25 20:59:43 -07:00
parent ea1e622206
commit e4e6051999
24 changed files with 104 additions and 104 deletions

View File

@@ -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;
}

View File

@@ -50,7 +50,7 @@ export default class DataArchiver
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
}
},
});
}

View File

@@ -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

View File

@@ -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}`);
}
}
}
}

View File

@@ -29,7 +29,7 @@ export default class BlueskyClient extends Client
this.#loggedIn = true;
}
}
}
async send(status, generator) {
await this.login();

View File

@@ -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');
}

View File

@@ -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;

View File

@@ -15,7 +15,7 @@ export default class SalmonRunUpcomingStatus extends StatusGenerator
return useSalmonRunSchedulesStore().upcomingSchedules.find(
s => s.isBigRun
|| s.isMystery
|| s.isGrizzcoMystery
|| s.isGrizzcoMystery,
);
}

View File

@@ -64,7 +64,7 @@ export default class SplatNet3Client
'X-NACOUNTRY': 'US', // TODO
'X-GameWebToken': webServiceToken,
'Accept-Language': this.acceptLanguage,
}
},
});
if (!response.ok) {

View File

@@ -14,7 +14,7 @@ import ruleYaguraSvg from '@/assets/img/rules/yagura.svg';
const props = defineProps({
rule: {
required: true,
}
},
});
const img = computed(() => {

View File

@@ -98,8 +98,8 @@ const props = defineProps({
required: true,
},
event: {
required: true
}
required: true,
},
});
const { types } = useScheduleTypes();

View File

@@ -2,8 +2,8 @@
const props = defineProps({
fill: {
type: String,
default: 'fill-splatoon-yellow'
}
default: 'fill-splatoon-yellow',
},
});
</script>

View File

@@ -2,8 +2,8 @@
const props = defineProps({
fill: {
type: String,
default: 'fill-splatoon-yellow'
}
default: 'fill-splatoon-yellow',
},
});
</script>

View File

@@ -2,8 +2,8 @@
const props = defineProps({
fill: {
type: String,
default: 'fill-splatoon-yellow'
}
default: 'fill-splatoon-yellow',
},
});
</script>

View File

@@ -2,8 +2,8 @@
const props = defineProps({
fill: {
type: String,
default: 'fill-splatoon-yellow'
}
default: 'fill-splatoon-yellow',
},
});
</script>

View File

@@ -2,8 +2,8 @@
const props = defineProps({
fill: {
type: String,
default: 'fill-splatoon-yellow'
}
default: 'fill-splatoon-yellow',
},
});
</script>

View File

@@ -2,8 +2,8 @@
const props = defineProps({
fill: {
type: String,
default: 'fill-splatoon-yellow'
}
default: 'fill-splatoon-yellow',
},
});
</script>

View File

@@ -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

View File

@@ -48,7 +48,7 @@ const router = createRouter({
path: '/splatfest',
component: SplatfestView,
},
]
],
})
export default router

View File

@@ -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)

View File

@@ -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.

View File

@@ -26,6 +26,6 @@ const usSplatfests = useUSSplatfestsStore();
const festival = computed(() =>
usSplatfests.upcomingFestival
?? usSplatfests.activeFestival
?? usSplatfests.recentFestival
?? usSplatfests.recentFestival,
);
</script>

View File

@@ -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 &');
})
]
}),
],
}

View File

@@ -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'),
},
},
},
})