Skip to content

Commit

Permalink
npm up
Browse files Browse the repository at this point in the history
  • Loading branch information
swantzter committed Oct 30, 2024
1 parent d68d92b commit 7ac4944
Show file tree
Hide file tree
Showing 33 changed files with 3,018 additions and 2,474 deletions.
114 changes: 95 additions & 19 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,105 @@
import love from 'eslint-config-love'
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'

export default [
{
...neostandard({
ignores: [
'node_modules/',
'dist/',
'.vscode/',
'src/generated/'
]
...resolveIgnoresFromGitignore(),
],
ts: true,
}),
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['*.mjs'],
},
tsconfigRootDir: process.cwd(),
},
},
},
{
...love,
files: ["**/*.js", "**/*.ts", "**/*.mjs"]
name: 'migrate/eslint-config-standard-with-typescript',
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/consistent-type-exports': [
'error',
{
fixMixedExportsWithInlineTypeSpecifier: true,
},
],
'@typescript-eslint/consistent-type-imports': 'error',
'@stylistic/member-delimiter-style': [
'error',
{
multiline: { delimiter: 'none' },
singleline: { delimiter: 'comma', requireLast: false },
},
],
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/triple-slash-reference': ['error', { lib: 'never', path: 'never', types: 'never' }],
'@stylistic/type-annotation-spacing': 'error',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
},
},
{
name: 'RopeScore/custom',
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/restrict-template-expressions': ['warn', {
allowNumber: true,
allowBoolean: true,
allowRegExp: true,
allowAny: true,
}],
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/only-throw-error': ['error', {
allowThrowingUnknown: true,
}],
'@stylistic/comma-dangle': ['warn', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
enums: 'always-multiline',
functions: 'never',
}],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off'
}
}
'no-void': 'off',
'no-console': 'warn',
},
},
{
name: 'RopeScore/tests',
files: ['**/*.test.ts', '**/*.test.js'],
rules: {
'@typescript-eslint/ban-ts-comment': ['error', {
'ts-expect-error': false,
'ts-ignore': true,
'ts-nocheck': true,
'ts-check': false,
minimumDescriptionLength: 3,
}],
},
},
{
name: 'RopeScore/allow-console',
files: ['migrations/*.ts', 'migrations/*.js'],
rules: {
'no-console': 'off',
},
},
]
28 changes: 14 additions & 14 deletions migrations/202309031700-update-competition-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const newCevtMap: Record<string, undefined | Record<string, undefined | string>>
'e.ijru.fs.sr.srpf.2.75': 'e.svgf.fs.sr.srpf-rh.2.75@2020',
'e.ijru.fs.sr.srtf.4.75': 'e.svgf.fs.sr.srtf-rh.4.75@2020',
'e.ijru.fs.dd.ddsf.3.75': 'e.svgf.fs.dd.ddsf-rh.3.75@2020',
'e.ijru.fs.dd.ddpf.4.75': 'e.svgf.fs.dd.ddpf-rh.4.75@2020'
'e.ijru.fs.dd.ddpf.4.75': 'e.svgf.fs.dd.ddpf-rh.4.75@2020',
},
'svgf-vh@2023': {
'e.ijru.sp.sr.srss.1.30': 'e.svgf.sp.sr.srss.1.30@2023',
'e.ijru.sp.sr.srsr.4.4x30': 'e.svgf.sp.sr.srsr.4.4x30@2023',
'e.ijru.fs.sr.srif.1.75': 'e.svgf.fs.sr.srif-vh.1.75@2023',
'e.ijru.fs.sr.srtf.4.75': 'e.svgf.fs.sr.srtf-vh.4.75@2023',
'e.svgf.fs.dd.ddpf.4.120': 'e.svgf.fs.dd.ddpf-vh.4.120@2023'
}
'e.svgf.fs.dd.ddpf.4.120': 'e.svgf.fs.dd.ddpf-vh.4.120@2023',
},
}

function getNewCEvt (rulesId: string, cEvt: string) {
Expand Down Expand Up @@ -47,31 +47,31 @@ async function run () {

const entryLimit = pLimit(100)
const entries = await firestore.collection('entries').where('categoryId', '==', category.id).get()
await Promise.all(entries.docs.map(async dSnap => entryLimit(async () => {
await Promise.all(entries.docs.map(async dSnap => await entryLimit(async () => {
const oldId = dSnap.get('competitionEventId') as string
if (typeof oldId === 'string' && oldId.includes('@')) return
return firestore.collection('entries').doc(dSnap.id).update({
competitionEventId: getNewCEvt(rulesId, oldId)
return await firestore.collection('entries').doc(dSnap.id).update({
competitionEventId: getNewCEvt(rulesId, oldId),
})
})))

const scshLimit = pLimit(100)
const scoresheets = await getScoresheetsByEntryIds(entries.docs.map(dSnap => dSnap.id))
await Promise.all(scoresheets.map(async dSnap => scshLimit(async () => {
await Promise.all(scoresheets.map(async dSnap => await scshLimit(async () => {
const oldId = dSnap.get('competitionEventId') as string
if (typeof oldId === 'string' && oldId.includes('@')) return
return firestore.collection('scoresheets').doc(dSnap.id).update({
competitionEventId: getNewCEvt(rulesId, oldId)
return await firestore.collection('scoresheets').doc(dSnap.id).update({
competitionEventId: getNewCEvt(rulesId, oldId),
})
})))

const jALimit = pLimit(100)
const judgeAssignments = await firestore.collection('judge-assignments').where('categoryId', '==', category.id).get()
await Promise.all(judgeAssignments.docs.map(async dSnap => jALimit(async () => {
await Promise.all(judgeAssignments.docs.map(async dSnap => await jALimit(async () => {
const oldId = dSnap.get('competitionEventId') as string
if (typeof oldId === 'string' && oldId.includes('@')) return
return firestore.collection('judge-assignments').doc(dSnap.id).update({
competitionEventId: getNewCEvt(rulesId, oldId)
return await firestore.collection('judge-assignments').doc(dSnap.id).update({
competitionEventId: getNewCEvt(rulesId, oldId),
})
})))

Expand All @@ -80,9 +80,9 @@ async function run () {
competitionEventIds: (category.get('competitionEventIds') as string[]).map(cEvt => getNewCEvt(rulesId, cEvt)),
...(category.get('pagePrintConfig') != null
? {
pagePrintConfig: Object.fromEntries(Object.entries(category.get('pagePrintConfig') as Record<string, unknown>).map(([cEvt, v]) => [getNewCEvt(rulesId, cEvt), v]))
pagePrintConfig: Object.fromEntries(Object.entries(category.get('pagePrintConfig') as Record<string, unknown>).map(([cEvt, v]) => [getNewCEvt(rulesId, cEvt), v])),
}
: {})
: {}),
})
}
}
Expand Down
16 changes: 8 additions & 8 deletions migrations/202309031701-fix-some-competition-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ async function run () {
await Promise.all(categories.docs.map(async dSnap => {
const competitionEventIds = dSnap.get('competitionEventIds') as string[]
competitionEventIds.splice(competitionEventIds.indexOf(oldCEvt), 1, newCEvt)
return firestore.collection('categories').doc(dSnap.id).set({
return await firestore.collection('categories').doc(dSnap.id).set({
...dSnap.data(),
competitionEventIds
competitionEventIds,
})
}))

const entries = await firestore.collection('entries').where('competitionEventId', '==', oldCEvt).get()
await Promise.all(entries.docs.map(async dSnap => {
return firestore.collection('entries').doc(dSnap.id).update({
competitionEventId: newCEvt
return await firestore.collection('entries').doc(dSnap.id).update({
competitionEventId: newCEvt,
})
}))

const scoresheets = await firestore.collection('scoresheets').where('competitionEventId', '==', oldCEvt).get()
await Promise.all(scoresheets.docs.map(async dSnap => {
return firestore.collection('scoresheets').doc(dSnap.id).update({
competitionEventId: newCEvt
return await firestore.collection('scoresheets').doc(dSnap.id).update({
competitionEventId: newCEvt,
})
}))

const judgeAssignments = await firestore.collection('judge-assignments').where('competitionEventId', '==', oldCEvt).get()
await Promise.all(judgeAssignments.docs.map(async dSnap => {
return firestore.collection('judge-assignments').doc(dSnap.id).update({
competitionEventId: newCEvt
return await firestore.collection('judge-assignments').doc(dSnap.id).update({
competitionEventId: newCEvt,
})
}))
}
Expand Down
4 changes: 2 additions & 2 deletions migrations/202309131814-add-locked-action-at.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const firestore = new Firestore()
async function run () {
const entries = await firestore.collection('entries').where('lockedAt', '!=', null).get()
await Promise.all(entries.docs.map(async dSnap => {
return firestore.collection('entries').doc(dSnap.id).update({
lockActionAt: dSnap.get('lockedAt')
return await firestore.collection('entries').doc(dSnap.id).update({
lockActionAt: dSnap.get('lockedAt'),
})
}))
}
Expand Down
Loading

0 comments on commit 7ac4944

Please sign in to comment.