From 63a443ed30b801d849f044ccd251ff9280730210 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 23 Dec 2023 04:02:38 +0100 Subject: [PATCH] [MIRROR] Fixes radar issues [MDB IGNORE] (#25785) * Fixes radar issues (#80453) ## About The Pull Request Went through tgui:sonar to search for bugs. Some of these are valid - they've been addressed. Others, not so. Telling me I need to make icon names and css classes into constants is a nit at best. Radar seems to be bugged in certain areas: Classnames ok to dupe, but not ones with conditionals. Most of the function duplication errors rely on hooks. I think this should close #79815 and we should remove radar shortly after. See my comment [here](https://github.com/tgstation/tgstation/issues/79815#issuecomment-1859286784) ## Why It's Good For The Game Fixes #79815 ## Changelog N/A none of this was player facing * Fixes radar issues --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> --- tgui/packages/common/redux.ts | 2 +- tgui/packages/tgui-dev-server/link/client.cjs | 64 +++++++------- tgui/packages/tgui-dev-server/winreg.js | 4 +- tgui/packages/tgui/components/Button.tsx | 1 - tgui/packages/tgui/components/Input.tsx | 2 - tgui/packages/tgui/events.ts | 1 - .../tgui/interfaces/BasketballPanel.tsx | 2 +- .../tgui/interfaces/CellularEmporium.tsx | 3 +- .../tgui/interfaces/CommandReport.tsx | 18 ++-- .../interfaces/Fabrication/DesignBrowser.tsx | 20 ++--- .../tgui/interfaces/NumberInputModal.tsx | 12 +-- .../packages/tgui/interfaces/Orbit/helpers.ts | 13 +-- tgui/packages/tgui/interfaces/PaperSheet.tsx | 84 +++++++------------ .../tgui/interfaces/PlaneMasterDebug.tsx | 26 +++--- .../tgui/interfaces/PrisonerManagement.tsx | 25 +++--- tgui/packages/tgui/layouts/NtosWindow.tsx | 2 +- tgui/packages/tgui/renderer.ts | 19 +++-- tgui/packages/tgui/routes.tsx | 1 + 18 files changed, 125 insertions(+), 174 deletions(-) diff --git a/tgui/packages/common/redux.ts b/tgui/packages/common/redux.ts index 997cc1d2d68..c8eb268f5d4 100644 --- a/tgui/packages/common/redux.ts +++ b/tgui/packages/common/redux.ts @@ -95,7 +95,7 @@ export const applyMiddleware = ( return (reducer, ...args): Store => { const store = createStoreFunction(reducer, ...args); - let dispatch: Dispatch = () => { + let dispatch: Dispatch = (action, ...args) => { throw new Error( 'Dispatching while constructing your middleware is not allowed.', ); diff --git a/tgui/packages/tgui-dev-server/link/client.cjs b/tgui/packages/tgui-dev-server/link/client.cjs index 1e21d42ce86..b0e6f7bc9d4 100644 --- a/tgui/packages/tgui-dev-server/link/client.cjs +++ b/tgui/packages/tgui-dev-server/link/client.cjs @@ -31,11 +31,9 @@ const ensureConnection = () => { }; } } -}; -if (process.env.NODE_ENV !== 'production') { window.onunload = () => socket && socket.close(); -} +}; const subscribe = (fn) => subscribers.push(fn); @@ -136,38 +134,38 @@ const sendLogEntry = (level, ns, ...args) => { const setupHotReloading = () => { if ( - // prettier-ignore - process.env.NODE_ENV !== 'production' - && process.env.WEBPACK_HMR_ENABLED - && window.WebSocket + process.env.NODE_ENV === 'production' || + !process.env.WEBPACK_HMR_ENABLED || + !window.WebSocket ) { - if (module.hot) { - ensureConnection(); - sendLogEntry(0, null, 'setting up hot reloading'); - subscribe((msg) => { - const { type } = msg; - sendLogEntry(0, null, 'received', type); - if (type === 'hotUpdate') { - const status = module.hot.status(); - if (status !== 'idle') { - sendLogEntry(0, null, 'hot reload status:', status); - return; - } - module.hot - .check({ - ignoreUnaccepted: true, - ignoreDeclined: true, - ignoreErrored: true, - }) - .then((modules) => { - sendLogEntry(0, null, 'outdated modules', modules); - }) - .catch((err) => { - sendLogEntry(0, null, 'reload error', err); - }); + return; + } + if (module.hot) { + ensureConnection(); + sendLogEntry(0, null, 'setting up hot reloading'); + subscribe((msg) => { + const { type } = msg; + sendLogEntry(0, null, 'received', type); + if (type === 'hotUpdate') { + const status = module.hot.status(); + if (status !== 'idle') { + sendLogEntry(0, null, 'hot reload status:', status); + return; } - }); - } + module.hot + .check({ + ignoreUnaccepted: true, + ignoreDeclined: true, + ignoreErrored: true, + }) + .then((modules) => { + sendLogEntry(0, null, 'outdated modules', modules); + }) + .catch((err) => { + sendLogEntry(0, null, 'reload error', err); + }); + } + }); } }; diff --git a/tgui/packages/tgui-dev-server/winreg.js b/tgui/packages/tgui-dev-server/winreg.js index 4f66d715950..43a41701907 100644 --- a/tgui/packages/tgui-dev-server/winreg.js +++ b/tgui/packages/tgui-dev-server/winreg.js @@ -36,8 +36,8 @@ export const regQuery = async (path, key) => { logger.error('could not find the start of the key value'); return null; } - const value = stdout.substring(indexOfValue + 4, indexOfEol); - return value; + + return stdout.substring(indexOfValue + 4, indexOfEol); } catch (err) { logger.error(err); return null; diff --git a/tgui/packages/tgui/components/Button.tsx b/tgui/packages/tgui/components/Button.tsx index 8dd52d9e2ad..4feff290cc9 100644 --- a/tgui/packages/tgui/components/Button.tsx +++ b/tgui/packages/tgui/components/Button.tsx @@ -125,7 +125,6 @@ export const Button = (props: Props) => { // Refocus layout on pressing escape. if (event.key === KEY.Escape) { event.preventDefault(); - return; } }} {...computeBoxProps(rest)} diff --git a/tgui/packages/tgui/components/Input.tsx b/tgui/packages/tgui/components/Input.tsx index d9ecf31e908..ae3c9b6ac6f 100644 --- a/tgui/packages/tgui/components/Input.tsx +++ b/tgui/packages/tgui/components/Input.tsx @@ -70,8 +70,6 @@ export const Input = (props: Props) => { event.currentTarget.value = toInputValue(value); event.currentTarget.blur(); - - return; } }; diff --git a/tgui/packages/tgui/events.ts b/tgui/packages/tgui/events.ts index a31f4821d6e..cc53d31bfab 100644 --- a/tgui/packages/tgui/events.ts +++ b/tgui/packages/tgui/events.ts @@ -122,7 +122,6 @@ window.addEventListener('focusin', (e) => { setWindowFocus(true); if (canStealFocus(e.target as HTMLElement)) { stealFocus(e.target as HTMLElement); - return; } }); diff --git a/tgui/packages/tgui/interfaces/BasketballPanel.tsx b/tgui/packages/tgui/interfaces/BasketballPanel.tsx index d33f59d0797..f349b5137da 100644 --- a/tgui/packages/tgui/interfaces/BasketballPanel.tsx +++ b/tgui/packages/tgui/interfaces/BasketballPanel.tsx @@ -40,7 +40,7 @@ export const BasketballPanel = (props) => { />