mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
lint
This commit is contained in:
parent
6fef46d5df
commit
76ccb0ba36
@ -4,7 +4,11 @@ module.exports = {
|
||||
commonjs: true,
|
||||
es6: false,
|
||||
},
|
||||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
// "plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 8,
|
||||
@ -12,6 +16,7 @@ module.exports = {
|
||||
ecmaFeatures: {
|
||||
experimentalObjectRestSpread: true,
|
||||
},
|
||||
project: ["./tsconfig.json", "./test/tsconfig.json", "./tools/tsconfig.json", "./test/cypress/tsconfig.json"],
|
||||
},
|
||||
plugins: ["@typescript-eslint"],
|
||||
rules: {
|
||||
|
@ -114,7 +114,7 @@
|
||||
"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 .",
|
||||
"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: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",
|
||||
|
@ -2029,12 +2029,12 @@ export class Bladeburner implements IBladeburner {
|
||||
this.stamina = Math.min(this.maxStamina, this.stamina);
|
||||
|
||||
// Count increase for contracts/operations
|
||||
for (const contract of Object.values(this.contracts) as Contract[]) {
|
||||
for (const contract of Object.values(this.contracts) ) {
|
||||
const growthF = Growths[contract.name];
|
||||
if (growthF === undefined) throw new Error(`growth formula for action '${contract.name}' is undefined`);
|
||||
contract.count += (seconds * growthF()) / BladeburnerConstants.ActionCountGrowthPeriod;
|
||||
}
|
||||
for (const op of Object.values(this.operations) as Operation[]) {
|
||||
for (const op of Object.values(this.operations) ) {
|
||||
const growthF = Growths[op.name];
|
||||
if (growthF === undefined) throw new Error(`growth formula for action '${op.name}' is undefined`);
|
||||
if (growthF !== undefined) {
|
||||
|
@ -74,7 +74,7 @@ export function GeneralActionElem(props: IProps): React.ReactElement {
|
||||
<CopyableText value={props.action.name} />
|
||||
<StartButton
|
||||
bladeburner={props.bladeburner}
|
||||
type={ActionTypes[props.action.name as string]}
|
||||
type={ActionTypes[props.action.name ]}
|
||||
name={props.action.name}
|
||||
rerender={rerender}
|
||||
/>
|
||||
|
@ -22,7 +22,7 @@ export function Augmentations(props: IProps): React.ReactElement {
|
||||
const [augmentation, setAugmentation] = useState("Augmented Targeting I");
|
||||
|
||||
function setAugmentationDropdown(event: SelectChangeEvent<string>): void {
|
||||
setAugmentation(event.target.value as string);
|
||||
setAugmentation(event.target.value );
|
||||
}
|
||||
function queueAug(): void {
|
||||
props.player.queueAugmentation(augmentation);
|
||||
|
@ -15,7 +15,7 @@ import { CodingContractTypes } from "../../CodingContracts";
|
||||
export function CodingContracts(): React.ReactElement {
|
||||
const [codingcontract, setCodingcontract] = useState("Find Largest Prime Factor");
|
||||
function setCodingcontractDropdown(event: SelectChangeEvent<string>): void {
|
||||
setCodingcontract(event.target.value as string);
|
||||
setCodingcontract(event.target.value );
|
||||
}
|
||||
|
||||
function specificContract(): void {
|
||||
|
@ -18,7 +18,7 @@ const bigNumber = 1e12;
|
||||
export function Companies(): React.ReactElement {
|
||||
const [company, setCompany] = useState(FactionNames.ECorp as string);
|
||||
function setCompanyDropdown(event: SelectChangeEvent<string>): void {
|
||||
setCompany(event.target.value as string);
|
||||
setCompany(event.target.value );
|
||||
}
|
||||
function resetCompanyRep(): void {
|
||||
AllCompanies[company].playerReputation = 0;
|
||||
|
@ -29,7 +29,7 @@ export function Factions(props: IProps): React.ReactElement {
|
||||
const [faction, setFaction] = useState(FactionNames.Illuminati as string);
|
||||
|
||||
function setFactionDropdown(event: SelectChangeEvent<string>): void {
|
||||
setFaction(event.target.value as string);
|
||||
setFaction(event.target.value );
|
||||
}
|
||||
|
||||
function receiveInvite(): void {
|
||||
|
@ -19,7 +19,7 @@ interface IProps {
|
||||
export function Programs(props: IProps): React.ReactElement {
|
||||
const [program, setProgram] = useState("NUKE.exe");
|
||||
function setProgramDropdown(event: SelectChangeEvent<string>): void {
|
||||
setProgram(event.target.value as string);
|
||||
setProgram(event.target.value );
|
||||
}
|
||||
function addProgram(): void {
|
||||
if (!props.player.hasProgram(program)) {
|
||||
|
@ -6,20 +6,13 @@ import AccordionDetails from "@mui/material/AccordionDetails";
|
||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { saveObject } from "../../SaveObject";
|
||||
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
|
||||
import { Upload } from "@mui/icons-material";
|
||||
import { Button } from "@mui/material";
|
||||
import { OptionSwitch } from "../../ui/React/OptionSwitch";
|
||||
|
||||
// Update as additional BitNodes get implemented
|
||||
|
||||
interface IProps {
|
||||
player: IPlayer;
|
||||
}
|
||||
|
||||
export function SaveFile(props: IProps): React.ReactElement {
|
||||
export function SaveFile(): React.ReactElement {
|
||||
const importInput = useRef<HTMLInputElement>(null);
|
||||
const [saveFile, setSaveFile] = useState("");
|
||||
const [restoreScripts, setRestoreScripts] = useState(true);
|
||||
|
@ -15,7 +15,7 @@ import MenuItem from "@mui/material/MenuItem";
|
||||
export function Servers(): React.ReactElement {
|
||||
const [server, setServer] = useState("home");
|
||||
function setServerDropdown(event: SelectChangeEvent<string>): void {
|
||||
setServer(event.target.value as string);
|
||||
setServer(event.target.value );
|
||||
}
|
||||
function rootServer(): void {
|
||||
const s = GetServer(server);
|
||||
|
@ -8,8 +8,8 @@ export function Unclickable(): React.ReactElement {
|
||||
|
||||
function unclickable(event: React.MouseEvent<HTMLDivElement>): void {
|
||||
if (!event.target || !(event.target instanceof Element)) return;
|
||||
const display = getComputedStyle(event.target as Element).display;
|
||||
const visibility = getComputedStyle(event.target as Element).visibility;
|
||||
const display = getComputedStyle(event.target ).display;
|
||||
const visibility = getComputedStyle(event.target ).visibility;
|
||||
if (display === "none" && visibility === "hidden" && event.isTrusted) player.giveExploit(Exploit.Unclickable);
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,8 @@ export const CurrentOptionsPage = (props: IProps): React.ReactElement => {
|
||||
}
|
||||
|
||||
function handleLocaleChange(event: SelectChangeEvent<string>): void {
|
||||
setLocale(event.target.value as string);
|
||||
Settings.Locale = event.target.value as string;
|
||||
setLocale(event.target.value );
|
||||
Settings.Locale = event.target.value ;
|
||||
}
|
||||
|
||||
function handleTimestampFormatChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -54,7 +54,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
|
||||
multiplier = getMaxNumberLevelUpgrades(props.player, node, HacknetNodeConstants.MaxLevel);
|
||||
} else {
|
||||
const levelsToMax = HacknetNodeConstants.MaxLevel - node.level;
|
||||
multiplier = Math.min(levelsToMax, purchaseMult as number);
|
||||
multiplier = Math.min(levelsToMax, purchaseMult );
|
||||
}
|
||||
|
||||
const increase =
|
||||
@ -94,7 +94,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
|
||||
multiplier = getMaxNumberRamUpgrades(props.player, node, HacknetNodeConstants.MaxRam);
|
||||
} else {
|
||||
const levelsToMax = Math.round(Math.log2(HacknetNodeConstants.MaxRam / node.ram));
|
||||
multiplier = Math.min(levelsToMax, purchaseMult as number);
|
||||
multiplier = Math.min(levelsToMax, purchaseMult );
|
||||
}
|
||||
|
||||
const increase =
|
||||
@ -144,7 +144,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
|
||||
multiplier = getMaxNumberCoreUpgrades(props.player, node, HacknetNodeConstants.MaxCores);
|
||||
} else {
|
||||
const levelsToMax = HacknetNodeConstants.MaxCores - node.cores;
|
||||
multiplier = Math.min(levelsToMax, purchaseMult as number);
|
||||
multiplier = Math.min(levelsToMax, purchaseMult );
|
||||
}
|
||||
|
||||
const increase =
|
||||
|
@ -257,7 +257,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
|
||||
|
||||
function getMaterial(divisionName: string, cityName: string, materialName: string): Material {
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
const matName = (materialName as string).replace(/ /g, "");
|
||||
const matName = (materialName ).replace(/ /g, "");
|
||||
const material = warehouse.materials[matName];
|
||||
if (material === undefined) throw new Error(`Invalid material name: '${materialName}'`);
|
||||
return material;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { INetscriptHelper } from "./INetscriptHelper";
|
||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { calculateServerGrowth } from "../Server/formulas/grow";
|
||||
import {
|
||||
|
@ -606,7 +606,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
|
||||
_ctx.log(() => "cannot backdoor this kind of server");
|
||||
return Promise.resolve();
|
||||
}
|
||||
const server = baseserver as Server;
|
||||
const server = baseserver ;
|
||||
const installTime = (calculateHackingTime(server, player) / 4) * 1000;
|
||||
|
||||
// No root access or skill level too low
|
||||
|
@ -693,7 +693,7 @@ export function Root(props: IProps): React.ReactElement {
|
||||
if (server === null) throw new Error(`Server '${closingScript.hostname}' should not be null, but it is.`);
|
||||
|
||||
const serverScriptIndex = server.scripts.findIndex((script) => script.filename === closingScript.fileName);
|
||||
if (serverScriptIndex === -1 || savedScriptCode !== server.scripts[serverScriptIndex as number].code) {
|
||||
if (serverScriptIndex === -1 || savedScriptCode !== server.scripts[serverScriptIndex ].code) {
|
||||
PromptEvent.emit({
|
||||
txt: `Do you want to save changes to ${closingScript.fileName} on ${closingScript.hostname}?`,
|
||||
resolve: (result: boolean | string) => {
|
||||
|
@ -36,7 +36,7 @@ function toNumber(n: number | IMinMaxRange): number {
|
||||
return n;
|
||||
}
|
||||
case "object": {
|
||||
const range = n as IMinMaxRange;
|
||||
const range = n ;
|
||||
value = getRandomInt(range.min, range.max);
|
||||
break;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ export function placeOrder(
|
||||
|
||||
// Process to see if it should be executed immediately
|
||||
const processOrderRefs = {
|
||||
stockMarket: StockMarket as IStockMarket,
|
||||
stockMarket: StockMarket ,
|
||||
symbolToStockMap: SymbolToStockMap,
|
||||
};
|
||||
processOrders(stock, order.type, order.pos, processOrderRefs);
|
||||
|
@ -84,7 +84,7 @@ export function mv(
|
||||
|
||||
script.filename = destPath;
|
||||
} else if (srcFile instanceof TextFile) {
|
||||
const textFile = srcFile as TextFile;
|
||||
const textFile = srcFile ;
|
||||
if (!dest.endsWith(".txt")) {
|
||||
terminal.error(`Source and destination files must have the same type`);
|
||||
return;
|
||||
|
@ -121,7 +121,7 @@ export function getTextFile(fn: string, server: BaseServer): TextFile | null {
|
||||
filename = removeLeadingSlash(filename);
|
||||
}
|
||||
|
||||
for (const file of server.textFiles as TextFile[]) {
|
||||
for (const file of server.textFiles ) {
|
||||
if (file.fn === filename) {
|
||||
return file;
|
||||
}
|
||||
|
@ -4,8 +4,5 @@ import { getRandomByte } from "./helpers/getRandomByte";
|
||||
* Generate a random IP address
|
||||
* Does not check to see if the IP already exists in the game
|
||||
*/
|
||||
export function createRandomIp(): string {
|
||||
const ip: string = getRandomByte(99) + "." + getRandomByte(9) + "." + getRandomByte(9) + "." + getRandomByte(9);
|
||||
|
||||
return ip;
|
||||
}
|
||||
export const createRandomIp = (): string =>
|
||||
`${getRandomByte(99)}.${getRandomByte(9)}.${getRandomByte(9)}.${getRandomByte(9)}`;
|
||||
|
@ -6,7 +6,6 @@ import { Company } from "../../src/Company/Company";
|
||||
import { Server } from "../../src/Server/Server";
|
||||
|
||||
import { buyStock, sellStock, shortStock, sellShort } from "../../src/StockMarket/BuyingAndSelling";
|
||||
import { IStockMarket } from "../../src/StockMarket/IStockMarket";
|
||||
import { Order } from "../../src/StockMarket/Order";
|
||||
import {
|
||||
forecastForecastChangeFromCompanyWork,
|
||||
@ -1149,7 +1148,7 @@ describe("Stock Market Tests", function () {
|
||||
Player.setMoney(100e9);
|
||||
|
||||
processOrdersRefs = {
|
||||
stockMarket: StockMarket as IStockMarket,
|
||||
stockMarket: StockMarket,
|
||||
symbolToStockMap: SymbolToStockMap,
|
||||
};
|
||||
});
|
||||
|
4
tools/tsconfig.json
Normal file
4
tools/tsconfig.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["**/*.js"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user