Misc flow and lint fixes

This commit is contained in:
Nicolas Gallagher
2017-06-18 12:56:14 -07:00
parent d1d5461b29
commit 6203a3fec6
16 changed files with 132 additions and 111 deletions

View File

@@ -20,7 +20,7 @@ const createKey = id => `${prefix}-${id}`;
export default class ReactNativePropRegistry {
static register(object: Object): number {
let id = uniqueID++;
const id = uniqueID++;
if (process.env.NODE_ENV !== 'production') {
Object.freeze(object);
}

View File

@@ -15,13 +15,10 @@ import Dimensions from '../../apis/Dimensions';
import findNodeHandle from '../findNodeHandle';
import invariant from 'fbjs/lib/invariant';
import Platform from '../../apis/Platform';
import React from 'react';
import TextInputState from '../../components/TextInput/TextInputState';
import UIManager from '../../apis/UIManager';
import warning from 'fbjs/lib/warning';
// type Component = React.Component
/**
* Mixin that can be integrated in order to handle scrolling that plays well
* with `ResponderEventPlugin`. Integrate with your platform specific scroll
@@ -102,7 +99,7 @@ import warning from 'fbjs/lib/warning';
const emptyObject = {};
var IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16;
const IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16;
type State = {
isTouching: boolean,
@@ -113,7 +110,7 @@ type State = {
};
type Event = Object;
var ScrollResponderMixin = {
const ScrollResponderMixin = {
// mixins: [Subscribable.Mixin],
scrollResponderMixinGetInitialState: function(): State {
return {
@@ -228,7 +225,7 @@ var ScrollResponderMixin = {
* @param {SyntheticEvent} e Event.
*/
scrollResponderHandleTouchEnd: function(e: Event) {
var nativeEvent = e.nativeEvent;
const nativeEvent = e.nativeEvent;
this.state.isTouching = nativeEvent.touches.length !== 0;
this.props.onTouchEnd && this.props.onTouchEnd(e);
},
@@ -241,7 +238,7 @@ var ScrollResponderMixin = {
// By default scroll views will unfocus a textField
// if another touch occurs outside of it
var currentlyFocusedTextInput = TextInputState.currentlyFocusedField();
const currentlyFocusedTextInput = TextInputState.currentlyFocusedField();
if (
!this.props.keyboardShouldPersistTaps &&
currentlyFocusedTextInput != null &&
@@ -340,9 +337,9 @@ var ScrollResponderMixin = {
* a touch has just started or ended.
*/
scrollResponderIsAnimating: function(): boolean {
var now = Date.now();
var timeSinceLastMomentumScrollEnd = now - this.state.lastMomentumScrollEndTime;
var isAnimating =
const now = Date.now();
const timeSinceLastMomentumScrollEnd = now - this.state.lastMomentumScrollEndTime;
const isAnimating =
timeSinceLastMomentumScrollEnd < IS_ANIMATING_TOUCH_START_THRESHOLD_MS ||
this.state.lastMomentumScrollEndTime < this.state.lastMomentumScrollBeginTime;
return isAnimating;
@@ -457,11 +454,11 @@ var ScrollResponderMixin = {
width: number,
height: number
) {
var keyboardScreenY = Dimensions.get('window').height;
let keyboardScreenY = Dimensions.get('window').height;
if (this.keyboardWillOpenTo) {
keyboardScreenY = this.keyboardWillOpenTo.endCoordinates.screenY;
}
var scrollOffsetY = top - keyboardScreenY + height + this.additionalScrollOffset;
let scrollOffsetY = top - keyboardScreenY + height + this.additionalScrollOffset;
// By default, this can scroll with negative offset, pulling the content
// down so that the target component's bottom meets the keyboard's top.
@@ -548,7 +545,7 @@ var ScrollResponderMixin = {
}
};
var ScrollResponder = {
const ScrollResponder = {
Mixin: ScrollResponderMixin
};

View File

@@ -6,9 +6,9 @@ const isNumeric = n => {
return !isNaN(parseFloat(n)) && isFinite(n);
};
const multiplyStyleLengthValue = (value: String | Number, multiple) => {
const multiplyStyleLengthValue = (value: string | number, multiple) => {
if (typeof value === 'string') {
const number = parseFloat(value, 10) * multiple;
const number = parseFloat(value) * multiple;
const unit = getUnit(value);
return `${number}${unit}`;
} else if (isNumeric(value)) {

View File

@@ -1,6 +1,18 @@
/**
* Copyright (c) 2016-present, Nicolas Gallagher.
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule processColor
* @flow
*/
import normalizeColor from 'normalize-css-color';
const processColor = (color, opacity = 1) => {
const processColor = (color: ?(string | number), opacity: number = 1) => {
if (
color === undefined ||
color === null ||

View File

@@ -13,7 +13,7 @@ const _requestIdleCallback = function(cb) {
}, 1);
};
const _cancelIdleCallback = function(id) {
const _cancelIdleCallback = function(id: number) {
clearTimeout(id);
};