Skip to content

Commit

Permalink
[eslint] Enforce react/prop-types
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 4, 2015
1 parent 12631c4 commit e965062
Show file tree
Hide file tree
Showing 58 changed files with 282 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ rules:
react/no-direct-mutation-state: 2
react/no-multi-comp: 0 # Wishlist, one day
react/no-unknown-property: 2
react/prop-types: 0 # Wishlist, one day
react/prop-types: 2
react/react-in-jsx-scope: 2
react/require-extension: 2
react/self-closing-comp: 2
Expand Down
4 changes: 4 additions & 0 deletions docs/src/app/components/app-left-nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const menuItems = [
const AppLeftNav = React.createClass({
mixins: [StylePropable],

propTypes: {
history: React.PropTypes.object,
},

contextTypes: {
muiTheme: React.PropTypes.object,
router: React.PropTypes.func,
Expand Down
4 changes: 4 additions & 0 deletions docs/src/app/components/code-example/code-block.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const DefaultRawTheme = Styles.LightRawTheme;

const CodeBlock = React.createClass({

propTypes: {
children: React.PropTypes.node,
},

contextTypes : {
muiTheme: React.PropTypes.object,
},
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/components/code-example/code-example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const DefaultRawTheme = Styles.LightRawTheme;
const CodeExample = React.createClass({

propTypes : {
children: React.PropTypes.node,
code: React.PropTypes.string.isRequired,
layoutSideBySide: React.PropTypes.bool,
},
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/components/component-doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const ComponentDoc = React.createClass({
},

propTypes: {
children: React.PropTypes.node,
componentInfo: React.PropTypes.array.isRequired,
desc: React.PropTypes.oneOfType([
React.PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/components/component-info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ComponentInfo = React.createClass({
propTypes: {
infoArray: React.PropTypes.array.isRequired,
name: React.PropTypes.string.isRequired,
style: React.PropTypes.object,
},

//for passing default theme context to children
Expand Down
2 changes: 2 additions & 0 deletions docs/src/app/components/full-width-section.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ let FullWidthSection = React.createClass({
mixins: [StylePropable, StyleResizable],

propTypes: {
children: React.PropTypes.node,
contentStyle: React.PropTypes.object,
contentType: React.PropTypes.string,
style: React.PropTypes.object,
useContent: React.PropTypes.bool,
},

Expand Down
5 changes: 5 additions & 0 deletions docs/src/app/components/master.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const Master = React.createClass({
};
},

propTypes: {
children: React.PropTypes.node,
history: React.PropTypes.object,
},

childContextTypes : {
muiTheme: React.PropTypes.object,
},
Expand Down
1 change: 1 addition & 0 deletions docs/src/app/components/mobile-tear-sheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const MobileTearSheet = React.createClass({
},

propTypes: {
children: React.PropTypes.node,
height: React.PropTypes.number,
},

Expand Down
4 changes: 4 additions & 0 deletions docs/src/app/components/pages/components.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ export default class Components extends React.Component {
}

}

Components.propTypes = {
children: React.PropTypes.node,
};
5 changes: 5 additions & 0 deletions docs/src/app/components/pages/components/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,8 @@ export default class TabsPage extends React.Component {
this.setState({tabsValue: value});
}
}


TabsPage.propTypes = {
history: React.PropTypes.object,
};
4 changes: 4 additions & 0 deletions docs/src/app/components/pages/customization.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ export default class Customization extends React.Component {
}

}

Customization.propTypes = {
children: React.PropTypes.node,
};
4 changes: 4 additions & 0 deletions docs/src/app/components/pages/get-started.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export default class GetStarted extends React.Component {
}

}

GetStarted.propTypes = {
children: React.PropTypes.node,
};
1 change: 1 addition & 0 deletions docs/src/app/components/pages/page-with-nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let PageWithNav = React.createClass({
mixins: [StyleResizable, StylePropable, History],

propTypes: {
children: React.PropTypes.node,
menuItems: React.PropTypes.array,
},

Expand Down
8 changes: 5 additions & 3 deletions src/card/card-actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import StylePropable from '../mixins/style-propable';
import ThemeManager from '../styles/theme-manager';
import DefaultRawTheme from '../styles/raw-themes/light-raw-theme';


const CardActions = React.createClass({
mixins: [StylePropable],
mixins: [
StylePropable,
],

contextTypes: {
muiTheme: React.PropTypes.object,
Expand All @@ -31,7 +32,7 @@ const CardActions = React.createClass({
//to update theme inside state whenever a new theme is passed down
//from the parent / owner using context
componentWillReceiveProps(nextProps, nextContext) {
let newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme;
const newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme;
this.setState({muiTheme: newMuiTheme});
},

Expand All @@ -46,6 +47,7 @@ const CardActions = React.createClass({

propTypes: {
actAsExpander: React.PropTypes.bool,
children: React.PropTypes.node,
expandable: React.PropTypes.bool,
showExpandableButton: React.PropTypes.bool,
style: React.PropTypes.object,
Expand Down
6 changes: 4 additions & 2 deletions src/card/card-header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import StylePropable from '../mixins/style-propable';
import ThemeManager from '../styles/theme-manager';
import DefaultRawTheme from '../styles/raw-themes/light-raw-theme';


const CardHeader = React.createClass({

mixins: [StylePropable],
mixins: [
StylePropable,
],

contextTypes: {
muiTheme: React.PropTypes.object,
Expand Down Expand Up @@ -41,6 +42,7 @@ const CardHeader = React.createClass({
propTypes: {
actAsExpander: React.PropTypes.bool,
avatar: React.PropTypes.node,
children: React.PropTypes.node,
expandable: React.PropTypes.bool,
showExpandableButton: React.PropTypes.bool,
style: React.PropTypes.object,
Expand Down
5 changes: 4 additions & 1 deletion src/card/card-media.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import DefaultRawTheme from '../styles/raw-themes/light-raw-theme';

const CardMedia = React.createClass({

mixins:[StylePropable],
mixins: [
StylePropable,
],

contextTypes: {
muiTheme: React.PropTypes.object,
Expand Down Expand Up @@ -39,6 +41,7 @@ const CardMedia = React.createClass({

propTypes: {
actAsExpander: React.PropTypes.bool,
children: React.PropTypes.node,
expandable: React.PropTypes.bool,
mediaStyle: React.PropTypes.object,
overlay: React.PropTypes.node,
Expand Down
6 changes: 4 additions & 2 deletions src/card/card-text.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import StylePropable from '../mixins/style-propable';
import ThemeManager from '../styles/theme-manager';
import DefaultRawTheme from '../styles/raw-themes/light-raw-theme';


const CardText = React.createClass({

mixins: [StylePropable],
mixins: [
StylePropable,
],

contextTypes: {
muiTheme: React.PropTypes.object,
Expand Down Expand Up @@ -38,6 +39,7 @@ const CardText = React.createClass({

propTypes: {
actAsExpander: React.PropTypes.bool,
children: React.PropTypes.node,
color: React.PropTypes.string,
expandable: React.PropTypes.bool,
style: React.PropTypes.object,
Expand Down
28 changes: 18 additions & 10 deletions src/card/card-title.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import StylePropable from '../mixins/style-propable';
import ThemeManager from '../styles/theme-manager';
import DefaultRawTheme from '../styles/raw-themes/light-raw-theme';


const CardTitle = React.createClass({

mixins: [StylePropable],
mixins: [
StylePropable,
],

contextTypes: {
muiTheme: React.PropTypes.object,
Expand All @@ -33,12 +34,15 @@ const CardTitle = React.createClass({
//to update theme inside state whenever a new theme is passed down
//from the parent / owner using context
componentWillReceiveProps(nextProps, nextContext) {
let newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme;
this.setState({muiTheme: newMuiTheme});
const newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme;
this.setState({
muiTheme: newMuiTheme,
});
},

propTypes: {
actAsExpander: React.PropTypes.bool,
children: React.PropTypes.node,
expandable: React.PropTypes.bool,
showExpandableButton: React.PropTypes.bool,
style: React.PropTypes.object,
Expand Down Expand Up @@ -78,15 +82,19 @@ const CardTitle = React.createClass({
},

render() {
let styles = this.getStyles();
let rootStyle = this.prepareStyles(styles.root, this.props.style);
let titleStyle = this.prepareStyles(styles.title, this.props.titleStyle);
let subtitleStyle = this.prepareStyles(styles.subtitle, this.props.subtitleStyle);
const styles = this.getStyles();
const rootStyle = this.prepareStyles(styles.root, this.props.style);
const titleStyle = this.prepareStyles(styles.title, this.props.titleStyle);
const subtitleStyle = this.prepareStyles(styles.subtitle, this.props.subtitleStyle);

return (
<div {...this.props} style={rootStyle}>
<span style={titleStyle}>{this.props.title}</span>
<span style={subtitleStyle}>{this.props.subtitle}</span>
<span style={titleStyle}>
{this.props.title}
</span>
<span style={subtitleStyle}>
{this.props.subtitle}
</span>
{this.props.children}
</div>
);
Expand Down
8 changes: 6 additions & 2 deletions src/date-picker/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import DefaultRawTheme from '../styles/raw-themes/light-raw-theme';

const Calendar = React.createClass({

mixins: [StylePropable, WindowListenable],
mixins: [
StylePropable,
WindowListenable,
],

contextTypes: {
muiTheme: React.PropTypes.object,
Expand All @@ -40,13 +43,14 @@ const Calendar = React.createClass({
locale: React.PropTypes.string.isRequired,
maxDate: React.PropTypes.object,
minDate: React.PropTypes.object,
mode: React.PropTypes.oneOf(['portrait', 'landscape']),
onDayTouchTap: React.PropTypes.func,
open: React.PropTypes.bool,
shouldDisableDate: React.PropTypes.func,
},

windowListeners: {
'keydown': '_handleWindowKeyDown',
keydown: '_handleWindowKeyDown',
},

getDefaultProps() {
Expand Down
7 changes: 6 additions & 1 deletion src/date-picker/date-display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import ThemeManager from '../styles/theme-manager';

const DateDisplay = React.createClass({

mixins: [StylePropable],
mixins: [
StylePropable,
],

contextTypes: {
muiTheme: React.PropTypes.object,
Expand All @@ -16,7 +18,10 @@ const DateDisplay = React.createClass({
propTypes: {
DateTimeFormat: React.PropTypes.func.isRequired,
disableYearSelection: React.PropTypes.bool,
handleMonthDayClick: React.PropTypes.func,
handleYearClick: React.PropTypes.func,
locale: React.PropTypes.string.isRequired,
mode: React.PropTypes.oneOf(['portrait', 'landscape']),
monthDaySelected: React.PropTypes.bool,
selectedDate: React.PropTypes.object.isRequired,
style: React.PropTypes.object,
Expand Down
38 changes: 21 additions & 17 deletions src/date-picker/date-picker-inline.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import React from 'react';
import Paper from '../paper';

const styles = {
actions: {
marginRight: 8,
paddingBottom: 12,
textAlign: 'right',
},
container: {
zIndex: 3,
width: '100%',
position: 'relative',
display: 'block',
},
subContainer: {
position: 'absolute',
height: 'auto',
},
};

const DatePickerInline = React.createClass({

propTypes: {
actions: React.PropTypes.node,
children: React.PropTypes.node,
open: React.PropTypes.bool,
style: React.PropTypes.object,
},

getDefaultProps() {
Expand All @@ -26,23 +47,6 @@ const DatePickerInline = React.createClass({
return <span />;
}

const styles = {
actions: {
marginRight: 8,
paddingBottom: 12,
textAlign: 'right',
},
container: {
zIndex: 3,
width: '100%',
position: 'relative',
display: 'block',
},
subContainer: {
position: 'absolute',
height: 'auto',
},
};
return (
<div style={styles.container}>
<div style={styles.subContainer}>
Expand Down
Loading

0 comments on commit e965062

Please sign in to comment.