Skip to content

Commit c9a986b

Browse files
author
Tautvilas
committed
fix(lint)
1 parent c431d1f commit c9a986b

File tree

14 files changed

+122
-81
lines changed

14 files changed

+122
-81
lines changed

.eslintrc.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
"env": {
3+
"es6": true,
4+
"node": true
5+
},
6+
"globals": {
7+
"expect": true,
8+
"it": true,
9+
"describe": true,
10+
},
11+
"extends": "eslint:recommended",
12+
"parser": "babel-eslint",
13+
"parserOptions": {
14+
"ecmaFeatures": {
15+
"experimentalObjectRestSpread": true,
16+
"jsx": true
17+
},
18+
"sourceType": "module"
19+
},
20+
"plugins": [
21+
"react"
22+
],
23+
"rules": {
24+
"no-unused-vars": 2,
25+
"react/jsx-uses-vars": 2,
26+
"react/jsx-uses-react": 2,
27+
"indent": [
28+
"error",
29+
2
30+
],
31+
"linebreak-style": [
32+
"error",
33+
"unix"
34+
],
35+
"quotes": [
36+
"error",
37+
"single"
38+
],
39+
"semi": [
40+
"error",
41+
"always"
42+
]
43+
}
44+
};

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Wix React Native Calendar Components",
66
"scripts": {
77
"test": "jasmine src/*.spec.js",
8-
"lint": ":",
8+
"lint": "eslint src/",
99
"build": ":",
1010
"release": "wnpm-release"
1111
},
@@ -26,9 +26,12 @@
2626
"react-native": "0.44.0"
2727
},
2828
"devDependencies": {
29+
"babel-eslint": "^7.2.3",
30+
"eslint": "^3.19.0",
31+
"eslint-plugin-react": "^7.0.0",
32+
"jasmine": "^2.5.2",
2933
"react": "16.0.0-alpha.6",
3034
"react-native": "0.44.0",
31-
"jasmine": "^2.5.2",
3235
"wnpm-ci": "^6.1.0"
3336
}
3437
}

src/agenda/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, {Component} from 'react';
22
import {
3-
Image,
43
Text,
54
TouchableOpacity,
65
View,
@@ -118,7 +117,7 @@ export default class AgendaView extends Component {
118117
selectedDay={this.state.selectedDay}
119118
topDay={this.state.topDay}
120119
onDayChange={this.onDayChange.bind(this)}
121-
onScroll={(y) => {}}
120+
onScroll={() => {}}
122121
ref={(c) => this.list = c}
123122
/>
124123
);

src/agenda/reservation-list/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class ReactComp extends Component {
206206
onScroll={this.onScroll.bind(this)}
207207
showsVerticalScrollIndicator={false}
208208
scrollEventThrottle={200}
209-
onMoveShouldSetResponderCapture={(evt) => {this.onListTouch(); return false;}}
209+
onMoveShouldSetResponderCapture={() => {this.onListTouch(); return false;}}
210210
/>
211211
);
212212
}

src/agenda/reservation-list/style.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {StyleSheet} from 'react-native';
2-
import * as appStyle from '../../style';
32

43
export default StyleSheet.create({
54
container: {

src/agenda/style.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ export default function styleConstructor(theme = {}) {
5454
backgroundColor: appStyle.backgroundColor
5555
},
5656
});
57-
};
57+
}

src/calendar-list/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CalendarList extends Component {
4545
this.lastScrollPosition = -1000;
4646
}
4747

48-
renderCalendar(row, x, y, z) {
48+
renderCalendar(row) {
4949
if (row.getTime) {
5050
return (
5151
<Calendar

src/calendar/day/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Day extends Component {
1818
state: React.PropTypes.oneOf(['selected', 'disabled', 'today', ''])
1919
};
2020

21-
shouldComponentUpdate(nextProps, nextState) {
21+
shouldComponentUpdate(nextProps) {
2222
return ['state', 'children', 'marked', 'onPress'].reduce((prev, next) => {
2323
if (prev || nextProps[next] !== this.props[next]) {
2424
return true;

src/calendar/day/style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ export default function styleConstructor(theme={}) {
4444
backgroundColor: appStyle.selectedDotColor
4545
}
4646
});
47-
};
47+
}

src/calendar/index.js

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -48,79 +48,79 @@ class Calendar extends Component {
4848
return;
4949
}
5050
this.setState({
51-
currentMonth: day.clone()
52-
}, () => {
53-
if (!doNotTriggerListeners) {
54-
const currMont = this.state.currentMonth.clone();
55-
if (this.props.onMonthChange) {
56-
this.props.onMonthChange(xdateToData(currMont));
51+
currentMonth: day.clone()
52+
}, () => {
53+
if (!doNotTriggerListeners) {
54+
const currMont = this.state.currentMonth.clone();
55+
if (this.props.onMonthChange) {
56+
this.props.onMonthChange(xdateToData(currMont));
57+
}
58+
if (this.props.onVisibleMonthsChange) {
59+
this.props.onVisibleMonthsChange([xdateToData(currMont)]);
60+
}
5761
}
58-
if (this.props.onVisibleMonthsChange) {
59-
this.props.onVisibleMonthsChange([xdateToData(currMont)]);
60-
}
61-
}
62-
});
63-
}
62+
});
63+
}
6464

65-
pressDay(day) {
66-
const minDate = parseDate(this.props.minDate);
67-
if (!minDate || dateutils.isGTE(day, minDate)) {
68-
this.updateMonth(day);
69-
if (this.props.onDayPress) {
70-
this.props.onDayPress(xdateToData(day));
65+
pressDay(day) {
66+
const minDate = parseDate(this.props.minDate);
67+
if (!minDate || dateutils.isGTE(day, minDate)) {
68+
this.updateMonth(day);
69+
if (this.props.onDayPress) {
70+
this.props.onDayPress(xdateToData(day));
71+
}
7172
}
7273
}
73-
}
74-
75-
addMonth(count) {
76-
this.updateMonth(this.state.currentMonth.clone().addMonths(count, true));
77-
}
7874

79-
isSelected(day) {
80-
let selectedDays = [];
81-
if (this.props.selected) {
82-
selectedDays = this.props.selected;
75+
addMonth(count) {
76+
this.updateMonth(this.state.currentMonth.clone().addMonths(count, true));
8377
}
84-
for (let i = 0; i < selectedDays.length; i++) {
85-
if (dateutils.sameDate(day, parseDate(selectedDays[i]))) {
86-
return true;
78+
79+
isSelected(day) {
80+
let selectedDays = [];
81+
if (this.props.selected) {
82+
selectedDays = this.props.selected;
8783
}
84+
for (let i = 0; i < selectedDays.length; i++) {
85+
if (dateutils.sameDate(day, parseDate(selectedDays[i]))) {
86+
return true;
87+
}
88+
}
89+
return false;
8890
}
89-
return false;
90-
}
9191

92-
renderDay(day, id) {
93-
const minDate = parseDate(this.props.minDate);
94-
let state = '';
95-
if (this.isSelected(day)) {
96-
state = 'selected';
97-
} else if (minDate && !dateutils.isGTE(day, minDate)) {
98-
state = 'disabled';
99-
} else if (!dateutils.sameMonth(day, this.state.currentMonth)) {
100-
state = 'disabled';
101-
} else if (dateutils.sameDate(day, XDate())) {
102-
state = 'today';
103-
}
104-
let dayComp;
105-
if (!dateutils.sameMonth(day, this.state.currentMonth) && this.props.hideExtraDays) {
106-
if (this.props.markingType === 'interactive') {
107-
dayComp = (<View key={id} style={{flex: 1}}/>);
108-
} else {
109-
dayComp = (<View key={id} style={{width: 32}}/>);
92+
renderDay(day, id) {
93+
const minDate = parseDate(this.props.minDate);
94+
let state = '';
95+
if (this.isSelected(day)) {
96+
state = 'selected';
97+
} else if (minDate && !dateutils.isGTE(day, minDate)) {
98+
state = 'disabled';
99+
} else if (!dateutils.sameMonth(day, this.state.currentMonth)) {
100+
state = 'disabled';
101+
} else if (dateutils.sameDate(day, XDate())) {
102+
state = 'today';
110103
}
111-
} else {
112-
const DayComp = this.props.markingType === 'interactive' ? UnitDay : Day;
113-
dayComp = (
114-
<DayComp
115-
key={id}
116-
state={state}
117-
theme={this.props.theme}
118-
onPress={this.pressDay.bind(this, day)}
119-
marked={this.getDateMarking(day)}
120-
>
121-
{day.getDate()}
122-
</DayComp>
123-
);
104+
let dayComp;
105+
if (!dateutils.sameMonth(day, this.state.currentMonth) && this.props.hideExtraDays) {
106+
if (this.props.markingType === 'interactive') {
107+
dayComp = (<View key={id} style={{flex: 1}}/>);
108+
} else {
109+
dayComp = (<View key={id} style={{width: 32}}/>);
110+
}
111+
} else {
112+
const DayComp = this.props.markingType === 'interactive' ? UnitDay : Day;
113+
dayComp = (
114+
<DayComp
115+
key={id}
116+
state={state}
117+
theme={this.props.theme}
118+
onPress={this.pressDay.bind(this, day)}
119+
marked={this.getDateMarking(day)}
120+
>
121+
{day.getDate()}
122+
</DayComp>
123+
);
124124
}
125125
return dayComp;
126126
}

src/calendar/unit-day/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ class Day extends Component {
1818
state: React.PropTypes.oneOf(['selected', 'disabled', 'today', ''])
1919
};
2020

21-
shouldComponentUpdate(nextProps, nextState) {
21+
shouldComponentUpdate(nextProps) {
2222
const newMarkingStyle = this.getDrawingStyle(nextProps.marked);
2323

24-
/*
25-
if (!_.isEqual(this.markingStyle, newMarkingStyle)) {
24+
if (JSON.stringify(this.markingStyle) !== JSON.stringify(newMarkingStyle)) {
2625
this.markingStyle = newMarkingStyle;
2726
return true;
2827
}
29-
*/
30-
return true;
3128

3229
return ['state', 'children'].reduce((prev, next) => {
3330
if (prev || nextProps[next] !== this.props[next]) {

src/dateutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ module.exports = {
7878
fromTo,
7979
isLTE,
8080
isGTE
81-
}
81+
};

src/interface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function xdateToData(xdate) {
66
month: xdate.getMonth() + 1,
77
day: xdate.getDate(),
88
timestamp: XDate(xdate.toString('yyyy-MM-dd'), true).getTime()
9-
}
9+
};
1010
}
1111

1212
function padNumber(n) {

src/interface.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ describe('calendar interface', () => {
2929
it('should accept XDate as argument', () => {
3030
const testDate = XDate('2016-11-22 00:00:00+3');
3131
expect(testDate.toISOString()).toEqual('2016-11-21T21:00:00Z');
32-
const date = iface.parseDate(testDate);
3332
const time = 1479772800000;
3433
expect(XDate(time, true).toISOString()).toEqual('2016-11-22T00:00:00Z');
3534
});

0 commit comments

Comments
 (0)