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