8000 fix: migrate to ESLint 9 · CasP0/github-pages-deploy-action@9c1917a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c1917a

Browse files
committed
fix: migrate to ESLint 9
1 parent ea27152 commit 9c1917a

File tree

8 files changed

+134
-51
lines changed

8 files changed

+134
-51
lines changed

__tests__/execute.test.ts

Lines changed: 2 additions & 2 deletions

__tests__/git.test.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('execute', () => {
1010
stdout('hello')
1111
await execute('echo Montezuma', './', true)
1212

13-
expect(exec).toBeCalledWith('echo Montezuma', [], {
13+
expect(exec).toHaveBeenCalledWith('echo Montezuma', [], {
1414
cwd: './',
1515
silent: true,
1616
ignoreReturnCode: false,
@@ -27,7 +27,7 @@ describe('execute', () => {
2727
stdout('hello')
2828
await execute('echo Montezuma', './', false)
2929

30-
expect(exec).toBeCalledWith('echo Montezuma', [], {
30+
expect(exec).toHaveBeenCalledWith('echo Montezuma', [], {
3131
cwd: './',
3232
silent: false,
3333
ignoreReturnCode: false,
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('git', () => {
5454
})
5555

5656
await init(action)
57-
expect(execute).toBeCalledTimes(7)
57+
expect(execute).toHaveBeenCalledTimes(7)
5858
})
5959

6060
it('should catch when a function throws an error', async () => {
@@ -101,7 +101,7 @@ describe('git', () => {
101101
})
102102

103103
await init(action)
104-
expect(execute).toBeCalledTimes(7)
104+
expect(execute).toHaveBeenCalledTimes(7)
105105
})
106106

107107
it('should not unset git config if a user is using ssh', async () => {
@@ -123,7 +123,7 @@ describe('git', () => {
123123
})
124124

125125
await init(action)
126-
expect(execute).toBeCalledTimes(6)
126+
expect(execute).toHaveBeenCalledTimes(6)
127127

128128
process.env.CI = undefined
129129
})
@@ -144,7 +144,7 @@ describe('git', () => {
144144
})
145145

146146
await init(action)
147-
expect(execute).toBeCalledTimes(7)
147+
expect(execute).toHaveBeenCalledTimes(7)
148148
})
149149
})
150150

@@ -167,8 +167,8 @@ describe('git', () => {
167167
const response = await deploy(action)
168168

169169
// Includes the call to generateWorktree
170-
expect(execute).toBeCalledTimes(14)
171-
expect(rmRF).toBeCalledTimes(1)
170+
expect(execute).toHaveBeenCalledTimes(14)
171+
expect(rmRF).toHaveBeenCalledTimes(1)
172172
expect(response).toBe(Status.SUCCESS)
173173
})
174174

@@ -190,8 +190,8 @@ describe('git', () => {
190190
const response = await deploy(action)
191191

192192
// Includes the call to generateWorktree
193-
expect(execute).toBeCalledTimes(13)
194-
expect(rmRF).toBeCalledTimes(1)
193+
expect(execute).toHaveBeenCalledTimes(13)
194+
expect(rmRF).toHaveBeenCalledTimes(1)
195195
expect(response).toBe(Status.SUCCESS)
196196
})
197197

@@ -215,8 +215,8 @@ describe('git', () => {
215215
await deploy(action)
216216

217217
// Includes the call to generateWorktree
218-
expect(execute).toBeCalledTimes(14)
219-
expect(rmRF).toBeCalledTimes(1)
218+
expect(execute).toHaveBeenCalledTimes(14)
219+
expect(rmRF).toHaveBeenCalledTimes(1)
220220
})
221221

222222
it('should execute commands with single commit toggled and existing branch', async () => {
@@ -239,8 +239,8 @@ describe('git', () => {
239239
await deploy(action)
240240

241241
// Includes the call to generateWorktree
242-
expect(execute).toBeCalledTimes(13)
243-
expect(rmRF).toBeCalledTimes(1)
242+
expect(execute).toHaveBeenCalledTimes(13)
243+
expect(rmRF).toHaveBeenCalledTimes(1)
244244
})
245245

246246
it('should execute commands with single commit and dryRun toggled', async () => {
@@ -264,8 +264,8 @@ describe('git', () => {
264264
await deploy(action)
265265

266266
// Includes the call to generateWorktree
267-
expect(execute).toBeCalledTimes(13)
268-
expect(rmRF).toBeCalledTimes(1)
267+
expect(execute).toHaveBeenCalledTimes(13)
268+
expect(rmRF).toHaveBeenCalledTimes(1)
269269
})
270270

271271
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
@@ -295,9 +295,9 @@ describe('git', () => {
295295
const response = await deploy(action)
296296

297297
// Includes the call to generateWorktree
298-
expect(execute).toBeCalledTimes(14)
299-
expect(rmRF).toBeCalledTimes(1)
300-
expect(fs.existsSync).toBeCalledTimes(2)
298+
expect(execute).toHaveBeenCalledTimes(14)
299+
expect(rmRF).toHaveBeenCalledTimes(1)
300+
expect(fs.existsSync).toHaveBeenCalledTimes(2)
301301
expect(response).toBe(Status.SUCCESS)
302302
})
303303

@@ -327,8 +327,8 @@ describe('git', () => {
327327
await deploy(action)
328328

329329
// Includes the call to generateWorktree
330-
expect(execute).toBeCalledTimes(11)
331-
expect(rmRF).toBeCalledTimes(1)
330+
expect(execute).toHaveBeenCalledTimes(11)
331+
expect(rmRF).toHaveBeenCalledTimes(1)
332332
})
333333
})
334334

@@ -352,8 +352,8 @@ describe('git', () => {
352352
await deploy(action)
353353

354354
// Includes the call to generateWorktree
355-
expect(execute).toBeCalledTimes(11)
356-
expect(rmRF).toBeCalledTimes(1)
355+
expect(execute).toHaveBeenCalledTimes(11)
356+
expect(rmRF).toHaveBeenCalledTimes(1)
357357
})
358358

359359
it('should gracefully handle target folder', async () => {
@@ -372,9 +372,9 @@ describe('git', () => {
372372

373373
await deploy(action)
374374

375-
expect(execute).toBeCalledTimes(11)
376-
expect(rmRF).toBeCalledTimes(1)
377-
expect(mkdirP).toBeCalledTimes(1)
375+
expect(execute).toHaveBeenCalledTimes(11)
376+
expect(rmRF).toHaveBeenCalledTimes(1)
377+
expect(mkdirP).toHaveBeenCalledTimes(1)
378378
})
379379

380380
it('should stop early if there is nothing to commit', async () => {
@@ -392,8 +392,8 @@ describe('git', () => {
392392
})
393393

394394
const response = await deploy(action)
395-
expect(execute).toBeCalledTimes(11)
396-
expect(rmRF).toBeCalledTimes(1)
395+
expect(execute).toHaveBeenCalledTimes(11)
396+
expect(rmRF).toHaveBeenCalledTimes(1)
397397
expect(response).toBe(Status.SKIPPED)
398398
})
399399

@@ -466,7 +466,7 @@ describe('git', () => {
466466
})
467467

468468
const response = await deploy(action)
469-
expect(execute).toBeCalledTimes(16)
469+
expect(execute).toHaveBeenCalledTimes(16)
470470
expect(response).toBe(Status.SUCCESS)
471471
})
472472
})

__tests__/main.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ describe('main', () => {
5353
debug: true
5454
})
5555
await run(action)
56-
expect(execute).toBeCalledTimes(18)
57-
expect(rmRF).toBeCalledTimes(1)
58-
expect(exportVariable).toBeCalledTimes(1)
56+
expect(execute).toHaveBeenCalledTimes(18)
57+
expect(rmRF).toHaveBeenCalledTimes(1)
58+
expect(exportVariable).toHaveBeenCalledTimes(1)
5959
})
6060

6161
it('should run through the commands and succeed', async () => {
@@ -73,9 +73,9 @@ describe('main', () => {
7373
isTest: TestFlag.HAS_CHANGED_FILES
7474
})
7575
await run(action)
76-
expect(execute).toBeCalledTimes(21)
77-
expect(rmRF).toBeCalledTimes(1)
78-
expect(exportVariable).toBeCalledTimes(1)
76+
expect(execute).toHaveBeenCalledTimes(21)
77+
expect(rmRF).toHaveBeenCalledTimes(1)
78+
expect(exportVariable).toHaveBeenCalledTimes(1)
7979
})
8080

8181
it('should throw if an error is encountered', async () => {
@@ -92,8 +92,8 @@ describe('main', () => {
9292
isTest: TestFlag.HAS_CHANGED_FILES
9393
})
9494
await run(action)
95-
expect(execute).toBeCalledTimes(0)
96-
expect(setFailed).toBeCalledTimes(1)
97-
expect(exportVariable).toBeCalledTimes(1)
95+
expect(execute).toHaveBeenCalledTimes(0)
96+
expect(setFailed).toHaveBeenCalledTimes(1)
97+
expect(exportVariable).toHaveBeenCalledTimes(1)
9898
})
9999
})

__tests__/ssh.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ describe('configureSSH', () => {
5757

5858
await configureSSH(action)
5959

60-
expect(execute).toBeCalledTimes(0)
61-
expect(mkdirP).toBeCalledTimes(0)
62-
expect(appendFileSync).toBeCalledTimes(0)
60+
expect(execute).toHaveBeenCalledTimes(0)
61+
expect(mkdirP).toHaveBeenCalledTimes(0)
62+
expect(appendFileSync).toHaveBeenCalledTimes(0)
6363
})
6464

6565
it('should configure the ssh client if a key is defined', async () => {
@@ -82,9 +82,9 @@ describe('configureSSH', () => {
8282

8383
await configureSSH(action)
8484

85-
expect(execFileSync).toBeCalledTimes(1)
86-
expect(exportVariable).toBeCalledTimes(2)
87-
expect(execSync).toBeCalledTimes(3)
85+
expect(execFileSync).toHaveBeenCalledTimes(1)
86+
expect(exportVariable).toHaveBeenCalledTimes(2)
87+
expect(execSync).toHaveBeenCalledTimes(3)
8888
})
8989

9090
it('should not export variables if the return from ssh-agent is skewed', async () => {
@@ -107,9 +107,9 @@ describe('configureSSH', () => {
107107

108108
await configureSSH(action)
109109

110-
expect(execFileSync).toBeCalledTimes(1)
111-
expect(exportVariable).toBeCalledTimes(0)
112-
expect(execSync).toBeCalledTimes(3)
110+
expect(execFileSync).toHaveBeenCalledTimes(1)
111+
expect(exportVariable).toHaveBeenCalledTimes(0)
112+
expect(execSync).toHaveBeenCalledTimes(3)
113113
})
114114

115115
it('should throw if something errors', async () => {

__tests__/worktree.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ describe('generateWorktree', () => {
175175
'gh1'
176176
])
177177

178-
expect(async () => {
178+
return expect(async () => {
179179
await execute(
180180
'git log --format=%s',
181181
path.join(workspace, 'worktree'),
@@ -208,7 +208,7 @@ describe('generateWorktree', () => {
208208

209209
expect(dirEntries).toEqual(['.git'])
210210

211-
expect(async () => {
211+
return expect(async () => {
212212
await execute(
213213
'git log --format=%s',
214214
path.join(workspace, 'worktree'),

eslint.config.mjs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import eslintConfigPrettier from "eslint-config-prettier";
4+
import jest from "eslint-plugin-jest";
5+
6+
export default tseslint.config(
7+
eslintConfigPrettier,
8+
jest.configs['flat/recommended'],
9+
eslint.configs.recommended,
10+
...tseslint.configs.recommended,
11+
{
12+
languageOptions: {
13+
globals: {
14+
process: true,
15+
module: true,
16+
}
17+
},
18+
rules: {
19+
"jest/no-conditional-expect": "off",
20+
"@typescript-eslint/ban-types": [
21+
"error",
22+
{
23+
types: {
24+
"Number": {
25+
"message": "Use number instead",
26+
"fixWith": "number"
27+
},
28+
"String": {
29+
"message": "Use string instead",
30+
"fixWith": "string"
31+
},
32+
"Boolean": {
33+
"message": "Use boolean instead",
34+
"fixWith": "boolean"
35+
},
36+
"Object": {
37+
"message": "Use object instead",
38+
"fixWith": "object"
39+
},
40+
"{}": {
41+
"message": "Use object instead",
42+
"fixWith": "object"
43+
},
44+
"Symbol": {
45+
"message": "Use symbol instead",
46+
"fixWith": "symbol"
47+
}
48+
}
49+
}
50+
],
51+
"@typescript-eslint/array-type": ["error", {"default": "array"}],
52+
"@typescript-eslint/explicit-module-boundary-types": "error",
53+
"@typescript-eslint/no-explicit-any": "error",
54+
"@typescript-eslint/no-unused-vars": "error",
55+
"@typescript-eslint/explicit-function-return-type": "error",
56+
"object-shorthand": ["error", "always"],
57+
"prefer-destructuring": [
58+
"error",
59+
{
60+
"array": false,
61+
"object": true
62+
},
63+
{
64+
"enforceForRenamedProperties": false
65+
}
66+
],
67+
"no-console": ["error", {"allow": ["warn", "error"]}],
68+
"no-alert": "error",
69+
"no-debugger": "error"
70+
}
71+
}
72+
);

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
"@actions/core": "1.10.1",
3939
"@actions/exec": "1.1.1",
4040
"@actions/github": "6.0.0",
41-
"@actions/io": "1.1.3"
41+
"@actions/io": "1.1.3",
42+
"@eslint/js": "^9.0.0",
43+
"typescript-eslint": "^7.7.0"
4244
},
4345
"devDependencies": {
4446
"@types/jest": "29.5.12",

yarn.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@
653653
minimatch "^3.1.2"
654654
strip-json-comments "^3.1.1"
655655

656-
"@eslint/js@9.0.0":
656+
"@eslint/js@9.0.0", "@eslint/js@^9.0.0":
657657
version "9.0.0"
658658
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.0.0.tgz#1a9e4b4c96d8c7886e0110ed310a0135144a1691"
659659
integrity sha512-RThY/MnKrhubF6+s1JflwUjPEsnCEmYCWwqa/aRISKWNXGZ9epUwft4bUMM35SdKF9xvBrLydAM1RDHd1Z//ZQ==
@@ -3332,6 +3332,15 @@ type-fest@^0.8.1:
33323332
version "0.8.1"
33333333
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
33343334

3335+
typescript-eslint@^7.7.0:
3336+
version "7.7.0"
3337+
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-7.7.0.tgz#b755e350dad25bb1e5b3826d11daa973dc0970ac"
3338+
integrity sha512-wZZ+7mTQJCn4mGAvzdERtL4vwKGM/mF9cMSMeKUllz3Hgbd1Mdd5L60Q+nJmCio9RB4OyMMr0EX4Ry2Q7jiAyw==
3339+
dependencies:
3340+
"@typescript-eslint/eslint-plugin" "7.7.0"
3341+
"@typescript-eslint/parser" "7.7.0"
3342+
"@typescript-eslint/utils" "7.7.0"
3343+
33353344
typescript@5.4.5:
33363345
version "5.4.5"
33373346
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"

0 commit comments

Comments
 (0)
0