Skip to content

Commit

Permalink
fix(src): eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchentw committed May 30, 2016
1 parent 89f7d12 commit f2b242a
Show file tree
Hide file tree
Showing 40 changed files with 404 additions and 202 deletions.
3 changes: 2 additions & 1 deletion src/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default class Circle extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Circle
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getBounds() { return this.state.circle.getBounds(); }

getCenter() { return this.state.circle.getCenter(); }
Expand Down
8 changes: 6 additions & 2 deletions src/DirectionsRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default class DirectionsRenderer extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DirectionsRenderer
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getDirections() { return this.state.directionsRenderer.getDirections(); }

getPanel() { return this.state.directionsRenderer.getPanel(); }
Expand Down Expand Up @@ -69,7 +70,10 @@ export default class DirectionsRenderer extends Component {
render() {
if (this.state.directionsRenderer) {
return (
<DirectionsRendererCreator directionsRenderer={this.state.directionsRenderer} {...this.props}>
<DirectionsRendererCreator
directionsRenderer={this.state.directionsRenderer}
{...this.props}
>
{this.props.children}
</DirectionsRendererCreator>
);
Expand Down
8 changes: 6 additions & 2 deletions src/DrawingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default class DrawingManager extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DrawingManager
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getDrawingMode() { return this.state.drawingManager.getDrawingMode(); }
// END - Public APIs
//
Expand All @@ -65,7 +66,10 @@ export default class DrawingManager extends Component {
render() {
if (this.state.drawingManager) {
return (
<DrawingManagerCreator drawingManager={this.state.drawingManager} {...this.props}>
<DrawingManagerCreator
drawingManager={this.state.drawingManager}
{...this.props}
>
{this.props.children}
</DrawingManagerCreator>
);
Expand Down
23 changes: 16 additions & 7 deletions src/GoogleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default class GoogleMap extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
getBounds() { return (this.props.map || this.refs.delegate).getBounds(); }

getCenter() { return (this.props.map || this.refs.delegate).getCenter(); }
Expand All @@ -65,14 +66,17 @@ export default class GoogleMap extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return !it.match(/^get/) && !it.match(/^set/) && !it.match(/Map$/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return !it.match(/^get/) && !it.match(/^set/) && !it.match(/Map$/); })
fitBounds(bounds) { return (this.props.map || this.refs.delegate).fitBounds(bounds); }

panBy(x, y) { return (this.props.map || this.refs.delegate).panBy(x, y); }

panTo(latLng) { return (this.props.map || this.refs.delegate).panTo(latLng); }

panToBounds(latLngBounds) { return (this.props.map || this.refs.delegate).panToBounds(latLngBounds); }
panToBounds(latLngBounds) {
return (this.props.map || this.refs.delegate).panToBounds(latLngBounds);
}
// END - Public APIs - Use this carefully
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map
Expand All @@ -82,8 +86,9 @@ export default class GoogleMap extends Component {
const isUsingNewBehavior = USE_NEW_BEHAVIOR_TAG_NAME === containerTagName;

warning(isUsingNewBehavior,
`"GoogleMap" with containerTagName is deprecated now and will be removed in next major release (5.0.0).
Use "GoogleMapLoader" instead. See https://github.com/tomchentw/react-google-maps/pull/157 for more details.`
`"GoogleMap" with containerTagName is deprecated now and will be removed in
next major release (5.0.0). Use "GoogleMapLoader" instead.
See https://github.com/tomchentw/react-google-maps/pull/157 for more details.`
);
}

Expand All @@ -97,8 +102,12 @@ Use "GoogleMapLoader" instead. See https://github.com/tomchentw/react-google-map
{children}
</GoogleMapHolder>
);
} else {// ------------ Deprecated ------------
const realContainerTagName = (containerTagName === undefined || containerTagName === null) ? `div` : containerTagName;
} else { // ------------ Deprecated ------------
const realContainerTagName = (
(containerTagName === undefined || containerTagName === null)
? `div`
: containerTagName
);

return (
<GoogleMapLoader
Expand Down
11 changes: 8 additions & 3 deletions src/GoogleMapLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const USE_NEW_BEHAVIOR_TAG_NAME = `__new_behavior__`;/* CIRCULAR_DEPENDENCY */
export default class GoogleMapLoader extends Component {
static propTypes = {
containerElement: PropTypes.node.isRequired,
googleMapElement: PropTypes.element.isRequired, /* CIRCULAR_DEPENDENCY. Uncomment when 5.0.0 comes: propTypesElementOfType(GoogleMap).isRequired, */
/* CIRCULAR_DEPENDENCY. Uncomment when 5.0.0 comes:
propTypesElementOfType(GoogleMap).isRequired, */
googleMapElement: PropTypes.element.isRequired,
};

static defaultProps = {
Expand All @@ -28,12 +30,15 @@ export default class GoogleMapLoader extends Component {
if (this.state.map || domEl === null) {
return;
}
const { children, ...mapProps } = this.props.googleMapElement.props;
const {
children, // eslint-disable-line no-unused-vars
...restProps,
} = this.props.googleMapElement.props;
//
// Create google.maps.Map instance so that dom is initialized before
// React's children creators.
//
const map = GoogleMapHolder._createMap(domEl, mapProps);
const map = GoogleMapHolder._createMap(domEl, restProps);
this.setState({ map });
}

Expand Down
3 changes: 2 additions & 1 deletion src/InfoWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default class InfoWindow extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#InfoWindow
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getContent() { /* TODO: children */ }

getPosition() { return this.state.infoWindow.getPosition(); }
Expand Down
3 changes: 2 additions & 1 deletion src/KmlLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default class KmlLayer extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#KmlLayer
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
getDefaultViewport() { return this.state.kmlLayer.getDefaultViewport(); }

getMetadata() { return this.state.kmlLayer.getMetadata(); }
Expand Down
3 changes: 2 additions & 1 deletion src/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default class Marker extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Marker
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
getAnimation() { return this.state.marker.getAnimation(); }

getAttribution() { return this.state.marker.getAttribution(); }
Expand Down
8 changes: 6 additions & 2 deletions src/OverlayView.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default class OverlayView extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#OverlayView
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getPanes() { return this.state.overlayView.getPanes(); }

getProjection() { return this.state.overlayView.getProjection(); }
Expand All @@ -71,7 +72,10 @@ export default class OverlayView extends Component {
const { mapHolderRef } = this.context;
if (this.state.overlayView) {
return (
<OverlayViewCreator mapHolderRef={mapHolderRef} overlayView={this.state.overlayView} {...this.props}>
<OverlayViewCreator
mapHolderRef={mapHolderRef}
overlayView={this.state.overlayView} {...this.props}
>
{this.props.children}
</OverlayViewCreator>
);
Expand Down
3 changes: 2 additions & 1 deletion src/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default class Polygon extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polygon
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getDraggable() { return this.state.polygon.getDraggable(); }

getEditable() { return this.state.polygon.getEditable(); }
Expand Down
3 changes: 2 additions & 1 deletion src/Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default class Polyline extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getDraggable() { return this.state.polyline.getDraggable(); }

getEditable() { return this.state.polyline.getEditable(); }
Expand Down
3 changes: 2 additions & 1 deletion src/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default class Rectangle extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Rectangle
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getBounds() { return this.state.rectangle.getBounds(); }

getDraggable() { return this.state.rectangle.getDraggable(); }
Expand Down
25 changes: 16 additions & 9 deletions src/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default class SearchBox extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#SearchBox
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
getBounds() { return this.state.searchBox.getBounds(); }

getPlaces() { return this.state.searchBox.getPlaces(); }
Expand All @@ -55,20 +56,20 @@ export default class SearchBox extends Component {
}
const { classes, style, placeholder, ...searchBoxProps } = this.props;

// Cannot create input via component - Google Maps will mess with React's internal state by detaching/attaching.
// Cannot create input via component - Google Maps will mess with React's internal state
// by detaching/attaching.
// Allow developers to style the "hidden element" via inputClasses.
const domEl = document.createElement(`input`);
domEl.className = classes;
domEl.type = `text`;
domEl.placeholder = placeholder;

for (const propKey in style) {
if (style.hasOwnProperty(propKey)) {
domEl.style[propKey] = style[propKey];
}
}
Object.assign(domEl.style, style);

const searchBox = SearchBoxCreator._createSearchBox(domEl, searchBoxProps);
const searchBox = SearchBoxCreator._createSearchBox(
domEl,
searchBoxProps
);

this.setState({
inputElement: domEl,
Expand All @@ -81,7 +82,13 @@ export default class SearchBox extends Component {
const { mapHolderRef } = this.context;

return this.state.searchBox ? (
<SearchBoxCreator controlPosition={controlPosition} inputElement={this.state.inputElement} mapHolderRef={mapHolderRef} searchBox={this.state.searchBox} {...this.props}>
<SearchBoxCreator
controlPosition={controlPosition}
inputElement={this.state.inputElement}
mapHolderRef={mapHolderRef}
searchBox={this.state.searchBox}
{...this.props}
>
{this.props.children}
</SearchBoxCreator>
) : (<noscript />);
Expand Down
5 changes: 3 additions & 2 deletions src/_Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
skeletonDefaultPropTypes,
skeletonControlledPropTypes,
skeletonEventPropTypes,
} from "./creators/SkeletonCreator";
} from "./creators/_SkeletonCreator";

import GoogleMapHolder from "./creators/GoogleMapHolder";

Expand All @@ -35,7 +35,8 @@ export default class Skeleton extends Component {
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; })
// .filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getAnimation() { return this.state.skeleton.getAnimation(); }
// END - Public APIs
//
Expand Down
2 changes: 2 additions & 0 deletions src/__mocks__/google.maps.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as event from "./google.maps.event.mock";

export class Map {
constructor(domEl, options) {
this.domEl = domEl;
this.options = options;
}

setOptions(nextOptions) {
Expand Down
27 changes: 18 additions & 9 deletions src/addons/MarkerClusterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,21 @@ export default class MarkerClusterer extends Component {
getZoomOnClick() { return this.state.markerClusterer.getZoomOnClick(); }

// Public APIs - Use this carefully
addMarker(marker, nodraw = false) { return this.state.markerClusterer.addMarker(marker, nodraw); }
addMarker(marker, nodraw = false) {
return this.state.markerClusterer.addMarker(marker, nodraw);
}

addMarkers(markers, nodraw = false) { return this.state.markerClusterer.addMarkers(markers, nodraw); }
addMarkers(markers, nodraw = false) {
return this.state.markerClusterer.addMarkers(markers, nodraw);
}

removeMarker(marker, nodraw = false) { return this.state.markerClusterer.removeMarker(marker, nodraw); }
removeMarker(marker, nodraw = false) {
return this.state.markerClusterer.removeMarker(marker, nodraw);
}

removeMarkers(markers, nodraw = false) { return this.state.markerClusterer.removeMarkers(markers, nodraw); }
removeMarkers(markers, nodraw = false) {
return this.state.markerClusterer.removeMarkers(markers, nodraw);
}

clearMarkers() { return this.state.markerClusterer.clearMarkers(); }

Expand All @@ -88,18 +96,19 @@ export default class MarkerClusterer extends Component {
return;
}

const { ...markerClustererProps } = this.props;
const { mapHolderRef } = this.context;
const markerClusterer = MarkerClustererCreator._createMarkerClusterer(mapHolderRef, markerClustererProps);
const markerClusterer = MarkerClustererCreator._createMarkerClusterer(
this.context.mapHolderRef,
this.props
);

this.setState({ markerClusterer });
}

render() {
if (this.state.markerClusterer) {
return (
<MarkerClustererCreator markerClusterer={ this.state.markerClusterer } { ...this.props }>
{ this.props.children }
<MarkerClustererCreator markerClusterer={this.state.markerClusterer} { ...this.props }>
{this.props.children}
</MarkerClustererCreator>
);
} else {
Expand Down
Loading

0 comments on commit f2b242a

Please sign in to comment.