From 10fffe67fc7efe926a903288accd2eef7e275a6d Mon Sep 17 00:00:00 2001 From: felixlinker Date: Thu, 4 Oct 2018 23:45:13 +0100 Subject: [PATCH] Code style fixes --- src/app/Coriolis.jsx | 5 +- src/app/components/ActiveLink.jsx | 4 +- src/app/components/AvailableModulesMenu.jsx | 14 +++--- src/app/components/BarChart.jsx | 1 - src/app/components/ComparisonTable.jsx | 1 - src/app/components/CostSection.jsx | 11 ++--- src/app/components/Defence.jsx | 40 ++++++++-------- src/app/components/FSDProfile.jsx | 2 +- src/app/components/ModalDeleteAll.jsx | 1 - src/app/components/Modification.jsx | 11 ++--- src/app/components/ModificationsMenu.jsx | 19 ++++---- src/app/components/Movement.jsx | 14 +++--- src/app/components/Offence.jsx | 40 ++++++++-------- src/app/components/PowerBands.jsx | 1 - src/app/components/Slot.jsx | 2 +- src/app/components/UtilitySlotSection.jsx | 2 - src/app/components/VerticalBarChart.jsx | 1 - src/app/shipyard/Modification.js | 2 - src/app/shipyard/Module.js | 2 - src/app/shipyard/ModuleSet.js | 1 - src/app/shipyard/Ship.js | 53 ++++++++++----------- src/app/stores/Persist.js | 1 - src/app/utils/BlueprintFunctions.js | 44 ++++++++--------- 23 files changed, 125 insertions(+), 147 deletions(-) diff --git a/src/app/Coriolis.jsx b/src/app/Coriolis.jsx index 88921586..5e2f7afd 100644 --- a/src/app/Coriolis.jsx +++ b/src/app/Coriolis.jsx @@ -27,7 +27,6 @@ const zlib = require('pako'); * Coriolis App */ export default class Coriolis extends React.Component { - static childContextTypes = { closeMenu: PropTypes.func.isRequired, hideModal: PropTypes.func.isRequired, @@ -394,7 +393,7 @@ export default class Coriolis extends React.Component { let currentMenu = this.state.currentMenu; return
+ className={this.state.noTouch ? 'no-touch' : null}>
{this.state.error ? this.state.error : this.state.page ? React.createElement(this.state.page, { currentMenu }) : } @@ -403,7 +402,7 @@ export default class Coriolis extends React.Component {
{window.CORIOLIS_VERSION} - {window.CORIOLIS_DATE} + title="Coriolis Github Project">{window.CORIOLIS_VERSION} - {window.CORIOLIS_DATE}
{this.props.children}; } - -} \ No newline at end of file +} diff --git a/src/app/components/AvailableModulesMenu.jsx b/src/app/components/AvailableModulesMenu.jsx index 8e743165..cddafb14 100644 --- a/src/app/components/AvailableModulesMenu.jsx +++ b/src/app/components/AvailableModulesMenu.jsx @@ -98,7 +98,7 @@ const CATEGORIES = { 'defence': ['ch', 'po', 'ec'], 'scanners': ['sc', 'ss', 'cs', 'kw', 'ws'], // Overloaded with internal scanners // Experimental - 'experimental': ['axmc', 'axmr', 'rfl', 'tbrfl', 'tbsc', 'tbem', 'xs', 'sfn', 'rcpl', 'dtl', 'rsl', 'mahr', ], + 'experimental': ['axmc', 'axmr', 'rfl', 'tbrfl', 'tbsc', 'tbem', 'xs', 'sfn', 'rcpl', 'dtl', 'rsl', 'mahr',], // Guardian 'guardian': ['gpp', 'gpd', 'gpc', 'ggc', 'gsrp', 'gfsb', 'ghrp', 'gmrp', 'gsc'] @@ -108,7 +108,6 @@ const CATEGORIES = { * Available modules menu */ export default class AvailableModulesMenu extends TranslatedComponent { - static propTypes = { modules: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired, onSelect: PropTypes.func.isRequired, @@ -159,7 +158,7 @@ export default class AvailableModulesMenu extends TranslatedComponent { this._hideDiff(event); onSelect(m); } - ); + ); if (modules instanceof Array) { list = buildGroup(modules[0].grp, modules); @@ -502,14 +501,13 @@ export default class AvailableModulesMenu extends TranslatedComponent { render() { return (
this.node = node} - className={cn('select', this.props.className)} - onScroll={this._hideDiff} - onClick={(e) => e.stopPropagation() } - onContextMenu={stopCtxPropagation} + className={cn('select', this.props.className)} + onScroll={this._hideDiff} + onClick={(e) => e.stopPropagation() } + onContextMenu={stopCtxPropagation} > {this.state.list}
); } - } diff --git a/src/app/components/BarChart.jsx b/src/app/components/BarChart.jsx index 47515169..ca2d448b 100644 --- a/src/app/components/BarChart.jsx +++ b/src/app/components/BarChart.jsx @@ -38,7 +38,6 @@ function insertLinebreaks(d) { * Bar Chart */ export default class BarChart extends TranslatedComponent { - static defaultProps = { colors: ['#7b6888', '#6b486b', '#3182bd', '#a05d56', '#d0743c'], labels: null, diff --git a/src/app/components/ComparisonTable.jsx b/src/app/components/ComparisonTable.jsx index c2a9acd5..c1f6767f 100644 --- a/src/app/components/ComparisonTable.jsx +++ b/src/app/components/ComparisonTable.jsx @@ -10,7 +10,6 @@ import { outfitURL } from '../utils/UrlGenerators'; * Comparison Table */ export default class ComparisonTable extends TranslatedComponent { - static propTypes = { facets: PropTypes.array.isRequired, builds: PropTypes.array.isRequired, diff --git a/src/app/components/CostSection.jsx b/src/app/components/CostSection.jsx index ca7270f7..90019560 100644 --- a/src/app/components/CostSection.jsx +++ b/src/app/components/CostSection.jsx @@ -13,7 +13,6 @@ import { ShoppingIcon } from '../components/SvgIcons'; * Cost Section */ export default class CostSection extends TranslatedComponent { - static propTypes = { ship: PropTypes.object.isRequired, code: PropTypes.string.isRequired, @@ -361,11 +360,11 @@ export default class CostSection extends TranslatedComponent { for (let i = 0, l = retrofitCosts.length; i < l; i++) { let item = retrofitCosts[i]; rows.push( - {item.sellClassRating} - {translate(item.sellName)} - {item.buyClassRating} - {translate(item.buyName)} - 0 ? 'warning' : 'secondary-disabled' : 'disabled')}>{int(item.netCost)}{units.CR} + {item.sellClassRating} + {translate(item.sellName)} + {item.buyClassRating} + {translate(item.buyName)} + 0 ? 'warning' : 'secondary-disabled' : 'disabled')}>{int(item.netCost)}{units.CR} ); } } else { diff --git a/src/app/components/Defence.jsx b/src/app/components/Defence.jsx index 3419801f..7987f943 100644 --- a/src/app/components/Defence.jsx +++ b/src/app/components/Defence.jsx @@ -226,26 +226,26 @@ export default class Defence extends TranslatedComponent { return ( {shield.total ? -
-

{translate('shield metrics')}

-
-

{shieldSourcesTt}

)} onMouseOut={tooltip.bind(null, null)} className='summary'>{translate('raw shield strength')}
{formats.int(shield.total)}{units.MJ} -

{translate('PHRASE_TIME_TO_LOSE_SHIELDS')}
{shielddamage.totalsdps == 0 ? translate('ever') : formats.time(Calc.timeToDeplete(shield.total, shielddamage.totalsdps, shielddamage.totalseps, pd.getWeaponsCapacity(), pd.getWeaponsRechargeRate() * opponentWep / 4))}

-

{translate('PHRASE_TIME_TO_RECOVER_SHIELDS')}
{shield.recover === Math.Inf ? translate('never') : formats.time(shield.recover)}

-

{translate('PHRASE_TIME_TO_RECHARGE_SHIELDS')}
{shield.recharge === Math.Inf ? translate('never') : formats.time(shield.recharge)}

-
-
-

{translate('shield sources')}

- -
-
-

{translate('damage taken')}(%)

- -
-
-

{translate('effective shield')}(MJ)

- -
+
+

{translate('shield metrics')}

+
+

{shieldSourcesTt}

)} onMouseOut={tooltip.bind(null, null)} className='summary'>{translate('raw shield strength')}
{formats.int(shield.total)}{units.MJ} +

{translate('PHRASE_TIME_TO_LOSE_SHIELDS')}
{shielddamage.totalsdps == 0 ? translate('ever') : formats.time(Calc.timeToDeplete(shield.total, shielddamage.totalsdps, shielddamage.totalseps, pd.getWeaponsCapacity(), pd.getWeaponsRechargeRate() * opponentWep / 4))}

+

{translate('PHRASE_TIME_TO_RECOVER_SHIELDS')}
{shield.recover === Math.Inf ? translate('never') : formats.time(shield.recover)}

+

{translate('PHRASE_TIME_TO_RECHARGE_SHIELDS')}
{shield.recharge === Math.Inf ? translate('never') : formats.time(shield.recharge)}

+
+
+

{translate('shield sources')}

+ +
+
+

{translate('damage taken')}(%)

+ +
+
+

{translate('effective shield')}(MJ)

+ +
: null }
diff --git a/src/app/components/FSDProfile.jsx b/src/app/components/FSDProfile.jsx index bd12fc10..ae041a43 100644 --- a/src/app/components/FSDProfile.jsx +++ b/src/app/components/FSDProfile.jsx @@ -69,7 +69,7 @@ export default class FSDProfile extends TranslatedComponent { const { formats, translate, units } = language; const { ship, cargo, fuel } = this.props; - + // Calculate bounds for our line chart - use thruster info for X const thrusters = ship.standard[1].m; const fsd = ship.standard[2].m; diff --git a/src/app/components/ModalDeleteAll.jsx b/src/app/components/ModalDeleteAll.jsx index fd0eb948..8edc1b2d 100644 --- a/src/app/components/ModalDeleteAll.jsx +++ b/src/app/components/ModalDeleteAll.jsx @@ -6,7 +6,6 @@ import Persist from '../stores/Persist'; * Delete All saved data modal */ export default class ModalDeleteAll extends TranslatedComponent { - /** * Delete everything and hide the modal */ diff --git a/src/app/components/Modification.jsx b/src/app/components/Modification.jsx index b2979bb7..69ac3f8e 100644 --- a/src/app/components/Modification.jsx +++ b/src/app/components/Modification.jsx @@ -9,7 +9,6 @@ import { isValueBeneficial } from '../utils/BlueprintFunctions'; * Modification */ export default class Modification extends TranslatedComponent { - static propTypes = { ship: PropTypes.object.isRequired, m: PropTypes.object.isRequired, @@ -98,15 +97,15 @@ export default class Modification extends TranslatedComponent { style={{ textAlign: 'right', cursor: 'inherit' }}/> } - {units[m.getStoredUnitFor(name)]} + {units[m.getStoredUnitFor(name)]} + modValue ? + isValueBeneficial(name, modValue) ? 'secondary' : 'warning' : + '' + }> {formats.f2(modValue / 100) || 0}% diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index b68bf004..803226a9 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -23,7 +23,6 @@ const MODIFICATIONS_COMPARATOR = (mod1, mod2) => { * Modifications menu */ export default class ModificationsMenu extends TranslatedComponent { - static propTypes = { ship: PropTypes.object.isRequired, m: PropTypes.object.isRequired, @@ -461,10 +460,10 @@ export default class ModificationsMenu extends TranslatedComponent { } return (
e.stopPropagation() } - onContextMenu={stopCtxPropagation} - ref={modItem => this.modItems['modMainDiv'] = modItem} + className={cn('select', this.props.className)} + onClick={(e) => e.stopPropagation() } + onContextMenu={stopCtxPropagation} + ref={modItem => this.modItems['modMainDiv'] = modItem} > { showBlueprintsMenu | showSpecialsMenu ? '' : haveBlueprint ?
this.modItems[this.firstBPLabel] = modItems}>{blueprintLabel}
: @@ -473,11 +472,11 @@ export default class ModificationsMenu extends TranslatedComponent { { showSpecial & !showSpecialsMenu ?
{specialLabel}
: null } { showSpecialsMenu ? specials : null } { showReset ?
{ translate('reset') }
: null } - { showRolls ? + { showRolls ? - - - { showRolls ? +
+ + { showRolls ? @@ -485,7 +484,7 @@ export default class ModificationsMenu extends TranslatedComponent { : null } - +
{ translate('roll') }: { translate('0%') } { translate('100%') } { translate('random') }
: null } { showMods ?
: null } { showMods ? diff --git a/src/app/components/Movement.jsx b/src/app/components/Movement.jsx index 65b3582e..42dca8b5 100644 --- a/src/app/components/Movement.jsx +++ b/src/app/components/Movement.jsx @@ -35,13 +35,13 @@ export default class Movement extends TranslatedComponent { return ( - // Axes + {/* Axes */} - // End Arrow + {/* End Arrow */} - // Axes arcs and arrows + {/* Axes arcs and arrows */} @@ -57,13 +57,13 @@ export default class Movement extends TranslatedComponent { - // Speed + {/* Speed */} {ship.canThrust(cargo, fuel) ? formats.int(ship.calcSpeed(eng, fuel, cargo, boost)) + 'm/s' : '-'} - // Pitch + {/* Pitch */} {ship.canThrust(cargo, fuel) ? formats.int(ship.calcPitch(eng, fuel, cargo, boost)) + '°/s' : '-'} - // Roll + {/* Roll */} {ship.canThrust(cargo, fuel) ? formats.int(ship.calcRoll(eng, fuel, cargo, boost)) + '°/s' : '-'} - // Yaw + {/* Yaw */} {ship.canThrust(cargo, fuel) ? formats.int(ship.calcYaw(eng, fuel, cargo, boost)) + '°/s' : '-'} ); diff --git a/src/app/components/Offence.jsx b/src/app/components/Offence.jsx index 83450bdf..524c40a7 100644 --- a/src/app/components/Offence.jsx +++ b/src/app/components/Offence.jsx @@ -203,9 +203,9 @@ export default class Offence extends TranslatedComponent { let totalSEps = 0; - let totalSDpsObject = {'absolute': 0, 'explosive': 0, 'kinetic': 0, 'thermal': 0}; - let shieldsSDpsObject = {'absolute': 0, 'explosive': 0, 'kinetic': 0, 'thermal': 0}; - let armourSDpsObject = {'absolute': 0, 'explosive': 0, 'kinetic': 0, 'thermal': 0}; + let totalSDpsObject = { 'absolute': 0, 'explosive': 0, 'kinetic': 0, 'thermal': 0 }; + let shieldsSDpsObject = { 'absolute': 0, 'explosive': 0, 'kinetic': 0, 'thermal': 0 }; + let armourSDpsObject = { 'absolute': 0, 'explosive': 0, 'kinetic': 0, 'thermal': 0 }; const rows = []; for (let i = 0; i < damage.length; i++) { @@ -267,22 +267,22 @@ export default class Offence extends TranslatedComponent { return (
- - - - - - - - - - - - - - - - +
{translate('weapon')}{translate('overall')}{translate('opponent\'s shields')}{translate('opponent\'s armour')}
{'sdps'}{'sdps'}{'eft'}{'sdps'}{'eft'}
+ + + + + + + + + + + + + + + {rows} {rows.length > 0 && @@ -296,7 +296,7 @@ export default class Offence extends TranslatedComponent { } -
{translate('weapon')}{translate('overall')}{translate('opponent\'s shields')}{translate('opponent\'s armour')}
{'sdps'}{'sdps'}{'eft'}{'sdps'}{'eft'}
+

{translate('offence metrics')}

diff --git a/src/app/components/PowerBands.jsx b/src/app/components/PowerBands.jsx index 8d3d2c24..c66dfa07 100644 --- a/src/app/components/PowerBands.jsx +++ b/src/app/components/PowerBands.jsx @@ -32,7 +32,6 @@ function bandText(val, index, wattScale) { * Renders the SVG to simulate in-game power bands */ export default class PowerBands extends TranslatedComponent { - static propTypes = { bands: PropTypes.array.isRequired, available: PropTypes.number.isRequired, diff --git a/src/app/components/Slot.jsx b/src/app/components/Slot.jsx index a7db217d..63f7e8a4 100644 --- a/src/app/components/Slot.jsx +++ b/src/app/components/Slot.jsx @@ -88,7 +88,7 @@ export default class Slot extends TranslatedComponent { if(event.target.className == 'r') { this._toggleModifications(); } - this.props.onOpen(event); + this.props.onOpen(event); } } /** diff --git a/src/app/components/UtilitySlotSection.jsx b/src/app/components/UtilitySlotSection.jsx index 83f65afe..9857bc38 100644 --- a/src/app/components/UtilitySlotSection.jsx +++ b/src/app/components/UtilitySlotSection.jsx @@ -8,7 +8,6 @@ import { stopCtxPropagation } from '../utils/UtilityFunctions'; * Utility Slot Section */ export default class UtilitySlotSection extends SlotSection { - /** * Constructor * @param {Object} props React Component properties @@ -133,5 +132,4 @@ export default class UtilitySlotSection extends SlotSection {
; } - } diff --git a/src/app/components/VerticalBarChart.jsx b/src/app/components/VerticalBarChart.jsx index 52774ef9..98304041 100644 --- a/src/app/components/VerticalBarChart.jsx +++ b/src/app/components/VerticalBarChart.jsx @@ -17,7 +17,6 @@ const merge = function(one, two) { * A vertical bar chart */ export default class VerticalBarChart extends TranslatedComponent { - static propTypes = { data : PropTypes.array.isRequired, yMax : PropTypes.number diff --git a/src/app/shipyard/Modification.js b/src/app/shipyard/Modification.js index 5c2d4566..44531429 100755 --- a/src/app/shipyard/Modification.js +++ b/src/app/shipyard/Modification.js @@ -2,7 +2,6 @@ * Modification - a modification and its value */ export default class Modification { - /** * @param {String} id Unique modification ID * @param {Number} value Value of the modification @@ -11,5 +10,4 @@ export default class Modification { this.id = id; this.value = value; } - } diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index 8c0a5a9f..d03202a4 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -7,7 +7,6 @@ import { STATS_FORMATTING, SI_PREFIXES } from './StatsFormatting'; * Module - active module in a ship's buildout */ export default class Module { - /** * Construct a new module * @param {Object} params Module parameters. Either grp/id or template @@ -1091,5 +1090,4 @@ export default class Module { getHackTime(modified = true) { return this.get('hacktime', modified); } - } diff --git a/src/app/shipyard/ModuleSet.js b/src/app/shipyard/ModuleSet.js index d1bc3c90..129ee019 100755 --- a/src/app/shipyard/ModuleSet.js +++ b/src/app/shipyard/ModuleSet.js @@ -17,7 +17,6 @@ function filter(arr, maxClass, minClass, mass) { * The available module set for a specific ship */ export default class ModuleSet { - /** * Instantiate the module set * @param {Object} modules All Modules diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js index 4c5313ff..b6db1b53 100755 --- a/src/app/shipyard/Ship.js +++ b/src/app/shipyard/Ship.js @@ -71,7 +71,6 @@ function reduceToIDs(idArray, slot, slotIndex) { * Ship Model - Encapsulates and models in-game ship behavior */ export default class Ship { - /** * @param {String} id Unique ship Id / Key * @param {Object} properties Basic ship properties such as name, manufacturer, mass, etc @@ -416,16 +415,16 @@ export default class Ship { clearModifications(m) { m.mods = {}; this.updatePowerGenerated() - .updatePowerUsed() - .recalculateMass() - .updateJumpStats() - .recalculateShield() - .recalculateShieldCells() - .recalculateArmour() - .recalculateDps() - .recalculateEps() - .recalculateHps() - .updateMovement(); + .updatePowerUsed() + .recalculateMass() + .updateJumpStats() + .recalculateShield() + .recalculateShieldCells() + .recalculateArmour() + .recalculateDps() + .recalculateEps() + .recalculateHps() + .updateMovement(); } /** @@ -696,16 +695,16 @@ export default class Ship { // Update aggragated stats if (comps) { this.updatePowerGenerated() - .updatePowerUsed() - .recalculateMass() - .updateJumpStats() - .recalculateShield() - .recalculateShieldCells() - .recalculateArmour() - .recalculateDps() - .recalculateEps() - .recalculateHps() - .updateMovement(); + .updatePowerUsed() + .recalculateMass() + .updateJumpStats() + .recalculateShield() + .recalculateShieldCells() + .recalculateArmour() + .recalculateDps() + .recalculateEps() + .recalculateHps() + .updateMovement(); } return this.updatePowerPrioritesString().updatePowerEnabledString().updateModificationsString(); @@ -1205,7 +1204,7 @@ export default class Ship { .reduce((sum, cargo) => sum + cargo) .value(); - // handle passenger capacity + // handle passenger capacity passengerCapacity += chain(slots) .map(slot => slot.m ? slot.m.get('passengers') : null) .map(passengers => passengers || 0) @@ -1683,11 +1682,11 @@ export default class Ship { updated; this.useBulkhead(0) - .use(standard[2], fsd) // FSD - .use(standard[3], ls) // Life Support - .use(standard[5], s) // Sensors - .use(standard[4], pd) // Power Distributor - .use(standard[6], ft); // Fuel Tank + .use(standard[2], fsd) // FSD + .use(standard[3], ls) // Life Support + .use(standard[5], s) // Sensors + .use(standard[4], pd) // Power Distributor + .use(standard[6], ft); // Fuel Tank // Turn off nearly everything if (m.fsdDisabled) this.setSlotEnabled(this.standard[2], false); diff --git a/src/app/stores/Persist.js b/src/app/stores/Persist.js index e2724dbd..d0be7ef9 100644 --- a/src/app/stores/Persist.js +++ b/src/app/stores/Persist.js @@ -70,7 +70,6 @@ function _delete(key) { * export is an instance (see end of this file). */ export class Persist extends EventEmitter { - /** * Create an instance */ diff --git a/src/app/utils/BlueprintFunctions.js b/src/app/utils/BlueprintFunctions.js index e71efb25..2c38449d 100644 --- a/src/app/utils/BlueprintFunctions.js +++ b/src/app/utils/BlueprintFunctions.js @@ -19,7 +19,7 @@ export function specialToolTip(translate, blueprint, grp, m, specialName) { // We also add in any benefits from specials that aren't covered above if (m.blueprint) { for (const feature in Modifications.modifierActions[specialName]) { - // if (!blueprint.features[feature] && !m.mods.feature) { + // if (!blueprint.features[feature] && !m.mods.feature) { const featureDef = Modifications.modifications[feature]; if (featureDef && !featureDef.hidden) { let symbol = ''; @@ -37,14 +37,14 @@ export function specialToolTip(translate, blueprint, grp, m, specialName) { const currentIsBeneficial = isValueBeneficial(feature, current); effects.push( - - {translate(feature, grp)} -   - {current}{symbol} -   - - ); + + {translate(feature, grp)} +   + {current}{symbol} +   + + ); } } } @@ -54,7 +54,7 @@ export function specialToolTip(translate, blueprint, grp, m, specialName) {
- {effects} + {effects}
@@ -215,12 +215,12 @@ export function blueprintTooltip(translate, blueprint, engineers, grp, m) {
- - - + + + {m ? : null } - - + + {effects} @@ -228,10 +228,10 @@ export function blueprintTooltip(translate, blueprint, engineers, grp, m) {
{translate('feature')}{translate('worst')}
{translate('feature')}{translate('worst')}{translate('current')}{translate('best')}
{translate('best')}
{ components ? - - - - + + + + {components} @@ -239,9 +239,9 @@ export function blueprintTooltip(translate, blueprint, engineers, grp, m) {
{translate('component')}{translate('amount')}
{translate('component')}{translate('amount')}
: null } { engineersList ? - - - + + + {engineersList}
{translate('engineers')}
{translate('engineers')}