fix(lint): resolve @typescript-eslint/no-explicit-any warnings
This commit is contained in:
@@ -18,101 +18,111 @@ describe('run', () => {
|
||||
})
|
||||
|
||||
test('finds vulnerabilities with default values', () => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
||||
const stdout = fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/error.txt')
|
||||
)
|
||||
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||
(): child_process.SpawnSyncReturns<string> => {
|
||||
const stdout = fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||
.toString()
|
||||
|
||||
return {
|
||||
pid: 100,
|
||||
output: [stdout],
|
||||
output: [null, stdout, ''],
|
||||
stdout,
|
||||
stderr: '',
|
||||
status: 1,
|
||||
signal: null,
|
||||
error: null
|
||||
error: undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
audit.run('low', 'false', 'false')
|
||||
expect(audit.foundVulnerability()).toBeTruthy()
|
||||
})
|
||||
|
||||
test('finds vulnerabilities with production flag enabled', () => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
||||
const stdout = fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/error.txt')
|
||||
)
|
||||
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||
(): child_process.SpawnSyncReturns<string> => {
|
||||
const stdout = fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||
.toString()
|
||||
|
||||
return {
|
||||
pid: 100,
|
||||
output: [stdout],
|
||||
output: [null, stdout, ''],
|
||||
stdout,
|
||||
stderr: '',
|
||||
status: 1,
|
||||
signal: null,
|
||||
error: null
|
||||
error: undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
audit.run('low', 'true', 'false')
|
||||
expect(audit.foundVulnerability()).toBeTruthy()
|
||||
})
|
||||
|
||||
test('finds vulnerabilities with json flag enabled', () => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
||||
const stdout = fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/error.json')
|
||||
)
|
||||
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||
(): child_process.SpawnSyncReturns<string> => {
|
||||
const stdout = fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/error.json'))
|
||||
.toString()
|
||||
|
||||
return {
|
||||
pid: 100,
|
||||
output: [stdout],
|
||||
output: [null, stdout, ''],
|
||||
stdout,
|
||||
stderr: '',
|
||||
status: 1,
|
||||
signal: null,
|
||||
error: null
|
||||
error: undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
audit.run('low', 'false', 'true')
|
||||
expect(audit.foundVulnerability()).toBeTruthy()
|
||||
})
|
||||
|
||||
test('does not find vulnerabilities', () => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
||||
const stdout = fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/success.txt')
|
||||
)
|
||||
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||
(): child_process.SpawnSyncReturns<string> => {
|
||||
const stdout = fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/success.txt'))
|
||||
.toString()
|
||||
|
||||
return {
|
||||
pid: 100,
|
||||
output: [stdout],
|
||||
output: [null, stdout, ''],
|
||||
stdout,
|
||||
stderr: '',
|
||||
status: 0,
|
||||
signal: null,
|
||||
error: null
|
||||
error: undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
audit.run('low', 'false', 'false')
|
||||
expect(audit.foundVulnerability()).toBeFalsy()
|
||||
})
|
||||
|
||||
test('throws an error if error is not null', () => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||
(): child_process.SpawnSyncReturns<string> => {
|
||||
return {
|
||||
pid: 100,
|
||||
output: '',
|
||||
output: [null, '', ''],
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
status: 0,
|
||||
signal: null,
|
||||
error: new Error('Something is wrong')
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
expect.assertions(1)
|
||||
const e = new Error('Something is wrong')
|
||||
@@ -120,17 +130,19 @@ describe('run', () => {
|
||||
})
|
||||
|
||||
test('throws an error if status is null', () => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||
(): child_process.SpawnSyncReturns<string> => {
|
||||
return {
|
||||
pid: 100,
|
||||
output: '',
|
||||
output: [null, '', ''],
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
status: null,
|
||||
signal: 'SIGTERM',
|
||||
error: null
|
||||
error: undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
expect.assertions(1)
|
||||
const e = new Error('the subprocess terminated due to a signal.')
|
||||
@@ -138,17 +150,19 @@ describe('run', () => {
|
||||
})
|
||||
|
||||
test('throws an error if stderr is null', () => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
||||
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||
(): child_process.SpawnSyncReturns<string> => {
|
||||
return {
|
||||
pid: 100,
|
||||
output: '',
|
||||
output: [null, '', 'Something is wrong'],
|
||||
stdout: '',
|
||||
stderr: 'Something is wrong',
|
||||
status: 1,
|
||||
signal: null,
|
||||
error: null
|
||||
error: undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
expect.assertions(1)
|
||||
const e = new Error('Something is wrong')
|
||||
|
||||
@@ -47,12 +47,11 @@ describe('run: pr', () => {
|
||||
})
|
||||
|
||||
test('does not call pr.createComment if vulnerabilities are not found', () => {
|
||||
vi.mocked(Audit).mockImplementation((): any => {
|
||||
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||
return {
|
||||
stdout: fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/success.txt')
|
||||
),
|
||||
status: 0,
|
||||
stdout: fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/success.txt'))
|
||||
.toString(),
|
||||
run: (): Promise<void> => {
|
||||
return Promise.resolve(void 0)
|
||||
},
|
||||
@@ -72,12 +71,11 @@ describe('run: pr', () => {
|
||||
})
|
||||
|
||||
test('calls pr.createComment if vulnerabilities are found in PR', () => {
|
||||
vi.mocked(Audit).mockImplementation((): any => {
|
||||
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||
return {
|
||||
stdout: fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/error.txt')
|
||||
),
|
||||
status: 1,
|
||||
stdout: fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||
.toString(),
|
||||
run: (): Promise<void> => {
|
||||
return Promise.resolve(void 0)
|
||||
},
|
||||
@@ -99,12 +97,11 @@ describe('run: pr', () => {
|
||||
test('does not call pr.createComment if create_pr_comments is set to false', () => {
|
||||
process.env.INPUT_CREATE_PR_COMMENTS = 'false'
|
||||
|
||||
vi.mocked(Audit).mockImplementation((): any => {
|
||||
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||
return {
|
||||
stdout: fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/error.txt')
|
||||
),
|
||||
status: 1,
|
||||
stdout: fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||
.toString(),
|
||||
run: (): Promise<void> => {
|
||||
return Promise.resolve(void 0)
|
||||
},
|
||||
@@ -141,12 +138,11 @@ describe('run: issue', () => {
|
||||
test('does not call octokit.rest.issues.create if create_issues is set to false', () => {
|
||||
process.env.INPUT_CREATE_ISSUES = 'false'
|
||||
|
||||
vi.mocked(Audit).mockImplementation((): any => {
|
||||
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||
return {
|
||||
stdout: fs.readFileSync(
|
||||
path.join(__dirname, 'testdata/audit/error.txt')
|
||||
),
|
||||
status: 1,
|
||||
stdout: fs
|
||||
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||
.toString(),
|
||||
run: (): Promise<void> => {
|
||||
return Promise.resolve(void 0)
|
||||
},
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -27,8 +27,7 @@ export type GetIssuesFunc = (options: {
|
||||
owner: string
|
||||
repo: string
|
||||
state: 'open' | 'closed' | 'all' | undefined
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[key: string]: any // Allow additional properties
|
||||
[key: string]: string | undefined // Allow additional properties
|
||||
}) => Promise<{ data: Array<{ title: string; number: number }> }>
|
||||
|
||||
export async function getExistingIssueNumber(
|
||||
|
||||
Reference in New Issue
Block a user