mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-24 07:02:26 +01:00
format and lint
This commit is contained in:
parent
9774235404
commit
3addda7173
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -75,7 +75,7 @@ interface Player {
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface Multipliers {
|
export interface Multipliers {
|
||||||
/** Multiplier to hacking skill */
|
/** Multiplier to hacking skill */
|
||||||
hacking?: number;
|
hacking?: number;
|
||||||
/** Multiplier to strength skill */
|
/** Multiplier to strength skill */
|
||||||
|
@ -803,7 +803,9 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
...colorProps,
|
...colorProps,
|
||||||
};
|
};
|
||||||
|
|
||||||
const scriptTabText = `${hostname}:~${fileName.startsWith("/") ? "" : "/"}${fileName} ${dirty(index)}`;
|
const scriptTabText = `${hostname}:~${fileName.startsWith("/") ? "" : "/"}${fileName} ${dirty(
|
||||||
|
index,
|
||||||
|
)}`;
|
||||||
return (
|
return (
|
||||||
<Draggable
|
<Draggable
|
||||||
key={fileName + hostname}
|
key={fileName + hostname}
|
||||||
|
@ -62,7 +62,7 @@ class NumeralFormatter {
|
|||||||
if (n === Infinity) return "∞";
|
if (n === Infinity) return "∞";
|
||||||
for (let i = 0; i < extraFormats.length; i++) {
|
for (let i = 0; i < extraFormats.length; i++) {
|
||||||
if (extraFormats[i] < nAbs && nAbs <= extraFormats[i] * 1000) {
|
if (extraFormats[i] < nAbs && nAbs <= extraFormats[i] * 1000) {
|
||||||
return this.format(n as number / extraFormats[i], "0." + "0".repeat(decimalPlaces)) + extraNotations[i];
|
return this.format((n as number) / extraFormats[i], "0." + "0".repeat(decimalPlaces)) + extraNotations[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nAbs < 1000) {
|
if (nAbs < 1000) {
|
||||||
|
@ -5,8 +5,6 @@ import { RunningScript } from "../../../src/Script/RunningScript";
|
|||||||
import { Script } from "../../../src/Script/Script";
|
import { Script } from "../../../src/Script/Script";
|
||||||
import { WorkerScript } from "../../../src/Netscript/WorkerScript";
|
import { WorkerScript } from "../../../src/Netscript/WorkerScript";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
||||||
const ScriptBaseCost = RamCostConstants.ScriptBaseRamCost;
|
const ScriptBaseCost = RamCostConstants.ScriptBaseRamCost;
|
||||||
// Creates a mock RunningScript object
|
// Creates a mock RunningScript object
|
||||||
@ -85,10 +83,9 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
|||||||
// Run the function through the workerscript's args
|
// Run the function through the workerscript's args
|
||||||
const scope = workerScript.env.vars;
|
const scope = workerScript.env.vars;
|
||||||
let curr = fnDesc.reduce((prev, curr) => {
|
let curr = fnDesc.reduce((prev, curr) => {
|
||||||
try{
|
try {
|
||||||
return prev[curr];
|
return prev[curr];
|
||||||
}
|
} catch {
|
||||||
catch{
|
|
||||||
throw new Error(`Invalid function: [${fnDesc}]`);
|
throw new Error(`Invalid function: [${fnDesc}]`);
|
||||||
}
|
}
|
||||||
}, scope as any);
|
}, scope as any);
|
||||||
@ -143,14 +140,13 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
|||||||
scriptRef: runningScript,
|
scriptRef: runningScript,
|
||||||
};
|
};
|
||||||
workerScript.env.vars = NetscriptFunctions(workerScript as unknown as WorkerScript);
|
workerScript.env.vars = NetscriptFunctions(workerScript as unknown as WorkerScript);
|
||||||
|
|
||||||
// Run the function through the workerscript's args
|
// Run the function through the workerscript's args
|
||||||
const scope = workerScript.env.vars;
|
const scope = workerScript.env.vars;
|
||||||
let curr = fnDesc.reduce((prev, curr) => {
|
let curr = fnDesc.reduce((prev, curr) => {
|
||||||
try{
|
try {
|
||||||
return prev[curr];
|
return prev[curr];
|
||||||
}
|
} catch {
|
||||||
catch{
|
|
||||||
throw new Error(`Invalid function: [${fnDesc}]`);
|
throw new Error(`Invalid function: [${fnDesc}]`);
|
||||||
}
|
}
|
||||||
}, scope as any);
|
}, scope as any);
|
||||||
|
@ -283,8 +283,8 @@ describe("Terminal Directory Tests", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return false for invalid inputs (inputs that aren't filepaths)", function () {
|
it("should return false for invalid inputs (inputs that aren't filepaths)", function () {
|
||||||
expect(isInRootDirectory(null as unknown as string)).toEqual(false);
|
expect(isInRootDirectory(null as unknown as string)).toEqual(false);
|
||||||
expect(isInRootDirectory(undefined as unknown as string)).toEqual(false);
|
expect(isInRootDirectory(undefined as unknown as string)).toEqual(false);
|
||||||
expect(isInRootDirectory("")).toEqual(false);
|
expect(isInRootDirectory("")).toEqual(false);
|
||||||
expect(isInRootDirectory(" ")).toEqual(false);
|
expect(isInRootDirectory(" ")).toEqual(false);
|
||||||
expect(isInRootDirectory("a")).toEqual(false);
|
expect(isInRootDirectory("a")).toEqual(false);
|
||||||
|
@ -241,6 +241,8 @@ describe("Finding the number furthest away from 0", () => {
|
|||||||
expect(numeralWrapper.largestAbsoluteNumber(789123, -123456, -456789)).toEqual(789123);
|
expect(numeralWrapper.largestAbsoluteNumber(789123, -123456, -456789)).toEqual(789123);
|
||||||
});
|
});
|
||||||
test("Should return 0 for invalid input", () => {
|
test("Should return 0 for invalid input", () => {
|
||||||
expect(numeralWrapper.largestAbsoluteNumber("abc" as unknown as number, undefined, null as unknown as number)).toEqual(0);
|
expect(
|
||||||
|
numeralWrapper.largestAbsoluteNumber("abc" as unknown as number, undefined, null as unknown as number),
|
||||||
|
).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user