chore(server): add switch case exhaustiveness lint (#29029)

This commit is contained in:
Mees Frensel
2026-06-17 12:04:41 +02:00
committed by GitHub
parent fbb0bc6e39
commit 430a2bbfd3
10 changed files with 44 additions and 15 deletions

View File

@@ -51,6 +51,7 @@ export default typescriptEslint.config([
'unicorn/no-array-sort': 'off',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/switch-exhaustiveness-check': ['error', { considerDefaultExhaustiveForUnions: true }],
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
curly: 2,

View File

@@ -28,9 +28,13 @@ export class SchemaCheck extends CommandRunner {
}
case 'missing': {
console.log(` - ${migration.name} exists, but has not been applied to the database`);
console.log(` - ${migration.name} exists on disk, but has not been applied to the database`);
break;
}
case 'applied': {
break; // happy path, do nothing
}
}
}
}

View File

@@ -9,6 +9,7 @@ import {
PersonPathType,
RawExtractedFormat,
StorageFolder,
UserPathType,
} from 'src/enum';
import { AssetRepository } from 'src/repositories/asset.repository';
import { ConfigRepository } from 'src/repositories/config.repository';
@@ -327,13 +328,19 @@ export class StorageCore {
case AssetFileType.EncodedVideo:
case AssetFileType.Thumbnail:
case AssetFileType.Preview:
case AssetFileType.Sidecar: {
case AssetFileType.Sidecar:
case AssetPathType.EncodedVideo: {
return this.assetRepository.upsertFile({ assetId: id, type: pathType as AssetFileType, path: newPath });
}
case PersonPathType.Face: {
return this.personRepository.update({ id, thumbnailPath: newPath });
}
case UserPathType.Profile: {
this.logger.warn('Unexpected path type:', pathType);
return;
}
}
}

View File

@@ -281,17 +281,20 @@ export class MaintenanceWorkerService {
async runAction(action: SetMaintenanceModeDto) {
switch (action.action) {
case MaintenanceAction.Start: {
case MaintenanceAction.Start:
case MaintenanceAction.SelectDatabaseRestore: {
return;
}
case MaintenanceAction.End: {
return this.endMaintenance();
}
case MaintenanceAction.SelectDatabaseRestore: {
return;
case MaintenanceAction.RestoreDatabase: {
return this.runRestoreDatabase(action);
}
}
}
async runRestoreDatabase(action: SetMaintenanceModeDto) {
const lock = await this.databaseRepository.tryLock(DatabaseLock.MaintenanceOperation);
if (!lock) {
return;

View File

@@ -243,14 +243,16 @@ const getEnv = (): EnvData => {
};
let vectorExtension: VectorExtension | undefined;
switch (dto.DB_VECTOR_EXTENSION) {
case 'pgvector': {
vectorExtension = DatabaseExtension.Vector;
break;
}
case 'vectorchord': {
vectorExtension = DatabaseExtension.VectorChord;
break;
if (dto.DB_VECTOR_EXTENSION) {
switch (dto.DB_VECTOR_EXTENSION) {
case 'pgvector': {
vectorExtension = DatabaseExtension.Vector;
break;
}
case 'vectorchord': {
vectorExtension = DatabaseExtension.VectorChord;
break;
}
}
}

View File

@@ -478,8 +478,10 @@ export class MediaRepository {
case 'av1': {
return this.parseEnum(Av1Profile, profile);
}
default: {
return null;
}
}
return null;
}
private compareStreams(a: FfprobeStream, b: FfprobeStream): number {

View File

@@ -163,6 +163,9 @@ export class DatabaseBackupService {
);
switch (bin) {
case 'pg_dump': {
break;
}
case 'pg_dumpall': {
args.push('--database');
break;

View File

@@ -257,6 +257,8 @@ export class JobService extends BaseService {
}
break;
}
// no default
}
}
}

View File

@@ -498,6 +498,9 @@ export class LibraryService extends BaseService {
const stat = stats[i];
const action = this.checkExistingAsset(asset, stat);
switch (action) {
case AssetSyncResult.DO_NOTHING: {
break;
}
case AssetSyncResult.OFFLINE: {
if (asset.status === AssetStatus.Trashed) {
trashedAssetIdsToOffline.push(asset.id);

View File

@@ -1138,7 +1138,9 @@ export class MetadataService extends BaseService {
case 3: {
return ExifOrientation.Rotate90CW;
}
default: {
return null;
}
}
return null;
}
}