Skip to content

Commit 7ac4944

Browse files
committed
npm up
1 parent d68d92b commit 7ac4944

33 files changed

+3018
-2474
lines changed

eslint.config.mjs

+95-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,105 @@
1-
import love from 'eslint-config-love'
1+
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
2+
import eslint from '@eslint/js'
3+
import tseslint from 'typescript-eslint'
24

35
export default [
4-
{
6+
...neostandard({
57
ignores: [
6-
'node_modules/',
7-
'dist/',
8-
'.vscode/',
9-
'src/generated/'
10-
]
8+
...resolveIgnoresFromGitignore(),
9+
],
10+
ts: true,
11+
}),
12+
eslint.configs.recommended,
13+
...tseslint.configs.strictTypeChecked,
14+
...tseslint.configs.stylisticTypeChecked,
15+
{
16+
languageOptions: {
17+
parserOptions: {
18+
projectService: {
19+
allowDefaultProject: ['*.mjs'],
20+
},
21+
tsconfigRootDir: process.cwd(),
22+
},
23+
},
1124
},
1225
{
13-
...love,
14-
files: ["**/*.js", "**/*.ts", "**/*.mjs"]
26+
name: 'migrate/eslint-config-standard-with-typescript',
27+
rules: {
28+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
29+
'@typescript-eslint/consistent-type-exports': [
30+
'error',
31+
{
32+
fixMixedExportsWithInlineTypeSpecifier: true,
33+
},
34+
],
35+
'@typescript-eslint/consistent-type-imports': 'error',
36+
'@stylistic/member-delimiter-style': [
37+
'error',
38+
{
39+
multiline: { delimiter: 'none' },
40+
singleline: { delimiter: 'comma', requireLast: false },
41+
},
42+
],
43+
'@typescript-eslint/method-signature-style': 'error',
44+
'@typescript-eslint/no-explicit-any': 'off',
45+
'@typescript-eslint/no-unnecessary-condition': 'off',
46+
'@typescript-eslint/no-unsafe-assignment': 'off',
47+
'@typescript-eslint/no-unsafe-call': 'off',
48+
'@typescript-eslint/no-unsafe-member-access': 'off',
49+
'@typescript-eslint/no-unsafe-return': 'off',
50+
'@typescript-eslint/promise-function-async': 'error',
51+
'@typescript-eslint/require-array-sort-compare': 'error',
52+
'@typescript-eslint/require-await': 'off',
53+
'@typescript-eslint/return-await': ['error', 'always'],
54+
'@typescript-eslint/triple-slash-reference': ['error', { lib: 'never', path: 'never', types: 'never' }],
55+
'@stylistic/type-annotation-spacing': 'error',
56+
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
57+
},
1558
},
1659
{
60+
name: 'RopeScore/custom',
1761
rules: {
18-
'@typescript-eslint/explicit-function-return-type': 'off',
19-
'@typescript-eslint/strict-boolean-expressions': 'off',
20-
'@typescript-eslint/restrict-template-expressions': 'off',
21-
'@typescript-eslint/return-await': 'off',
22-
'@typescript-eslint/no-floating-promises': 'off',
62+
'@typescript-eslint/restrict-template-expressions': ['warn', {
63+
allowNumber: true,
64+
allowBoolean: true,
65+
allowRegExp: true,
66+
allowAny: true,
67+
}],
68+
'@typescript-eslint/no-this-alias': 'off',
69+
'@typescript-eslint/only-throw-error': ['error', {
70+
allowThrowingUnknown: true,
71+
}],
72+
'@stylistic/comma-dangle': ['warn', {
73+
arrays: 'always-multiline',
74+
objects: 'always-multiline',
75+
imports: 'always-multiline',
76+
exports: 'always-multiline',
77+
enums: 'always-multiline',
78+
functions: 'never',
79+
}],
2380
'@typescript-eslint/no-non-null-assertion': 'off',
24-
'@typescript-eslint/promise-function-async': 'off',
25-
'@typescript-eslint/only-throw-error': 'off',
26-
'@typescript-eslint/non-nullable-type-assertion-style': 'off'
27-
}
28-
}
81+
'no-void': 'off',
82+
'no-console': 'warn',
83+
},
84+
},
85+
{
86+
name: 'RopeScore/tests',
87+
files: ['**/*.test.ts', '**/*.test.js'],
88+
rules: {
89+
'@typescript-eslint/ban-ts-comment': ['error', {
90+
'ts-expect-error': false,
91+
'ts-ignore': true,
92+
'ts-nocheck': true,
93+
'ts-check': false,
94+
minimumDescriptionLength: 3,
95+
}],
96+
},
97+
},
98+
{
99+
name: 'RopeScore/allow-console',
100+
files: ['migrations/*.ts', 'migrations/*.js'],
101+
rules: {
102+
'no-console': 'off',
103+
},
104+
},
29105
]

migrations/202309031700-update-competition-events.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ const newCevtMap: Record<string, undefined | Record<string, undefined | string>>
99
'e.ijru.fs.sr.srpf.2.75': 'e.svgf.fs.sr.srpf-rh.2.75@2020',
1010
'e.ijru.fs.sr.srtf.4.75': 'e.svgf.fs.sr.srtf-rh.4.75@2020',
1111
'e.ijru.fs.dd.ddsf.3.75': 'e.svgf.fs.dd.ddsf-rh.3.75@2020',
12-
'e.ijru.fs.dd.ddpf.4.75': 'e.svgf.fs.dd.ddpf-rh.4.75@2020'
12+
'e.ijru.fs.dd.ddpf.4.75': 'e.svgf.fs.dd.ddpf-rh.4.75@2020',
1313
},
1414
'svgf-vh@2023': {
1515
'e.ijru.sp.sr.srss.1.30': 'e.svgf.sp.sr.srss.1.30@2023',
1616
'e.ijru.sp.sr.srsr.4.4x30': 'e.svgf.sp.sr.srsr.4.4x30@2023',
1717
'e.ijru.fs.sr.srif.1.75': 'e.svgf.fs.sr.srif-vh.1.75@2023',
1818
'e.ijru.fs.sr.srtf.4.75': 'e.svgf.fs.sr.srtf-vh.4.75@2023',
19-
'e.svgf.fs.dd.ddpf.4.120': 'e.svgf.fs.dd.ddpf-vh.4.120@2023'
20-
}
19+
'e.svgf.fs.dd.ddpf.4.120': 'e.svgf.fs.dd.ddpf-vh.4.120@2023',
20+
},
2121
}
2222

2323
function getNewCEvt (rulesId: string, cEvt: string) {
@@ -47,31 +47,31 @@ async function run () {
4747

4848
const entryLimit = pLimit(100)
4949
const entries = await firestore.collection('entries').where('categoryId', '==', category.id).get()
50-
await Promise.all(entries.docs.map(async dSnap => entryLimit(async () => {
50+
await Promise.all(entries.docs.map(async dSnap => await entryLimit(async () => {
5151
const oldId = dSnap.get('competitionEventId') as string
5252
if (typeof oldId === 'string' && oldId.includes('@')) return
53-
return firestore.collection('entries').doc(dSnap.id).update({
54-
competitionEventId: getNewCEvt(rulesId, oldId)
53+
return await firestore.collection('entries').doc(dSnap.id).update({
54+
competitionEventId: getNewCEvt(rulesId, oldId),
5555
})
5656
})))
5757

5858
const scshLimit = pLimit(100)
5959
const scoresheets = await getScoresheetsByEntryIds(entries.docs.map(dSnap => dSnap.id))
60-
await Promise.all(scoresheets.map(async dSnap => scshLimit(async () => {
60+
await Promise.all(scoresheets.map(async dSnap => await scshLimit(async () => {
6161
const oldId = dSnap.get('competitionEventId') as string
6262
if (typeof oldId === 'string' && oldId.includes('@')) return
63-
return firestore.collection('scoresheets').doc(dSnap.id).update({
64-
competitionEventId: getNewCEvt(rulesId, oldId)
63+
return await firestore.collection('scoresheets').doc(dSnap.id).update({
64+
competitionEventId: getNewCEvt(rulesId, oldId),
6565
})
6666
})))
6767

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

@@ -80,9 +80,9 @@ async function run () {
8080
competitionEventIds: (category.get('competitionEventIds') as string[]).map(cEvt => getNewCEvt(rulesId, cEvt)),
8181
...(category.get('pagePrintConfig') != null
8282
? {
83-
pagePrintConfig: Object.fromEntries(Object.entries(category.get('pagePrintConfig') as Record<string, unknown>).map(([cEvt, v]) => [getNewCEvt(rulesId, cEvt), v]))
83+
pagePrintConfig: Object.fromEntries(Object.entries(category.get('pagePrintConfig') as Record<string, unknown>).map(([cEvt, v]) => [getNewCEvt(rulesId, cEvt), v])),
8484
}
85-
: {})
85+
: {}),
8686
})
8787
}
8888
}

migrations/202309031701-fix-some-competition-events.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ async function run () {
1111
await Promise.all(categories.docs.map(async dSnap => {
1212
const competitionEventIds = dSnap.get('competitionEventIds') as string[]
1313
competitionEventIds.splice(competitionEventIds.indexOf(oldCEvt), 1, newCEvt)
14-
return firestore.collection('categories').doc(dSnap.id).set({
14+
return await firestore.collection('categories').doc(dSnap.id).set({
1515
...dSnap.data(),
16-
competitionEventIds
16+
competitionEventIds,
1717
})
1818
}))
1919

2020
const entries = await firestore.collection('entries').where('competitionEventId', '==', oldCEvt).get()
2121
await Promise.all(entries.docs.map(async dSnap => {
22-
return firestore.collection('entries').doc(dSnap.id).update({
23-
competitionEventId: newCEvt
22+
return await firestore.collection('entries').doc(dSnap.id).update({
23+
competitionEventId: newCEvt,
2424
})
2525
}))
2626

2727
const scoresheets = await firestore.collection('scoresheets').where('competitionEventId', '==', oldCEvt).get()
2828
await Promise.all(scoresheets.docs.map(async dSnap => {
29-
return firestore.collection('scoresheets').doc(dSnap.id).update({
30-
competitionEventId: newCEvt
29+
return await firestore.collection('scoresheets').doc(dSnap.id).update({
30+
competitionEventId: newCEvt,
3131
})
3232
}))
3333

3434
const judgeAssignments = await firestore.collection('judge-assignments').where('competitionEventId', '==', oldCEvt).get()
3535
await Promise.all(judgeAssignments.docs.map(async dSnap => {
36-
return firestore.collection('judge-assignments').doc(dSnap.id).update({
37-
competitionEventId: newCEvt
36+
return await firestore.collection('judge-assignments').doc(dSnap.id).update({
37+
competitionEventId: newCEvt,
3838
})
3939
}))
4040
}

migrations/202309131814-add-locked-action-at.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const firestore = new Firestore()
55
async function run () {
66
const entries = await firestore.collection('entries').where('lockedAt', '!=', null).get()
77
await Promise.all(entries.docs.map(async dSnap => {
8-
return firestore.collection('entries').doc(dSnap.id).update({
9-
lockActionAt: dSnap.get('lockedAt')
8+
return await firestore.collection('entries').doc(dSnap.id).update({
9+
lockActionAt: dSnap.get('lockedAt'),
1010
})
1111
}))
1212
}

0 commit comments

Comments
 (0)