refactor: enable ban-ts-comment rule

This commit is contained in:
Miodec 2025-04-16 19:15:30 +02:00
parent 158226629d
commit 0b05b3c2fd
27 changed files with 71 additions and 71 deletions

View file

@ -9,7 +9,8 @@
"plugins": ["jest", "vitest"],
"rules": {
"no-explicit-any": "allow",
"explicit-function-return-type": "off"
"explicit-function-return-type": "off",
"ban-ts-comment": "off"
}
}
]

View file

@ -196,8 +196,6 @@ export class WeeklyXpLeaderboard {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
connection.set;
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore
const [[, rank], [, totalXp], [, _count], [, result]] = (await connection
.multi()
.zrevrank(weeklyXpLeaderboardScoresKey, uid)
@ -207,7 +205,8 @@ export class WeeklyXpLeaderboard {
.exec()) as [
[null, number | null],
[null, string | null],
[null, number | null]
[null, number | null],
[null, string | null]
];
if (rank === null) {

View file

@ -10,7 +10,8 @@
"no-explicit-any": "allow",
"explicit-function-return-type": "off",
"no-array-for-each": "off",
"eqeqeq": "off"
"eqeqeq": "off",
"ban-ts-comment": "off"
}
}
]

View file

@ -1,7 +1,7 @@
import $ from "jquery";
// @ts-ignore
//@ts-expect-error add to globl
global["$"] = $;
// @ts-ignore
//@ts-expect-error add to globl
global["jQuery"] = $;
vi.mock("../src/ts/constants/env-config", () => ({

View file

@ -1453,7 +1453,7 @@ function setThemes(
if (!isConfigValueValid("themes", theme, ConfigSchemas.ThemeNameSchema))
return false;
//@ts-expect-error
//@ts-expect-error config used to have 9
if (customThemeColors.length === 9) {
//color missing
if (customState) {
@ -1539,7 +1539,7 @@ export function setCustomThemeColors(
nosave?: boolean
): boolean {
// migrate existing configs missing sub alt color
// @ts-expect-error
// @ts-expect-error legacy configs
if (colors.length === 9) {
//color missing
Notifications.add(
@ -1931,8 +1931,8 @@ export function setCustomBackgroundFilter(
array: ConfigSchemas.CustomBackgroundFilter,
nosave?: boolean
): boolean {
//convert existing configs using five values down to four
//@ts-expect-error
// @ts-expect-error this used to be 5
// need to convert existing configs using five values down to four
if (array.length === 5) {
array = [array[0], array[1], array[2], array[3]];
}

View file

@ -10,15 +10,15 @@ type Config = {
//@ts-expect-error these get replaced by vite
const backendUrl = BACKEND_URL;
// @ts-expect-error
// @ts-expect-error ---
const isDevelopment = IS_DEVELOPMENT;
// @ts-expect-error
// @ts-expect-error ---
const clientVersion = CLIENT_VERSION;
// @ts-expect-error
// @ts-expect-error ---
const recaptchaSiteKey = RECAPTCHA_SITE_KEY;
// @ts-expect-error
// @ts-expect-error ---
const quickLoginEmail = QUICK_LOGIN_EMAIL;
// @ts-expect-error
// @ts-expect-error ---
const quickLoginPassword = QUICK_LOGIN_PASSWORD;
export const envConfig: Config = {

View file

@ -143,7 +143,7 @@ export async function checkAdblock(): Promise<void> {
return new Promise((resolve) => {
if (choice === "eg") {
if (adBlock === undefined) {
//@ts-expect-error
//@ts-expect-error 3rd party ad code
if (window.egAdPack === undefined) {
adBlock = true;
} else {
@ -151,7 +151,7 @@ export async function checkAdblock(): Promise<void> {
}
}
} else if (choice === "pw") {
//@ts-expect-error
//@ts-expect-error 3rd party ad code
if (window.ramp === undefined) {
adBlock = true;
}
@ -169,13 +169,13 @@ export async function checkCookieblocker(): Promise<void> {
return;
}
//@ts-expect-error
//@ts-expect-error 3rd party ad code
if (window.__tcfapi === undefined) {
cookieBlocker = true;
resolve();
return;
}
//@ts-expect-error
//@ts-expect-error 3rd party ad code
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
window.__tcfapi("getTCData", 2, (tcData, success) => {
if (success as boolean) {
@ -269,13 +269,13 @@ export function updateFooterAndVerticalAds(visible: boolean): void {
export function showConsentPopup(): void {
if (choice === "eg") {
//@ts-expect-error
//@ts-expect-error 3rd party ad code, doesnt have types
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
window.__tcfapi("displayConsentUi", 2, function () {
//
});
} else {
//@ts-expect-error
//@ts-expect-error 3rd party ad code, doesnt have types
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
ramp.showCmpModal();
}
@ -322,7 +322,7 @@ $(document).ready(() => {
});
window.onerror = function (error): void {
//@ts-expect-error
//@ts-expect-error ---
if (choice === "eg") {
if (typeof error === "string" && error.startsWith("EG APS")) {
$("#ad-result-wrapper .iconAndText").addClass("withLeft");

View file

@ -15,7 +15,7 @@ export function render(
return;
}
//@ts-expect-error
//@ts-expect-error 3rd party code, no types
const widgetId = grecaptcha.render(element, {
sitekey: siteKey,
callback,
@ -29,7 +29,7 @@ export function reset(id: string): void {
return;
}
//@ts-expect-error
//@ts-expect-error 3rd party code, no types
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
grecaptcha.reset(captchas[id]);
}
@ -39,7 +39,7 @@ export function getResponse(id: string): string {
return "";
}
//@ts-expect-error
//@ts-expect-error 3rd party code, no types
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
return grecaptcha.getResponse(captchas[id]);
}

View file

@ -87,14 +87,14 @@ class ChartWithUpdateColors<
}
getDataset(id: DatasetIds): ChartDataset<TType, TData> {
//@ts-expect-error
//@ts-expect-error its too difficult to figure out these types, but this works
return this.data.datasets?.find((x) => x.yAxisID === id);
}
getScale(
id: DatasetIds extends never ? never : "x" | DatasetIds
): DatasetIds extends never ? never : CartesianScaleOptions {
//@ts-expect-error
//@ts-expect-error its too difficult to figure out these types, but this works
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
return this.options.scales[id];
}
@ -1155,7 +1155,7 @@ async function updateColors<
const gridcolor = blendTwoHexColors(bgcolor, subaltcolor, 0.75);
//@ts-expect-error
//@ts-expect-error its too difficult to figure out these types, but this works
chart.data.datasets[0].borderColor = (ctx): string => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const isPb = ctx.raw?.isPb as boolean;
@ -1177,7 +1177,7 @@ async function updateColors<
if (chart?.data?.datasets[0]?.type === undefined) {
if (chart.config.type === "line") {
dataset0.pointBackgroundColor = (ctx): string => {
//@ts-expect-error
//@ts-expect-error not sure why raw comes out to unknown, but this works
const isPb = ctx.raw?.isPb as boolean;
const color = isPb ? textcolor : maincolor;
return color;

View file

@ -15,7 +15,7 @@ export function init(): void {
export function renderResult(widerThanBreakpoint: boolean): void {
if (widerThanBreakpoint) {
//@ts-expect-error
//@ts-expect-error 3rd party ad code
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
window.egAps.render([
"ad-result",
@ -24,7 +24,7 @@ export function renderResult(widerThanBreakpoint: boolean): void {
"ad-footer",
]);
} else {
//@ts-expect-error
//@ts-expect-error 3rd party ad code
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
window.egAps.render([
"ad-result-small",
@ -37,7 +37,7 @@ export function renderResult(widerThanBreakpoint: boolean): void {
export function reinstate(): boolean {
try {
//@ts-expect-error
//@ts-expect-error 3rd party ad code
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
window.egAps.reinstate();
return true;
@ -48,7 +48,7 @@ export function reinstate(): boolean {
}
export async function refreshVisible(): Promise<void> {
////@ts-expect-error
////@ts-expect-error 3rd party ad code
// const adDivs = Object.keys(window.egAdPack.gptAdSlots);
// const visibleAdDivs = [];
// for (let i = 0; i < adDivs.length; i++) {
@ -63,6 +63,6 @@ export async function refreshVisible(): Promise<void> {
// visibleAdDivs.push(adDivs[i]);
// }
// }
// //@ts-ignore
// //@ts-expect-error 3rd party ad code
// window.egAps.refreshAds(visibleAdDivs);
}

View file

@ -94,11 +94,11 @@ function updateUI(): void {
//@ts-expect-error really cant be bothered fixing all these issues - its gonna get caught anyway
const koChar: string =
//@ts-expect-error
//@ts-expect-error ---
koCurrWord[inputGroupLength][inputCharLength] ??
//@ts-expect-error
//@ts-expect-error ---
koCurrWord[koCurrInput.length][
//@ts-expect-error
//@ts-expect-error ---
inputCharLength - koCurrWord[inputGroupLength].length
];

View file

@ -95,7 +95,7 @@ export async function change(
await previousPage?.afterHide();
await nextPage?.beforeShow({
params: options.params,
//@ts-expect-error
// @ts-expect-error for the future (i think)
data: options.data,
});
}

View file

@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
//@ts-nocheck
// oxlint-disable ban-ts-comment
//@ts-nocheck too many errors from 3rd party ad code
import Config from "../config";
import * as ActivePage from "../states/active-page";

View file

@ -398,10 +398,8 @@ export async function previewClick(val: string): Promise<void> {
const clickSoundIds = Object.keys(safeClickSounds);
if (!clickSoundIds.includes(val)) return;
//@ts-expect-error
safeClickSounds[val][0].sounds[0].seek(0);
//@ts-expect-error
safeClickSounds[val][0].sounds[0].play();
safeClickSounds?.[val]?.[0]?.sounds[0]?.seek(0);
safeClickSounds?.[val]?.[0]?.sounds[0]?.play();
}
export async function previewError(val: string): Promise<void> {

View file

@ -2,7 +2,8 @@
import { FirebaseApp, initializeApp } from "firebase/app";
import { getAuth, Auth as AuthType, User } from "firebase/auth";
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
//@ts-ignore
// oxlint-disable ban-ts-comment
// @ts-ignore as far as i remember this is for CI
// eslint-disable-next-line import/no-unresolved
import { firebaseConfig } from "./constants/firebase-config";
import * as Notifications from "./elements/notifications";

View file

@ -48,7 +48,7 @@ import { getDevOptionsModal } from "./utils/async-modules";
function addToGlobal(items: Record<string, unknown>): void {
for (const [name, item] of Object.entries(items)) {
//@ts-expect-error
//@ts-expect-error dev
window[name] = item;
}
}

View file

@ -1103,7 +1103,7 @@ function sortAndRefreshHistory(
}
}
//@ts-expect-error
// @ts-expect-error temp
temp.push(filteredResults[idx]);
parsedIndexes.push(idx);
}
@ -1289,7 +1289,7 @@ $(".pageAccount .group.presetFilterButtons").on(
);
$(".pageAccount .content .group.aboveHistory .exportCSV").on("click", () => {
//@ts-expect-error
//@ts-expect-error dont really wanna figure out the types here but it works
void Misc.downloadResultsCSV(filteredResults);
});

View file

@ -316,7 +316,7 @@ async function requestData(update = false): Promise<void> {
state.pageSize = dataResponse.body.data.pageSize;
if (state.type === "daily") {
//@ts-ignore not sure why this is causing errors when it's clearly defined in the schema
//@ts-expect-error not sure why this is causing errors when it's clearly defined in the schema
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
state.minWpm = dataResponse.body.data.minWpm;
}

View file

@ -441,7 +441,7 @@ function reset(): void {
$(".pageSettings .section[data-config-name='funbox'] .buttons").empty();
$(".pageSettings .section[data-config-name='fontFamily'] .buttons").empty();
for (const select of document.querySelectorAll(".pageSettings select")) {
//@ts-expect-error
//@ts-expect-error slim gets added to the html element but ts doesnt know about it
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
select?.slim?.destroy?.();
}

View file

@ -39,7 +39,7 @@ export async function show(): Promise<void> {
.css("opacity", 0)
.removeClass("hidden")
.animate({ opacity: 1 }, 125, () => {
//@ts-expect-error
//@ts-expect-error 3rd party ad code
window.dataLayer.push({ event: "EG_Video" });
});
}

View file

@ -4,7 +4,7 @@ import * as MerchBanner from "./elements/merch-banner";
import * as CookiesModal from "./modals/cookies";
import * as ConnectionState from "./states/connection";
import * as AccountButton from "./elements/account-button";
//@ts-expect-error
//@ts-expect-error no types for this package
import Konami from "konami";
import * as ServerConfiguration from "./ape/server-configuration";
import { getActiveFunboxesWithFunction } from "./test/funbox/list";

View file

@ -86,7 +86,7 @@ export function clearNotSignedInResult(): void {
export function setNotSignedInUidAndHash(uid: string): void {
if (notSignedInLastResult === null) return;
notSignedInLastResult.uid = uid;
//@ts-expect-error
//@ts-expect-error really need to delete this
delete notSignedInLastResult.hash;
notSignedInLastResult.hash = objectHash(notSignedInLastResult);
}

View file

@ -74,13 +74,13 @@ export function getStats(): unknown {
};
try {
// @ts-expect-error
// @ts-expect-error ---
ret.keypressTimings.spacing.average =
TestInput.keypressTimings.spacing.array.reduce(
(previous, current) => (current += previous)
) / TestInput.keypressTimings.spacing.array.length;
// @ts-expect-error
// @ts-expect-error ---
ret.keypressTimings.spacing.sd = Numbers.stdDev(
TestInput.keypressTimings.spacing.array
);
@ -88,13 +88,13 @@ export function getStats(): unknown {
//
}
try {
// @ts-expect-error
// @ts-expect-error ---
ret.keypressTimings.duration.average =
TestInput.keypressTimings.duration.array.reduce(
(previous, current) => (current += previous)
) / TestInput.keypressTimings.duration.array.length;
// @ts-expect-error
// @ts-expect-error ---
ret.keypressTimings.duration.sd = Numbers.stdDev(
TestInput.keypressTimings.duration.array
);

View file

@ -30,7 +30,7 @@ function mergeWithDefaultConfig(config: PartialConfig): Config {
export function replaceLegacyValues(
configObj: ConfigSchemas.PartialConfig
): ConfigSchemas.PartialConfig {
//@ts-expect-error
//@ts-expect-error legacy configs
if (configObj.quickTab === true && configObj.quickRestart === undefined) {
configObj.quickRestart = "tab";
}
@ -40,7 +40,7 @@ export function replaceLegacyValues(
}
if (
//@ts-expect-error
//@ts-expect-error legacy configs
configObj.swapEscAndTab === true &&
configObj.quickRestart === undefined
) {
@ -48,14 +48,14 @@ export function replaceLegacyValues(
}
if (
//@ts-expect-error
//@ts-expect-error legacy configs
configObj.alwaysShowCPM === true &&
configObj.typingSpeedUnit === undefined
) {
configObj.typingSpeedUnit = "cpm";
}
//@ts-expect-error
//@ts-expect-error legacy configs
if (configObj.showAverage === "wpm") {
configObj.showAverage = "speed";
}
@ -65,7 +65,7 @@ export function replaceLegacyValues(
}
if (
//@ts-expect-error
//@ts-expect-error legacy configs
configObj.showTimerProgress === false &&
configObj.timerStyle === undefined
) {
@ -73,7 +73,7 @@ export function replaceLegacyValues(
}
if (
//@ts-expect-error
//@ts-expect-error legacy configs
configObj.showLiveWpm === true &&
configObj.liveSpeedStyle === undefined
) {
@ -85,7 +85,7 @@ export function replaceLegacyValues(
}
if (
//@ts-expect-error
//@ts-expect-error legacy configs
configObj.showLiveBurst === true &&
configObj.liveBurstStyle === undefined
) {
@ -97,7 +97,7 @@ export function replaceLegacyValues(
}
if (
//@ts-expect-error
//@ts-expect-error legacy configs
configObj.showLiveAcc === true &&
configObj.liveAccStyle === undefined
) {

View file

@ -227,12 +227,12 @@ export function getFirstDayOfTheWeek(): Day {
//modern browsers support `weekInfo` or `getWeekInfo()`
if ("weekInfo" in locale) {
// @ts-ignore
// @ts-expect-error weekInfo is not in the type definition
return (locale.weekInfo.firstDay as number) % 7;
}
if ("getWeekInfo" in locale) {
// @ts-ignore
// @ts-expect-error getWeekInfo is not in the type definition
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return (locale.getWeekInfo().firstDay as number) % 7;
}

View file

@ -151,7 +151,7 @@ export function toggleFullscreen(): void {
} else if (elem.mozRequestFullScreen) {
void elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
// @ts-expect-error
// @ts-expect-error some code i found online
void elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {

View file

@ -76,6 +76,8 @@
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"typescript/no-namespace": "error",
"eqeqeq": "error",
"ban-ts-comment": "error",
"todo-lowerthis": "off",
"max-depth": [
@ -86,10 +88,7 @@
],
"todo": "off",
"ban-ts-comment": "off",
"no-array-for-each": "off",
"eqeqeq": "error",
"prefer-ts-expect-error": "off",
"consider": "off",
"no-cycle": "off",