From 744548ad143b7350e7e1d7d39e72bf2f4108fee6 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Tue, 19 Apr 2016 00:11:31 +0100 Subject: [PATCH] Fix lint for moved ReactNative --- .../ReactIOS/IOSDefaultEventPluginOrder.js | 2 +- .../ReactIOS/IOSNativeBridgeEventPlugin.js | 2 +- .../native/ReactIOS/NativeMethodsMixin.js | 8 +++--- .../native/ReactNative/ReactNative.js | 12 --------- .../ReactNativeAttributePayload.js | 10 +++---- .../ReactNative/ReactNativeBaseComponent.js | 4 +-- .../ReactNative/ReactNativeContainerInfo.js | 2 +- .../ReactNative/ReactNativeDOMIDOperations.js | 1 - .../ReactNativeDefaultInjection.js | 4 +-- .../ReactNative/ReactNativeEventEmitter.js | 2 +- .../ReactNativeGlobalInteractionHandler.js | 2 +- .../ReactNativeGlobalResponderHandler.js | 3 +-- .../native/ReactNative/ReactNativeMount.js | 4 +-- .../ReactNativeReconcileTransaction.js | 4 +-- .../ReactNative/ReactNativeTagHandles.js | 6 ++--- .../ReactNative/ReactNativeTextComponent.js | 6 ++--- .../ReactNativeAttributePayload-test.js | 27 ++++++++++++++----- .../native/ReactNative/findNodeHandle.js | 1 - .../shared/event/eventPlugins/PanResponder.js | 17 ++++++------ .../event/eventPlugins/TouchHistoryMath.js | 2 +- 20 files changed, 58 insertions(+), 61 deletions(-) diff --git a/src/renderers/native/ReactIOS/IOSDefaultEventPluginOrder.js b/src/renderers/native/ReactIOS/IOSDefaultEventPluginOrder.js index 80098fc414f30..eae211c40fcea 100644 --- a/src/renderers/native/ReactIOS/IOSDefaultEventPluginOrder.js +++ b/src/renderers/native/ReactIOS/IOSDefaultEventPluginOrder.js @@ -13,7 +13,7 @@ var IOSDefaultEventPluginOrder = [ 'ResponderEventPlugin', - 'IOSNativeBridgeEventPlugin' + 'IOSNativeBridgeEventPlugin', ]; module.exports = IOSDefaultEventPluginOrder; diff --git a/src/renderers/native/ReactIOS/IOSNativeBridgeEventPlugin.js b/src/renderers/native/ReactIOS/IOSNativeBridgeEventPlugin.js index 844e47536ba2a..564e10f28c95b 100644 --- a/src/renderers/native/ReactIOS/IOSNativeBridgeEventPlugin.js +++ b/src/renderers/native/ReactIOS/IOSNativeBridgeEventPlugin.js @@ -65,7 +65,7 @@ var IOSNativeBridgeEventPlugin = { return null; } return event; - } + }, }; module.exports = IOSNativeBridgeEventPlugin; diff --git a/src/renderers/native/ReactIOS/NativeMethodsMixin.js b/src/renderers/native/ReactIOS/NativeMethodsMixin.js index f9247a14195ee..0d06e11fef227 100644 --- a/src/renderers/native/ReactIOS/NativeMethodsMixin.js +++ b/src/renderers/native/ReactIOS/NativeMethodsMixin.js @@ -169,7 +169,7 @@ var NativeMethodsMixin = { */ blur: function() { TextInputState.blurTextInput(findNodeHandle(this)); - } + }, }; function throwOnStylesProp(component, props) { @@ -195,10 +195,10 @@ if (__DEV__) { !NativeMethodsMixin_DEV.componentWillReceiveProps, 'Do not override existing functions.' ); - NativeMethodsMixin_DEV.componentWillMount = function () { + NativeMethodsMixin_DEV.componentWillMount = function() { throwOnStylesProp(this, this.props); }; - NativeMethodsMixin_DEV.componentWillReceiveProps = function (newProps) { + NativeMethodsMixin_DEV.componentWillReceiveProps = function(newProps) { throwOnStylesProp(this, newProps); }; } @@ -210,7 +210,7 @@ if (__DEV__) { var mountSafeCallback = function(context: ReactComponent, callback: ?Function): any { return function() { if (!callback || (context.isMounted && !context.isMounted())) { - return; + return undefined; } return callback.apply(context, arguments); }; diff --git a/src/renderers/native/ReactNative/ReactNative.js b/src/renderers/native/ReactNative/ReactNative.js index 8ab2391606836..e40c6b7576571 100644 --- a/src/renderers/native/ReactNative/ReactNative.js +++ b/src/renderers/native/ReactNative/ReactNative.js @@ -16,9 +16,7 @@ var ReactNativeComponentTree = require('ReactNativeComponentTree'); var ReactNativeDefaultInjection = require('ReactNativeDefaultInjection'); -var ReactCurrentOwner = require('ReactCurrentOwner'); var ReactElement = require('ReactElement'); -var ReactInstanceHandles = require('ReactInstanceHandles'); var ReactNativeMount = require('ReactNativeMount'); var ReactUpdates = require('ReactUpdates'); @@ -45,16 +43,6 @@ var ReactNative = { /* eslint-enable camelcase */ unmountComponentAtNodeAndRemoveContainer: ReactNativeMount.unmountComponentAtNodeAndRemoveContainer, - - // Deprecations (remove for 0.13) - renderComponent: function( - element: ReactElement, - mountInto: number, - callback?: ?(() => void) - ): ?ReactComponent { - warning('Use React.render instead of React.renderComponent'); - return ReactNative.render(element, mountInto, callback); - }, }; // Inject the runtime into a devtools global hook regardless of browser. diff --git a/src/renderers/native/ReactNative/ReactNativeAttributePayload.js b/src/renderers/native/ReactNative/ReactNativeAttributePayload.js index 7adf0d27c7dc6..ca1cd57030408 100644 --- a/src/renderers/native/ReactNative/ReactNativeAttributePayload.js +++ b/src/renderers/native/ReactNative/ReactNativeAttributePayload.js @@ -408,9 +408,9 @@ function diffProperties( defaultDiffer(prevProp, nextProp) ); if (shouldUpdate) { - var nextValue = typeof attributeConfig.process === 'function' ? - attributeConfig.process(nextProp) : - nextProp; + nextValue = typeof attributeConfig.process === 'function' ? + attributeConfig.process(nextProp) : + nextProp; (updatePayload || (updatePayload = {}))[altKey] = nextValue; } } else { @@ -437,7 +437,7 @@ function diffProperties( // Also iterate through all the previous props to catch any that have been // removed and make sure native gets the signal so it can reset them to the // default. - for (var propKey in prevProps) { + for (propKey in prevProps) { if (nextProps[propKey] !== undefined) { continue; // we've already covered this key in the previous pass } @@ -539,7 +539,7 @@ var ReactNativeAttributePayload = { nextProps, validAttributes ); - } + }, }; diff --git a/src/renderers/native/ReactNative/ReactNativeBaseComponent.js b/src/renderers/native/ReactNative/ReactNativeBaseComponent.js index 4a87bc2d76654..a15dae5bba4af 100644 --- a/src/renderers/native/ReactNative/ReactNativeBaseComponent.js +++ b/src/renderers/native/ReactNative/ReactNativeBaseComponent.js @@ -20,8 +20,6 @@ var ReactMultiChild = require('ReactMultiChild'); var UIManager = require('UIManager'); var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev'); -var invariant = require('invariant'); -var warning = require('warning'); var registrationNames = ReactNativeEventEmitter.registrationNames; var putListener = ReactNativeEventEmitter.putListener; @@ -215,7 +213,7 @@ ReactNativeBaseComponent.Mixin = { context ); return tag; - } + }, }; /** diff --git a/src/renderers/native/ReactNative/ReactNativeContainerInfo.js b/src/renderers/native/ReactNative/ReactNativeContainerInfo.js index d3de99316c804..cc37ede4a09d1 100644 --- a/src/renderers/native/ReactNative/ReactNativeContainerInfo.js +++ b/src/renderers/native/ReactNative/ReactNativeContainerInfo.js @@ -13,7 +13,7 @@ function ReactNativeContainerInfo(tag) { var info = { - _tag: tag + _tag: tag, }; return info; } diff --git a/src/renderers/native/ReactNative/ReactNativeDOMIDOperations.js b/src/renderers/native/ReactNative/ReactNativeDOMIDOperations.js index c2a995ee761df..0bb92fef55211 100644 --- a/src/renderers/native/ReactNative/ReactNativeDOMIDOperations.js +++ b/src/renderers/native/ReactNative/ReactNativeDOMIDOperations.js @@ -12,7 +12,6 @@ 'use strict'; var ReactNativeComponentTree = require('ReactNativeComponentTree'); -var ReactNativeTagHandles = require('ReactNativeTagHandles'); var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes'); var ReactPerf = require('ReactPerf'); var UIManager = require('UIManager'); diff --git a/src/renderers/native/ReactNative/ReactNativeDefaultInjection.js b/src/renderers/native/ReactNative/ReactNativeDefaultInjection.js index c95e300be2825..2c603ec9aa6a3 100644 --- a/src/renderers/native/ReactNative/ReactNativeDefaultInjection.js +++ b/src/renderers/native/ReactNative/ReactNativeDefaultInjection.js @@ -66,7 +66,7 @@ function inject() { */ EventPluginHub.injection.injectEventPluginsByName({ 'ResponderEventPlugin': ResponderEventPlugin, - 'IOSNativeBridgeEventPlugin': IOSNativeBridgeEventPlugin + 'IOSNativeBridgeEventPlugin': IOSNativeBridgeEventPlugin, }); ReactUpdates.injection.injectReconcileTransaction( @@ -87,7 +87,7 @@ function inject() { return new ReactSimpleEmptyComponent( ReactElement.createElement(View, { collapsable: true, - style: { position: 'absolute' } + style: { position: 'absolute' }, }), instantiate ); diff --git a/src/renderers/native/ReactNative/ReactNativeEventEmitter.js b/src/renderers/native/ReactNative/ReactNativeEventEmitter.js index 67d18d11cb48e..1b252c699553e 100644 --- a/src/renderers/native/ReactNative/ReactNativeEventEmitter.js +++ b/src/renderers/native/ReactNative/ReactNativeEventEmitter.js @@ -209,7 +209,7 @@ var ReactNativeEventEmitter = merge(ReactEventEmitterMixin, { nativeEvent ); } - } + }, }); module.exports = ReactNativeEventEmitter; diff --git a/src/renderers/native/ReactNative/ReactNativeGlobalInteractionHandler.js b/src/renderers/native/ReactNative/ReactNativeGlobalInteractionHandler.js index d5c9b95447791..b84408a0d5399 100644 --- a/src/renderers/native/ReactNative/ReactNativeGlobalInteractionHandler.js +++ b/src/renderers/native/ReactNative/ReactNativeGlobalInteractionHandler.js @@ -27,7 +27,7 @@ var ReactNativeGlobalInteractionHandler = { } else if (!interactionHandle) { interactionHandle = InteractionManager.createInteractionHandle(); } - } + }, }; module.exports = ReactNativeGlobalInteractionHandler; diff --git a/src/renderers/native/ReactNative/ReactNativeGlobalResponderHandler.js b/src/renderers/native/ReactNative/ReactNativeGlobalResponderHandler.js index 1fb45e783fa1e..84bd45fb6f1f6 100644 --- a/src/renderers/native/ReactNative/ReactNativeGlobalResponderHandler.js +++ b/src/renderers/native/ReactNative/ReactNativeGlobalResponderHandler.js @@ -10,7 +10,6 @@ */ 'use strict'; -var ReactNativeTagHandles = require('ReactNativeTagHandles'); var UIManager = require('UIManager'); var ReactNativeGlobalResponderHandler = { @@ -23,7 +22,7 @@ var ReactNativeGlobalResponderHandler = { } else { UIManager.clearJSResponder(); } - } + }, }; module.exports = ReactNativeGlobalResponderHandler; diff --git a/src/renderers/native/ReactNative/ReactNativeMount.js b/src/renderers/native/ReactNative/ReactNativeMount.js index f0e9988e35da0..50d300923a2a9 100644 --- a/src/renderers/native/ReactNative/ReactNativeMount.js +++ b/src/renderers/native/ReactNative/ReactNativeMount.js @@ -130,7 +130,7 @@ var ReactNativeMount = { if (!ReactNativeTagHandles.reactTagIsNativeTopRootID(containerTag)) { console.error('You cannot render into anything but a top root'); - return; + return null; } ReactNativeTagHandles.assertRootTag(containerTag); @@ -225,7 +225,7 @@ var ReactNativeMount = { // Call back into native to remove all of the subviews from this container ReactReconciler.unmountComponent(instance); UIManager.removeSubviewsFromContainerWithID(containerID); - } + }, }; diff --git a/src/renderers/native/ReactNative/ReactNativeReconcileTransaction.js b/src/renderers/native/ReactNative/ReactNativeReconcileTransaction.js index b6721964988f0..1c40be74bc4e2 100644 --- a/src/renderers/native/ReactNative/ReactNativeReconcileTransaction.js +++ b/src/renderers/native/ReactNative/ReactNativeReconcileTransaction.js @@ -32,7 +32,7 @@ var ON_DOM_READY_QUEUEING = { */ close: function() { this.reactMountReady.notifyAll(); - } + }, }; /** @@ -88,7 +88,7 @@ var Mixin = { destructor: function() { CallbackQueue.release(this.reactMountReady); this.reactMountReady = null; - } + }, }; Object.assign( diff --git a/src/renderers/native/ReactNative/ReactNativeTagHandles.js b/src/renderers/native/ReactNative/ReactNativeTagHandles.js index f0079fdabc0b7..2a4d7bd01065a 100644 --- a/src/renderers/native/ReactNative/ReactNativeTagHandles.js +++ b/src/renderers/native/ReactNative/ReactNativeTagHandles.js @@ -12,7 +12,6 @@ 'use strict'; var invariant = require('invariant'); -var warning = require('warning'); /** * Keeps track of allocating and associating native "tags" which are numeric, @@ -28,7 +27,6 @@ var warning = require('warning'); * unmount a component with a `rootNodeID`, then mount a new one in its place, */ var INITIAL_TAG_COUNT = 1; -var NATIVE_TOP_ROOT_ID_SEPARATOR = '{TOP_LEVEL}'; var ReactNativeTagHandles = { tagsStartAt: INITIAL_TAG_COUNT, tagCount: INITIAL_TAG_COUNT, @@ -46,14 +44,14 @@ var ReactNativeTagHandles = { assertRootTag: function(tag: number): void { invariant( this.reactTagIsNativeTopRootID(tag), - 'Expect a native root tag, instead got ', tag + 'Expect a native root tag, instead got %s', tag ); }, reactTagIsNativeTopRootID: function(reactTag: number): bool { // We reserve all tags that are 1 mod 10 for native root views return reactTag % 10 === 1; - } + }, }; module.exports = ReactNativeTagHandles; diff --git a/src/renderers/native/ReactNative/ReactNativeTextComponent.js b/src/renderers/native/ReactNative/ReactNativeTextComponent.js index 434e4b8885f5f..3de8a82dd21d5 100644 --- a/src/renderers/native/ReactNative/ReactNativeTextComponent.js +++ b/src/renderers/native/ReactNative/ReactNativeTextComponent.js @@ -31,8 +31,8 @@ Object.assign(ReactNativeTextComponent.prototype, { // TODO: nativeParent should have this context already. Stop abusing context. invariant( context.isInAParentText, - 'RawText "' + this._stringText + '" must be wrapped in an explicit ' + - ' component.' + 'RawText "%s" must be wrapped in an explicit component.', + this._stringText ); this._nativeParent = nativeParent; var tag = ReactNativeTagHandles.allocateTag(); @@ -74,7 +74,7 @@ Object.assign(ReactNativeTextComponent.prototype, { this._currentElement = null; this._stringText = null; this._rootNodeID = null; - } + }, }); diff --git a/src/renderers/native/ReactNative/__tests__/ReactNativeAttributePayload-test.js b/src/renderers/native/ReactNative/__tests__/ReactNativeAttributePayload-test.js index d325ca0919739..be65d175a2830 100644 --- a/src/renderers/native/ReactNative/__tests__/ReactNativeAttributePayload-test.js +++ b/src/renderers/native/ReactNative/__tests__/ReactNativeAttributePayload-test.js @@ -87,10 +87,10 @@ describe('ReactNativeAttributePayload', function() { it('should do deep diffs of Objects by default', () => { expect(diff( - {a: [1], b: {k: [3,4]}, c: {k: [4,4]} }, - {a: [2], b: {k: [3,4]}, c: {k: [4,5]} }, + {a: [1], b: {k: [3, 4]}, c: {k: [4, 4]} }, + {a: [2], b: {k: [3, 4]}, c: {k: [4, 5]} }, {a: true, b: true, c: true} - )).toEqual({a: [2], c: {k: [4,5]}}); + )).toEqual({a: [2], c: {k: [4, 5]}}); }); it('should work with undefined styles', () => { @@ -222,10 +222,25 @@ describe('ReactNativeAttributePayload', function() { // Note that if the property changes from one function to another, we don't // need to send an update. expect(diff( - {a: function() { return 1; }, b: function() { return 2; }, c: 3}, - {b: function() { return 9; }, c: function() { return 3; }, }, + { + a: function() { + return 1; + }, + b: function() { + return 2; + }, + c: 3, + }, + { + b: function() { + return 9; + }, + c: function() { + return 3; + }, + }, {a: true, b: true, c: true} )).toEqual({a: null, c: true}); }); - }); +}); diff --git a/src/renderers/native/ReactNative/findNodeHandle.js b/src/renderers/native/ReactNative/findNodeHandle.js index 15f709e7e9a8c..2979490de7a6a 100644 --- a/src/renderers/native/ReactNative/findNodeHandle.js +++ b/src/renderers/native/ReactNative/findNodeHandle.js @@ -14,7 +14,6 @@ var ReactCurrentOwner = require('ReactCurrentOwner'); var ReactInstanceMap = require('ReactInstanceMap'); -var ReactNativeTagHandles = require('ReactNativeTagHandles'); var invariant = require('invariant'); var warning = require('warning'); diff --git a/src/renderers/shared/event/eventPlugins/PanResponder.js b/src/renderers/shared/event/eventPlugins/PanResponder.js index c633dd724be79..a102747fe6bcb 100644 --- a/src/renderers/shared/event/eventPlugins/PanResponder.js +++ b/src/renderers/shared/event/eventPlugins/PanResponder.js @@ -2,7 +2,7 @@ * @providesModule PanResponder */ -"use strict"; +'use strict'; var TouchHistoryMath = require('TouchHistoryMath'); @@ -320,25 +320,25 @@ var PanResponder = { gestureState.y0 = currentCentroidY(e.touchHistory); gestureState.dx = 0; gestureState.dy = 0; - config.onPanResponderGrant && config.onPanResponderGrant(e, gestureState); + if (config.onPanResponderGrant) config.onPanResponderGrant(e, gestureState); // TODO: t7467124 investigate if this can be removed return config.onShouldBlockNativeResponder === undefined ? true : config.onShouldBlockNativeResponder(); }, onResponderReject: function(e) { - config.onPanResponderReject && config.onPanResponderReject(e, gestureState); + if (config.onPanResponderReject) config.onPanResponderReject(e, gestureState); }, onResponderRelease: function(e) { - config.onPanResponderRelease && config.onPanResponderRelease(e, gestureState); + if (config.onPanResponderRelease) config.onPanResponderRelease(e, gestureState); PanResponder._initializeGestureState(gestureState); }, onResponderStart: function(e) { var touchHistory = e.touchHistory; gestureState.numberActiveTouches = touchHistory.numberActiveTouches; - config.onPanResponderStart && config.onPanResponderStart(e, gestureState); + if (config.onPanResponderStart) config.onPanResponderStart(e, gestureState); }, onResponderMove: function(e) { @@ -351,18 +351,19 @@ var PanResponder = { // Filter out any touch moves past the first one - we would have // already processed multi-touch geometry during the first event. PanResponder._updateGestureStateOnMove(gestureState, touchHistory); - config.onPanResponderMove && config.onPanResponderMove(e, gestureState); + if (config.onPanResponderMove) config.onPanResponderMove(e, gestureState); }, onResponderEnd: function(e) { var touchHistory = e.touchHistory; gestureState.numberActiveTouches = touchHistory.numberActiveTouches; - config.onPanResponderEnd && config.onPanResponderEnd(e, gestureState); + if (config.onPanResponderEnd) config.onPanResponderEnd(e, gestureState); }, onResponderTerminate: function(e) { - config.onPanResponderTerminate && + if (config.onPanResponderTerminate) { config.onPanResponderTerminate(e, gestureState); + } PanResponder._initializeGestureState(gestureState); }, diff --git a/src/renderers/shared/event/eventPlugins/TouchHistoryMath.js b/src/renderers/shared/event/eventPlugins/TouchHistoryMath.js index 1507d21f5618b..a2a725bd2fa62 100644 --- a/src/renderers/shared/event/eventPlugins/TouchHistoryMath.js +++ b/src/renderers/shared/event/eventPlugins/TouchHistoryMath.js @@ -2,7 +2,7 @@ * @providesModule TouchHistoryMath */ -"use strict"; +'use strict'; var TouchHistoryMath = { /**