Mats Byrkeland edb6ca72fd Fix ESLint warnings using 'yarn lint --fix'
Summary:
Hi! I would like to contribute to React Native, and I am just starting out. I forked the repo and found that it has quite a lot of ESLint warnings – many of which were automatically fixable. This PR is simply the result of running `yarn lint --fix` from the root folder.

Most changes are removing trailing spaces from comments.

Haven't really done any manual testing, since I haven't done any code changes manually. `yarn test` runs fine, `yarn flow` runs fine, `yarn prettier` is satisfied.

N/A

[INTERNAL][MINOR][] - Fix ESLint warnings
Closes https://github.com/facebook/react-native/pull/18047

Differential Revision: D7054948

Pulled By: hramos

fbshipit-source-id: d53e692698d1687de5821c3fb5cdb76a5e03b71e
2018-02-22 07:23:17 -08:00

95 lines
2.4 KiB
JavaScript

/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule Linking
* @flow
*/
'use strict';
const NativeEventEmitter = require('NativeEventEmitter');
const NativeModules = require('NativeModules');
const Platform = require('Platform');
const invariant = require('fbjs/lib/invariant');
const LinkingManager = Platform.OS === 'android' ?
NativeModules.IntentAndroid : NativeModules.LinkingManager;
/**
* `Linking` gives you a general interface to interact with both incoming
* and outgoing app links.
*
* See https://facebook.github.io/react-native/docs/linking.html
*/
class Linking extends NativeEventEmitter {
constructor() {
super(LinkingManager);
}
/**
* Add a handler to Linking changes by listening to the `url` event type
* and providing the handler
*
* See https://facebook.github.io/react-native/docs/linking.html#addeventlistener
*/
addEventListener(type: string, handler: Function) {
this.addListener(type, handler);
}
/**
* Remove a handler by passing the `url` event type and the handler.
*
* See https://facebook.github.io/react-native/docs/linking.html#removeeventlistener
*/
removeEventListener(type: string, handler: Function ) {
this.removeListener(type, handler);
}
/**
* Try to open the given `url` with any of the installed apps.
*
* See https://facebook.github.io/react-native/docs/linking.html#openurl
*/
openURL(url: string): Promise<any> {
this._validateURL(url);
return LinkingManager.openURL(url);
}
/**
* Determine whether or not an installed app can handle a given URL.
*
* See https://facebook.github.io/react-native/docs/linking.html#canopenurl
*/
canOpenURL(url: string): Promise<boolean> {
this._validateURL(url);
return LinkingManager.canOpenURL(url);
}
/**
* If the app launch was triggered by an app link,
* it will give the link url, otherwise it will give `null`
*
* See https://facebook.github.io/react-native/docs/linking.html#getinitialurl
*/
getInitialURL(): Promise<?string> {
return LinkingManager.getInitialURL();
}
_validateURL(url: string) {
invariant(
typeof url === 'string',
'Invalid URL: should be a string. Was: ' + url
);
invariant(
url,
'Invalid URL: cannot be empty'
);
}
}
module.exports = new Linking();