Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESLint and fix a number of linting violations #501

Merged
merged 4 commits into from
Aug 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should already be gitignored, and as such, eslint should already ignore it - why is this needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing, without ignoring this, eslint . takes significantly longer.

13 changes: 13 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"prefer-object-spread"
],
"rules": {
"prefer-object-spread/prefer-object-spread": 2,
"react/jsx-filename-extension": 0,
"no-use-before-define": 0,
"no-underscore-dangle": 0
}
}
30 changes: 15 additions & 15 deletions components/AnimatedRegion.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
class AnimatedRegion extends AnimatedWithChildren {
//latitude: AnimatedValue;
//longitude: AnimatedValue;
//latitudeDelta: AnimatedValue;
//longitudeDelta: AnimatedValue;
//_listeners: {[key: string]: {
// latitude: AnimatedValue;
// longitude: AnimatedValue;
// latitudeDelta: AnimatedValue;
// longitudeDelta: AnimatedValue;
// _listeners: {[key: string]: {
// latitude: string,
// longitude: string,
// latitudeDelta: string;
// longitudeDelta: string,
//}};
// }};

constructor(valueIn) {
super();
var value = valueIn || { // probably want to come up with better defaults
const value = valueIn || { // probably want to come up with better defaults
latitude: 0,
longitude: 0,
latitudeDelta: 0,
Expand All @@ -34,10 +34,10 @@ class AnimatedRegion extends AnimatedWithChildren {
}

setValue(value) {
//this.latitude.setValue(value.latitude);
//this.longitude.setValue(value.longitude);
//this.latitudeDelta.setValue(value.latitudeDelta);
//this.longitudeDelta.setValue(value.longitudeDelta);
// this.latitude.setValue(value.latitude);
// this.longitude.setValue(value.longitude);
// this.latitudeDelta.setValue(value.latitudeDelta);
// this.longitudeDelta.setValue(value.longitudeDelta);
this.latitude._value = value.latitude;
this.longitude._value = value.longitude;
this.latitudeDelta._value = value.latitudeDelta;
Expand Down Expand Up @@ -90,8 +90,8 @@ class AnimatedRegion extends AnimatedWithChildren {
}

addListener(callback) {
var id = String(_uniqueId++);
var jointCallback = ({value: number}) => {
const id = String(_uniqueId++);
const jointCallback = ({ value: number }) => {
callback(this.__getValue());
};
this._listeners[id] = {
Expand All @@ -112,7 +112,7 @@ class AnimatedRegion extends AnimatedWithChildren {
}

spring(config) {
var animations = [];
const animations = [];
config.hasOwnProperty('latitude') &&
animations.push(timing(this.latitude, {
...config,
Expand Down Expand Up @@ -141,7 +141,7 @@ class AnimatedRegion extends AnimatedWithChildren {
}

timing(config) {
var animations = [];
const animations = [];
config.hasOwnProperty('latitude') &&
animations.push(timing(this.latitude, {
...config,
Expand Down
25 changes: 9 additions & 16 deletions components/MapCallout.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@

var React = require('react');
var {
PropTypes,
} = React;

var ReactNative = require('react-native');
var {
import React, { PropTypes } from 'react';
import {
View,
NativeMethodsMixin,
requireNativeComponent,
StyleSheet,
} = ReactNative;
} from 'react-native';

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

propTypes: {
Expand All @@ -21,25 +16,23 @@ var MapCallout = React.createClass({
onPress: PropTypes.func,
},

getDefaultProps: function() {
getDefaultProps() {
return {
tooltip: false,
};
},

render: function() {
render() {
return <AIRMapCallout {...this.props} style={[styles.callout, this.props.style]} />;
},
});

var styles = StyleSheet.create({
const styles = StyleSheet.create({
callout: {
position: 'absolute',
//flex: 0,
//backgroundColor: 'transparent',
},
});

var AIRMapCallout = requireNativeComponent('AIRMapCallout', MapCallout);
const AIRMapCallout = requireNativeComponent('AIRMapCallout', MapCallout);

module.exports = MapCallout;
28 changes: 12 additions & 16 deletions components/MapCircle.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@

var React = require('react');
var {
PropTypes,
} = React;

var ReactNative = require('react-native');
var {
import React, { PropTypes } from 'react';
import {
View,
NativeMethodsMixin,
requireNativeComponent,
StyleSheet,
} = ReactNative;
} from 'react-native';

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

propTypes: {
Expand Down Expand Up @@ -127,18 +121,20 @@ var MapCircle = React.createClass({
lineDashPattern: PropTypes.arrayOf(PropTypes.number),
},

getDefaultProps: function() {
getDefaultProps() {
return {
strokeColor: '#000',
strokeWidth: 1,
};
},

_onPress: function(e) {
this.props.onPress && this.props.onPress(e);
_onPress(e) {
if (this.props.onPress) {
this.props.onPress(e);
}
},

render: function() {
render() {
return (
<AIRMapCircle
{...this.props}
Expand All @@ -148,6 +144,6 @@ var MapCircle = React.createClass({
},
});

var AIRMapCircle = requireNativeComponent('AIRMapCircle', MapCircle);
const AIRMapCircle = requireNativeComponent('AIRMapCircle', MapCircle);

module.exports = MapCircle;
43 changes: 20 additions & 23 deletions components/MapMarker.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
'use strict';

var React = require('react');
var {
PropTypes,
} = React;

var ReactNative = require('react-native');
var {
import React, { PropTypes } from 'react';
import {
View,
NativeMethodsMixin,
requireNativeComponent,
StyleSheet,
Platform,
NativeModules,
Animated,
} = ReactNative;
findNodeHandle,
} from 'react-native';

var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this not be an import?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I still need to do that for each of the files.


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

viewConfig: {
Expand Down Expand Up @@ -208,19 +203,19 @@ var MapMarker = React.createClass({

},

showCallout: function() {
showCallout() {
this._runCommand('showCallout', []);
},

hideCallout: function() {
hideCallout() {
this._runCommand('hideCallout', []);
},

_getHandle: function() {
return ReactNative.findNodeHandle(this.refs.marker);
_getHandle() {
return findNodeHandle(this.refs.marker);
},

_runCommand: function (name, args) {
_runCommand(name, args) {
switch (Platform.OS) {
case 'android':
NativeModules.UIManager.dispatchViewManagerCommand(
Expand All @@ -239,12 +234,14 @@ var MapMarker = React.createClass({
}
},

_onPress: function(e) {
this.props.onPress && this.props.onPress(e);
_onPress(e) {
if (this.props.onPress) {
this.props.onPress(e);
}
},

render: function() {
var image = undefined;
render() {
let image;
if (this.props.image) {
image = resolveAssetSource(this.props.image) || {};
image = image.uri;
Expand All @@ -262,14 +259,14 @@ var MapMarker = React.createClass({
},
});

var styles = StyleSheet.create({
const styles = StyleSheet.create({
marker: {
position: 'absolute',
backgroundColor: 'transparent',
},
});

var AIRMapMarker = requireNativeComponent('AIRMapMarker', MapMarker);
const AIRMapMarker = requireNativeComponent('AIRMapMarker', MapMarker);

MapMarker.Animated = Animated.createAnimatedComponent(MapMarker);

Expand Down
35 changes: 12 additions & 23 deletions components/MapPolygon.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
var React = require('react');
var {
PropTypes,
} = React;

var ReactNative = require('react-native');
var {
import React, { PropTypes } from 'react';
import {
View,
NativeMethodsMixin,
requireNativeComponent,
StyleSheet,
} = ReactNative;
} from 'react-native';

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

propTypes: {
Expand Down Expand Up @@ -131,18 +126,20 @@ var MapPolygon = React.createClass({
lineDashPattern: PropTypes.arrayOf(PropTypes.number),
},

getDefaultProps: function() {
getDefaultProps() {
return {
strokeColor: '#000',
strokeWidth: 1,
};
},

_onPress: function(e) {
this.props.onPress && this.props.onPress(e);
_onPress(e) {
if (this.props.onPress) {
this.props.onPress(e);
}
},

render: function() {
render() {
return (
<AIRMapPolygon
{...this.props}
Expand All @@ -152,14 +149,6 @@ var MapPolygon = React.createClass({
},
});

var styles = StyleSheet.create({
polyline: {
position: 'absolute',
width: 0,
height: 0,
},
});

var AIRMapPolygon = requireNativeComponent('AIRMapPolygon', MapPolygon);
const AIRMapPolygon = requireNativeComponent('AIRMapPolygon', MapPolygon);

module.exports = MapPolygon;
Loading