From 4eb59ac70c812476cbdbb4487408aa4898cefe78 Mon Sep 17 00:00:00 2001 From: BB Date: Wed, 16 Mar 2022 20:43:04 +0100 Subject: [PATCH] Turned on no-useless-concat lint and fixed it in code --- .eslintrc.js | 2 +- src/Augmentation/AugmentationHelpers.tsx | 10 +++++----- src/Bladeburner/Action.tsx | 2 +- src/Bladeburner/Skills.ts | 8 ++++---- src/Corporation/data/ResearchMetadata.ts | 4 ++-- src/Faction/FactionHelpers.tsx | 3 +-- src/Faction/ui/FactionRoot.tsx | 2 +- src/NetscriptWorker.ts | 4 ++-- .../Player/PlayerObjectGeneralMethods.tsx | 4 +--- src/RedPill.tsx | 2 +- src/ScriptEditor/ui/ScriptEditorRoot.tsx | 4 ++-- src/StockMarket/BuyingAndSelling.tsx | 2 +- src/data/codingcontracttypes.ts | 2 +- src/utils/v1APIBreak.ts | 4 ++-- tools/bump-version/index.js | 2 +- 15 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c88ebcfeb..f76817b2a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -253,7 +253,7 @@ module.exports = { "no-use-before-define": ["off"], "no-useless-call": ["off"], "no-useless-computed-key": ["error"], - "no-useless-concat": ["off"], + "no-useless-concat": ["error"], "no-useless-constructor": ["error"], "no-useless-escape": ["off"], "no-useless-rename": [ diff --git a/src/Augmentation/AugmentationHelpers.tsx b/src/Augmentation/AugmentationHelpers.tsx index 7cd2d1ce6..823c9b17b 100644 --- a/src/Augmentation/AugmentationHelpers.tsx +++ b/src/Augmentation/AugmentationHelpers.tsx @@ -148,7 +148,7 @@ function initAugmentations(): void { name: AugmentationNames.HemoRecirculator, moneyCost: 4.5e7, repCost: 1e4, - info: "A heart implant that greatly increases the body's ability to effectively use and pump " + "blood.", + info: "A heart implant that greatly increases the body's ability to effectively use and pump blood.", strength_mult: 1.08, defense_mult: 1.08, agility_mult: 1.08, @@ -430,7 +430,7 @@ function initAugmentations(): void { repCost: 1.125e6, moneyCost: 4.25e9, info: - "Graphene is grafted and fused into the skeletal structure, " + "enhancing bone density and tensile strength.", + "Graphene is grafted and fused into the skeletal structure, enhancing bone density and tensile strength.", strength_mult: 1.7, defense_mult: 1.7, }); @@ -1085,7 +1085,7 @@ function initAugmentations(): void { name: AugmentationNames.FocusWire, repCost: 7.5e4, moneyCost: 9e8, - info: "A cranial implant that stops procrastination by blocking specific neural pathways " + "in the brain.", + info: "A cranial implant that stops procrastination by blocking specific neural pathways in the brain.", hacking_exp_mult: 1.05, strength_exp_mult: 1.05, defense_exp_mult: 1.05, @@ -1486,7 +1486,7 @@ function initAugmentations(): void { name: AugmentationNames.SmartSonar, repCost: 2.25e4, moneyCost: 7.5e7, - info: "A cochlear implant that helps the player detect and locate enemies " + "using sound propagation.", + info: "A cochlear implant that helps the player detect and locate enemies using sound propagation.", dexterity_mult: 1.1, dexterity_exp_mult: 1.15, crime_money_mult: 1.25, @@ -2015,7 +2015,7 @@ function initAugmentations(): void { repCost: 6.25e4, moneyCost: 2.75e8, info: - "Cybernetic arms created from plasteel and carbon fibers that completely replace " + "the user's organic arms.", + "Cybernetic arms created from plasteel and carbon fibers that completely replace the user's organic arms.", strength_mult: 1.3, dexterity_mult: 1.3, }); diff --git a/src/Bladeburner/Action.tsx b/src/Bladeburner/Action.tsx index a8012696d..c166ef567 100644 --- a/src/Bladeburner/Action.tsx +++ b/src/Bladeburner/Action.tsx @@ -135,7 +135,7 @@ export class Action implements IAction { if (this.decays.hasOwnProperty(decay)) { if (this.decays[decay] > 1) { throw new Error( - "Invalid decays when constructing " + "Action " + this.name + ". " + "Decay value cannot be greater than 1", + `Invalid decays when constructing Action ${this.name}. Decay value cannot be greater than 1`, ); } } diff --git a/src/Bladeburner/Skills.ts b/src/Bladeburner/Skills.ts index 6067b4f71..cdc621152 100644 --- a/src/Bladeburner/Skills.ts +++ b/src/Bladeburner/Skills.ts @@ -8,7 +8,7 @@ export const Skills: IMap = {}; Skills[SkillNames.BladesIntuition] = new Skill({ name: SkillNames.BladesIntuition, desc: - "Each level of this skill increases your success chance " + "for all Contracts, Operations, and BlackOps by 3%", + "Each level of this skill increases your success chance for all Contracts, Operations, and BlackOps by 3%", baseCost: 3, costInc: 2.1, successChanceAll: 3, @@ -33,14 +33,14 @@ export const Skills: IMap = {}; }); Skills[SkillNames.DigitalObserver] = new Skill({ name: SkillNames.DigitalObserver, - desc: "Each level of this skill increases your success chance in " + "all Operations and BlackOps by 4%", + desc: "Each level of this skill increases your success chance in all Operations and BlackOps by 4%", baseCost: 2, costInc: 2.1, successChanceOperation: 4, }); Skills[SkillNames.Tracer] = new Skill({ name: SkillNames.Tracer, - desc: "Each level of this skill increases your success chance in " + "all Contracts by 4%", + desc: "Each level of this skill increases your success chance in all Contracts by 4%", baseCost: 2, costInc: 2.1, successChanceContract: 4, @@ -67,7 +67,7 @@ export const Skills: IMap = {}; }); Skills[SkillNames.EvasiveSystem] = new Skill({ name: SkillNames.EvasiveSystem, - desc: "Each level of this skill increases your effective " + "dexterity and agility for Bladeburner actions by 4%", + desc: "Each level of this skill increases your effective dexterity and agility for Bladeburner actions by 4%", baseCost: 2, costInc: 2.1, effDex: 4, diff --git a/src/Corporation/data/ResearchMetadata.ts b/src/Corporation/data/ResearchMetadata.ts index b8ca4aeb1..d82b3b9d7 100644 --- a/src/Corporation/data/ResearchMetadata.ts +++ b/src/Corporation/data/ResearchMetadata.ts @@ -106,7 +106,7 @@ export const researchMetadata: IConstructorParams[] = [ { name: "JoyWire", cost: 20e3, - desc: "A brain implant which is installed in employees, increasing their " + "maximum happiness by 10.", + desc: "A brain implant which is installed in employees, increasing their maximum happiness by 10.", }, { name: "Market-TA.I", @@ -160,7 +160,7 @@ export const researchMetadata: IConstructorParams[] = [ { name: "sudo.Assist", cost: 15e3, - desc: "Develop a virtual assistant AI to handle and manage administrative " + "issues for your corporation.", + desc: "Develop a virtual assistant AI to handle and manage administrative issues for your corporation.", }, { name: "uPgrade: Capacity.I", diff --git a/src/Faction/FactionHelpers.tsx b/src/Faction/FactionHelpers.tsx index 33011af70..51d72eec5 100644 --- a/src/Faction/FactionHelpers.tsx +++ b/src/Faction/FactionHelpers.tsx @@ -117,8 +117,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal const factionInfo = fac.getInfo(); const hasPrereqs = hasAugmentationPrereqs(aug); if (!hasPrereqs) { - const txt = - "You must first purchase or install " + aug.prereqs.join(",") + " before you can " + "purchase this one."; + const txt = `You must first purchase or install ${aug.prereqs.join(",")} before you can purchase this one.`; if (sing) { return txt; } else { diff --git a/src/Faction/ui/FactionRoot.tsx b/src/Faction/ui/FactionRoot.tsx index aef4d5f8d..1dd5a1a66 100644 --- a/src/Faction/ui/FactionRoot.tsx +++ b/src/Faction/ui/FactionRoot.tsx @@ -28,7 +28,7 @@ type IProps = { }; // Info text for all options on the UI -const gangInfo = "Create and manage a gang for this Faction. Gangs will earn you money and " + "faction reputation"; +const gangInfo = "Create and manage a gang for this Faction. Gangs will earn you money and faction reputation"; const hackingContractsInfo = "Complete hacking contracts for your faction. " + "Your effectiveness, which determines how much " + diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index a3935f76d..c561b5a9d 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -375,7 +375,7 @@ function processNetscript1Imports(code: string, workerScript: WorkerScript): any }); //Now we have to generate the code that would create the namespace - generatedCode += "var " + namespace + ";\n" + "(function (namespace) {\n"; + generatedCode += `var ${namespace};\n(function (namespace) {\n`; //Add the function declarations fnDeclarations.forEach((fn: any) => { @@ -390,7 +390,7 @@ function processNetscript1Imports(code: string, workerScript: WorkerScript): any }); //Finish - generatedCode += "})(" + namespace + " || " + "(" + namespace + " = {}));\n"; + generatedCode += `})(${namespace} || (" + namespace + " = {}));\n`; } else { //import {...} from script diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index 08ce271fc..ee97fc982 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -1313,9 +1313,7 @@ export function createProgramWork(this: IPlayer, numCycles: number): boolean { export function finishCreateProgramWork(this: IPlayer, cancelled: boolean): string { const programName = this.createProgramName; if (cancelled === false) { - dialogBoxCreate( - "You've finished creating " + programName + "!
" + "The new program can be found on your home computer.", - ); + dialogBoxCreate(`You've finished creating ${programName}!
The new program can be found on your home computer.`); this.getHomeComputer().programs.push(programName); } else { diff --git a/src/RedPill.tsx b/src/RedPill.tsx index ffaa77fa4..1e0773799 100644 --- a/src/RedPill.tsx +++ b/src/RedPill.tsx @@ -39,7 +39,7 @@ function giveSourceFile(bitNodeNumber: number): void { if (alreadyOwned && ownedSourceFile) { if (ownedSourceFile.lvl >= 3 && ownedSourceFile.n !== 12) { dialogBoxCreate( - "The Source-File for the BitNode you just destroyed, " + sourceFile.name + ", " + "is already at max level!", + `The Source-File for the BitNode you just destroyed, ${sourceFile.name}, is already at max level!`, ); } else { ++ownedSourceFile.lvl; diff --git a/src/ScriptEditor/ui/ScriptEditorRoot.tsx b/src/ScriptEditor/ui/ScriptEditorRoot.tsx index 31d8f10b7..7e7292c85 100644 --- a/src/ScriptEditor/ui/ScriptEditorRoot.tsx +++ b/src/ScriptEditor/ui/ScriptEditorRoot.tsx @@ -526,7 +526,7 @@ export function Root(props: IProps): React.ReactElement { const textFile = new TextFile(scriptToSave.fileName, scriptToSave.code); server.textFiles.push(textFile); } else { - dialogBoxCreate("Invalid filename. Must be either a script (.script, .js, or .ns) or " + " or text file (.txt)"); + dialogBoxCreate("Invalid filename. Must be either a script (.script, .js, or .ns) or a text file (.txt)"); return; } @@ -610,7 +610,7 @@ export function Root(props: IProps): React.ReactElement { const textFile = new TextFile(currentScript.fileName, currentScript.code); server.textFiles.push(textFile); } else { - dialogBoxCreate("Invalid filename. Must be either a script (.script, .js, or .ns) or " + " or text file (.txt)"); + dialogBoxCreate("Invalid filename. Must be either a script (.script, .js, or .ns) or a text file (.txt)"); return; } diff --git a/src/StockMarket/BuyingAndSelling.tsx b/src/StockMarket/BuyingAndSelling.tsx index c4b754e11..c978ff711 100644 --- a/src/StockMarket/BuyingAndSelling.tsx +++ b/src/StockMarket/BuyingAndSelling.tsx @@ -117,7 +117,7 @@ export function buyStock( const resultTxt = `Bought ${numeralWrapper.formatShares(shares)} shares of ${stock.symbol} for ${numeralWrapper.formatMoney( totalPrice, - )}. ` + `Paid ${numeralWrapper.formatMoney(CONSTANTS.StockMarketCommission)} in commission fees.`; + )}. Paid ${numeralWrapper.formatMoney(CONSTANTS.StockMarketCommission)} in commission fees.`; workerScript.log("stock.buy", () => resultTxt); } else if (opts.suppressDialog !== true) { dialogBoxCreate( diff --git a/src/data/codingcontracttypes.ts b/src/data/codingcontracttypes.ts index f2b6124ee..23235fa9a 100644 --- a/src/data/codingcontracttypes.ts +++ b/src/data/codingcontracttypes.ts @@ -640,7 +640,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [ "of the path, you may only move to adjacent numbers in the row below.", "The triangle is represented as a 2D array of numbers:\n\n", `${triangle}\n\n`, - "Example: If you are given the following triangle:\n\n" + "[\n", + "Example: If you are given the following triangle:\n\n[\n", "     [2],\n", "    [3,4],\n", "   [6,5,7],\n", diff --git a/src/utils/v1APIBreak.ts b/src/utils/v1APIBreak.ts index 783463c5f..86e7cbf28 100644 --- a/src/utils/v1APIBreak.ts +++ b/src/utils/v1APIBreak.ts @@ -94,9 +94,9 @@ export function v1APIBreak(): void { if (s.length === 0) continue; - txt += `// Detected change ${change[0]}, reason: ${change[1]}` + "\n"; + txt += `// Detected change ${change[0]}, reason: ${change[1]}\n`; for (const fl of s) { - txt += `${fl.file}:${fl.line}` + "\n"; + txt += `${fl.file}:${fl.line}\n`; } } } diff --git a/tools/bump-version/index.js b/tools/bump-version/index.js index 8464bc189..de73e7a2f 100644 --- a/tools/bump-version/index.js +++ b/tools/bump-version/index.js @@ -59,7 +59,7 @@ async function main(version, versionNumber, changelog) { join('\n').replaceAll('`', '\\`'); modifiedConstants = modifiedConstants. - replace(/(^\s*?LatestUpdate:\s`\n)(.*)`,$/ms, `$1${paddedChangelog}\n` + "`,"); + replace(/(^\s*?LatestUpdate:\s`\n)(.*)`,$/ms, `$1${paddedChangelog}\n\`,`); } await fs.writeFile(appPaths.constants, modifiedConstants); console.log(`Modified ${appPaths.constants}`);