Skip to content

Commit

Permalink
setup eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
damusnet committed Oct 13, 2015
1 parent 9f7d60c commit f8680aa
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 59 deletions.
18 changes: 11 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"extends": "eslint:recommended",
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"node": true
"node": true,
"es6": true
},
"parser": "babel-eslint",
"rules": {
"quotes": [2, "single"],
"strict": [2, "never"],
"no-underscore-dangle": [0],
"curly": [0]
}
"extends": "defaults/configurations/airbnb",
"plugins": [
"react"
]
}
24 changes: 14 additions & 10 deletions lib/SwipeViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ Object.defineProperty(exports, '__esModule', {

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

'use strict';

var SwipeViews = (function (_React$Component) {
_inherits(SwipeViews, _React$Component);

function SwipeViews(props) {
_classCallCheck(this, SwipeViews);

Expand All @@ -38,8 +38,6 @@ var SwipeViews = (function (_React$Component) {
};
}

_inherits(SwipeViews, _React$Component);

_createClass(SwipeViews, [{
key: 'componentDidMount',
value: function componentDidMount() {
Expand All @@ -48,7 +46,7 @@ var SwipeViews = (function (_React$Component) {
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
this._selectIndex(parseInt(nextProps.selectedIndex));
this._selectIndex(parseInt(nextProps.selectedIndex, 10));
}
}, {
key: 'render',
Expand Down Expand Up @@ -136,13 +134,13 @@ var SwipeViews = (function (_React$Component) {
if (!this.context.router) {
return null;
}
this.props.children.map(function (child, selectedIndex) {
this.props.children.map(function (child, index) {
var to = child.props.title.props.to;
var isActive = _this2.context.router.isActive(to);
if (isActive) {
var translation = selectedIndex * _this2.state.pageWidthPerCent;
var translation = index * _this2.state.pageWidthPerCent;
return _this2.setState({
selectedIndex: selectedIndex,
selectedIndex: index,
translation: translation,
clientX: null,
animate: true
Expand Down Expand Up @@ -250,4 +248,10 @@ exports['default'] = SwipeViews;
SwipeViews.contextTypes = {
router: _react2['default'].PropTypes.func
};

SwipeViews.propTypes = {
children: _react2['default'].PropTypes.array.isRequired,
selectedIndex: _react2['default'].PropTypes.number,
onIndexChange: _react2['default'].PropTypes.func
};
module.exports = exports['default'];
48 changes: 26 additions & 22 deletions lib/react-swipe-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };

function _interopRequire(obj) { return obj && obj.__esModule ? obj['default'] : obj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var _React = _interopRequire(_react);

'use strict';
var _React = _interopRequireDefault(_react);

var SwipeViews = (function (_React$Component) {
_inherits(SwipeViews, _React$Component);

function SwipeViews(props) {
_classCallCheck(this, SwipeViews);

Expand All @@ -45,8 +45,6 @@
};
}

_inherits(SwipeViews, _React$Component);

_createClass(SwipeViews, [{
key: 'componentDidMount',
value: function componentDidMount() {
Expand All @@ -55,7 +53,7 @@
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
this._selectIndex(parseInt(nextProps.selectedIndex));
this._selectIndex(parseInt(nextProps.selectedIndex, 10));
}
}, {
key: 'render',
Expand All @@ -75,21 +73,21 @@
width: this.props.children.length * 100 + '%'
};

return _React.createElement(
return _React['default'].createElement(
'div',
{ className: 'SwipeViewsContainer' },
_React.createElement(
_React['default'].createElement(
'header',
{ className: 'SwipeViewsHeader' },
_React.createElement(
_React['default'].createElement(
'div',
{ className: 'SwipeViewsTabs' },
_React.createElement(
_React['default'].createElement(
'ul',
null,
this.props.children.map(function (child, index) {
var className = index === _this.state.selectedIndex ? 'active' : '';
return _React.createElement(
return _React['default'].createElement(
'li',
{
key: index,
Expand All @@ -100,10 +98,10 @@
);
})
),
_React.createElement('div', { className: 'SwipeViewsInk', style: swipeViewsInkStyle })
_React['default'].createElement('div', { className: 'SwipeViewsInk', style: swipeViewsInkStyle })
)
),
_React.createElement(
_React['default'].createElement(
'div',
{
className: 'SwipeViews',
Expand All @@ -112,7 +110,7 @@
onTouchEnd: this._handleTouchEnd.bind(this)
},
this.props.children.map(function (child, index) {
return _React.createElement(
return _React['default'].createElement(
'div',
{
className: 'SwipeView',
Expand Down Expand Up @@ -143,13 +141,13 @@
if (!this.context.router) {
return null;
}
this.props.children.map(function (child, selectedIndex) {
this.props.children.map(function (child, index) {
var to = child.props.title.props.to;
var isActive = _this2.context.router.isActive(to);
if (isActive) {
var translation = selectedIndex * _this2.state.pageWidthPerCent;
var translation = index * _this2.state.pageWidthPerCent;
return _this2.setState({
selectedIndex: selectedIndex,
selectedIndex: index,
translation: translation,
clientX: null,
animate: true
Expand Down Expand Up @@ -250,11 +248,17 @@
}]);

return SwipeViews;
})(_React.Component);
})(_React['default'].Component);

module.exports = SwipeViews;

SwipeViews.contextTypes = {
router: _React.PropTypes.func
router: _React['default'].PropTypes.func
};

SwipeViews.propTypes = {
children: _React['default'].PropTypes.array.isRequired,
selectedIndex: _React['default'].PropTypes.number,
onIndexChange: _React['default'].PropTypes.func
};
});
2 changes: 1 addition & 1 deletion lib/react-swipe-views.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f8680aa

Please sign in to comment.