Skip to content

Commit

Permalink
[Tech] Update just about all of our dependencies (Heroic-Games-Launch…
Browse files Browse the repository at this point in the history
…er#2525)

* Update just about all of our dependencies

Notable changes:
- `filesize`'s type definitions don't seem right to me. I've overwritten
  those with something that *works*
- `react-i18next` does not export `TFunction` anymore, but `i18next`
  (now?) does
- `typescript-eslint` got smarter, which meant having to add `async` to
  some functions that only returned Promises sometimes
- `i18next`'s `t` function can return null by default. We've already
  disabled this in it our initialization functions, but our types didn't
  know about this yet
- Jest seems to no longer specify the type of a thing in a snapshot
  (`Array []` -> `[]`)

* Filter out `satisfies`-related errors in `find-deadcode`

To be clear, this is absolutely meant as a temporary solution until
*someone* picks up ts-prune and updates it to support this by itself

How this works:
- The `find-deadcode` script filters out lines containing `satisfies`
  along with the line directly after (which contains the token directly
  after `satisfies`
- By piping the output into `sed`, the original return value of
  `ts-prune` is lost (so it'll no longer fail the workflow if issues are
  found). To fix this, in the workflow, we pipe *that* output to `wc -l`
  (counting output lines) and make sure that's less than 4 (the 3
  allowed lines are produced by Yarn, so they'll always be there)

* Replace ts-prune with unimported

* Review fixes

* Revert "Filter out `satisfies`-related errors in `find-deadcode`"

This reverts commit 28b5191.

* Install a specific version of ts-morph to resolve ts-prune issues

* Re-introduce ts-prune

* Some more updates

---------

Co-authored-by: Nocccer <[email protected]>
  • Loading branch information
CommandMC and Nocccer authored Mar 17, 2023
1 parent c77a344 commit 38fa46d
Show file tree
Hide file tree
Showing 13 changed files with 2,212 additions and 1,417 deletions.
27 changes: 27 additions & 0 deletions .unimportedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"rootDir": "./src",
"preset": "node",
"entry": [
"src/frontend/index.tsx",
"src/backend/main.ts",
"src/backend/preload.ts"
],
"aliases": {
"backend/*": ["./backend", "./backend/*"],
"common/*": ["./common", "./common/*"],
"frontend/*": ["./frontend", "./frontend/*"]
},
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"ignorePatterns": [
"**/node_modules/**",
"**/__tests__/**",
"**/__mocks__/**",
"common/typedefs/*.d.ts"
],
"ignoreUnimported": [
"src/backend/jest.config.js",
"src/common/types/proxy-types.ts"
],
"ignoreUnused": ["@fontsource/cabin", "@fontsource/rubik", "tslib"],
"ignoreUnresolved": ["../../tsconfig", "./writable.js", "type-fest"]
}
105 changes: 54 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,52 +122,50 @@
}
},
"dependencies": {
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@fontsource/cabin": "^4.5.5",
"@fontsource/rubik": "^4.5.6",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@mui/icons-material": "^5.10.9",
"@mui/material": "^5.10.12",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@fontsource/cabin": "^4.5.10",
"@fontsource/rubik": "^4.5.14",
"@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-brands-svg-icons": "^6.3.0",
"@fortawesome/free-regular-svg-icons": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.12",
"@node-steam/vdf": "^2.2.0",
"@shockpkg/icon-encoder": "^2.1.3",
"axios": "^0.26.1",
"check-disk-space": "^3.3.1",
"classnames": "^2.3.1",
"crc": "^4.1.1",
"crc": "^4.3.2",
"discord-rich-presence-typescript": "^0.0.8",
"electron-store": "^8.0.1",
"electron-updater": "^5.0.1",
"filesize": "^8.0.7",
"filesize": "^10.0.6",
"font-list": "^1.4.5",
"fs-extra": "^10.1.0",
"fs-extra": "^11.1.0",
"fuse.js": "^6.6.2",
"graceful-fs": "^4.2.10",
"howlongtobeat": "^1.7.0",
"i18next": "^21.6.16",
"i18next-fs-backend": "^1.1.4",
"i18next-http-backend": "^1.4.0",
"i18next": "^22.4.11",
"i18next-fs-backend": "^2.1.1",
"i18next-http-backend": "^2.1.1",
"ini": "^3.0.0",
"plist": "^3.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^11.16.7",
"react-markdown": "^8.0.3",
"react-router-dom": "^6.3.0",
"recharts": "^2.1.14",
"react-i18next": "^12.2.0",
"react-markdown": "^8.0.5",
"react-router-dom": "^6.9.0",
"recharts": "^2.4.3",
"sanitize-filename": "^1.6.3",
"shlex": "^2.1.2",
"short-uuid": "^4.2.0",
"simple-keyboard": "^3.4.136",
"source-map-support": "^0.5.21",
"short-uuid": "^4.2.2",
"simple-keyboard": "^3.5.33",
"steam-shortcut-editor": "^3.1.1",
"systeminformation": "^5.15.0",
"ts-prune": "^0.10.3",
"tslib": "^2.4.0"
"systeminformation": "^5.17.12",
"tslib": "^2.5.0"
},
"scripts": {
"start": "vite",
Expand Down Expand Up @@ -201,42 +199,47 @@
]
},
"devDependencies": {
"@testing-library/dom": "^7.31.0",
"@testing-library/dom": "^9.0.1",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.1.1",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.1.1",
"@types/classnames": "^2.3.1",
"@types/i18next-fs-backend": "^1.1.2",
"@types/ini": "^1.3.31",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.25",
"@types/jest": "^29.4.0",
"@types/node": "^18.15.0",
"@types/plist": "^3.0.2",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/react-router-dom": "^5.3.3",
"@types/tmp": "^0.2.3",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"@vitejs/plugin-react": "^2.2.0",
"electron": "^22.2.0",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"@vitejs/plugin-react": "^3.0.0",
"electron": "^23.1.3",
"electron-builder": "^23.6.0",
"electron-devtools-installer": "^3.2.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-react": "^7.29.4",
"husky": "^7.0.4",
"i18next-parser": "^6.3.0",
"jest": "^28.1.3",
"prettier": "^2.6.2",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.31.11",
"husky": "^8.0.3",
"i18next-parser": "^7.7.0",
"jest": "^29.5.0",
"prettier": "^2.8.1",
"pretty-quick": "^3.1.3",
"sass": "^1.55.0",
"sass": "^1.59.2",
"tmp": "^0.2.1",
"ts-jest": "^28.0.7",
"type-fest": "^3.2.0",
"typescript": "^4.8.4",
"vite": "^3.2.2",
"ts-jest": "^29.0.5",
"ts-prune": "^0.10.3",
"type-fest": "^3.6.1",
"typescript": "^4.9.4",
"unimported": "^1.26.0",
"vite": "^4.0.3",
"vite-plugin-electron": "^0.10.2",
"vite-plugin-svgr": "^2.2.2"
"vite-plugin-svgr": "^2.4.0"
},
"resolutions": {
"ts-morph": "^17.0.1"
}
}
14 changes: 7 additions & 7 deletions src/backend/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe('backend/utils.ts', () => {

const releases = await utils.getLatestReleases()
expect(releases).toMatchInlineSnapshot(`
Array [
Object {
[
{
"body": "2.5.2 HOTFIX #2 Release",
"html_url": "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/tag/v2.5.2",
"id": 200,
Expand All @@ -77,7 +77,7 @@ describe('backend/utils.ts', () => {
"tag_name": "v2.5.2",
"type": "stable",
},
Object {
{
"body": "2.6.0 Beta Release",
"html_url": "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/tag/v2.6.0-beta.1",
"id": 100,
Expand All @@ -97,8 +97,8 @@ describe('backend/utils.ts', () => {

const releases = await utils.getLatestReleases()
expect(releases).toMatchInlineSnapshot(`
Array [
Object {
[
{
"body": "2.6.0 Beta Release",
"html_url": "https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/tag/v2.6.0-beta.1",
"id": 100,
Expand All @@ -117,7 +117,7 @@ describe('backend/utils.ts', () => {
jest.spyOn(app, 'getVersion').mockReturnValueOnce('')

const releases = await utils.getLatestReleases()
expect(releases).toMatchInlineSnapshot(`Array []`)
expect(releases).toMatchInlineSnapshot(`[]`)
})

test('Fetching available releases fails', async () => {
Expand All @@ -128,7 +128,7 @@ describe('backend/utils.ts', () => {
['Error when checking for Heroic updates', 'Failed to fetch!'],
'Backend'
)
expect(releases).toMatchInlineSnapshot(`Array []`)
expect(releases).toMatchInlineSnapshot(`[]`)
})
})
})
4 changes: 2 additions & 2 deletions src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
gogInstallInfoStore as GOGinstallInfoStore,
libraryStore as GOGlibraryStore
} from './gog/electronStores'
import fileSize from 'filesize'
import * as fileSize from 'filesize'
import makeClient from 'discord-rich-presence-typescript'
import { notify, showDialogBoxModalAuto } from './dialog/dialog'
import { getAppInfo } from './sideload/games'
Expand Down Expand Up @@ -115,7 +115,7 @@ function semverGt(target: string, base: string) {
return isGE
}

const getFileSize = fileSize.partial({ base: 2 })
const getFileSize = fileSize.partial({ base: 2 }) as (arg: unknown) => string

function getWineFromProton(
wineVersion: WineInstallation,
Expand Down
8 changes: 8 additions & 0 deletions src/common/typedefs/i18next.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// i18next.d.ts
import 'i18next'

declare module 'i18next' {
interface CustomTypeOptions {
returnNull: false
}
}
4 changes: 2 additions & 2 deletions src/frontend/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LegendaryInstallInfo } from 'common/types/legendary'
import { GogInstallInfo } from 'common/types/gog'

import { install, launch, repair, updateGame } from './library'
import fileSize from 'filesize'
import * as fileSize from 'filesize'
const readFile = window.api.readConfig

const writeConfig = window.api.writeConfig
Expand All @@ -27,7 +27,7 @@ const handleQuit = window.api.quit

const openDiscordLink = window.api.openDiscordLink

export const size = fileSize.partial({ base: 2 })
export const size = fileSize.partial({ base: 2 }) as (arg: unknown) => string

const sendKill = window.api.kill

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/helpers/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
UpdateParams
} from 'common/types'

import { TFunction } from 'react-i18next'
import { TFunction } from 'i18next'
import { getGameInfo, sendKill } from './index'
import { DialogModalOptions } from 'frontend/types'

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/hooks/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Runner, Status } from 'common/types'
import { TFunction } from 'react-i18next'
import { TFunction } from 'i18next'

type StatusArgs = {
status: Status
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/screens/Library/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Category } from 'frontend/types'
import { TFunction } from 'react-i18next'
import { TFunction } from 'i18next'

export function getLibraryTitle(
category: Category,
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/screens/Settings/components/EgsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const EgsSettings = () => {
})
}

function handleEgsFolder() {
async function handleEgsFolder() {
if (isLinked) {
return ''
}
Expand Down Expand Up @@ -107,7 +107,7 @@ const EgsSettings = () => {
}
onIconClick={
!egsPath.length
? () => handleEgsFolder()
? async () => handleEgsFolder()
: () => (isLinked ? '' : setEgsPath(''))
}
afterInput={
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/screens/Settings/components/Tools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function Tools() {
}
}

function dropHandler(ev: React.DragEvent<HTMLSpanElement>) {
async function dropHandler(ev: React.DragEvent<HTMLSpanElement>) {
// Prevent default behavior (Prevent file from being opened)
ev.preventDefault()

Expand Down Expand Up @@ -129,7 +129,7 @@ export default function Tools() {
<span className="toolTitle">Winetricks</span>
</button>
<a
onDrop={(ev) => dropHandler(ev)}
onDrop={async (ev) => dropHandler(ev)}
onDragOver={(ev) => dragOverHandler(ev)}
className="button outline drag"
onClick={handleRunExe}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/state/GlobalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
DialogModalOptions,
ExternalLinkDialogOptions
} from 'frontend/types'
import { TFunction, withTranslation } from 'react-i18next'
import { withTranslation } from 'react-i18next'
import {
getGameInfo,
getLegendaryConfig,
Expand All @@ -27,7 +27,7 @@ import {
launch,
notify
} from '../helpers'
import { i18n, t } from 'i18next'
import { i18n, t, TFunction } from 'i18next'

import ContextProvider from './ContextProvider'

Expand Down
Loading

0 comments on commit 38fa46d

Please sign in to comment.