Skip to content

Commit

Permalink
feat: update linting (#1150)
Browse files Browse the repository at this point in the history
* chore: add linter rule for empty then() blocks and update to eslint 9

* fix: show error on the then() block instead of other parts

* fix: fix import of react recommended lint

* fix: fix package in scripts

* chore: apply new linting rules

* fix: fix lint command

* fix: fix lint command

* fix: fix lints and configs

* fix: fix outdated next version

* chore: use a shared config and add documentation
  • Loading branch information
DasProffi authored Jan 9, 2025
1 parent 02c53e7 commit 59b56df
Show file tree
Hide file tree
Showing 279 changed files with 9,563 additions and 7,252 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ This repository is split up into multiple subprojects using [pnpm](https://pnpm.
- library of helpwave (see [lib](/lib))

## Getting Started
To get started you will have to in install [pnpm](https://pnpm.io). After that you
can use the following commands to start one of our projects.

### Prerequisites
Before you can start you need to have these installed:
- [Node.js](https://nodejs.org/)
- [pnpm](https://pnpm.io/) (installation through npm `npm install -g pnpm`)

### Setup
```shell
pnpm install
cd <project> # e.g. tasks, landing-page
```

### Usage
```shell
cd tasks # or any other page like e.g. landing-page
pnpm run dev
```

Expand All @@ -42,7 +51,7 @@ pnpm run storybook
This project is tested with [BrowserStack](https://www.browserstack.com).

## Linter
Our projects use linting with `eslint` to create a uniform code style. The linter can used with:
Our projects use linting with `eslint` to create a uniform code style. The linter can be used with:

```shell
pnpm run --filter "@helpwave/*" lint
Expand All @@ -52,7 +61,7 @@ pnpm run --filter "@helpwave/*" lint
pnpm run --filter "@helpwave/*" lint --fix
```

It is configured in the [eslint-config](eslint-config/index.js).
It's configuration and further explanation can be found in the [eslint-config](eslint-config/README.md).

## Scripts
The list of all our scripts can be found [here](documentation/scripts.md).
Expand Down
5 changes: 0 additions & 5 deletions api-services/.eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion api-services/authentication/grpc_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Metadata } from 'grpc-web'
import { KeycloakService } from '../util/keycloak'

type AuthenticatedGrpcMetadata = {
Authorization: string
Authorization: string,
}

const defaultOrganization = `3b25c6f5-4705-4074-9fc6-a50c28eba406`
Expand Down
2 changes: 1 addition & 1 deletion api-services/authentication/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const buildAuthorizationUrl = (params: {
codeChallenge: string,
redirectUri: string,
scopes: string[],
state: string
state: string,
}): URL => {
const authorizationUrl = new URL(params.baseUrl)
authorizationUrl.searchParams.set('client_id', params.clientId)
Expand Down
6 changes: 3 additions & 3 deletions api-services/authentication/useAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ type AuthContextValue = {
token?: string,
organization?: {
id: string,
name: string
name: string,
},
organizations: string[],
signOut: () => void,
redirectUserToOrganizationSelection: () => void
redirectUserToOrganizationSelection: () => void,
}

const defaultAuthContextValue: AuthContextValue = {
Expand Down Expand Up @@ -108,7 +108,7 @@ export const useAuth = (): AuthContextValue => {
}
authContext.setUser(user)
})
}, [])
}, []) // eslint-disable-line react-hooks/exhaustive-deps

return authContext
}
Expand Down
18 changes: 9 additions & 9 deletions api-services/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ const getAPIServiceConfig = () => {
// Not using the index notation causes build errors
const maybeConfig = configSchema.safeParse({
NODE_ENV: process.env.NODE_ENV,
NEXT_PUBLIC_API_URL: process.env['NEXT_PUBLIC_API_URL'], // eslint-disable-line dot-notation
NEXT_PUBLIC_OFFLINE_API: process.env['NEXT_PUBLIC_OFFLINE_API'], // eslint-disable-line dot-notation
NEXT_PUBLIC_REQUEST_LOGGING: process.env['NEXT_PUBLIC_REQUEST_LOGGING'], // eslint-disable-line dot-notation
NEXT_PUBLIC_OAUTH_ISSUER_URL: process.env['NEXT_PUBLIC_OAUTH_ISSUER_URL'], // eslint-disable-line dot-notation
NEXT_PUBLIC_OAUTH_REDIRECT_URI: process.env['NEXT_PUBLIC_OAUTH_REDIRECT_URI'], // eslint-disable-line dot-notation
NEXT_PUBLIC_OAUTH_CLIENT_ID: process.env['NEXT_PUBLIC_OAUTH_CLIENT_ID'], // eslint-disable-line dot-notation
NEXT_PUBLIC_OAUTH_SCOPES: process.env['NEXT_PUBLIC_OAUTH_SCOPES'], // eslint-disable-line dot-notation
NEXT_PUBLIC_FAKE_TOKEN_ENABLE: process.env['NEXT_PUBLIC_FAKE_TOKEN_ENABLE'], // eslint-disable-line dot-notation
NEXT_PUBLIC_FAKE_TOKEN: process.env['NEXT_PUBLIC_FAKE_TOKEN'], // eslint-disable-line dot-notation
NEXT_PUBLIC_API_URL: process.env['NEXT_PUBLIC_API_URL'],
NEXT_PUBLIC_OFFLINE_API: process.env['NEXT_PUBLIC_OFFLINE_API'],
NEXT_PUBLIC_REQUEST_LOGGING: process.env['NEXT_PUBLIC_REQUEST_LOGGING'],
NEXT_PUBLIC_OAUTH_ISSUER_URL: process.env['NEXT_PUBLIC_OAUTH_ISSUER_URL'],
NEXT_PUBLIC_OAUTH_REDIRECT_URI: process.env['NEXT_PUBLIC_OAUTH_REDIRECT_URI'],
NEXT_PUBLIC_OAUTH_CLIENT_ID: process.env['NEXT_PUBLIC_OAUTH_CLIENT_ID'],
NEXT_PUBLIC_OAUTH_SCOPES: process.env['NEXT_PUBLIC_OAUTH_SCOPES'],
NEXT_PUBLIC_FAKE_TOKEN_ENABLE: process.env['NEXT_PUBLIC_FAKE_TOKEN_ENABLE'],
NEXT_PUBLIC_FAKE_TOKEN: process.env['NEXT_PUBLIC_FAKE_TOKEN'],
})

if (!maybeConfig.success) {
Expand Down
2 changes: 1 addition & 1 deletion api-services/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ declare namespace NodeJS {
NEXT_PUBLIC_OAUTH_CLIENT_ID?: string,
NEXT_PUBLIC_OAUTH_SCOPES?: string,
NEXT_PUBLIC_FAKE_TOKEN_ENABLE?: string,
NEXT_PUBLIC_FAKE_TOKEN?: string
NEXT_PUBLIC_FAKE_TOKEN?: string,
}
}
3 changes: 3 additions & 0 deletions api-services/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '@helpwave/eslint-config'

export default config.recommended
8 changes: 4 additions & 4 deletions api-services/mutations/properties/property_mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const usePropertyCreateMutation = (callback: (property: Property) => void
return newValue
},
onSuccess: () => {
queryClient.invalidateQueries([QueryKeys.properties]).then()
queryClient.invalidateQueries([QueryKeys.properties]).catch(console.error)
}
})
}
Expand Down Expand Up @@ -187,7 +187,7 @@ export const usePropertyUpdateMutation = (callback: (property: Property) => void
return property
},
onSuccess: () => {
queryClient.invalidateQueries([QueryKeys.properties]).then()
queryClient.invalidateQueries([QueryKeys.properties]).catch(console.error)
}
})
}
Expand All @@ -196,7 +196,7 @@ type ChangeSelectOptions = {
propertyId: string,
add: SelectOption[],
update: SelectOption[],
remove: string[]
remove: string[],
}
export const usePropertyChangeSelectOptionMutation = (callback: () => void = noop) => {
const queryClient = useQueryClient()
Expand Down Expand Up @@ -235,7 +235,7 @@ export const usePropertyChangeSelectOptionMutation = (callback: () => void = noo
callback()
},
onSuccess: () => {
queryClient.invalidateQueries([QueryKeys.properties]).then()
queryClient.invalidateQueries([QueryKeys.properties]).catch(console.error)
}
})
}
10 changes: 5 additions & 5 deletions api-services/mutations/properties/property_value_mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import {
AttachPropertyValueRequest,
GetAttachedPropertyValuesRequest,
TaskPropertyMatcher,
PatientPropertyMatcher, GetAttachedPropertyValuesResponse
GetAttachedPropertyValuesResponse,
PatientPropertyMatcher, TaskPropertyMatcher
} from '@helpwave/proto-ts/services/property_svc/v1/property_value_svc_pb'
import {
Date as ProtoDate
Expand All @@ -13,7 +13,7 @@ import { ArrayUtil } from '@helpwave/common/util/array'
import { APIServices } from '../../services'
import { getAuthenticatedGrpcMetadata } from '../../authentication/grpc_metadata'
import { QueryKeys } from '../query_keys'
import type { SubjectType, FieldType } from '../../types/properties/property'
import type { FieldType, SubjectType } from '../../types/properties/property'
import type { AttachedProperty, DisplayableAttachedProperty } from '../../types/properties/attached_property'
import { GRPCConverter } from '../../util/util'
import type { Update } from '../../types/update'
Expand Down Expand Up @@ -85,7 +85,7 @@ export const usePropertyWithValueListQuery = (subjectId: string | undefined, sub
}

type AttachedPropertyMutationUpdate<T extends AttachedProperty> = Update<T> & {
fieldType: FieldType
fieldType: FieldType,
}

/**
Expand Down Expand Up @@ -160,7 +160,7 @@ export const useAttachPropertyMutation = <T extends AttachedProperty>(callback:
return newProperty
},
onSuccess: (data) => {
queryClient.invalidateQueries([QueryKeys.properties, QueryKeys.attachedProperties, data.subjectId]).then()
queryClient.invalidateQueries([QueryKeys.properties, QueryKeys.attachedProperties, data.subjectId]).catch(console.error)
},
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type PropertyViewRuleFilterUpdate = {
appendToAlwaysInclude?: string[],
removeFromAlwaysInclude?: string[],
appendToDontAlwaysInclude?: string[],
removeFromDontAlwaysInclude?: string[]
removeFromDontAlwaysInclude?: string[],
}

export const useUpdatePropertyViewRuleRequest = (subjectType: SubjectType, wardId?: string) => {
Expand Down Expand Up @@ -50,7 +50,7 @@ export const useUpdatePropertyViewRuleRequest = (subjectType: SubjectType, wardI
await APIServices.propertyViewSource.updatePropertyViewRule(req, getAuthenticatedGrpcMetadata())
},
onSuccess: () => {
queryClient.invalidateQueries([QueryKeys.properties]).then()
queryClient.invalidateQueries([QueryKeys.properties]).catch(console.error)
}
})
}
16 changes: 8 additions & 8 deletions api-services/mutations/tasks/bed_mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ export const useBedCreateMutation = () => {
return { id: res.getId(), name: bed.name }
},
onSuccess: () => {
queryClient.refetchQueries([QueryKeys.beds]).then()
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).then()
queryClient.refetchQueries([QueryKeys.wards]).then()
queryClient.refetchQueries([QueryKeys.beds]).catch(console.error)
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).catch(console.error)
queryClient.refetchQueries([QueryKeys.wards]).catch(console.error)
},
})
}
Expand All @@ -76,8 +76,8 @@ export const useBedUpdateMutation = () => {
return obj
},
onSuccess: () => {
queryClient.refetchQueries([APIServices.bed]).then()
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).then()
queryClient.refetchQueries([APIServices.bed]).catch(console.error)
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).catch(console.error)
},
})
}
Expand All @@ -100,9 +100,9 @@ export const useBedDeleteMutation = () => {
return obj
},
onSuccess: () => {
queryClient.refetchQueries([APIServices.bed]).then()
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).then()
queryClient.refetchQueries([QueryKeys.wards]).then()
queryClient.refetchQueries([APIServices.bed]).catch(console.error)
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).catch(console.error)
queryClient.refetchQueries([QueryKeys.wards]).catch(console.error)
},
})
}
28 changes: 14 additions & 14 deletions api-services/mutations/tasks/patient_mutations.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import {
AssignBedRequest,
CreatePatientRequest,
DischargePatientRequest,
UpdatePatientRequest,
AssignBedRequest,
UnassignBedRequest,
ReadmitPatientRequest,
GetRecentPatientsRequest,
GetPatientAssignmentByWardRequest,
GetPatientDetailsRequest,
GetPatientListRequest,
GetPatientsByWardRequest,
GetPatientAssignmentByWardRequest,
GetPatientListRequest
GetRecentPatientsRequest,
ReadmitPatientRequest,
UnassignBedRequest,
UpdatePatientRequest
} from '@helpwave/proto-ts/services/tasks_svc/v1/patient_svc_pb'
import { noop } from '@helpwave/common/util/noop'
import { APIServices } from '../../services'
import { getAuthenticatedGrpcMetadata } from '../../authentication/grpc_metadata'
import type {
PatientDetailsDTO, PatientDTO,
PatientDTO, PatientDetailsDTO,
PatientListDTO,
PatientMinimalDTO,
PatientWithBedIdDTO,
Expand Down Expand Up @@ -273,8 +273,8 @@ export const useAssignBedMutation = (callback: (bed: BedWithPatientId) => void =
return bed
},
onSuccess: () => {
queryClient.refetchQueries([QueryKeys.rooms]).then()
queryClient.refetchQueries([QueryKeys.patients]).then()
queryClient.refetchQueries([QueryKeys.rooms]).catch(console.error)
queryClient.refetchQueries([QueryKeys.patients]).catch(console.error)
}
})
}
Expand All @@ -296,8 +296,8 @@ export const useUnassignMutation = (callback: () => void = noop) => {
return res.toObject()
},
onSuccess: () => {
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).then()
queryClient.refetchQueries([QueryKeys.patients]).then()
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).catch(console.error)
queryClient.refetchQueries([QueryKeys.patients]).catch(console.error)
}
})
}
Expand Down Expand Up @@ -358,8 +358,8 @@ export const useReadmitPatientMutation = (callback: (patientId: string) => void
return res.toObject()
},
onSuccess: () => {
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).then()
queryClient.refetchQueries([QueryKeys.patients]).then()
queryClient.refetchQueries([QueryKeys.rooms, roomOverviewsQueryKey]).catch(console.error)
queryClient.refetchQueries([QueryKeys.patients]).catch(console.error)
}
})
}
10 changes: 5 additions & 5 deletions api-services/mutations/tasks/room_mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const useRoomUpdateMutation = (callback: (room: RoomMinimalDTO) => void)
return room
},
onSuccess: () => {
queryClient.invalidateQueries([QueryKeys.rooms]).then()
queryClient.invalidateQueries([QueryKeys.rooms]).catch(console.error)
},
})
}
Expand All @@ -113,8 +113,8 @@ export const useRoomCreateMutation = (callback: (room: RoomMinimalDTO) => void =
return room
},
onSuccess: () => {
queryClient.refetchQueries([QueryKeys.rooms]).then()
queryClient.refetchQueries([QueryKeys.wards]).then()
queryClient.refetchQueries([QueryKeys.rooms]).catch(console.error)
queryClient.refetchQueries([QueryKeys.wards]).catch(console.error)
}
})
}
Expand All @@ -135,8 +135,8 @@ export const useRoomDeleteMutation = (callback: () => void = noop) => {
return req.toObject()
},
onSuccess: () => {
queryClient.refetchQueries([QueryKeys.rooms]).then()
queryClient.refetchQueries([QueryKeys.wards]).then()
queryClient.refetchQueries([QueryKeys.rooms]).catch(console.error)
queryClient.refetchQueries([QueryKeys.wards]).catch(console.error)
}
})
}
Loading

0 comments on commit 59b56df

Please sign in to comment.