Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/enable @typescript-eslint/prefer-nullish-coalescing rule in libs/ui and apps/client (#7317)

Kenrick Tandrian45ef139cf849
diff --git a/apps/client/eslint.config.cjs b/apps/client/eslint.config.cjs
index 96ecefd504..bcbe2c1c13 100644
--- a/apps/client/eslint.config.cjs
+++ b/apps/client/eslint.config.cjs
@@ -47,7 +47,9 @@ module.exports = [
{
files: ['**/*.ts', '**/*.tsx'],
// Override or add rules here
- rules: {}
+ rules: {
+ '@typescript-eslint/prefer-nullish-coalescing': 'error'
+ }
},
{
files: ['**/*.js', '**/*.jsx'],
diff --git a/apps/client/jest.config.ts b/apps/client/jest.config.ts
index 04378bdbd7..26d772e11f 100644
--- a/apps/client/jest.config.ts
+++ b/apps/client/jest.config.ts
@@ -1,4 +1,3 @@
-/* eslint-disable */
export default {
displayName: 'client',
diff --git a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
index 967a289ef0..c34e8eb78c 100644
--- a/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
+++ b/apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
@@ -550,7 +550,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
) as Record<string, string>,
locale:
this.assetProfileForm.controls.scraperConfiguration.controls.locale
- ?.value || undefined,
+ ?.value ?? undefined,
mode:
this.assetProfileForm.controls.scraperConfiguration.controls.mode
?.value ?? undefined,
@@ -599,7 +599,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
assetClass: this.assetProfileForm.controls.assetClass.value ?? undefined,
assetSubClass:
this.assetProfileForm.controls.assetSubClass.value ?? undefined,
- comment: this.assetProfileForm.controls.comment.value || undefined,
+ comment: this.assetProfileForm.controls.comment.value ?? undefined,
currency: this.assetProfileForm.controls.currency.value ?? undefined,
dataGatheringFrequency:
this.assetProfileForm.controls.dataGatheringFrequency.value ??
@@ -607,8 +607,8 @@ export class GfAssetProfileDialogComponent implements OnInit {
isActive: isBoolean(this.assetProfileForm.controls.isActive.value)
? this.assetProfileForm.controls.isActive.value
: undefined,
- name: this.assetProfileForm.controls.name.value || undefined,
- url: this.assetProfileForm.controls.url.value || undefined
+ name: this.assetProfileForm.controls.name.value ?? undefined,
+ url: this.assetProfileForm.controls.url.value ?? undefined
};
try {
@@ -743,7 +743,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
) as Record<string, string>,
locale:
this.assetProfileForm.controls.scraperConfiguration.controls.locale
- ?.value || undefined,
+ ?.value ?? undefined,
mode: this.assetProfileForm.controls.scraperConfiguration.controls
.mode?.value,
selector:
diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
index ca88120cac..d27b5ceae7 100644
--- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
+++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
@@ -200,12 +200,12 @@ export class GfCreateOrUpdateAccountDialogComponent {
protected async onSubmit() {
const account: CreateAccountDto | UpdateAccountDto = {
balance: this.accountForm.get('balance')?.value,
- comment: this.accountForm.get('comment')?.value || null,
+ comment: this.accountForm.get('comment')?.value ?? null,
currency: this.accountForm.get('currency')?.value,
id: this.accountForm.get('accountId')?.value,
isExcluded: this.accountForm.get('isExcluded')?.value,
name: this.accountForm.get('name')?.value,
- platformId: this.accountForm.get('platformId')?.value?.id || null,
+ platformId: this.accountForm.get('platformId')?.value?.id ?? null,
tags: this.accountForm
.get('tags')
?.value?.filter(({ id }: Tag) => {
diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
index be9ac7b048..10bc7ccc83 100644
--- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
+++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
@@ -493,7 +493,7 @@ export class GfCreateOrUpdateActivityDialogComponent {
accountId: this.activityForm.get('accountId')?.value,
assetClass: this.activityForm.get('assetClass')?.value,
assetSubClass: this.activityForm.get('assetSubClass')?.value,
- comment: this.activityForm.get('comment')?.value || null,
+ comment: this.activityForm.get('comment')?.value ?? null,
currency: this.activityForm.get('currency')?.value,
customCurrency: this.activityForm.get('currencyOfUnitPrice')?.value,
dataSource: ['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(
diff --git a/apps/client/src/app/services/user/user.service.ts b/apps/client/src/app/services/user/user.service.ts
index 52f33dc5ac..d58f77c3e3 100644
--- a/apps/client/src/app/services/user/user.service.ts
+++ b/apps/client/src/app/services/user/user.service.ts
@@ -192,6 +192,6 @@ export class UserService extends ObservableStore<UserStoreState> {
return throwError(errMessage);
}
- return throwError(error || 'Server error');
+ return throwError(error ?? 'Server error');
}
}
diff --git a/libs/ui/eslint.config.cjs b/libs/ui/eslint.config.cjs
index e21452b5f0..65d17debdc 100644
--- a/libs/ui/eslint.config.cjs
+++ b/libs/ui/eslint.config.cjs
@@ -41,7 +41,8 @@ module.exports = [
}
],
'@angular-eslint/prefer-inject': 'off',
- '@angular-eslint/prefer-standalone': 'off'
+ '@angular-eslint/prefer-standalone': 'off',
+ '@typescript-eslint/prefer-nullish-coalescing': 'error'
},
languageOptions: {
parserOptions: {
diff --git a/libs/ui/src/lib/activities-table/activities-table.component.ts b/libs/ui/src/lib/activities-table/activities-table.component.ts
index b1bfcf686e..fba02ad30d 100644
--- a/libs/ui/src/lib/activities-table/activities-table.component.ts
+++ b/libs/ui/src/lib/activities-table/activities-table.component.ts
@@ -267,7 +267,7 @@ export class GfActivitiesTableComponent implements AfterViewInit, OnInit {
public isExcludedFromAnalysis(activity: Activity) {
return (
- (activity.account && isAccountExcluded(activity.account)) ||
+ (activity.account && isAccountExcluded(activity.account)) ??
activity.tags?.some(({ id }) => {
return id === TAG_ID_EXCLUDE_FROM_ANALYSIS;
}) === true