Skip to content

Commit

Permalink
Update typescript, eslint, and other deps (eslint style updates inclu…
Browse files Browse the repository at this point in the history
…ded)
  • Loading branch information
anoek committed Dec 10, 2024
1 parent 053c504 commit 67acc4f
Show file tree
Hide file tree
Showing 39 changed files with 822 additions and 759 deletions.
9 changes: 6 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
import stylistic from "@stylistic/eslint-plugin";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -31,6 +32,7 @@ export default [
prettier,
"react-hooks": fixupPluginRules(reactHooks),
"@typescript-eslint": typescriptEslint,
"@stylistic": stylistic,
},

languageOptions: {
Expand Down Expand Up @@ -63,8 +65,9 @@ export default [
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/member-delimiter-style": "error",
"@stylistic/member-delimiter-style": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-empty-object-type": "off",

"@typescript-eslint/no-inferrable-types": [
"error",
Expand All @@ -84,8 +87,8 @@ export default [

"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/semi": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@stylistic/semi": "error",
"@stylistic/type-annotation-spacing": "error",
"computed-property-spacing": ["error", "never"],
curly: "error",
"eol-last": "error",
Expand Down
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"defaults"
],
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"@eslint/compat": "^1.2.4",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "=9.14.0",
"@google-cloud/translate": "^7.0.3",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.2.0",
Expand All @@ -40,22 +40,23 @@
"@types/react-linkify": "^1.0.4",
"@types/testing-library__jest-dom": "^5.14.5",
"@types/valid-url": "^1.0.7",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"@stylistic/eslint-plugin": "^2.12.0",
"autoprefixer": "^10.4.19",
"body-parser": "^1.20.2",
"circular-dependency-plugin": "^5.2.2",
"cspell": "^8.3.2",
"css-what": "^6.1.0",
"cssnano": "^6.0.1",
"deepl-node": "^1.10.1",
"eslint": "^9.7.0",
"eslint": "=9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^46.9.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.6.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-unicorn": "^49.0.0",
"express": "^4.19.2",
"express-http-proxy": "^2.0.0",
Expand All @@ -64,12 +65,12 @@
"goban": "=8.3.72",
"gulp": "^5.0.0",
"gulp-clean-css": "^4.3.0",
"gulp-eslint-new": "^2.2.0",
"gulp-eslint-new": "^2.4.0",
"gulp-livereload": "^4.0.2",
"gulp-postcss": "^9.0.0",
"gulp-rename": "^2.0.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-stylus": "^2.7.0",
"gulp-stylus": "^3.0.1",
"html-minifier": "4.0.0",
"husky": "^8.0.1",
"jest": "^29.7.0",
Expand All @@ -84,12 +85,12 @@
"prettier-eslint": "^16.3.0",
"pump": "^3.0.0",
"source-map-loader": "^4.0.0",
"stylus": "0.60.0",
"stylus": "0.64.0",
"supervisor": "^0.12.0",
"ts-jest": "^29.1.1",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"typescript": "=5.5.4",
"webpack": "^5.94.0",
"typescript": "=5.7.2",
"webpack": "^5.97.1",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
"xgettext-js": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChallengeLinkButton/ChallengeLinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function copyChallengeLinkURL(ack_target: HTMLElement, uuid: string): voi
// ... give them the whole thing to copy...
showChallengeLink(challenge_link, ack_target),
);
} catch (e) {
} catch {
// Their browser doesn't even know about navigator.clipboard?
showChallengeLink(challenge_link, ack_target);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChallengeModal/ChallengeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export class ChallengeModalBody extends React.Component<
$("#challenge-goban-height").focus();
return false;
}
} catch (e) {
} catch {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chat/ChatLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ function ChatLines({
setTimeout(() => {
try {
div.scrollTop = div.scrollHeight;
} catch (e) {
} catch {
// ignore error
}
}, 100);
Expand Down
4 changes: 2 additions & 2 deletions src/components/MiniGoban/MiniGoban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function MiniGoban(props: MiniGobanProps): JSX.Element {
.catch(() => {
console.log("Couldn't work out black rank");
});
} catch (e) {
} catch {
console.log("Couldn't work out who played black");
}
}
Expand All @@ -203,7 +203,7 @@ export function MiniGoban(props: MiniGobanProps): JSX.Element {
.catch(() => {
console.log("Couldn't work out white rank");
});
} catch (e) {
} catch {
console.log("Couldn't work out who played black");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Notifications/NotificationManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function emitNotification(title: string, body: string, cb?: () => void) {
emitNotification(title, body, cb);
})
.catch((err: any) => console.error(err));
} catch (e) {
} catch {
/* deprecated usage, but only way supported on safari currently */
void Notification.requestPermission(() => {
emitNotification(title, body, cb);
Expand Down Expand Up @@ -493,7 +493,7 @@ export class NotificationManager {
}
emitNotification(title, body);
}
} catch (e) {
} catch {
// ignore error
}
}
Expand Down
15 changes: 11 additions & 4 deletions src/components/OgsHelpProvider/OgsHelpProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export function OgsHelpProvider(props: OgsHelpProviderProps): JSX.Element {

React.useEffect(() => {
data.events.on("remote_data_sync_complete", () => {
debugDynamicHelp && console.log("Telling RDH: Storage loaded");
if (debugDynamicHelp) {
console.log("Telling RDH: Storage loaded");
}
setStorageLoaded(true);
});
}, []);
Expand All @@ -60,21 +62,26 @@ export function OgsHelpProvider(props: OgsHelpProviderProps): JSX.Element {
const dynamicHelpStorage: DynamicHelp.DynamicHelpStorageAPI = {
saveState: (rdhState: string) => {
if (storageLoaded) {
debugDynamicHelp &&
if (debugDynamicHelp) {
console.log("Writing rdhState", user.username, user.id, rdhState);
}
return data.set(
"rdh-system-state",
rdhState,
data.Replication.REMOTE_OVERWRITES_LOCAL,
) as string;
} else {
debugDynamicHelp && console.log("NOT writing rdhState");
if (debugDynamicHelp) {
console.log("NOT writing rdhState");
}
return rdhState;
}
},
getState: (defaultValue?: string) => {
const new_state = data.get("rdh-system-state", defaultValue || "");
debugDynamicHelp && console.log("Read rdhState", user.username, user.id, new_state);
if (debugDynamicHelp) {
console.log("Read rdhState", user.username, user.id, new_state);
}
return new_state;
},
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/PaginatedTable/PaginatedTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ export interface PaginatedTableRef {
}

export const PaginatedTable = React.forwardRef<PaginatedTableRef, PaginatedTableProperties<any>>(
_PaginatedTable,
PaginatedTableImpl,
) as <RawEntryT = any, GroomedEntryT = RawEntryT>(
props: PaginatedTableProperties<RawEntryT, GroomedEntryT> & {
ref?: React.ForwardedRef<PaginatedTableRef>;
},
) => ReturnType<typeof _PaginatedTable>;
) => ReturnType<typeof PaginatedTableImpl>;

function _PaginatedTable<RawEntryT = any, GroomedEntryT = RawEntryT>(
function PaginatedTableImpl<RawEntryT = any, GroomedEntryT = RawEntryT>(
props: PaginatedTableProperties<RawEntryT, GroomedEntryT>,
ref: React.ForwardedRef<PaginatedTableRef>,
): JSX.Element {
Expand Down
4 changes: 2 additions & 2 deletions src/components/PlayerAutocomplete/PlayerAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ interface SuggestionEntry {
export const PlayerAutocomplete = React.forwardRef<
PlayerAutocompleteRef,
PlayerAutocompleteProperties
>(_PlayerAutocomplete);
>(PlayerAutocompleteImpl);

function _PlayerAutocomplete(
function PlayerAutocompleteImpl(
props: PlayerAutocompleteProperties,
ref: React.ForwardedRef<PlayerAutocompleteRef>,
): JSX.Element {
Expand Down
8 changes: 4 additions & 4 deletions src/components/Report/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ export function Report(props: ReportProperties): JSX.Element {
})
.then(() => {
set_submitting(false);
onClose && onClose();
onClose?.();
void alert.fire({ text: _("Thanks for the report!") });
})
.catch(() => {
set_submitting(false);
onClose && onClose();
onClose?.();
void alert.fire({ text: _("There was an error submitting your report") });
});
}
Expand All @@ -326,12 +326,12 @@ export function Report(props: ReportProperties): JSX.Element {
post("moderation/warn", { user_id: reported_user_id, text: note })
.then(() => {
set_submitting(false);
onClose && onClose();
onClose?.();
void alert.fire("Warning sent");
})
.catch(() => {
set_submitting(false);
onClose && onClose();
onClose?.();
void alert.fire({ text: _("There was an error submitting the warning!") });
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/SeekGraph/SeekGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ export class SeekGraph extends TypedEventEmitter<Events> {
ctx.strokeStyle = palette.timeLineColor;
try {
ctx.setLineDash([2, 3]);
} catch (e) {
} catch {
// ignore error
}
ctx.stroke();
Expand Down Expand Up @@ -609,7 +609,7 @@ export class SeekGraph extends TypedEventEmitter<Events> {
word = _("Correspondence");
metrics = ctx.measureText(word);
ctx.fillText(word, live_line + (w - live_line - metrics.width) / 2, baseline);
} catch (e) {
} catch {
// ignore error
}
ctx.restore();
Expand Down Expand Up @@ -915,7 +915,7 @@ export class SeekGraph extends TypedEventEmitter<Events> {
shortShortTimeControl(C.time_control_parameters),
timeControlSystemText(C.time_control).toLocaleLowerCase(),
]);
} catch (err) {
} catch {
// ignore error
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export function MultipleContainers({
requestAnimationFrame(() => {
recentlyMovedToNewContainer.current = false;
});
onUpdate ? onUpdate(items) : null;
onUpdate?.(items);
}, [items]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cached.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const cached = {
if (cb) {
cb();
}
} catch (e) {
} catch {
// ignore
}
disable_refresh_callback_on_user_change = false;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/chat_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export interface UnreadChanged {
channel: string;
unread_ct: number;
unread_delta: number;
mentioned: Boolean;
previous_mentioned: Boolean;
mentioned: boolean;
previous_mentioned: boolean;
}

const channel_information_cache: { [channel: string]: ChannelInformation } = {};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export function getPrefix(key_prefix: string = "", strip_prefix?: boolean): { [k
function safeLocalStorageSet(key: string, value: any) {
try {
localStorage.setItem(key, value);
} catch (e) {
} catch {
console.warn(
`Failed to save setting ${key}, LocalStorage is probably disabled. If you are using Safari, the most likely cause of this is being in Private Browsing Mode.`,
);
Expand All @@ -320,7 +320,7 @@ function safeLocalStorageSet(key: string, value: any) {
function safeLocalStorageRemove(key: string) {
try {
localStorage.removeItem(key);
} catch (e) {
} catch {
console.warn(
`Failed to remove ${key}, LocalStorage is probably disabled. If you are using Safari, the most likely cause of this is being in Private Browsing Mode.`,
);
Expand Down
9 changes: 3 additions & 6 deletions src/lib/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ export default class Debug {
private format(message: string): string {
return `[${this.module}] ${message}`;
}
log = (message: string, ...rest: Array<any>) => {
log = (message: string, ...rest: Array<any>) =>
debug[this.module] ? console.log(this.format(message), ...rest) : undefined;
};
trace = (message: string, ...rest: Array<any>) => {
trace = (message: string, ...rest: Array<any>) =>
debug[this.module] ? console.trace(this.format(message), ...rest) : undefined;
};
info = (message: string, ...rest: Array<any>) => {
info = (message: string, ...rest: Array<any>) =>
debug[this.module] ? console.info(this.format(message), ...rest) : undefined;
};
warn = (message: string, ...rest: Array<any>) => {
console.warn(this.format(message), ...rest);
};
Expand Down
Loading

0 comments on commit 67acc4f

Please sign in to comment.