mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-09 00:45:32 +08:00
fixed lint warnings
This commit is contained in:
parent
b4b036eb2f
commit
ee90d33b11
9 changed files with 68 additions and 102 deletions
|
|
@ -40,7 +40,7 @@ let eslintConfig = {
|
|||
"no-dupe-else-if": "warn",
|
||||
"no-dupe-keys": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-empty": "warn",
|
||||
"no-empty": ["warn", { allowEmptyCatch: true }],
|
||||
"no-empty-character-class": "error",
|
||||
"no-empty-pattern": "error",
|
||||
"no-ex-assign": "error",
|
||||
|
|
@ -72,7 +72,7 @@ let eslintConfig = {
|
|||
"no-unsafe-finally": "error",
|
||||
"no-unsafe-negation": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-unused-vars": "warn",
|
||||
"no-unused-vars": ["warn", { argsIgnorePattern: "e|event" }],
|
||||
"no-use-before-define": "warn",
|
||||
"no-useless-catch": "error",
|
||||
"no-useless-escape": "error",
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ function linkWithGoogle() {
|
|||
});
|
||||
}
|
||||
|
||||
let dontCheckUserName = false;
|
||||
// let dontCheckUserName = false;
|
||||
|
||||
function signUp() {
|
||||
$(".pageLogin .register .button").addClass("disabled");
|
||||
|
|
@ -135,7 +135,7 @@ function signUp() {
|
|||
.createUserWithEmailAndPassword(email, password)
|
||||
.then((user) => {
|
||||
// Account has been created here.
|
||||
dontCheckUserName = true;
|
||||
// dontCheckUserName = true;
|
||||
let usr = user.user;
|
||||
usr
|
||||
.updateProfile({
|
||||
|
|
@ -257,12 +257,12 @@ firebase.auth().onAuthStateChanged(function (user) {
|
|||
accountIconLoading(true);
|
||||
getAccountDataAndInit();
|
||||
var displayName = user.displayName;
|
||||
var email = user.email;
|
||||
var emailVerified = user.emailVerified;
|
||||
var photoURL = user.photoURL;
|
||||
var isAnonymous = user.isAnonymous;
|
||||
var uid = user.uid;
|
||||
var providerData = user.providerData;
|
||||
// var email = user.email;
|
||||
// var emailVerified = user.emailVerified;
|
||||
// var photoURL = user.photoURL;
|
||||
// var isAnonymous = user.isAnonymous;
|
||||
// var uid = user.uid;
|
||||
// var providerData = user.providerData;
|
||||
$(".pageLogin .preloader").addClass("hidden");
|
||||
$("#menu .icon-button.account .text").text(displayName);
|
||||
|
||||
|
|
@ -562,10 +562,10 @@ var resultHistoryChart = new Chart($(".pageAccount #resultHistoryChart"), {
|
|||
|
||||
return label;
|
||||
},
|
||||
label: function (tooltipItem, data) {
|
||||
label: function () {
|
||||
return;
|
||||
},
|
||||
afterLabel: function (tooltipItem, data) {
|
||||
afterLabel: function () {
|
||||
return;
|
||||
},
|
||||
},
|
||||
|
|
@ -684,7 +684,7 @@ let activityChart = new Chart($(".pageAccount #activityChart"), {
|
|||
return `Average Wpm: ${Misc.roundTo2(resultData.y)}`;
|
||||
}
|
||||
},
|
||||
label: function (tooltipItem, data) {
|
||||
label: function () {
|
||||
return;
|
||||
},
|
||||
},
|
||||
|
|
@ -1225,23 +1225,23 @@ function showActiveFilters() {
|
|||
refreshAccountPage();
|
||||
}
|
||||
|
||||
function showChartPreloader() {
|
||||
$(".pageAccount .group.chart .preloader").stop(true, true).animate(
|
||||
{
|
||||
opacity: 1,
|
||||
},
|
||||
125
|
||||
);
|
||||
}
|
||||
// function showChartPreloader() {
|
||||
// $(".pageAccount .group.chart .preloader").stop(true, true).animate(
|
||||
// {
|
||||
// opacity: 1,
|
||||
// },
|
||||
// 125
|
||||
// );
|
||||
// }
|
||||
|
||||
function hideChartPreloader() {
|
||||
$(".pageAccount .group.chart .preloader").stop(true, true).animate(
|
||||
{
|
||||
opacity: 0,
|
||||
},
|
||||
125
|
||||
);
|
||||
}
|
||||
// function hideChartPreloader() {
|
||||
// $(".pageAccount .group.chart .preloader").stop(true, true).animate(
|
||||
// {
|
||||
// opacity: 0,
|
||||
// },
|
||||
// 125
|
||||
// );
|
||||
// }
|
||||
|
||||
$(".pageAccount .topFilters .button.allFilters").click((e) => {
|
||||
Object.keys(ResultFilters.getFilters()).forEach((group) => {
|
||||
|
|
@ -2146,26 +2146,16 @@ function refreshAccountPage() {
|
|||
let minWpmChartVal = Math.min(...wpms);
|
||||
let maxWpmChartVal = Math.max(...wpms);
|
||||
|
||||
let accuracies = accChartData.map((r) => r.y);
|
||||
let minAccuracyChartVal = Math.min(...accuracies);
|
||||
let maxAccuracyChartVal = Math.max(...accuracies);
|
||||
|
||||
// let accuracies = accChartData.map((r) => r.y);
|
||||
resultHistoryChart.options.scales.yAxes[0].ticks.max =
|
||||
Math.floor(maxWpmChartVal) + (10 - (Math.floor(maxWpmChartVal) % 10));
|
||||
// resultHistoryChart.options.scales.yAxes[1].ticks.max = Math.ceil(
|
||||
// maxAccuracyChartVal
|
||||
// );
|
||||
|
||||
if (!config.startGraphsAtZero) {
|
||||
resultHistoryChart.options.scales.yAxes[0].ticks.min = Math.floor(
|
||||
minWpmChartVal
|
||||
);
|
||||
// resultHistoryChart.options.scales.yAxes[1].ticks.min = Math.floor(
|
||||
// minAccuracyChartVal
|
||||
// );
|
||||
} else {
|
||||
resultHistoryChart.options.scales.yAxes[0].ticks.min = 0;
|
||||
// resultHistoryChart.options.scales.yAxes[1].ticks.min = 0;
|
||||
}
|
||||
|
||||
if (chartData == [] || chartData.length == 0) {
|
||||
|
|
@ -2331,11 +2321,11 @@ function hideResultEditTagsPanel() {
|
|||
}
|
||||
}
|
||||
|
||||
$(".pageAccount .toggleAccuracyOnChart").click((params) => {
|
||||
$(".pageAccount .toggleAccuracyOnChart").click((e) => {
|
||||
toggleChartAccuracy();
|
||||
});
|
||||
|
||||
$(".pageAccount .toggleChartStyle").click((params) => {
|
||||
$(".pageAccount .toggleChartStyle").click((e) => {
|
||||
toggleChartStyle();
|
||||
});
|
||||
|
||||
|
|
@ -2381,9 +2371,9 @@ function updateActiveResultEditTagsPanelButtons(active) {
|
|||
});
|
||||
}
|
||||
|
||||
$("#resultEditTagsPanel .confirmButton").click((f) => {
|
||||
$("#resultEditTagsPanel .confirmButton").click((e) => {
|
||||
let resultid = $("#resultEditTagsPanel").attr("resultid");
|
||||
let oldtags = JSON.parse($("#resultEditTagsPanel").attr("tags"));
|
||||
// let oldtags = JSON.parse($("#resultEditTagsPanel").attr("tags"));
|
||||
|
||||
let newtags = [];
|
||||
$.each($("#resultEditTagsPanel .buttons .button"), (index, obj) => {
|
||||
|
|
|
|||
|
|
@ -197,7 +197,6 @@ export async function db_getUserAverageWpm10(
|
|||
function cont() {
|
||||
let wpmSum = 0;
|
||||
let count = 0;
|
||||
let i = 0;
|
||||
// You have to use every so you can break out of the loop
|
||||
dbSnapshot.results.every((result) => {
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
//try to keep this list short because we need to eliminate it eventually
|
||||
global.simplePopups = simplePopups;
|
||||
global.sendVerificationEmail = Misc.sendVerificationEmail;
|
||||
global.getuid = getuid;
|
||||
|
||||
//these exports are just for debugging in the browser
|
||||
global.snapshot = db_getSnapshot;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class Notification {
|
|||
);
|
||||
}
|
||||
);
|
||||
$(`#notificationCenter .notif[id='${this.id}']`).click((e) => {
|
||||
$(`#notificationCenter .notif[id='${this.id}']`).click(() => {
|
||||
this.hide();
|
||||
});
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ class Notification {
|
|||
this.hide();
|
||||
}, this.duration + 250);
|
||||
}
|
||||
$(`#notificationCenter .notif[id='${this.id}']`).hover((e) => {
|
||||
$(`#notificationCenter .notif[id='${this.id}']`).hover(() => {
|
||||
$(`#notificationCenter .notif[id='${this.id}']`).toggleClass("hover");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import * as Misc from "./misc";
|
||||
|
||||
let filters = defaultResultFilters;
|
||||
|
||||
let defaultResultFilters = {
|
||||
difficulty: {
|
||||
normal: true,
|
||||
|
|
@ -58,7 +56,7 @@ let defaultResultFilters = {
|
|||
},
|
||||
};
|
||||
|
||||
load();
|
||||
let filters = defaultResultFilters;
|
||||
|
||||
Misc.getLanguageList().then((languages) => {
|
||||
languages.forEach((language) => {
|
||||
|
|
@ -123,3 +121,5 @@ export function reset() {
|
|||
filters = defaultResultFilters;
|
||||
save();
|
||||
}
|
||||
|
||||
load();
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ function copyResultToClipboard() {
|
|||
})
|
||||
),
|
||||
])
|
||||
.then((f) => {
|
||||
.then(() => {
|
||||
$("#notificationCenter").removeClass("hidden");
|
||||
$("#commandLineMobileButton").removeClass("hidden");
|
||||
Notifications.add("Copied to clipboard", 1, 2);
|
||||
|
|
@ -834,14 +834,14 @@ function punctuateWord(previousWord, currentWord, index, maxindex) {
|
|||
) {
|
||||
word = `"${word}"`;
|
||||
} else if (
|
||||
Math.random() < 0.01 &&
|
||||
Math.random() < 0.011 &&
|
||||
Misc.getLastChar(previousWord) != "," &&
|
||||
Misc.getLastChar(previousWord) != "." &&
|
||||
config.language.split("_")[0] !== "russian"
|
||||
) {
|
||||
word = `'${word}'`;
|
||||
} else if (
|
||||
Math.random() < 0.01 &&
|
||||
Math.random() < 0.012 &&
|
||||
Misc.getLastChar(previousWord) != "," &&
|
||||
Misc.getLastChar(previousWord) != "."
|
||||
) {
|
||||
|
|
@ -859,21 +859,21 @@ function punctuateWord(previousWord, currentWord, index, maxindex) {
|
|||
} else {
|
||||
word = `(${word})`;
|
||||
}
|
||||
} else if (Math.random() < 0.01) {
|
||||
} else if (Math.random() < 0.013) {
|
||||
if (config.language.split("_")[0] == "french") {
|
||||
word = ":";
|
||||
} else {
|
||||
word += ":";
|
||||
}
|
||||
} else if (
|
||||
Math.random() < 0.01 &&
|
||||
Math.random() < 0.014 &&
|
||||
Misc.getLastChar(previousWord) != "," &&
|
||||
Misc.getLastChar(previousWord) != "." &&
|
||||
previousWord != "-"
|
||||
) {
|
||||
word = "-";
|
||||
} else if (
|
||||
Math.random() < 0.01 &&
|
||||
Math.random() < 0.015 &&
|
||||
Misc.getLastChar(previousWord) != "," &&
|
||||
Misc.getLastChar(previousWord) != "." &&
|
||||
Misc.getLastChar(previousWord) != ";"
|
||||
|
|
@ -1177,8 +1177,7 @@ function updateWordElement(showError) {
|
|||
// }
|
||||
// }
|
||||
if (!showError) {
|
||||
if (currentLetter == undefined) {
|
||||
} else {
|
||||
if (currentLetter !== undefined) {
|
||||
ret += `<letter class="correct ${tabChar}${nlChar}">${currentLetter}</letter>`;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2112,11 +2111,6 @@ function showResult(difficultyFailed = false) {
|
|||
let maxChartVal = Math.max(
|
||||
...[Math.max(...rawWpmPerSecond), Math.max(...wpmHistory)]
|
||||
);
|
||||
|
||||
let minChartVal = Math.min(
|
||||
...[Math.min(...rawWpmPerSecond), Math.min(...wpmHistory)]
|
||||
);
|
||||
|
||||
if (!config.startGraphsAtZero) {
|
||||
wpmOverTimeChart.options.scales.yAxes[0].ticks.min = Math.min(
|
||||
...wpmHistory
|
||||
|
|
@ -2285,7 +2279,6 @@ function showResult(difficultyFailed = false) {
|
|||
|
||||
//check local pb
|
||||
accountIconLoading(true);
|
||||
let localPb = false;
|
||||
let dontShowCrown = false;
|
||||
let pbDiff = 0;
|
||||
db_getLocalPB(
|
||||
|
|
@ -2319,7 +2312,6 @@ function showResult(difficultyFailed = false) {
|
|||
"+" + Misc.roundTo2(pbDiff)
|
||||
);
|
||||
}
|
||||
localPb = true;
|
||||
}
|
||||
if (lpb > 0) {
|
||||
wpmOverTimeChart.options.annotation.annotations.push({
|
||||
|
|
@ -2690,8 +2682,6 @@ function showResult(difficultyFailed = false) {
|
|||
if (e.data.resultCode === 2) {
|
||||
//new pb
|
||||
showCrown();
|
||||
if (!localPb) {
|
||||
}
|
||||
db_saveLocalPB(
|
||||
config.mode,
|
||||
mode2,
|
||||
|
|
@ -3052,9 +3042,13 @@ function restartTest(withSameWordset = false, nosave = false, event) {
|
|||
if (config.mode !== "zen") event.preventDefault();
|
||||
} catch {}
|
||||
if (
|
||||
Misc.canQuickRestart(config.mode, config.words, config.time, customText)
|
||||
!Misc.canQuickRestart(
|
||||
config.mode,
|
||||
config.words,
|
||||
config.time,
|
||||
customText
|
||||
)
|
||||
) {
|
||||
} else {
|
||||
let message = "Use your mouse to confirm.";
|
||||
if (config.quickTab)
|
||||
message = "Press shift + tab or use your mouse to confirm.";
|
||||
|
|
@ -3279,18 +3273,6 @@ function focusWords() {
|
|||
}
|
||||
}
|
||||
|
||||
function setCustomText() {
|
||||
customText.text = prompt("Custom text").trim();
|
||||
customText.text = customText.text.replace(/[\n\r\t ]/gm, " ");
|
||||
customText.text = customText.text.replace(/ +/gm, " ");
|
||||
customText.text = customText.text.split(" ");
|
||||
if (customText.text.text.length >= 10000) {
|
||||
Notifications.add("Custom text cannot be longer than 10000 words.", 0);
|
||||
setMode("time");
|
||||
customText.text = "The quick brown fox jumped over the lazy dog".split(" ");
|
||||
}
|
||||
}
|
||||
|
||||
function changePage(page) {
|
||||
if (pageTransition) {
|
||||
return;
|
||||
|
|
@ -4488,20 +4470,17 @@ function movePaceCaret(expectedStepEnd) {
|
|||
let newTop;
|
||||
let newLeft;
|
||||
try {
|
||||
let newIndex =
|
||||
paceCaret.currentWordIndex -
|
||||
(currentWordIndex - currentWordElementIndex);
|
||||
if (paceCaret.currentLetterIndex === -1) {
|
||||
currentLetter = document
|
||||
.querySelectorAll("#words .word")
|
||||
[
|
||||
paceCaret.currentWordIndex -
|
||||
(currentWordIndex - currentWordElementIndex)
|
||||
].querySelectorAll("letter")[0];
|
||||
[newIndex].querySelectorAll("letter")[0];
|
||||
} else {
|
||||
currentLetter = document
|
||||
.querySelectorAll("#words .word")
|
||||
[
|
||||
paceCaret.currentWordIndex -
|
||||
(currentWordIndex - currentWordElementIndex)
|
||||
].querySelectorAll("letter")[paceCaret.currentLetterIndex];
|
||||
[newIndex].querySelectorAll("letter")[paceCaret.currentLetterIndex];
|
||||
}
|
||||
newTop = currentLetter.offsetTop - $(currentLetter).height() / 20;
|
||||
newLeft;
|
||||
|
|
@ -5202,6 +5181,7 @@ function handleTab(event) {
|
|||
) {
|
||||
if (config.quickTab) {
|
||||
if (config.mode == "zen" && !event.shiftKey) {
|
||||
//ignore
|
||||
} else {
|
||||
if (event.shiftKey) manualRestart = true;
|
||||
|
||||
|
|
@ -5360,7 +5340,7 @@ function handleBackspace(event) {
|
|||
function handleSpace(event, isEnter) {
|
||||
if (!testActive) return;
|
||||
if (currentInput === "") return;
|
||||
let nextWord = wordsList[currentWordIndex + 1];
|
||||
// let nextWord = wordsList[currentWordIndex + 1];
|
||||
// if ((isEnter && nextWord !== "\n") && (isEnter && activeFunBox !== "58008")) return;
|
||||
// if (!isEnter && nextWord === "\n") return;
|
||||
event.preventDefault();
|
||||
|
|
@ -5858,6 +5838,7 @@ window.addEventListener("beforeunload", (event) => {
|
|||
!customText.isWordRandom &&
|
||||
customText.text.length < 1000)
|
||||
) {
|
||||
//ignore
|
||||
} else {
|
||||
if (testActive) {
|
||||
event.preventDefault();
|
||||
|
|
@ -5890,7 +5871,7 @@ if (window.location.hostname === "localhost") {
|
|||
manualRestart = true;
|
||||
|
||||
let configLoadDone;
|
||||
let configLoadPromise = new Promise((v, x) => {
|
||||
let configLoadPromise = new Promise((v) => {
|
||||
configLoadDone = v;
|
||||
});
|
||||
loadConfigFromCookie();
|
||||
|
|
@ -6166,7 +6147,7 @@ let wpmOverTimeChart = new Chart(ctx, {
|
|||
mode: "index",
|
||||
intersect: false,
|
||||
callbacks: {
|
||||
afterLabel: function (ti, data) {
|
||||
afterLabel: function (ti) {
|
||||
try {
|
||||
$(".wordInputAfter").remove();
|
||||
|
||||
|
|
@ -6180,7 +6161,7 @@ let wpmOverTimeChart = new Chart(ctx, {
|
|||
if (input != undefined)
|
||||
wordEl.append(`<div class="wordInputAfter">${input}</div>`);
|
||||
});
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -616,7 +616,6 @@ function refreshTagsSettingsSection() {
|
|||
let tagsEl = $(".pageSettings .section.tags .tagsList").empty();
|
||||
db_getSnapshot().tags.forEach((tag) => {
|
||||
let tagPbString = "No PB found";
|
||||
let balloon = "";
|
||||
if (tag.pb != undefined && tag.pb > 0) {
|
||||
tagPbString = `PB: ${tag.pb}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,8 +113,7 @@ async function saveConfigToDB() {
|
|||
obj: config,
|
||||
}).then((d) => {
|
||||
accountIconLoading(false);
|
||||
if (d.data.returnCode === 1) {
|
||||
} else {
|
||||
if (d.data.returnCode !== 1) {
|
||||
Notifications.add(`Error saving config to DB! ${d.data.message}`, 4000);
|
||||
}
|
||||
return;
|
||||
|
|
@ -797,8 +796,7 @@ function toggleKeyTips() {
|
|||
|
||||
//mode
|
||||
function setTimeConfig(time, nosave) {
|
||||
if (time !== null && !isNaN(time) && time >= 0) {
|
||||
} else {
|
||||
if (time === null || isNaN(time) || time < 0) {
|
||||
time = 15;
|
||||
}
|
||||
time = parseInt(time);
|
||||
|
|
@ -821,8 +819,7 @@ function setQuoteLength(len, nosave, multipleMode) {
|
|||
config.quoteLength = len;
|
||||
} else {
|
||||
if (!Array.isArray(config.quoteLength)) config.quoteLength = [];
|
||||
if (len !== null && !isNaN(len) && len >= -1 && len <= 3) {
|
||||
} else {
|
||||
if (len === null || isNaN(len) || len < -1 || len > 3) {
|
||||
len = 1;
|
||||
}
|
||||
len = parseInt(len);
|
||||
|
|
@ -843,8 +840,7 @@ function setQuoteLength(len, nosave, multipleMode) {
|
|||
}
|
||||
|
||||
function setWordCount(wordCount, nosave) {
|
||||
if (wordCount !== null && !isNaN(wordCount) && wordCount >= 0) {
|
||||
} else {
|
||||
if (wordCount === null || isNaN(wordCount) || wordCount < 0) {
|
||||
wordCount = 10;
|
||||
}
|
||||
wordCount = parseInt(wordCount);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue