Skip to content

Commit

Permalink
chore: eslint security upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
fgladisch committed Jul 2, 2019
1 parent f7400ac commit 8cd8795
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"rules": {
"indent" : [2, "tab", { "SwitchCase": 1 }],
"react/jsx-indent": [2, 'tab'],
"react/jsx-indent-props": [2, 'tab'],
"react/jsx-indent": [2, "tab"],
"react/jsx-indent-props": [2, "tab"],
"no-tabs": 0
}
}
63 changes: 63 additions & 0 deletions dist/containers/CenterContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');

var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var alignItems = function alignItems(direction, horizontal, vertical) {
return direction === 'row' && vertical || direction === 'column' && horizontal;
};
var justifyContent = function justifyContent(direction, horizontal, vertical) {
return direction === 'row' && horizontal || direction === 'column' && vertical;
};

var CenterContainer = function CenterContainer(props) {
var style = props.style,
direction = props.direction,
horizontal = props.horizontal,
vertical = props.vertical,
children = props.children,
other = (0, _objectWithoutProperties3.default)(props, ['style', 'direction', 'horizontal', 'vertical', 'children']);

var containerStyle = (0, _extends3.default)({
display: 'flex',
flexDirection: props.direction,
alignItems: alignItems(direction, horizontal, vertical) ? 'center' : 'stretch',
justifyContent: justifyContent(direction, horizontal, vertical) ? 'center' : 'stretch'
}, style);

return _react2.default.createElement(
'div',
(0, _extends3.default)({ style: containerStyle }, other),
children
);
};
CenterContainer.propTypes = {
children: _react2.default.PropTypes.node,
style: _react2.default.PropTypes.object,
direction: _react2.default.PropTypes.string,
vertical: _react2.default.PropTypes.bool,
horizontal: _react2.default.PropTypes.bool
};
CenterContainer.defaultProps = {
style: {},
direction: 'row',
vertical: true,
horizontal: true
};

exports.default = CenterContainer;
19 changes: 19 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Stopwatch = exports.CenterContainer = undefined;

var _CenterContainer = require('./containers/CenterContainer');

var _CenterContainer2 = _interopRequireDefault(_CenterContainer);

var _Stopwatch = require('./timers/Stopwatch');

var _Stopwatch2 = _interopRequireDefault(_Stopwatch);

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

exports.CenterContainer = _CenterContainer2.default;
exports.Stopwatch = _Stopwatch2.default;
118 changes: 118 additions & 0 deletions dist/timers/Stopwatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Stopwatch = undefined;

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _sprintf = require('sprintf-js/src/sprintf');

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

var Stopwatch = exports.Stopwatch = function (_React$Component) {
(0, _inherits3.default)(Stopwatch, _React$Component);

function Stopwatch() {
var _ref;

var _temp, _this, _ret;

(0, _classCallCheck3.default)(this, Stopwatch);

for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = Stopwatch.__proto__ || (0, _getPrototypeOf2.default)(Stopwatch)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
elapsed: 0,
startTime: new Date(),
timer: null
}, _this.calculateElapsedSeconds = function (startTime) {
var now = new Date();
var timeDiff = now.getTime() - startTime.getTime();

return Math.abs(timeDiff / 1000);
}, _this.getTimeDiffString = function () {
var seconds = Math.floor(_this.state.elapsed % 60);
var minutes = Math.floor(_this.state.elapsed / 60) % 60;
var hours = Math.floor(_this.state.elapsed / 3600);

var timeString = '';

if (hours > 0) {
timeString += (0, _sprintf.sprintf)('%02d', hours) + ':';
}

timeString += (0, _sprintf.sprintf)('%02d', minutes) + ':' + (0, _sprintf.sprintf)('%02d', seconds);

return timeString;
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
}

(0, _createClass3.default)(Stopwatch, [{
key: 'componentWillMount',
value: function componentWillMount() {
var _this2 = this;

var startTime = this.props.start || new Date();
this.setState({
elapsed: this.calculateElapsedSeconds(startTime),
startTime: startTime,
timer: setInterval(function () {
_this2.setState({
elapsed: _this2.calculateElapsedSeconds(_this2.state.startTime)
});
}, 500)
});
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
clearInterval(this.state.timer);
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
'span',
{ style: this.props.style, className: this.props.className },
this.getTimeDiffString()
);
}
}]);
return Stopwatch;
}(_react2.default.Component);

Stopwatch.propTypes = {
style: _react2.default.PropTypes.object,
className: _react2.default.PropTypes.string,
start: _react2.default.PropTypes.instanceOf(Date)
};
Stopwatch.defaultProps = {
style: {}
};
exports.default = Stopwatch;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"babel-preset-react-hmre": "~1.1.1",
"babel-preset-stage-0": "~6.16.0",
"debug": "~3.1.0",
"eslint": "~3.9.1",
"eslint": "~4.18.2",
"eslint-config-airbnb": "~12.0.0",
"eslint-plugin-import": "~1.16.0",
"eslint-plugin-jsx-a11y": "~2.2.2",
Expand Down

0 comments on commit 8cd8795

Please sign in to comment.