weareinreach / InReach

Detected the use of variables before they are defined JS-0357
Anti-pattern
Major
5 occurrences in this check
'mockData' was used before it was defined
  4
  5export const mockOrgNameSearch = (input: SearchInput): ApiOutput['organization']['searchName'] => {
  6	const searchRegex = new RegExp(`.*${input.search}.*`, 'i')
  7	const results = mockData.filter(({ name }) => searchRegex.test(name))  8	return results
  9}
 10
'locationSearchMockData' was used before it was defined
  4	input: ApiInput['geo']['autocomplete']
  5): ApiOutput['geo']['autocomplete'] => {
  6	const searchRegex = new RegExp(`.*${input.search}.*`, 'i')
  7	const results = locationSearchMockData.names  8		.filter(({ searchValue }) => searchRegex.test(searchValue))
  9		.map(({ searchValue, ...data }) => ({ ...data }))
 10
'locationSearchMockData' was used before it was defined
 13
 14export const mockGeocode = (input: ApiInput['geo']['geoByPlaceId']): ApiOutput['geo']['geoByPlaceId'] => {
 15	// const searchRegex = new RegExp(`.*${input.search}.*`, 'i')
 16	const results = locationSearchMockData.locations 17		.filter(({ placeId }) => placeId === input)
 18		.map(({ geometry, ...data }) => ({ geometry, ...data }))
 19	const result = results[0]
'userListSelect' was used before it was defined
228			reviews: reviewIds,
229			phones: orgPhoneInclude,
230			emails: orgEmailInclude,
231			userLists: userListSelect(ctx),232			id: true,
233		},
234	} satisfies Prisma.Organization$servicesArgs)
'reject' was used before it was defined
 5
 6export const isAuthed = t.middleware(({ ctx, meta, next }) => {
 7	if (!ctx.session || !ctx.session.user || !checkPermissions(meta, ctx)) {
 8		return reject() 9	}
10	return next({
11		ctx: {