From 405ec0d2b29a30715884a5c6af0e670d55b53f12 Mon Sep 17 00:00:00 2001 From: dw-0 Date: Sat, 26 Oct 2024 09:41:37 +0200 Subject: [PATCH] Feature/switch the consistent-type-definitions eslint rule from warn to error (#3980) * Switch the consistent-type-definitions eslint rule from warn to error * Update changelog --------- Signed-off-by: Dominik Willner --- .eslintrc.json | 1 - CHANGELOG.md | 1 + apps/api/src/app/auth/interfaces/simplewebauthn.ts | 4 ++-- apps/api/src/app/user/update-user-setting.dto.ts | 4 ++-- .../components/home-holdings/home-holdings.component.ts | 7 ++----- .../rule/rule-settings-dialog/interfaces/interfaces.ts | 6 ++++-- .../rule-settings-dialog/rule-settings-dialog.component.ts | 2 +- apps/client/src/app/components/rule/rule.component.ts | 6 ++++-- apps/client/src/app/components/rules/rules.component.ts | 6 ++++-- apps/client/src/app/components/toggle/toggle.component.ts | 2 +- .../pages/portfolio/analysis/analysis-page.component.ts | 5 +++-- libs/common/src/lib/interfaces/index.ts | 6 +++++- .../toggle-option.interface.ts} | 4 ++-- libs/common/src/lib/interfaces/user-settings.interface.ts | 4 ++-- .../x-ray-rules-settings.interface.ts} | 4 ++-- libs/common/src/lib/types/index.ts | 6 +----- 16 files changed, 36 insertions(+), 32 deletions(-) rename libs/common/src/lib/{types/toggle-option.type.ts => interfaces/toggle-option.interface.ts} (50%) rename libs/common/src/lib/{types/x-ray-rules-settings.type.ts => interfaces/x-ray-rules-settings.interface.ts} (92%) diff --git a/.eslintrc.json b/.eslintrc.json index cdda2a98..a66ee6f0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -142,7 +142,6 @@ // The following rules are part of @typescript-eslint/stylistic-type-checked // and can be remove once solved - "@typescript-eslint/consistent-type-definitions": "warn", "@typescript-eslint/prefer-function-type": "warn", "@typescript-eslint/prefer-nullish-coalescing": "warn", // TODO: Requires strictNullChecks: true "@typescript-eslint/consistent-type-assertions": "warn", diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e80f3b0..8bc021cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Switched the `consistent-type-definitions` rule from `warn` to `error` in the `eslint` configuration - Switched the `no-empty-function` rule from `warn` to `error` in the `eslint` configuration ### Fixed diff --git a/apps/api/src/app/auth/interfaces/simplewebauthn.ts b/apps/api/src/app/auth/interfaces/simplewebauthn.ts index 4b9058e2..ef0a14ff 100644 --- a/apps/api/src/app/auth/interfaces/simplewebauthn.ts +++ b/apps/api/src/app/auth/interfaces/simplewebauthn.ts @@ -198,12 +198,12 @@ export interface AuthenticatorAssertionResponseJSON /** * A WebAuthn-compatible device and the information needed to verify assertions by it */ -export declare type AuthenticatorDevice = { +export declare interface AuthenticatorDevice { credentialPublicKey: Buffer; credentialID: Buffer; counter: number; transports?: AuthenticatorTransport[]; -}; +} /** * An attempt to communicate that this isn't just any string, but a Base64URL-encoded string */ diff --git a/apps/api/src/app/user/update-user-setting.dto.ts b/apps/api/src/app/user/update-user-setting.dto.ts index 6ea6d742..a4441af9 100644 --- a/apps/api/src/app/user/update-user-setting.dto.ts +++ b/apps/api/src/app/user/update-user-setting.dto.ts @@ -1,10 +1,10 @@ import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code'; +import { XRayRulesSettings } from '@ghostfolio/common/interfaces'; import type { ColorScheme, DateRange, HoldingsViewMode, - ViewMode, - XRayRulesSettings + ViewMode } from '@ghostfolio/common/types'; import { diff --git a/apps/client/src/app/components/home-holdings/home-holdings.component.ts b/apps/client/src/app/components/home-holdings/home-holdings.component.ts index c76638d3..d2b23d03 100644 --- a/apps/client/src/app/components/home-holdings/home-holdings.component.ts +++ b/apps/client/src/app/components/home-holdings/home-holdings.component.ts @@ -4,14 +4,11 @@ import { UserService } from '@ghostfolio/client/services/user/user.service'; import { AssetProfileIdentifier, PortfolioPosition, + ToggleOption, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; -import { - HoldingType, - HoldingsViewMode, - ToggleOption -} from '@ghostfolio/common/types'; +import { HoldingType, HoldingsViewMode } from '@ghostfolio/common/types'; import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { FormControl } from '@angular/forms'; diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts index 7eee7e52..6fcbd2d3 100644 --- a/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts +++ b/apps/client/src/app/components/rule/rule-settings-dialog/interfaces/interfaces.ts @@ -1,5 +1,7 @@ -import { PortfolioReportRule } from '@ghostfolio/common/interfaces'; -import { XRayRulesSettings } from '@ghostfolio/common/types'; +import { + PortfolioReportRule, + XRayRulesSettings +} from '@ghostfolio/common/interfaces'; export interface IRuleSettingsDialogParams { rule: PortfolioReportRule; diff --git a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts index 7aa22877..8b3dfed3 100644 --- a/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts +++ b/apps/client/src/app/components/rule/rule-settings-dialog/rule-settings-dialog.component.ts @@ -1,4 +1,4 @@ -import { XRayRulesSettings } from '@ghostfolio/common/types'; +import { XRayRulesSettings } from '@ghostfolio/common/interfaces'; import { CommonModule } from '@angular/common'; import { Component, Inject } from '@angular/core'; diff --git a/apps/client/src/app/components/rule/rule.component.ts b/apps/client/src/app/components/rule/rule.component.ts index f51ce805..04e6de66 100644 --- a/apps/client/src/app/components/rule/rule.component.ts +++ b/apps/client/src/app/components/rule/rule.component.ts @@ -1,7 +1,9 @@ import { UpdateUserSettingDto } from '@ghostfolio/api/app/user/update-user-setting.dto'; import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface'; -import { PortfolioReportRule } from '@ghostfolio/common/interfaces'; -import { XRayRulesSettings } from '@ghostfolio/common/types'; +import { + PortfolioReportRule, + XRayRulesSettings +} from '@ghostfolio/common/interfaces'; import { ChangeDetectionStrategy, diff --git a/apps/client/src/app/components/rules/rules.component.ts b/apps/client/src/app/components/rules/rules.component.ts index fb2ef1cd..bec0b642 100644 --- a/apps/client/src/app/components/rules/rules.component.ts +++ b/apps/client/src/app/components/rules/rules.component.ts @@ -1,6 +1,8 @@ import { UpdateUserSettingDto } from '@ghostfolio/api/app/user/update-user-setting.dto'; -import { PortfolioReportRule } from '@ghostfolio/common/interfaces'; -import { XRayRulesSettings } from '@ghostfolio/common/types'; +import { + PortfolioReportRule, + XRayRulesSettings +} from '@ghostfolio/common/interfaces'; import { ChangeDetectionStrategy, diff --git a/apps/client/src/app/components/toggle/toggle.component.ts b/apps/client/src/app/components/toggle/toggle.component.ts index ecc21029..4e056f1d 100644 --- a/apps/client/src/app/components/toggle/toggle.component.ts +++ b/apps/client/src/app/components/toggle/toggle.component.ts @@ -1,4 +1,4 @@ -import { ToggleOption } from '@ghostfolio/common/types'; +import { ToggleOption } from '@ghostfolio/common/interfaces'; import { ChangeDetectionStrategy, diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts index 4cd75c7a..6eb42b68 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts @@ -4,13 +4,14 @@ import { ImpersonationStorageService } from '@ghostfolio/client/services/imperso import { UserService } from '@ghostfolio/client/services/user/user.service'; import { HistoricalDataItem, + InvestmentItem, PortfolioInvestments, PortfolioPerformance, PortfolioPosition, + ToggleOption, User } from '@ghostfolio/common/interfaces'; -import { InvestmentItem } from '@ghostfolio/common/interfaces/investment-item.interface'; -import { GroupBy, ToggleOption } from '@ghostfolio/common/types'; +import { GroupBy } from '@ghostfolio/common/types'; import { translate } from '@ghostfolio/ui/i18n'; import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; diff --git a/libs/common/src/lib/interfaces/index.ts b/libs/common/src/lib/interfaces/index.ts index 51bb7c10..0ec04594 100644 --- a/libs/common/src/lib/interfaces/index.ts +++ b/libs/common/src/lib/interfaces/index.ts @@ -50,8 +50,10 @@ import type { Subscription } from './subscription.interface'; import type { SymbolMetrics } from './symbol-metrics.interface'; import type { SystemMessage } from './system-message.interface'; import type { TabConfiguration } from './tab-configuration.interface'; +import type { ToggleOption } from './toggle-option.interface'; import type { UserSettings } from './user-settings.interface'; import type { User } from './user.interface'; +import type { XRayRulesSettings } from './x-ray-rules-settings.interface'; export { Access, @@ -104,6 +106,8 @@ export { Subscription, SymbolMetrics, TabConfiguration, + ToggleOption, User, - UserSettings + UserSettings, + XRayRulesSettings }; diff --git a/libs/common/src/lib/types/toggle-option.type.ts b/libs/common/src/lib/interfaces/toggle-option.interface.ts similarity index 50% rename from libs/common/src/lib/types/toggle-option.type.ts rename to libs/common/src/lib/interfaces/toggle-option.interface.ts index 25ba4d7d..ca7b16bb 100644 --- a/libs/common/src/lib/types/toggle-option.type.ts +++ b/libs/common/src/lib/interfaces/toggle-option.interface.ts @@ -1,4 +1,4 @@ -export type ToggleOption = { +export interface ToggleOption { label: string; value: string; -}; +} diff --git a/libs/common/src/lib/interfaces/user-settings.interface.ts b/libs/common/src/lib/interfaces/user-settings.interface.ts index 106f5460..e9e90e71 100644 --- a/libs/common/src/lib/interfaces/user-settings.interface.ts +++ b/libs/common/src/lib/interfaces/user-settings.interface.ts @@ -1,9 +1,9 @@ +import { XRayRulesSettings } from '@ghostfolio/common/interfaces/x-ray-rules-settings.interface'; import { ColorScheme, DateRange, HoldingsViewMode, - ViewMode, - XRayRulesSettings + ViewMode } from '@ghostfolio/common/types'; export interface UserSettings { diff --git a/libs/common/src/lib/types/x-ray-rules-settings.type.ts b/libs/common/src/lib/interfaces/x-ray-rules-settings.interface.ts similarity index 92% rename from libs/common/src/lib/types/x-ray-rules-settings.type.ts rename to libs/common/src/lib/interfaces/x-ray-rules-settings.interface.ts index 8808162f..f38a8e6a 100644 --- a/libs/common/src/lib/types/x-ray-rules-settings.type.ts +++ b/libs/common/src/lib/interfaces/x-ray-rules-settings.interface.ts @@ -1,4 +1,4 @@ -export type XRayRulesSettings = { +export interface XRayRulesSettings { AccountClusterRiskCurrentInvestment?: RuleSettings; AccountClusterRiskSingleAccount?: RuleSettings; AllocationClusterRiskDevelopedMarkets?: RuleSettings; @@ -7,7 +7,7 @@ export type XRayRulesSettings = { CurrencyClusterRiskCurrentInvestment?: RuleSettings; EmergencyFundSetup?: RuleSettings; FeeRatioInitialInvestment?: RuleSettings; -}; +} interface RuleSettings { isActive: boolean; diff --git a/libs/common/src/lib/types/index.ts b/libs/common/src/lib/types/index.ts index f8307152..a66755ab 100644 --- a/libs/common/src/lib/types/index.ts +++ b/libs/common/src/lib/types/index.ts @@ -16,10 +16,8 @@ import type { Market } from './market.type'; import type { OrderWithAccount } from './order-with-account.type'; import type { RequestWithUser } from './request-with-user.type'; import type { SubscriptionOffer } from './subscription-offer.type'; -import type { ToggleOption } from './toggle-option.type'; import type { UserWithSettings } from './user-with-settings.type'; import type { ViewMode } from './view-mode.type'; -import type { XRayRulesSettings } from './x-ray-rules-settings.type'; export type { AccessType, @@ -40,8 +38,6 @@ export type { OrderWithAccount, RequestWithUser, SubscriptionOffer, - ToggleOption, UserWithSettings, - ViewMode, - XRayRulesSettings + ViewMode };