Skip to content

Commit 5d15c8c

Browse files
authored
chore(eslint): upgrade to eslint 9 (JamesIves#987)
* feat: bump dependencies and eslint * Update fetch.test.ts * fix: downgrade
1 parent 52257b9 commit 5d15c8c

File tree

10 files changed

+1003
-714
lines changed

10 files changed

+1003
-714
lines changed

.eslintrc.json

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version: '20.10.0'
22+
node-version-file: '.nvmrc'
2323
registry-url: 'https://registry.npmjs.org'
2424

2525
- name: Install Yarn

.github/workflows/production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- uses: actions/setup-node@v4
2020
with:
21-
node-version: '20.10.0'
21+
node-version-file: '.nvmrc'
2222
registry-url: 'https://registry.npmjs.org'
2323

2424
- name: Install Yarn

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
# Setup .npmrc file to publish to npm
1818
- uses: actions/setup-node@v4
1919
with:
20-
node-version: '20.10.0'
20+
node-version-file: '.nvmrc'
2121
registry-url: 'https://registry.npmjs.org'
2222
scope: '@jamesives'
2323

@@ -42,7 +42,7 @@ jobs:
4242
# Setup .npmrc file to publish to GitHub Packages
4343
- uses: actions/setup-node@v4
4444
with:
45-
node-version: '20.10.0'
45+
node-version-file: '.nvmrc'
4646
registry-url: 'https://npm.pkg.github.com'
4747
scope: '@jamesives'
4848

__tests__/fetch.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {retrieveData, generateExport} from '../src/fetch'
22
import nock from 'nock'
33

44
jest.setTimeout(1000000)
5+
nock.enableNetConnect()
56

67
describe('fetch', () => {
78
describe('retrieveData', () => {
@@ -20,7 +21,7 @@ describe('fetch', () => {
2021
expect(data).toEqual('{"data":"12345"}')
2122
})
2223

23-
it('should handle the triple bracket replacements ', async () => {
24+
it('should handle the triple bracket replacements', async () => {
2425
nock('https://jives.dev/')
2526
.post('/', '{"bestCat":"montezuma"}')
2627
.reply(200, {

__tests__/lib.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('lib', () => {
3535
})
3636
await run(action)
3737

38-
expect(exportVariable).toBeCalled()
38+
expect(exportVariable).toHaveBeenCalled()
3939
})
4040

4141
it('should run through the commands but not save output', async () => {
@@ -46,7 +46,7 @@ describe('lib', () => {
4646
})
4747
await run(action)
4848

49-
expect(exportVariable).toBeCalledTimes(0)
49+
expect(exportVariable).toHaveBeenCalledTimes(0)
5050
})
5151

5252
it('should throw an error if no endpoint is provided', async () => {
@@ -58,7 +58,7 @@ describe('lib', () => {
5858
try {
5959
await run(action)
6060
} catch (error) {
61-
expect(setFailed).toBeCalled()
61+
expect(setFailed).toHaveBeenCalled()
6262
}
6363
})
6464

@@ -73,7 +73,7 @@ describe('lib', () => {
7373
try {
7474
await run(action)
7575
} catch (error) {
76-
expect(setFailed).toBeCalled()
76+
expect(setFailed).toHaveBeenCalled()
7777
}
7878
})
7979
})

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: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,30 @@
3535
"github-action"
3636
],
3737
"dependencies": {
38-
"@actions/core": "1.10.0",
38+
"@actions/core": "1.10.1",
3939
"@actions/io": "1.1.3",
4040
"async-retry": "1.3.3",
4141
"cross-fetch": "4.0.0",
4242
"mustache": "4.2.0"
4343
},
4444
"devDependencies": {
45-
"@types/async-retry": "1.4.3",
46-
"@types/jest": "27.5.0",
47-
"@types/mustache": "4.2.2",
48-
"@types/node": "20.11.16",
49-
"@typescript-eslint/eslint-plugin": "5.62.0",
50-
"@typescript-eslint/parser": "5.62.0",
51-
"eslint": "8.54.0",
52-
"eslint-config-prettier": "9.0.0",
53-
"eslint-plugin-jest": "27.6.3",
54-
"eslint-plugin-prettier": "4.2.1",
45+
"@types/async-retry": "1.3.0",
46+
"@types/jest": "29.5.12",
47+
"@types/mustache": "4.2.5",
48+
"@types/node": "20.12.7",
49+
"@types/retry": "0.12.5",
50+
"@typescript-eslint/eslint-plugin": "7.7.0",
51+
"@typescript-eslint/parser": "7.7.0",
52+
"eslint": "9.0.0",
53+
"eslint-config-prettier": "9.1.0",
54+
"eslint-plugin-jest": "28.2.0",
55+
"eslint-plugin-prettier": "5.1.3",
5556
"jest": "27.5.1",
5657
"jest-circus": "27.5.1",
57-
"nock": "13.5.0",
58-
"prettier": "2.8.4",
59-
"ts-jest": "27.1.4",
60-
"typescript": "4.9.5"
58+
"nock": "13.5.4",
59+
"prettier": "3.2.5",
60+
"ts-jest": "29.1.2",
61+
"typescript": "5.4.5",
62+
"typescript-eslint": "7.7.0"
6163
}
6264
}

src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export const extractErrorMessage = (error: unknown): string =>
1717
error instanceof Error
1818
? error.message
1919
: typeof error == 'string'
20-
? error
21-
: JSON.stringify(error)
20+
? error
21+
: JSON.stringify(error)
2222

2323
/* Attempt to parse data as JSON and catch any errors. */
2424
export const parseData = (data: string): Record<string, unknown> | null => {

0 commit comments

Comments
 (0)