Skip to content

Commit

Permalink
Tag all TypeScript issues as FIXMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed Sep 19, 2023
1 parent 31eaaee commit 4488721
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 76 deletions.
4 changes: 2 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export default defineConfig({
},
GetFromMemories (property: string) {
for (const memory of config.get<Memory[]>('memories')) {
// @ts-expect-error any type issue
// @ts-expect-error FIXME any type issue
if (memory[property]) {
// @ts-expect-error any type issue
// @ts-expect-error FIXME any type issue
return memory[property]
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MIT
*/

// @ts-expect-error due to non-existing type definitions for MarsDB
// @ts-expect-error FIXME due to non-existing type definitions for MarsDB
import MarsDB = require('marsdb')

const reviews = new MarsDB.Collection('posts')
Expand Down
2 changes: 1 addition & 1 deletion lib/antiCheat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const totalCheatScore = () => {
}

function areCoupled (challenge: Challenge, previousChallenge: Challenge) {
// @ts-expect-error any type issues
// @ts-expect-error FIXME any type issues
return coupledChallenges[challenge.key]?.indexOf(previousChallenge.key) > -1 || coupledChallenges[previousChallenge.key]?.indexOf(challenge.key) > -1
}

Expand Down
4 changes: 2 additions & 2 deletions lib/challengeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const sendNotification = function (challenge: { difficulty?: number, key:
notifications.push(notification)

if (global.io && (isRestore || !wasPreviouslyShown)) {
// @ts-expect-error global type safety issues
// @ts-expect-error FIXME global type safety issues
global.io.emit('challenge solved', notification)
}
}
Expand All @@ -64,7 +64,7 @@ export const sendCodingChallengeNotification = function (challenge: { key: strin
codingChallengeStatus: challenge.codingChallengeStatus
}
if (global.io) {
// @ts-expect-error global type safety issues
// @ts-expect-error FIXME global type safety issues
global.io.emit('code challenge solved', notification)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/insecurity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as utils from './utils'

/* jslint node: true */
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-expect-error no typescript definitions for z85 :(
// @ts-expect-error FIXME no typescript definitions for z85 :(
import * as z85 from 'z85'

export const publicKey = fs ? fs.readFileSync('encryptionkeys/jwt.pub', 'utf8') : 'placeholder-public-key'
Expand Down
2 changes: 1 addition & 1 deletion lib/startup/registerWebsocketEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let firstConnectedSocket: any = null

const registerWebsocketEvents = (server: any) => {
const io = new Server(server, { cors: { origin: 'http:https://localhost:4200' } })
// @ts-expect-error issue with global type safety
// @ts-expect-error FIXME issue with global type safety
global.io = io

io.on('connection', (socket: any) => {
Expand Down
14 changes: 7 additions & 7 deletions lib/startup/validateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const checkMinimumRequiredNumberOfProducts = (products: Product[]) => {
const checkUnambiguousMandatorySpecialProducts = (products: Product[]) => {
let success = true
specialProducts.forEach(({ name, key }) => {
// @ts-expect-error Ignoring any type issue on purpose
// @ts-expect-error FIXME Ignoring any type issue on purpose
const matchingProducts = products.filter((product) => product[key])
if (matchingProducts.length === 0) {
logger.warn(`No product is configured as ${colors.italic(name)} but one is required (${colors.red('NOT OK')})`)
Expand All @@ -89,9 +89,9 @@ const checkUnambiguousMandatorySpecialProducts = (products: Product[]) => {
const checkNecessaryExtraKeysOnSpecialProducts = (products: Product[]) => {
let success = true
specialProducts.forEach(({ name, key, extra = {} }) => {
// @ts-expect-error implicit any type issue
// @ts-expect-error FIXME implicit any type issue
const matchingProducts = products.filter((product) => product[key])
// @ts-expect-error implicit any type issue
// @ts-expect-error FIXME implicit any type issue
if (extra.key && matchingProducts.length === 1 && !matchingProducts[0][extra.key]) {
logger.warn(`Product ${colors.italic(matchingProducts[0].name)} configured as ${colors.italic(name)} does't contain necessary ${colors.italic(`${extra.name}`)} (${colors.red('NOT OK')})`)
success = false
Expand All @@ -103,7 +103,7 @@ const checkNecessaryExtraKeysOnSpecialProducts = (products: Product[]) => {
const checkUniqueSpecialOnProducts = (products: Product[]) => {
let success = true
products.forEach((product) => {
// @ts-expect-error any type issue
// @ts-expect-error FIXME any type issue
const appliedSpecials = specialProducts.filter(({ key }) => product[key])
if (appliedSpecials.length > 1) {
logger.warn(`Product ${colors.italic(product.name)} is used as ${appliedSpecials.map(({ name }) => `${colors.italic(name)}`).join(' and ')} but can only be used for one challenge (${colors.red('NOT OK')})`)
Expand All @@ -125,7 +125,7 @@ const checkMinimumRequiredNumberOfMemories = (memories: Memory[]) => {
const checkUnambiguousMandatorySpecialMemories = (memories: Memory[]) => {
let success = true
specialMemories.forEach(({ name, keys }) => {
// @ts-expect-error any type issue
// @ts-expect-error FIXME any type issue
const matchingMemories = memories.filter((memory) => memory[keys[0]] && memory[keys[1]])
if (matchingMemories.length === 0) {
logger.warn(`No memory is configured as ${colors.italic(name)} but one is required (${colors.red('NOT OK')})`)
Expand All @@ -141,7 +141,7 @@ const checkUnambiguousMandatorySpecialMemories = (memories: Memory[]) => {
const checkSpecialMemoriesHaveNoUserAssociated = (memories: Memory[]) => {
let success = true
specialMemories.forEach(({ name, user, keys }) => {
// @ts-expect-error any type issue
// @ts-expect-error FIXME any type issue
const matchingMemories = memories.filter((memory) => memory[keys[0]] && memory[keys[1]] && memory.user && memory.user !== user)
if (matchingMemories.length > 0) {
logger.warn(`Memory configured as ${colors.italic(name)} must belong to user ${colors.italic(user)} but was linked to ${colors.italic(matchingMemories[0].user)} user (${colors.red('NOT OK')})`)
Expand All @@ -154,7 +154,7 @@ const checkSpecialMemoriesHaveNoUserAssociated = (memories: Memory[]) => {
const checkUniqueSpecialOnMemories = (memories: Memory[]) => {
let success = true
memories.forEach((memory) => {
// @ts-expect-error any type issue
// @ts-expect-error FIXME any type issue
const appliedSpecials = specialMemories.filter(({ keys }) => memory[keys[0]] && memory[keys[1]])
if (appliedSpecials.length > 1) {
logger.warn(`Memory ${colors.italic(memory.caption)} is used as ${appliedSpecials.map(({ name }) => `${colors.italic(name)}`).join(' and ')} but can only be used for one challenge (${colors.red('NOT OK')})`)
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const trunc = function (str: string, length: number) {

export const version = (module?: string) => {
if (module) {
// @ts-expect-error Ignoring any type issue on purpose
// @ts-expect-error FIXME Ignoring any type issue on purpose
return packageJson.dependencies[module]
} else {
return packageJson.version
Expand Down
4 changes: 2 additions & 2 deletions models/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const relationsInit = (_sequelize: Sequelize) => {
name: 'BasketId'
}
})
// @ts-expect-error type mismatch
// @ts-expect-error FIXME type mismatch
makeKeyNonUpdatable(BasketItemModel, 'BasketId')

CardModel.belongsTo(UserModel, {
Expand Down Expand Up @@ -94,7 +94,7 @@ const relationsInit = (_sequelize: Sequelize) => {
name: 'ProductId'
}
})
// @ts-expect-error type mismatch
// @ts-expect-error FIXME type mismatch
makeKeyNonUpdatable(BasketItemModel, 'ProductId')

QuantityModel.belongsTo(ProductModel, {
Expand Down
2 changes: 1 addition & 1 deletion routes/profileImageFileUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function fileUpload () {
if (loggedInUser) {
fs.open(`frontend/dist/frontend/assets/public/images/uploads/${loggedInUser.data.id}.${uploadedFileType.ext}`, 'w', function (err, fd) {
if (err != null) logger.warn('Error opening file: ' + err.message)
// @ts-expect-error buffer has unexpected type
// @ts-expect-error FIXME buffer has unexpected type
fs.write(fd, buffer, 0, buffer.length, null, function (err) {
if (err != null) logger.warn('Error writing file: ' + err.message)
fs.close(fd, function () { })
Expand Down
2 changes: 1 addition & 1 deletion routes/showProductReviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const security = require('../lib/insecurity')
const db = require('../data/mongodb')

// Blocking sleep function as in native MongoDB
// @ts-expect-error Type safety broken for global object
// @ts-expect-error FIXME Type safety broken for global object
global.sleep = (time: number) => {
// Ensure that users don't accidentally dos their servers for too long
if (time > 2000) {
Expand Down
6 changes: 3 additions & 3 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ restoreOverwrittenFilesWithOriginals().then(() => {
/* Create middleware to change paths from the serve-index plugin from absolute to relative */
const serveIndexMiddleware = (req: Request, res: Response, next: NextFunction) => {
const origEnd = res.end
// @ts-expect-error assignment broken due to seemingly void return value
// @ts-expect-error FIXME assignment broken due to seemingly void return value
res.end = function () {
if (arguments.length) {
const reqPath = req.originalUrl.replace(/\?.*$/, '')
Expand All @@ -234,7 +234,7 @@ restoreOverwrittenFilesWithOriginals().then(() => {
return 'a href="' + relativePath + '"'
})
}
// @ts-expect-error passed argument has wrong type
// @ts-expect-error FIXME passed argument has wrong type
origEnd.apply(this, arguments)
}
next()
Expand Down Expand Up @@ -281,7 +281,7 @@ restoreOverwrittenFilesWithOriginals().then(() => {

app.use(bodyParser.text({ type: '*/*' }))
app.use(function jsonParser (req: Request, res: Response, next: NextFunction) {
// @ts-expect-error intentionally saving original request in this property
// @ts-expect-error FIXME intentionally saving original request in this property
req.rawBody = req.body
if (req.headers['content-type']?.includes('application/json')) {
if (!req.body) {
Expand Down
44 changes: 22 additions & 22 deletions test/api/2faSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const API_URL = 'http:https://localhost:3000/api'
const jsonHeader = { 'content-type': 'application/json' }

async function login ({ email, password, totpSecret }: { email: string, password: string, totpSecret?: string }) {
// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
const loginRes = await frisby
.post(REST_URL + '/user/login', {
email,
Expand All @@ -30,7 +30,7 @@ async function login ({ email, password, totpSecret }: { email: string, password
})

if (loginRes.json.status && loginRes.json.status === 'totp_token_required') {
// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
const totpRes = await frisby
.post(REST_URL + '/2fa/verify', {
tmpToken: loginRes.json.data.tmpToken,
Expand All @@ -44,7 +44,7 @@ async function login ({ email, password, totpSecret }: { email: string, password
}

async function register ({ email, password, totpSecret }: { email: string, password: string, totpSecret?: string }) {
// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
const res = await frisby
.post(API_URL + '/Users/', {
email,
Expand All @@ -59,7 +59,7 @@ async function register ({ email, password, totpSecret }: { email: string, passw
if (totpSecret) {
const { token } = await login({ email, password })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/setup',
{
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('/rest/2fa/verify', () => {

const totpToken = otplib.authenticator.generate('IFTXE3SPOEYVURT2MRYGI52TKJ4HC3KH')

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(REST_URL + '/2fa/verify', {
headers: jsonHeader,
body: {
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('/rest/2fa/verify', () => {

const totpToken = otplib.authenticator.generate('THIS9ISNT8THE8RIGHT8SECRET')

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(REST_URL + '/2fa/verify', {
headers: jsonHeader,
body: {
Expand All @@ -150,7 +150,7 @@ describe('/rest/2fa/verify', () => {

const totpToken = otplib.authenticator.generate('IFTXE3SPOEYVURT2MRYGI52TKJ4HC3KH')

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(REST_URL + '/2fa/verify', {
headers: jsonHeader,
body: {
Expand All @@ -170,7 +170,7 @@ describe('/rest/2fa/status', () => {
totpSecret: 'IFTXE3SPOEYVURT2MRYGI52TKJ4HC3KH'
})

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.get(
REST_URL + '/2fa/status',
{
Expand All @@ -195,7 +195,7 @@ describe('/rest/2fa/status', () => {
password: '0Y8rMnww$*9VFYE§59-!Fg1L6t&6lB'
})

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.get(
REST_URL + '/2fa/status',
{
Expand All @@ -219,7 +219,7 @@ describe('/rest/2fa/status', () => {
})

it('GET should return 401 when not logged in', async () => {
// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.get(REST_URL + '/2fa/status')
.expect('status', 401)
})
Expand All @@ -235,7 +235,7 @@ describe('/rest/2fa/setup', () => {
await register({ email, password })
const { token } = await login({ email, password })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/setup',
{
Expand All @@ -254,7 +254,7 @@ describe('/rest/2fa/setup', () => {
})
.expect('status', 200)

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.get(
REST_URL + '/2fa/status',
{
Expand All @@ -281,7 +281,7 @@ describe('/rest/2fa/setup', () => {
await register({ email, password })
const { token } = await login({ email, password })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/setup',
{
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('/rest/2fa/setup', () => {
await register({ email, password })
const { token } = await login({ email, password })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/setup',
{
Expand Down Expand Up @@ -339,7 +339,7 @@ describe('/rest/2fa/setup', () => {
await register({ email, password })
const { token } = await login({ email, password })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/setup',
{
Expand All @@ -366,7 +366,7 @@ describe('/rest/2fa/setup', () => {

const { token } = await login({ email, password, totpSecret })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/setup',
{
Expand Down Expand Up @@ -396,14 +396,14 @@ describe('/rest/2fa/disable', () => {
await register({ email, password, totpSecret })
const { token } = await login({ email, password, totpSecret })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await getStatus(token)
.expect('status', 200)
.expect('json', {
setup: true
})

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/disable',
{
Expand All @@ -417,7 +417,7 @@ describe('/rest/2fa/disable', () => {
}
).expect('status', 200)

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await getStatus(token)
.expect('status', 200)
.expect('json', {
Expand All @@ -433,14 +433,14 @@ describe('/rest/2fa/disable', () => {
await register({ email, password, totpSecret })
const { token } = await login({ email, password, totpSecret })

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await getStatus(token)
.expect('status', 200)
.expect('json', {
setup: true
})

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await frisby.post(
REST_URL + '/2fa/disable',
{
Expand All @@ -454,7 +454,7 @@ describe('/rest/2fa/disable', () => {
}
).expect('status', 401)

// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
await getStatus(token)
.expect('status', 200)
.expect('json', {
Expand Down
2 changes: 1 addition & 1 deletion test/api/chatBotSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const API_URL = `${URL}/api/`
let trainingData: { data: any[] }

async function login ({ email, password }: { email: string, password: string }) {
// @ts-expect-error promise return handling broken
// @ts-expect-error FIXME promise return handling broken
const loginRes = await frisby
.post(REST_URL + '/user/login', {
email,
Expand Down
Loading

0 comments on commit 4488721

Please sign in to comment.