Browse Source

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

* feat(ui): implement prefer-nullish-coalescing eslint check

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

* fix(client): remove whitespace
pull/6947/merge
Kenrick Tandrian 9 hours ago
committed by GitHub
parent
commit
45ef139cf8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      apps/client/eslint.config.cjs
  2. 1
      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/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
  5. 2
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
  6. 2
      apps/client/src/app/services/user/user.service.ts
  7. 3
      libs/ui/eslint.config.cjs
  8. 2
      libs/ui/src/lib/activities-table/activities-table.component.ts

4
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'],

1
apps/client/jest.config.ts

@ -1,4 +1,3 @@
/* eslint-disable */
export default {
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>,
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:

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() {
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) => {

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,
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(

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(error || 'Server error');
return throwError(error ?? 'Server error');
}
}

3
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: {

2
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

Loading…
Cancel
Save