Skip to content

Commit 241c5ac

Browse files
author
Spike Brehm
authored
Merge pull request #501 from spikebrehm/add-eslint
Add ESLint and fix a number of linting violations
2 parents 08b3bcb + 9ffe3a2 commit 241c5ac

36 files changed

+2013
-2033
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": "airbnb",
4+
"plugins": [
5+
"prefer-object-spread"
6+
],
7+
"rules": {
8+
"prefer-object-spread/prefer-object-spread": 2,
9+
"react/jsx-filename-extension": 0,
10+
"no-use-before-define": 0,
11+
"no-underscore-dangle": 0
12+
}
13+
}

components/AnimatedRegion.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
class AnimatedRegion extends AnimatedWithChildren {
2-
//latitude: AnimatedValue;
3-
//longitude: AnimatedValue;
4-
//latitudeDelta: AnimatedValue;
5-
//longitudeDelta: AnimatedValue;
6-
//_listeners: {[key: string]: {
2+
// latitude: AnimatedValue;
3+
// longitude: AnimatedValue;
4+
// latitudeDelta: AnimatedValue;
5+
// longitudeDelta: AnimatedValue;
6+
// _listeners: {[key: string]: {
77
// latitude: string,
88
// longitude: string,
99
// latitudeDelta: string;
1010
// longitudeDelta: string,
11-
//}};
11+
// }};
1212

1313
constructor(valueIn) {
1414
super();
15-
var value = valueIn || { // probably want to come up with better defaults
15+
const value = valueIn || { // probably want to come up with better defaults
1616
latitude: 0,
1717
longitude: 0,
1818
latitudeDelta: 0,
@@ -34,10 +34,10 @@ class AnimatedRegion extends AnimatedWithChildren {
3434
}
3535

3636
setValue(value) {
37-
//this.latitude.setValue(value.latitude);
38-
//this.longitude.setValue(value.longitude);
39-
//this.latitudeDelta.setValue(value.latitudeDelta);
40-
//this.longitudeDelta.setValue(value.longitudeDelta);
37+
// this.latitude.setValue(value.latitude);
38+
// this.longitude.setValue(value.longitude);
39+
// this.latitudeDelta.setValue(value.latitudeDelta);
40+
// this.longitudeDelta.setValue(value.longitudeDelta);
4141
this.latitude._value = value.latitude;
4242
this.longitude._value = value.longitude;
4343
this.latitudeDelta._value = value.latitudeDelta;
@@ -90,8 +90,8 @@ class AnimatedRegion extends AnimatedWithChildren {
9090
}
9191

9292
addListener(callback) {
93-
var id = String(_uniqueId++);
94-
var jointCallback = ({value: number}) => {
93+
const id = String(_uniqueId++);
94+
const jointCallback = ({ value: number }) => {
9595
callback(this.__getValue());
9696
};
9797
this._listeners[id] = {
@@ -112,7 +112,7 @@ class AnimatedRegion extends AnimatedWithChildren {
112112
}
113113

114114
spring(config) {
115-
var animations = [];
115+
const animations = [];
116116
config.hasOwnProperty('latitude') &&
117117
animations.push(timing(this.latitude, {
118118
...config,
@@ -141,7 +141,7 @@ class AnimatedRegion extends AnimatedWithChildren {
141141
}
142142

143143
timing(config) {
144-
var animations = [];
144+
const animations = [];
145145
config.hasOwnProperty('latitude') &&
146146
animations.push(timing(this.latitude, {
147147
...config,

components/MapCallout.js

+9-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
2-
var React = require('react');
3-
var {
4-
PropTypes,
5-
} = React;
6-
7-
var ReactNative = require('react-native');
8-
var {
1+
import React, { PropTypes } from 'react';
2+
import {
93
View,
104
NativeMethodsMixin,
115
requireNativeComponent,
126
StyleSheet,
13-
} = ReactNative;
7+
} from 'react-native';
148

15-
var MapCallout = React.createClass({
9+
// eslint-disable-next-line react/prefer-es6-class
10+
const MapCallout = React.createClass({
1611
mixins: [NativeMethodsMixin],
1712

1813
propTypes: {
@@ -21,25 +16,23 @@ var MapCallout = React.createClass({
2116
onPress: PropTypes.func,
2217
},
2318

24-
getDefaultProps: function() {
19+
getDefaultProps() {
2520
return {
2621
tooltip: false,
2722
};
2823
},
2924

30-
render: function() {
25+
render() {
3126
return <AIRMapCallout {...this.props} style={[styles.callout, this.props.style]} />;
3227
},
3328
});
3429

35-
var styles = StyleSheet.create({
30+
const styles = StyleSheet.create({
3631
callout: {
3732
position: 'absolute',
38-
//flex: 0,
39-
//backgroundColor: 'transparent',
4033
},
4134
});
4235

43-
var AIRMapCallout = requireNativeComponent('AIRMapCallout', MapCallout);
36+
const AIRMapCallout = requireNativeComponent('AIRMapCallout', MapCallout);
4437

4538
module.exports = MapCallout;

components/MapCircle.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
2-
var React = require('react');
3-
var {
4-
PropTypes,
5-
} = React;
6-
7-
var ReactNative = require('react-native');
8-
var {
1+
import React, { PropTypes } from 'react';
2+
import {
93
View,
104
NativeMethodsMixin,
115
requireNativeComponent,
12-
StyleSheet,
13-
} = ReactNative;
6+
} from 'react-native';
147

15-
var MapCircle = React.createClass({
8+
// eslint-disable-next-line react/prefer-es6-class
9+
const MapCircle = React.createClass({
1610
mixins: [NativeMethodsMixin],
1711

1812
propTypes: {
@@ -127,18 +121,20 @@ var MapCircle = React.createClass({
127121
lineDashPattern: PropTypes.arrayOf(PropTypes.number),
128122
},
129123

130-
getDefaultProps: function() {
124+
getDefaultProps() {
131125
return {
132126
strokeColor: '#000',
133127
strokeWidth: 1,
134128
};
135129
},
136130

137-
_onPress: function(e) {
138-
this.props.onPress && this.props.onPress(e);
131+
_onPress(e) {
132+
if (this.props.onPress) {
133+
this.props.onPress(e);
134+
}
139135
},
140136

141-
render: function() {
137+
render() {
142138
return (
143139
<AIRMapCircle
144140
{...this.props}
@@ -148,6 +144,6 @@ var MapCircle = React.createClass({
148144
},
149145
});
150146

151-
var AIRMapCircle = requireNativeComponent('AIRMapCircle', MapCircle);
147+
const AIRMapCircle = requireNativeComponent('AIRMapCircle', MapCircle);
152148

153149
module.exports = MapCircle;

components/MapMarker.js

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
'use strict';
2-
3-
var React = require('react');
4-
var {
5-
PropTypes,
6-
} = React;
7-
8-
var ReactNative = require('react-native');
9-
var {
1+
import React, { PropTypes } from 'react';
2+
import {
103
View,
114
NativeMethodsMixin,
125
requireNativeComponent,
136
StyleSheet,
147
Platform,
158
NativeModules,
169
Animated,
17-
} = ReactNative;
10+
findNodeHandle,
11+
} from 'react-native';
1812

19-
var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
13+
const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
2014

21-
var MapMarker = React.createClass({
15+
// eslint-disable-next-line react/prefer-es6-class
16+
const MapMarker = React.createClass({
2217
mixins: [NativeMethodsMixin],
2318

2419
viewConfig: {
@@ -208,19 +203,19 @@ var MapMarker = React.createClass({
208203

209204
},
210205

211-
showCallout: function() {
206+
showCallout() {
212207
this._runCommand('showCallout', []);
213208
},
214209

215-
hideCallout: function() {
210+
hideCallout() {
216211
this._runCommand('hideCallout', []);
217212
},
218213

219-
_getHandle: function() {
220-
return ReactNative.findNodeHandle(this.refs.marker);
214+
_getHandle() {
215+
return findNodeHandle(this.refs.marker);
221216
},
222217

223-
_runCommand: function (name, args) {
218+
_runCommand(name, args) {
224219
switch (Platform.OS) {
225220
case 'android':
226221
NativeModules.UIManager.dispatchViewManagerCommand(
@@ -239,12 +234,14 @@ var MapMarker = React.createClass({
239234
}
240235
},
241236

242-
_onPress: function(e) {
243-
this.props.onPress && this.props.onPress(e);
237+
_onPress(e) {
238+
if (this.props.onPress) {
239+
this.props.onPress(e);
240+
}
244241
},
245242

246-
render: function() {
247-
var image = undefined;
243+
render() {
244+
let image;
248245
if (this.props.image) {
249246
image = resolveAssetSource(this.props.image) || {};
250247
image = image.uri;
@@ -262,14 +259,14 @@ var MapMarker = React.createClass({
262259
},
263260
});
264261

265-
var styles = StyleSheet.create({
262+
const styles = StyleSheet.create({
266263
marker: {
267264
position: 'absolute',
268265
backgroundColor: 'transparent',
269266
},
270267
});
271268

272-
var AIRMapMarker = requireNativeComponent('AIRMapMarker', MapMarker);
269+
const AIRMapMarker = requireNativeComponent('AIRMapMarker', MapMarker);
273270

274271
MapMarker.Animated = Animated.createAnimatedComponent(MapMarker);
275272

components/MapPolygon.js

+12-23
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
var React = require('react');
2-
var {
3-
PropTypes,
4-
} = React;
5-
6-
var ReactNative = require('react-native');
7-
var {
1+
import React, { PropTypes } from 'react';
2+
import {
83
View,
94
NativeMethodsMixin,
105
requireNativeComponent,
11-
StyleSheet,
12-
} = ReactNative;
6+
} from 'react-native';
137

14-
var MapPolygon = React.createClass({
8+
// eslint-disable-next-line react/prefer-es6-class
9+
const MapPolygon = React.createClass({
1510
mixins: [NativeMethodsMixin],
1611

1712
propTypes: {
@@ -131,18 +126,20 @@ var MapPolygon = React.createClass({
131126
lineDashPattern: PropTypes.arrayOf(PropTypes.number),
132127
},
133128

134-
getDefaultProps: function() {
129+
getDefaultProps() {
135130
return {
136131
strokeColor: '#000',
137132
strokeWidth: 1,
138133
};
139134
},
140135

141-
_onPress: function(e) {
142-
this.props.onPress && this.props.onPress(e);
136+
_onPress(e) {
137+
if (this.props.onPress) {
138+
this.props.onPress(e);
139+
}
143140
},
144141

145-
render: function() {
142+
render() {
146143
return (
147144
<AIRMapPolygon
148145
{...this.props}
@@ -152,14 +149,6 @@ var MapPolygon = React.createClass({
152149
},
153150
});
154151

155-
var styles = StyleSheet.create({
156-
polyline: {
157-
position: 'absolute',
158-
width: 0,
159-
height: 0,
160-
},
161-
});
162-
163-
var AIRMapPolygon = requireNativeComponent('AIRMapPolygon', MapPolygon);
152+
const AIRMapPolygon = requireNativeComponent('AIRMapPolygon', MapPolygon);
164153

165154
module.exports = MapPolygon;

0 commit comments

Comments
 (0)