Skip to content

Commit

Permalink
Merge pull request react-bootstrap#638 from AlexKVal/object-shorthand
Browse files Browse the repository at this point in the history
Add new ealint `object-shorthand` rule.
  • Loading branch information
AlexKVal committed May 10, 2015
2 parents 3017b18 + 02a8764 commit 1181c55
Show file tree
Hide file tree
Showing 32 changed files with 73 additions and 72 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"no-underscore-dangle": 0,
"no-unused-vars": [1, { "vars": "all", "args": "none" }],
"no-var": 2,
"object-shorthand": 1,
"quotes": [1, "single", "avoid-escape"],
"react/display-name": 0,
"react/jsx-no-undef": 1,
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/CollapsibleParagraph.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const CollapsibleParagraph = React.createClass({
mixins: [CollapsibleMixin],

getCollapsibleDOMNode: function(){
getCollapsibleDOMNode(){
return this.refs.panel.getDOMNode();
},

getCollapsibleDimensionValue: function(){
getCollapsibleDimensionValue(){
return this.refs.panel.getDOMNode().scrollHeight;
},

onHandleToggle: function(e){
onHandleToggle(e){
e.preventDefault();
this.setState({expanded:!this.state.expanded});
},

render: function(){
render(){
let styles = this.getCollapsibleClassSet();
let text = this.isExpanded() ? 'Hide' : 'Show';
return (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/IntroductionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PageHeader from './PageHeader';
import PageFooter from './PageFooter';

const IntroductionPage = React.createClass({
render: function () {
render() {
return (
<div>
<NavMain activePage="introduction" />
Expand Down
4 changes: 2 additions & 2 deletions docs/src/ReactPlayground.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const ReactPlayground = React.createClass({
},

handleCodeModeSwitch(mode) {
this.setState({mode: mode});
this.setState({mode});
},

handleCodeModeToggle(e) {
Expand All @@ -209,7 +209,7 @@ const ReactPlayground = React.createClass({
mode = this.MODES.NONE;
}

this.setState({mode: mode});
this.setState({mode});
},

compileCode() {
Expand Down
4 changes: 2 additions & 2 deletions ie8/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let app = express();

if (development) {
let webpackConfig = webpackConfigBuilder({
development: development,
development,
ie8: true
});
let publicPath = webpackConfig.output.publicPath;
Expand All @@ -23,7 +23,7 @@ if (development) {
app = app
.use(webpackMiddleware(webpack(webpackConfig), {
noInfo: false,
publicPath: publicPath,
publicPath,
stats: {
colors: true
}
Expand Down
2 changes: 1 addition & 1 deletion src/Affix.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import domUtils from './utils/domUtils';

const Affix = React.createClass({
statics: {
domUtils: domUtils
domUtils
},

mixins: [AffixMixin],
Expand Down
2 changes: 1 addition & 1 deletion src/AffixMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const AffixMixin = {

this.setState({
affixClass: affixType,
affixPositionTop: affixPositionTop
affixPositionTop
});
},

Expand Down
2 changes: 1 addition & 1 deletion src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Button = React.createClass({
classes = {
active: this.props.active,
'btn-block': this.props.block,
...classes
...classes // eslint-disable-line object-shorthand
};

if (this.props.navItem) {
Expand Down
6 changes: 3 additions & 3 deletions src/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const Carousel = React.createClass({
active: isActive,
ref: child.ref,
key: child.key ? child.key : index,
index: index,
index,
animateOut: isPreviousActive,
animateIn: isActive && this.state.previousActiveIndex != null && this.props.slide,
direction: this.state.direction,
Expand Down Expand Up @@ -278,8 +278,8 @@ const Carousel = React.createClass({

this.setState({
activeIndex: index,
previousActiveIndex: previousActiveIndex,
direction: direction
previousActiveIndex,
direction
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/CollapsibleNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const specCollapsibleNav = {
activeKey: this.props.activeKey,
activeHref: this.props.activeHref,
ref: 'nocollapse_' + key,
key: key,
key,
navItem: true
}
);
Expand All @@ -114,7 +114,7 @@ const specCollapsibleNav = {
activeHref: this.props.activeHref,
onSelect: createChainedFunction(child.props.onSelect, this.props.onSelect),
ref: 'collapsible_' + key,
key: key,
key,
navItem: true
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/FadeMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
}
},

componentWillUnmount: function () {
componentWillUnmount() {
let els = getElementsAndSelf(React.findDOMNode(this), ['fade']),
container = (this.props.container && React.findDOMNode(this.props.container)) ||
domUtils.ownerDocument(this).body;
Expand Down
2 changes: 1 addition & 1 deletion src/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Input extends React.Component {

renderFormGroup(children) {
if (this.props.type === 'submit') {
let {bsStyle, ...other} = this.props; /* eslint no-unused-vars: 0 */
let {bsStyle, ...other} = this.props; /* eslint no-unused-vars: 0 object-shorthand: 0 */
return <FormGroup {...other}>{children}</FormGroup>;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Nav = React.createClass({
return React.findDOMNode(this);
},

getCollapsibleDimensionValue: function () {
getCollapsibleDimensionValue() {
let node = React.findDOMNode(this.refs.ul),
height = node.offsetHeight,
computedStyles = domUtils.getComputedStyles(node);
Expand Down
6 changes: 3 additions & 3 deletions src/NavItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const NavItem = React.createClass({
title,
target,
children,
...props } = this.props;
...props } = this.props; // eslint-disable-line object-shorthand
let classes = {
'active': active,
'disabled': disabled
active,
disabled
};
let linkProps = {
href,
Expand Down
2 changes: 1 addition & 1 deletion src/OverlayTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const OverlayTrigger = React.createClass({
}
},

getPosition: function () {
getPosition() {
let node = React.findDOMNode(this);
let container = this.getContainerDOMNode();

Expand Down
2 changes: 1 addition & 1 deletion src/styleMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const styleMaps = {
'tabs': 'tabs',
'pills': 'pills'
},
addStyle: function(name) {
addStyle(name) {
styleMaps.STYLES[name] = name;
},
SIZES: {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/EventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ const EventListener = {
* @param {function} callback Callback function.
* @return {object} Object with a `remove` method.
*/
listen: function(target, eventType, callback) {
listen(target, eventType, callback) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, false);
return {
remove: function() {
remove() {
target.removeEventListener(eventType, callback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent('on' + eventType, callback);
return {
remove: function() {
remove() {
target.detachEvent('on' + eventType, callback);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/utils/TransitionEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function removeEventListener(node, eventName, eventListener) {
}

const ReactTransitionEvents = {
addEndEventListener: function(node, eventListener) {
addEndEventListener(node, eventListener) {
if (endEvents.length === 0) {
// If CSS transitions are not supported, trigger an "end animation"
// event immediately.
Expand All @@ -100,7 +100,7 @@ const ReactTransitionEvents = {
});
},

removeEndEventListener: function(node, eventListener) {
removeEndEventListener(node, eventListener) {
if (endEvents.length === 0) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ValidComponentChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ export default {
map: mapValidComponents,
forEach: forEachValidComponents,
numberOf: numberOfValidComponents,
hasValidComponent: hasValidComponent
hasValidComponent
};
8 changes: 4 additions & 4 deletions src/utils/domUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ function offsetParentFunc(elem) {
}

export default {
ownerDocument: ownerDocument,
getComputedStyles: getComputedStyles,
getOffset: getOffset,
getPosition: getPosition,
ownerDocument,
getComputedStyles,
getOffset,
getPosition,
offsetParent: offsetParentFunc
};
2 changes: 1 addition & 1 deletion test/BootstrapMixinSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('BootstrapMixin', function () {
Component = React.createClass({
mixins: [BootstrapMixin],

render: function () {
render() {
return React.DOM.button(this.props);
}
});
Expand Down
6 changes: 3 additions & 3 deletions test/CollapsableMixinSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ describe('CollapsableMixin', function () {
Component = React.createClass({
mixins: [CollapsableMixin],

getCollapsableDOMNode: function(){
getCollapsableDOMNode(){
return this.refs.panel.getDOMNode();
},

getCollapsableDimensionValue: function(){
getCollapsableDimensionValue(){
return 15;
},

render: function(){
render(){
let styles = this.getCollapsableClassSet();
return (
<div>
Expand Down
12 changes: 6 additions & 6 deletions test/CollapsableNavSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {shouldWarn} from './helpers';
describe('Deprecations for collapsable property in CollapsibleNav', function () {
it('Should not warn about deprecation when collaps_i_ble property is used', function () {
let Component = React.createClass({
render: function() {
render() {
return (
<CollapsibleNav collapsible />
);
Expand All @@ -21,7 +21,7 @@ describe('Deprecations for collapsable property in CollapsibleNav', function ()

it('Should warn about deprecation when collaps_a_ble property is used', function () {
let Component = React.createClass({
render: function() {
render() {
return (
<CollapsibleNav collapsable />
);
Expand All @@ -36,7 +36,7 @@ describe('Deprecations for collapsable property in CollapsibleNav', function ()
describe('Deprecations for collapsable property in Panel', function () {
it('Should not warn about deprecation when collaps_i_ble property is used', function () {
let Component = React.createClass({
render: function() {
render() {
return (
<Panel collapsible />
);
Expand All @@ -49,7 +49,7 @@ describe('Deprecations for collapsable property in Panel', function () {

it('Should warn about deprecation when collaps_a_ble property is used', function () {
let Component = React.createClass({
render: function() {
render() {
return (
<Panel collapsable />
);
Expand All @@ -64,7 +64,7 @@ describe('Deprecations for collapsable property in Panel', function () {
describe('Deprecations for collapsable property in Nav', function () {
it('Should not warn about deprecation when collaps_i_ble property is used', function () {
let Component = React.createClass({
render: function() {
render() {
return (
<Nav collapsible />
);
Expand All @@ -77,7 +77,7 @@ describe('Deprecations for collapsable property in Nav', function () {

it('Should warn about deprecation when collaps_a_ble property is used', function () {
let Component = React.createClass({
render: function() {
render() {
return (
<Nav collapsable />
);
Expand Down
14 changes: 7 additions & 7 deletions test/CollapsibleMixinSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ describe('CollapsibleMixin', function () {
Component = React.createClass({
mixins: [CollapsibleMixin],

getCollapsibleDOMNode: function(){
getCollapsibleDOMNode(){
return this.refs.panel.getDOMNode();
},

getCollapsibleDimensionValue: function(){
getCollapsibleDimensionValue(){
return 15;
},

render: function(){
render(){
let styles = this.getCollapsibleClassSet();
return (
<div>
Expand Down Expand Up @@ -222,9 +222,9 @@ describe('CollapsibleMixin', function () {
Component = React.createClass({
mixins: [CollapsibleMixin],

getCollapsableDimension: function(){},
getCollapsableDimension(){},

render: function(){
render(){
return ( <div /> );
}
});
Expand All @@ -241,9 +241,9 @@ describe('CollapsibleMixin', function () {
Component = React.createClass({
mixins: [CollapsibleMixin],

getCollapsibleDimension: function(){},
getCollapsibleDimension(){},

render: function(){
render(){
return ( <div /> );
}
});
Expand Down
Loading

0 comments on commit 1181c55

Please sign in to comment.