Fixed high number of ESLint errors

This commit is contained in:
Daniël van Noord
2021-04-04 17:05:39 +02:00
parent e2f99d1cf9
commit e3321ebe2f
53 changed files with 130 additions and 182 deletions

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-nested-ternary */
/** General functions to format or beautify strings */
import { CMOptions } from '../../Config/VariablesAndData';
@@ -78,6 +77,7 @@ export function Beautify(num, floats, forced) {
}
}
if (answer === '') {
// eslint-disable-next-line no-console
console.log(
`Could not beautify number with Cookie Monster Beautify: ${num}`,
);
@@ -86,7 +86,7 @@ export function Beautify(num, floats, forced) {
if (CMOptions.ScaleSeparator) answer = answer.replace('.', ',');
return answer;
}
console.log(`Could not beautify number with Cookie Monster Beautify: ${num}`);
console.log(`Could not beautify number with Cookie Monster Beautify: ${num}`); // eslint-disable-line no-console
return BackupFunctions.Beautify(num, floats);
}
@@ -119,15 +119,15 @@ export function FormatTime(time, longFormat) {
return longFormat ? 'Over 9000 days!' : '>9000d';
str +=
y > 0
? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, `
? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, ` // eslint-disable-line no-nested-ternary
: '';
str +=
d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : '';
d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : ''; // eslint-disable-line no-nested-ternary
if (str.length > 0 || h > 0)
str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `;
str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `; // eslint-disable-line no-nested-ternary
if (str.length > 0 || m > 0)
str += `${m + (longFormat ? (m === 1 ? ' minute' : ' minutes') : 'm')}, `;
str += s + (longFormat ? (s === 1 ? ' second' : ' seconds') : 's');
str += `${m + (longFormat ? (m === 1 ? ' minute' : ' minutes') : 'm')}, `; // eslint-disable-line no-nested-ternary
str += s + (longFormat ? (s === 1 ? ' second' : ' seconds') : 's'); // eslint-disable-line no-nested-ternary
}
return str;
}

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-nested-ternary */
import {
CacheObjects1,
CacheObjects10,
@@ -72,10 +71,10 @@ export default function UpdateBuildings() {
});
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) >
return ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
ColoursOrdering.indexOf(b.color)
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color)
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1
@@ -90,10 +89,10 @@ export default function UpdateBuildings() {
});
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) >
return ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
ColoursOrdering.indexOf(b.color)
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color)
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-nested-ternary */
import { CacheUpgrades } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import {
@@ -81,9 +80,9 @@ export default function UpdateUpgrades() {
if (CMOptions.SortUpgrades) {
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) > ColoursOrdering.indexOf(b.color)
return ColoursOrdering.indexOf(a.color) > ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color)
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
/** Section: Functions related to the Golden Cookie Timers */
import { CMOptions } from '../../Config/VariablesAndData';
@@ -28,14 +27,14 @@ export default function CreateGCTimer(cookie) {
cookie.pop();
};
GCTimer.onmouseover = function () {
cookie.l.style.filter =
cookie.l.style.filter = // eslint-disable-line no-param-reassign
'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';
cookie.l.style.webkitFilter =
cookie.l.style.webkitFilter = // eslint-disable-line no-param-reassign
'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';
};
GCTimer.onmouseout = function () {
cookie.l.style.filter = '';
cookie.l.style.webkitFilter = '';
cookie.l.style.filter = ''; // eslint-disable-line no-param-reassign
cookie.l.style.webkitFilter = ''; // eslint-disable-line no-param-reassign
};
GCTimers[cookie.id] = GCTimer;

View File

@@ -218,7 +218,6 @@ export default function CreatePrefOption(config) {
input.min = Config[config].min;
input.max = Config[config].max;
input.oninput = function () {
if (this.value > this.max) console.log('TEST');
CMOptions[config] = this.value;
SaveConfig();
RefreshScale();

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { CMOptions } from '../../../Config/VariablesAndData';
function CrateTooltipLockedAchievements(me) {
@@ -58,9 +57,11 @@ export default function AddMissingAchievements() {
if (!achievsCrate.className.includes('enabled')) {
const id = achievsCrate.onclick.toString().match(/(?<=\[).*(?=\])/g)[0];
const { icon } = Game.AchievementsById[id];
// eslint-disable-next-line no-param-reassign
achievsCrate.style.backgroundPosition = `${-icon[0] * 48}px ${
-icon[1] * 48
}px`;
// eslint-disable-next-line no-param-reassign
achievsCrate.onmouseover = function () {
if (!Game.mouseDown) {
Game.setOnCrate(this);

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { CMOptions } from '../../Config/VariablesAndData';
import {
ColourTextPre,
@@ -163,7 +162,7 @@ export function TooltipCreateCalculationSection(tooltip) {
tooltip.appendChild(income);
tooltip.appendChild(TooltipCreateHeader('Bonus Cookies per Click'));
tooltip.lastChild.style.display = 'none';
tooltip.lastChild.style.display = 'none'; // eslint-disable-line no-param-reassign
const click = document.createElement('div');
click.style.marginBottom = '4px';
click.style.color = 'white';
@@ -186,7 +185,8 @@ export function TooltipCreateCalculationSection(tooltip) {
tooltip.appendChild(
TooltipCreateHeader('Production left till next achievement'),
);
tooltip.lastChild.id = 'CMTooltipProductionHeader'; // Assign a id in order to hid when no achiev's are left
// Assign a id in order to hide when no achiev's are left
tooltip.lastChild.id = 'CMTooltipProductionHeader'; // eslint-disable-line no-param-reassign
const production = document.createElement('div');
production.id = 'CMTooltipProduction';
tooltip.appendChild(production);

View File

@@ -1,11 +1,8 @@
/* eslint-disable no-unused-vars */
import UpdateTooltips, * as UpdateTooltip from './UpdateTooltips';
import { TooltipCreateTooltipBox } from './CreateTooltip';
import UpdateTooltips from './UpdateTooltips';
import {
Beautify,
GetTimeColour,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import CopyData from '../../Sim/SimulationData/CopyData';
import {
SimpleTooltipElements,
TooltipName,
@@ -143,8 +140,8 @@ export function CreateTooltip(type, name) {
}
// Sets global variables used by CM.Disp.UpdateTooltip()
TooltipType = type;
TooltipName = name;
TooltipType = type; // eslint-disable-line no-unused-vars
TooltipName = name; // eslint-disable-line no-unused-vars
UpdateTooltips();

View File

@@ -1,4 +1,3 @@
/* eslint-disable prefer-const */
/**
* Section: Variables used in Disp functions */
@@ -91,15 +90,15 @@ export const SimpleTooltipElements = {};
* These are variables used by the functions that create tooltips for wrinklers
* See CM.Disp.CheckWrinklerTooltip(), CM.Disp.UpdateWrinklerTooltip() and CM.Main.AddWrinklerAreaDetect()
*/
export let TooltipWrinklerArea = 0;
export let TooltipWrinkler = -1;
export let TooltipWrinklerArea = 0; // eslint-disable-line prefer-const
export let TooltipWrinkler = -1; // eslint-disable-line prefer-const
/**
* This array is used to store whether a Wrinkler tooltip is being shown or not
* [i] = 1 means tooltip is being shown, [i] = 0 means hidden
* It is used by CM.Disp.CheckWrinklerTooltip() and CM.Main.AddWrinklerAreaDetect()
*/
export let TooltipWrinklerBeingShown = [];
export let TooltipWrinklerBeingShown = []; // eslint-disable-line prefer-const
export let CMLastAscendState;
export let CMSayTime;
@@ -107,9 +106,9 @@ export let CMSayTime;
/**
* These are variables used to create various displays when the game is loaded on the "sell all" screen
*/
export let LastTargetBotBar = 1;
export let LastTargetBuildings = 1;
export let LastTargetTooltipBuilding = 1;
export let LastTargetBotBar = 1; // eslint-disable-line prefer-const
export let LastTargetBuildings = 1; // eslint-disable-line prefer-const
export let LastTargetTooltipBuilding = 1; // eslint-disable-line prefer-const
/**
* These arrays are used in the stats page to show
@@ -133,12 +132,12 @@ export const BuffColours = {
/**
* This array is used to track GC timers
*/
export let GCTimers = {};
export let GCTimers = {}; // eslint-disable-line prefer-const
/**
* Used to store the number of cookies to be displayed in the tab-title
*/
export let Title = '';
export let Title = ''; // eslint-disable-line prefer-const
export let TooltipPrice;
export let TooltipBonusIncome;
@@ -152,4 +151,4 @@ export let LastNumberOfTimers;
/**
* This stores the names of settings shown in the favourites section
*/
export let FavouriteSettings = [];
export let FavouriteSettings = []; // eslint-disable-line prefer-const