lint fixes

This commit is contained in:
Ulf Gebhardt 2026-02-23 10:32:33 +01:00
parent 9a2ff64232
commit fc708d2ae4
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
9 changed files with 22 additions and 24 deletions

View File

@ -1235,7 +1235,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
// Jenny users
for (let i = 0; i < 30; i++) {
await Factory.build('user', { name: `Jenny${i}` })
await Factory.build('user', { name: `Jenny${String(i)}` })
}
// Jenny posts

View File

@ -18,7 +18,7 @@ import { createOrUpdateLocations } from './users/location'
import type { Context } from '@src/context'
const removeUserFromGroupWriteTxResultPromise = async (session, groupId, userId) => {
const removeUserFromGroupWriteTxResultPromise = (session, groupId, userId) => {
return session.writeTransaction(async (transaction) => {
const removeUserFromGroupCypher = `
MATCH (user:User {id: $userId})-[membership:MEMBER_OF]->(group:Group {id: $groupId})

View File

@ -21,7 +21,7 @@ export default {
notifications: async (_parent, args, context, _resolveInfo) => {
const { user: currentUser } = context
const session = context.driver.session()
let whereClause, orderByClause
let whereClause: string, orderByClause: string
switch (args.read) {
case true:

View File

@ -45,7 +45,7 @@ export default {
reports: async (_parent, params, context, _resolveInfo) => {
const { driver } = context
const session = driver.session()
let orderByClause
let orderByClause: string
const filterClauses: string[] = []
switch (params.orderBy) {
case 'createdAt_asc':

View File

@ -11,7 +11,7 @@ import { ROOM_COUNT_UPDATED } from '@constants/subscriptions'
import Resolver from './helpers/Resolver'
export const getUnreadRoomsCount = async (userId, session) => {
export const getUnreadRoomsCount = (userId, session) => {
return session.readTransaction(async (transaction) => {
const unreadRoomsCypher = `
MATCH (user:User { id: $userId })-[:CHATS_IN]->(room:Room)<-[:INSIDE]-(message:Message)<-[:CREATED]-(sender:User)

View File

@ -107,8 +107,8 @@ const countGroupsSetup = {
...countSetup,
}
const searchResultPromise = async (session, setup, params) => {
return session.readTransaction(async (transaction) => {
const searchResultPromise = (session, setup, params) => {
return session.readTransaction((transaction) => {
return transaction.run(cypherTemplate(setup), params)
})
}

View File

@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
export function normalizeWhitespace(str) {
export function normalizeWhitespace(str: string) {
// delete the first character if it is !, @ or #
return str
.replace(/^([!@#])/, '')
@ -12,32 +12,32 @@ export function normalizeWhitespace(str) {
.trim()
}
export function escapeSpecialCharacters(str) {
export function escapeSpecialCharacters(str: string) {
return str.replace(/(["[\]&|\\{}+!()^~*?:/-])/g, '\\$1')
}
const matchWholeText = (str, boost = 8) => {
return `"${String(str)}"^${String(boost)}`
const matchWholeText = (str: string, boost = 8) => {
return `"${str}"^${String(boost)}`
}
const matchEachWordExactly = (str, boost = 4) => {
const matchEachWordExactly = (str: string, boost = 4) => {
if (!str.includes(' ')) return ''
const tmp = str
.split(' ')
.map((s, i) => (i === 0 ? `"${String(s)}"` : `AND "${String(s)}"`))
.map((s, i) => (i === 0 ? `"${s}"` : `AND "${s}"`))
.join(' ')
return `(${tmp})^${String(boost)}`
}
const matchSomeWordsExactly = (str, boost = 2) => {
const matchSomeWordsExactly = (str: string, boost = 2) => {
if (!str.includes(' ')) return ''
return str
.split(' ')
.map((s) => `"${String(s)}"^${String(boost)}`)
.map((s) => `"${s}"^${String(boost)}`)
.join(' ')
}
const matchBeginningOfWords = (str) => {
const matchBeginningOfWords = (str: string) => {
return str
.split(' ')
.filter((s) => s.length >= 2)
@ -45,7 +45,7 @@ const matchBeginningOfWords = (str) => {
.join(' ')
}
export function queryString(str) {
export function queryString(str: string) {
const normalizedString = normalizeWhitespace(str)
const escapedString = escapeSpecialCharacters(normalizedString)
return `

View File

@ -76,10 +76,8 @@ export const createOrUpdateLocations = async (
if (locationName !== null) {
const response: any = await fetch(
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(
String(locationName),
)}.json?access_token=${String(
context.config.MAPBOX_TOKEN,
)}&types=region,place,country,address&language=${locales.join(',')}`,
locationName,
)}.json?access_token=${context.config.MAPBOX_TOKEN}&types=region,place,country,address&language=${locales.join(',')}`,
{
signal: AbortSignal.timeout(REQUEST_TIMEOUT),
},
@ -161,7 +159,7 @@ export const createOrUpdateLocations = async (
export const queryLocations = async ({ place, lang }, context: Context) => {
const res: any = await fetch(
`https://api.mapbox.com/geocoding/v5/mapbox.places/${String(place)}.json?access_token=${String(context.config.MAPBOX_TOKEN)}&types=region,place,country&language=${String(lang)}`,
`https://api.mapbox.com/geocoding/v5/mapbox.places/${place}.json?access_token=${context.config.MAPBOX_TOKEN}&types=region,place,country&language=${lang}`,
{
signal: AbortSignal.timeout(REQUEST_TIMEOUT),
},

View File

@ -210,7 +210,7 @@ const notifyMemberOfGroup = async (groupId, userId, reason, context) => {
const notifyUsersOfMention = async (label, id, idsOfUsers, reason, context) => {
if (!idsOfUsers?.length) return []
await validateNotifyUsers(label, reason)
validateNotifyUsers(label, reason)
let mentionedCypher
switch (reason) {
case 'mentioned_in_post': {
@ -277,7 +277,7 @@ const notifyUsersOfMention = async (label, id, idsOfUsers, reason, context) => {
}
const notifyUsersOfComment = async (label, commentId, reason, context) => {
await validateNotifyUsers(label, reason)
validateNotifyUsers(label, reason)
const session = context.driver.session()
try {
return await session.writeTransaction(async (transaction) => {