Skip to content

Commit

Permalink
fix(lint)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tautvilas committed May 8, 2017
1 parent c431d1f commit c9a986b
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 81 deletions.
44 changes: 44 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
"env": {
"es6": true,
"node": true
},
"globals": {
"expect": true,
"it": true,
"describe": true,
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"no-unused-vars": 2,
"react/jsx-uses-vars": 2,
"react/jsx-uses-react": 2,
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Wix React Native Calendar Components",
"scripts": {
"test": "jasmine src/*.spec.js",
"lint": ":",
"lint": "eslint src/",
"build": ":",
"release": "wnpm-release"
},
Expand All @@ -26,9 +26,12 @@
"react-native": "0.44.0"
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"eslint": "^3.19.0",
"eslint-plugin-react": "^7.0.0",
"jasmine": "^2.5.2",
"react": "16.0.0-alpha.6",
"react-native": "0.44.0",
"jasmine": "^2.5.2",
"wnpm-ci": "^6.1.0"
}
}
3 changes: 1 addition & 2 deletions src/agenda/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {Component} from 'react';
import {
Image,
Text,
TouchableOpacity,
View,
Expand Down Expand Up @@ -118,7 +117,7 @@ export default class AgendaView extends Component {
selectedDay={this.state.selectedDay}
topDay={this.state.topDay}
onDayChange={this.onDayChange.bind(this)}
onScroll={(y) => {}}
onScroll={() => {}}
ref={(c) => this.list = c}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/agenda/reservation-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class ReactComp extends Component {
onScroll={this.onScroll.bind(this)}
showsVerticalScrollIndicator={false}
scrollEventThrottle={200}
onMoveShouldSetResponderCapture={(evt) => {this.onListTouch(); return false;}}
onMoveShouldSetResponderCapture={() => {this.onListTouch(); return false;}}
/>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/agenda/reservation-list/style.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {StyleSheet} from 'react-native';
import * as appStyle from '../../style';

export default StyleSheet.create({
container: {
Expand Down
2 changes: 1 addition & 1 deletion src/agenda/style.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ export default function styleConstructor(theme = {}) {
backgroundColor: appStyle.backgroundColor
},
});
};
}
2 changes: 1 addition & 1 deletion src/calendar-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CalendarList extends Component {
this.lastScrollPosition = -1000;
}

renderCalendar(row, x, y, z) {
renderCalendar(row) {
if (row.getTime) {
return (
<Calendar
Expand Down
2 changes: 1 addition & 1 deletion src/calendar/day/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Day extends Component {
state: React.PropTypes.oneOf(['selected', 'disabled', 'today', ''])
};

shouldComponentUpdate(nextProps, nextState) {
shouldComponentUpdate(nextProps) {
return ['state', 'children', 'marked', 'onPress'].reduce((prev, next) => {
if (prev || nextProps[next] !== this.props[next]) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/calendar/day/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export default function styleConstructor(theme={}) {
backgroundColor: appStyle.selectedDotColor
}
});
};
}
126 changes: 63 additions & 63 deletions src/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,79 +48,79 @@ class Calendar extends Component {
return;
}
this.setState({
currentMonth: day.clone()
}, () => {
if (!doNotTriggerListeners) {
const currMont = this.state.currentMonth.clone();
if (this.props.onMonthChange) {
this.props.onMonthChange(xdateToData(currMont));
currentMonth: day.clone()
}, () => {
if (!doNotTriggerListeners) {
const currMont = this.state.currentMonth.clone();
if (this.props.onMonthChange) {
this.props.onMonthChange(xdateToData(currMont));
}
if (this.props.onVisibleMonthsChange) {
this.props.onVisibleMonthsChange([xdateToData(currMont)]);
}
}
if (this.props.onVisibleMonthsChange) {
this.props.onVisibleMonthsChange([xdateToData(currMont)]);
}
}
});
}
});
}

pressDay(day) {
const minDate = parseDate(this.props.minDate);
if (!minDate || dateutils.isGTE(day, minDate)) {
this.updateMonth(day);
if (this.props.onDayPress) {
this.props.onDayPress(xdateToData(day));
pressDay(day) {
const minDate = parseDate(this.props.minDate);
if (!minDate || dateutils.isGTE(day, minDate)) {
this.updateMonth(day);
if (this.props.onDayPress) {
this.props.onDayPress(xdateToData(day));
}
}
}
}

addMonth(count) {
this.updateMonth(this.state.currentMonth.clone().addMonths(count, true));
}

isSelected(day) {
let selectedDays = [];
if (this.props.selected) {
selectedDays = this.props.selected;
addMonth(count) {
this.updateMonth(this.state.currentMonth.clone().addMonths(count, true));
}
for (let i = 0; i < selectedDays.length; i++) {
if (dateutils.sameDate(day, parseDate(selectedDays[i]))) {
return true;

isSelected(day) {
let selectedDays = [];
if (this.props.selected) {
selectedDays = this.props.selected;
}
for (let i = 0; i < selectedDays.length; i++) {
if (dateutils.sameDate(day, parseDate(selectedDays[i]))) {
return true;
}
}
return false;
}
return false;
}

renderDay(day, id) {
const minDate = parseDate(this.props.minDate);
let state = '';
if (this.isSelected(day)) {
state = 'selected';
} else if (minDate && !dateutils.isGTE(day, minDate)) {
state = 'disabled';
} else if (!dateutils.sameMonth(day, this.state.currentMonth)) {
state = 'disabled';
} else if (dateutils.sameDate(day, XDate())) {
state = 'today';
}
let dayComp;
if (!dateutils.sameMonth(day, this.state.currentMonth) && this.props.hideExtraDays) {
if (this.props.markingType === 'interactive') {
dayComp = (<View key={id} style={{flex: 1}}/>);
} else {
dayComp = (<View key={id} style={{width: 32}}/>);
renderDay(day, id) {
const minDate = parseDate(this.props.minDate);
let state = '';
if (this.isSelected(day)) {
state = 'selected';
} else if (minDate && !dateutils.isGTE(day, minDate)) {
state = 'disabled';
} else if (!dateutils.sameMonth(day, this.state.currentMonth)) {
state = 'disabled';
} else if (dateutils.sameDate(day, XDate())) {
state = 'today';
}
} else {
const DayComp = this.props.markingType === 'interactive' ? UnitDay : Day;
dayComp = (
<DayComp
key={id}
state={state}
theme={this.props.theme}
onPress={this.pressDay.bind(this, day)}
marked={this.getDateMarking(day)}
>
{day.getDate()}
</DayComp>
);
let dayComp;
if (!dateutils.sameMonth(day, this.state.currentMonth) && this.props.hideExtraDays) {
if (this.props.markingType === 'interactive') {
dayComp = (<View key={id} style={{flex: 1}}/>);
} else {
dayComp = (<View key={id} style={{width: 32}}/>);
}
} else {
const DayComp = this.props.markingType === 'interactive' ? UnitDay : Day;
dayComp = (
<DayComp
key={id}
state={state}
theme={this.props.theme}
onPress={this.pressDay.bind(this, day)}
marked={this.getDateMarking(day)}
>
{day.getDate()}
</DayComp>
);
}
return dayComp;
}
Expand Down
7 changes: 2 additions & 5 deletions src/calendar/unit-day/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ class Day extends Component {
state: React.PropTypes.oneOf(['selected', 'disabled', 'today', ''])
};

shouldComponentUpdate(nextProps, nextState) {
shouldComponentUpdate(nextProps) {
const newMarkingStyle = this.getDrawingStyle(nextProps.marked);

/*
if (!_.isEqual(this.markingStyle, newMarkingStyle)) {
if (JSON.stringify(this.markingStyle) !== JSON.stringify(newMarkingStyle)) {
this.markingStyle = newMarkingStyle;
return true;
}
*/
return true;

return ['state', 'children'].reduce((prev, next) => {
if (prev || nextProps[next] !== this.props[next]) {
Expand Down
2 changes: 1 addition & 1 deletion src/dateutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ module.exports = {
fromTo,
isLTE,
isGTE
}
};
2 changes: 1 addition & 1 deletion src/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function xdateToData(xdate) {
month: xdate.getMonth() + 1,
day: xdate.getDate(),
timestamp: XDate(xdate.toString('yyyy-MM-dd'), true).getTime()
}
};
}

function padNumber(n) {
Expand Down
1 change: 0 additions & 1 deletion src/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('calendar interface', () => {
it('should accept XDate as argument', () => {
const testDate = XDate('2016-11-22 00:00:00+3');
expect(testDate.toISOString()).toEqual('2016-11-21T21:00:00Z');
const date = iface.parseDate(testDate);
const time = 1479772800000;
expect(XDate(time, true).toISOString()).toEqual('2016-11-22T00:00:00Z');
});
Expand Down

0 comments on commit c9a986b

Please sign in to comment.