From 25ac2cef60f4bca139d477627c861bb48373a255 Mon Sep 17 00:00:00 2001 From: Martijn Hols Date: Fri, 2 Jun 2017 20:34:41 +0200 Subject: [PATCH] Fix warnings --- package.json | 1 + src/Main/App.js | 17 +++++++++-------- src/Main/CastEfficiency.js | 23 ++++++++++++----------- src/Main/Cooldown.js | 27 ++++++++++++++------------- src/Main/CooldownOverview.js | 29 +++++++++++++++-------------- src/Main/Fight.js | 15 ++++++++------- src/Main/FightSelecter.js | 23 ++++++++++++----------- src/Main/Mana.js | 9 +++++---- src/Main/PlayerBreakdown.js | 5 +++-- src/Main/PlayerSelecter.js | 19 ++++++++++--------- src/Main/ReportSelecter.js | 3 ++- src/Main/Results.js | 5 +++-- src/Main/StatisticBox.js | 7 ++++--- src/Main/Talents.js | 13 ++++++++++--- src/common/Icon.js | 5 +++-- src/common/ItemIcon.js | 3 ++- src/common/ItemLink.js | 5 +++-- src/common/SpellIcon.js | 5 +++-- src/common/SpellLink.js | 7 ++++--- src/{ => tests/Main}/App.test.js | 0 20 files changed, 123 insertions(+), 98 deletions(-) rename src/{ => tests/Main}/App.test.js (100%) diff --git a/package.json b/package.json index 9c870cf35fd..08f4ea0b49a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dependencies": { "chartist": "^0.11.0", "chartist-plugin-legend": "^0.6.1", + "prop-types": "^15.5.10", "react": "^15.4.2", "react-chartist": "^0.12.0", "react-dom": "^15.4.2", diff --git a/src/Main/App.js b/src/Main/App.js index 6f5ab39cd11..e3accf22cc7 100644 --- a/src/Main/App.js +++ b/src/Main/App.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { Link, hashHistory } from 'react-router'; import ReactTooltip from 'react-tooltip'; @@ -27,14 +28,14 @@ const githubUrl = 'https://github.com/MartijnHols/WoWAnalyzer'; class App extends Component { static propTypes = { - router: React.PropTypes.shape({ - push: React.PropTypes.func.isRequired, - }).isRequired, - params: React.PropTypes.shape({ - reportCode: React.PropTypes.string, - playerName: React.PropTypes.string, - fightId: React.PropTypes.string, - resultTab: React.PropTypes.string, + router: PropTypes.shape({ + push: PropTypes.func.isRequired, + }), + params: PropTypes.shape({ + reportCode: PropTypes.string, + playerName: PropTypes.string, + fightId: PropTypes.string, + resultTab: PropTypes.string, }), }; static defaultProps = { diff --git a/src/Main/CastEfficiency.js b/src/Main/CastEfficiency.js index 19dfd41a116..fd60f9cf25e 100644 --- a/src/Main/CastEfficiency.js +++ b/src/Main/CastEfficiency.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import SpellLink from 'common/SpellLink'; import SpellIcon from 'common/SpellIcon'; @@ -64,18 +65,18 @@ const CastEfficiency = ({ categories, abilities }) => { ); }; CastEfficiency.propTypes = { - abilities: React.PropTypes.arrayOf(React.PropTypes.shape({ - ability: React.PropTypes.shape({ - name: React.PropTypes.string.isRequired, - spellId: React.PropTypes.number.isRequired, - icon: React.PropTypes.string.isRequired, + abilities: PropTypes.arrayOf(PropTypes.shape({ + ability: PropTypes.shape({ + name: PropTypes.string.isRequired, + spellId: PropTypes.number.isRequired, + icon: PropTypes.string.isRequired, }), - cpm: React.PropTypes.number.isRequired, - maxCpm: React.PropTypes.number, - casts: React.PropTypes.number.isRequired, - maxCasts: React.PropTypes.number.isRequired, - castEfficiency: React.PropTypes.number, - canBeImproved: React.PropTypes.bool.isRequired, + cpm: PropTypes.number.isRequired, + maxCpm: PropTypes.number, + casts: PropTypes.number.isRequired, + maxCasts: PropTypes.number.isRequired, + castEfficiency: PropTypes.number, + canBeImproved: PropTypes.bool.isRequired, })).isRequired, }; diff --git a/src/Main/Cooldown.js b/src/Main/Cooldown.js index c5b082cb834..7cbac1871d5 100644 --- a/src/Main/Cooldown.js +++ b/src/Main/Cooldown.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import SpellLink from 'common/SpellLink'; import SpellIcon from 'common/SpellIcon'; @@ -26,20 +27,20 @@ function formatPercentage(percentage) { class Cooldown extends React.Component { static propTypes = { - fightStart: React.PropTypes.number.isRequired, - fightEnd: React.PropTypes.number.isRequired, - ShowStatistics: React.PropTypes.bool, - showResourceStatistics: React.PropTypes.bool, - cooldown: React.PropTypes.shape({ - ability: React.PropTypes.shape({ - id: React.PropTypes.number.isRequired, - name: React.PropTypes.string.isRequired, - icon: React.PropTypes.string.isRequired, + fightStart: PropTypes.number.isRequired, + fightEnd: PropTypes.number.isRequired, + ShowStatistics: PropTypes.bool, + showResourceStatistics: PropTypes.bool, + cooldown: PropTypes.shape({ + ability: PropTypes.shape({ + id: PropTypes.number.isRequired, + name: PropTypes.string.isRequired, + icon: PropTypes.string.isRequired, }), - start: React.PropTypes.number.isRequired, - end: React.PropTypes.number, - events: React.PropTypes.arrayOf(React.PropTypes.shape({ - type: React.PropTypes.string.isRequired, + start: PropTypes.number.isRequired, + end: PropTypes.number, + events: PropTypes.arrayOf(PropTypes.shape({ + type: PropTypes.string.isRequired, })).isRequired, }).isRequired, }; diff --git a/src/Main/CooldownOverview.js b/src/Main/CooldownOverview.js index 4730f4d55da..ffe31abb62f 100644 --- a/src/Main/CooldownOverview.js +++ b/src/Main/CooldownOverview.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import Cooldown from './Cooldown'; @@ -14,21 +15,21 @@ const CooldownOverview = ({ fightStart, fightEnd, cooldowns, showOutputStatistic ); CooldownOverview.propTypes = { - fightStart: React.PropTypes.number.isRequired, - fightEnd: React.PropTypes.number.isRequired, - showOutputStatistics: React.PropTypes.bool, - showResourceStatistics: React.PropTypes.bool, - cooldowns: React.PropTypes.arrayOf(React.PropTypes.shape({ - ability: React.PropTypes.shape({ - id: React.PropTypes.number.isRequired, - name: React.PropTypes.string.isRequired, - icon: React.PropTypes.string.isRequired, - cooldownType: React.PropTypes.string.isRequired + fightStart: PropTypes.number.isRequired, + fightEnd: PropTypes.number.isRequired, + showOutputStatistics: PropTypes.bool, + showResourceStatistics: PropTypes.bool, + cooldowns: PropTypes.arrayOf(PropTypes.shape({ + ability: PropTypes.shape({ + id: PropTypes.number.isRequired, + name: PropTypes.string.isRequired, + icon: PropTypes.string.isRequired, + cooldownType: PropTypes.string.isRequired }), - start: React.PropTypes.number.isRequired, - end: React.PropTypes.number, - events: React.PropTypes.arrayOf(React.PropTypes.shape({ - type: React.PropTypes.string.isRequired, + start: PropTypes.number.isRequired, + end: PropTypes.number, + events: PropTypes.arrayOf(PropTypes.shape({ + type: PropTypes.string.isRequired, })).isRequired, })).isRequired, }; diff --git a/src/Main/Fight.js b/src/Main/Fight.js index 433405559aa..490a773a9af 100644 --- a/src/Main/Fight.js +++ b/src/Main/Fight.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import DIFFICULTIES from './DIFFICULTIES'; @@ -23,13 +24,13 @@ const Fight = ({ difficulty, name, kill, start_time, end_time, wipes, ...others ); }; Fight.propTypes = { - id: React.PropTypes.number.isRequired, - difficulty: React.PropTypes.number.isRequired, - boss: React.PropTypes.number.isRequired, - start_time: React.PropTypes.number.isRequired, - end_time: React.PropTypes.number.isRequired, - name: React.PropTypes.string.isRequired, - kill: React.PropTypes.bool.isRequired, + id: PropTypes.number.isRequired, + difficulty: PropTypes.number.isRequired, + boss: PropTypes.number.isRequired, + start_time: PropTypes.number.isRequired, + end_time: PropTypes.number.isRequired, + name: PropTypes.string.isRequired, + kill: PropTypes.bool.isRequired, }; export default Fight; diff --git a/src/Main/FightSelecter.js b/src/Main/FightSelecter.js index 057c95fa12e..11782dc8868 100644 --- a/src/Main/FightSelecter.js +++ b/src/Main/FightSelecter.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { Link } from 'react-router'; import ReactTooltip from 'react-tooltip'; @@ -8,17 +9,17 @@ import getWipeCount from './getWipeCount'; class FightSelecter extends Component { static propTypes = { - report: React.PropTypes.shape({ - code: React.PropTypes.string.isRequired, - title: React.PropTypes.string.isRequired, - fights: React.PropTypes.arrayOf(React.PropTypes.shape({ - id: React.PropTypes.number.isRequired, - difficulty: React.PropTypes.number, - boss: React.PropTypes.number.isRequired, - start_time: React.PropTypes.number.isRequired, - end_time: React.PropTypes.number.isRequired, - name: React.PropTypes.string.isRequired, - kill: React.PropTypes.bool, + report: PropTypes.shape({ + code: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + fights: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.number.isRequired, + difficulty: PropTypes.number, + boss: PropTypes.number.isRequired, + start_time: PropTypes.number.isRequired, + end_time: PropTypes.number.isRequired, + name: PropTypes.string.isRequired, + kill: PropTypes.bool, })), }), }; diff --git a/src/Main/Mana.js b/src/Main/Mana.js index 88567772ace..bbd0a6253d7 100644 --- a/src/Main/Mana.js +++ b/src/Main/Mana.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import ChartistGraph from 'react-chartist'; import Chartist from 'chartist'; import 'chartist-plugin-legend'; @@ -17,10 +18,10 @@ const formatDuration = (duration) => { class Mana extends React.PureComponent { static propTypes = { - reportCode: React.PropTypes.string.isRequired, - actorId: React.PropTypes.number.isRequired, - start: React.PropTypes.number.isRequired, - end: React.PropTypes.number.isRequired, + reportCode: PropTypes.string.isRequired, + actorId: PropTypes.number.isRequired, + start: PropTypes.number.isRequired, + end: PropTypes.number.isRequired, }; constructor() { diff --git a/src/Main/PlayerBreakdown.js b/src/Main/PlayerBreakdown.js index fb8ffaef3f6..fd14f1b776e 100644 --- a/src/Main/PlayerBreakdown.js +++ b/src/Main/PlayerBreakdown.js @@ -1,11 +1,12 @@ import React from 'react'; +import PropTypes from 'prop-types'; import SPECS from 'common/SPECS'; class PlayerBreakdown extends React.Component { static propTypes = { - stats: React.PropTypes.object.isRequired, - playersById: React.PropTypes.object.isRequired, + stats: PropTypes.object.isRequired, + playersById: PropTypes.object.isRequired, }; calculatePlayerBreakdown(stats, playersById) { diff --git a/src/Main/PlayerSelecter.js b/src/Main/PlayerSelecter.js index 58da0d08a4d..aef1f0d5e17 100644 --- a/src/Main/PlayerSelecter.js +++ b/src/Main/PlayerSelecter.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import { Link } from 'react-router'; import ReactTooltip from 'react-tooltip'; @@ -8,17 +9,17 @@ import makeAnalyzerUrl from './makeAnalyzerUrl'; class PlayerSelecter extends Component { static propTypes = { - report: React.PropTypes.shape({ - code: React.PropTypes.string.isRequired, - title: React.PropTypes.string.isRequired, - friendlies: React.PropTypes.arrayOf(React.PropTypes.shape({ - id: React.PropTypes.number.isRequired, - type: React.PropTypes.string.isRequired, - name: React.PropTypes.string.isRequired, + report: PropTypes.shape({ + code: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + friendlies: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.number.isRequired, + type: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, })), }).isRequired, - fightId: React.PropTypes.number.isRequired, - combatants: React.PropTypes.arrayOf(React.PropTypes.shape({ + fightId: PropTypes.number.isRequired, + combatants: PropTypes.arrayOf(PropTypes.shape({ })).isRequired, }; diff --git a/src/Main/ReportSelecter.js b/src/Main/ReportSelecter.js index 9a1c17d39a7..42308086ad4 100644 --- a/src/Main/ReportSelecter.js +++ b/src/Main/ReportSelecter.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import AVAILABLE_CONFIGS from 'Parser/AVAILABLE_CONFIGS'; @@ -7,7 +8,7 @@ import Changelog from './Changelog'; class ReportSelecter extends Component { static propTypes = { - onSubmit: React.PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, }; codeInput = null; diff --git a/src/Main/Results.js b/src/Main/Results.js index 437b914ff84..818baa673ee 100644 --- a/src/Main/Results.js +++ b/src/Main/Results.js @@ -1,10 +1,11 @@ import React from 'react'; +import PropTypes from 'prop-types'; import { Link } from 'react-router'; class Results extends React.Component { static propTypes = { - parser: React.PropTypes.object.isRequired, - tab: React.PropTypes.string, + parser: PropTypes.object.isRequired, + tab: PropTypes.string, }; render() { diff --git a/src/Main/StatisticBox.js b/src/Main/StatisticBox.js index 58476e287b9..30803113bb3 100644 --- a/src/Main/StatisticBox.js +++ b/src/Main/StatisticBox.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; const StatisticBox = ({ icon, value, label }) => (
@@ -20,9 +21,9 @@ const StatisticBox = ({ icon, value, label }) => (
); StatisticBox.propTypes = { - icon: React.PropTypes.node.isRequired, - value: React.PropTypes.node.isRequired, - label: React.PropTypes.node.isRequired, + icon: PropTypes.node.isRequired, + value: PropTypes.node.isRequired, + label: PropTypes.node.isRequired, }; export default StatisticBox; \ No newline at end of file diff --git a/src/Main/Talents.js b/src/Main/Talents.js index 0c6cc1f866d..196d8930def 100644 --- a/src/Main/Talents.js +++ b/src/Main/Talents.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import SPELLS from 'common/SPELLS'; import SpellLink from 'common/SpellLink'; @@ -28,7 +29,7 @@ const Talent = ({ talent }) => { ); }; Talent.propTypes = { - talent: React.PropTypes.number, + talent: PropTypes.number, }; const Talents = ({ combatant }) => { @@ -67,8 +68,14 @@ const Talents = ({ combatant }) => { ); }; Talents.propTypes = { - combatant: React.PropTypes.shape({ - + combatant: PropTypes.shape({ + lv15Talent: PropTypes.number, + lv30Talent: PropTypes.number, + lv45Talent: PropTypes.number, + lv60Talent: PropTypes.number, + lv75Talent: PropTypes.number, + lv90Talent: PropTypes.number, + lv100Talent: PropTypes.number, }).isRequired, }; diff --git a/src/common/Icon.js b/src/common/Icon.js index ff55b6f8310..66b1c6825eb 100644 --- a/src/common/Icon.js +++ b/src/common/Icon.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; const Icon = ({ icon, alt, ...other }) => { icon = icon.replace('.jpg', '').replace('-', ''); @@ -16,8 +17,8 @@ const Icon = ({ icon, alt, ...other }) => { ); }; Icon.propTypes = { - icon: React.PropTypes.string.isRequired, - alt: React.PropTypes.string.isRequired, + icon: PropTypes.string.isRequired, + alt: PropTypes.string.isRequired, }; export default Icon; diff --git a/src/common/ItemIcon.js b/src/common/ItemIcon.js index b2a986c3c7a..e156c51b91a 100644 --- a/src/common/ItemIcon.js +++ b/src/common/ItemIcon.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import ITEMS from './ITEMS'; import ItemLink from './ItemLink'; import Icon from './Icon'; @@ -13,7 +14,7 @@ const ItemIcon = ({ id, ...others }) => ( ); ItemIcon.propTypes = { - id: React.PropTypes.number.isRequired, + id: PropTypes.number.isRequired, }; export default ItemIcon; diff --git a/src/common/ItemLink.js b/src/common/ItemLink.js index a49b4481595..dfc639518eb 100644 --- a/src/common/ItemLink.js +++ b/src/common/ItemLink.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import ITEMS from './ITEMS'; const ItemLink = ({ id, children }) => ( @@ -7,8 +8,8 @@ const ItemLink = ({ id, children }) => ( ); ItemLink.propTypes = { - id: React.PropTypes.number.isRequired, - children: React.PropTypes.node, + id: PropTypes.number.isRequired, + children: PropTypes.node, }; export default ItemLink; diff --git a/src/common/SpellIcon.js b/src/common/SpellIcon.js index c7300e85ec7..2db390ff055 100644 --- a/src/common/SpellIcon.js +++ b/src/common/SpellIcon.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import SPELLS from './SPELLS'; import SpellLink from './SpellLink'; import Icon from './Icon'; @@ -27,8 +28,8 @@ const SpellIcon = ({ id, noLink, ...others }) => { ); }; SpellIcon.propTypes = { - id: React.PropTypes.number.isRequired, - noLink: React.PropTypes.bool, + id: PropTypes.number.isRequired, + noLink: PropTypes.bool, }; export default SpellIcon; diff --git a/src/common/SpellLink.js b/src/common/SpellLink.js index c85166ae11f..d025293ee0d 100644 --- a/src/common/SpellLink.js +++ b/src/common/SpellLink.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import SPELLS from './SPELLS'; const SpellLink = ({ id, children, category = undefined, ...other }) => { @@ -13,9 +14,9 @@ const SpellLink = ({ id, children, category = undefined, ...other }) => { ); }; SpellLink.propTypes = { - id: React.PropTypes.number.isRequired, - children: React.PropTypes.node, - category: React.PropTypes.string, + id: PropTypes.number.isRequired, + children: PropTypes.node, + category: PropTypes.string, }; export default SpellLink; diff --git a/src/App.test.js b/src/tests/Main/App.test.js similarity index 100% rename from src/App.test.js rename to src/tests/Main/App.test.js