Browse Source

feat(client): implement prefer-nullish-coalescing eslint check

pull/7317/head
KenTandrian 2 days ago
parent
commit
d4507de9c0
  1. 4
      apps/client/eslint.config.cjs
  2. 2
      apps/client/jest.config.ts
  3. 10
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  4. 4
      apps/client/src/app/components/home-holdings/home-holdings.component.ts
  5. 4
      apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
  6. 2
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
  7. 2
      apps/client/src/app/services/user/user.service.ts

4
apps/client/eslint.config.cjs

@ -47,7 +47,9 @@ module.exports = [
{ {
files: ['**/*.ts', '**/*.tsx'], files: ['**/*.ts', '**/*.tsx'],
// Override or add rules here // Override or add rules here
rules: {} rules: {
'@typescript-eslint/prefer-nullish-coalescing': 'error'
}
}, },
{ {
files: ['**/*.js', '**/*.jsx'], files: ['**/*.js', '**/*.jsx'],

2
apps/client/jest.config.ts

@ -1,4 +1,4 @@
/* eslint-disable */
export default { export default {
displayName: 'client', displayName: 'client',

10
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>, ) as Record<string, string>,
locale: locale:
this.assetProfileForm.controls.scraperConfiguration.controls.locale this.assetProfileForm.controls.scraperConfiguration.controls.locale
?.value || undefined, ?.value ?? undefined,
mode: mode:
this.assetProfileForm.controls.scraperConfiguration.controls.mode this.assetProfileForm.controls.scraperConfiguration.controls.mode
?.value ?? undefined, ?.value ?? undefined,
@ -599,7 +599,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
assetClass: this.assetProfileForm.controls.assetClass.value ?? undefined, assetClass: this.assetProfileForm.controls.assetClass.value ?? undefined,
assetSubClass: assetSubClass:
this.assetProfileForm.controls.assetSubClass.value ?? undefined, 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, currency: this.assetProfileForm.controls.currency.value ?? undefined,
dataGatheringFrequency: dataGatheringFrequency:
this.assetProfileForm.controls.dataGatheringFrequency.value ?? this.assetProfileForm.controls.dataGatheringFrequency.value ??
@ -607,8 +607,8 @@ export class GfAssetProfileDialogComponent implements OnInit {
isActive: isBoolean(this.assetProfileForm.controls.isActive.value) isActive: isBoolean(this.assetProfileForm.controls.isActive.value)
? this.assetProfileForm.controls.isActive.value ? this.assetProfileForm.controls.isActive.value
: undefined, : undefined,
name: this.assetProfileForm.controls.name.value || undefined, name: this.assetProfileForm.controls.name.value ?? undefined,
url: this.assetProfileForm.controls.url.value || undefined url: this.assetProfileForm.controls.url.value ?? undefined
}; };
try { try {
@ -743,7 +743,7 @@ export class GfAssetProfileDialogComponent implements OnInit {
) as Record<string, string>, ) as Record<string, string>,
locale: locale:
this.assetProfileForm.controls.scraperConfiguration.controls.locale this.assetProfileForm.controls.scraperConfiguration.controls.locale
?.value || undefined, ?.value ?? undefined,
mode: this.assetProfileForm.controls.scraperConfiguration.controls mode: this.assetProfileForm.controls.scraperConfiguration.controls
.mode?.value, .mode?.value,
selector: selector:

4
apps/client/src/app/components/home-holdings/home-holdings.component.ts

@ -181,8 +181,8 @@ export class GfHomeHoldingsComponent implements OnInit {
this.viewModeFormControl.setValue( this.viewModeFormControl.setValue(
this.deviceType === 'mobile' this.deviceType === 'mobile'
? GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE ? GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE
: this.user?.settings?.holdingsViewMode || : (this.user?.settings?.holdingsViewMode ??
GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE, GfHomeHoldingsComponent.DEFAULT_HOLDINGS_VIEW_MODE),
{ emitEvent: false } { emitEvent: false }
); );
} else if (this.holdingType === 'CLOSED') { } else if (this.holdingType === 'CLOSED') {

4
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() { protected async onSubmit() {
const account: CreateAccountDto | UpdateAccountDto = { const account: CreateAccountDto | UpdateAccountDto = {
balance: this.accountForm.get('balance')?.value, 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, currency: this.accountForm.get('currency')?.value,
id: this.accountForm.get('accountId')?.value, id: this.accountForm.get('accountId')?.value,
isExcluded: this.accountForm.get('isExcluded')?.value, isExcluded: this.accountForm.get('isExcluded')?.value,
name: this.accountForm.get('name')?.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 tags: this.accountForm
.get('tags') .get('tags')
?.value?.filter(({ id }: Tag) => { ?.value?.filter(({ id }: Tag) => {

2
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, accountId: this.activityForm.get('accountId')?.value,
assetClass: this.activityForm.get('assetClass')?.value, assetClass: this.activityForm.get('assetClass')?.value,
assetSubClass: this.activityForm.get('assetSubClass')?.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, currency: this.activityForm.get('currency')?.value,
customCurrency: this.activityForm.get('currencyOfUnitPrice')?.value, customCurrency: this.activityForm.get('currencyOfUnitPrice')?.value,
dataSource: ['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes( dataSource: ['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(

2
apps/client/src/app/services/user/user.service.ts

@ -192,6 +192,6 @@ export class UserService extends ObservableStore<UserStoreState> {
return throwError(errMessage); return throwError(errMessage);
} }
return throwError(error || 'Server error'); return throwError(error ?? 'Server error');
} }
} }

Loading…
Cancel
Save