Skip to content

Commit 6cf8f98

Browse files
committed
Address eslint errors and warnings.
1 parent 61fd4fc commit 6cf8f98

15 files changed

+48
-42
lines changed

__tests__/cache.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('dependency cache', () => {
9494
beforeEach(() => {
9595
spyCacheRestore = jest
9696
.spyOn(cache, 'restoreCache')
97-
.mockImplementation((paths: string[], primaryKey: string) =>
97+
.mockImplementation((_paths: string[], _primaryKey: string) =>
9898
Promise.resolve(undefined)
9999
)
100100
spyWarning.mockImplementation(() => null)
@@ -184,7 +184,7 @@ describe('dependency cache', () => {
184184
beforeEach(() => {
185185
spyCacheSave = jest
186186
.spyOn(cache, 'saveCache')
187-
.mockImplementation((paths: string[], key: string) =>
187+
.mockImplementation((_paths: string[], _key: string) =>
188188
Promise.resolve(0)
189189
)
190190
spyWarning.mockImplementation(() => null)

__tests__/cleanup.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe('cleanup', () => {
3535
ReturnType<typeof cache.saveCache>,
3636
Parameters<typeof cache.saveCache>
3737
>
38-
let spyJobStatusSuccess: jest.SpyInstance
3938

4039
beforeEach(() => {
4140
spyWarning = jest.spyOn(core, 'warning')
@@ -50,7 +49,7 @@ describe('cleanup', () => {
5049
})
5150

5251
it('does not fail nor warn even when the save process throws a ReserveCacheError', async () => {
53-
spyCacheSave.mockImplementation((paths: string[], key: string) =>
52+
spyCacheSave.mockImplementation((_paths: string[], _key: string) =>
5453
Promise.reject(
5554
new cache.ReserveCacheError(
5655
'Unable to reserve cache with key, another job may be creating this cache.'
@@ -66,7 +65,7 @@ describe('cleanup', () => {
6665
})
6766

6867
it('does not fail even though the save process throws error', async () => {
69-
spyCacheSave.mockImplementation((paths: string[], key: string) =>
68+
spyCacheSave.mockImplementation((_paths: string[], _key: string) =>
7069
Promise.reject(new Error('Unexpected error'))
7170
)
7271
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {

__tests__/graalvm.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
1313
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
1414

1515
test('request invalid version/javaVersion', async () => {
16-
for (var combination of [
16+
for (const combination of [
1717
['22.3.0', '7'],
1818
['22.3', '17'],
1919
['22.3', '7']
@@ -23,7 +23,7 @@ test('request invalid version/javaVersion', async () => {
2323
await graalvm.setUpGraalVMRelease('', combination[0], combination[1])
2424
} catch (err) {
2525
if (!(err instanceof Error)) {
26-
fail(`Unexpected non-Error: ${err}`)
26+
throw new Error(`Unexpected non-Error: ${err}`)
2727
}
2828
error = err
2929
}
@@ -36,17 +36,17 @@ test('request invalid version/javaVersion', async () => {
3636

3737
test('find version/javaVersion', async () => {
3838
// Make sure the action can find the latest Java version for known major versions
39-
for (var majorJavaVersion of ['17', '20']) {
39+
for (const majorJavaVersion of ['17', '20']) {
4040
await graalvm.findLatestGraalVMJDKCEJavaVersion(majorJavaVersion)
4141
}
4242

4343
let error = new Error('unexpected')
4444
try {
4545
await graalvm.findLatestGraalVMJDKCEJavaVersion('11')
46-
fail('Should not find Java version for 11')
46+
throw new Error('Should not find Java version for 11')
4747
} catch (err) {
4848
if (!(err instanceof Error)) {
49-
fail(`Unexpected non-Error: ${err}`)
49+
throw new Error(`Unexpected non-Error: ${err}`)
5050
}
5151
error = err
5252
}
@@ -68,7 +68,7 @@ test('find version/javaVersion', async () => {
6868
findGraalVMVersion(invalidRelease)
6969
} catch (err) {
7070
if (!(err instanceof Error)) {
71-
fail(`Unexpected non-Error: ${err}`)
71+
throw new Error(`Unexpected non-Error: ${err}`)
7272
}
7373
error = err
7474
}
@@ -78,25 +78,25 @@ test('find version/javaVersion', async () => {
7878
findHighestJavaVersion(latestRelease, 'invalid')
7979
} catch (err) {
8080
if (!(err instanceof Error)) {
81-
fail(`Unexpected non-Error: ${err}`)
81+
throw new Error(`Unexpected non-Error: ${err}`)
8282
}
8383
error = err
8484
}
8585
expect(error.message).toContain('Could not find highest Java version.')
8686
})
8787

88-
test('find version/javaVersion', async () => {
89-
let url22EA = await findLatestEABuildDownloadUrl('22-ea')
88+
test('find EA version/javaVersion', async () => {
89+
const url22EA = await findLatestEABuildDownloadUrl('22-ea')
9090
expect(url22EA).not.toBe('')
91-
let urlLatestEA = await findLatestEABuildDownloadUrl('latest-ea')
91+
const urlLatestEA = await findLatestEABuildDownloadUrl('latest-ea')
9292
expect(urlLatestEA).not.toBe('')
9393

9494
let error = new Error('unexpected')
9595
try {
9696
await findLatestEABuildDownloadUrl('8-ea')
9797
} catch (err) {
9898
if (!(err instanceof Error)) {
99-
fail(`Unexpected non-Error: ${err}`)
99+
throw new Error(`Unexpected non-Error: ${err}`)
100100
}
101101
error = err
102102
}

__tests__/liberica.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {expect, test} from '@jest/globals'
77
process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
88
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
99

10+
/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["expect", "expectLatestToBe", "expectURL"] }] */
11+
1012
test('find latest JDK version', async () => {
1113
// Make sure the action can find the latest Java version for known major versions
1214
await expectLatestToBe('11', atLeast('11.0.22+12'))
@@ -61,8 +63,8 @@ function atLeast(expectedMinVersion: string): verifier {
6163
return function (
6264
version: string,
6365
major: number,
64-
minor: number,
65-
patch: number
66+
_minor: number,
67+
_patch: number
6668
) {
6769
expect(major).toBe(expectedMajor)
6870
if (semver.compareBuild(version, expectedMinVersion) < 0) {
@@ -90,9 +92,9 @@ function upToBuild(expectedMinVersion: string): verifier {
9092
function exactly(expectedVersion: string): verifier {
9193
return function (
9294
version: string,
93-
major: number,
94-
minor: number,
95-
patch: number
95+
_major: number,
96+
_minor: number,
97+
_patch: number
9698
) {
9799
if (semver.compareBuild(version, expectedVersion) != 0) {
98100
throw new Error(`Expected version ${expectedVersion} but got ${version}`)

__tests__/mandrel.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
77
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
88

99
test('request invalid version/javaVersion combination', async () => {
10-
for (var combination of [
10+
for (const combination of [
1111
['mandrel-23.1.1.0-Final', '17'],
1212
['mandrel-23.0.2.1-Final', '21']
1313
]) {
@@ -16,7 +16,7 @@ test('request invalid version/javaVersion combination', async () => {
1616
await mandrel.setUpMandrel(combination[0], combination[1])
1717
} catch (err) {
1818
if (!(err instanceof Error)) {
19-
fail(`Unexpected non-Error: ${err}`)
19+
throw new Error(`Unexpected non-Error: ${err}`)
2020
}
2121
error = err
2222
}
@@ -27,7 +27,7 @@ test('request invalid version/javaVersion combination', async () => {
2727
}
2828
})
2929
test('request invalid version', async () => {
30-
for (var combination of [
30+
for (const combination of [
3131
['mandrel-23.1.1.0', '21'],
3232
['mandrel-23.0.2.1', '17']
3333
]) {
@@ -36,7 +36,7 @@ test('request invalid version', async () => {
3636
await mandrel.setUpMandrel(combination[0], combination[1])
3737
} catch (err) {
3838
if (!(err instanceof Error)) {
39-
fail(`Unexpected non-Error: ${err}`)
39+
throw new Error(`Unexpected non-Error: ${err}`)
4040
}
4141
error = err
4242
}
@@ -56,7 +56,7 @@ test('find latest', async () => {
5656

5757
test('get known latest Mandrel for specific JDK', async () => {
5858
// Test deprecated versions that won't get updates anymore
59-
for (var combination of [
59+
for (const combination of [
6060
['11', '22.2.0.0-Final'],
6161
['20', '23.0.1.2-Final']
6262
]) {
@@ -68,7 +68,7 @@ test('get known latest Mandrel for specific JDK', async () => {
6868

6969
test('get latest Mandrel for specific JDK', async () => {
7070
// Test supported versions
71-
for (var javaVersion of ['17', '21']) {
71+
for (const javaVersion of ['17', '21']) {
7272
const latest = await mandrel.getLatestMandrelReleaseUrl(javaVersion)
7373
expect(latest).toContain(`mandrel-java${javaVersion}`)
7474
}

__tests__/msvc.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
77
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
88

99
test('decide whether Window env must be set up for GraalVM for JDK', async () => {
10-
for (var javaVersion of [
10+
for (const javaVersion of [
1111
'17',
1212
'17.0.8',
1313
'17.0',
@@ -22,7 +22,7 @@ test('decide whether Window env must be set up for GraalVM for JDK', async () =>
2222
})
2323

2424
test('decide whether Window env must be set up for legacy GraalVM', async () => {
25-
for (var combination of [
25+
for (const combination of [
2626
['7', '22.3.0'],
2727
['17', '22.3'],
2828
['7', '22.3'],

__tests__/sbom.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,13 @@ describe('sbom feature', () => {
248248
const invalidSBOM = {
249249
'out-of-spec-field': {}
250250
}
251+
let error
251252
try {
252253
await setUpAndProcessSBOM(invalidSBOM)
253-
fail('Expected an error since invalid JSON was passed')
254-
} catch (error) {
254+
throw new Error('Expected an error since invalid JSON was passed')
255+
} catch (e) {
256+
error = e
257+
} finally {
255258
expect(error).toBeInstanceOf(Error)
256259
}
257260
})

__tests__/utils.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import * as path from 'path'
21
import {expect, test} from '@jest/globals'
32
import {toSemVer} from '../src/utils'
43

54
test('convert version', async () => {
6-
for (var inputAndExpectedOutput of [
5+
for (const inputAndExpectedOutput of [
76
['22', '22.0.0'],
87
['22.0', '22.0.0'],
98
['22.0.0', '22.0.0'],
@@ -17,13 +16,13 @@ test('convert version', async () => {
1716
})
1817

1918
test('convert invalid version', async () => {
20-
for (var input of ['dev', 'abc', 'a.b.c']) {
19+
for (const input of ['dev', 'abc', 'a.b.c']) {
2120
let error = new Error('unexpected')
2221
try {
2322
toSemVer(input)
2423
} catch (err) {
2524
if (!(err instanceof Error)) {
26-
fail(`Unexpected non-Error: ${err}`)
25+
throw new Error(`Unexpected non-Error: ${err}`)
2726
}
2827
error = err
2928
}

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default [
7070
camelcase: 'off',
7171
'eslint-comments/no-use': 'off',
7272
'eslint-comments/no-unused-disable': 'off',
73+
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
7374
'i18n-text/no-en': 'off',
7475
'import/no-namespace': 'off',
7576
'no-console': 'off',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint": "npx eslint .",
1212
"package": "ncc build -o dist/main src/main.ts && ncc build -o dist/cleanup src/cleanup.ts",
1313
"test": "npx jest",
14-
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
14+
"all": "npm run format:write && npm run lint && npm run test && npm run package"
1515
},
1616
"repository": {
1717
"type": "git",

0 commit comments

Comments
 (0)