Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump @typescript-eslint/eslint-plugin from 7.16.0 to 8.19.0 in /backend #1713

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,405 changes: 117 additions & 1,288 deletions backend/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
"@types/shelljs": "^0.8.15",
"@types/supertest": "^6.0.2",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@typescript-eslint/parser": "^8.19.0",
"@vitest/coverage-v8": "^2.1.4",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.2.1",
Expand Down
4 changes: 3 additions & 1 deletion backend/src/clients/cognito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@aws-sdk/client-cognito-identity-provider'

import { UserInformation } from '../connectors/authentication/Base.js'
import log from '../services/log.js'
import config from '../utils/config.js'
import { ConfigurationError, InternalError } from '../utils/error.js'

Expand All @@ -14,7 +15,8 @@ export async function listUsers(query: string, exactMatch = false) {
try {
dnName = config.oauth.cognito.userIdAttribute
userPoolId = config.oauth.cognito.userPoolId
} catch (e) {
} catch (err) {
log.error(err)
throw ConfigurationError('Cannot find userIdAttribute in oauth configuration', { oauthConfiguration: config.oauth })
}

Expand Down
1 change: 1 addition & 0 deletions backend/src/connectors/fileScanning/clamAv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class ClamAvFileScanningConnector extends BaseFileScanningConnector {
av = await new NodeClam().init({ clamdscan: config.avScanning.clamdscan })
log.info('Clam AV initialised.')
} catch (error) {
log.error(error)
log.warn(`Could not initialise Clam AV, retrying (attempt ${retryCount})...`)
this.init(++retryCount)
}
Expand Down
3 changes: 3 additions & 0 deletions backend/src/connectors/fileScanning/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import log from '../../services/log.js'
import config from '../../utils/config.js'
import { ConfigurationError } from '../../utils/error.js'
import { BaseFileScanningConnector } from './Base.js'
Expand Down Expand Up @@ -25,6 +26,7 @@ export function runFileScanners(cache = true) {
await scanner.init()
fileScanConnectors.push(scanner)
} catch (error) {
log.error(error)
throw ConfigurationError('Could not configure or initialise Clam AV')
}
break
Expand All @@ -34,6 +36,7 @@ export function runFileScanners(cache = true) {
await scanner.init()
fileScanConnectors.push(scanner)
} catch (error) {
log.error(error)
throw ConfigurationError('Could not configure or initialise ModelScan')
}
break
Expand Down
1 change: 1 addition & 0 deletions backend/src/connectors/fileScanning/modelScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class ModelScanFileScanningConnector extends BaseFileScanningConnector {
await getModelScanInfo()
log.info('ModelScan initialised.')
} catch (error) {
log.error(error)
log.warn(`Could not initialise ModelScan, retrying (attempt ${retryCount})...`)
this.init(++retryCount)
}
Expand Down
2 changes: 2 additions & 0 deletions backend/src/migrations/011_find_and_remove_invalid_users.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import authentication from '../connectors/authentication/index.js'
import { MigrationMetadata } from '../models/Migration.js'
import ModelModel from '../models/Model.js'
import log from '../services/log.js'

/**
* As we now do backend validation for users being added to model access lists, we
Expand All @@ -21,6 +22,7 @@ export async function up() {
try {
await authentication.getUserInformation(collaborator.entity)
} catch (err) {
log.error(err)
invalidUsers.push(collaborator.entity)
}
}
Expand Down
18 changes: 10 additions & 8 deletions backend/src/services/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export async function doesMigrationExist(name: string) {
}

export async function markMigrationComplete(name: string, metadata: MigrationMetadata | undefined) {
metadata
? await MigrationModel.create({
name,
metadata,
})
: await MigrationModel.create({
name,
})
if (metadata) {
await MigrationModel.create({
name,
metadata,
})
} else {
await MigrationModel.create({
name,
})
}
}
6 changes: 6 additions & 0 deletions backend/test/clients/cognito.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const configMock = vi.hoisted(
},
},
},
log: {
level: 'info',
},
instrumentation: {
enabled: false,
},
}) as any,
)
vi.mock('../../src/utils/config.js', () => ({
Expand Down
14 changes: 7 additions & 7 deletions backend/test/models/Token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('models > Token', () => {
const token = new TokenModel()
const result = await token.compareToken('abc')

expect(result).false
expect(result).toBe(false)
})

test('compareToken > return bcrypt error thrown when comparing', async () => {
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('models > Token', () => {

const result = await token.compareToken('abc')

expect(result).true
expect(result).toBe(true)
})

test('compareToken > return false on unsuccessful bcrypt comparison', async () => {
Expand All @@ -70,7 +70,7 @@ describe('models > Token', () => {

const result = await token.compareToken('abc')

expect(result).false
expect(result).toBe(false)
})

test('compareToken > return true on successful sha256 comparison', async () => {
Expand All @@ -81,7 +81,7 @@ describe('models > Token', () => {

const result = await token.compareToken('abc')

expect(result).true
expect(result).toBe(true)
})

test('compareToken > return true on successful sha256 comparison', async () => {
Expand All @@ -92,7 +92,7 @@ describe('models > Token', () => {

const result = await token.compareToken('abc')

expect(result).true
expect(result).toBe(true)
})

test('compareToken > return true on successful sha256 comparison', async () => {
Expand All @@ -103,7 +103,7 @@ describe('models > Token', () => {

const result = await token.compareToken('abc')

expect(result).true
expect(result).toBe(true)
})

test('compareToken > return false on unsuccessful sha256 comparison', async () => {
Expand All @@ -114,6 +114,6 @@ describe('models > Token', () => {

const result = await token.compareToken('abc')

expect(result).false
expect(result).toBe(false)
})
})
2 changes: 1 addition & 1 deletion backend/test/services/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
test('setLatestImportedModelCard > success', async () => {
await setLatestImportedModelCard('abc')

expect(modelMocks.updateOne).toHaveBeenCalledOnce
expect(modelMocks.updateOne).toHaveBeenCalledOnce()

Check failure on line 421 in backend/test/services/model.spec.ts

View workflow job for this annotation

GitHub Actions / unit_testing

test/services/model.spec.ts > services > model > setLatestImportedModelCard > success

AssertionError: expected "spy" to be called once, but got 0 times ❯ test/services/model.spec.ts:421:34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling this unit test was already broken, but now that we're actually calling toHaveBeenCalledOnce() it's correctly showing that it's failed.

})

test('setLatestImportedModelCard > cannot find latest model card', async () => {
Expand Down
Loading
Loading