Skip to content

Commit

Permalink
[google] decorateMapComponent - don't ignore entire file w/eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbox committed Sep 21, 2016
1 parent 2d37a79 commit 4640109
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions components/decorateMapComponent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable */

import { PropTypes } from 'react';
import {
requireNativeComponent,
Expand Down Expand Up @@ -29,7 +27,7 @@ export const contextTypes = {
};

export const createNotSupportedComponent = message => () => {
console.error(message);
console.error(message); // eslint-disable-line no-console
return null;
};

Expand All @@ -38,23 +36,24 @@ export const googleMapIsInstalled = !!NativeModules.UIManager[getAirMapName(PROV
export default function decorateMapComponent(Component, { componentType, providers }) {
const components = {};

const getDefaultComponent = () => requireNativeComponent(getAirComponentName(null, componentType), Component);
const getDefaultComponent = () =>
requireNativeComponent(getAirComponentName(null, componentType), Component);

Component.contextTypes = contextTypes;
Component.prototype.getAirComponent = function() {
Component.contextTypes = contextTypes; // eslint-disable-line no-param-reassign
Component.prototype.getAirComponent = function getAirComponent() { // eslint-disable-line no-param-reassign,max-len

This comment has been minimized.

Copy link
@spikebrehm

spikebrehm Sep 21, 2016

This line is violating max-len?

This comment has been minimized.

Copy link
@gilbox

gilbox Sep 21, 2016

Author Contributor

it violates b/c of the eslint comment

This comment has been minimized.

Copy link
@gilbox

gilbox Sep 21, 2016

Author Contributor

image

This comment has been minimized.

Copy link
@spikebrehm

spikebrehm Sep 21, 2016

That's ironic.

Instead, you could do

// eslint-disable-next-line no-param-reassign
Component.prototype.getAirComponent = function getAirComponent() {
const provider = this.context.provider || PROVIDER_DEFAULT;
if (components[provider]) return components[provider];

if (provider === PROVIDER_DEFAULT) {
components.default = getDefaultComponent();
return components.default
return components.default;
}

const providerInfo = providers[provider];
const platformSupport = providerInfo[Platform.OS];
const componentName = getAirComponentName(provider, componentType);
if (platformSupport === NOT_SUPPORTED) {
components[provider] = createNotSupportedComponent(`react-native-maps: ${componentName} is not supported on ${Platform.OS}`);
components[provider] = createNotSupportedComponent(`react-native-maps: ${componentName} is not supported on ${Platform.OS}`); // eslint-disable-line max-len
} else if (platformSupport === SUPPORTED) {
if (provider !== PROVIDER_GOOGLE || (Platform.OS === 'ios' && googleMapIsInstalled)) {
components[provider] = requireNativeComponent(componentName, Component);
Expand All @@ -67,12 +66,12 @@ export default function decorateMapComponent(Component, { componentType, provide
return components[provider];
};

Component.prototype.getUIManagerCommand = function(name) {
Component.prototype.getUIManagerCommand = function getUIManagerCommand(name) { // eslint-disable-line no-param-reassign,max-len
return NativeModules.UIManager[getAirComponentName(this.context.provider, componentType)]
.Commands[name];
};

Component.prototype.getMapManagerCommand = function(name) {
Component.prototype.getMapManagerCommand = function getMapManagerCommand(name) { // eslint-disable-line no-param-reassign,max-len
const airComponentName = `${getAirComponentName(this.context.provider, componentType)}Manager`;
return NativeModules[airComponentName][name];
};
Expand Down

0 comments on commit 4640109

Please sign in to comment.