From 7202970bdcf65edd2354216784de01f944211d25 Mon Sep 17 00:00:00 2001 From: AlexKVal Date: Thu, 20 Aug 2015 17:48:26 +0300 Subject: [PATCH] Impose 'brace-style' 'default-case' and 'ident' rules part of `airbnb` style --- .eslintrc | 3 --- docs/examples/ButtonInput.js | 4 +-- docs/examples/Input.js | 6 ++--- docs/src/PropTable.js | 44 +++++++++++++++--------------- src/AffixMixin.js | 2 +- src/Carousel.js | 24 ++++++++--------- src/Dropdown.js | 33 +++++++++++------------ src/DropdownMenu.js | 25 +++++++++--------- src/InputBase.js | 47 +++++++++++++++++---------------- src/NavItem.js | 20 +++++++------- src/Navbar.js | 2 +- src/Overlay.js | 4 +-- src/SplitButton.js | 2 +- src/Tabs.js | 20 +++++++------- src/Thumbnail.js | 6 ++--- src/utils/deprecationWarning.js | 4 +-- test/GlyphiconSpec.js | 8 +++--- test/ThumbnailSpec.js | 4 +-- tools/build.js | 12 ++++----- tools/fs-utils.js | 42 ++++++++++++++--------------- 20 files changed, 153 insertions(+), 159 deletions(-) diff --git a/.eslintrc b/.eslintrc index 7e00e12148..ae5570a5d6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,15 +13,12 @@ "babel" ], "rules": { - "brace-style": 0, "constructor-super": 2, "comma-dangle": 0, "comma-spacing": 2, "comma-style": [2, "last"], - "default-case": 0, "func-names": 0, "guard-for-in": 0, - "indent": 0, "one-var": [2, { "initialized": "never" }], "padded-blocks": 0, "prefer-const": 0, diff --git a/docs/examples/ButtonInput.js b/docs/examples/ButtonInput.js index e1c64bdfb2..774940998d 100644 --- a/docs/examples/ButtonInput.js +++ b/docs/examples/ButtonInput.js @@ -17,8 +17,8 @@ const ButtonInputExample = React.createClass({ let length = this.refs.input.getValue().length; let style = 'danger'; - if (length > 10) { style = 'success'; } - else if (length > 5) { style = 'warning'; } + if (length > 10) style = 'success'; + else if (length > 5) style = 'warning'; let disabled = style !== 'success'; diff --git a/docs/examples/Input.js b/docs/examples/Input.js index 980413339a..c98d7911e7 100644 --- a/docs/examples/Input.js +++ b/docs/examples/Input.js @@ -7,9 +7,9 @@ const ExampleInput = React.createClass({ validationState() { let length = this.state.value.length; - if (length > 10) { return 'success'; } - else if (length > 5) { return 'warning'; } - else if (length > 0) { return 'error'; } + if (length > 10) return 'success'; + else if (length > 5) return 'warning'; + else if (length > 0) return 'error'; }, handleChange() { diff --git a/docs/src/PropTable.js b/docs/src/PropTable.js index 46fb2314c8..4feaed34a4 100644 --- a/docs/src/PropTable.js +++ b/docs/src/PropTable.js @@ -146,28 +146,28 @@ const PropTable = React.createClass({ let doclets = prop.doclets || {}; switch (name) { - case 'object': - return name; - case 'union': - return type.value.reduce((current, val, i, list) => { - let item = this.getType({ type: val }); - if (React.isValidElement(item)) { - item = React.cloneElement(item, {key: i}); - } - current = current.concat(item); - - return i === (list.length - 1) ? current : current.concat(' | '); - }, []); - case 'array': - let child = this.getType({ type: type.value }); - - return {'array<'}{ child }{'>'}; - case 'enum': - return this.renderEnum(type); - case 'custom': - return cleanDocletValue(doclets.type || name); - default: - return name; + case 'object': + return name; + case 'union': + return type.value.reduce((current, val, i, list) => { + let item = this.getType({ type: val }); + if (React.isValidElement(item)) { + item = React.cloneElement(item, {key: i}); + } + current = current.concat(item); + + return i === (list.length - 1) ? current : current.concat(' | '); + }, []); + case 'array': + let child = this.getType({ type: type.value }); + + return {'array<'}{ child }{'>'}; + case 'enum': + return this.renderEnum(type); + case 'custom': + return cleanDocletValue(doclets.type || name); + default: + return name; } }, diff --git a/src/AffixMixin.js b/src/AffixMixin.js index af97e131c7..8e013dd4dc 100644 --- a/src/AffixMixin.js +++ b/src/AffixMixin.js @@ -30,7 +30,7 @@ const AffixMixin = { checkPosition() { let DOMNode, scrollHeight, scrollTop, position, offsetTop, offsetBottom, - affix, affixType, affixPositionTop; + affix, affixType, affixPositionTop; // TODO: or not visible if (!this.isMounted()) { diff --git a/src/Carousel.js b/src/Carousel.js index 8801661c2d..c306b6285b 100644 --- a/src/Carousel.js +++ b/src/Carousel.js @@ -249,18 +249,18 @@ const Carousel = React.createClass({ this.state.previousActiveIndex === index && this.props.slide; return cloneElement( - child, - { - active: isActive, - ref: child.ref, - key: child.key ? child.key : index, - index, - animateOut: isPreviousActive, - animateIn: isActive && this.state.previousActiveIndex != null && this.props.slide, - direction: this.state.direction, - onAnimateOutEnd: isPreviousActive ? this.handleItemAnimateOutEnd : null - } - ); + child, + { + active: isActive, + ref: child.ref, + key: child.key ? child.key : index, + index, + animateOut: isPreviousActive, + animateIn: isActive && this.state.previousActiveIndex != null && this.props.slide, + direction: this.state.direction, + onAnimateOutEnd: isPreviousActive ? this.handleItemAnimateOutEnd : null + } + ); }, handleSelect(index, direction) { diff --git a/src/Dropdown.js b/src/Dropdown.js index a5b652af39..473e4a62f1 100644 --- a/src/Dropdown.js +++ b/src/Dropdown.js @@ -106,21 +106,21 @@ class Dropdown extends React.Component { }; switch(event.keyCode) { - case keycode.codes.down: - if (!this.props.open) { - this.toggleOpen(); - } - else { - focusNext(); - } - event.preventDefault(); - break; - case keycode.codes.esc: - case keycode.codes.tab: - if (this.props.open) { - this.handleClose(event); - } - break; + case keycode.codes.down: + if (!this.props.open) { + this.toggleOpen(); + } else { + focusNext(); + } + event.preventDefault(); + break; + case keycode.codes.esc: + case keycode.codes.tab: + if (this.props.open) { + this.handleClose(event); + } + break; + default: } } @@ -134,8 +134,7 @@ class Dropdown extends React.Component { // to the next focusable input if (event && event.keyCode === keycode.codes.tab){ setTimeout(this.toggleOpen); - } - else { + } else { this.toggleOpen(); } diff --git a/src/DropdownMenu.js b/src/DropdownMenu.js index 770684e26b..ed81eb21fe 100644 --- a/src/DropdownMenu.js +++ b/src/DropdownMenu.js @@ -20,18 +20,19 @@ class DropdownMenu extends React.Component { handleKeyDown(event) { switch(event.keyCode) { - case keycode.codes.down: - this.focusNext(); - event.preventDefault(); - break; - case keycode.codes.up: - this.focusPrevious(); - event.preventDefault(); - break; - case keycode.codes.esc: - case keycode.codes.tab: - this.props.onClose(event); - break; + case keycode.codes.down: + this.focusNext(); + event.preventDefault(); + break; + case keycode.codes.up: + this.focusPrevious(); + event.preventDefault(); + break; + case keycode.codes.esc: + case keycode.codes.tab: + this.props.onClose(event); + break; + default: } } diff --git a/src/InputBase.js b/src/InputBase.js index c5745d3867..c1e193053e 100644 --- a/src/InputBase.js +++ b/src/InputBase.js @@ -76,8 +76,9 @@ class InputBase extends React.Component { let inputGroupClassName; switch (this.props.bsSize) { - case 'small': inputGroupClassName = 'input-group-sm'; break; - case 'large': inputGroupClassName = 'input-group-lg'; break; + case 'small': inputGroupClassName = 'input-group-sm'; break; + case 'large': inputGroupClassName = 'input-group-lg'; break; + default: } return addonBefore || addonAfter || buttonBefore || buttonAfter ? ( @@ -98,10 +99,10 @@ class InputBase extends React.Component { } switch (this.props.bsStyle) { - case 'success': return ; - case 'warning': return ; - case 'error': return ; - default: return ; + case 'success': return ; + case 'warning': return ; + case 'error': return ; + default: return ; } } else { return null; @@ -157,24 +158,24 @@ class InputBase extends React.Component { } switch (this.props.type) { - case 'select': - return ( - - ); - case 'textarea': - return