From 245d48b7db42d148d40068950e1c7e5d2837e3ec Mon Sep 17 00:00:00 2001 From: ReznoRMichael Date: Sun, 24 Jan 2021 21:17:55 +0100 Subject: [PATCH] eslint es2015 fixes --- .eslintignore | 1 + .gitignore | 3 ++- js/HKCheckCompletion.js | 14 ++++++++++---- js/LoadJson.js | 7 +++---- js/LoadSaveFile.js | 2 ++ js/aes-js.js | 1 + 6 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..7d2cb50 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +files/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 45f2f5b..e387594 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ js/LoadJson.js config.json package.json package-lock.json -workspace.code-workspace \ No newline at end of file +workspace.code-workspace +.eslintrc.js \ No newline at end of file diff --git a/js/HKCheckCompletion.js b/js/HKCheckCompletion.js index e6eed83..9c9fa15 100644 --- a/js/HKCheckCompletion.js +++ b/js/HKCheckCompletion.js @@ -1,3 +1,6 @@ +/* eslint-disable no-unused-vars */ +/* global bench */ +/* eslint-disable no-prototype-builtins */ // ---------------- Constants ----------------- // const DATA_UNKNOWN = "Data unknown"; @@ -1008,7 +1011,7 @@ function CheckAdditionalThings(divId, dataObject, playerData, worldData) { */ function CountMaps(mapArray) { let totalMaps = 0; - for (i = 0, len = mapArray.length; i < len; i++) { + for (let i = 0, len = mapArray.length; i < len; i++) { if (playerData[mapArray[i]] === true) totalMaps++ } return totalMaps; @@ -1018,6 +1021,10 @@ function CheckAdditionalThings(divId, dataObject, playerData, worldData) { textPrefix = dataObject[i][0]; (dataObject[i][1]) ? textSuffix = dataObject[i][1]: textSuffix = ""; + let amount = 0; + let countTotal = 0; + let total = 0; + switch (i) { case "areaMaps": case "grubsCollected": @@ -1031,7 +1038,6 @@ function CheckAdditionalThings(divId, dataObject, playerData, worldData) { case "journalNotesCompleted": case "whiteDefenderDefeats": case "greyPrinceDefeats": - let amount = 0; if (i === "areaMaps") { amount = CountMaps(dataObject[i][3]); } else if (i === "whisperingRoots") { @@ -1042,7 +1048,7 @@ function CheckAdditionalThings(divId, dataObject, playerData, worldData) { if (i === "stationsOpened") { if (playerData.openedHiddenStation === true) amount++; } - let countTotal = amount; + countTotal = amount; if (i === "journalEntriesCompleted" || i === "journalNotesCompleted") { countTotal = amount + " / " + playerData.journalEntriesTotal; } @@ -1091,7 +1097,7 @@ function CheckAdditionalThings(divId, dataObject, playerData, worldData) { case "relicsHallownestSeal": case "relicsKingsIdol": case "relicsArcaneEgg": - let total = playerData[dataObject[i][3]] + playerData[dataObject[i][4]]; + total = playerData[dataObject[i][3]] + playerData[dataObject[i][4]]; (total >= dataObject[i][2]) ? CurrentDataTrue(): CurrentDataBlank(); textPrefix += ": " + total; break; diff --git a/js/LoadJson.js b/js/LoadJson.js index 7d00e84..0ee18ca 100644 --- a/js/LoadJson.js +++ b/js/LoadJson.js @@ -1,6 +1,5 @@ -var jsonObj = ""; - // save file names list in the save/ folder + var fileName = [ "reznor0", // 0 "reznor1beforegruz", // 1 @@ -24,7 +23,7 @@ var fileName = [ * @param {string} filename Path and .json file name to be loaded * @param callback Function to be called when the request completes */ -function LoadJSON(filename, callback) { +function LoadJSON(filename) { // new Http request object (asynchronous), both the web page and the XML file it tries to load, must be located on the same server. var xobj = new XMLHttpRequest(); @@ -70,4 +69,4 @@ function LoadJSON(filename, callback) { } */ // jsonObj = LoadJSON("../save/" + fileName[5], JSONparse(response)); -jsonObj = LoadJSON("save/" + fileName[5] + ".json"); \ No newline at end of file +LoadJSON("save/" + fileName[5] + ".json"); \ No newline at end of file diff --git a/js/LoadSaveFile.js b/js/LoadSaveFile.js index f2cd8ea..47c713a 100644 --- a/js/LoadSaveFile.js +++ b/js/LoadSaveFile.js @@ -1,3 +1,4 @@ +/* global aesjs, HKReadTextArea */ /* Parts of the code thanks to bloodorca https://github.com/bloodorca/hollow (base64.js, functions.js) with slight modifications. The steps used there for decryption were taken from KayDeeTee https://github.com/KayDeeTee/Hollow-Knight-SaveManager @@ -35,6 +36,7 @@ let bench = { * Starts benchmarking. * @param {FileList} input FileList object containing a list of File objects. The FileList behaves like an array, so you can check its length property to get the number of selected files. */ +// eslint-disable-next-line no-unused-vars function LoadSaveFile(input, startTime = new Date()) { // console.info("Input length: " + input.files.length) diff --git a/js/aes-js.js b/js/aes-js.js index 02f4394..b276aa7 100644 --- a/js/aes-js.js +++ b/js/aes-js.js @@ -1,3 +1,4 @@ +/* eslint-disable */ "use strict"; (function (root) {