Skip to content

Commit

Permalink
more lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Gagnon committed May 25, 2022
1 parent c1650e3 commit ca2e225
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
parser: "@typescript-eslint/parser",
parserOptions: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
"start:container": "webpack-dev-server --progress --env.devServer --mode development --env.runInContainer",
"build": "webpack --mode production",
"build:dev": "webpack --mode development",
"lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src test",
"lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 .",
"lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src",
"lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 src",
"lint:report-diff": "eslint --max-warnings 0 $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs)",
"preinstall": "node ./tools/engines-check/engines-check.js",
"postinstall": "cd electron && npm install",
Expand Down
12 changes: 7 additions & 5 deletions src/ui/React/RecoveryRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export function RecoveryRoot({ router, softReset, errorData, resetError }: IProp
Settings.AutosaveInterval = 0;

useEffect(() => {
load().then((content) => {
const epochTime = Math.round(Date.now() / 1000);
const filename = `RECOVERY_BITBURNER_${epochTime}.json`;
download(filename, content);
});
load()
.then((content) => {
const epochTime = Math.round(Date.now() / 1000);
const filename = `RECOVERY_BITBURNER_${epochTime}.json`;
download(filename, content);
})
.catch((err) => console.error(err));
}, []);

return (
Expand Down
3 changes: 2 additions & 1 deletion src/ui/React/StatsRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Typography, TableCell, TableRow } from "@mui/material";
import { numeralWrapper } from "../numeralFormat";
import { formatNumber } from "../../utils/StringHelperFunctions";
import { characterOverviewStyles as useStyles } from "./CharacterOverview";
import { ClassNameMap } from "@material-ui/core/styles/withStyles";

interface ITableRowData {
content?: string;
Expand All @@ -15,7 +16,7 @@ interface ITableRowData {
interface IProps {
name: string;
color: string;
classes?: any;
classes?: ClassNameMap;
data?: ITableRowData;
children?: React.ReactElement;
}
Expand Down
12 changes: 6 additions & 6 deletions src/utils/CompressionContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function comprLZEncode(plain: string): string {
for (let offset = 1; offset <= Math.min(9, i); ++offset) {
if (plain[i - offset] === c) {
// start new backreference
set(new_state, offset, 1, string + length + plain.substring(i - length, i));
set(new_state, offset, 1, string + String(length) + plain.substring(i - length, i));
}
}
}
Expand All @@ -99,17 +99,17 @@ export function comprLZEncode(plain: string): string {
set(new_state, offset, length + 1, string);
} else {
// start new backreference
set(new_state, offset, 1, string + "9" + offset + "0");
set(new_state, offset, 1, string + "9" + String(offset) + "0");
}
}

// start new literal
set(new_state, 0, 1, string + length + offset);
set(new_state, 0, 1, string + String(length) + String(offset));

// end current backreference and start new backreference
for (let new_offset = 1; new_offset <= Math.min(9, i); ++new_offset) {
if (plain[i - new_offset] === c) {
set(new_state, new_offset, 1, string + length + offset + "0");
set(new_state, new_offset, 1, string + String(length) + String(offset) + "0");
}
}
}
Expand All @@ -128,7 +128,7 @@ export function comprLZEncode(plain: string): string {
continue;
}

string += len + plain.substring(plain.length - len, plain.length);
string += String(len) + plain.substring(plain.length - len, plain.length);
if (result == null || string.length < result.length) {
result = string;
} else if (string.length == result.length && Math.random() < 0.5) {
Expand All @@ -143,7 +143,7 @@ export function comprLZEncode(plain: string): string {
continue;
}

string += len + "" + offset;
string += String(len) + "" + String(offset);
if (result == null || string.length < result.length) {
result = string;
} else if (string.length == result.length && Math.random() < 0.5) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ErrorHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function getErrorForDisplay(error: Error, errorInfo?: React.ErrorInfo, pa
const fileName = (metadata.error as any).fileName;
const features =
`lang=${metadata.features.language} cookiesEnabled=${metadata.features.cookiesEnabled.toString()}` +
` doNotTrack=${metadata.features.doNotTrack} indexedDb=${metadata.features.indexedDb.toString()}`;
` doNotTrack=${metadata.features.doNotTrack ?? "null"} indexedDb=${metadata.features.indexedDb.toString()}`;

const title = `${metadata.error.name}: ${metadata.error.message}${metadata.page && ` (at "${Page[metadata.page]}")`}`;
const body = `
Expand Down
2 changes: 1 addition & 1 deletion src/utils/JSONReviver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { validateObject } from "./Validator";

interface IReviverValue {
export interface IReviverValue {
ctor: string;
data: any;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/MoneySourceTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This is an object that is used to keep track of where all of the player's
* money is coming from (or going to)
*/
import { Generic_fromJSON, Generic_toJSON, Reviver } from "./JSONReviver";
import { Generic_fromJSON, Generic_toJSON, Reviver, IReviverValue } from "./JSONReviver";

export class MoneySourceTracker {
// eslint-disable-next-line @typescript-eslint/ban-types
Expand Down Expand Up @@ -56,7 +56,7 @@ export class MoneySourceTracker {

// Initiatizes a MoneySourceTracker object from a JSON save state.
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
static fromJSON(value: any): MoneySourceTracker {
static fromJSON(value: IReviverValue): MoneySourceTracker {
return Generic_fromJSON(MoneySourceTracker, value.data);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/helpers/clearObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function clearObject(obj: unknown): void {
if (typeof obj !== "object" || obj === null || obj === undefined) return;
for (const key of Object.getOwnPropertyNames(obj)) {
if (obj.hasOwnProperty(key)) {
// tslint:disable-next-line:no-dynamic-delete
delete (obj as any)[key];
const o = obj as Record<string, unknown>;
for (const key of Object.getOwnPropertyNames(o)) {
if (o.hasOwnProperty(key)) {
delete o[key];
}
}
}

0 comments on commit ca2e225

Please sign in to comment.