From 4c10978fc7951510f95e7291c0c5ca8cdbc21345 Mon Sep 17 00:00:00 2001 From: Nowadays Date: Tue, 29 Oct 2024 22:54:34 +0100 Subject: [PATCH 1/3] chore: migrate to eslint flat package to support eslint V9 --- .gitignore | 3 ++- package.json | 2 ++ server/.eslintrc.js | 31 ------------------------- server/eslint.config.mjs | 50 ++++++++++++++++++++++++++++++++++++++++ yarn.lock | 9 ++++++++ 5 files changed, 63 insertions(+), 32 deletions(-) delete mode 100644 server/.eslintrc.js create mode 100644 server/eslint.config.mjs diff --git a/.gitignore b/.gitignore index e3b2dbf7..5eb8acaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ data/ docs-output/ node_modules -.yarn \ No newline at end of file +.yarn +.idea \ No newline at end of file diff --git a/package.json b/package.json index 6d9440a5..c9d55869 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,8 @@ "devDependencies": { "@automock/jest": "^1.4.0", "@babel/core": "^7.26.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.13.0", "@nestjs/cli": "^10.4.5", "@nestjs/schematics": "^10.2.3", "@nestjs/testing": "^10.4.4", diff --git a/server/.eslintrc.js b/server/.eslintrc.js deleted file mode 100644 index 9844fbb4..00000000 --- a/server/.eslintrc.js +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - 'prettier/prettier': [ - 'error', - { - 'endOfLine': 'auto', - } - ] - }, -}; diff --git a/server/eslint.config.mjs b/server/eslint.config.mjs new file mode 100644 index 00000000..ebb892c1 --- /dev/null +++ b/server/eslint.config.mjs @@ -0,0 +1,50 @@ +import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: ["**/eslint.config.mjs"], +}, ...compat.extends("plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"), { + plugins: { + "@typescript-eslint": typescriptEslintEslintPlugin, + }, + + languageOptions: { + globals: { + ...globals.node, + ...globals.jest, + }, + + parser: tsParser, + ecmaVersion: 5, + sourceType: "module", + + parserOptions: { + project: "tsconfig.json", + tsconfigRootDir: ".", + }, + }, + + rules: { + "@typescript-eslint/interface-name-prefix": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "off", + + "prettier/prettier": ["error", { + endOfLine: "auto", + }], + }, +}]; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 53ebdd63..beb2246d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2147,6 +2147,13 @@ __metadata: languageName: node linkType: hard +"@eslint/js@npm:^9.13.0": + version: 9.13.0 + resolution: "@eslint/js@npm:9.13.0" + checksum: 10c0/672257bffe17777b8a98bd80438702904cc7a0b98b9c2e426a8a10929198b3553edf8a3fc20feed4133c02e7c8f7331a0ef1b23e5dab8e4469f7f1791beff1e0 + languageName: node + linkType: hard + "@eslint/object-schema@npm:^2.1.4": version: 2.1.4 resolution: "@eslint/object-schema@npm:2.1.4" @@ -11656,6 +11663,8 @@ __metadata: dependencies: "@automock/jest": "npm:^1.4.0" "@babel/core": "npm:^7.26.0" + "@eslint/eslintrc": "npm:^3.1.0" + "@eslint/js": "npm:^9.13.0" "@headlessui/react": "npm:2.1.9" "@heroicons/react": "npm:^1.0.6" "@monaco-editor/react": "npm:^4.6.0" From 575a6c58ea678ef87e4ae2ab1e9200462ef257b7 Mon Sep 17 00:00:00 2001 From: Nowadays Date: Thu, 7 Nov 2024 23:06:20 +0100 Subject: [PATCH 2/3] fix(package.json): lint:server script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c9d55869..90c7f597 100644 --- a/package.json +++ b/package.json @@ -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": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "lint:server": "cd server && eslint \"**/*.ts\" --fix", "test": "jest", "test:clear": "jest --clearCache", "test:watch": "jest --watch", From 149dc78d08beed8df967e8da576307b8cf02f1ce Mon Sep 17 00:00:00 2001 From: Nowadays Date: Thu, 7 Nov 2024 23:27:51 +0100 Subject: [PATCH 3/3] fix: lint issues --- package.json | 2 +- server/eslint.config.mjs | 7 +- .../1728503476668-Update_tautulli_URL.ts | 2 +- server/src/modules/api/lib/cache.ts | 2 +- server/src/modules/api/lib/plexApi.ts | 6 +- .../overseerr-api/overseerr-api.service.ts | 4 +- .../modules/api/plex-api/plex-api.service.ts | 67 ++++++++++--------- .../api/tautulli-api/tautulli-api.service.ts | 2 +- .../modules/api/tmdb-api/tmdb-id.service.ts | 4 +- .../src/modules/api/tmdb-api/tmdb.service.ts | 2 - .../collections/collections.service.ts | 16 ++--- .../entities/collection.entities.ts | 10 ++- .../entities/collection_log.entities.ts | 2 +- .../entities/collection_media.entities.ts | 2 +- .../rules/entities/rule-group.entities.ts | 3 +- .../modules/rules/entities/rules.entities.ts | 2 +- .../modules/rules/getter/getter.service.ts | 2 +- .../rules/getter/overseerr-getter.service.ts | 19 +++--- .../rules/getter/plex-getter.service.ts | 13 ++-- .../rules/getter/radarr-getter.service.ts | 14 ++-- .../rules/getter/sonarr-getter.service.ts | 2 - .../src/modules/rules/helpers/yaml.service.ts | 5 +- server/src/modules/rules/rules.service.ts | 2 +- .../rules/tasks/rule-executor.service.ts | 1 - ...le.comparator.service.doRuleAction.spec.ts | 2 +- 25 files changed, 92 insertions(+), 101 deletions(-) diff --git a/package.json b/package.json index 90c7f597..ad526f72 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/server/eslint.config.mjs b/server/eslint.config.mjs index ebb892c1..4319f40e 100644 --- a/server/eslint.config.mjs +++ b/server/eslint.config.mjs @@ -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", }], diff --git a/server/src/database/migrations/1728503476668-Update_tautulli_URL.ts b/server/src/database/migrations/1728503476668-Update_tautulli_URL.ts index b783763a..17f29bc1 100644 --- a/server/src/database/migrations/1728503476668-Update_tautulli_URL.ts +++ b/server/src/database/migrations/1728503476668-Update_tautulli_URL.ts @@ -9,5 +9,5 @@ export class UpdateTautulliURL1728503476668 implements MigrationInterface { ); } - public async down(queryRunner: QueryRunner): Promise {} + public async down(): Promise {} } diff --git a/server/src/modules/api/lib/cache.ts b/server/src/modules/api/lib/cache.ts index 5396d02a..0a31735b 100644 --- a/server/src/modules/api/lib/cache.ts +++ b/server/src/modules/api/lib/cache.ts @@ -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(); } } diff --git a/server/src/modules/api/lib/plexApi.ts b/server/src/modules/api/lib/plexApi.ts index 92f349c2..70da8e84 100644 --- a/server/src/modules/api/lib/plexApi.ts +++ b/server/src/modules/api/lib/plexApi.ts @@ -87,13 +87,13 @@ class PlexApi extends NodePlexAPI { } } - deleteQuery(arg) { + deleteQuery(arg) { return super.deleteQuery(arg); } - postQuery(arg) { + postQuery(arg) { return super.postQuery(arg); } - putQuery(arg) { + putQuery(arg) { return super.putQuery(arg); } diff --git a/server/src/modules/api/overseerr-api/overseerr-api.service.ts b/server/src/modules/api/overseerr-api/overseerr-api.service.ts index 9c65c3be..48b297f4 100644 --- a/server/src/modules/api/overseerr-api/overseerr-api.service.ts +++ b/server/src/modules/api/overseerr-api/overseerr-api.service.ts @@ -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}`, ); diff --git a/server/src/modules/api/plex-api/plex-api.service.ts b/server/src/modules/api/plex-api/plex-api.service.ts index d6cb985a..dad8e489 100644 --- a/server/src/modules/api/plex-api/plex-api.service.ts +++ b/server/src/modules/api/plex-api/plex-api.service.ts @@ -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 { @@ -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'; @@ -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, @@ -73,6 +73,7 @@ export class PlexApiService { webAppUrl: this.settings.plex_hostname, }; } + public async initialize({ plexToken, timeout, @@ -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?', @@ -444,7 +447,7 @@ export class PlexApiService { `[Plex] Removed media with ID ${plexId} from Plex library.`, ); try { - await this.plexClient.deleteQuery({ + await this.plexClient.deleteQuery({ uri: `/library/metadata/${plexId}`, }); } catch (e) { @@ -480,7 +483,7 @@ export class PlexApiService { public async createCollection(params: CreateUpdateCollection) { try { - const response = await this.plexClient.postQuery({ + const response = await this.plexClient.postQuery({ uri: `/library/collections?type=${ params.type }&title=${encodeURIComponent(params.title)}§ionId=${ @@ -505,7 +508,7 @@ export class PlexApiService { public async updateCollection(body: CreateUpdateCollection) { try { - await this.plexClient.putQuery({ + await this.plexClient.putQuery({ uri: `/library/sections/${body.libraryId}/all?type=18&id=${ body.collectionId }&title.value=${encodeURIComponent( @@ -527,7 +530,7 @@ export class PlexApiService { collectionId: string, ): Promise { try { - await this.plexClient.deleteQuery({ + await this.plexClient.deleteQuery({ uri: `/library/collections/${collectionId}`, }); } catch (err) { @@ -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 @@ -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: diff --git a/server/src/modules/api/tautulli-api/tautulli-api.service.ts b/server/src/modules/api/tautulli-api/tautulli-api.service.ts index e7312e7f..b4213b9c 100644 --- a/server/src/modules/api/tautulli-api/tautulli-api.service.ts +++ b/server/src/modules/api/tautulli-api/tautulli-api.service.ts @@ -84,7 +84,7 @@ interface Response { | { message: string | null; result: 'error'; - data: {}; + data: object; }; } diff --git a/server/src/modules/api/tmdb-api/tmdb-id.service.ts b/server/src/modules/api/tmdb-api/tmdb-id.service.ts index d9bc3f2f..1e42956a 100644 --- a/server/src/modules/api/tmdb-api/tmdb-id.service.ts +++ b/server/src/modules/api/tmdb-api/tmdb-id.service.ts @@ -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 { diff --git a/server/src/modules/api/tmdb-api/tmdb.service.ts b/server/src/modules/api/tmdb-api/tmdb.service.ts index c3868cb7..d5e02ef3 100644 --- a/server/src/modules/api/tmdb-api/tmdb.service.ts +++ b/server/src/modules/api/tmdb-api/tmdb.service.ts @@ -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; diff --git a/server/src/modules/collections/collections.service.ts b/server/src/modules/collections/collections.service.ts index bc6ccebe..ed6a7f05 100644 --- a/server/src/modules/collections/collections.service.ts +++ b/server/src/modules/collections/collections.service.ts @@ -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, @@ -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 @@ -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 }); diff --git a/server/src/modules/collections/entities/collection.entities.ts b/server/src/modules/collections/entities/collection.entities.ts index e976174b..3779a900 100644 --- a/server/src/modules/collections/entities/collection.entities.ts +++ b/server/src/modules/collections/entities/collection.entities.ts @@ -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[]; } diff --git a/server/src/modules/collections/entities/collection_log.entities.ts b/server/src/modules/collections/entities/collection_log.entities.ts index daed305d..d4dfc08a 100644 --- a/server/src/modules/collections/entities/collection_log.entities.ts +++ b/server/src/modules/collections/entities/collection_log.entities.ts @@ -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; diff --git a/server/src/modules/collections/entities/collection_media.entities.ts b/server/src/modules/collections/entities/collection_media.entities.ts index 5a7be4f7..125d2cff 100644 --- a/server/src/modules/collections/entities/collection_media.entities.ts +++ b/server/src/modules/collections/entities/collection_media.entities.ts @@ -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; diff --git a/server/src/modules/rules/entities/rule-group.entities.ts b/server/src/modules/rules/entities/rule-group.entities.ts index 4ddf35b3..855f2c93 100644 --- a/server/src/modules/rules/entities/rule-group.entities.ts +++ b/server/src/modules/rules/entities/rule-group.entities.ts @@ -5,7 +5,6 @@ import { Column, PrimaryGeneratedColumn, OneToMany, - ManyToOne, OneToOne, JoinColumn, } from 'typeorm'; @@ -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[]; diff --git a/server/src/modules/rules/entities/rules.entities.ts b/server/src/modules/rules/entities/rules.entities.ts index f03b7812..17108dd5 100644 --- a/server/src/modules/rules/entities/rules.entities.ts +++ b/server/src/modules/rules/entities/rules.entities.ts @@ -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; diff --git a/server/src/modules/rules/getter/getter.service.ts b/server/src/modules/rules/getter/getter.service.ts index 595d9e76..6645ff6d 100644 --- a/server/src/modules/rules/getter/getter.service.ts +++ b/server/src/modules/rules/getter/getter.service.ts @@ -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); diff --git a/server/src/modules/rules/getter/overseerr-getter.service.ts b/server/src/modules/rules/getter/overseerr-getter.service.ts index e58bea04..83392587 100644 --- a/server/src/modules/rules/getter/overseerr-getter.service.ts +++ b/server/src/modules/rules/getter/overseerr-getter.service.ts @@ -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, @@ -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); } @@ -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; diff --git a/server/src/modules/rules/getter/plex-getter.service.ts b/server/src/modules/rules/getter/plex-getter.service.ts index 88b1f923..34452fdb 100644 --- a/server/src/modules/rules/getter/plex-getter.service.ts +++ b/server/src/modules/rules/getter/plex-getter.service.ts @@ -56,7 +56,7 @@ export class PlexGetterService { const viewers: PlexSeenBy[] = await this.plexApi .getWatchHistory(metadata.ratingKey) - .catch((_err) => { + .catch(() => { return null; }); if (viewers) { @@ -236,7 +236,7 @@ export class PlexGetterService { return null; } }) - .catch((_err) => { + .catch(() => { return null; }); } @@ -281,7 +281,7 @@ export class PlexGetterService { for (const episode of episodes) { const viewers: PlexSeenBy[] = await this.plexApi .getWatchHistory(episode.ratingKey) - .catch((_err) => { + .catch(() => { return null; }); @@ -365,7 +365,9 @@ export class PlexGetterService { const views = await this.plexApi.getWatchHistory( episode.ratingKey, ); - views?.length > 0 ? viewCount++ : undefined; + if (views?.length > 0) { + viewCount++; + } } } return viewCount; @@ -447,7 +449,8 @@ export class PlexGetterService { : metadata.guid; const media_uuid = guid.match(/plex:\/\/[a-z]+\/([a-z0-9]+)$/); - const plexUsers: SimplePlexUser[] = await this.plexApi.getCorrectedUsers(); + const plexUsers: SimplePlexUser[] = + await this.plexApi.getCorrectedUsers(); const userFilterPromises = plexUsers.map(async (u) => { if (u.uuid === undefined || media_uuid === undefined) return false; // break if uuids are unavailable diff --git a/server/src/modules/rules/getter/radarr-getter.service.ts b/server/src/modules/rules/getter/radarr-getter.service.ts index ab413c8d..f82dc878 100644 --- a/server/src/modules/rules/getter/radarr-getter.service.ts +++ b/server/src/modules/rules/getter/radarr-getter.service.ts @@ -1,13 +1,12 @@ import { Injectable, Logger } from '@nestjs/common'; -import { PlexLibraryItem } from '../../../modules/api/plex-api/interfaces/library.interfaces'; -import { ServarrService } from '../../../modules/api/servarr-api/servarr.service'; -import { TmdbIdService } from '../../../modules/api/tmdb-api/tmdb-id.service'; +import { PlexLibraryItem } from '../../api/plex-api/interfaces/library.interfaces'; +import { ServarrService } from '../../api/servarr-api/servarr.service'; +import { TmdbIdService } from '../../api/tmdb-api/tmdb-id.service'; import { Application, Property, RuleConstants, } from '../constants/rules.constants'; -import { EPlexDataType } from '../../api/plex-api/enums/plex-data-type-enum'; import { RulesDto } from '../dtos/rules.dto'; @Injectable() @@ -25,12 +24,7 @@ export class RadarrGetterService { ).props; } - async get( - id: number, - libItem: PlexLibraryItem, - dataType?: EPlexDataType, - ruleGroup?: RulesDto, - ) { + async get(id: number, libItem: PlexLibraryItem, ruleGroup?: RulesDto) { if (!ruleGroup.collection?.radarrSettingsId) { this.logger.error( `No Radarr server configured for ${ruleGroup.collection?.title}`, diff --git a/server/src/modules/rules/getter/sonarr-getter.service.ts b/server/src/modules/rules/getter/sonarr-getter.service.ts index 2ea38ea5..6bf9af86 100644 --- a/server/src/modules/rules/getter/sonarr-getter.service.ts +++ b/server/src/modules/rules/getter/sonarr-getter.service.ts @@ -261,8 +261,6 @@ export class SonarrGetterService { ) )?.seasonNumber : false; - } else { - false; } } } diff --git a/server/src/modules/rules/helpers/yaml.service.ts b/server/src/modules/rules/helpers/yaml.service.ts index 0a53c667..38b9b7eb 100644 --- a/server/src/modules/rules/helpers/yaml.service.ts +++ b/server/src/modules/rules/helpers/yaml.service.ts @@ -1,10 +1,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { RuleDto } from '../dtos/rule.dto'; import { ReturnStatus } from '../rules.service'; -import { - RuleOperators, - RulePossibility, -} from '../constants/rules.constants'; +import { RuleOperators, RulePossibility } from '../constants/rules.constants'; import YAML from 'yaml'; import { EPlexDataType, diff --git a/server/src/modules/rules/rules.service.ts b/server/src/modules/rules/rules.service.ts index f1d39e6c..f088e613 100644 --- a/server/src/modules/rules/rules.service.ts +++ b/server/src/modules/rules/rules.service.ts @@ -780,7 +780,7 @@ export class RulesService { .execute(); return groupId.identifiers[0].id; } else { - const groupId = await connection + await connection .update(RuleGroup) .set(values) .where({ id: id }) diff --git a/server/src/modules/rules/tasks/rule-executor.service.ts b/server/src/modules/rules/tasks/rule-executor.service.ts index 5e9e7176..228b3208 100644 --- a/server/src/modules/rules/tasks/rule-executor.service.ts +++ b/server/src/modules/rules/tasks/rule-executor.service.ts @@ -1,5 +1,4 @@ import { Injectable, Logger } from '@nestjs/common'; -import _ from 'lodash'; import { PlexLibraryItem } from '../../api/plex-api/interfaces/library.interfaces'; import { PlexApiService } from '../../api/plex-api/plex-api.service'; import { CollectionsService } from '../../collections/collections.service'; diff --git a/server/src/modules/rules/tests/rule.comparator.service.doRuleAction.spec.ts b/server/src/modules/rules/tests/rule.comparator.service.doRuleAction.spec.ts index e8307717..699bf20d 100644 --- a/server/src/modules/rules/tests/rule.comparator.service.doRuleAction.spec.ts +++ b/server/src/modules/rules/tests/rule.comparator.service.doRuleAction.spec.ts @@ -13,7 +13,7 @@ describe('RuleComparatorService', () => { .using({ get: jest.fn() }) .compile(); - ruleComparatorService = unit; + ruleComparatorService = unit; }); describe('doRuleAction', () => {