From a14c10bad2ea65c65d950e6633fa9302b10aa679 Mon Sep 17 00:00:00 2001 From: dw-0 Date: Mon, 14 Oct 2024 10:49:18 +0200 Subject: [PATCH] Feature/Enable unused compiler options in tsconfig (#3895) * Enable noUnusedLocals noUnusedParameters in compiler options of tsconfig * Update changelog --- CHANGELOG.md | 2 ++ apps/api/src/app/account/create-account.dto.ts | 2 +- apps/api/src/app/account/update-account.dto.ts | 2 +- apps/api/src/app/auth/auth.controller.ts | 11 ++++------- apps/api/src/app/auth/google.strategy.ts | 8 ++++---- apps/api/src/app/auth/web-auth.service.ts | 11 +++++------ .../transform-data-source-in-response.interceptor.ts | 2 +- .../yahoo-finance/yahoo-finance.service.spec.ts | 4 ---- .../yahoo-finance/yahoo-finance.service.ts | 2 -- .../google-sheets/google-sheets.service.ts | 2 +- .../benchmark-comparator.component.ts | 7 ++++--- .../investment-chart/investment-chart.component.ts | 7 ++++--- libs/common/src/lib/chart-helper.ts | 2 +- libs/ui/src/lib/line-chart/line-chart.component.ts | 7 ++++--- tsconfig.base.json | 4 ++-- 15 files changed, 34 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c0743bc..021aaa9fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Exposed the timeout of the portfolio snapshot computation as an environment variable (`PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT`) - Harmonized the processor concurrency environment variables - Improved the portfolio unit tests to work with exported activity files +- Enabled the `noUnusedLocals` compiler option in the `tsconfig` +- Enabled the `noUnusedParameters` compiler option in the `tsconfig` ### Fixed diff --git a/apps/api/src/app/account/create-account.dto.ts b/apps/api/src/app/account/create-account.dto.ts index f3c88316f..b331d4ec7 100644 --- a/apps/api/src/app/account/create-account.dto.ts +++ b/apps/api/src/app/account/create-account.dto.ts @@ -36,6 +36,6 @@ export class CreateAccountDto { name: string; @IsString() - @ValidateIf((object, value) => value !== null) + @ValidateIf((_object, value) => value !== null) platformId: string | null; } diff --git a/apps/api/src/app/account/update-account.dto.ts b/apps/api/src/app/account/update-account.dto.ts index 6b87af71b..3a721d873 100644 --- a/apps/api/src/app/account/update-account.dto.ts +++ b/apps/api/src/app/account/update-account.dto.ts @@ -35,6 +35,6 @@ export class UpdateAccountDto { name: string; @IsString() - @ValidateIf((object, value) => value !== null) + @ValidateIf((_object, value) => value !== null) platformId: string | null; } diff --git a/apps/api/src/app/auth/auth.controller.ts b/apps/api/src/app/auth/auth.controller.ts index c81c7e224..5019bef21 100644 --- a/apps/api/src/app/auth/auth.controller.ts +++ b/apps/api/src/app/auth/auth.controller.ts @@ -14,12 +14,12 @@ import { Req, Res, UseGuards, - VERSION_NEUTRAL, - Version + Version, + VERSION_NEUTRAL } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { Request, Response } from 'express'; -import { StatusCodes, getReasonPhrase } from 'http-status-codes'; +import { getReasonPhrase, StatusCodes } from 'http-status-codes'; import { AuthService } from './auth.service'; import { @@ -130,10 +130,7 @@ export class AuthController { public async verifyAttestation( @Body() body: { deviceName: string; credential: AttestationCredentialJSON } ) { - return this.webAuthService.verifyAttestation( - body.deviceName, - body.credential - ); + return this.webAuthService.verifyAttestation(body.credential); } @Post('webauthn/generate-assertion-options') diff --git a/apps/api/src/app/auth/google.strategy.ts b/apps/api/src/app/auth/google.strategy.ts index ea6772680..02f82a7a8 100644 --- a/apps/api/src/app/auth/google.strategy.ts +++ b/apps/api/src/app/auth/google.strategy.ts @@ -11,7 +11,7 @@ import { AuthService } from './auth.service'; export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { public constructor( private readonly authService: AuthService, - private readonly configurationService: ConfigurationService + configurationService: ConfigurationService ) { super({ callbackURL: `${configurationService.get( @@ -25,9 +25,9 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { } public async validate( - request: any, - token: string, - refreshToken: string, + _request: any, + _token: string, + _refreshToken: string, profile: Profile, done: Function ) { diff --git a/apps/api/src/app/auth/web-auth.service.ts b/apps/api/src/app/auth/web-auth.service.ts index 961bbe9a7..2f8dd1018 100644 --- a/apps/api/src/app/auth/web-auth.service.ts +++ b/apps/api/src/app/auth/web-auth.service.ts @@ -13,16 +13,16 @@ import { import { REQUEST } from '@nestjs/core'; import { JwtService } from '@nestjs/jwt'; import { + generateAuthenticationOptions, GenerateAuthenticationOptionsOpts, + generateRegistrationOptions, GenerateRegistrationOptionsOpts, VerifiedAuthenticationResponse, VerifiedRegistrationResponse, - VerifyAuthenticationResponseOpts, - VerifyRegistrationResponseOpts, - generateAuthenticationOptions, - generateRegistrationOptions, verifyAuthenticationResponse, - verifyRegistrationResponse + VerifyAuthenticationResponseOpts, + verifyRegistrationResponse, + VerifyRegistrationResponseOpts } from '@simplewebauthn/server'; import { @@ -80,7 +80,6 @@ export class WebAuthService { } public async verifyAttestation( - deviceName: string, credential: AttestationCredentialJSON ): Promise { const user = this.request.user; diff --git a/apps/api/src/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor.ts b/apps/api/src/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor.ts index aff42f002..f5034927c 100644 --- a/apps/api/src/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor.ts +++ b/apps/api/src/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor.ts @@ -21,7 +21,7 @@ export class TransformDataSourceInResponseInterceptor ) {} public intercept( - context: ExecutionContext, + _context: ExecutionContext, next: CallHandler ): Observable { return next.handle().pipe( diff --git a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.spec.ts b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.spec.ts index 951a623d0..8a8ab1f08 100644 --- a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.spec.ts +++ b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.spec.ts @@ -1,4 +1,3 @@ -import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.service'; import { YahooFinanceDataEnhancerService } from './yahoo-finance.service'; @@ -26,16 +25,13 @@ jest.mock( ); describe('YahooFinanceDataEnhancerService', () => { - let configurationService: ConfigurationService; let cryptocurrencyService: CryptocurrencyService; let yahooFinanceDataEnhancerService: YahooFinanceDataEnhancerService; beforeAll(async () => { - configurationService = new ConfigurationService(); cryptocurrencyService = new CryptocurrencyService(); yahooFinanceDataEnhancerService = new YahooFinanceDataEnhancerService( - configurationService, cryptocurrencyService ); }); diff --git a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts index 1b1335b7e..6090b4f98 100644 --- a/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts @@ -1,4 +1,3 @@ -import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.service'; import { DataEnhancerInterface } from '@ghostfolio/api/services/data-provider/interfaces/data-enhancer.interface'; import { @@ -24,7 +23,6 @@ import type { Price } from 'yahoo-finance2/dist/esm/src/modules/quoteSummary-ifa @Injectable() export class YahooFinanceDataEnhancerService implements DataEnhancerInterface { public constructor( - private readonly configurationService: ConfigurationService, private readonly cryptocurrencyService: CryptocurrencyService ) {} diff --git a/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts b/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts index 966069f22..9f2344233 100644 --- a/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts +++ b/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts @@ -76,7 +76,7 @@ export class GoogleSheetsService implements DataProviderInterface { } = {}; rows - .filter((row, index) => { + .filter((_row, index) => { return index >= 1; }) .forEach((row) => { diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts index a59515969..dc80b4058 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts +++ b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts @@ -29,12 +29,13 @@ import { SymbolProfile } from '@prisma/client'; import { Chart, ChartData, + LinearScale, LineController, LineElement, - LinearScale, PointElement, TimeScale, - Tooltip + Tooltip, + TooltipPosition } from 'chart.js'; import 'chartjs-adapter-date-fns'; import annotationPlugin from 'chartjs-plugin-annotation'; @@ -74,7 +75,7 @@ export class BenchmarkComparatorComponent implements OnChanges, OnDestroy { Tooltip ); - Tooltip.positioners['top'] = (elements, position) => + Tooltip.positioners['top'] = (_elements, position: TooltipPosition) => getTooltipPositionerMapTop(this.chart, position); } diff --git a/apps/client/src/app/components/investment-chart/investment-chart.component.ts b/apps/client/src/app/components/investment-chart/investment-chart.component.ts index 15a4a6f9a..e84032060 100644 --- a/apps/client/src/app/components/investment-chart/investment-chart.component.ts +++ b/apps/client/src/app/components/investment-chart/investment-chart.component.ts @@ -29,12 +29,13 @@ import { BarElement, Chart, ChartData, + LinearScale, LineController, LineElement, - LinearScale, PointElement, TimeScale, - Tooltip + Tooltip, + TooltipPosition } from 'chart.js'; import 'chartjs-adapter-date-fns'; import annotationPlugin from 'chartjs-plugin-annotation'; @@ -79,7 +80,7 @@ export class InvestmentChartComponent implements OnChanges, OnDestroy { Tooltip ); - Tooltip.positioners['top'] = (elements, position) => + Tooltip.positioners['top'] = (_elements, position: TooltipPosition) => getTooltipPositionerMapTop(this.chart, position); } diff --git a/libs/common/src/lib/chart-helper.ts b/libs/common/src/lib/chart-helper.ts index 5b65d4a87..4181ebbbf 100644 --- a/libs/common/src/lib/chart-helper.ts +++ b/libs/common/src/lib/chart-helper.ts @@ -103,7 +103,7 @@ export function getVerticalHoverLinePlugin( colorScheme?: ColorScheme ) { return { - afterDatasetsDraw: (chart, x, options) => { + afterDatasetsDraw: (chart, _, options) => { const active = chart.getActiveElements(); if (!active || active.length === 0) { diff --git a/libs/ui/src/lib/line-chart/line-chart.component.ts b/libs/ui/src/lib/line-chart/line-chart.component.ts index 4098e1d5b..e48ead9d9 100644 --- a/libs/ui/src/lib/line-chart/line-chart.component.ts +++ b/libs/ui/src/lib/line-chart/line-chart.component.ts @@ -27,12 +27,13 @@ import { import { Chart, Filler, + LinearScale, LineController, LineElement, - LinearScale, PointElement, TimeScale, - Tooltip + Tooltip, + TooltipPosition } from 'chart.js'; import 'chartjs-adapter-date-fns'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; @@ -85,7 +86,7 @@ export class GfLineChartComponent Tooltip ); - Tooltip.positioners['top'] = (elements, position) => + Tooltip.positioners['top'] = (_elements, position: TooltipPosition) => getTooltipPositionerMapTop(this.chart, position); } diff --git a/tsconfig.base.json b/tsconfig.base.json index e977a9596..34ed5d559 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -31,8 +31,8 @@ "noImplicitThis": false, "noImplicitOverride": false, "noPropertyAccessFromIndexSignature": false, - "noUnusedLocals": false, - "noUnusedParameters": false, + "noUnusedLocals": true, + "noUnusedParameters": true, "allowUnreachableCode": true }, "exclude": ["node_modules", "tmp"]