Skip to content

Commit

Permalink
chore(eslint): upgrade to eslint 9 (#987)
Browse files Browse the repository at this point in the history
* feat: bump dependencies and eslint

* Update fetch.test.ts

* fix: downgrade
  • Loading branch information
JamesIves authored Apr 18, 2024
1 parent 52257b9 commit 5d15c8c
Show file tree
Hide file tree
Showing 10 changed files with 1,003 additions and 714 deletions.
74 changes: 0 additions & 74 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Install Yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Install Yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
scope: '@jamesives'

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

Expand Down
3 changes: 2 additions & 1 deletion __tests__/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {retrieveData, generateExport} from '../src/fetch'
import nock from 'nock'

jest.setTimeout(1000000)
nock.enableNetConnect()

describe('fetch', () => {
describe('retrieveData', () => {
Expand All @@ -20,7 +21,7 @@ describe('fetch', () => {
expect(data).toEqual('{"data":"12345"}')
})

it('should handle the triple bracket replacements ', async () => {
it('should handle the triple bracket replacements', async () => {
nock('https://jives.dev/')
.post('/', '{"bestCat":"montezuma"}')
.reply(200, {
Expand Down
8 changes: 4 additions & 4 deletions __tests__/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('lib', () => {
})
await run(action)

expect(exportVariable).toBeCalled()
expect(exportVariable).toHaveBeenCalled()
})

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

expect(exportVariable).toBeCalledTimes(0)
expect(exportVariable).toHaveBeenCalledTimes(0)
})

it('should throw an error if no endpoint is provided', async () => {
Expand All @@ -58,7 +58,7 @@ describe('lib', () => {
try {
await run(action)
} catch (error) {
expect(setFailed).toBeCalled()
expect(setFailed).toHaveBeenCalled()
}
})

Expand All @@ -73,7 +73,7 @@ describe('lib', () => {
try {
await run(action)
} catch (error) {
expect(setFailed).toBeCalled()
expect(setFailed).toHaveBeenCalled()
}
})
})
72 changes: 72 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import eslintConfigPrettier from 'eslint-config-prettier'
import jest from 'eslint-plugin-jest'

export default tseslint.config(
eslintConfigPrettier,
jest.configs['flat/recommended'],
eslint.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
globals: {
process: true,
module: true
}
},
rules: {
'jest/no-conditional-expect': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
Number: {
message: 'Use number instead',
fixWith: 'number'
},
String: {
message: 'Use string instead',
fixWith: 'string'
},
Boolean: {
message: 'Use boolean instead',
fixWith: 'boolean'
},
Object: {
message: 'Use object instead',
fixWith: 'object'
},
'{}': {
message: 'Use object instead',
fixWith: 'object'
},
Symbol: {
message: 'Use symbol instead',
fixWith: 'symbol'
}
}
}
],
'@typescript-eslint/array-type': ['error', {default: 'array'}],
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'object-shorthand': ['error', 'always'],
'prefer-destructuring': [
'error',
{
array: false,
object: true
},
{
enforceForRenamedProperties: false
}
],
'no-console': ['error', {allow: ['warn', 'error']}],
'no-alert': 'error',
'no-debugger': 'error'
}
}
)
32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,30 @@
"github-action"
],
"dependencies": {
"@actions/core": "1.10.0",
"@actions/core": "1.10.1",
"@actions/io": "1.1.3",
"async-retry": "1.3.3",
"cross-fetch": "4.0.0",
"mustache": "4.2.0"
},
"devDependencies": {
"@types/async-retry": "1.4.3",
"@types/jest": "27.5.0",
"@types/mustache": "4.2.2",
"@types/node": "20.11.16",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.54.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-jest": "27.6.3",
"eslint-plugin-prettier": "4.2.1",
"@types/async-retry": "1.3.0",
"@types/jest": "29.5.12",
"@types/mustache": "4.2.5",
"@types/node": "20.12.7",
"@types/retry": "0.12.5",
"@typescript-eslint/eslint-plugin": "7.7.0",
"@typescript-eslint/parser": "7.7.0",
"eslint": "9.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.2.0",
"eslint-plugin-prettier": "5.1.3",
"jest": "27.5.1",
"jest-circus": "27.5.1",
"nock": "13.5.0",
"prettier": "2.8.4",
"ts-jest": "27.1.4",
"typescript": "4.9.5"
"nock": "13.5.4",
"prettier": "3.2.5",
"ts-jest": "29.1.2",
"typescript": "5.4.5",
"typescript-eslint": "7.7.0"
}
}
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const extractErrorMessage = (error: unknown): string =>
error instanceof Error
? error.message
: typeof error == 'string'
? error
: JSON.stringify(error)
? error
: JSON.stringify(error)

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

0 comments on commit 5d15c8c

Please sign in to comment.