Skip to content

Commit

Permalink
fix: Lint Promises in conditions
Browse files Browse the repository at this point in the history
Checking for a Promise instead of the awaited value is wrong.
  • Loading branch information
Dschoordsch committed Jan 21, 2025
1 parent 4b973a8 commit 409cd35
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default tseslint.config(
'no-extra-boolean-cast': 'off',
'no-case-declarations': 'off',
'no-useless-escape': 'off',
'no-constant-binary-expression': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-empty-interface': 'off',
Expand Down Expand Up @@ -50,7 +49,7 @@ export default tseslint.config(
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-misused-promises': ['error', {checksVoidReturn: false}],
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/server/dataloader/customLoaderMakers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ export const publicTemplatesByType = (parent: RootDataLoader) => {
if (cachedTemplatesStr) {
const cachedTemplates = JSON.parse(cachedTemplatesStr) as MeetingTemplate[]
cachedTemplates.forEach(
(meetingTemplate) => meetingTemplate.createdAt === new Date(meetingTemplate.createdAt)
(meetingTemplate) => meetingTemplate.createdAt = new Date(meetingTemplate.createdAt)
)
return cachedTemplates
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const addIntegrationProvider = {
if (scope === 'global') {
return {error: {message: 'Must be a super user to add a global provider'}}
}
if (scope === 'org' && !isUserOrgAdmin(viewerId, orgId!, dataLoader)) {
if (scope === 'org' && !(await isUserOrgAdmin(viewerId, orgId!, dataLoader))) {
return {
error: {
message:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ const removeIntegrationProvider = {
if (scope === 'global') {
return {error: {message: 'Must be a super user to remove a global provider'}}
}
if (scope === 'org' && !isUserOrgAdmin(viewerId, orgId!, dataLoader)) {
if (scope === 'org' && !(await isUserOrgAdmin(viewerId, orgId!, dataLoader))) {
return {error: {message: 'Must be a member of the organization that created the provider'}}
}
if (scope === 'team' && !isTeamMember(authToken, teamId!)) {
const team = await dataLoader.get('teams').load(teamId!)
if (!team || !isUserOrgAdmin(viewerId, team.orgId, dataLoader)) {
if (!team || !(await isUserOrgAdmin(viewerId, team.orgId, dataLoader))) {
return {error: {message: 'Must be on the team that created the provider'}}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/server/graphql/public/mutations/updateAutoJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const updateAutoJoin: MutationResolvers['updateAutoJoin'] = async (
if (!isSuperUser(authToken)) {
const viewerTeams = (await dataLoader.get('teams').loadMany(teamIds)).filter(isValid)
const isNotBillingLeader = viewerTeams.some(
({orgId}) => !isUserBillingLeader(viewerId, orgId, dataLoader)
({orgId}) => !(await isUserBillingLeader(viewerId, orgId, dataLoader))
)
if (isNotBillingLeader) {
return standardError(new Error('Viewer is not billing leader'), {userId: viewerId})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const updateIntegrationProvider: MutationResolvers['updateIntegrationProvider']
return {error: {message: 'Must be a super user to add a global provider'}}
}
if (
(oldScope === 'org' && !isUserOrgAdmin(viewerId, oldOrgId!, dataLoader)) ||
(newScope === 'org' && !isUserOrgAdmin(viewerId, newOrgId!, dataLoader))
(oldScope === 'org' && !(await isUserOrgAdmin(viewerId, oldOrgId!, dataLoader))) ||
(newScope === 'org' && !(await isUserOrgAdmin(viewerId, newOrgId!, dataLoader)))
) {
return {
error: {
Expand All @@ -73,10 +73,10 @@ const updateIntegrationProvider: MutationResolvers['updateIntegrationProvider']
if (
(oldScope === 'team' &&
!isTeamMember(authToken, oldTeamId!) &&
!isUserOrgAdmin(viewerId, oldTeam!.orgId, dataLoader)) ||
!(await isUserOrgAdmin(viewerId, oldTeam!.orgId, dataLoader))) ||
(newScope === 'team' &&
!isTeamMember(authToken, newTeamId!) &&
!isUserOrgAdmin(viewerId, newTeam!.orgId, dataLoader))
!(await isUserOrgAdmin(viewerId, newTeam!.orgId, dataLoader)))
) {
return {error: {message: 'Must be on the team for the integration provider'}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const OrgIntegrationProviders: OrgIntegrationProvidersResolvers = {

gitlab: async ({orgId}, _args, {authToken, dataLoader}) => {
const viewerId = getUserId(authToken)
if (!isUserInOrg(viewerId, orgId, dataLoader)) return []
if (!(await isUserInOrg(viewerId, orgId, dataLoader))) return []
const providers = await dataLoader
.get('sharedIntegrationProviders')
.load({service: 'gitlab', orgIds: [orgId], teamIds: []})
Expand Down

0 comments on commit 409cd35

Please sign in to comment.