diff --git a/frontend/CHANGELOG.md b/frontend/CHANGELOG.md
index e89f8cf9a7..40fc19bbd6 100644
--- a/frontend/CHANGELOG.md
+++ b/frontend/CHANGELOG.md
@@ -10,6 +10,7 @@ The latest version of this document is always available in
## [Unreleased]
- Move metrics poller to seperate class
- Bugfix: CreatedAt set when creating new toggle
+- chore(lint): Added propTypes to all components
## [3.0.0-alpha.6]
- Bugfix: actions should always throw errors
diff --git a/frontend/src/component/application/__tests__/application-edit-component-test.js b/frontend/src/component/application/__tests__/application-edit-component-test.js
index 5875a8c68b..892c953030 100644
--- a/frontend/src/component/application/__tests__/application-edit-component-test.js
+++ b/frontend/src/component/application/__tests__/application-edit-component-test.js
@@ -6,7 +6,9 @@ import renderer from 'react-test-renderer';
jest.mock('react-mdl');
test('renders correctly if no application', () => {
- const tree = renderer.create().toJSON();
+ const tree = renderer
+ .create()
+ .toJSON();
expect(tree).toMatchSnapshot();
});
diff --git a/frontend/src/component/application/application-edit-component.js b/frontend/src/component/application/application-edit-component.js
index 98c40f33b5..6806a27e39 100644
--- a/frontend/src/component/application/application-edit-component.js
+++ b/frontend/src/component/application/application-edit-component.js
@@ -1,5 +1,6 @@
/* eslint react/no-multi-comp:off */
import React, { Component, PureComponent } from 'react';
+import PropTypes from 'prop-types';
import { Link } from 'react-router';
import {
@@ -23,6 +24,13 @@ import { IconLink, shorten, styles as commonStyles } from '../common';
import { formatFullDateTime } from '../common/util';
class StatefulTextfield extends Component {
+ static propTypes = {
+ value: PropTypes.string,
+ label: PropTypes.string,
+ rows: PropTypes.number,
+ onBlur: PropTypes.func.isRequired,
+ };
+
constructor(props) {
super(props);
this.state = { value: props.value };
@@ -47,6 +55,13 @@ class StatefulTextfield extends Component {
}
class ClientApplications extends PureComponent {
+ static propTypes = {
+ fetchApplication: PropTypes.func.isRequired,
+ appName: PropTypes.string,
+ application: PropTypes.object,
+ storeApplicationMetaData: PropTypes.func.isRequired,
+ };
+
constructor(props) {
super(props);
this.state = { activeTab: 0 };
diff --git a/frontend/src/component/application/application-list-component.js b/frontend/src/component/application/application-list-component.js
index 3c0f117e40..037837d5ca 100644
--- a/frontend/src/component/application/application-list-component.js
+++ b/frontend/src/component/application/application-list-component.js
@@ -1,8 +1,14 @@
import React, { Component } from 'react';
+import PropTypes from 'prop-types';
import { ProgressBar, Card } from 'react-mdl';
import { AppsLinkList, styles as commonStyles } from '../common';
class ClientStrategies extends Component {
+ static propTypes = {
+ applications: PropTypes.array,
+ fetchAll: PropTypes.func.isRequired,
+ };
+
componentDidMount() {
this.props.fetchAll();
}
diff --git a/frontend/src/component/archive/archive-list-component.jsx b/frontend/src/component/archive/archive-list-component.jsx
index 2a0976151a..d3320cd7b2 100644
--- a/frontend/src/component/archive/archive-list-component.jsx
+++ b/frontend/src/component/archive/archive-list-component.jsx
@@ -1,9 +1,16 @@
import React, { Component } from 'react';
+import PropTypes from 'prop-types';
import { Link } from 'react-router';
import { DataTable, TableHeader, IconButton, Icon, Card } from 'react-mdl';
import { styles as commonStyles } from '../common';
class ArchiveList extends Component {
+ static propTypes = {
+ archive: PropTypes.array,
+ fetchArchive: PropTypes.func,
+ revive: PropTypes.func,
+ };
+
componentDidMount() {
this.props.fetchArchive();
}
diff --git a/frontend/src/component/common/index.js b/frontend/src/component/common/index.js
index 15ff789736..706faf38bd 100644
--- a/frontend/src/component/common/index.js
+++ b/frontend/src/component/common/index.js
@@ -1,4 +1,5 @@
import React from 'react';
+import PropTypes from 'prop-types';
import { Link } from 'react-router';
import { List, ListItem, ListItemContent, Button, Icon, Switch, MenuItem } from 'react-mdl';
import styles from './common.scss';
@@ -25,6 +26,9 @@ export const AppsLinkList = ({ apps }) => (
))}
);
+AppsLinkList.propTypes = {
+ apps: PropTypes.array.isRequired,
+};
export const HeaderTitle = ({ title, actions, subtitle }) => (
);
+HeaderTitle.propTypes = {
+ title: PropTypes.string,
+ subtitle: PropTypes.string,
+ actions: PropTypes.any,
+};
export const DataTableHeader = ({ title, actions }) => (
@@ -52,6 +61,10 @@ export const DataTableHeader = ({ title, actions }) => (
{actions &&
{actions}
}
);
+DataTableHeader.propTypes = {
+ title: PropTypes.string,
+ actions: PropTypes.any,
+};
export const FormButtons = ({ submitText = 'Create', onCancel }) => (
@@ -65,6 +78,10 @@ export const FormButtons = ({ submitText = 'Create', onCancel }) => (
);
+FormButtons.propTypes = {
+ submitText: PropTypes.string,
+ onCancel: PropTypes.func.isRequired,
+};
export const SwitchWithLabel = ({ onChange, checked, children, ...switchProps }) => (
@@ -74,6 +91,10 @@ export const SwitchWithLabel = ({ onChange, checked, children, ...switchProps })
);
+SwitchWithLabel.propTypes = {
+ checked: PropTypes.bool,
+ onChange: PropTypes.func,
+};
export const TogglesLinkList = ({ toggles }) => (
@@ -89,6 +110,9 @@ export const TogglesLinkList = ({ toggles }) => (
))}
);
+TogglesLinkList.propTypes = {
+ toggles: PropTypes.array,
+};
export function getIcon(type) {
switch (type) {
@@ -110,6 +134,10 @@ export const IconLink = ({ url, icon }) => (
);
+IconLink.propTypes = {
+ url: PropTypes.string,
+ icon: PropTypes.string,
+};
export const DropdownButton = ({ label, id }) => (
);
+DropdownButton.propTypes = {
+ label: PropTypes.string,
+ id: PropTypes.string,
+};
export const MenuItemWithIcon = ({ icon, label, disabled, ...menuItemProps }) => (
);
+MenuItemWithIcon.propTypes = {
+ icon: PropTypes.string,
+ label: PropTypes.string,
+ disabled: PropTypes.bool,
+};
const badNumbers = [NaN, Infinity, -Infinity];
export function calc(value, total, decimal) {
diff --git a/frontend/src/component/feature/form/index.jsx b/frontend/src/component/feature/form/index.jsx
index a1290022d9..6e6b029dd1 100644
--- a/frontend/src/component/feature/form/index.jsx
+++ b/frontend/src/component/feature/form/index.jsx
@@ -104,11 +104,14 @@ AddFeatureToggleComponent.propTypes = {
setValue: PropTypes.func.isRequired,
addStrategy: PropTypes.func.isRequired,
removeStrategy: PropTypes.func.isRequired,
+ moveStrategy: PropTypes.func.isRequired,
updateStrategy: PropTypes.func.isRequired,
onSubmit: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
validateName: PropTypes.func.isRequired,
editmode: PropTypes.bool,
+ initCallRequired: PropTypes.bool,
+ init: PropTypes.func,
};
export default AddFeatureToggleComponent;
diff --git a/frontend/src/component/feature/form/strategy-input-percentage.jsx b/frontend/src/component/feature/form/strategy-input-percentage.jsx
index 44596b5ca8..4af5b432bc 100644
--- a/frontend/src/component/feature/form/strategy-input-percentage.jsx
+++ b/frontend/src/component/feature/form/strategy-input-percentage.jsx
@@ -1,4 +1,5 @@
import React from 'react';
+import PropTypes from 'prop-types';
import { Slider } from 'react-mdl';
const labelStyle = {
@@ -8,7 +9,7 @@ const labelStyle = {
fontSize: '12px',
};
-export default ({ name, value, onChange }) => (
+const InputPercentage = ({ name, value, onChange }) => (
{name}: {value}%
@@ -16,3 +17,11 @@ export default ({ name, value, onChange }) => (
);
+
+InputPercentage.propTypes = {
+ name: PropTypes.string,
+ value: PropTypes.number,
+ onChange: PropTypes.func.isRequired,
+};
+
+export default InputPercentage;
diff --git a/frontend/src/component/feature/list-component.jsx b/frontend/src/component/feature/list-component.jsx
index 683406278e..269b2877a3 100644
--- a/frontend/src/component/feature/list-component.jsx
+++ b/frontend/src/component/feature/list-component.jsx
@@ -13,6 +13,7 @@ export default class FeatureListComponent extends React.PureComponent {
featureMetrics: PropTypes.object.isRequired,
fetchFeatureToggles: PropTypes.func.isRequired,
updateSetting: PropTypes.func.isRequired,
+ toggleFeature: PropTypes.func.isRequired,
settings: PropTypes.object,
};
diff --git a/frontend/src/component/feature/metric-component.jsx b/frontend/src/component/feature/metric-component.jsx
index b0c61a777c..5bfae8ff4b 100644
--- a/frontend/src/component/feature/metric-component.jsx
+++ b/frontend/src/component/feature/metric-component.jsx
@@ -17,6 +17,9 @@ const StrategyChipItem = ({ strategy }) => (
);
+StrategyChipItem.propTypes = {
+ strategy: PropTypes.object.isRequired,
+};
// TODO what about "missing" strategies here?
const StrategiesList = ({ strategies }) => (
@@ -25,6 +28,9 @@ const StrategiesList = ({ strategies }) => (
{strategies.map((strategy, i) =>
)}
);
+StrategiesList.propTypes = {
+ strategies: PropTypes.array.isRequired,
+};
export default class MetricComponent extends React.Component {
static propTypes = {
diff --git a/frontend/src/component/history/history-component.jsx b/frontend/src/component/history/history-component.jsx
index 5b0c35882c..b207421c39 100644
--- a/frontend/src/component/history/history-component.jsx
+++ b/frontend/src/component/history/history-component.jsx
@@ -1,9 +1,15 @@
import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
import { Card } from 'react-mdl';
import HistoryList from './history-list-container';
import { styles as commonStyles } from '../common';
class History extends PureComponent {
+ static propTypes = {
+ fetchHistory: PropTypes.func.isRequired,
+ history: PropTypes.array.isRequired,
+ };
+
componentDidMount() {
this.props.fetchHistory();
}
diff --git a/frontend/src/component/history/history-list-component.jsx b/frontend/src/component/history/history-list-component.jsx
index e04de07a81..1b01155fdd 100644
--- a/frontend/src/component/history/history-list-component.jsx
+++ b/frontend/src/component/history/history-list-component.jsx
@@ -1,4 +1,5 @@
import React, { Component } from 'react';
+import PropTypes from 'prop-types';
import HistoryItemDiff from './history-item-diff';
import HistoryItemJson from './history-item-json';
import { Table, TableHeader } from 'react-mdl';
@@ -8,6 +9,13 @@ import { formatFullDateTime } from '../common/util';
import styles from './history.scss';
class HistoryList extends Component {
+ static propTypes = {
+ title: PropTypes.string,
+ history: PropTypes.array,
+ settings: PropTypes.object,
+ updateSetting: PropTypes.func.isRequired,
+ };
+
toggleShowDiff() {
this.props.updateSetting('showData', !this.props.settings.showData);
}
diff --git a/frontend/src/component/history/history-list-toggle-component.jsx b/frontend/src/component/history/history-list-toggle-component.jsx
index 11d093ae35..ee4a69b99a 100644
--- a/frontend/src/component/history/history-list-toggle-component.jsx
+++ b/frontend/src/component/history/history-list-toggle-component.jsx
@@ -5,6 +5,8 @@ import HistoryList from './history-list-container';
class HistoryListToggle extends Component {
static propTypes = {
toggleName: PropTypes.string.isRequired,
+ history: PropTypes.array,
+ fetchHistoryForToggle: PropTypes.func.isRequired,
};
componentDidMount() {
diff --git a/frontend/src/component/strategies/add-strategy.jsx b/frontend/src/component/strategies/add-strategy.jsx
index 107aebf960..551d47815a 100644
--- a/frontend/src/component/strategies/add-strategy.jsx
+++ b/frontend/src/component/strategies/add-strategy.jsx
@@ -66,6 +66,11 @@ const Parameter = ({ set, input = {}, index }) => (
/>
);
+Parameter.propTypes = {
+ input: PropTypes.object,
+ set: PropTypes.func,
+ index: PropTypes.number,
+};
const EditHeader = () => (
@@ -90,6 +95,12 @@ const Parameters = ({ input = [], count = 0, updateInList }) => (
);
+Parameters.propTypes = {
+ input: PropTypes.array,
+ updateInList: PropTypes.func.isRequired,
+ count: PropTypes.number,
+};
+
class AddStrategy extends Component {
static propTypes = {
input: PropTypes.object,
diff --git a/frontend/src/component/strategies/list-component.jsx b/frontend/src/component/strategies/list-component.jsx
index 90278ca07e..020602a706 100644
--- a/frontend/src/component/strategies/list-component.jsx
+++ b/frontend/src/component/strategies/list-component.jsx
@@ -6,6 +6,12 @@ import { List, ListItem, ListItemContent, IconButton, Grid, Cell } from 'react-m
import { HeaderTitle } from '../common';
class StrategiesListComponent extends Component {
+ static propTypes = {
+ strategies: PropTypes.array.isRequired,
+ fetchStrategies: PropTypes.func.isRequired,
+ removeStrategy: PropTypes.func.isRequired,
+ };
+
static contextTypes = {
router: PropTypes.object,
};
diff --git a/frontend/src/component/user/show-user-component.jsx b/frontend/src/component/user/show-user-component.jsx
index ef55e294ba..815df9282d 100644
--- a/frontend/src/component/user/show-user-component.jsx
+++ b/frontend/src/component/user/show-user-component.jsx
@@ -5,6 +5,7 @@ import styles from './user.scss';
export default class ShowUserComponent extends React.Component {
static propTypes = {
profile: PropTypes.object,
+ fetchUser: PropTypes.func.isRequired,
};
componentDidMount() {