mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
Merge pull request #3114 from ApamNapat/turn_on_three_more_lints
Mixing spaces and tabs, extra semicolons and lonely ifs are now illegal
This commit is contained in:
commit
f65221b1f1
@ -137,7 +137,7 @@ module.exports = {
|
||||
"no-ex-assign": ["off"],
|
||||
"no-extra-boolean-cast": ["error"],
|
||||
"no-extra-parens": ["off"],
|
||||
"no-extra-semi": ["off"],
|
||||
"no-extra-semi": ["error"],
|
||||
"no-eval": ["off"],
|
||||
"no-extend-native": ["off"],
|
||||
"no-extra-bind": ["error"],
|
||||
@ -166,12 +166,12 @@ module.exports = {
|
||||
"no-label-var": ["error"],
|
||||
"no-labels": ["off"],
|
||||
"no-lone-blocks": ["error"],
|
||||
"no-lonely-if": ["off"],
|
||||
"no-lonely-if": ["error"],
|
||||
"no-loop-func": ["off"],
|
||||
"no-magic-numbers": ["off"],
|
||||
"no-mixed-operators": ["off"],
|
||||
"no-mixed-requires": ["error"],
|
||||
"no-mixed-spaces-and-tabs": ["off"],
|
||||
"no-mixed-spaces-and-tabs": ["error"],
|
||||
"no-multi-assign": ["off"],
|
||||
"no-multi-spaces": ["off"],
|
||||
"no-multi-str": ["error"],
|
||||
|
@ -337,23 +337,21 @@ async function restoreIfNewerExists(window) {
|
||||
let bestMatch;
|
||||
if (!steam.data && !disk.data) {
|
||||
log.info("No data to import");
|
||||
} else {
|
||||
} else if (!steam.data) {
|
||||
// We'll just compare using the lastSave field for now.
|
||||
if (!steam.data) {
|
||||
log.debug('Best potential save match: Disk');
|
||||
bestMatch = disk;
|
||||
} else if (!disk.data) {
|
||||
log.debug('Best potential save match: Steam Cloud');
|
||||
bestMatch = steam;
|
||||
} else if ((steam.data.lastSave >= disk.data.lastSave)
|
||||
|| (steam.data.playtime + lowPlaytime > disk.data.playtime)) {
|
||||
// We want to prioritze steam data if the playtime is very close
|
||||
log.debug('Best potential save match: Steam Cloud');
|
||||
bestMatch = steam;
|
||||
} else {
|
||||
log.debug('Best potential save match: disk');
|
||||
bestMatch = disk;
|
||||
}
|
||||
log.debug('Best potential save match: Disk');
|
||||
bestMatch = disk;
|
||||
} else if (!disk.data) {
|
||||
log.debug('Best potential save match: Steam Cloud');
|
||||
bestMatch = steam;
|
||||
} else if ((steam.data.lastSave >= disk.data.lastSave)
|
||||
|| (steam.data.playtime + lowPlaytime > disk.data.playtime)) {
|
||||
// We want to prioritze steam data if the playtime is very close
|
||||
log.debug('Best potential save match: Steam Cloud');
|
||||
bestMatch = steam;
|
||||
} else {
|
||||
log.debug('Best potential save match: disk');
|
||||
bestMatch = disk;
|
||||
}
|
||||
if (bestMatch) {
|
||||
if (bestMatch.data.lastSave > currentData.lastSave + 5000) {
|
||||
|
@ -218,8 +218,7 @@ export function SellProduct(product: Product, city: string, amt: string, price:
|
||||
product.sllman[city][0] = false;
|
||||
product.sllman[city][1] = "";
|
||||
}
|
||||
} else {
|
||||
if (all) {
|
||||
} else if (all) {
|
||||
for (let i = 0; i < cities.length; ++i) {
|
||||
const tempCity = cities[i];
|
||||
product.sllman[tempCity][0] = true;
|
||||
@ -229,7 +228,6 @@ export function SellProduct(product: Product, city: string, amt: string, price:
|
||||
product.sllman[city][0] = true;
|
||||
product.sllman[city][1] = qty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,7 @@ export function ThrowPartyModal(props: IProps): React.ReactElement {
|
||||
function throwParty(): void {
|
||||
if (cost === null || isNaN(cost) || cost < 0) {
|
||||
dialogBoxCreate("Invalid value entered");
|
||||
} else {
|
||||
if (!canParty) {
|
||||
} else if (!canParty) {
|
||||
dialogBoxCreate("You don't have enough company funds to throw a party!");
|
||||
} else {
|
||||
const mult = ThrowParty(corp, props.office, cost);
|
||||
@ -46,7 +45,6 @@ export function ThrowPartyModal(props: IProps): React.ReactElement {
|
||||
props.rerender();
|
||||
props.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function EffectText(): React.ReactElement {
|
||||
|
@ -166,8 +166,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
|
||||
|
||||
if (sing) {
|
||||
return "You purchased " + aug.name;
|
||||
} else {
|
||||
if (!Settings.SuppressBuyAugmentationConfirmation) {
|
||||
} else if (!Settings.SuppressBuyAugmentationConfirmation) {
|
||||
dialogBoxCreate(
|
||||
"You purchased " +
|
||||
aug.name +
|
||||
@ -177,7 +176,6 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
|
||||
"augmentations will now be more expensive.",
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dialogBoxCreate(
|
||||
"Hmm, something went wrong when trying to purchase an Augmentation. " +
|
||||
|
@ -52,21 +52,19 @@ export function SpecialLocation(props: IProps): React.ReactElement {
|
||||
if (p.inBladeburner()) {
|
||||
// Enter Bladeburner division
|
||||
router.toBladeburner();
|
||||
} else {
|
||||
} else if (p.strength >= 100 && p.defense >= 100 && p.dexterity >= 100 && p.agility >= 100) {
|
||||
// Apply for Bladeburner division
|
||||
if (p.strength >= 100 && p.defense >= 100 && p.dexterity >= 100 && p.agility >= 100) {
|
||||
p.startBladeburner({ new: true });
|
||||
dialogBoxCreate("You have been accepted into the Bladeburner division!");
|
||||
setRerender((old) => !old);
|
||||
p.startBladeburner({new: true});
|
||||
dialogBoxCreate("You have been accepted into the Bladeburner division!");
|
||||
setRerender((old) => !old);
|
||||
|
||||
const worldHeader = document.getElementById("world-menu-header");
|
||||
if (worldHeader instanceof HTMLElement) {
|
||||
worldHeader.click();
|
||||
worldHeader.click();
|
||||
}
|
||||
} else {
|
||||
dialogBoxCreate("Rejected! Please apply again when you have 100 of each combat stat (str, def, dex, agi)");
|
||||
const worldHeader = document.getElementById("world-menu-header");
|
||||
if (worldHeader instanceof HTMLElement) {
|
||||
worldHeader.click();
|
||||
worldHeader.click();
|
||||
}
|
||||
} else {
|
||||
dialogBoxCreate("Rejected! Please apply again when you have 100 of each combat stat (str, def, dex, agi)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,11 +608,9 @@ export function process(this: IPlayer, router: IRouter, numCycles = 1): void {
|
||||
if (this.workPartTime(numCycles)) {
|
||||
router.toCity();
|
||||
}
|
||||
} else {
|
||||
if (this.work(numCycles)) {
|
||||
} else if (this.work(numCycles)) {
|
||||
router.toCity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2244,8 +2242,7 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
||||
if (!(fulcrumSecretServer instanceof Server)) throw new Error("Fulcrum Secret Technologies should be normal server");
|
||||
if (fulcrumSecretServer == null) {
|
||||
console.error("Could not find Fulcrum Secret Technologies Server");
|
||||
} else {
|
||||
if (
|
||||
} else if (
|
||||
!fulcrumsecrettechonologiesFac.isBanned &&
|
||||
!fulcrumsecrettechonologiesFac.isMember &&
|
||||
!fulcrumsecrettechonologiesFac.alreadyInvited &&
|
||||
@ -2254,7 +2251,6 @@ export function checkForFactionInvitations(this: IPlayer): Faction[] {
|
||||
) {
|
||||
invitedFactions.push(fulcrumsecrettechonologiesFac);
|
||||
}
|
||||
}
|
||||
|
||||
//BitRunners
|
||||
const bitrunnersFac = Factions["BitRunners"];
|
||||
|
@ -75,12 +75,10 @@ function giveSourceFile(bitNodeNumber: number): void {
|
||||
export function enterBitNode(router: IRouter, flume: boolean, destroyedBitNode: number, newBitNode: number): void {
|
||||
if (!flume) {
|
||||
giveSourceFile(destroyedBitNode);
|
||||
} else {
|
||||
if (SourceFileFlags[5] === 0 && newBitNode !== 5) {
|
||||
} else if (SourceFileFlags[5] === 0 && newBitNode !== 5) {
|
||||
Player.intelligence = 0;
|
||||
Player.intelligence_exp = 0;
|
||||
}
|
||||
}
|
||||
if (newBitNode === 5 && Player.intelligence === 0) {
|
||||
Player.intelligence = 1;
|
||||
}
|
||||
|
@ -165,8 +165,7 @@ function executeOrder(order: Order, refs: IProcessOrderRefs): void {
|
||||
|
||||
console.error("Could not find the following Order in Order Book: ");
|
||||
console.error(order);
|
||||
} else {
|
||||
if (isBuy) {
|
||||
} else if (isBuy) {
|
||||
dialogBoxCreate(
|
||||
<>
|
||||
Failed to execute {order.type} for {stock.symbol} @ <Money money={order.price} /> ({pos}). This is most likely
|
||||
@ -174,5 +173,4 @@ function executeOrder(order: Order, refs: IProcessOrderRefs): void {
|
||||
</>,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,13 +213,11 @@ export class Stock {
|
||||
} else {
|
||||
this.otlkMag -= changeAmt;
|
||||
}
|
||||
} else {
|
||||
} else if (this.b) {
|
||||
// Forecast decreases
|
||||
if (this.b) {
|
||||
this.otlkMag -= changeAmt;
|
||||
} else {
|
||||
this.otlkMag += changeAmt;
|
||||
}
|
||||
this.otlkMag -= changeAmt;
|
||||
} else {
|
||||
this.otlkMag += changeAmt;
|
||||
}
|
||||
|
||||
this.otlkMag = Math.min(this.otlkMag, 50);
|
||||
|
@ -113,11 +113,9 @@ export function StockTicker(props: IProps): React.ReactElement {
|
||||
if (qty > stock.playerShares) {
|
||||
return <>You do not have this many shares in the Long position</>;
|
||||
}
|
||||
} else {
|
||||
if (qty > stock.playerShortShares) {
|
||||
} else if (qty > stock.playerShortShares) {
|
||||
return <>You do not have this many shares in the Short position</>;
|
||||
}
|
||||
}
|
||||
|
||||
const cost = getSellTransactionGain(stock, qty, position);
|
||||
if (cost == null) {
|
||||
|
@ -68,13 +68,11 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (inQuote === ``) {
|
||||
} else if (inQuote === ``) {
|
||||
inQuote = `"`;
|
||||
} else if (inQuote === `"`) {
|
||||
inQuote = ``;
|
||||
}
|
||||
}
|
||||
} else if (c === "'") {
|
||||
// Single quotes, same thing as above
|
||||
if (!escaped && prevChar === " ") {
|
||||
@ -88,13 +86,11 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (inQuote === ``) {
|
||||
} else if (inQuote === ``) {
|
||||
inQuote = `'`;
|
||||
} else if (inQuote === `'`) {
|
||||
inQuote = ``;
|
||||
}
|
||||
}
|
||||
} else if (c === " " && inQuote === ``) {
|
||||
const arg = command.substr(start, i - start);
|
||||
|
||||
|
@ -179,13 +179,11 @@ export function ls(
|
||||
i--;
|
||||
if (!style) {
|
||||
terminal.print(row);
|
||||
} else {
|
||||
if (linked) {
|
||||
} else if (linked) {
|
||||
terminal.printRaw(<ClickableScriptRow row={row} prefix={prefix} hostname={server.hostname} />);
|
||||
} else {
|
||||
terminal.printRaw(<span style={style}>{row}</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,9 @@ export function unalias(
|
||||
if (args.length !== 1) {
|
||||
terminal.error("Incorrect usage of unalias name. Usage: unalias [alias]");
|
||||
return;
|
||||
} else {
|
||||
if (removeAlias(args[0] + "")) {
|
||||
} else if (removeAlias(args[0] + "")) {
|
||||
terminal.print(`Removed alias ${args[0]}`);
|
||||
} else {
|
||||
terminal.error(`No such alias exists: ${args[0]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,28 +66,22 @@ export function tabCompletion(
|
||||
if (arg === "") {
|
||||
if (longestStartSubstr === command) {
|
||||
return allPossibilities;
|
||||
} else {
|
||||
if (semiColonIndex === -1) {
|
||||
} else if (semiColonIndex === -1) {
|
||||
// No semicolon, so replace the whole command
|
||||
return longestStartSubstr;
|
||||
} else {
|
||||
// Replace only after the last semicolon
|
||||
return `${oldValue.slice(0, semiColonIndex + 1)} ${longestStartSubstr}`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (longestStartSubstr === arg) {
|
||||
} else if (longestStartSubstr === arg) {
|
||||
// List all possible options
|
||||
return allPossibilities;
|
||||
} else {
|
||||
if (semiColonIndex == -1) {
|
||||
} else if (semiColonIndex == -1) {
|
||||
// No semicolon, so replace the whole command
|
||||
return `${command} ${longestStartSubstr}`;
|
||||
} else {
|
||||
// Replace only after the last semicolon
|
||||
return `${oldValue.slice(0, semiColonIndex + 1)} ${command} ${longestStartSubstr}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,7 @@ export function validateObject<Type extends Record<string, unknown>, Key extends
|
||||
if (paramValidator !== undefined) {
|
||||
if (typeof paramValidator === 'function') {
|
||||
paramValidator(obj, key);
|
||||
} else {
|
||||
if (paramValidator.func !== undefined) {
|
||||
} else if (paramValidator.func !== undefined) {
|
||||
paramValidator.func(obj, validator, key);
|
||||
} else {
|
||||
if ((typeof obj[key]) !== (typeof paramValidator.default)) {
|
||||
@ -31,7 +30,6 @@ export function validateObject<Type extends Record<string, unknown>, Key extends
|
||||
if (obj[key] > paramValidator.max) obj[key] = paramValidator.max as Type[Key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user