Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowadays authored and benscobie committed Nov 9, 2024
1 parent 575a6c5 commit 149dc78
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 101 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"start:ui": "cd ui && next start -p 80",
"start:server": "cd server && node dist/main",
"lint:ui": "cd ui && next lint",
"lint:server": "cd server && eslint \"**/*.ts\" --fix",
"lint:server": "cd server && eslint \"{src,test}/**/*.ts\" --fix",
"test": "jest",
"test:clear": "jest --clearCache",
"test:watch": "jest --watch",
Expand Down
7 changes: 6 additions & 1 deletion server/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export default [{
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",

"@typescript-eslint/no-unused-vars": [
"error",
{
caughtErrors: "none"
}
],
"prettier/prettier": ["error", {
endOfLine: "auto",
}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export class UpdateTautulliURL1728503476668 implements MigrationInterface {
);
}

public async down(queryRunner: QueryRunner): Promise<void> {}
public async down(): Promise<void> {}
}
2 changes: 1 addition & 1 deletion server/src/modules/api/lib/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CacheManager {
}

public flushAll(): void {
for (const [key, value] of Object.entries(this.getAllCaches())) {
for (const [, value] of Object.entries(this.getAllCaches())) {
value.flush();
}
}
Expand Down
6 changes: 3 additions & 3 deletions server/src/modules/api/lib/plexApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ class PlexApi extends NodePlexAPI {
}
}

deleteQuery<T>(arg) {
deleteQuery(arg) {
return super.deleteQuery(arg);
}
postQuery<T>(arg) {
postQuery(arg) {
return super.postQuery(arg);
}
putQuery<T>(arg) {
putQuery(arg) {
return super.putQuery(arg);
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/modules/api/overseerr-api/overseerr-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ export class OverseerrApiService {
let hasNext = true;
let skip = 0;

let users: OverseerrUserResponseResult[] = [];
const users: OverseerrUserResponseResult[] = [];

while (hasNext) {
let resp: OverseerrUserResponse = await this.api.get(
const resp: OverseerrUserResponse = await this.api.get(
`/user?take=${size}&skip=${skip}`,
);

Expand Down
67 changes: 35 additions & 32 deletions server/src/modules/api/plex-api/plex-api.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common';
import { PlexSettings } from '../../../modules/settings/interfaces/plex-settings.interface';
import { SettingsService } from '../../..//modules/settings/settings.service';
import { PlexSettings } from '../../settings/interfaces/plex-settings.interface';
import { SettingsService } from '../../settings/settings.service';
import { BasicResponseDto } from './dto/basic-response.dto';
import { CollectionHubSettingsDto } from './dto/collection-hub-settings.dto';
import {
Expand Down Expand Up @@ -35,7 +35,6 @@ import PlexTvApi, { PlexUser } from '../lib/plextvApi';
import cacheManager from '../../api/lib/cache';
import { Settings } from '../../settings/entities/settings.entities';
import PlexCommunityApi, {
GraphQLQuery,
PlexCommunityWatchHistory,
PlexCommunityWatchList,
} from '../../api/lib/plexCommunityApi';
Expand All @@ -47,6 +46,7 @@ export class PlexApiService {
private plexCommunityClient: PlexCommunityApi;
private machineId: string;
private readonly logger = new Logger(PlexApiService.name);

constructor(
@Inject(forwardRef(() => SettingsService))
private readonly settings: SettingsService,
Expand All @@ -73,6 +73,7 @@ export class PlexApiService {
webAppUrl: this.settings.plex_hostname,
};
}

public async initialize({
plexToken,
timeout,
Expand Down Expand Up @@ -153,15 +154,17 @@ export class PlexApiService {
}),
)
: [];
const fileteredResults: PlexMetadata[] = [];
const filteredResults: PlexMetadata[] = [];
(await results).forEach((el: PlexMetadata) => {
fileteredResults.find(
(e: PlexMetadata) => e.ratingKey === el.ratingKey,
) === undefined
? fileteredResults.push(el)
: undefined;
if (
filteredResults.find(
(e: PlexMetadata) => e.ratingKey === el.ratingKey,
) === undefined
) {
filteredResults.push(el);
}
});
return fileteredResults;
return filteredResults;
} catch (err) {
this.logger.warn(
'Plex api communication failure.. Is the application running?',
Expand Down Expand Up @@ -444,7 +447,7 @@ export class PlexApiService {
`[Plex] Removed media with ID ${plexId} from Plex library.`,
);
try {
await this.plexClient.deleteQuery<void>({
await this.plexClient.deleteQuery({
uri: `/library/metadata/${plexId}`,
});
} catch (e) {
Expand Down Expand Up @@ -480,7 +483,7 @@ export class PlexApiService {

public async createCollection(params: CreateUpdateCollection) {
try {
const response = await this.plexClient.postQuery<PlexLibraryResponse>({
const response = await this.plexClient.postQuery({
uri: `/library/collections?type=${
params.type
}&title=${encodeURIComponent(params.title)}&sectionId=${
Expand All @@ -505,7 +508,7 @@ export class PlexApiService {

public async updateCollection(body: CreateUpdateCollection) {
try {
await this.plexClient.putQuery<PlexLibraryResponse>({
await this.plexClient.putQuery({
uri: `/library/sections/${body.libraryId}/all?type=18&id=${
body.collectionId
}&title.value=${encodeURIComponent(
Expand All @@ -527,7 +530,7 @@ export class PlexApiService {
collectionId: string,
): Promise<BasicResponseDto> {
try {
await this.plexClient.deleteQuery<PlexLibraryResponse>({
await this.plexClient.deleteQuery({
uri: `/library/collections/${collectionId}`,
});
} catch (err) {
Expand Down Expand Up @@ -955,15 +958,15 @@ export class PlexApiService {
const data = await this.getChildrenMetadata(context.id.toString());

// transform & add eps
data
? handleMedia.push(
...data.map((el) => {
return {
plexId: +el.ratingKey,
};
}),
)
: undefined;
if (data) {
handleMedia.push(
...data.map((el) => {
return {
plexId: +el.ratingKey,
};
}),
);
}
break;
case EPlexDataType.EPISODES:
// transform & push episode
Expand Down Expand Up @@ -993,15 +996,15 @@ export class PlexApiService {
season.ratingKey.toString(),
);
// transform & add eps
eps
? handleMedia.push(
...eps.map((el) => {
return {
plexId: +el.ratingKey,
};
}),
)
: undefined;
if (eps) {
handleMedia.push(
...eps.map((el) => {
return {
plexId: +el.ratingKey,
};
}),
);
}
}
break;
case EPlexDataType.MOVIES:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ interface Response<T> {
| {
message: string | null;
result: 'error';
data: {};
data: object;
};
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/modules/api/tmdb-api/tmdb-id.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class TmdbIdService {
libItem.grandparentRatingKey.toString(),
)
: libItem.parentRatingKey
? await this.plexApi.getMetadata(libItem.parentRatingKey.toString())
: libItem;
? await this.plexApi.getMetadata(libItem.parentRatingKey.toString())
: libItem;

return this.getTmdbIdFromPlexData(libItem);
} else {
Expand Down
2 changes: 0 additions & 2 deletions server/src/modules/api/tmdb-api/tmdb.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import {
TmdbUpcomingMoviesResponse,
} from './interfaces/tmdb.interface';

const ANIME_KEYWORD_ID = 210024;

export class TmdbApiService extends ExternalApiService {
private region?: string;
private originalLanguage?: string;
Expand Down
16 changes: 8 additions & 8 deletions server/src/modules/collections/collections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ interface addCollectionDbResponse {
deleteAfterDays: number;
manualCollection: boolean;
}

@Injectable()
export class CollectionsService {
private readonly logger = new Logger(CollectionsService.name);

constructor(
@InjectRepository(Collection)
private readonly collectionRepo: Repository<Collection>,
Expand Down Expand Up @@ -562,11 +564,11 @@ export class CollectionsService {
sharedHome: collection.visibleOnHome,
});
} else {
collection.manualCollection
? this.logger.warn(
`Manual Collection '${collection.manualCollectionName}' doesn't exist in Plex..`,
)
: undefined;
if (collection.manualCollection) {
this.logger.warn(
`Manual Collection '${collection.manualCollectionName}' doesn't exist in Plex..`,
);
}
}
}
// add children to collection
Expand Down Expand Up @@ -696,9 +698,7 @@ export class CollectionsService {
});

if (!collection.manualCollection) {
const status = await this.plexApi.deleteCollection(
collection.plexId.toString(),
);
await this.plexApi.deleteCollection(collection.plexId.toString());
}

await this.CollectionMediaRepo.delete({ collectionId: collection.id });
Expand Down
10 changes: 4 additions & 6 deletions server/src/modules/collections/entities/collection.entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,14 @@ export class Collection {
sonarrSettings: SonarrSettings;

@OneToMany(
(type) => CollectionMedia,
() => CollectionMedia,
(collectionMedia) => collectionMedia.collectionId,
{ onDelete: 'CASCADE' },
)
collectionMedia: CollectionMedia[];

@OneToMany(
(type) => CollectionLog,
(collectionLog) => collectionLog.collection,
{ onDelete: 'CASCADE' },
)
@OneToMany(() => CollectionLog, (collectionLog) => collectionLog.collection, {
onDelete: 'CASCADE',
})
collectionLog: CollectionLog[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CollectionLog {
@PrimaryGeneratedColumn()
id: number;

@ManyToOne((type) => Collection, (collection) => collection.collectionLog, {
@ManyToOne(() => Collection, (collection) => collection.collectionLog, {
onDelete: 'CASCADE',
})
collection: Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CollectionMedia {
@Column({ default: false, nullable: true })
isManual: boolean;

@ManyToOne((type) => Collection, (collection) => collection.collectionMedia, {
@ManyToOne(() => Collection, (collection) => collection.collectionMedia, {
onDelete: 'CASCADE',
})
collection: Collection;
Expand Down
3 changes: 1 addition & 2 deletions server/src/modules/rules/entities/rule-group.entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Column,
PrimaryGeneratedColumn,
OneToMany,
ManyToOne,
OneToOne,
JoinColumn,
} from 'typeorm';
Expand Down Expand Up @@ -37,7 +36,7 @@ export class RuleGroup {
@Column({ nullable: true })
dataType: number;

@OneToMany((type) => Rules, (rules) => rules.ruleGroup, {
@OneToMany(() => Rules, (rules) => rules.ruleGroup, {
onDelete: 'CASCADE',
})
rules: Rules[];
Expand Down
2 changes: 1 addition & 1 deletion server/src/modules/rules/entities/rules.entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Rules {
@Column({ default: true })
isActive: boolean;

@ManyToOne((type) => RuleGroup, (ruleGroup) => ruleGroup.rules, {
@ManyToOne(() => RuleGroup, (ruleGroup) => ruleGroup.rules, {
onDelete: 'CASCADE',
})
ruleGroup: RuleGroup;
Expand Down
2 changes: 1 addition & 1 deletion server/src/modules/rules/getter/getter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ValueGetterService {
return await this.plexGetter.get(val2, libItem, dataType, ruleGroup);
}
case Application.RADARR: {
return await this.radarrGetter.get(val2, libItem, dataType, ruleGroup);
return await this.radarrGetter.get(val2, libItem, ruleGroup);
}
case Application.SONARR: {
return await this.sonarrGetter.get(val2, libItem, dataType, ruleGroup);
Expand Down
19 changes: 8 additions & 11 deletions server/src/modules/rules/getter/overseerr-getter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import {
OverSeerrMediaResponse,
OverseerrMediaStatus,
OverseerrRequest,
} from '../../../modules/api/overseerr-api/overseerr-api.service';
import {
PlexLibraryItem,
SimplePlexUser,
} from '../../../modules/api/plex-api/interfaces/library.interfaces';
import { PlexApiService } from '../../../modules/api/plex-api/plex-api.service';
import { TmdbIdService } from '../../../modules/api/tmdb-api/tmdb-id.service';
import { TmdbApiService } from '../../../modules/api/tmdb-api/tmdb.service';
} from '../../api/overseerr-api/overseerr-api.service';
import { PlexLibraryItem } from '../../api/plex-api/interfaces/library.interfaces';
import { PlexApiService } from '../../api/plex-api/plex-api.service';
import { TmdbIdService } from '../../api/tmdb-api/tmdb-id.service';
import { TmdbApiService } from '../../api/tmdb-api/tmdb.service';
import {
Application,
Property,
Expand Down Expand Up @@ -120,10 +117,10 @@ export class OverseerrGetterService {
if (request.requestedBy?.userType === 2) {
userNames.push(request.requestedBy?.username);
} else {
let user = plexUsers.find(
const user = plexUsers.find(
(u) => u.plexId === request.requestedBy?.plexId,
)?.username;

if (user) {
userNames.push(user);
}
Expand All @@ -134,7 +131,7 @@ export class OverseerrGetterService {
if (request.requestedBy?.userType === 2) {
userNames.push(request.requestedBy?.username);
} else {
let user = plexUsers.find(
const user = plexUsers.find(
(u) => u.plexId === request.requestedBy?.plexId,
)?.username;

Expand Down
Loading

0 comments on commit 149dc78

Please sign in to comment.