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', () => {
|
test('finds vulnerabilities with default values', () => {
|
||||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||||
const stdout = fs.readFileSync(
|
(): child_process.SpawnSyncReturns<string> => {
|
||||||
path.join(__dirname, 'testdata/audit/error.txt')
|
const stdout = fs
|
||||||
)
|
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||||
|
.toString()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pid: 100,
|
pid: 100,
|
||||||
output: [stdout],
|
output: [null, stdout, ''],
|
||||||
stdout,
|
stdout,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
status: 1,
|
status: 1,
|
||||||
signal: null,
|
signal: null,
|
||||||
error: null
|
error: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
audit.run('low', 'false', 'false')
|
audit.run('low', 'false', 'false')
|
||||||
expect(audit.foundVulnerability()).toBeTruthy()
|
expect(audit.foundVulnerability()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('finds vulnerabilities with production flag enabled', () => {
|
test('finds vulnerabilities with production flag enabled', () => {
|
||||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||||
const stdout = fs.readFileSync(
|
(): child_process.SpawnSyncReturns<string> => {
|
||||||
path.join(__dirname, 'testdata/audit/error.txt')
|
const stdout = fs
|
||||||
)
|
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||||
|
.toString()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pid: 100,
|
pid: 100,
|
||||||
output: [stdout],
|
output: [null, stdout, ''],
|
||||||
stdout,
|
stdout,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
status: 1,
|
status: 1,
|
||||||
signal: null,
|
signal: null,
|
||||||
error: null
|
error: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
audit.run('low', 'true', 'false')
|
audit.run('low', 'true', 'false')
|
||||||
expect(audit.foundVulnerability()).toBeTruthy()
|
expect(audit.foundVulnerability()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('finds vulnerabilities with json flag enabled', () => {
|
test('finds vulnerabilities with json flag enabled', () => {
|
||||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||||
const stdout = fs.readFileSync(
|
(): child_process.SpawnSyncReturns<string> => {
|
||||||
path.join(__dirname, 'testdata/audit/error.json')
|
const stdout = fs
|
||||||
)
|
.readFileSync(path.join(__dirname, 'testdata/audit/error.json'))
|
||||||
|
.toString()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pid: 100,
|
pid: 100,
|
||||||
output: [stdout],
|
output: [null, stdout, ''],
|
||||||
stdout,
|
stdout,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
status: 1,
|
status: 1,
|
||||||
signal: null,
|
signal: null,
|
||||||
error: null
|
error: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
audit.run('low', 'false', 'true')
|
audit.run('low', 'false', 'true')
|
||||||
expect(audit.foundVulnerability()).toBeTruthy()
|
expect(audit.foundVulnerability()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('does not find vulnerabilities', () => {
|
test('does not find vulnerabilities', () => {
|
||||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||||
const stdout = fs.readFileSync(
|
(): child_process.SpawnSyncReturns<string> => {
|
||||||
path.join(__dirname, 'testdata/audit/success.txt')
|
const stdout = fs
|
||||||
)
|
.readFileSync(path.join(__dirname, 'testdata/audit/success.txt'))
|
||||||
|
.toString()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pid: 100,
|
pid: 100,
|
||||||
output: [stdout],
|
output: [null, stdout, ''],
|
||||||
stdout,
|
stdout,
|
||||||
stderr: '',
|
stderr: '',
|
||||||
status: 0,
|
status: 0,
|
||||||
signal: null,
|
signal: null,
|
||||||
error: null
|
error: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
audit.run('low', 'false', 'false')
|
audit.run('low', 'false', 'false')
|
||||||
expect(audit.foundVulnerability()).toBeFalsy()
|
expect(audit.foundVulnerability()).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('throws an error if error is not null', () => {
|
test('throws an error if error is not null', () => {
|
||||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||||
return {
|
(): child_process.SpawnSyncReturns<string> => {
|
||||||
pid: 100,
|
return {
|
||||||
output: '',
|
pid: 100,
|
||||||
stdout: '',
|
output: [null, '', ''],
|
||||||
stderr: '',
|
stdout: '',
|
||||||
status: 0,
|
stderr: '',
|
||||||
signal: null,
|
status: 0,
|
||||||
error: new Error('Something is wrong')
|
signal: null,
|
||||||
|
error: new Error('Something is wrong')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
expect.assertions(1)
|
expect.assertions(1)
|
||||||
const e = new Error('Something is wrong')
|
const e = new Error('Something is wrong')
|
||||||
@@ -120,17 +130,19 @@ describe('run', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('throws an error if status is null', () => {
|
test('throws an error if status is null', () => {
|
||||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||||
return {
|
(): child_process.SpawnSyncReturns<string> => {
|
||||||
pid: 100,
|
return {
|
||||||
output: '',
|
pid: 100,
|
||||||
stdout: '',
|
output: [null, '', ''],
|
||||||
stderr: '',
|
stdout: '',
|
||||||
status: null,
|
stderr: '',
|
||||||
signal: 'SIGTERM',
|
status: null,
|
||||||
error: null
|
signal: 'SIGTERM',
|
||||||
|
error: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
expect.assertions(1)
|
expect.assertions(1)
|
||||||
const e = new Error('the subprocess terminated due to a signal.')
|
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', () => {
|
test('throws an error if stderr is null', () => {
|
||||||
vi.mocked(child_process).spawnSync.mockImplementation((): any => {
|
vi.mocked(child_process).spawnSync.mockImplementation(
|
||||||
return {
|
(): child_process.SpawnSyncReturns<string> => {
|
||||||
pid: 100,
|
return {
|
||||||
output: '',
|
pid: 100,
|
||||||
stdout: '',
|
output: [null, '', 'Something is wrong'],
|
||||||
stderr: 'Something is wrong',
|
stdout: '',
|
||||||
status: 1,
|
stderr: 'Something is wrong',
|
||||||
signal: null,
|
status: 1,
|
||||||
error: null
|
signal: null,
|
||||||
|
error: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
expect.assertions(1)
|
expect.assertions(1)
|
||||||
const e = new Error('Something is wrong')
|
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', () => {
|
test('does not call pr.createComment if vulnerabilities are not found', () => {
|
||||||
vi.mocked(Audit).mockImplementation((): any => {
|
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||||
return {
|
return {
|
||||||
stdout: fs.readFileSync(
|
stdout: fs
|
||||||
path.join(__dirname, 'testdata/audit/success.txt')
|
.readFileSync(path.join(__dirname, 'testdata/audit/success.txt'))
|
||||||
),
|
.toString(),
|
||||||
status: 0,
|
|
||||||
run: (): Promise<void> => {
|
run: (): Promise<void> => {
|
||||||
return Promise.resolve(void 0)
|
return Promise.resolve(void 0)
|
||||||
},
|
},
|
||||||
@@ -72,12 +71,11 @@ describe('run: pr', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('calls pr.createComment if vulnerabilities are found in PR', () => {
|
test('calls pr.createComment if vulnerabilities are found in PR', () => {
|
||||||
vi.mocked(Audit).mockImplementation((): any => {
|
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||||
return {
|
return {
|
||||||
stdout: fs.readFileSync(
|
stdout: fs
|
||||||
path.join(__dirname, 'testdata/audit/error.txt')
|
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||||
),
|
.toString(),
|
||||||
status: 1,
|
|
||||||
run: (): Promise<void> => {
|
run: (): Promise<void> => {
|
||||||
return Promise.resolve(void 0)
|
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', () => {
|
test('does not call pr.createComment if create_pr_comments is set to false', () => {
|
||||||
process.env.INPUT_CREATE_PR_COMMENTS = 'false'
|
process.env.INPUT_CREATE_PR_COMMENTS = 'false'
|
||||||
|
|
||||||
vi.mocked(Audit).mockImplementation((): any => {
|
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||||
return {
|
return {
|
||||||
stdout: fs.readFileSync(
|
stdout: fs
|
||||||
path.join(__dirname, 'testdata/audit/error.txt')
|
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||||
),
|
.toString(),
|
||||||
status: 1,
|
|
||||||
run: (): Promise<void> => {
|
run: (): Promise<void> => {
|
||||||
return Promise.resolve(void 0)
|
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', () => {
|
test('does not call octokit.rest.issues.create if create_issues is set to false', () => {
|
||||||
process.env.INPUT_CREATE_ISSUES = 'false'
|
process.env.INPUT_CREATE_ISSUES = 'false'
|
||||||
|
|
||||||
vi.mocked(Audit).mockImplementation((): any => {
|
vi.mocked(Audit).mockImplementation((): unknown => {
|
||||||
return {
|
return {
|
||||||
stdout: fs.readFileSync(
|
stdout: fs
|
||||||
path.join(__dirname, 'testdata/audit/error.txt')
|
.readFileSync(path.join(__dirname, 'testdata/audit/error.txt'))
|
||||||
),
|
.toString(),
|
||||||
status: 1,
|
|
||||||
run: (): Promise<void> => {
|
run: (): Promise<void> => {
|
||||||
return Promise.resolve(void 0)
|
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
|
owner: string
|
||||||
repo: string
|
repo: string
|
||||||
state: 'open' | 'closed' | 'all' | undefined
|
state: 'open' | 'closed' | 'all' | undefined
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
[key: string]: string | undefined // Allow additional properties
|
||||||
[key: string]: any // Allow additional properties
|
|
||||||
}) => Promise<{ data: Array<{ title: string; number: number }> }>
|
}) => Promise<{ data: Array<{ title: string; number: number }> }>
|
||||||
|
|
||||||
export async function getExistingIssueNumber(
|
export async function getExistingIssueNumber(
|
||||||
|
|||||||
Reference in New Issue
Block a user