From 8a011282a0375df451c6d0c073c42c0af9b0ece2 Mon Sep 17 00:00:00 2001
From: Brandon Dail
Date: Mon, 23 Jan 2017 18:05:59 -0600
Subject: [PATCH 001/110] Deprecate React.createMixin
This API was never fully implemented. Since mixins are no longer considered part of the future React API, it will be removed.
---
src/isomorphic/React.js | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/isomorphic/React.js b/src/isomorphic/React.js
index 39b6aa31ce..5064ee63bd 100644
--- a/src/isomorphic/React.js
+++ b/src/isomorphic/React.js
@@ -37,20 +37,35 @@ if (__DEV__) {
}
var __spread = Object.assign;
+var createMixin = function(mixin) {
+ return mixin;
+};
if (__DEV__) {
- var warned = false;
+ var warnedForSpread = false;
+ var warnedForCreateMixin = false;
__spread = function() {
warning(
- warned,
+ warnedForSpread,
'React.__spread is deprecated and should not be used. Use ' +
'Object.assign directly or another helper function with similar ' +
'semantics. You may be seeing this warning due to your compiler. ' +
'See https://fb.me/react-spread-deprecation for more details.'
);
- warned = true;
+ warnedForSpread = true;
return Object.assign.apply(null, arguments);
};
+
+ createMixin = function(mixin) {
+ warning(
+ warnedForCreateMixin,
+ 'React.createMixin is deprecated and should not be used. You ' +
+ 'can use your mixin directly instead.'
+ );
+ warnedForCreateMixin = true;
+ return mixin;
+ };
+
}
var React = {
@@ -77,10 +92,7 @@ var React = {
PropTypes: ReactPropTypes,
createClass: ReactClass.createClass,
createFactory: createFactory,
- createMixin: function(mixin) {
- // Currently a noop. Will be used to validate and trace mixins.
- return mixin;
- },
+ createMixin: createMixin,
// This looks DOM specific but these are actually isomorphic helpers
// since they are just generating DOM strings.
From 16c4f9006a4c36d9100bc75a3ad7792ba3b73e40 Mon Sep 17 00:00:00 2001
From: Brandon Dail
Date: Mon, 23 Jan 2017 18:07:00 -0600
Subject: [PATCH 002/110] Add test for deprecation warnings
---
src/isomorphic/__tests__/React-test.js | 42 ++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 src/isomorphic/__tests__/React-test.js
diff --git a/src/isomorphic/__tests__/React-test.js b/src/isomorphic/__tests__/React-test.js
new file mode 100644
index 0000000000..db318fa604
--- /dev/null
+++ b/src/isomorphic/__tests__/React-test.js
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2013-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. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ * @emails react-core
+ */
+
+'use strict';
+
+describe('React', () => {
+
+ var React;
+
+ beforeEach(() => {
+ React = require('React');
+ });
+
+ it('should log a deprecation warning once when using React.__spread', () => {
+ spyOn(console, 'error');
+ React.__spread({});
+ React.__spread({});
+ expect(console.error.calls.count()).toBe(1);
+ expect(console.error.calls.argsFor(0)[0]).toContain(
+ 'React.__spread is deprecated and should not be used'
+ );
+ });
+
+ it('should log a deprecation warning once when using React.createMixin', () => {
+ spyOn(console, 'error');
+ React.createMixin();
+ React.createMixin();
+ expect(console.error.calls.count()).toBe(1);
+ expect(console.error.calls.argsFor(0)[0]).toContain(
+ 'React.createMixin is deprecated and should not be used'
+ );
+ });
+
+});
From ddd8260e4b49c178640a0e3314627c1bb5d8f70e Mon Sep 17 00:00:00 2001
From: Brandon Dail
Date: Mon, 23 Jan 2017 19:42:28 -0600
Subject: [PATCH 003/110] Update deprecation wording to be less aggressive
---
src/isomorphic/React.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/isomorphic/React.js b/src/isomorphic/React.js
index 5064ee63bd..8cdfb5d4a7 100644
--- a/src/isomorphic/React.js
+++ b/src/isomorphic/React.js
@@ -60,7 +60,7 @@ if (__DEV__) {
warning(
warnedForCreateMixin,
'React.createMixin is deprecated and should not be used. You ' +
- 'can use your mixin directly instead.'
+ 'can use this mixin directly instead.'
);
warnedForCreateMixin = true;
return mixin;
From 6428cf735950e24732c69cfeb411ab60d49a9043 Mon Sep 17 00:00:00 2001
From: Flarnie Marchan
Date: Thu, 13 Apr 2017 11:41:22 -0700
Subject: [PATCH 004/110] Quick fix for `eslint` on 15.6-dev branch
The `.eslintignore` had gotten a merge conflict committed accidentally
at some point, and also was not ignoring the `addons` directory. This
fixes that.
We also had a couple of missing commas that snuck in, and those are
fixed here too.
---
.eslintignore | 4 +---
.../classic/class/__tests__/ReactCreateClass-test.js | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/.eslintignore b/.eslintignore
index 2d7c565d32..cdcaed49e2 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,4 +1,5 @@
# We can probably lint these later but not important at this point
+addons/
src/renderers/art
src/shared/vendor
# But not in docs/_js/examples/*
@@ -9,11 +10,8 @@ docs/_site/
docs/vendor/bundle/
# This should be more like examples/**/thirdparty/** but
# we should fix https://github.com/facebook/esprima/pull/85 first
-<<<<<<< HEAD
examples/
-=======
fixtures/
->>>>>>> 4a37718... Remove examples/ folder (#9323)
# Ignore built files.
build/
coverage/
diff --git a/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js b/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js
index 9c1a44ea5d..267f5f8ad9 100644
--- a/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js
+++ b/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js
@@ -367,7 +367,7 @@ describe('ReactClass-spec', () => {
render() {
ops.push('Render: ' + this.state.step);
return ;
- }
+ },
});
var instance = ReactTestUtils.renderIntoDocument();
@@ -414,7 +414,7 @@ describe('ReactClass-spec', () => {
instance = this;
this.log('render');
return ;
- }
+ },
});
var container = document.createElement('div');
From 25177ec4ea0f79ca852be932881d28faf8b353f8 Mon Sep 17 00:00:00 2001
From: Eric Sakmar
Date: Thu, 20 Apr 2017 14:20:15 -0400
Subject: [PATCH 005/110] Adds CSS Grid properties to list of unitless numbers
(#9185)
---
src/renderers/dom/shared/CSSProperty.js | 6 ++++++
src/renderers/dom/shared/__tests__/CSSProperty-test.js | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/src/renderers/dom/shared/CSSProperty.js b/src/renderers/dom/shared/CSSProperty.js
index fa0645c987..6091751529 100644
--- a/src/renderers/dom/shared/CSSProperty.js
+++ b/src/renderers/dom/shared/CSSProperty.js
@@ -30,7 +30,13 @@ var isUnitlessNumber = {
flexNegative: true,
flexOrder: true,
gridRow: true,
+ gridRowEnd: true,
+ gridRowSpan: true,
+ gridRowStart: true,
gridColumn: true,
+ gridColumnEnd: true,
+ gridColumnSpan: true,
+ gridColumnStart: true,
fontWeight: true,
lineClamp: true,
lineHeight: true,
diff --git a/src/renderers/dom/shared/__tests__/CSSProperty-test.js b/src/renderers/dom/shared/__tests__/CSSProperty-test.js
index 331d38fc22..f8fc2b8727 100644
--- a/src/renderers/dom/shared/__tests__/CSSProperty-test.js
+++ b/src/renderers/dom/shared/__tests__/CSSProperty-test.js
@@ -25,7 +25,13 @@ describe('CSSProperty', () => {
expect(CSSProperty.isUnitlessNumber.msFlexGrow).toBeTruthy();
expect(CSSProperty.isUnitlessNumber.MozFlexGrow).toBeTruthy();
expect(CSSProperty.isUnitlessNumber.msGridRow).toBeTruthy();
+ expect(CSSProperty.isUnitlessNumber.msGridRowEnd).toBeTruthy();
+ expect(CSSProperty.isUnitlessNumber.msGridRowSpan).toBeTruthy();
+ expect(CSSProperty.isUnitlessNumber.msGridRowStart).toBeTruthy();
expect(CSSProperty.isUnitlessNumber.msGridColumn).toBeTruthy();
+ expect(CSSProperty.isUnitlessNumber.msGridColumnEnd).toBeTruthy();
+ expect(CSSProperty.isUnitlessNumber.msGridColumnSpan).toBeTruthy();
+ expect(CSSProperty.isUnitlessNumber.msGridColumnStart).toBeTruthy();
});
});
From a6b51ed8fb5cea1f8f7c0032d47ccdd5516c430a Mon Sep 17 00:00:00 2001
From: Chris Pearce
Date: Tue, 18 Apr 2017 14:31:47 +0100
Subject: [PATCH 006/110] Only attempt to clear measures if we created the
measure (#9451)
This fixes an issue where if we decided not to create a measurement we would clear ALL measurements from the performance entry buffer due to passing `undefined` as the entry name.
---
src/renderers/shared/ReactDebugTool.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/renderers/shared/ReactDebugTool.js b/src/renderers/shared/ReactDebugTool.js
index f7edbfbc74..9dae836d97 100644
--- a/src/renderers/shared/ReactDebugTool.js
+++ b/src/renderers/shared/ReactDebugTool.js
@@ -291,7 +291,9 @@ function markEnd(debugID, markType) {
}
performance.clearMarks(markName);
- performance.clearMeasures(measurementName);
+ if (measurementName) {
+ performance.clearMeasures(measurementName);
+ }
}
var ReactDebugTool = {
From 1926f9ab062eba4222d45ca712eaf656bb84b0c2 Mon Sep 17 00:00:00 2001
From: Flarnie Marchan
Date: Fri, 21 Apr 2017 12:56:54 -0700
Subject: [PATCH 007/110] Quick fix for flowconfig
We had a merge conflict sneak in somewhere, and also want to ignore the
'addons' directory.
---
.flowconfig | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/.flowconfig b/.flowconfig
index 1b15b4d7d2..3a962f8881 100644
--- a/.flowconfig
+++ b/.flowconfig
@@ -1,14 +1,12 @@
[ignore]
-<<<<<<< HEAD
/examples/.*
-=======
/fixtures/.*
->>>>>>> 4a37718... Remove examples/ folder (#9323)
/build/.*
/.*/node_modules/y18n/.*
/.*/__mocks__/.*
/.*/__tests__/.*
+/addons/.*
# Ignore Docs
/docs/.*
From ad1d3526f5b4e77de610940adb3090002ecf12ef Mon Sep 17 00:00:00 2001
From: Flarnie Marchan
Date: Sat, 22 Apr 2017 11:36:25 -0700
Subject: [PATCH 008/110] Run 'prettier' on the v15.6 branch (#9487)
* Run 'prettier' on the v15.6 branch
This is an easy fix and I'd like this branch to be as similar to master
(v16.0) as possible.
* `npm install --save-dev prettier && yarn prettier`
Checking in the updated `package.json` and `yarn.lock` for the 15.6
branch.
Oddly, running `yarn prettier` updated more files. I thought the
previous commit had covered all `prettier` syntax updates. Will commit
the new changes in a separate commit.
* Ran prettier
More syntax updates to get `prettier` checks passing on the `15.6-dev`
branch, and eventually, on 15-stable.
* Tweak eslint ignore comments to get linter passing
Something with running `prettier` moves or changes these comments in a
way that they were no longer being applied. We tweaked them so that both
'prettier' and 'eslint' pass.
---
package.json | 1 +
src/addons/ReactFragment.js | 10 +-
src/addons/ReactWithAddons.js | 3 +-
src/addons/__tests__/ReactFragment-test.js | 28 +-
.../renderSubtreeIntoContainer-test.js | 10 +-
src/addons/__tests__/update-test.js | 74 +-
src/addons/link/LinkedStateMixin.js | 2 +-
src/addons/link/ReactLink.js | 6 +-
.../transitions/ReactCSSTransitionGroup.js | 23 +-
.../ReactCSSTransitionGroupChild.js | 19 +-
.../ReactTransitionChildMapping.js | 2 +-
.../transitions/ReactTransitionGroup.js | 60 +-
.../ReactTransitionChildMapping-test.js | 2 +-
src/addons/update.js | 34 +-
src/isomorphic/React.js | 12 +-
src/isomorphic/__tests__/React-test.js | 6 +-
src/isomorphic/children/ReactChildren.js | 29 +-
.../children/__tests__/ReactChildren-test.js | 119 +-
.../children/__tests__/onlyChild-test.js | 34 +-
.../children/__tests__/sliceChildren-test.js | 36 +-
src/isomorphic/children/onlyChild.js | 2 +-
.../__tests__/ReactContextValidator-test.js | 48 +-
src/isomorphic/classic/class/ReactClass.js | 189 +--
.../class/__tests__/ReactClass-test.js | 54 +-
.../class/__tests__/ReactCreateClass-test.js | 61 +-
.../classic/element/ReactCurrentOwner.js | 4 +-
.../classic/element/ReactDOMFactories.js | 2 +-
.../classic/element/ReactElement.js | 54 +-
.../classic/element/ReactElementType.js | 2 +-
.../classic/element/ReactElementValidator.js | 86 +-
.../element/__tests__/ReactElement-test.js | 111 +-
.../__tests__/ReactElementClone-test.js | 69 +-
.../__tests__/ReactElementValidator-test.js | 148 +-
.../types/__tests__/ReactPropTypes-test.js | 380 +++--
.../hooks/ReactComponentTreeHook.js | 76 +-
src/isomorphic/modern/class/ReactComponent.js | 12 +-
.../modern/class/ReactNoopUpdateQueue.js | 10 +-
.../__tests__/ReactClassEquivalence-test.js | 26 +-
.../class/__tests__/ReactES6Class-test.js | 68 +-
.../__tests__/ReactPureComponent-test.js | 1 -
.../element/__tests__/ReactJSXElement-test.js | 21 +-
.../ReactJSXElementValidator-test.js | 89 +-
src/renderers/art/ReactART.js | 194 ++-
src/renderers/art/__tests__/ReactART-test.js | 83 +-
src/renderers/dom/ReactDOM.js | 38 +-
src/renderers/dom/__mocks__/ReactDOM.js | 5 +-
.../dom/__tests__/ReactDOMProduction-test.js | 33 +-
.../dom/client/ReactBrowserEventEmitter.js | 55 +-
.../dom/client/ReactDOMComponentTree.js | 16 +-
.../dom/client/ReactDOMIDOperations.js | 1 -
src/renderers/dom/client/ReactDOMSelection.js | 12 +-
.../dom/client/ReactDOMTreeTraversal.js | 4 +-
.../dom/client/ReactEventListener.js | 13 +-
.../dom/client/ReactInputSelection.js | 37 +-
src/renderers/dom/client/ReactMount.js | 267 ++--
.../dom/client/ReactReconcileTransaction.js | 2 -
.../ReactBrowserEventEmitter-test.js | 151 +-
.../dom/client/__tests__/ReactDOM-test.js | 28 +-
.../__tests__/ReactDOMComponentTree-test.js | 7 +-
.../__tests__/ReactDOMIDOperations-test.js | 16 +-
.../dom/client/__tests__/ReactDOMSVG-test.js | 4 +-
.../__tests__/ReactDOMTreeTraversal-test.js | 54 +-
.../__tests__/ReactEventIndependence-test.js | 7 +-
.../__tests__/ReactEventListener-test.js | 133 +-
.../dom/client/__tests__/ReactMount-test.js | 25 +-
.../__tests__/ReactMountDestruction-test.js | 26 +-
.../__tests__/ReactRenderDocument-test.js | 37 +-
.../dom/client/__tests__/findDOMNode-test.js | 9 +-
.../__tests__/validateDOMNesting-test.js | 116 +-
.../eventPlugins/BeforeInputEventPlugin.js | 60 +-
.../client/eventPlugins/ChangeEventPlugin.js | 93 +-
.../eventPlugins/EnterLeaveEventPlugin.js | 42 +-
.../client/eventPlugins/SelectEventPlugin.js | 39 +-
.../client/eventPlugins/SimpleEventPlugin.js | 27 +-
.../dom/client/eventPlugins/TapEventPlugin.js | 40 +-
.../__tests__/BeforeInputEventPlugin-test.js | 101 +-
.../__tests__/ChangeEventPlugin-test.js | 4 +-
.../__tests__/EnterLeaveEventPlugin-test.js | 9 +-
.../__tests__/SelectEventPlugin-test.js | 4 +-
.../__tests__/SimpleEventPlugin-test.js | 44 +-
src/renderers/dom/client/findDOMNode.js | 17 +-
.../SyntheticAnimationEvent.js | 15 +-
.../SyntheticClipboardEvent.js | 23 +-
.../SyntheticCompositionEvent.js | 12 +-
.../syntheticEvents/SyntheticDragEvent.js | 15 +-
.../syntheticEvents/SyntheticFocusEvent.js | 15 +-
.../syntheticEvents/SyntheticInputEvent.js | 15 +-
.../syntheticEvents/SyntheticKeyboardEvent.js | 15 +-
.../syntheticEvents/SyntheticMouseEvent.js | 36 +-
.../syntheticEvents/SyntheticTouchEvent.js | 15 +-
.../SyntheticTransitionEvent.js | 15 +-
.../syntheticEvents/SyntheticUIEvent.js | 15 +-
.../syntheticEvents/SyntheticWheelEvent.js | 38 +-
.../__tests__/SyntheticClipboardEvent-test.js | 13 +-
.../__tests__/SyntheticEvent-test.js | 91 +-
.../__tests__/SyntheticWheelEvent-test.js | 1 -
.../dom/client/utils/DOMChildrenOperations.js | 51 +-
src/renderers/dom/client/utils/DOMLazyTree.js | 59 +-
.../dom/client/utils/ViewportMetrics.js | 2 -
.../utils/__tests__/getEventCharCode-test.js | 13 +-
.../getNodeForCharacterOffset-test.js | 14 +-
.../utils/__tests__/setInnerHTML-test.js | 8 +-
src/renderers/dom/client/utils/getEventKey.js | 38 +-
.../dom/client/utils/getEventModifierState.js | 8 +-
.../client/utils/getTextContentAccessor.js | 6 +-
.../utils/getVendorPrefixedEventName.js | 3 +-
.../dom/client/utils/isEventSupported.js | 6 +-
.../dom/client/utils/setInnerHTML.js | 37 +-
.../dom/client/utils/setTextContent.js | 8 +-
.../dom/client/validateDOMNesting.js | 234 ++-
.../dom/client/wrappers/LinkedValueUtils.js | 58 +-
.../dom/client/wrappers/ReactDOMInput.js | 120 +-
.../dom/client/wrappers/ReactDOMOption.js | 12 +-
.../dom/client/wrappers/ReactDOMSelect.js | 24 +-
.../dom/client/wrappers/ReactDOMTextarea.js | 21 +-
.../wrappers/__tests__/ReactDOMInput-test.js | 315 ++--
.../wrappers/__tests__/ReactDOMOption-test.js | 17 +-
.../wrappers/__tests__/ReactDOMSelect-test.js | 272 ++--
.../__tests__/ReactDOMTextarea-test.js | 45 +-
src/renderers/dom/fiber/ReactDOMFiber.js | 60 +-
.../dom/server/ReactMarkupChecksum.js | 5 +-
.../dom/server/ReactServerRendering.js | 13 +-
.../server/ReactServerRenderingTransaction.js | 17 +-
.../dom/server/ReactServerUpdateQueue.js | 30 +-
.../__tests__/ReactServerRendering-test.js | 174 ++-
.../dom/shared/CSSPropertyOperations.js | 16 +-
src/renderers/dom/shared/DOMProperty.js | 42 +-
.../dom/shared/DOMPropertyOperations.js | 54 +-
src/renderers/dom/shared/Danger.js | 14 +-
.../dom/shared/HTMLDOMPropertyConfig.js | 2 +-
.../ReactComponentBrowserEnvironment.js | 8 +-
src/renderers/dom/shared/ReactDOMComponent.js | 359 +++--
.../dom/shared/ReactDOMContainerInfo.js | 11 +-
.../dom/shared/ReactDOMEmptyComponent.js | 6 +-
.../dom/shared/ReactDOMTextComponent.js | 19 +-
.../dom/shared/ReactDefaultInjection.js | 33 +-
.../dom/shared/SVGDOMPropertyConfig.js | 2 +-
.../dom/shared/__tests__/CSSProperty-test.js | 1 -
.../__tests__/CSSPropertyOperations-test.js | 135 +-
.../__tests__/DOMPropertyOperations-test.js | 295 ++--
.../__tests__/ReactDOMComponent-test.js | 351 +++--
.../__tests__/ReactDOMInvalidARIAHook-test.js | 16 +-
.../escapeTextContentForBrowser-test.js | 10 +-
.../quoteAttributeValueForBrowser-test.js | 10 +-
.../dom/shared/dangerousStyleValue.js | 13 +-
.../dom/shared/escapeTextContentForBrowser.js | 7 +-
.../shared/hooks/ReactDOMInvalidARIAHook.js | 24 +-
.../hooks/ReactDOMNullInputValuePropHook.js | 18 +-
.../hooks/ReactDOMUnknownPropertyHook.js | 51 +-
src/renderers/native/NativeMethodsMixin.js | 56 +-
src/renderers/native/ReactNative.js | 5 +-
.../native/ReactNativeAttributePayload.js | 183 ++-
.../native/ReactNativeBaseComponent.js | 31 +-
.../native/ReactNativeBridgeEventPlugin.js | 12 +-
.../native/ReactNativeComponentEnvironment.js | 5 +-
.../native/ReactNativeDOMIDOperations.js | 2 +-
.../native/ReactNativeDefaultInjection.js | 22 +-
.../native/ReactNativeEventEmitter.js | 26 +-
.../ReactNativeGlobalResponderHandler.js | 5 +-
src/renderers/native/ReactNativeMount.js | 44 +-
.../native/ReactNativeReconcileTransaction.js | 2 +-
src/renderers/native/ReactNativeTagHandles.js | 3 +-
.../native/ReactNativeTextComponent.js | 28 +-
.../native/ReactNativeTreeTraversal.js | 4 +-
.../InitializeJavaScriptAppEngine.js | 1 +
src/renderers/native/__mocks__/deepDiffer.js | 6 +-
.../deepFreezeAndThrowOnMutationInDev.js | 2 +-
.../native/__mocks__/flattenStyle.js | 2 +-
.../ReactNativeAttributePayload-test.js | 295 ++--
.../__tests__/ReactNativeEvents-test.js | 9 +-
.../native/__tests__/ReactNativeMount-test.js | 7 +-
.../native/createReactNativeComponentClass.js | 4 +-
src/renderers/native/findNodeHandle.js | 27 +-
src/renderers/noop/ReactNoop.js | 99 +-
src/renderers/shared/ReactDebugTool.js | 61 +-
src/renderers/shared/ReactPerf.js | 45 +-
.../shared/__tests__/ReactDebugTool-test.js | 3 +-
.../shared/__tests__/ReactPerf-test.js | 254 +--
src/renderers/shared/fiber/ReactChildFiber.js | 125 +-
src/renderers/shared/fiber/ReactFiber.js | 54 +-
.../shared/fiber/ReactFiberBeginWork.js | 156 +-
.../shared/fiber/ReactFiberCommitWork.js | 32 +-
.../shared/fiber/ReactFiberCompleteWork.js | 58 +-
.../shared/fiber/ReactFiberReconciler.js | 76 +-
src/renderers/shared/fiber/ReactFiberRoot.js | 6 +-
.../shared/fiber/ReactFiberScheduler.js | 101 +-
.../shared/fiber/ReactFiberUpdateQueue.js | 28 +-
.../shared/fiber/ReactReifiedYield.js | 20 +-
.../fiber/__tests__/ReactCoroutine-test.js | 24 +-
.../fiber/__tests__/ReactIncremental-test.js | 63 +-
.../ReactIncrementalSideEffects-test.js | 76 +-
.../shared/fiber/isomorphic/ReactCoroutine.js | 35 +-
.../shared/fiber/isomorphic/ReactTypes.js | 9 +-
.../hooks/ReactHostOperationHistoryHook.js | 21 +-
.../hooks/ReactInvalidSetStateWarningHook.js | 2 +-
.../__tests__/ReactComponentTreeHook-test.js | 1284 ++++++++-------
.../ReactComponentTreeHook-test.native.js | 1391 ++++++++++-------
.../ReactHostOperationHistoryHook-test.js | 725 +++++----
.../shared/shared/ReactInstanceMap.js | 2 -
.../shared/shouldUpdateReactComponent.js | 2 +-
.../shared/stack/event/EventPluginHub.js | 38 +-
.../shared/stack/event/EventPluginRegistry.js | 49 +-
.../shared/stack/event/EventPluginUtils.js | 51 +-
.../shared/stack/event/EventPropagators.js | 34 +-
.../shared/stack/event/PluginModuleType.js | 11 +-
.../shared/stack/event/SyntheticEvent.js | 63 +-
.../event/__tests__/EventPluginHub-test.js | 2 +-
.../__tests__/EventPluginRegistry-test.js | 46 +-
.../eventPlugins/ResponderEventPlugin.js | 122 +-
.../eventPlugins/ResponderSyntheticEvent.js | 15 +-
.../ResponderTouchHistoryStore.js | 26 +-
.../event/eventPlugins/TouchHistoryMath.js | 88 +-
.../__tests__/ResponderEventPlugin-test.js | 629 +++++---
.../stack/reconciler/ReactChildReconciler.js | 42 +-
.../reconciler/ReactComponentEnvironment.js | 4 +-
.../reconciler/ReactCompositeComponent.js | 268 ++--
.../ReactDefaultBatchingStrategy.js | 14 +-
.../reconciler/ReactEventEmitterMixin.js | 12 +-
.../stack/reconciler/ReactHostComponent.js | 2 +-
.../stack/reconciler/ReactMultiChild.js | 64 +-
.../reconciler/ReactMultiChildUpdateTypes.js | 10 +-
.../shared/stack/reconciler/ReactOwner.js | 26 +-
.../stack/reconciler/ReactReconciler.js | 58 +-
.../shared/stack/reconciler/ReactRef.js | 10 +-
.../reconciler/ReactSimpleEmptyComponent.js | 8 +-
.../stack/reconciler/ReactUpdateQueue.js | 42 +-
.../shared/stack/reconciler/ReactUpdates.js | 78 +-
.../__tests__/ReactChildReconciler-test.js | 16 +-
.../__tests__/ReactComponent-test.js | 109 +-
.../__tests__/ReactComponentLifeCycle-test.js | 132 +-
.../__tests__/ReactCompositeComponent-test.js | 128 +-
...actCompositeComponentDOMMinimalism-test.js | 20 +-
...ReactCompositeComponentNestedState-test.js | 37 +-
.../ReactCompositeComponentState-test.js | 162 +-
.../__tests__/ReactEmptyComponent-test.js | 107 +-
.../__tests__/ReactErrorBoundaries-test.js | 10 +-
.../__tests__/ReactIdentity-test.js | 39 +-
.../__tests__/ReactMockedComponent-test.js | 14 +-
.../__tests__/ReactMultiChild-test.js | 25 +-
.../ReactMultiChildReconcile-test.js | 89 +-
.../__tests__/ReactMultiChildText-test.js | 207 ++-
.../__tests__/ReactStatelessComponent-test.js | 27 +-
.../reconciler/__tests__/ReactUpdates-test.js | 62 +-
.../__tests__/refs-destruction-test.js | 32 +-
.../stack/reconciler/__tests__/refs-test.js | 62 +-
.../reconciler/instantiateReactComponent.js | 31 +-
src/renderers/shared/utils/CallbackQueue.js | 2 +-
src/renderers/shared/utils/ReactErrorUtils.js | 10 +-
src/renderers/shared/utils/Transaction.js | 37 +-
.../utils/__tests__/Transaction-test.js | 47 +-
.../utils/__tests__/accumulateInto-test.js | 3 +-
.../shared/utils/__tests__/adler32-test.js | 4 +-
src/renderers/shared/utils/accumulate.js | 7 +-
src/renderers/shared/utils/accumulateInto.js | 7 +-
src/renderers/shared/utils/adler32.js | 7 +-
.../shared/utils/forEachAccumulated.js | 2 +-
.../shared/utils/isTextInputElement.js | 28 +-
src/renderers/testing/ReactShallowRenderer.js | 62 +-
src/renderers/testing/ReactTestMount.js | 44 +-
.../testing/ReactTestReconcileTransaction.js | 4 +-
src/renderers/testing/ReactTestRenderer.js | 14 +-
.../testing/ReactTestTextComponent.js | 2 +-
.../__tests__/ReactTestRenderer-test.js | 90 +-
.../types/ReactPropTypeLocationNames.js | 2 +-
src/shared/types/ReactPropTypeLocations.js | 5 +-
src/shared/types/checkReactTypeSpec.js | 35 +-
src/shared/utils/KeyEscapeUtils.js | 23 +-
src/shared/utils/PooledClass.js | 4 +-
.../utils/__tests__/PooledClass-test.js | 50 +-
.../__tests__/reactProdInvariant-test.js | 18 +-
.../__tests__/traverseAllChildren-test.js | 221 ++-
src/shared/utils/deprecated.js | 7 +-
src/shared/utils/flattenChildren.js | 25 +-
src/shared/utils/getIteratorFn.js | 8 +-
src/shared/utils/reactProdInvariant.js | 17 +-
src/shared/utils/traverseAllChildren.js | 53 +-
src/test/ReactComponentTreeTestUtils.js | 20 +-
src/test/ReactTestUtils.js | 123 +-
src/test/__tests__/ReactTestUtils-test.js | 80 +-
.../__tests__/reactComponentExpect-test.js | 1 -
src/test/getTestDocument.js | 3 +-
src/test/reactComponentExpect.js | 30 +-
src/umd/ReactUMDEntry.js | 2 +-
src/umd/ReactWithAddonsUMDEntry.js | 2 +-
.../ReactAddonsDOMDependenciesUMDShim.js | 9 +-
src/umd/shims/getNextDebugIDUMDShim.js | 1 -
yarn.lock | 101 +-
287 files changed, 9348 insertions(+), 7893 deletions(-)
diff --git a/package.json b/package.json
index 2142490155..96f4beb4f3 100644
--- a/package.json
+++ b/package.json
@@ -71,6 +71,7 @@
"merge-stream": "^1.0.0",
"object-assign": "^4.1.1",
"platform": "^1.1.0",
+ "prettier": "^1.2.2",
"prop-types": "15.5.7",
"run-sequence": "^1.1.4",
"through2": "^2.0.0",
diff --git a/src/addons/ReactFragment.js b/src/addons/ReactFragment.js
index 5d83e84533..0ed35d4ae6 100644
--- a/src/addons/ReactFragment.js
+++ b/src/addons/ReactFragment.js
@@ -41,7 +41,7 @@ var ReactFragment = {
warning(
false,
'React.addons.createFragment only accepts a single object. Got: %s',
- object
+ object,
);
return object;
}
@@ -49,7 +49,7 @@ var ReactFragment = {
warning(
false,
'React.addons.createFragment does not accept a ReactElement ' +
- 'without a wrapper object.'
+ 'without a wrapper object.',
);
return object;
}
@@ -57,7 +57,7 @@ var ReactFragment = {
invariant(
object.nodeType !== 1,
'React.addons.createFragment(...): Encountered an invalid child; DOM ' +
- 'elements are not valid children of React components.'
+ 'elements are not valid children of React components.',
);
var result = [];
@@ -68,7 +68,7 @@ var ReactFragment = {
warning(
false,
'React.addons.createFragment(...): Child objects should have ' +
- 'non-numeric keys so ordering is preserved.'
+ 'non-numeric keys so ordering is preserved.',
);
warnedAboutNumeric = true;
}
@@ -77,7 +77,7 @@ var ReactFragment = {
object[key],
result,
key,
- emptyFunction.thatReturnsArgument
+ emptyFunction.thatReturnsArgument,
);
}
diff --git a/src/addons/ReactWithAddons.js b/src/addons/ReactWithAddons.js
index 4d556e9223..8cf081c982 100644
--- a/src/addons/ReactWithAddons.js
+++ b/src/addons/ReactWithAddons.js
@@ -14,8 +14,7 @@
var LinkedStateMixin = require('LinkedStateMixin');
var React = require('React');
var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies');
-var ReactComponentWithPureRenderMixin =
- require('ReactComponentWithPureRenderMixin');
+var ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin');
var ReactCSSTransitionGroup = require('ReactCSSTransitionGroup');
var ReactFragment = require('ReactFragment');
var ReactTransitionGroup = require('ReactTransitionGroup');
diff --git a/src/addons/__tests__/ReactFragment-test.js b/src/addons/__tests__/ReactFragment-test.js
index 0f278686a3..1fc6f03d2a 100644
--- a/src/addons/__tests__/ReactFragment-test.js
+++ b/src/addons/__tests__/ReactFragment-test.js
@@ -16,7 +16,6 @@ var ReactDOM;
var ReactFragment;
describe('ReactFragment', () => {
-
beforeEach(() => {
React = require('React');
ReactDOM = require('ReactDOM');
@@ -33,9 +32,9 @@ describe('ReactFragment', () => {
var container = document.createElement('div');
expect(() => ReactDOM.render(element, container)).toThrowError(
'Objects are not valid as a React child (found: object with keys ' +
- '{x, y, z}). If you meant to render a collection of children, use an ' +
- 'array instead or wrap the object using createFragment(object) from ' +
- 'the React add-ons.'
+ '{x, y, z}). If you meant to render a collection of children, use an ' +
+ 'array instead or wrap the object using createFragment(object) from ' +
+ 'the React add-ons.',
);
});
@@ -53,9 +52,9 @@ describe('ReactFragment', () => {
var container = document.createElement('div');
expect(() => ReactDOM.render(, container)).toThrowError(
'Objects are not valid as a React child (found: object with keys ' +
- '{a, b, c}). If you meant to render a collection of children, use an ' +
- 'array instead or wrap the object using createFragment(object) from ' +
- 'the React add-ons. Check the render method of `Foo`.'
+ '{a, b, c}). If you meant to render a collection of children, use an ' +
+ 'array instead or wrap the object using createFragment(object) from ' +
+ 'the React add-ons. Check the render method of `Foo`.',
);
});
@@ -64,9 +63,9 @@ describe('ReactFragment', () => {
var container = document.createElement('div');
expect(() => ReactDOM.render(
{oldEl}
, container)).toThrowError(
'Objects are not valid as a React child (found: object with keys ' +
- '{_isReactElement, type, props}). It looks like you\'re using an ' +
- 'element created by a different version of React. Make sure to use ' +
- 'only one copy of React.'
+ "{_isReactElement, type, props}). It looks like you're using an " +
+ 'element created by a different version of React. Make sure to use ' +
+ 'only one copy of React.',
);
});
@@ -77,7 +76,7 @@ describe('ReactFragment', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'Child objects should have non-numeric keys so ordering is preserved.'
+ 'Child objects should have non-numeric keys so ordering is preserved.',
);
});
@@ -86,7 +85,7 @@ describe('ReactFragment', () => {
ReactFragment.create(null);
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'React.addons.createFragment only accepts a single object.'
+ 'React.addons.createFragment only accepts a single object.',
);
});
@@ -95,7 +94,7 @@ describe('ReactFragment', () => {
ReactFragment.create([]);
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'React.addons.createFragment only accepts a single object.'
+ 'React.addons.createFragment only accepts a single object.',
);
});
@@ -105,8 +104,7 @@ describe('ReactFragment', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'React.addons.createFragment does not accept a ReactElement without a ' +
- 'wrapper object.'
+ 'wrapper object.',
);
});
-
});
diff --git a/src/addons/__tests__/renderSubtreeIntoContainer-test.js b/src/addons/__tests__/renderSubtreeIntoContainer-test.js
index 1ee3bd6a93..643c851ff7 100644
--- a/src/addons/__tests__/renderSubtreeIntoContainer-test.js
+++ b/src/addons/__tests__/renderSubtreeIntoContainer-test.js
@@ -17,7 +17,6 @@ var ReactTestUtils = require('ReactTestUtils');
var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer');
describe('renderSubtreeIntoContainer', () => {
-
it('should pass context when rendering subtree elsewhere', () => {
var portal = document.createElement('div');
@@ -47,9 +46,11 @@ describe('renderSubtreeIntoContainer', () => {
}
componentDidMount() {
- expect(function() {
- renderSubtreeIntoContainer(this, , portal);
- }.bind(this)).not.toThrow();
+ expect(
+ function() {
+ renderSubtreeIntoContainer(this, , portal);
+ }.bind(this),
+ ).not.toThrow();
}
}
@@ -195,5 +196,4 @@ describe('renderSubtreeIntoContainer', () => {
ReactDOM.render(, container);
expect(portal.firstChild.innerHTML).toBe('changed-changed');
});
-
});
diff --git a/src/addons/__tests__/update-test.js b/src/addons/__tests__/update-test.js
index fe557da38f..15cf7ff75d 100644
--- a/src/addons/__tests__/update-test.js
+++ b/src/addons/__tests__/update-test.js
@@ -14,7 +14,6 @@
var update = require('update');
describe('update', () => {
-
describe('$push', () => {
it('pushes', () => {
expect(update([1], {$push: [7]})).toEqual([1, 7]);
@@ -27,12 +26,12 @@ describe('update', () => {
it('only pushes an array', () => {
expect(update.bind(null, [], {$push: 7})).toThrowError(
'update(): expected spec of $push to be an array; got 7. Did you ' +
- 'forget to wrap your parameter in an array?'
+ 'forget to wrap your parameter in an array?',
);
});
it('only pushes unto an array', () => {
expect(update.bind(null, 1, {$push: 7})).toThrowError(
- 'update(): expected target of $push to be an array; got 1.'
+ 'update(): expected target of $push to be an array; got 1.',
);
});
});
@@ -49,12 +48,12 @@ describe('update', () => {
it('only unshifts an array', () => {
expect(update.bind(null, [], {$unshift: 7})).toThrowError(
'update(): expected spec of $unshift to be an array; got 7. Did you ' +
- 'forget to wrap your parameter in an array?'
+ 'forget to wrap your parameter in an array?',
);
});
it('only unshifts unto an array', () => {
expect(update.bind(null, 1, {$unshift: 7})).toThrowError(
- 'update(): expected target of $unshift to be an array; got 1.'
+ 'update(): expected target of $unshift to be an array; got 1.',
);
});
});
@@ -71,16 +70,16 @@ describe('update', () => {
it('only splices an array of arrays', () => {
expect(update.bind(null, [], {$splice: 1})).toThrowError(
'update(): expected spec of $splice to be an array of arrays; got 1. ' +
- 'Did you forget to wrap your parameters in an array?'
+ 'Did you forget to wrap your parameters in an array?',
);
expect(update.bind(null, [], {$splice: [1]})).toThrowError(
'update(): expected spec of $splice to be an array of arrays; got 1. ' +
- 'Did you forget to wrap your parameters in an array?'
+ 'Did you forget to wrap your parameters in an array?',
);
});
it('only splices unto an array', () => {
expect(update.bind(null, 1, {$splice: 7})).toThrowError(
- 'Expected $splice target to be an array; got 1'
+ 'Expected $splice target to be an array; got 1',
);
});
});
@@ -96,12 +95,12 @@ describe('update', () => {
});
it('only merges with an object', () => {
expect(update.bind(null, {}, {$merge: 7})).toThrowError(
- 'update(): $merge expects a spec of type \'object\'; got 7'
+ "update(): $merge expects a spec of type 'object'; got 7",
);
});
it('only merges with an object', () => {
expect(update.bind(null, 7, {$merge: {a: 'b'}})).toThrowError(
- 'update(): $merge expects a target of type \'object\'; got 7'
+ "update(): $merge expects a target of type 'object'; got 7",
);
});
});
@@ -131,32 +130,37 @@ describe('update', () => {
});
it('only applies a function', () => {
expect(update.bind(null, 2, {$apply: 123})).toThrowError(
- 'update(): expected spec of $apply to be a function; got 123.'
+ 'update(): expected spec of $apply to be a function; got 123.',
);
});
});
it('should support deep updates', () => {
- expect(update({
- a: 'b',
- c: {
- d: 'e',
- f: [1],
- g: [2],
- h: [3],
- i: {j: 'k'},
- l: 4,
- },
- }, {
- c: {
- d: {$set: 'm'},
- f: {$push: [5]},
- g: {$unshift: [6]},
- h: {$splice: [[0, 1, 7]]},
- i: {$merge: {n: 'o'}},
- l: {$apply: (x) => x * 2},
- },
- })).toEqual({
+ expect(
+ update(
+ {
+ a: 'b',
+ c: {
+ d: 'e',
+ f: [1],
+ g: [2],
+ h: [3],
+ i: {j: 'k'},
+ l: 4,
+ },
+ },
+ {
+ c: {
+ d: {$set: 'm'},
+ f: {$push: [5]},
+ g: {$unshift: [6]},
+ h: {$splice: [[0, 1, 7]]},
+ i: {$merge: {n: 'o'}},
+ l: {$apply: x => x * 2},
+ },
+ },
+ ),
+ ).toEqual({
a: 'b',
c: {
d: 'm',
@@ -172,14 +176,14 @@ describe('update', () => {
it('should require a command', () => {
expect(update.bind(null, {a: 'b'}, {a: 'c'})).toThrowError(
'update(): You provided a key path to update() that did not contain ' +
- 'one of $push, $unshift, $splice, $set, $merge, $apply. Did you ' +
- 'forget to include {$set: ...}?'
+ 'one of $push, $unshift, $splice, $set, $merge, $apply. Did you ' +
+ 'forget to include {$set: ...}?',
);
});
it('should perform safe hasOwnProperty check', () => {
- expect(update({}, {'hasOwnProperty': {$set: 'a'}})).toEqual({
- 'hasOwnProperty': 'a',
+ expect(update({}, {hasOwnProperty: {$set: 'a'}})).toEqual({
+ hasOwnProperty: 'a',
});
});
});
diff --git a/src/addons/link/LinkedStateMixin.js b/src/addons/link/LinkedStateMixin.js
index 9e446f4836..4a646095df 100644
--- a/src/addons/link/LinkedStateMixin.js
+++ b/src/addons/link/LinkedStateMixin.js
@@ -30,7 +30,7 @@ var LinkedStateMixin = {
linkState: function(key) {
return new ReactLink(
this.state[key],
- ReactStateSetters.createStateKeySetter(this, key)
+ ReactStateSetters.createStateKeySetter(this, key),
);
},
};
diff --git a/src/addons/link/ReactLink.js b/src/addons/link/ReactLink.js
index d327b4f8ec..22e71d5512 100644
--- a/src/addons/link/ReactLink.js
+++ b/src/addons/link/ReactLink.js
@@ -58,9 +58,9 @@ function ReactLink(value, requestChange) {
*/
function createLinkTypeChecker(linkType) {
var shapes = {
- value: linkType === undefined ?
- React.PropTypes.any.isRequired :
- linkType.isRequired,
+ value: linkType === undefined
+ ? React.PropTypes.any.isRequired
+ : linkType.isRequired,
requestChange: React.PropTypes.func.isRequired,
};
return React.PropTypes.shape(shapes);
diff --git a/src/addons/transitions/ReactCSSTransitionGroup.js b/src/addons/transitions/ReactCSSTransitionGroup.js
index 517c4faee2..4c1fb3b6e4 100644
--- a/src/addons/transitions/ReactCSSTransitionGroup.js
+++ b/src/addons/transitions/ReactCSSTransitionGroup.js
@@ -28,16 +28,19 @@ function createTransitionTimeoutPropValidator(transitionType) {
// If no timeout duration is provided
if (props[timeoutPropName] == null) {
return new Error(
- timeoutPropName + ' wasn\'t supplied to ReactCSSTransitionGroup: ' +
- 'this can cause unreliable animations and won\'t be supported in ' +
- 'a future version of React. See ' +
- 'https://fb.me/react-animation-transition-group-timeout for more ' +
- 'information.'
+ timeoutPropName +
+ " wasn't supplied to ReactCSSTransitionGroup: " +
+ "this can cause unreliable animations and won't be supported in " +
+ 'a future version of React. See ' +
+ 'https://fb.me/react-animation-transition-group-timeout for more ' +
+ 'information.',
);
- // If the duration isn't a number
+ // If the duration isn't a number
} else if (typeof props[timeoutPropName] !== 'number') {
- return new Error(timeoutPropName + ' must be a number (in milliseconds)');
+ return new Error(
+ timeoutPropName + ' must be a number (in milliseconds)',
+ );
}
}
};
@@ -68,7 +71,7 @@ class ReactCSSTransitionGroup extends React.Component {
transitionLeave: true,
};
- _wrapChild = (child) => {
+ _wrapChild = child => {
// We need to provide this childFactory so that
// ReactCSSTransitionGroupChild can receive updates to name, enter, and
// leave while it is leaving.
@@ -83,14 +86,14 @@ class ReactCSSTransitionGroup extends React.Component {
enterTimeout: this.props.transitionEnterTimeout,
leaveTimeout: this.props.transitionLeaveTimeout,
},
- child
+ child,
);
};
render() {
return React.createElement(
ReactTransitionGroup,
- Object.assign({}, this.props, {childFactory: this._wrapChild})
+ Object.assign({}, this.props, {childFactory: this._wrapChild}),
);
}
}
diff --git a/src/addons/transitions/ReactCSSTransitionGroupChild.js b/src/addons/transitions/ReactCSSTransitionGroupChild.js
index 536d0a2543..94bf1fd6f0 100644
--- a/src/addons/transitions/ReactCSSTransitionGroupChild.js
+++ b/src/addons/transitions/ReactCSSTransitionGroupChild.js
@@ -17,7 +17,6 @@ var ReactAddonsDOMDependencies = require('ReactAddonsDOMDependencies');
var propTypesFactory = require('prop-types/factory');
var PropTypes = propTypesFactory(React.isValidElement);
-
var CSSCore = require('CSSCore');
var ReactTransitionEvents = require('ReactTransitionEvents');
@@ -67,8 +66,10 @@ class ReactCSSTransitionGroupChild extends React.Component {
return;
}
- var className = this.props.name[animationType] || this.props.name + '-' + animationType;
- var activeClassName = this.props.name[animationType + 'Active'] || className + '-active';
+ var className =
+ this.props.name[animationType] || this.props.name + '-' + animationType;
+ var activeClassName =
+ this.props.name[animationType + 'Active'] || className + '-active';
var timeout = null;
var endListener = function(e) {
@@ -149,29 +150,29 @@ class ReactCSSTransitionGroupChild extends React.Component {
this.classNameAndNodeQueue.length = 0;
}
- componentWillAppear = (done) => {
+ componentWillAppear = done => {
if (this.props.appear) {
this.transition('appear', done, this.props.appearTimeout);
} else {
done();
}
- }
+ };
- componentWillEnter = (done) => {
+ componentWillEnter = done => {
if (this.props.enter) {
this.transition('enter', done, this.props.enterTimeout);
} else {
done();
}
- }
+ };
- componentWillLeave = (done) => {
+ componentWillLeave = done => {
if (this.props.leave) {
this.transition('leave', done, this.props.leaveTimeout);
} else {
done();
}
- }
+ };
render() {
return onlyChild(this.props.children);
diff --git a/src/addons/transitions/ReactTransitionChildMapping.js b/src/addons/transitions/ReactTransitionChildMapping.js
index a01bd42526..4ba6795dfc 100644
--- a/src/addons/transitions/ReactTransitionChildMapping.js
+++ b/src/addons/transitions/ReactTransitionChildMapping.js
@@ -86,7 +86,7 @@ var ReactTransitionChildMapping = {
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
var pendingNextKey = nextKeysPending[nextKey][i];
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(
- pendingNextKey
+ pendingNextKey,
);
}
}
diff --git a/src/addons/transitions/ReactTransitionGroup.js b/src/addons/transitions/ReactTransitionGroup.js
index f067a7efb4..cd576aa852 100644
--- a/src/addons/transitions/ReactTransitionGroup.js
+++ b/src/addons/transitions/ReactTransitionGroup.js
@@ -59,14 +59,14 @@ class ReactTransitionGroup extends React.Component {
componentWillReceiveProps(nextProps) {
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(
- nextProps.children
+ nextProps.children,
);
var prevChildMapping = this.state.children;
this.setState({
children: ReactTransitionChildMapping.mergeChildMappings(
prevChildMapping,
- nextChildMapping
+ nextChildMapping,
),
});
@@ -74,16 +74,22 @@ class ReactTransitionGroup extends React.Component {
for (key in nextChildMapping) {
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
- if (nextChildMapping[key] && !hasPrev &&
- !this.currentlyTransitioningKeys[key]) {
+ if (
+ nextChildMapping[key] &&
+ !hasPrev &&
+ !this.currentlyTransitioningKeys[key]
+ ) {
this.keysToEnter.push(key);
}
}
for (key in prevChildMapping) {
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
- if (prevChildMapping[key] && !hasNext &&
- !this.currentlyTransitioningKeys[key]) {
+ if (
+ prevChildMapping[key] &&
+ !hasNext &&
+ !this.currentlyTransitioningKeys[key]
+ ) {
this.keysToLeave.push(key);
}
}
@@ -101,21 +107,19 @@ class ReactTransitionGroup extends React.Component {
keysToLeave.forEach(this.performLeave);
}
- performAppear = (key) => {
+ performAppear = key => {
this.currentlyTransitioningKeys[key] = true;
var component = this.refs[key];
if (component.componentWillAppear) {
- component.componentWillAppear(
- this._handleDoneAppearing.bind(this, key)
- );
+ component.componentWillAppear(this._handleDoneAppearing.bind(this, key));
} else {
this._handleDoneAppearing(key);
}
};
- _handleDoneAppearing = (key) => {
+ _handleDoneAppearing = key => {
var component = this.refs[key];
if (component.componentDidAppear) {
component.componentDidAppear();
@@ -124,7 +128,7 @@ class ReactTransitionGroup extends React.Component {
delete this.currentlyTransitioningKeys[key];
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
- this.props.children
+ this.props.children,
);
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
@@ -133,21 +137,19 @@ class ReactTransitionGroup extends React.Component {
}
};
- performEnter = (key) => {
+ performEnter = key => {
this.currentlyTransitioningKeys[key] = true;
var component = this.refs[key];
if (component.componentWillEnter) {
- component.componentWillEnter(
- this._handleDoneEntering.bind(this, key)
- );
+ component.componentWillEnter(this._handleDoneEntering.bind(this, key));
} else {
this._handleDoneEntering(key);
}
};
- _handleDoneEntering = (key) => {
+ _handleDoneEntering = key => {
var component = this.refs[key];
if (component.componentDidEnter) {
component.componentDidEnter();
@@ -156,7 +158,7 @@ class ReactTransitionGroup extends React.Component {
delete this.currentlyTransitioningKeys[key];
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
- this.props.children
+ this.props.children,
);
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
@@ -165,7 +167,7 @@ class ReactTransitionGroup extends React.Component {
}
};
- performLeave = (key) => {
+ performLeave = key => {
this.currentlyTransitioningKeys[key] = true;
var component = this.refs[key];
@@ -179,7 +181,7 @@ class ReactTransitionGroup extends React.Component {
}
};
- _handleDoneLeaving = (key) => {
+ _handleDoneLeaving = key => {
var component = this.refs[key];
if (component.componentDidLeave) {
@@ -189,7 +191,7 @@ class ReactTransitionGroup extends React.Component {
delete this.currentlyTransitioningKeys[key];
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
- this.props.children
+ this.props.children,
);
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
@@ -216,10 +218,12 @@ class ReactTransitionGroup extends React.Component {
// already been removed. In case you need this behavior you can provide
// a childFactory function to wrap every child, even the ones that are
// leaving.
- childrenToRender.push(React.cloneElement(
- this.props.childFactory(child),
- {ref: key, key: key}
- ));
+ childrenToRender.push(
+ React.cloneElement(this.props.childFactory(child), {
+ ref: key,
+ key: key,
+ }),
+ );
}
}
@@ -235,11 +239,7 @@ class ReactTransitionGroup extends React.Component {
delete props.transitionAppearTimeout;
delete props.component;
- return React.createElement(
- this.props.component,
- props,
- childrenToRender
- );
+ return React.createElement(this.props.component, props, childrenToRender);
}
}
diff --git a/src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js b/src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js
index 621549691f..b6c7058989 100644
--- a/src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js
+++ b/src/addons/transitions/__tests__/ReactTransitionChildMapping-test.js
@@ -27,7 +27,7 @@ describe('ReactTransitionChildMapping', () => {
var two = ;
var component =
{one}{two}
;
expect(
- ReactTransitionChildMapping.getChildMapping(component.props.children)
+ ReactTransitionChildMapping.getChildMapping(component.props.children),
).toEqual({
'.$one': one,
'.$two': two,
diff --git a/src/addons/update.js b/src/addons/update.js
index 6e3c41785a..ce5fa018d1 100644
--- a/src/addons/update.js
+++ b/src/addons/update.js
@@ -9,7 +9,7 @@
* @providesModule update
*/
- /* global hasOwnProperty:true */
+/* global hasOwnProperty:true */
'use strict';
@@ -53,15 +53,15 @@ function invariantArrayCase(value, spec, command) {
Array.isArray(value),
'update(): expected target of %s to be an array; got %s.',
command,
- value
+ value,
);
var specValue = spec[command];
invariant(
Array.isArray(specValue),
'update(): expected spec of %s to be an array; got %s. ' +
- 'Did you forget to wrap your parameter in an array?',
+ 'Did you forget to wrap your parameter in an array?',
command,
- specValue
+ specValue,
);
}
@@ -73,16 +73,16 @@ function update(value, spec) {
invariant(
typeof spec === 'object',
'update(): You provided a key path to update() that did not contain one ' +
- 'of %s. Did you forget to include {%s: ...}?',
+ 'of %s. Did you forget to include {%s: ...}?',
ALL_COMMANDS_LIST.join(', '),
- COMMAND_SET
+ COMMAND_SET,
);
if (hasOwnProperty.call(spec, COMMAND_SET)) {
invariant(
Object.keys(spec).length === 1,
'Cannot have more than one key in an object with %s',
- COMMAND_SET
+ COMMAND_SET,
);
return spec[COMMAND_SET];
@@ -94,15 +94,15 @@ function update(value, spec) {
var mergeObj = spec[COMMAND_MERGE];
invariant(
mergeObj && typeof mergeObj === 'object',
- 'update(): %s expects a spec of type \'object\'; got %s',
+ "update(): %s expects a spec of type 'object'; got %s",
COMMAND_MERGE,
- mergeObj
+ mergeObj,
);
invariant(
nextValue && typeof nextValue === 'object',
- 'update(): %s expects a target of type \'object\'; got %s',
+ "update(): %s expects a target of type 'object'; got %s",
COMMAND_MERGE,
- nextValue
+ nextValue,
);
Object.assign(nextValue, spec[COMMAND_MERGE]);
}
@@ -126,22 +126,22 @@ function update(value, spec) {
Array.isArray(value),
'Expected %s target to be an array; got %s',
COMMAND_SPLICE,
- value
+ value,
);
invariant(
Array.isArray(spec[COMMAND_SPLICE]),
'update(): expected spec of %s to be an array of arrays; got %s. ' +
- 'Did you forget to wrap your parameters in an array?',
+ 'Did you forget to wrap your parameters in an array?',
COMMAND_SPLICE,
- spec[COMMAND_SPLICE]
+ spec[COMMAND_SPLICE],
);
spec[COMMAND_SPLICE].forEach(function(args) {
invariant(
Array.isArray(args),
'update(): expected spec of %s to be an array of arrays; got %s. ' +
- 'Did you forget to wrap your parameters in an array?',
+ 'Did you forget to wrap your parameters in an array?',
COMMAND_SPLICE,
- spec[COMMAND_SPLICE]
+ spec[COMMAND_SPLICE],
);
nextValue.splice.apply(nextValue, args);
});
@@ -152,7 +152,7 @@ function update(value, spec) {
typeof spec[COMMAND_APPLY] === 'function',
'update(): expected spec of %s to be a function; got %s.',
COMMAND_APPLY,
- spec[COMMAND_APPLY]
+ spec[COMMAND_APPLY],
);
nextValue = spec[COMMAND_APPLY](nextValue);
}
diff --git a/src/isomorphic/React.js b/src/isomorphic/React.js
index 8cdfb5d4a7..245be1aa77 100644
--- a/src/isomorphic/React.js
+++ b/src/isomorphic/React.js
@@ -48,9 +48,9 @@ if (__DEV__) {
warning(
warnedForSpread,
'React.__spread is deprecated and should not be used. Use ' +
- 'Object.assign directly or another helper function with similar ' +
- 'semantics. You may be seeing this warning due to your compiler. ' +
- 'See https://fb.me/react-spread-deprecation for more details.'
+ 'Object.assign directly or another helper function with similar ' +
+ 'semantics. You may be seeing this warning due to your compiler. ' +
+ 'See https://fb.me/react-spread-deprecation for more details.',
);
warnedForSpread = true;
return Object.assign.apply(null, arguments);
@@ -60,16 +60,14 @@ if (__DEV__) {
warning(
warnedForCreateMixin,
'React.createMixin is deprecated and should not be used. You ' +
- 'can use this mixin directly instead.'
+ 'can use this mixin directly instead.',
);
warnedForCreateMixin = true;
return mixin;
};
-
}
var React = {
-
// Modern
Children: {
@@ -112,7 +110,7 @@ if (__DEV__) {
warning(
didWarnPropTypesDeprecated,
'Accessing PropTypes via the main React package is deprecated. Use ' +
- 'the prop-types package from npm instead.'
+ 'the prop-types package from npm instead.',
);
didWarnPropTypesDeprecated = true;
return ReactPropTypes;
diff --git a/src/isomorphic/__tests__/React-test.js b/src/isomorphic/__tests__/React-test.js
index db318fa604..c2098227e5 100644
--- a/src/isomorphic/__tests__/React-test.js
+++ b/src/isomorphic/__tests__/React-test.js
@@ -12,7 +12,6 @@
'use strict';
describe('React', () => {
-
var React;
beforeEach(() => {
@@ -25,7 +24,7 @@ describe('React', () => {
React.__spread({});
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'React.__spread is deprecated and should not be used'
+ 'React.__spread is deprecated and should not be used',
);
});
@@ -35,8 +34,7 @@ describe('React', () => {
React.createMixin();
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'React.createMixin is deprecated and should not be used'
+ 'React.createMixin is deprecated and should not be used',
);
});
-
});
diff --git a/src/isomorphic/children/ReactChildren.js b/src/isomorphic/children/ReactChildren.js
index 75670dbe36..645c361ff6 100644
--- a/src/isomorphic/children/ReactChildren.js
+++ b/src/isomorphic/children/ReactChildren.js
@@ -20,13 +20,11 @@ var traverseAllChildren = require('traverseAllChildren');
var twoArgumentPooler = PooledClass.twoArgumentPooler;
var fourArgumentPooler = PooledClass.fourArgumentPooler;
-
var userProvidedKeyEscapeRegex = /\/+/g;
function escapeUserProvidedKey(text) {
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
}
-
/**
* PooledClass representing the bookkeeping associated with performing a child
* traversal. Allows avoiding binding callbacks.
@@ -68,13 +66,14 @@ function forEachChildren(children, forEachFunc, forEachContext) {
if (children == null) {
return children;
}
- var traverseContext =
- ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
+ var traverseContext = ForEachBookKeeping.getPooled(
+ forEachFunc,
+ forEachContext,
+ );
traverseAllChildren(children, forEachSingleChild, traverseContext);
ForEachBookKeeping.release(traverseContext);
}
-
/**
* PooledClass representing the bookkeeping associated with performing a child
* mapping. Allows avoiding binding callbacks.
@@ -109,7 +108,7 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
mappedChild,
result,
childKey,
- emptyFunction.thatReturnsArgument
+ emptyFunction.thatReturnsArgument,
);
} else if (mappedChild != null) {
if (ReactElement.isValidElement(mappedChild)) {
@@ -118,12 +117,10 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
// Keep both the (mapped) and old keys if they differ, just as
// traverseAllChildren used to do for objects as children
keyPrefix +
- (
- (mappedChild.key && (!child || (child.key !== mappedChild.key))) ?
- escapeUserProvidedKey(mappedChild.key) + '/' :
- ''
- ) +
- childKey
+ (mappedChild.key && (!child || child.key !== mappedChild.key)
+ ? escapeUserProvidedKey(mappedChild.key) + '/'
+ : '') +
+ childKey,
);
}
result.push(mappedChild);
@@ -139,7 +136,7 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
array,
escapedPrefix,
func,
- context
+ context,
);
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
MapBookKeeping.release(traverseContext);
@@ -167,8 +164,6 @@ function mapChildren(children, func, context) {
return result;
}
-
-
function forEachSingleChildDummy(traverseContext, child, name) {
return null;
}
@@ -186,7 +181,6 @@ function countChildren(children, context) {
return traverseAllChildren(children, forEachSingleChildDummy, null);
}
-
/**
* Flatten a children object (typically specified as `props.children`) and
* return an array with appropriately re-keyed children.
@@ -199,12 +193,11 @@ function toArray(children) {
children,
result,
null,
- emptyFunction.thatReturnsArgument
+ emptyFunction.thatReturnsArgument,
);
return result;
}
-
var ReactChildren = {
forEach: forEachChildren,
map: mapChildren,
diff --git a/src/isomorphic/children/__tests__/ReactChildren-test.js b/src/isomorphic/children/__tests__/ReactChildren-test.js
index 6eb4c89e2d..d6e6a8bfc5 100644
--- a/src/isomorphic/children/__tests__/ReactChildren-test.js
+++ b/src/isomorphic/children/__tests__/ReactChildren-test.js
@@ -69,7 +69,6 @@ describe('ReactChildren', () => {
var mappedChildren = ReactChildren.map(instance.props.children, callback);
expect(callback).toHaveBeenCalledWith(simpleKid, 0);
expect(mappedChildren[0]).toEqual();
-
});
it('should pass key to returned component', () => {
@@ -103,8 +102,11 @@ describe('ReactChildren', () => {
ReactChildren.forEach(instance.props.children, callback, scopeTester);
expect(lastContext).toBe(scopeTester);
- var mappedChildren =
- ReactChildren.map(instance.props.children, callback, scopeTester);
+ var mappedChildren = ReactChildren.map(
+ instance.props.children,
+ callback,
+ scopeTester,
+ );
expect(ReactChildren.count(mappedChildren)).toBe(1);
expect(mappedChildren[0]).toBe(scopeTester);
@@ -118,9 +120,9 @@ describe('ReactChildren', () => {
var four = ;
var mapped = [
- , // Key should be joined to obj key
- null, // Key should be added even if we don't supply it!
- , // Key should be added even if not supplied!
+ , // Key should be joined to obj key
+ null, // Key should be added even if we don't supply it!
+ , // Key should be added even if not supplied!
, // Map from null to something.
,
];
@@ -146,8 +148,7 @@ describe('ReactChildren', () => {
expect(callback).toHaveBeenCalledWith(four, 4);
callback.calls.reset();
- var mappedChildren =
- ReactChildren.map(instance.props.children, callback);
+ var mappedChildren = ReactChildren.map(instance.props.children, callback);
expect(callback.calls.count()).toBe(5);
expect(ReactChildren.count(mappedChildren)).toBe(4);
// Keys default to indices.
@@ -156,9 +157,7 @@ describe('ReactChildren', () => {
mappedChildren[1].key,
mappedChildren[2].key,
mappedChildren[3].key,
- ]).toEqual(
- ['giraffe/.$keyZero', '.$keyTwo', '.3', '.$keyFour']
- );
+ ]).toEqual(['giraffe/.$keyZero', '.$keyTwo', '.3', '.$keyFour']);
expect(callback).toHaveBeenCalledWith(zero, 0);
expect(callback).toHaveBeenCalledWith(one, 1);
@@ -185,15 +184,15 @@ describe('ReactChildren', () => {
// 1. If grouped in an Object, the object key combined with `key` prop
// 2. If grouped in an Array, the `key` prop, falling back to array index
- var zeroMapped = ; // Key should be overridden
- var twoMapped = ; // Key should be added even if not supplied!
+ var zeroMapped = ; // Key should be overridden
+ var twoMapped = ; // Key should be added even if not supplied!
var fourMapped = ;
var fiveMapped = ;
var callback = jasmine.createSpy().and.callFake(function(kid, index) {
- return index === 0 ? zeroMapped :
- index === 1 ? twoMapped :
- index === 2 ? fourMapped : fiveMapped;
+ return index === 0
+ ? zeroMapped
+ : index === 1 ? twoMapped : index === 2 ? fourMapped : fiveMapped;
});
var frag = ReactFragment.create({
@@ -203,12 +202,7 @@ describe('ReactChildren', () => {
});
var instance =
{[frag]}
;
- expect([
- frag[0].key,
- frag[1].key,
- frag[2].key,
- frag[3].key,
- ]).toEqual([
+ expect([frag[0].key, frag[1].key, frag[2].key, frag[3].key]).toEqual([
'firstHalfKey/.$keyZero',
'firstHalfKey/.$keyTwo',
'secondHalfKey/.$keyFour',
@@ -244,9 +238,13 @@ describe('ReactChildren', () => {
'.0:$keyFive/.$keyFiveInner',
]);
- expect(mappedChildren[0]).toEqual();
+ expect(mappedChildren[0]).toEqual(
+ ,
+ );
expect(mappedChildren[1]).toEqual();
- expect(mappedChildren[2]).toEqual();
+ expect(mappedChildren[2]).toEqual(
+ ,
+ );
expect(mappedChildren[3]).toEqual();
});
@@ -271,21 +269,24 @@ describe('ReactChildren', () => {
);
var expectedForcedKeys = ['giraffe/.$keyZero', '.$keyOne'];
- var mappedChildrenForcedKeys =
- ReactChildren.map(forcedKeys.props.children, mapFn);
- var mappedForcedKeys = mappedChildrenForcedKeys.map((c) => c.key);
+ var mappedChildrenForcedKeys = ReactChildren.map(
+ forcedKeys.props.children,
+ mapFn,
+ );
+ var mappedForcedKeys = mappedChildrenForcedKeys.map(c => c.key);
expect(mappedForcedKeys).toEqual(expectedForcedKeys);
var expectedRemappedForcedKeys = [
'giraffe/.$giraffe/.$keyZero',
'.$.$keyOne',
];
- var remappedChildrenForcedKeys =
- ReactChildren.map(mappedChildrenForcedKeys, mapFn);
- expect(
- remappedChildrenForcedKeys.map((c) => c.key)
- ).toEqual(expectedRemappedForcedKeys);
-
+ var remappedChildrenForcedKeys = ReactChildren.map(
+ mappedChildrenForcedKeys,
+ mapFn,
+ );
+ expect(remappedChildrenForcedKeys.map(c => c.key)).toEqual(
+ expectedRemappedForcedKeys,
+ );
});
it('should not throw if key provided is a dupe with array key', () => {
@@ -315,14 +316,10 @@ describe('ReactChildren', () => {
);
- var mapped = ReactChildren.map(
- instance.props.children,
- element => element,
- );
+ var mapped = ReactChildren.map(instance.props.children, element => element);
- var mappedWithClone = ReactChildren.map(
- instance.props.children,
- element => React.cloneElement(element),
+ var mappedWithClone = ReactChildren.map(instance.props.children, element =>
+ React.cloneElement(element),
);
expect(mapped[0].key).toBe(mappedWithClone[0].key);
@@ -335,14 +332,10 @@ describe('ReactChildren', () => {
);
- var mapped = ReactChildren.map(
- instance.props.children,
- element => element,
- );
+ var mapped = ReactChildren.map(instance.props.children, element => element);
- var mappedWithClone = ReactChildren.map(
- instance.props.children,
- element => React.cloneElement(element, {key: 'unique'}),
+ var mappedWithClone = ReactChildren.map(instance.props.children, element =>
+ React.cloneElement(element, {key: 'unique'}),
);
expect(mapped[0].key).toBe(mappedWithClone[0].key);
@@ -399,14 +392,16 @@ describe('ReactChildren', () => {
// 2. If grouped in an Array, the `key` prop, falling back to array index
var instance = (
-
);
var numberOfChildren = ReactChildren.count(instance.props.children);
expect(numberOfChildren).toBe(5);
@@ -418,10 +413,8 @@ describe('ReactChildren', () => {
expect(ReactChildren.toArray().length).toBe(1);
expect(ReactChildren.toArray([]).length).toBe(1);
- expect(
- ReactChildren.toArray()[0].key
- ).toBe(
- ReactChildren.toArray([])[0].key
+ expect(ReactChildren.toArray()[0].key).toBe(
+ ReactChildren.toArray([])[0].key,
);
var flattened = ReactChildren.toArray([
@@ -445,9 +438,9 @@ describe('ReactChildren', () => {
expect(flattened[5].key).toBe(reversed[3].key);
// null/undefined/bool are all omitted
- expect(ReactChildren.toArray([1, 'two', null, undefined, true])).toEqual(
- [1, 'two']
- );
+ expect(ReactChildren.toArray([1, 'two', null, undefined, true])).toEqual([
+ 1,
+ 'two',
+ ]);
});
-
});
diff --git a/src/isomorphic/children/__tests__/onlyChild-test.js b/src/isomorphic/children/__tests__/onlyChild-test.js
index 8de1c9b807..0c8870c6d7 100644
--- a/src/isomorphic/children/__tests__/onlyChild-test.js
+++ b/src/isomorphic/children/__tests__/onlyChild-test.js
@@ -12,7 +12,6 @@
'use strict';
describe('onlyChild', () => {
-
var React;
var ReactFragment;
var onlyChild;
@@ -35,63 +34,66 @@ describe('onlyChild', () => {
it('should fail when passed two children', () => {
expect(function() {
- var instance =
+ var instance = (
- ;
+
+ );
onlyChild(instance.props.children);
}).toThrow();
});
it('should fail when passed nully values', () => {
expect(function() {
- var instance =
+ var instance = (
{null}
- ;
+
+ );
onlyChild(instance.props.children);
}).toThrow();
expect(function() {
- var instance =
+ var instance = (
{undefined}
- ;
+
+ );
onlyChild(instance.props.children);
}).toThrow();
});
it('should fail when key/value objects', () => {
expect(function() {
- var instance =
+ var instance = (
{ReactFragment.create({oneThing: })}
- ;
+
+ );
onlyChild(instance.props.children);
}).toThrow();
});
-
it('should not fail when passed interpolated single child', () => {
expect(function() {
- var instance =
+ var instance = (
{}
- ;
+
+ );
onlyChild(instance.props.children);
}).not.toThrow();
});
-
it('should return the only child', () => {
expect(function() {
- var instance =
+ var instance = (
- ;
+
+ );
onlyChild(instance.props.children);
}).not.toThrow();
});
-
});
diff --git a/src/isomorphic/children/__tests__/sliceChildren-test.js b/src/isomorphic/children/__tests__/sliceChildren-test.js
index 5b41e1f24b..d255324a72 100644
--- a/src/isomorphic/children/__tests__/sliceChildren-test.js
+++ b/src/isomorphic/children/__tests__/sliceChildren-test.js
@@ -12,7 +12,6 @@
'use strict';
describe('sliceChildren', () => {
-
var React;
var sliceChildren;
@@ -24,11 +23,7 @@ describe('sliceChildren', () => {
});
it('should render the whole set if start zero is supplied', () => {
- var fullSet = [
- ,
- ,
- ,
- ];
+ var fullSet = [, , ];
var children = sliceChildren(fullSet, 0);
expect(children).toEqual([
,
@@ -38,16 +33,9 @@ describe('sliceChildren', () => {
});
it('should render the remaining set if no end index is supplied', () => {
- var fullSet = [
- ,
- ,
- ,
- ];
+ var fullSet = [, , ];
var children = sliceChildren(fullSet, 1);
- expect(children).toEqual([
- ,
- ,
- ]);
+ expect(children).toEqual([, ]);
});
it('should exclude everything at or after the end index', () => {
@@ -58,9 +46,7 @@ describe('sliceChildren', () => {
,
];
var children = sliceChildren(fullSet, 1, 2);
- expect(children).toEqual([
- ,
- ]);
+ expect(children).toEqual([]);
});
it('should allow static children to be sliced', () => {
@@ -70,24 +56,16 @@ describe('sliceChildren', () => {
var el =
{a}{b}{c}
;
var children = sliceChildren(el.props.children, 1, 2);
- expect(children).toEqual([
- ,
- ]);
+ expect(children).toEqual([]);
});
it('should slice nested children', () => {
var fullSet = [
,
- [
- ,
- ,
- ],
+ [, ],
,
];
var children = sliceChildren(fullSet, 1, 2);
- expect(children).toEqual([
- ,
- ]);
+ expect(children).toEqual([]);
});
-
});
diff --git a/src/isomorphic/children/onlyChild.js b/src/isomorphic/children/onlyChild.js
index 43ec44f29c..8801fd6dc2 100644
--- a/src/isomorphic/children/onlyChild.js
+++ b/src/isomorphic/children/onlyChild.js
@@ -31,7 +31,7 @@ var invariant = require('invariant');
function onlyChild(children) {
invariant(
ReactElement.isValidElement(children),
- 'React.Children.only expected to receive a single React element child.'
+ 'React.Children.only expected to receive a single React element child.',
);
return children;
}
diff --git a/src/isomorphic/classic/__tests__/ReactContextValidator-test.js b/src/isomorphic/classic/__tests__/ReactContextValidator-test.js
index f6efecc9b8..ac0a47ca56 100644
--- a/src/isomorphic/classic/__tests__/ReactContextValidator-test.js
+++ b/src/isomorphic/classic/__tests__/ReactContextValidator-test.js
@@ -67,8 +67,12 @@ describe('ReactContextValidator', () => {
bar: React.PropTypes.number,
};
- var instance = ReactTestUtils.renderIntoDocument();
- reactComponentExpect(instance).expectRenderedChild().scalarContextEqual({foo: 'abc'});
+ var instance = ReactTestUtils.renderIntoDocument(
+ ,
+ );
+ reactComponentExpect(instance)
+ .expectRenderedChild()
+ .scalarContextEqual({foo: 'abc'});
});
it('should filter context properly in callbacks', () => {
@@ -121,7 +125,6 @@ describe('ReactContextValidator', () => {
foo: React.PropTypes.string,
};
-
var container = document.createElement('div');
ReactDOM.render(, container);
ReactDOM.render(, container);
@@ -148,9 +151,9 @@ describe('ReactContextValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed context type: ' +
- 'The context `foo` is marked as required in `Component`, but its value ' +
- 'is `undefined`.\n' +
- ' in Component (at **)'
+ 'The context `foo` is marked as required in `Component`, but its value ' +
+ 'is `undefined`.\n' +
+ ' in Component (at **)',
);
class ComponentInFooStringContext extends React.Component {
@@ -169,7 +172,7 @@ describe('ReactContextValidator', () => {
};
ReactTestUtils.renderIntoDocument(
-
+ ,
);
// Previous call should not error
@@ -190,15 +193,17 @@ describe('ReactContextValidator', () => {
foo: React.PropTypes.number,
};
- ReactTestUtils.renderIntoDocument();
+ ReactTestUtils.renderIntoDocument(
+ ,
+ );
expect(console.error.calls.count()).toBe(2);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
'Warning: Failed context type: ' +
- 'Invalid context `foo` of type `number` supplied ' +
- 'to `Component`, expected `string`.\n' +
- ' in Component (at **)\n' +
- ' in ComponentInFooNumberContext (at **)'
+ 'Invalid context `foo` of type `number` supplied ' +
+ 'to `Component`, expected `string`.\n' +
+ ' in Component (at **)\n' +
+ ' in ComponentInFooNumberContext (at **)',
);
});
@@ -223,9 +228,9 @@ describe('ReactContextValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed child context type: ' +
- 'The child context `foo` is marked as required in `Component`, but its ' +
- 'value is `undefined`.\n' +
- ' in Component (at **)'
+ 'The child context `foo` is marked as required in `Component`, but its ' +
+ 'value is `undefined`.\n' +
+ ' in Component (at **)',
);
ReactTestUtils.renderIntoDocument();
@@ -233,21 +238,18 @@ describe('ReactContextValidator', () => {
expect(console.error.calls.count()).toBe(2);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
'Warning: Failed child context type: ' +
- 'Invalid child context `foo` of type `number` ' +
- 'supplied to `Component`, expected `string`.\n' +
- ' in Component (at **)'
+ 'Invalid child context `foo` of type `number` ' +
+ 'supplied to `Component`, expected `string`.\n' +
+ ' in Component (at **)',
);
ReactTestUtils.renderIntoDocument(
-
+ ,
);
- ReactTestUtils.renderIntoDocument(
-
- );
+ ReactTestUtils.renderIntoDocument();
// Previous calls should not log errors
expect(console.error.calls.count()).toBe(2);
});
-
});
diff --git a/src/isomorphic/classic/class/ReactClass.js b/src/isomorphic/classic/class/ReactClass.js
index 9c9506e630..3d4cf6654d 100644
--- a/src/isomorphic/classic/class/ReactClass.js
+++ b/src/isomorphic/classic/class/ReactClass.js
@@ -20,7 +20,7 @@ var emptyObject = require('emptyObject');
var invariant = require('invariant');
var warning = require('warning');
-import type { ReactPropTypeLocations } from 'ReactPropTypeLocations';
+import type {ReactPropTypeLocations} from 'ReactPropTypeLocations';
var MIXINS_KEY = 'mixins';
@@ -37,23 +37,19 @@ type SpecPolicy =
/**
* These methods may be defined only once by the class specification or mixin.
*/
- 'DEFINE_ONCE' |
- /**
+ | 'DEFINE_ONCE' /**
* These methods may be defined by both the class specification and mixins.
* Subsequent definitions will be chained. These methods must return void.
*/
- 'DEFINE_MANY' |
- /**
+ | 'DEFINE_MANY' /**
* These methods are overriding the base class.
*/
- 'OVERRIDE_BASE' |
- /**
+ | 'OVERRIDE_BASE' /**
* These methods are similar to DEFINE_MANY, except we assume they return
* objects. We try to merge the keys of the return values of all the mixed in
* functions. If there is a key conflict we throw.
*/
- 'DEFINE_MANY_MERGED';
-
+ | 'DEFINE_MANY_MERGED';
var injectedMixins = [];
@@ -80,7 +76,6 @@ var injectedMixins = [];
* @internal
*/
var ReactClassInterface: {[key: string]: SpecPolicy} = {
-
/**
* An array of Mixin objects to include when defining your component.
*
@@ -175,8 +170,6 @@ var ReactClassInterface: {[key: string]: SpecPolicy} = {
*/
render: 'DEFINE_ONCE',
-
-
// ==== Delegate methods ====
/**
@@ -287,8 +280,6 @@ var ReactClassInterface: {[key: string]: SpecPolicy} = {
*/
componentWillUnmount: 'DEFINE_MANY',
-
-
// ==== Advanced methods ====
/**
@@ -302,7 +293,6 @@ var ReactClassInterface: {[key: string]: SpecPolicy} = {
* @overridable
*/
updateComponent: 'OVERRIDE_BASE',
-
};
/**
@@ -327,30 +317,22 @@ var RESERVED_SPEC_KEYS = {
},
childContextTypes: function(Constructor, childContextTypes) {
if (__DEV__) {
- validateTypeDef(
- Constructor,
- childContextTypes,
- 'childContext'
- );
+ validateTypeDef(Constructor, childContextTypes, 'childContext');
}
Constructor.childContextTypes = Object.assign(
{},
Constructor.childContextTypes,
- childContextTypes
+ childContextTypes,
);
},
contextTypes: function(Constructor, contextTypes) {
if (__DEV__) {
- validateTypeDef(
- Constructor,
- contextTypes,
- 'context'
- );
+ validateTypeDef(Constructor, contextTypes, 'context');
}
Constructor.contextTypes = Object.assign(
{},
Constructor.contextTypes,
- contextTypes
+ contextTypes,
);
},
/**
@@ -361,7 +343,7 @@ var RESERVED_SPEC_KEYS = {
if (Constructor.getDefaultProps) {
Constructor.getDefaultProps = createMergedResultFunction(
Constructor.getDefaultProps,
- getDefaultProps
+ getDefaultProps,
);
} else {
Constructor.getDefaultProps = getDefaultProps;
@@ -369,17 +351,9 @@ var RESERVED_SPEC_KEYS = {
},
propTypes: function(Constructor, propTypes) {
if (__DEV__) {
- validateTypeDef(
- Constructor,
- propTypes,
- 'prop'
- );
+ validateTypeDef(Constructor, propTypes, 'prop');
}
- Constructor.propTypes = Object.assign(
- {},
- Constructor.propTypes,
- propTypes
- );
+ Constructor.propTypes = Object.assign({}, Constructor.propTypes, propTypes);
},
statics: function(Constructor, statics) {
mixStaticSpecIntoComponent(Constructor, statics);
@@ -399,40 +373,39 @@ function validateTypeDef(
warning(
typeof typeDef[propName] === 'function',
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
- 'React.PropTypes.',
+ 'React.PropTypes.',
Constructor.displayName || 'ReactClass',
ReactPropTypeLocationNames[location],
- propName
+ propName,
);
}
}
}
function validateMethodOverride(isAlreadyDefined, name) {
- var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
- ReactClassInterface[name] :
- null;
+ var specPolicy = ReactClassInterface.hasOwnProperty(name)
+ ? ReactClassInterface[name]
+ : null;
// Disallow overriding of base class methods unless explicitly allowed.
if (ReactClassMixin.hasOwnProperty(name)) {
invariant(
specPolicy === 'OVERRIDE_BASE',
'ReactClassInterface: You are attempting to override ' +
- '`%s` from your class specification. Ensure that your method names ' +
- 'do not overlap with React methods.',
- name
+ '`%s` from your class specification. Ensure that your method names ' +
+ 'do not overlap with React methods.',
+ name,
);
}
// Disallow defining methods more than once unless explicitly allowed.
if (isAlreadyDefined) {
invariant(
- specPolicy === 'DEFINE_MANY' ||
- specPolicy === 'DEFINE_MANY_MERGED',
+ specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED',
'ReactClassInterface: You are attempting to define ' +
- '`%s` on your component more than once. This conflict may be due ' +
- 'to a mixin.',
- name
+ '`%s` on your component more than once. This conflict may be due ' +
+ 'to a mixin.',
+ name,
);
}
}
@@ -449,12 +422,12 @@ function mixSpecIntoComponent(Constructor, spec) {
warning(
isMixinValid,
- '%s: You\'re attempting to include a mixin that is either null ' +
- 'or not an object. Check the mixins included by the component, ' +
- 'as well as any mixins they include themselves. ' +
- 'Expected object but got %s.',
+ "%s: You're attempting to include a mixin that is either null " +
+ 'or not an object. Check the mixins included by the component, ' +
+ 'as well as any mixins they include themselves. ' +
+ 'Expected object but got %s.',
Constructor.displayName || 'ReactClass',
- spec === null ? null : typeofSpec
+ spec === null ? null : typeofSpec,
);
}
@@ -463,14 +436,14 @@ function mixSpecIntoComponent(Constructor, spec) {
invariant(
typeof spec !== 'function',
- 'ReactClass: You\'re attempting to ' +
- 'use a component class or function as a mixin. Instead, just use a ' +
- 'regular object.'
+ "ReactClass: You're attempting to " +
+ 'use a component class or function as a mixin. Instead, just use a ' +
+ 'regular object.',
);
invariant(
!ReactElement.isValidElement(spec),
- 'ReactClass: You\'re attempting to ' +
- 'use a component as a mixin. Instead, just use a regular object.'
+ "ReactClass: You're attempting to " +
+ 'use a component as a mixin. Instead, just use a regular object.',
);
var proto = Constructor.prototype;
@@ -504,8 +477,7 @@ function mixSpecIntoComponent(Constructor, spec) {
// The following member methods should not be automatically bound:
// 1. Expected ReactClass methods (in the "interface").
// 2. Overridden methods (that were mixed in).
- var isReactClassMethod =
- ReactClassInterface.hasOwnProperty(name);
+ var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
var isFunction = typeof property === 'function';
var shouldAutoBind =
isFunction &&
@@ -522,14 +494,13 @@ function mixSpecIntoComponent(Constructor, spec) {
// These cases should already be caught by validateMethodOverride.
invariant(
- isReactClassMethod && (
- specPolicy === 'DEFINE_MANY_MERGED' ||
- specPolicy === 'DEFINE_MANY'
- ),
+ isReactClassMethod &&
+ (specPolicy === 'DEFINE_MANY_MERGED' ||
+ specPolicy === 'DEFINE_MANY'),
'ReactClass: Unexpected spec policy %s for key %s ' +
- 'when mixing in component specs.',
+ 'when mixing in component specs.',
specPolicy,
- name
+ name,
);
// For methods which are defined more than once, call the existing
@@ -568,19 +539,19 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
invariant(
!isReserved,
'ReactClass: You are attempting to define a reserved ' +
- 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
- 'as an instance property instead; it will still be accessible on the ' +
- 'constructor.',
- name
+ 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
+ 'as an instance property instead; it will still be accessible on the ' +
+ 'constructor.',
+ name,
);
var isInherited = name in Constructor;
invariant(
!isInherited,
'ReactClass: You are attempting to define ' +
- '`%s` on your component more than once. This conflict may be ' +
- 'due to a mixin.',
- name
+ '`%s` on your component more than once. This conflict may be ' +
+ 'due to a mixin.',
+ name,
);
Constructor[name] = property;
}
@@ -596,7 +567,7 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
function mergeIntoWithNoDuplicateKeys(one, two) {
invariant(
one && two && typeof one === 'object' && typeof two === 'object',
- 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
+ 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.',
);
for (var key in two) {
@@ -604,11 +575,11 @@ function mergeIntoWithNoDuplicateKeys(one, two) {
invariant(
one[key] === undefined,
'mergeIntoWithNoDuplicateKeys(): ' +
- 'Tried to merge two objects with the same key: `%s`. This conflict ' +
- 'may be due to a mixin; in particular, this may be caused by two ' +
- 'getInitialState() or getDefaultProps() methods returning objects ' +
- 'with clashing keys.',
- key
+ 'Tried to merge two objects with the same key: `%s`. This conflict ' +
+ 'may be due to a mixin; in particular, this may be caused by two ' +
+ 'getInitialState() or getDefaultProps() methods returning objects ' +
+ 'with clashing keys.',
+ key,
);
one[key] = two[key];
}
@@ -678,16 +649,16 @@ function bindAutoBindMethod(component, method) {
warning(
false,
'bind(): React component methods may only be bound to the ' +
- 'component instance. See %s',
- componentName
+ 'component instance. See %s',
+ componentName,
);
} else if (!args.length) {
warning(
false,
'bind(): You are binding a component method to the component. ' +
- 'React does this for you automatically in a high-performance ' +
- 'way, so you can safely remove this call. See %s',
- componentName
+ 'React does this for you automatically in a high-performance ' +
+ 'way, so you can safely remove this call. See %s',
+ componentName,
);
return boundMethod;
}
@@ -711,10 +682,7 @@ function bindAutoBindMethods(component) {
for (var i = 0; i < pairs.length; i += 2) {
var autoBindKey = pairs[i];
var method = pairs[i + 1];
- component[autoBindKey] = bindAutoBindMethod(
- component,
- method
- );
+ component[autoBindKey] = bindAutoBindMethod(component, method);
}
}
@@ -723,7 +691,6 @@ function bindAutoBindMethods(component) {
* therefore not already part of the modern ReactComponent.
*/
var ReactClassMixin = {
-
/**
* TODO: This will be deprecated because state should always keep a consistent
* type signature and the only use case for this, is to avoid that.
@@ -750,7 +717,7 @@ var ReactClassComponent = function() {};
Object.assign(
ReactClassComponent.prototype,
ReactComponent.prototype,
- ReactClassMixin
+ ReactClassMixin,
);
let didWarnDeprecated = false;
@@ -761,7 +728,6 @@ let didWarnDeprecated = false;
* @class ReactClass
*/
var ReactClass = {
-
/**
* Creates a composite component class given a class specification.
* See https://facebook.github.io/react/docs/top-level-api.html#react.createclass
@@ -775,9 +741,9 @@ var ReactClass = {
warning(
didWarnDeprecated,
'%s: React.createClass is deprecated and will be removed in version 16. ' +
- 'Use plain JavaScript classes instead. If you\'re not yet ready to ' +
- 'migrate, create-react-class is available on npm as a ' +
- 'drop-in replacement.',
+ "Use plain JavaScript classes instead. If you're not yet ready to " +
+ 'migrate, create-react-class is available on npm as a ' +
+ 'drop-in replacement.',
(spec && spec.displayName) || 'A Component',
);
didWarnDeprecated = true;
@@ -794,7 +760,7 @@ var ReactClass = {
warning(
this instanceof Constructor,
'Something is calling a React component directly. Use a factory or ' +
- 'JSX instead. See: https://fb.me/react-legacyfactory'
+ 'JSX instead. See: https://fb.me/react-legacyfactory',
);
}
@@ -816,8 +782,10 @@ var ReactClass = {
var initialState = this.getInitialState ? this.getInitialState() : null;
if (__DEV__) {
// We allow auto-mocks to proceed as if they're returning null.
- if (initialState === undefined &&
- this.getInitialState._isMockFunction) {
+ if (
+ initialState === undefined &&
+ this.getInitialState._isMockFunction
+ ) {
// This is probably bad practice. Consider warning here and
// deprecating this convenience.
initialState = null;
@@ -826,7 +794,7 @@ var ReactClass = {
invariant(
typeof initialState === 'object' && !Array.isArray(initialState),
'%s.getInitialState(): must return an object or null',
- Constructor.displayName || 'ReactCompositeComponent'
+ Constructor.displayName || 'ReactCompositeComponent',
);
this.state = initialState;
@@ -835,9 +803,7 @@ var ReactClass = {
Constructor.prototype.constructor = Constructor;
Constructor.prototype.__reactAutoBindPairs = [];
- injectedMixins.forEach(
- mixSpecIntoComponent.bind(null, Constructor)
- );
+ injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
mixSpecIntoComponent(Constructor, spec);
@@ -861,23 +827,23 @@ var ReactClass = {
invariant(
Constructor.prototype.render,
- 'createClass(...): Class specification must implement a `render` method.'
+ 'createClass(...): Class specification must implement a `render` method.',
);
if (__DEV__) {
warning(
!Constructor.prototype.componentShouldUpdate,
'%s has a method called ' +
- 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
- 'The name is phrased as a question because the function is ' +
- 'expected to return a value.',
- spec.displayName || 'A component'
+ 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
+ 'The name is phrased as a question because the function is ' +
+ 'expected to return a value.',
+ spec.displayName || 'A component',
);
warning(
!Constructor.prototype.componentWillRecieveProps,
'%s has a method called ' +
- 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
- spec.displayName || 'A component'
+ 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
+ spec.displayName || 'A component',
);
}
@@ -896,7 +862,6 @@ var ReactClass = {
injectedMixins.push(mixin);
},
},
-
};
module.exports = ReactClass;
diff --git a/src/isomorphic/classic/class/__tests__/ReactClass-test.js b/src/isomorphic/classic/class/__tests__/ReactClass-test.js
index 5f315f0ca3..613d2cb5b6 100644
--- a/src/isomorphic/classic/class/__tests__/ReactClass-test.js
+++ b/src/isomorphic/classic/class/__tests__/ReactClass-test.js
@@ -16,7 +16,6 @@ var ReactDOM;
var ReactTestUtils;
describe('ReactClass-spec', () => {
-
beforeEach(() => {
React = require('React');
ReactDOM = require('ReactDOM');
@@ -37,9 +36,9 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toEqual(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: MyComponent: React.createClass is deprecated and will be removed in ' +
- 'version 16. Use plain JavaScript classes instead. If you\'re not yet ' +
- 'ready to migrate, create-react-class is available on npm as a ' +
- 'drop-in replacement.'
+ "version 16. Use plain JavaScript classes instead. If you're not yet " +
+ 'ready to migrate, create-react-class is available on npm as a ' +
+ 'drop-in replacement.',
);
console.error.calls.reset();
});
@@ -48,7 +47,7 @@ describe('ReactClass-spec', () => {
expect(function() {
React.createClass({});
}).toThrowError(
- 'createClass(...): Class specification must implement a `render` method.'
+ 'createClass(...): Class specification must implement a `render` method.',
);
});
@@ -59,8 +58,7 @@ describe('ReactClass-spec', () => {
},
});
- expect(TestComponent.displayName)
- .toBe('TestComponent');
+ expect(TestComponent.displayName).toBe('TestComponent');
});
it('should copy prop types onto the Constructor', () => {
@@ -75,8 +73,7 @@ describe('ReactClass-spec', () => {
});
expect(TestComponent.propTypes).toBeDefined();
- expect(TestComponent.propTypes.value)
- .toBe(propValidator);
+ expect(TestComponent.propTypes.value).toBe(propValidator);
});
it('should warn on invalid prop types', () => {
@@ -93,7 +90,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Component: prop type `prop` is invalid; ' +
- 'it must be a function, usually from React.PropTypes.'
+ 'it must be a function, usually from React.PropTypes.',
);
});
@@ -111,7 +108,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Component: context type `prop` is invalid; ' +
- 'it must be a function, usually from React.PropTypes.'
+ 'it must be a function, usually from React.PropTypes.',
);
});
@@ -129,7 +126,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Component: child context type `prop` is invalid; ' +
- 'it must be a function, usually from React.PropTypes.'
+ 'it must be a function, usually from React.PropTypes.',
);
});
@@ -147,8 +144,8 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: A component has a method called componentShouldUpdate(). Did you ' +
- 'mean shouldComponentUpdate()? The name is phrased as a question ' +
- 'because the function is expected to return a value.'
+ 'mean shouldComponentUpdate()? The name is phrased as a question ' +
+ 'because the function is expected to return a value.',
);
React.createClass({
@@ -163,8 +160,8 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(2);
expect(console.error.calls.argsFor(1)[0]).toBe(
'Warning: NamedComponent has a method called componentShouldUpdate(). Did you ' +
- 'mean shouldComponentUpdate()? The name is phrased as a question ' +
- 'because the function is expected to return a value.'
+ 'mean shouldComponentUpdate()? The name is phrased as a question ' +
+ 'because the function is expected to return a value.',
);
});
@@ -181,7 +178,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: A component has a method called componentWillRecieveProps(). Did you ' +
- 'mean componentWillReceiveProps()?'
+ 'mean componentWillReceiveProps()?',
);
});
@@ -202,9 +199,9 @@ describe('ReactClass-spec', () => {
});
}).toThrowError(
'ReactClass: You are attempting to define a reserved property, ' +
- '`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' +
- 'it as an instance property instead; it will still be accessible on ' +
- 'the constructor.'
+ '`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' +
+ 'it as an instance property instead; it will still be accessible on ' +
+ 'the constructor.',
);
});
@@ -230,19 +227,19 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(4);
expect(console.error.calls.argsFor(0)[0]).toBe(
'createClass(...): `mixins` is now a static property and should ' +
- 'be defined inside "statics".'
+ 'be defined inside "statics".',
);
expect(console.error.calls.argsFor(1)[0]).toBe(
'createClass(...): `propTypes` is now a static property and should ' +
- 'be defined inside "statics".'
+ 'be defined inside "statics".',
);
expect(console.error.calls.argsFor(2)[0]).toBe(
'createClass(...): `contextTypes` is now a static property and ' +
- 'should be defined inside "statics".'
+ 'should be defined inside "statics".',
);
expect(console.error.calls.argsFor(3)[0]).toBe(
'createClass(...): `childContextTypes` is now a static property and ' +
- 'should be defined inside "statics".'
+ 'should be defined inside "statics".',
);
});
@@ -336,7 +333,7 @@ describe('ReactClass-spec', () => {
expect(function() {
instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrowError(
- 'Component.getInitialState(): must return an object or null'
+ 'Component.getInitialState(): must return an object or null',
);
});
});
@@ -350,8 +347,8 @@ describe('ReactClass-spec', () => {
return ;
},
});
- expect(
- () => ReactTestUtils.renderIntoDocument()
+ expect(() =>
+ ReactTestUtils.renderIntoDocument(),
).not.toThrow();
});
@@ -367,8 +364,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Something is calling a React component directly. Use a ' +
- 'factory or JSX instead. See: https://fb.me/react-legacyfactory'
+ 'factory or JSX instead. See: https://fb.me/react-legacyfactory',
);
});
-
});
diff --git a/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js b/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js
index 267f5f8ad9..81bc5f9123 100644
--- a/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js
+++ b/src/isomorphic/classic/class/__tests__/ReactCreateClass-test.js
@@ -17,7 +17,6 @@ var ReactTestUtils;
var createReactClass;
describe('ReactClass-spec', () => {
-
beforeEach(() => {
React = require('React');
ReactDOM = require('ReactDOM');
@@ -34,7 +33,7 @@ describe('ReactClass-spec', () => {
expect(function() {
createReactClass({});
}).toThrowError(
- 'createClass(...): Class specification must implement a `render` method.'
+ 'createClass(...): Class specification must implement a `render` method.',
);
});
@@ -46,8 +45,7 @@ describe('ReactClass-spec', () => {
},
});
- expect(TestComponent.displayName)
- .toBe('TestComponent');
+ expect(TestComponent.displayName).toBe('TestComponent');
});
it('should copy prop types onto the Constructor', () => {
@@ -62,8 +60,7 @@ describe('ReactClass-spec', () => {
});
expect(TestComponent.propTypes).toBeDefined();
- expect(TestComponent.propTypes.value)
- .toBe(propValidator);
+ expect(TestComponent.propTypes.value).toBe(propValidator);
});
it('should warn on invalid prop types', () => {
@@ -80,7 +77,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Component: prop type `prop` is invalid; ' +
- 'it must be a function, usually from React.PropTypes.'
+ 'it must be a function, usually from React.PropTypes.',
);
});
@@ -98,7 +95,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Component: context type `prop` is invalid; ' +
- 'it must be a function, usually from React.PropTypes.'
+ 'it must be a function, usually from React.PropTypes.',
);
});
@@ -116,7 +113,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Component: child context type `prop` is invalid; ' +
- 'it must be a function, usually from React.PropTypes.'
+ 'it must be a function, usually from React.PropTypes.',
);
});
@@ -134,8 +131,8 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: A component has a method called componentShouldUpdate(). Did you ' +
- 'mean shouldComponentUpdate()? The name is phrased as a question ' +
- 'because the function is expected to return a value.'
+ 'mean shouldComponentUpdate()? The name is phrased as a question ' +
+ 'because the function is expected to return a value.',
);
createReactClass({
@@ -150,8 +147,8 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(2);
expect(console.error.calls.argsFor(1)[0]).toBe(
'Warning: NamedComponent has a method called componentShouldUpdate(). Did you ' +
- 'mean shouldComponentUpdate()? The name is phrased as a question ' +
- 'because the function is expected to return a value.'
+ 'mean shouldComponentUpdate()? The name is phrased as a question ' +
+ 'because the function is expected to return a value.',
);
});
@@ -168,7 +165,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: A component has a method called componentWillRecieveProps(). Did you ' +
- 'mean componentWillReceiveProps()?'
+ 'mean componentWillReceiveProps()?',
);
});
@@ -189,9 +186,9 @@ describe('ReactClass-spec', () => {
});
}).toThrowError(
'ReactClass: You are attempting to define a reserved property, ' +
- '`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' +
- 'it as an instance property instead; it will still be accessible on ' +
- 'the constructor.'
+ '`getDefaultProps`, that shouldn\'t be on the "statics" key. Define ' +
+ 'it as an instance property instead; it will still be accessible on ' +
+ 'the constructor.',
);
});
@@ -217,19 +214,19 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(4);
expect(console.error.calls.argsFor(0)[0]).toBe(
'createClass(...): `mixins` is now a static property and should ' +
- 'be defined inside "statics".'
+ 'be defined inside "statics".',
);
expect(console.error.calls.argsFor(1)[0]).toBe(
'createClass(...): `propTypes` is now a static property and should ' +
- 'be defined inside "statics".'
+ 'be defined inside "statics".',
);
expect(console.error.calls.argsFor(2)[0]).toBe(
'createClass(...): `contextTypes` is now a static property and ' +
- 'should be defined inside "statics".'
+ 'should be defined inside "statics".',
);
expect(console.error.calls.argsFor(3)[0]).toBe(
'createClass(...): `childContextTypes` is now a static property and ' +
- 'should be defined inside "statics".'
+ 'should be defined inside "statics".',
);
});
@@ -323,7 +320,7 @@ describe('ReactClass-spec', () => {
expect(function() {
instance = ReactTestUtils.renderIntoDocument(instance);
}).toThrowError(
- 'Component.getInitialState(): must return an object or null'
+ 'Component.getInitialState(): must return an object or null',
);
});
});
@@ -337,8 +334,8 @@ describe('ReactClass-spec', () => {
return ;
},
});
- expect(
- () => ReactTestUtils.renderIntoDocument()
+ expect(() =>
+ ReactTestUtils.renderIntoDocument(),
).not.toThrow();
});
@@ -354,7 +351,7 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Something is calling a React component directly. Use a ' +
- 'factory or JSX instead. See: https://fb.me/react-legacyfactory'
+ 'factory or JSX instead. See: https://fb.me/react-legacyfactory',
);
});
@@ -362,7 +359,7 @@ describe('ReactClass-spec', () => {
var ops = [];
var Component = createReactClass({
getInitialState() {
- return { step: 0 };
+ return {step: 0};
},
render() {
ops.push('Render: ' + this.state.step);
@@ -371,14 +368,10 @@ describe('ReactClass-spec', () => {
});
var instance = ReactTestUtils.renderIntoDocument();
- instance.replaceState({ step: 1 }, () => {
+ instance.replaceState({step: 1}, () => {
ops.push('Callback: ' + instance.state.step);
});
- expect(ops).toEqual([
- 'Render: 0',
- 'Render: 1',
- 'Callback: 1',
- ]);
+ expect(ops).toEqual(['Render: 0', 'Render: 1', 'Callback: 1']);
});
it('isMounted works', () => {
@@ -437,8 +430,8 @@ describe('ReactClass-spec', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toEqual(
'Warning: MyComponent: isMounted is deprecated. Instead, make sure to ' +
- 'clean up subscriptions and pending requests in componentWillUnmount ' +
- 'to prevent memory leaks.'
+ 'clean up subscriptions and pending requests in componentWillUnmount ' +
+ 'to prevent memory leaks.',
);
});
});
diff --git a/src/isomorphic/classic/element/ReactCurrentOwner.js b/src/isomorphic/classic/element/ReactCurrentOwner.js
index da5786e875..a095fe0097 100644
--- a/src/isomorphic/classic/element/ReactCurrentOwner.js
+++ b/src/isomorphic/classic/element/ReactCurrentOwner.js
@@ -12,7 +12,7 @@
'use strict';
-import type { ReactInstance } from 'ReactInstanceType';
+import type {ReactInstance} from 'ReactInstanceType';
/**
* Keeps track of the current owner.
@@ -21,13 +21,11 @@ import type { ReactInstance } from 'ReactInstanceType';
* currently being constructed.
*/
var ReactCurrentOwner = {
-
/**
* @internal
* @type {ReactComponent}
*/
current: (null: null | ReactInstance),
-
};
module.exports = ReactCurrentOwner;
diff --git a/src/isomorphic/classic/element/ReactDOMFactories.js b/src/isomorphic/classic/element/ReactDOMFactories.js
index 4890fa676c..c6ee9fc5d1 100644
--- a/src/isomorphic/classic/element/ReactDOMFactories.js
+++ b/src/isomorphic/classic/element/ReactDOMFactories.js
@@ -141,7 +141,7 @@ var ReactDOMFactories = {
track: createDOMFactory('track'),
u: createDOMFactory('u'),
ul: createDOMFactory('ul'),
- 'var': createDOMFactory('var'),
+ var: createDOMFactory('var'),
video: createDOMFactory('video'),
wbr: createDOMFactory('wbr'),
diff --git a/src/isomorphic/classic/element/ReactElement.js b/src/isomorphic/classic/element/ReactElement.js
index 90080c7ff8..15ff177641 100644
--- a/src/isomorphic/classic/element/ReactElement.js
+++ b/src/isomorphic/classic/element/ReactElement.js
@@ -59,10 +59,10 @@ function defineKeyPropWarningGetter(props, displayName) {
warning(
false,
'%s: `key` is not a prop. Trying to access it will result ' +
- 'in `undefined` being returned. If you need to access the same ' +
- 'value within the child component, you should pass it as a different ' +
- 'prop. (https://fb.me/react-special-props)',
- displayName
+ 'in `undefined` being returned. If you need to access the same ' +
+ 'value within the child component, you should pass it as a different ' +
+ 'prop. (https://fb.me/react-special-props)',
+ displayName,
);
}
};
@@ -80,10 +80,10 @@ function defineRefPropWarningGetter(props, displayName) {
warning(
false,
'%s: `ref` is not a prop. Trying to access it will result ' +
- 'in `undefined` being returned. If you need to access the same ' +
- 'value within the child component, you should pass it as a different ' +
- 'prop. (https://fb.me/react-special-props)',
- displayName
+ 'in `undefined` being returned. If you need to access the same ' +
+ 'value within the child component, you should pass it as a different ' +
+ 'prop. (https://fb.me/react-special-props)',
+ displayName,
);
}
};
@@ -203,8 +203,10 @@ ReactElement.createElement = function(type, config, children) {
source = config.__source === undefined ? null : config.__source;
// Remaining properties are added to a new props object
for (propName in config) {
- if (hasOwnProperty.call(config, propName) &&
- !RESERVED_PROPS.hasOwnProperty(propName)) {
+ if (
+ hasOwnProperty.call(config, propName) &&
+ !RESERVED_PROPS.hasOwnProperty(propName)
+ ) {
props[propName] = config[propName];
}
}
@@ -239,11 +241,13 @@ ReactElement.createElement = function(type, config, children) {
}
if (__DEV__) {
if (key || ref) {
- if (typeof props.$$typeof === 'undefined' ||
- props.$$typeof !== REACT_ELEMENT_TYPE) {
- var displayName = typeof type === 'function' ?
- (type.displayName || type.name || 'Unknown') :
- type;
+ if (
+ typeof props.$$typeof === 'undefined' ||
+ props.$$typeof !== REACT_ELEMENT_TYPE
+ ) {
+ var displayName = typeof type === 'function'
+ ? type.displayName || type.name || 'Unknown'
+ : type;
if (key) {
defineKeyPropWarningGetter(props, displayName);
}
@@ -260,7 +264,7 @@ ReactElement.createElement = function(type, config, children) {
self,
source,
ReactCurrentOwner.current,
- props
+ props,
);
};
@@ -287,7 +291,7 @@ ReactElement.cloneAndReplaceKey = function(oldElement, newKey) {
oldElement._self,
oldElement._source,
oldElement._owner,
- oldElement.props
+ oldElement.props,
);
return newElement;
@@ -332,8 +336,10 @@ ReactElement.cloneElement = function(element, config, children) {
defaultProps = element.type.defaultProps;
}
for (propName in config) {
- if (hasOwnProperty.call(config, propName) &&
- !RESERVED_PROPS.hasOwnProperty(propName)) {
+ if (
+ hasOwnProperty.call(config, propName) &&
+ !RESERVED_PROPS.hasOwnProperty(propName)
+ ) {
if (config[propName] === undefined && defaultProps !== undefined) {
// Resolve default props
props[propName] = defaultProps[propName];
@@ -357,15 +363,7 @@ ReactElement.cloneElement = function(element, config, children) {
props.children = childArray;
}
- return ReactElement(
- element.type,
- key,
- ref,
- self,
- source,
- owner,
- props
- );
+ return ReactElement(element.type, key, ref, self, source, owner, props);
};
/**
diff --git a/src/isomorphic/classic/element/ReactElementType.js b/src/isomorphic/classic/element/ReactElementType.js
index 9702b0f77a..a0d8427b19 100644
--- a/src/isomorphic/classic/element/ReactElementType.js
+++ b/src/isomorphic/classic/element/ReactElementType.js
@@ -12,7 +12,7 @@
'use strict';
-import type { ReactInstance } from 'ReactInstanceType';
+import type {ReactInstance} from 'ReactInstanceType';
export type Source = {
fileName: string,
diff --git a/src/isomorphic/classic/element/ReactElementValidator.js b/src/isomorphic/classic/element/ReactElementValidator.js
index 6613aeeb61..b840fc5885 100644
--- a/src/isomorphic/classic/element/ReactElementValidator.js
+++ b/src/isomorphic/classic/element/ReactElementValidator.js
@@ -63,8 +63,9 @@ function getCurrentComponentErrorInfo(parentType) {
var info = getDeclarationErrorAddendum();
if (!info) {
- var parentName = typeof parentType === 'string' ?
- parentType : parentType.displayName || parentType.name;
+ var parentName = typeof parentType === 'string'
+ ? parentType
+ : parentType.displayName || parentType.name;
if (parentName) {
info = ` Check the top-level render call using <${parentName}>.`;
}
@@ -89,9 +90,8 @@ function validateExplicitKey(element, parentType) {
}
element._store.validated = true;
- var memoizer = ownerHasKeyUseWarning.uniqueKey || (
- ownerHasKeyUseWarning.uniqueKey = {}
- );
+ var memoizer =
+ ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
if (memoizer[currentComponentErrorInfo]) {
@@ -103,21 +103,22 @@ function validateExplicitKey(element, parentType) {
// property, it may be the creator of the child that's responsible for
// assigning it a key.
var childOwner = '';
- if (element &&
- element._owner &&
- element._owner !== ReactCurrentOwner.current) {
+ if (
+ element &&
+ element._owner &&
+ element._owner !== ReactCurrentOwner.current
+ ) {
// Give the component that originally created this child.
- childOwner =
- ` It was passed a child from ${element._owner.getName()}.`;
+ childOwner = ` It was passed a child from ${element._owner.getName()}.`;
}
warning(
false,
'Each child in an array or iterator should have a unique "key" prop.' +
- '%s%s See https://fb.me/react-warning-keys for more information.%s',
+ '%s%s See https://fb.me/react-warning-keys for more information.%s',
currentComponentErrorInfo,
childOwner,
- ReactComponentTreeHook.getCurrentStackAddendum(element)
+ ReactComponentTreeHook.getCurrentStackAddendum(element),
);
}
@@ -182,39 +183,35 @@ function validatePropTypes(element) {
'prop',
name,
element,
- null
+ null,
);
}
if (typeof componentClass.getDefaultProps === 'function') {
warning(
componentClass.getDefaultProps.isReactClassApproved,
'getDefaultProps is only used on classic React.createClass ' +
- 'definitions. Use a static property named `defaultProps` instead.'
+ 'definitions. Use a static property named `defaultProps` instead.',
);
}
}
var ReactElementValidator = {
-
createElement: function(type, props, children) {
var validType = typeof type === 'string' || typeof type === 'function';
// We warn in this case but don't throw. We expect the element creation to
// succeed and there will likely be errors in render.
if (!validType) {
- if (
- typeof type !== 'function' &&
- typeof type !== 'string'
- ) {
+ if (typeof type !== 'function' && typeof type !== 'string') {
var info = '';
if (
type === undefined ||
- typeof type === 'object' &&
- type !== null &&
- Object.keys(type).length === 0
+ (typeof type === 'object' &&
+ type !== null &&
+ Object.keys(type).length === 0)
) {
info +=
' You likely forgot to export your component from the file ' +
- 'it\'s defined in.';
+ "it's defined in.";
}
var sourceInfo = getSourceInfoErrorAddendum(props);
@@ -229,8 +226,8 @@ var ReactElementValidator = {
warning(
false,
'React.createElement: type is invalid -- expected a string (for ' +
- 'built-in components) or a class/function (for composite ' +
- 'components) but got: %s.%s',
+ 'built-in components) or a class/function (for composite ' +
+ 'components) but got: %s.%s',
type == null ? type : typeof type,
info,
);
@@ -262,37 +259,29 @@ var ReactElementValidator = {
},
createFactory: function(type) {
- var validatedFactory = ReactElementValidator.createElement.bind(
- null,
- type
- );
+ var validatedFactory = ReactElementValidator.createElement.bind(null, type);
// Legacy hook TODO: Warn if this is accessed
validatedFactory.type = type;
if (__DEV__) {
if (canDefineProperty) {
- Object.defineProperty(
- validatedFactory,
- 'type',
- {
- enumerable: false,
- get: function() {
- warning(
- false,
- 'Factory.type is deprecated. Access the class directly ' +
- 'before passing it to createFactory.'
- );
- Object.defineProperty(this, 'type', {
- value: type,
- });
- return type;
- },
- }
- );
+ Object.defineProperty(validatedFactory, 'type', {
+ enumerable: false,
+ get: function() {
+ warning(
+ false,
+ 'Factory.type is deprecated. Access the class directly ' +
+ 'before passing it to createFactory.',
+ );
+ Object.defineProperty(this, 'type', {
+ value: type,
+ });
+ return type;
+ },
+ });
}
}
-
return validatedFactory;
},
@@ -304,7 +293,6 @@ var ReactElementValidator = {
validatePropTypes(newElement);
return newElement;
},
-
};
module.exports = ReactElementValidator;
diff --git a/src/isomorphic/classic/element/__tests__/ReactElement-test.js b/src/isomorphic/classic/element/__tests__/ReactElement-test.js
index cf82a95309..ae5ca18691 100644
--- a/src/isomorphic/classic/element/__tests__/ReactElement-test.js
+++ b/src/isomorphic/classic/element/__tests__/ReactElement-test.js
@@ -81,9 +81,9 @@ describe('ReactElement', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'Child: `key` is not a prop. Trying to access it will result ' +
- 'in `undefined` being returned. If you need to access the same ' +
- 'value within the child component, you should pass it as a different ' +
- 'prop. (https://fb.me/react-special-props)'
+ 'in `undefined` being returned. If you need to access the same ' +
+ 'value within the child component, you should pass it as a different ' +
+ 'prop. (https://fb.me/react-special-props)',
);
});
@@ -95,9 +95,9 @@ describe('ReactElement', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'div: `key` is not a prop. Trying to access it will result ' +
- 'in `undefined` being returned. If you need to access the same ' +
- 'value within the child component, you should pass it as a different ' +
- 'prop. (https://fb.me/react-special-props)'
+ 'in `undefined` being returned. If you need to access the same ' +
+ 'value within the child component, you should pass it as a different ' +
+ 'prop. (https://fb.me/react-special-props)',
);
});
@@ -123,9 +123,9 @@ describe('ReactElement', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'Child: `ref` is not a prop. Trying to access it will result ' +
- 'in `undefined` being returned. If you need to access the same ' +
- 'value within the child component, you should pass it as a different ' +
- 'prop. (https://fb.me/react-special-props)'
+ 'in `undefined` being returned. If you need to access the same ' +
+ 'value within the child component, you should pass it as a different ' +
+ 'prop. (https://fb.me/react-special-props)',
);
});
@@ -141,7 +141,7 @@ describe('ReactElement', () => {
it('returns an immutable element', () => {
var element = React.createFactory(ComponentClass)();
- expect(() => element.type = 'div').toThrow();
+ expect(() => (element.type = 'div')).toThrow();
});
it('does not reuse the original config object', () => {
@@ -233,7 +233,7 @@ describe('ReactElement', () => {
}
var instance = ReactTestUtils.renderIntoDocument(
- React.createElement(Wrapper)
+ React.createElement(Wrapper),
);
expect(element._owner.getPublicInstance()).toBe(instance);
@@ -242,9 +242,12 @@ describe('ReactElement', () => {
it('merges an additional argument onto the children prop', () => {
spyOn(console, 'error');
var a = 1;
- var element = React.createFactory(ComponentClass)({
- children: 'text',
- }, a);
+ var element = React.createFactory(ComponentClass)(
+ {
+ children: 'text',
+ },
+ a,
+ );
expect(element.props.children).toBe(a);
expect(console.error.calls.count()).toBe(0);
});
@@ -260,9 +263,12 @@ describe('ReactElement', () => {
it('overrides children if null is provided as an argument', () => {
spyOn(console, 'error');
- var element = React.createFactory(ComponentClass)({
- children: 'text',
- }, null);
+ var element = React.createFactory(ComponentClass)(
+ {
+ children: 'text',
+ },
+ null,
+ );
expect(element.props.children).toBe(null);
expect(console.error.calls.count()).toBe(0);
});
@@ -303,10 +309,8 @@ describe('ReactElement', () => {
}
}
- expect(React.isValidElement(React.createElement('div')))
- .toEqual(true);
- expect(React.isValidElement(React.createElement(Component)))
- .toEqual(true);
+ expect(React.isValidElement(React.createElement('div'))).toEqual(true);
+ expect(React.isValidElement(React.createElement(Component))).toEqual(true);
expect(React.isValidElement(null)).toEqual(false);
expect(React.isValidElement(true)).toEqual(false);
@@ -314,7 +318,7 @@ describe('ReactElement', () => {
expect(React.isValidElement('string')).toEqual(false);
expect(React.isValidElement(React.DOM.div)).toEqual(false);
expect(React.isValidElement(Component)).toEqual(false);
- expect(React.isValidElement({ type: 'div', props: {} })).toEqual(false);
+ expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
var jsonElement = JSON.stringify(React.createElement('div'));
expect(React.isValidElement(JSON.parse(jsonElement))).toBe(true);
@@ -341,7 +345,7 @@ describe('ReactElement', () => {
var container = document.createElement('div');
var instance = ReactDOM.render(
React.createElement(Component, {fruit: 'mango'}),
- container
+ container,
);
expect(instance.props.fruit).toBe('mango');
@@ -360,12 +364,12 @@ describe('ReactElement', () => {
Component.defaultProps = {prop: 'testKey'};
var instance = ReactTestUtils.renderIntoDocument(
- React.createElement(Component)
+ React.createElement(Component),
);
expect(instance.props.prop).toBe('testKey');
var inst2 = ReactTestUtils.renderIntoDocument(
- React.createElement(Component, {prop: null})
+ React.createElement(Component, {prop: null}),
);
expect(inst2.props.prop).toBe(null);
});
@@ -448,10 +452,8 @@ describe('ReactElement', () => {
}
}
- expect(React.isValidElement(React.createElement('div')))
- .toEqual(true);
- expect(React.isValidElement(React.createElement(Component)))
- .toEqual(true);
+ expect(React.isValidElement(React.createElement('div'))).toEqual(true);
+ expect(React.isValidElement(React.createElement(Component))).toEqual(true);
expect(React.isValidElement(null)).toEqual(false);
expect(React.isValidElement(true)).toEqual(false);
@@ -459,12 +461,11 @@ describe('ReactElement', () => {
expect(React.isValidElement('string')).toEqual(false);
expect(React.isValidElement(React.DOM.div)).toEqual(false);
expect(React.isValidElement(Component)).toEqual(false);
- expect(React.isValidElement({ type: 'div', props: {} })).toEqual(false);
+ expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
var jsonElement = JSON.stringify(React.createElement('div'));
expect(React.isValidElement(JSON.parse(jsonElement))).toBe(false);
});
-
});
describe('comparing jsx vs .createFactory() vs .createElement()', () => {
@@ -478,7 +479,6 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
Child = jest.genMockFromModule('ReactElementTestChild');
});
-
describe('when using jsx only', () => {
var Parent, instance;
beforeEach(() => {
@@ -491,11 +491,14 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
);
}
};
- instance = ReactTestUtils.renderIntoDocument();
+ instance = ReactTestUtils.renderIntoDocument();
});
it('should scry children but cannot', () => {
- var children = ReactTestUtils.scryRenderedComponentsWithType(instance, Child);
+ var children = ReactTestUtils.scryRenderedComponentsWithType(
+ instance,
+ Child,
+ );
expect(children.length).toBe(1);
});
@@ -504,7 +507,10 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
});
it('can capture Child instantiation calls', () => {
- expect(Child.mock.calls[0][0]).toEqual({ foo: 'foo value', children: 'children value' });
+ expect(Child.mock.calls[0][0]).toEqual({
+ foo: 'foo value',
+ children: 'children value',
+ });
});
});
@@ -514,7 +520,10 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
var childFactory = React.createFactory(Child);
class Parent extends React.Component {
render() {
- return React.DOM.div({}, childFactory({ ref: 'child', foo: 'foo value' }, 'children value'));
+ return React.DOM.div(
+ {},
+ childFactory({ref: 'child', foo: 'foo value'}, 'children value'),
+ );
}
}
factory = React.createFactory(Parent);
@@ -522,7 +531,10 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
});
it('can properly scry children', () => {
- var children = ReactTestUtils.scryRenderedComponentsWithType(instance, Child);
+ var children = ReactTestUtils.scryRenderedComponentsWithType(
+ instance,
+ Child,
+ );
expect(children.length).toBe(1);
});
@@ -531,7 +543,10 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
});
it('can capture Child instantiation calls', () => {
- expect(Child.mock.calls[0][0]).toEqual({ foo: 'foo value', children: 'children value' });
+ expect(Child.mock.calls[0][0]).toEqual({
+ foo: 'foo value',
+ children: 'children value',
+ });
});
});
@@ -540,7 +555,14 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
beforeEach(() => {
class Parent extends React.Component {
render() {
- return React.DOM.div({}, React.createElement(Child, { ref: 'child', foo: 'foo value' }, 'children value'));
+ return React.DOM.div(
+ {},
+ React.createElement(
+ Child,
+ {ref: 'child', foo: 'foo value'},
+ 'children value',
+ ),
+ );
}
}
factory = React.createFactory(Parent);
@@ -548,7 +570,10 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
});
it('should scry children but cannot', () => {
- var children = ReactTestUtils.scryRenderedComponentsWithType(instance, Child);
+ var children = ReactTestUtils.scryRenderedComponentsWithType(
+ instance,
+ Child,
+ );
expect(children.length).toBe(1);
});
@@ -557,8 +582,10 @@ describe('comparing jsx vs .createFactory() vs .createElement()', () => {
});
it('can capture Child instantiation calls', () => {
- expect(Child.mock.calls[0][0]).toEqual({ foo: 'foo value', children: 'children value' });
+ expect(Child.mock.calls[0][0]).toEqual({
+ foo: 'foo value',
+ children: 'children value',
+ });
});
});
-
});
diff --git a/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js b/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
index 69e8984ca2..298c47c1b4 100644
--- a/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
+++ b/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
@@ -42,7 +42,7 @@ describe('ReactElementClone', () => {
render() {
return (
;
@@ -218,7 +225,7 @@ describe('ReactElementClone', () => {
}
ReactTestUtils.renderIntoDocument(
- React.cloneElement(, {myprop: 'xyz'})
+ React.cloneElement(, {myprop: 'xyz'}),
);
});
@@ -250,7 +257,7 @@ describe('ReactElementClone', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'Each child in an array or iterator should have a unique "key" prop.'
+ 'Each child in an array or iterator should have a unique "key" prop.',
);
});
@@ -295,21 +302,20 @@ describe('ReactElementClone', () => {
}
class GrandParent extends React.Component {
render() {
- return React.createElement(
- Parent,
- { child: React.createElement(Component, {color: 'red'}) }
- );
+ return React.createElement(Parent, {
+ child: React.createElement(Component, {color: 'red'}),
+ });
}
}
ReactTestUtils.renderIntoDocument(React.createElement(GrandParent));
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Failed prop type: ' +
- 'Invalid prop `color` of type `number` supplied to `Component`, ' +
- 'expected `string`.\n' +
- ' in Component (created by GrandParent)\n' +
- ' in Parent (created by GrandParent)\n' +
- ' in GrandParent'
+ 'Invalid prop `color` of type `number` supplied to `Component`, ' +
+ 'expected `string`.\n' +
+ ' in Component (created by GrandParent)\n' +
+ ' in Parent (created by GrandParent)\n' +
+ ' in GrandParent',
);
});
@@ -359,5 +365,4 @@ describe('ReactElementClone', () => {
expect(Object.isFrozen(element.props)).toBe(true);
expect(clone.props).toEqual({foo: 'ef'});
});
-
});
diff --git a/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js b/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
index f2e403c5a4..f73ea16cff 100644
--- a/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+++ b/src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
@@ -46,7 +46,7 @@ describe('ReactElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'Each child in an array or iterator should have a unique "key" prop.'
+ 'Each child in an array or iterator should have a unique "key" prop.',
);
});
@@ -64,19 +64,17 @@ describe('ReactElementValidator', () => {
class ComponentWrapper extends React.Component {
render() {
- return InnerComponent({childSet: [Component(), Component()] });
+ return InnerComponent({childSet: [Component(), Component()]});
}
}
- ReactTestUtils.renderIntoDocument(
- React.createElement(ComponentWrapper)
- );
+ ReactTestUtils.renderIntoDocument(React.createElement(ComponentWrapper));
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'Each child in an array or iterator should have a unique "key" prop. ' +
- 'Check the render method of `InnerClass`. ' +
- 'It was passed a child from ComponentWrapper. '
+ 'Check the render method of `InnerClass`. ' +
+ 'It was passed a child from ComponentWrapper. ',
);
});
@@ -86,37 +84,31 @@ describe('ReactElementValidator', () => {
function Anonymous() {
return ;
}
- Object.defineProperty(Anonymous, 'name', { value: undefined });
+ Object.defineProperty(Anonymous, 'name', {value: undefined});
- var divs = [
- ,
- ,
- ];
+ var divs = [, ];
ReactTestUtils.renderIntoDocument({divs});
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Each child in an array or iterator should have a unique ' +
- '"key" prop. See https://fb.me/react-warning-keys for more information.\n' +
- ' in div (at **)'
+ '"key" prop. See https://fb.me/react-warning-keys for more information.\n' +
+ ' in div (at **)',
);
});
it('warns for keys for arrays of elements with no owner info', () => {
spyOn(console, 'error');
- var divs = [
- ,
- ,
- ];
+ var divs = [, ];
ReactTestUtils.renderIntoDocument(
{divs}
);
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Each child in an array or iterator should have a unique ' +
- '"key" prop. Check the top-level render call using
. See ' +
- 'https://fb.me/react-warning-keys for more information.\n' +
- ' in div (at **)'
+ '"key" prop. Check the top-level render call using
. See ' +
+ 'https://fb.me/react-warning-keys for more information.\n' +
+ ' in div (at **)',
);
});
@@ -140,12 +132,12 @@ describe('ReactElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Each child in an array or iterator should have a unique ' +
- '"key" prop. Check the render method of `Component`. See ' +
- 'https://fb.me/react-warning-keys for more information.\n' +
- ' in div (at **)\n' +
- ' in Component (at **)\n' +
- ' in Parent (at **)\n' +
- ' in GrandParent (at **)'
+ '"key" prop. Check the render method of `Component`. See ' +
+ 'https://fb.me/react-warning-keys for more information.\n' +
+ ' in div (at **)\n' +
+ ' in Component (at **)\n' +
+ ' in Parent (at **)\n' +
+ ' in GrandParent (at **)',
);
});
@@ -165,7 +157,7 @@ describe('ReactElementValidator', () => {
-
+ ,
);
expect(console.error.calls.count()).toBe(0);
@@ -191,7 +183,7 @@ describe('ReactElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'Each child in an array or iterator should have a unique "key" prop.'
+ 'Each child in an array or iterator should have a unique "key" prop.',
);
});
@@ -266,10 +258,10 @@ describe('ReactElementValidator', () => {
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Failed prop type: ' +
- 'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
- 'expected `string`.\n' +
- ' in MyComp (created by ParentComp)\n' +
- ' in ParentComp'
+ 'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
+ 'expected `string`.\n' +
+ ' in MyComp (created by ParentComp)\n' +
+ ' in ParentComp',
);
});
@@ -284,35 +276,35 @@ describe('ReactElementValidator', () => {
expect(console.error.calls.count()).toBe(6);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: undefined. You likely forgot to export your ' +
- 'component from the file it\'s defined in.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: undefined. You likely forgot to export your ' +
+ "component from the file it's defined in.",
);
expect(console.error.calls.argsFor(1)[0]).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: null.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: null.',
);
expect(console.error.calls.argsFor(2)[0]).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: boolean.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: boolean.',
);
expect(console.error.calls.argsFor(3)[0]).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: number.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: number.',
);
expect(console.error.calls.argsFor(4)[0]).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: object.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: object.',
);
expect(console.error.calls.argsFor(5)[0]).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: object. You likely forgot to export your ' +
- 'component from the file it\'s defined in.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: object. You likely forgot to export your ' +
+ "component from the file it's defined in.",
);
React.createElement('div');
expect(console.error.calls.count()).toBe(6);
@@ -327,15 +319,15 @@ describe('ReactElementValidator', () => {
ReactTestUtils.renderIntoDocument(React.createElement(ParentComp));
}).toThrowError(
'Element type is invalid: expected a string (for built-in components) ' +
- 'or a class/function (for composite components) but got: null. Check ' +
- 'the render method of `ParentComp`.'
+ 'or a class/function (for composite components) but got: null. Check ' +
+ 'the render method of `ParentComp`.',
);
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: null. Check the render method of `ParentComp`.' +
- '\n in ParentComp'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: null. Check the render method of `ParentComp`.' +
+ '\n in ParentComp',
);
});
@@ -355,8 +347,8 @@ describe('ReactElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Failed prop type: The prop `prop` is marked as required in ' +
- '`Component`, but its value is `null`.\n' +
- ' in Component'
+ '`Component`, but its value is `null`.\n' +
+ ' in Component',
);
});
@@ -372,14 +364,14 @@ describe('ReactElementValidator', () => {
Component.defaultProps = {prop: 'text'};
ReactTestUtils.renderIntoDocument(
- React.createElement(Component, {prop:null})
+ React.createElement(Component, {prop: null}),
);
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Failed prop type: The prop `prop` is marked as required in ' +
- '`Component`, but its value is `null`.\n' +
- ' in Component'
+ '`Component`, but its value is `null`.\n' +
+ ' in Component',
);
});
@@ -395,30 +387,28 @@ describe('ReactElementValidator', () => {
prop: React.PropTypes.string.isRequired,
};
+ ReactTestUtils.renderIntoDocument(React.createElement(Component));
ReactTestUtils.renderIntoDocument(
- React.createElement(Component)
- );
- ReactTestUtils.renderIntoDocument(
- React.createElement(Component, {prop: 42})
+ React.createElement(Component, {prop: 42}),
);
expect(console.error.calls.count()).toBe(2);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Failed prop type: ' +
- 'The prop `prop` is marked as required in `Component`, but its value ' +
- 'is `undefined`.\n' +
- ' in Component'
+ 'The prop `prop` is marked as required in `Component`, but its value ' +
+ 'is `undefined`.\n' +
+ ' in Component',
);
expect(console.error.calls.argsFor(1)[0]).toBe(
'Warning: Failed prop type: ' +
- 'Invalid prop `prop` of type `number` supplied to ' +
- '`Component`, expected `string`.\n' +
- ' in Component'
+ 'Invalid prop `prop` of type `number` supplied to ' +
+ '`Component`, expected `string`.\n' +
+ ' in Component',
);
ReactTestUtils.renderIntoDocument(
- React.createElement(Component, {prop: 'string'})
+ React.createElement(Component, {prop: 'string'}),
);
// Should not error for strings
@@ -431,7 +421,6 @@ describe('ReactElementValidator', () => {
class Component extends React.Component {
render() {
return React.createElement('span', null, this.props.myProp.value);
-
}
}
Component.propTypes = {
@@ -439,16 +428,16 @@ describe('ReactElementValidator', () => {
};
ReactTestUtils.renderIntoDocument(
- React.createElement(Component, {myProp: {value: 'hi'}})
+ React.createElement(Component, {myProp: {value: 'hi'}}),
);
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Component: type specification of prop `myProp` is invalid; ' +
- 'the type checker function must return `null` or an `Error` but ' +
- 'returned a function. You may have forgotten to pass an argument to ' +
- 'the type checker creator (arrayOf, instanceOf, objectOf, oneOf, ' +
- 'oneOfType, and shape all require an argument).'
+ 'the type checker function must return `null` or an `Error` but ' +
+ 'returned a function. You may have forgotten to pass an argument to ' +
+ 'the type checker creator (arrayOf, instanceOf, objectOf, oneOf, ' +
+ 'oneOfType, and shape all require an argument).',
);
});
@@ -462,7 +451,7 @@ describe('ReactElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Factory.type is deprecated. Access the class directly before ' +
- 'passing it to createFactory.'
+ 'passing it to createFactory.',
);
// Warn once, not again
expect(TestFactory.type).toBe(TestComponent);
@@ -511,7 +500,7 @@ describe('ReactElementValidator', () => {
// shouldn't blow up either.
var child = {
- $$typeof: ().$$typeof,
+ $$typeof: .$$typeof,
type: 'span',
key: null,
ref: null,
@@ -529,10 +518,9 @@ describe('ReactElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: undefined. You likely forgot to export your ' +
- 'component from the file it\'s defined in. Check your code at **.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: undefined. You likely forgot to export your ' +
+ "component from the file it's defined in. Check your code at **.",
);
});
-
});
diff --git a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
index 26cb0fa205..ab9f56bbc8 100644
--- a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
+++ b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
@@ -28,16 +28,18 @@ function typeCheckFail(declaration, value, message) {
'testComponent',
'prop',
null,
- ReactPropTypesSecret
+ ReactPropTypesSecret,
);
expect(error instanceof Error).toBe(true);
expect(error.message).toBe(message);
}
function typeCheckFailRequiredValues(declaration) {
- var specifiedButIsNullMsg = 'The prop `testProp` is marked as required in ' +
+ var specifiedButIsNullMsg =
+ 'The prop `testProp` is marked as required in ' +
'`testComponent`, but its value is `null`.';
- var unspecifiedMsg = 'The prop `testProp` is marked as required in ' +
+ var unspecifiedMsg =
+ 'The prop `testProp` is marked as required in ' +
'`testComponent`, but its value is \`undefined\`.';
var props1 = {testProp: null};
var error1 = declaration(
@@ -46,7 +48,7 @@ function typeCheckFailRequiredValues(declaration) {
'testComponent',
'prop',
null,
- ReactPropTypesSecret
+ ReactPropTypesSecret,
);
expect(error1 instanceof Error).toBe(true);
expect(error1.message).toBe(specifiedButIsNullMsg);
@@ -57,7 +59,7 @@ function typeCheckFailRequiredValues(declaration) {
'testComponent',
'prop',
null,
- ReactPropTypesSecret
+ ReactPropTypesSecret,
);
expect(error2 instanceof Error).toBe(true);
expect(error2.message).toBe(unspecifiedMsg);
@@ -68,7 +70,7 @@ function typeCheckFailRequiredValues(declaration) {
'testComponent',
'prop',
null,
- ReactPropTypesSecret
+ ReactPropTypesSecret,
);
expect(error3 instanceof Error).toBe(true);
expect(error3.message).toBe(unspecifiedMsg);
@@ -82,7 +84,7 @@ function typeCheckPass(declaration, value) {
'testComponent',
'prop',
null,
- ReactPropTypesSecret
+ ReactPropTypesSecret,
);
expect(error).toBe(null);
}
@@ -92,16 +94,11 @@ function expectWarningInDevelopment(declaration, value) {
var propName = 'testProp' + Math.random().toString();
var componentName = 'testComponent' + Math.random().toString();
for (var i = 0; i < 3; i++) {
- declaration(
- props,
- propName,
- componentName,
- 'prop'
- );
+ declaration(props, propName, componentName, 'prop');
}
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'You are manually calling a React.PropTypes validation '
+ 'You are manually calling a React.PropTypes validation ',
);
console.error.calls.reset();
}
@@ -121,31 +118,31 @@ describe('ReactPropTypes', () => {
PropTypes.string,
[],
'Invalid prop `testProp` of type `array` supplied to ' +
- '`testComponent`, expected `string`.'
+ '`testComponent`, expected `string`.',
);
typeCheckFail(
PropTypes.string,
false,
'Invalid prop `testProp` of type `boolean` supplied to ' +
- '`testComponent`, expected `string`.'
+ '`testComponent`, expected `string`.',
);
typeCheckFail(
PropTypes.string,
0,
'Invalid prop `testProp` of type `number` supplied to ' +
- '`testComponent`, expected `string`.'
+ '`testComponent`, expected `string`.',
);
typeCheckFail(
PropTypes.string,
{},
'Invalid prop `testProp` of type `object` supplied to ' +
- '`testComponent`, expected `string`.'
+ '`testComponent`, expected `string`.',
);
typeCheckFail(
PropTypes.string,
Symbol(),
'Invalid prop `testProp` of type `symbol` supplied to ' +
- '`testComponent`, expected `string`.'
+ '`testComponent`, expected `string`.',
);
});
@@ -154,13 +151,13 @@ describe('ReactPropTypes', () => {
PropTypes.string,
new Date(),
'Invalid prop `testProp` of type `date` supplied to ' +
- '`testComponent`, expected `string`.'
+ '`testComponent`, expected `string`.',
);
typeCheckFail(
PropTypes.string,
/please/,
'Invalid prop `testProp` of type `regexp` supplied to ' +
- '`testComponent`, expected `string`.'
+ '`testComponent`, expected `string`.',
);
});
@@ -260,9 +257,9 @@ describe('ReactPropTypes', () => {
describe('ArrayOf Type', () => {
it('should fail for invalid argument', () => {
typeCheckFail(
- PropTypes.arrayOf({ foo: PropTypes.string }),
- { foo: 'bar' },
- 'Property `testProp` of component `testComponent` has invalid PropType notation inside arrayOf.'
+ PropTypes.arrayOf({foo: PropTypes.string}),
+ {foo: 'bar'},
+ 'Property `testProp` of component `testComponent` has invalid PropType notation inside arrayOf.',
);
});
@@ -276,14 +273,14 @@ describe('ReactPropTypes', () => {
it('should support arrayOf with complex types', () => {
typeCheckPass(
PropTypes.arrayOf(PropTypes.shape({a: PropTypes.number.isRequired})),
- [{a: 1}, {a: 2}]
+ [{a: 1}, {a: 2}],
);
function Thing() {}
- typeCheckPass(
- PropTypes.arrayOf(PropTypes.instanceOf(Thing)),
- [new Thing(), new Thing()]
- );
+ typeCheckPass(PropTypes.arrayOf(PropTypes.instanceOf(Thing)), [
+ new Thing(),
+ new Thing(),
+ ]);
});
it('should warn with invalid items in the array', () => {
@@ -291,7 +288,7 @@ describe('ReactPropTypes', () => {
PropTypes.arrayOf(PropTypes.number),
[1, 2, 'b'],
'Invalid prop `testProp[2]` of type `string` supplied to ' +
- '`testComponent`, expected `number`.'
+ '`testComponent`, expected `number`.',
);
});
@@ -303,7 +300,9 @@ describe('ReactPropTypes', () => {
PropTypes.arrayOf(PropTypes.instanceOf(Thing)),
[new Thing(), 'xyz'],
'Invalid prop `testProp[1]` of type `String` supplied to ' +
- '`testComponent`, expected instance of `' + name + '`.'
+ '`testComponent`, expected instance of `' +
+ name +
+ '`.',
);
});
@@ -312,19 +311,19 @@ describe('ReactPropTypes', () => {
PropTypes.arrayOf(PropTypes.number),
{'0': 'maybe-array', length: 1},
'Invalid prop `testProp` of type `object` supplied to ' +
- '`testComponent`, expected an array.'
+ '`testComponent`, expected an array.',
);
typeCheckFail(
PropTypes.arrayOf(PropTypes.number),
123,
'Invalid prop `testProp` of type `number` supplied to ' +
- '`testComponent`, expected an array.'
+ '`testComponent`, expected an array.',
);
typeCheckFail(
PropTypes.arrayOf(PropTypes.number),
'string',
'Invalid prop `testProp` of type `string` supplied to ' +
- '`testComponent`, expected an array.'
+ '`testComponent`, expected an array.',
);
});
@@ -339,26 +338,32 @@ describe('ReactPropTypes', () => {
it('should warn for missing required values', () => {
typeCheckFailRequiredValues(
- PropTypes.arrayOf(PropTypes.number).isRequired
+ PropTypes.arrayOf(PropTypes.number).isRequired,
);
});
it('should warn if called manually in development', () => {
spyOn(console, 'error');
+ expectWarningInDevelopment(PropTypes.arrayOf({foo: PropTypes.string}), {
+ foo: 'bar',
+ });
+ expectWarningInDevelopment(PropTypes.arrayOf(PropTypes.number), [
+ 1,
+ 2,
+ 'b',
+ ]);
+ expectWarningInDevelopment(PropTypes.arrayOf(PropTypes.number), {
+ '0': 'maybe-array',
+ length: 1,
+ });
expectWarningInDevelopment(
- PropTypes.arrayOf({ foo: PropTypes.string }),
- { foo: 'bar' }
+ PropTypes.arrayOf(PropTypes.number).isRequired,
+ null,
);
expectWarningInDevelopment(
- PropTypes.arrayOf(PropTypes.number),
- [1, 2, 'b']
+ PropTypes.arrayOf(PropTypes.number).isRequired,
+ undefined,
);
- expectWarningInDevelopment(
- PropTypes.arrayOf(PropTypes.number),
- {'0': 'maybe-array', length: 1}
- );
- expectWarningInDevelopment(PropTypes.arrayOf(PropTypes.number).isRequired, null);
- expectWarningInDevelopment(PropTypes.arrayOf(PropTypes.number).isRequired, undefined);
});
});
@@ -384,25 +389,25 @@ describe('ReactPropTypes', () => {
PropTypes.element,
[, ],
'Invalid prop `testProp` of type `array` supplied to `testComponent`, ' +
- 'expected a single ReactElement.'
+ 'expected a single ReactElement.',
);
typeCheckFail(
PropTypes.element,
123,
'Invalid prop `testProp` of type `number` supplied to `testComponent`, ' +
- 'expected a single ReactElement.'
+ 'expected a single ReactElement.',
);
typeCheckFail(
PropTypes.element,
'foo',
'Invalid prop `testProp` of type `string` supplied to `testComponent`, ' +
- 'expected a single ReactElement.'
+ 'expected a single ReactElement.',
);
typeCheckFail(
PropTypes.element,
false,
'Invalid prop `testProp` of type `boolean` supplied to `testComponent`, ' +
- 'expected a single ReactElement.'
+ 'expected a single ReactElement.',
);
});
@@ -443,7 +448,6 @@ describe('ReactPropTypes', () => {
expectWarningInDevelopment(PropTypes.element.isRequired, null);
expectWarningInDevelopment(PropTypes.element.isRequired, undefined);
});
-
});
describe('Instance Types', () => {
@@ -458,43 +462,57 @@ describe('ReactPropTypes', () => {
PropTypes.instanceOf(Person),
false,
'Invalid prop `testProp` of type `Boolean` supplied to ' +
- '`testComponent`, expected instance of `' + personName + '`.'
+ '`testComponent`, expected instance of `' +
+ personName +
+ '`.',
);
typeCheckFail(
PropTypes.instanceOf(Person),
{},
'Invalid prop `testProp` of type `Object` supplied to ' +
- '`testComponent`, expected instance of `' + personName + '`.'
+ '`testComponent`, expected instance of `' +
+ personName +
+ '`.',
);
typeCheckFail(
PropTypes.instanceOf(Person),
'',
'Invalid prop `testProp` of type `String` supplied to ' +
- '`testComponent`, expected instance of `' + personName + '`.'
+ '`testComponent`, expected instance of `' +
+ personName +
+ '`.',
);
typeCheckFail(
PropTypes.instanceOf(Date),
{},
'Invalid prop `testProp` of type `Object` supplied to ' +
- '`testComponent`, expected instance of `' + dateName + '`.'
+ '`testComponent`, expected instance of `' +
+ dateName +
+ '`.',
);
typeCheckFail(
PropTypes.instanceOf(RegExp),
{},
'Invalid prop `testProp` of type `Object` supplied to ' +
- '`testComponent`, expected instance of `' + regExpName + '`.'
+ '`testComponent`, expected instance of `' +
+ regExpName +
+ '`.',
);
typeCheckFail(
PropTypes.instanceOf(Person),
new Cat(),
'Invalid prop `testProp` of type `Cat` supplied to ' +
- '`testComponent`, expected instance of `' + personName + '`.'
+ '`testComponent`, expected instance of `' +
+ personName +
+ '`.',
);
typeCheckFail(
PropTypes.instanceOf(Person),
Object.create(null),
'Invalid prop `testProp` of type `<>` supplied to ' +
- '`testComponent`, expected instance of `' + personName + '`.'
+ '`testComponent`, expected instance of `' +
+ personName +
+ '`.',
);
});
@@ -524,9 +542,11 @@ describe('ReactPropTypes', () => {
expectWarningInDevelopment(PropTypes.instanceOf(Date), {});
expectWarningInDevelopment(PropTypes.instanceOf(Date), new Date());
expectWarningInDevelopment(PropTypes.instanceOf(Date).isRequired, {});
- expectWarningInDevelopment(PropTypes.instanceOf(Date).isRequired, new Date());
+ expectWarningInDevelopment(
+ PropTypes.instanceOf(Date).isRequired,
+ new Date(),
+ );
});
-
});
describe('React Component Types', () => {
@@ -539,7 +559,8 @@ describe('ReactPropTypes', () => {
});
it('should warn for invalid values', () => {
- var failMessage = 'Invalid prop `testProp` supplied to ' +
+ var failMessage =
+ 'Invalid prop `testProp` supplied to ' +
'`testComponent`, expected a ReactNode.';
typeCheckFail(PropTypes.node, true, failMessage);
typeCheckFail(PropTypes.node, function() {}, failMessage);
@@ -565,18 +586,21 @@ describe('ReactPropTypes', () => {
// Object of renderable things
var frag = ReactFragment.create;
- typeCheckPass(PropTypes.node, frag({
- k0: 123,
- k1: 'Some string',
- k2: ,
- k3: frag({
- k30: ,
- k31: frag({k310: }),
- k32: 'Another string',
+ typeCheckPass(
+ PropTypes.node,
+ frag({
+ k0: 123,
+ k1: 'Some string',
+ k2: ,
+ k3: frag({
+ k30: ,
+ k31: frag({k310: }),
+ k32: 'Another string',
+ }),
+ k4: null,
+ k5: undefined,
}),
- k4: null,
- k5: undefined,
- }));
+ );
expect(console.error.calls.count()).toBe(0);
});
@@ -603,7 +627,10 @@ describe('ReactPropTypes', () => {
return {
next: function() {
var done = ++i > 2;
- return {value: done ? undefined : ['#' + i, ], done: done};
+ return {
+ value: done ? undefined : ['#' + i, ],
+ done: done,
+ };
},
};
},
@@ -634,45 +661,46 @@ describe('ReactPropTypes', () => {
expectWarningInDevelopment(PropTypes.node.isRequired, undefined);
expectWarningInDevelopment(PropTypes.node.isRequired, undefined);
});
-
});
describe('ObjectOf Type', () => {
it('should fail for invalid argument', () => {
typeCheckFail(
- PropTypes.objectOf({ foo: PropTypes.string }),
- { foo: 'bar' },
- 'Property `testProp` of component `testComponent` has invalid PropType notation inside objectOf.'
+ PropTypes.objectOf({foo: PropTypes.string}),
+ {foo: 'bar'},
+ 'Property `testProp` of component `testComponent` has invalid PropType notation inside objectOf.',
);
});
it('should support the objectOf propTypes', () => {
typeCheckPass(PropTypes.objectOf(PropTypes.number), {a: 1, b: 2, c: 3});
- typeCheckPass(
- PropTypes.objectOf(PropTypes.string),
- {a: 'a', b: 'b', c: 'c'}
- );
- typeCheckPass(
- PropTypes.objectOf(PropTypes.oneOf(['a', 'b'])),
- {a: 'a', b: 'b'}
- );
- typeCheckPass(
- PropTypes.objectOf(PropTypes.symbol),
- {a: Symbol(), b: Symbol(), c: Symbol()}
- );
+ typeCheckPass(PropTypes.objectOf(PropTypes.string), {
+ a: 'a',
+ b: 'b',
+ c: 'c',
+ });
+ typeCheckPass(PropTypes.objectOf(PropTypes.oneOf(['a', 'b'])), {
+ a: 'a',
+ b: 'b',
+ });
+ typeCheckPass(PropTypes.objectOf(PropTypes.symbol), {
+ a: Symbol(),
+ b: Symbol(),
+ c: Symbol(),
+ });
});
it('should support objectOf with complex types', () => {
typeCheckPass(
PropTypes.objectOf(PropTypes.shape({a: PropTypes.number.isRequired})),
- {a: {a: 1}, b: {a: 2}}
+ {a: {a: 1}, b: {a: 2}},
);
function Thing() {}
- typeCheckPass(
- PropTypes.objectOf(PropTypes.instanceOf(Thing)),
- {a: new Thing(), b: new Thing()}
- );
+ typeCheckPass(PropTypes.objectOf(PropTypes.instanceOf(Thing)), {
+ a: new Thing(),
+ b: new Thing(),
+ });
});
it('should warn with invalid items in the object', () => {
@@ -680,7 +708,7 @@ describe('ReactPropTypes', () => {
PropTypes.objectOf(PropTypes.number),
{a: 1, b: 2, c: 'b'},
'Invalid prop `testProp.c` of type `string` supplied to `testComponent`, ' +
- 'expected `number`.'
+ 'expected `number`.',
);
});
@@ -692,7 +720,9 @@ describe('ReactPropTypes', () => {
PropTypes.objectOf(PropTypes.instanceOf(Thing)),
{a: new Thing(), b: 'xyz'},
'Invalid prop `testProp.b` of type `String` supplied to ' +
- '`testComponent`, expected instance of `' + name + '`.'
+ '`testComponent`, expected instance of `' +
+ name +
+ '`.',
);
});
@@ -701,25 +731,25 @@ describe('ReactPropTypes', () => {
PropTypes.objectOf(PropTypes.number),
[1, 2],
'Invalid prop `testProp` of type `array` supplied to ' +
- '`testComponent`, expected an object.'
+ '`testComponent`, expected an object.',
);
typeCheckFail(
PropTypes.objectOf(PropTypes.number),
123,
'Invalid prop `testProp` of type `number` supplied to ' +
- '`testComponent`, expected an object.'
+ '`testComponent`, expected an object.',
);
typeCheckFail(
PropTypes.objectOf(PropTypes.number),
'string',
'Invalid prop `testProp` of type `string` supplied to ' +
- '`testComponent`, expected an object.'
+ '`testComponent`, expected an object.',
);
typeCheckFail(
PropTypes.objectOf(PropTypes.symbol),
Symbol(),
'Invalid prop `testProp` of type `symbol` supplied to ' +
- '`testComponent`, expected an object.'
+ '`testComponent`, expected an object.',
);
});
@@ -734,23 +764,26 @@ describe('ReactPropTypes', () => {
it('should warn for missing required values', () => {
typeCheckFailRequiredValues(
- PropTypes.objectOf(PropTypes.number).isRequired
+ PropTypes.objectOf(PropTypes.number).isRequired,
);
});
it('should warn if called manually in development', () => {
spyOn(console, 'error');
- expectWarningInDevelopment(
- PropTypes.objectOf({ foo: PropTypes.string }),
- { foo: 'bar' }
- );
- expectWarningInDevelopment(
- PropTypes.objectOf(PropTypes.number),
- {a: 1, b: 2, c: 'b'}
- );
+ expectWarningInDevelopment(PropTypes.objectOf({foo: PropTypes.string}), {
+ foo: 'bar',
+ });
+ expectWarningInDevelopment(PropTypes.objectOf(PropTypes.number), {
+ a: 1,
+ b: 2,
+ c: 'b',
+ });
expectWarningInDevelopment(PropTypes.objectOf(PropTypes.number), [1, 2]);
expectWarningInDevelopment(PropTypes.objectOf(PropTypes.number), null);
- expectWarningInDevelopment(PropTypes.objectOf(PropTypes.number), undefined);
+ expectWarningInDevelopment(
+ PropTypes.objectOf(PropTypes.number),
+ undefined,
+ );
});
});
@@ -761,8 +794,9 @@ describe('ReactPropTypes', () => {
PropTypes.oneOf('red', 'blue');
expect(console.error).toHaveBeenCalled();
- expect(console.error.calls.argsFor(0)[0])
- .toContain('Invalid argument supplied to oneOf, expected an instance of array.');
+ expect(console.error.calls.argsFor(0)[0]).toContain(
+ 'Invalid argument supplied to oneOf, expected an instance of array.',
+ );
typeCheckPass(PropTypes.oneOf('red', 'blue'), 'red');
});
@@ -772,25 +806,25 @@ describe('ReactPropTypes', () => {
PropTypes.oneOf(['red', 'blue']),
true,
'Invalid prop `testProp` of value `true` supplied to ' +
- '`testComponent`, expected one of ["red","blue"].'
+ '`testComponent`, expected one of ["red","blue"].',
);
typeCheckFail(
PropTypes.oneOf(['red', 'blue']),
[],
'Invalid prop `testProp` of value `` supplied to `testComponent`, ' +
- 'expected one of ["red","blue"].'
+ 'expected one of ["red","blue"].',
);
typeCheckFail(
PropTypes.oneOf(['red', 'blue']),
'',
'Invalid prop `testProp` of value `` supplied to `testComponent`, ' +
- 'expected one of ["red","blue"].'
+ 'expected one of ["red","blue"].',
);
typeCheckFail(
PropTypes.oneOf([0, 'false']),
false,
'Invalid prop `testProp` of value `false` supplied to ' +
- '`testComponent`, expected one of [0,"false"].'
+ '`testComponent`, expected one of [0,"false"].',
);
});
@@ -824,8 +858,9 @@ describe('ReactPropTypes', () => {
PropTypes.oneOfType(PropTypes.string, PropTypes.number);
expect(console.error).toHaveBeenCalled();
- expect(console.error.calls.argsFor(0)[0])
- .toContain('Invalid argument supplied to oneOfType, expected an instance of array.');
+ expect(console.error.calls.argsFor(0)[0]).toContain(
+ 'Invalid argument supplied to oneOfType, expected an instance of array.',
+ );
typeCheckPass(PropTypes.oneOf(PropTypes.string, PropTypes.number), []);
});
@@ -834,7 +869,7 @@ describe('ReactPropTypes', () => {
typeCheckFail(
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
[],
- 'Invalid prop `testProp` supplied to `testComponent`.'
+ 'Invalid prop `testProp` supplied to `testComponent`.',
);
var checker = PropTypes.oneOfType([
@@ -844,15 +879,12 @@ describe('ReactPropTypes', () => {
typeCheckFail(
checker,
{c: 1},
- 'Invalid prop `testProp` supplied to `testComponent`.'
+ 'Invalid prop `testProp` supplied to `testComponent`.',
);
});
it('should not warn if one of the types are valid', () => {
- var checker = PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number,
- ]);
+ var checker = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
typeCheckPass(checker, null);
typeCheckPass(checker, 'foo');
typeCheckPass(checker, 123);
@@ -867,16 +899,18 @@ describe('ReactPropTypes', () => {
it('should be implicitly optional and not warn without values', () => {
typeCheckPass(
- PropTypes.oneOfType([PropTypes.string, PropTypes.number]), null
+ PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ null,
);
typeCheckPass(
- PropTypes.oneOfType([PropTypes.string, PropTypes.number]), undefined
+ PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ undefined,
);
});
it('should warn for missing required values', () => {
typeCheckFailRequiredValues(
- PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
+ PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
);
});
@@ -884,18 +918,17 @@ describe('ReactPropTypes', () => {
spyOn(console, 'error');
expectWarningInDevelopment(
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- []
+ [],
);
expectWarningInDevelopment(
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- null
+ null,
);
expectWarningInDevelopment(
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
- undefined
+ undefined,
);
});
-
});
describe('Shape Types', () => {
@@ -904,13 +937,13 @@ describe('ReactPropTypes', () => {
PropTypes.shape({}),
'some string',
'Invalid prop `testProp` of type `string` supplied to ' +
- '`testComponent`, expected `object`.'
+ '`testComponent`, expected `object`.',
);
typeCheckFail(
PropTypes.shape({}),
['array'],
'Invalid prop `testProp` of type `array` supplied to ' +
- '`testComponent`, expected `object`.'
+ '`testComponent`, expected `object`.',
);
});
@@ -937,7 +970,7 @@ describe('ReactPropTypes', () => {
PropTypes.shape({key: PropTypes.number.isRequired}),
{},
'The prop `testProp.key` is marked as required in `testComponent`, ' +
- 'but its value is `undefined`.'
+ 'but its value is `undefined`.',
);
});
@@ -949,44 +982,49 @@ describe('ReactPropTypes', () => {
}),
{},
'The prop `testProp.key` is marked as required in `testComponent`, ' +
- 'but its value is `undefined`.'
+ 'but its value is `undefined`.',
);
});
it('should warn for invalid key types', () => {
- typeCheckFail(PropTypes.shape({key: PropTypes.number}),
+ typeCheckFail(
+ PropTypes.shape({key: PropTypes.number}),
{key: 'abc'},
'Invalid prop `testProp.key` of type `string` supplied to `testComponent`, ' +
- 'expected `number`.'
+ 'expected `number`.',
);
});
it('should be implicitly optional and not warn without values', () => {
typeCheckPass(
- PropTypes.shape(PropTypes.shape({key: PropTypes.number})), null
+ PropTypes.shape(PropTypes.shape({key: PropTypes.number})),
+ null,
);
typeCheckPass(
- PropTypes.shape(PropTypes.shape({key: PropTypes.number})), undefined
+ PropTypes.shape(PropTypes.shape({key: PropTypes.number})),
+ undefined,
);
});
it('should warn for missing required values', () => {
typeCheckFailRequiredValues(
- PropTypes.shape({key: PropTypes.number}).isRequired
+ PropTypes.shape({key: PropTypes.number}).isRequired,
);
});
it('should warn if called manually in development', () => {
spyOn(console, 'error');
expectWarningInDevelopment(PropTypes.shape({}), 'some string');
- expectWarningInDevelopment(PropTypes.shape({ foo: PropTypes.number }), { foo: 42 });
+ expectWarningInDevelopment(PropTypes.shape({foo: PropTypes.number}), {
+ foo: 42,
+ });
expectWarningInDevelopment(
PropTypes.shape({key: PropTypes.number}).isRequired,
- null
+ null,
);
expectWarningInDevelopment(
PropTypes.shape({key: PropTypes.number}).isRequired,
- undefined
+ undefined,
);
expectWarningInDevelopment(PropTypes.element, );
});
@@ -998,13 +1036,13 @@ describe('ReactPropTypes', () => {
PropTypes.symbol,
'hello',
'Invalid prop `testProp` of type `string` supplied to ' +
- '`testComponent`, expected `symbol`.'
+ '`testComponent`, expected `symbol`.',
);
typeCheckFail(
PropTypes.symbol,
- function() { },
+ function() {},
'Invalid prop `testProp` of type `function` supplied to ' +
- '`testComponent`, expected `symbol`.'
+ '`testComponent`, expected `symbol`.',
);
typeCheckFail(
PropTypes.symbol,
@@ -1012,7 +1050,7 @@ describe('ReactPropTypes', () => {
'@@toStringTag': 'Katana',
},
'Invalid prop `testProp` of type `object` supplied to ' +
- '`testComponent`, expected `symbol`.'
+ '`testComponent`, expected `symbol`.',
);
});
@@ -1061,15 +1099,15 @@ describe('ReactPropTypes', () => {
expect(spy.calls.argsFor(0)[1]).toBe('num');
});
- it('should have received the validator\'s return value', () => {
+ it("should have received the validator's return value", () => {
spyOn(console, 'error');
- var spy = jasmine.createSpy().and.callFake(
- function(props, propName, componentName) {
+ var spy = jasmine
+ .createSpy()
+ .and.callFake(function(props, propName, componentName) {
if (props[propName] !== 5) {
return new Error('num must be 5!');
}
- }
- );
+ });
Component = class extends React.Component {
static propTypes = {num: spy};
@@ -1082,33 +1120,31 @@ describe('ReactPropTypes', () => {
ReactTestUtils.renderIntoDocument(instance);
expect(console.error.calls.count()).toBe(1);
expect(
- console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)')
+ console.error.calls.argsFor(0)[0].replace(/\(at .+?:\d+\)/g, '(at **)'),
).toBe(
'Warning: Failed prop type: num must be 5!\n' +
- ' in Component (at **)'
+ ' in Component (at **)',
);
});
- it('should not warn if the validator returned null',
- () => {
- spyOn(console, 'error');
- var spy = jasmine.createSpy().and.callFake(
- function(props, propName, componentName) {
- return null;
- }
- );
- Component = class extends React.Component {
- static propTypes = {num: spy};
+ it('should not warn if the validator returned null', () => {
+ spyOn(console, 'error');
+ var spy = jasmine
+ .createSpy()
+ .and.callFake(function(props, propName, componentName) {
+ return null;
+ });
+ Component = class extends React.Component {
+ static propTypes = {num: spy};
- render() {
- return ;
- }
- };
+ render() {
+ return ;
+ }
+ };
- var instance = ;
- ReactTestUtils.renderIntoDocument(instance);
- expect(console.error.calls.count()).toBe(0);
- }
- );
+ var instance = ;
+ ReactTestUtils.renderIntoDocument(instance);
+ expect(console.error.calls.count()).toBe(0);
+ });
});
});
diff --git a/src/isomorphic/hooks/ReactComponentTreeHook.js b/src/isomorphic/hooks/ReactComponentTreeHook.js
index fd778f7536..b294881519 100644
--- a/src/isomorphic/hooks/ReactComponentTreeHook.js
+++ b/src/isomorphic/hooks/ReactComponentTreeHook.js
@@ -17,23 +17,26 @@ var ReactCurrentOwner = require('ReactCurrentOwner');
var invariant = require('invariant');
var warning = require('warning');
-import type { ReactElement, Source } from 'ReactElementType';
-import type { DebugID } from 'ReactInstanceType';
+import type {ReactElement, Source} from 'ReactElementType';
+import type {DebugID} from 'ReactInstanceType';
function isNative(fn) {
// Based on isNative() from Lodash
var funcToString = Function.prototype.toString;
var hasOwnProperty = Object.prototype.hasOwnProperty;
- var reIsNative = RegExp('^' + funcToString
- // Take an example native function source for comparison
- .call(hasOwnProperty)
- // Strip regex characters so we can use it for regex
- .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
- // Remove hasOwnProperty from the template to make it generic
- .replace(
- /hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,
- '$1.*?'
- ) + '$'
+ var reIsNative = RegExp(
+ '^' +
+ funcToString
+ // Take an example native function source for comparison
+ .call(hasOwnProperty)
+ // Strip regex characters so we can use it for regex
+ .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
+ // Remove hasOwnProperty from the template to make it generic
+ .replace(
+ /hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,
+ '$1.*?',
+ ) +
+ '$',
);
try {
var source = funcToString.call(fn);
@@ -43,7 +46,7 @@ function isNative(fn) {
}
}
-var canUseCollections = (
+var canUseCollections =
// Array.from
typeof Array.from === 'function' &&
// Map
@@ -59,8 +62,7 @@ var canUseCollections = (
// Set.prototype.keys
Set.prototype != null &&
typeof Set.prototype.keys === 'function' &&
- isNative(Set.prototype.keys)
-);
+ isNative(Set.prototype.keys);
var setItem;
var getItem;
@@ -96,7 +98,6 @@ if (canUseCollections) {
getRootIDs = function() {
return Array.from(rootIDSet.keys());
};
-
} else {
var itemByKey = {};
var rootByKey = {};
@@ -151,13 +152,16 @@ function purgeDeep(id) {
}
function describeComponentFrame(name, source, ownerName) {
- return '\n in ' + (name || 'Unknown') + (
- source ?
- ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' +
- source.lineNumber + ')' :
- ownerName ?
- ' (created by ' + ownerName + ')' :
- ''
+ return (
+ '\n in ' +
+ (name || 'Unknown') +
+ (source
+ ? ' (at ' +
+ source.fileName.replace(/^.*[\\\/]/, '') +
+ ':' +
+ source.lineNumber +
+ ')'
+ : ownerName ? ' (created by ' + ownerName + ')' : '')
);
}
@@ -184,8 +188,8 @@ function describeID(id: DebugID): string {
warning(
element,
'ReactComponentTreeHook: Missing React element for debugID %s when ' +
- 'building stack',
- id
+ 'building stack',
+ id,
);
return describeComponentFrame(name, element && element._source, ownerName);
}
@@ -202,19 +206,19 @@ var ReactComponentTreeHook = {
invariant(
nextChild,
'Expected hook events to fire for the child ' +
- 'before its parent includes it in onSetChildren().'
+ 'before its parent includes it in onSetChildren().',
);
invariant(
nextChild.childIDs != null ||
- typeof nextChild.element !== 'object' ||
- nextChild.element == null,
+ typeof nextChild.element !== 'object' ||
+ nextChild.element == null,
'Expected onSetChildren() to fire for a container child ' +
- 'before its parent includes it in onSetChildren().'
+ 'before its parent includes it in onSetChildren().',
);
invariant(
nextChild.isMounted,
'Expected onMountComponent() to fire for the child ' +
- 'before its parent includes it in onSetChildren().'
+ 'before its parent includes it in onSetChildren().',
);
if (nextChild.parentID == null) {
nextChild.parentID = id;
@@ -225,15 +229,19 @@ var ReactComponentTreeHook = {
invariant(
nextChild.parentID === id,
'Expected onBeforeMountComponent() parent and onSetChildren() to ' +
- 'be consistent (%s has parents %s and %s).',
+ 'be consistent (%s has parents %s and %s).',
nextChildID,
nextChild.parentID,
- id
+ id,
);
}
},
- onBeforeMountComponent(id: DebugID, element: ReactElement, parentID: DebugID): void {
+ onBeforeMountComponent(
+ id: DebugID,
+ element: ReactElement,
+ parentID: DebugID,
+ ): void {
var item = {
element,
parentID,
@@ -318,7 +326,7 @@ var ReactComponentTreeHook = {
info += describeComponentFrame(
name,
topElement._source,
- owner && owner.getName()
+ owner && owner.getName(),
);
}
diff --git a/src/isomorphic/modern/class/ReactComponent.js b/src/isomorphic/modern/class/ReactComponent.js
index b93da63e94..f0ab6fd090 100644
--- a/src/isomorphic/modern/class/ReactComponent.js
+++ b/src/isomorphic/modern/class/ReactComponent.js
@@ -60,10 +60,10 @@ ReactComponent.prototype.isReactComponent = {};
ReactComponent.prototype.setState = function(partialState, callback) {
invariant(
typeof partialState === 'object' ||
- typeof partialState === 'function' ||
- partialState == null,
+ typeof partialState === 'function' ||
+ partialState == null,
'setState(...): takes an object of state variables to update or a ' +
- 'function which returns an object of state variables.'
+ 'function which returns an object of state variables.',
);
this.updater.enqueueSetState(this, partialState);
if (callback) {
@@ -102,12 +102,12 @@ if (__DEV__) {
isMounted: [
'isMounted',
'Instead, make sure to clean up subscriptions and pending requests in ' +
- 'componentWillUnmount to prevent memory leaks.',
+ 'componentWillUnmount to prevent memory leaks.',
],
replaceState: [
'replaceState',
'Refactor your code to use setState instead (see ' +
- 'https://github.com/facebook/react/issues/3236).',
+ 'https://github.com/facebook/react/issues/3236).',
],
};
var defineDeprecationWarning = function(methodName, info) {
@@ -118,7 +118,7 @@ if (__DEV__) {
false,
'%s(...) is deprecated in plain JavaScript React classes. %s',
info[0],
- info[1]
+ info[1],
);
return undefined;
},
diff --git a/src/isomorphic/modern/class/ReactNoopUpdateQueue.js b/src/isomorphic/modern/class/ReactNoopUpdateQueue.js
index 49d4c72660..c9e03b723e 100644
--- a/src/isomorphic/modern/class/ReactNoopUpdateQueue.js
+++ b/src/isomorphic/modern/class/ReactNoopUpdateQueue.js
@@ -19,11 +19,12 @@ function warnNoop(publicInstance, callerName) {
warning(
false,
'%s(...): Can only update a mounted or mounting component. ' +
- 'This usually means you called %s() on an unmounted component. ' +
- 'This is a no-op. Please check the code for the %s component.',
+ 'This usually means you called %s() on an unmounted component. ' +
+ 'This is a no-op. Please check the code for the %s component.',
callerName,
callerName,
- constructor && (constructor.displayName || constructor.name) || 'ReactClass'
+ (constructor && (constructor.displayName || constructor.name)) ||
+ 'ReactClass',
);
}
}
@@ -32,7 +33,6 @@ function warnNoop(publicInstance, callerName) {
* This is the abstract API for an update queue.
*/
var ReactNoopUpdateQueue = {
-
/**
* Checks whether or not this composite component is mounted.
* @param {ReactClass} publicInstance The instance we want to test.
@@ -52,7 +52,7 @@ var ReactNoopUpdateQueue = {
* @param {?function} callback Called after state is updated.
* @internal
*/
- enqueueCallback: function(publicInstance, callback) { },
+ enqueueCallback: function(publicInstance, callback) {},
/**
* Forces an update. This should only be invoked when it is known with
diff --git a/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js b/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
index b78a2edab1..bfa6c3b214 100644
--- a/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
+++ b/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
@@ -26,7 +26,6 @@ describe('ReactClassEquivalence', () => {
var result2 = runJest('ReactES6Class-test.js');
compareResults(result1, result2);
});
-
});
function runJest(testFile) {
@@ -35,14 +34,13 @@ function runJest(testFile) {
var setupFile = path.resolve(
'scripts',
'jest',
- 'setupSpecEquivalenceReporter.js'
+ 'setupSpecEquivalenceReporter.js',
+ );
+ var result = spawnSync(
+ 'node',
+ [jestBin, testFile, '--setupTestFrameworkScriptFile', setupFile],
+ {cwd},
);
- var result = spawnSync('node', [
- jestBin,
- testFile,
- '--setupTestFrameworkScriptFile',
- setupFile,
- ], {cwd});
if (result.error) {
throw result.error;
@@ -51,12 +49,12 @@ function runJest(testFile) {
if (result.status !== 0) {
throw new Error(
'jest process exited with: ' +
- result.status +
- '\n' +
- 'stdout: ' +
- result.stdout.toString() +
- 'stderr: ' +
- result.stderr.toString()
+ result.status +
+ '\n' +
+ 'stdout: ' +
+ result.stdout.toString() +
+ 'stderr: ' +
+ result.stderr.toString(),
);
}
diff --git a/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js b/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
index ca34089157..ca25525532 100644
--- a/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
+++ b/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
@@ -15,7 +15,6 @@ var React;
var ReactDOM;
describe('ReactES6Class', () => {
-
var container;
var freeze = function(expectation) {
Object.freeze(expectation);
@@ -52,19 +51,19 @@ describe('ReactES6Class', () => {
}
it('preserves the name of the class for use in error messages', () => {
- class Foo extends React.Component { }
+ class Foo extends React.Component {}
expect(Foo.name).toBe('Foo');
});
it('throws if no render function is defined', () => {
spyOn(console, 'error');
- class Foo extends React.Component { }
+ class Foo extends React.Component {}
expect(() => ReactDOM.render(, container)).toThrow();
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Foo(...): No `render` method found on the returned component ' +
- 'instance: you may have forgotten to define `render`.'
+ 'instance: you may have forgotten to define `render`.',
);
});
@@ -174,7 +173,7 @@ describe('ReactES6Class', () => {
}
}
expect(() => test(, 'span', '')).toThrowError(
- 'Foo.state: must be set to an object or null'
+ 'Foo.state: must be set to an object or null',
);
});
});
@@ -203,10 +202,7 @@ describe('ReactES6Class', () => {
}
render() {
return (
-
+
);
}
}
@@ -225,12 +221,7 @@ describe('ReactES6Class', () => {
this.setState({bar: 'bar'});
}
render() {
- return (
-
- );
+ return ;
}
}
test(, 'DIV', 'foo');
@@ -295,23 +286,25 @@ describe('ReactES6Class', () => {
}
}
test(, 'SPAN', 'foo');
- expect(lifeCycles).toEqual([
- 'will-mount',
- 'did-mount',
- ]);
+ expect(lifeCycles).toEqual(['will-mount', 'did-mount']);
lifeCycles = []; // reset
test(, 'SPAN', 'bar');
expect(lifeCycles).toEqual([
- 'receive-props', freeze({value: 'bar'}),
- 'should-update', freeze({value: 'bar'}), {},
- 'will-update', freeze({value: 'bar'}), {},
- 'did-update', freeze({value: 'foo'}), {},
+ 'receive-props',
+ freeze({value: 'bar'}),
+ 'should-update',
+ freeze({value: 'bar'}),
+ {},
+ 'will-update',
+ freeze({value: 'bar'}),
+ {},
+ 'did-update',
+ freeze({value: 'foo'}),
+ {},
]);
lifeCycles = []; // reset
ReactDOM.unmountComponentAtNode(container);
- expect(lifeCycles).toEqual([
- 'will-unmount',
- ]);
+ expect(lifeCycles).toEqual(['will-unmount']);
});
it('warns when classic properties are defined on the instance, but does not invoke them.', () => {
@@ -341,16 +334,16 @@ describe('ReactES6Class', () => {
expect(getDefaultPropsWasCalled).toBe(false);
expect(console.error.calls.count()).toBe(4);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'getInitialState was defined on Foo, a plain JavaScript class.'
+ 'getInitialState was defined on Foo, a plain JavaScript class.',
);
expect(console.error.calls.argsFor(1)[0]).toContain(
- 'getDefaultProps was defined on Foo, a plain JavaScript class.'
+ 'getDefaultProps was defined on Foo, a plain JavaScript class.',
);
expect(console.error.calls.argsFor(2)[0]).toContain(
- 'propTypes was defined as an instance property on Foo.'
+ 'propTypes was defined as an instance property on Foo.',
);
expect(console.error.calls.argsFor(3)[0]).toContain(
- 'contextTypes was defined as an instance property on Foo.'
+ 'contextTypes was defined as an instance property on Foo.',
);
});
@@ -385,9 +378,9 @@ describe('ReactES6Class', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: ' +
- 'NamedComponent has a method called componentShouldUpdate(). Did you ' +
- 'mean shouldComponentUpdate()? The name is phrased as a question ' +
- 'because the function is expected to return a value.'
+ 'NamedComponent has a method called componentShouldUpdate(). Did you ' +
+ 'mean shouldComponentUpdate()? The name is phrased as a question ' +
+ 'because the function is expected to return a value.',
);
});
@@ -407,8 +400,8 @@ describe('ReactES6Class', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: ' +
- 'NamedComponent has a method called componentWillRecieveProps(). Did ' +
- 'you mean componentWillReceiveProps()?'
+ 'NamedComponent has a method called componentWillRecieveProps(). Did ' +
+ 'you mean componentWillReceiveProps()?',
);
});
@@ -419,10 +412,10 @@ describe('ReactES6Class', () => {
expect(() => instance.isMounted()).toThrow();
expect(console.error.calls.count()).toBe(2);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'replaceState(...) is deprecated in plain JavaScript React classes'
+ 'replaceState(...) is deprecated in plain JavaScript React classes',
);
expect(console.error.calls.argsFor(1)[0]).toContain(
- 'isMounted(...) is deprecated in plain JavaScript React classes'
+ 'isMounted(...) is deprecated in plain JavaScript React classes',
);
});
@@ -460,5 +453,4 @@ describe('ReactES6Class', () => {
var node = ReactDOM.findDOMNode(instance);
expect(node).toBe(container.firstChild);
});
-
});
diff --git a/src/isomorphic/modern/class/__tests__/ReactPureComponent-test.js b/src/isomorphic/modern/class/__tests__/ReactPureComponent-test.js
index 1235a1ea82..0cf7f751a7 100644
--- a/src/isomorphic/modern/class/__tests__/ReactPureComponent-test.js
+++ b/src/isomorphic/modern/class/__tests__/ReactPureComponent-test.js
@@ -93,5 +93,4 @@ describe('ReactPureComponent', () => {
ReactDOM.render(, document.createElement('div'));
expect(renders).toBe(1);
});
-
});
diff --git a/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js b/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
index 1b897494f6..fc494b436c 100644
--- a/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+++ b/src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
@@ -64,7 +64,7 @@ describe('ReactJSXElement', () => {
it('returns an immutable element', () => {
var element = ;
- expect(() => element.type = 'div').toThrow();
+ expect(() => (element.type = 'div')).toThrow();
});
it('does not reuse the object that is spread into props', () => {
@@ -80,7 +80,7 @@ describe('ReactJSXElement', () => {
expect(element.type).toBe(Component);
expect(element.key).toBe('12');
expect(element.ref).toBe('34');
- var expectation = {foo:'56'};
+ var expectation = {foo: '56'};
Object.freeze(expectation);
expect(element.props).toEqual(expectation);
});
@@ -90,7 +90,7 @@ describe('ReactJSXElement', () => {
expect(element.type).toBe(Component);
expect(element.key).toBe('12');
expect(element.ref).toBe(null);
- var expectation = {foo:'56'};
+ var expectation = {foo: '56'};
Object.freeze(expectation);
expect(element.props).toEqual(expectation);
});
@@ -124,7 +124,7 @@ describe('ReactJSXElement', () => {
var element2 = React.cloneElement(
,
{},
- undefined
+ undefined,
);
expect(element2.props.children).toBe(undefined);
});
@@ -165,7 +165,7 @@ describe('ReactJSXElement', () => {
expect(React.isValidElement({})).toEqual(false);
expect(React.isValidElement('string')).toEqual(false);
expect(React.isValidElement(Component)).toEqual(false);
- expect(React.isValidElement({ type: 'div', props: {} })).toEqual(false);
+ expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
});
it('is indistinguishable from a plain object', () => {
@@ -178,10 +178,7 @@ describe('ReactJSXElement', () => {
Component.defaultProps = {fruit: 'persimmon'};
var container = document.createElement('div');
- var instance = ReactDOM.render(
- ,
- container
- );
+ var instance = ReactDOM.render(, container);
expect(instance.props.fruit).toBe('mango');
ReactDOM.render(, container);
@@ -199,9 +196,9 @@ describe('ReactJSXElement', () => {
var instance = ReactTestUtils.renderIntoDocument();
expect(instance.props.prop).toBe('testKey');
- var inst2 =
- ReactTestUtils.renderIntoDocument();
+ var inst2 = ReactTestUtils.renderIntoDocument(
+ ,
+ );
expect(inst2.props.prop).toBe(null);
});
-
});
diff --git a/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js b/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
index 5bb44c6943..f11cfacfe4 100644
--- a/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
+++ b/src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
@@ -55,7 +55,7 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'Each child in an array or iterator should have a unique "key" prop.'
+ 'Each child in an array or iterator should have a unique "key" prop.',
);
});
@@ -70,11 +70,7 @@ describe('ReactJSXElementValidator', () => {
class ComponentWrapper extends React.Component {
render() {
- return (
- , ]}
- />
- );
+ return , ]} />;
}
}
@@ -83,8 +79,8 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'Each child in an array or iterator should have a unique "key" prop. ' +
- 'Check the render method of `InnerComponent`. ' +
- 'It was passed a child from ComponentWrapper. '
+ 'Check the render method of `InnerComponent`. ' +
+ 'It was passed a child from ComponentWrapper. ',
);
});
@@ -107,14 +103,16 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
- 'Each child in an array or iterator should have a unique "key" prop.'
+ 'Each child in an array or iterator should have a unique "key" prop.',
);
});
it('does not warns for arrays of elements with keys', () => {
spyOn(console, 'error');
- void {[, ]};
+ void (
+ {[, ]}
+ );
expect(console.error.calls.count()).toBe(0);
});
@@ -203,10 +201,10 @@ describe('ReactJSXElementValidator', () => {
ReactTestUtils.renderIntoDocument();
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed prop type: ' +
- 'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
- 'expected `string`.\n' +
- ' in MyComp (at **)\n' +
- ' in ParentComp (at **)'
+ 'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
+ 'expected `string`.\n' +
+ ' in MyComp (at **)\n' +
+ ' in ParentComp (at **)',
);
});
@@ -239,11 +237,11 @@ describe('ReactJSXElementValidator', () => {
// If it doesn't, it means we're using information from the old element.
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed prop type: ' +
- 'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
- 'expected `string`.\n' +
- ' in MyComp (at **)\n' +
- ' in MiddleComp (at **)\n' +
- ' in ParentComp (at **)'
+ 'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
+ 'expected `string`.\n' +
+ ' in MyComp (at **)\n' +
+ ' in MiddleComp (at **)\n' +
+ ' in ParentComp (at **)',
);
});
@@ -261,28 +259,28 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(4);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: undefined. You likely forgot to export your ' +
- 'component from the file it\'s defined in. ' +
- 'Check your code at **.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: undefined. You likely forgot to export your ' +
+ "component from the file it's defined in. " +
+ 'Check your code at **.',
);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: null. ' +
- 'Check your code at **.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: null. ' +
+ 'Check your code at **.',
);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(2)[0])).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: boolean. ' +
- 'Check your code at **.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: boolean. ' +
+ 'Check your code at **.',
);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(3)[0])).toBe(
'Warning: React.createElement: type is invalid -- expected a string ' +
- '(for built-in components) or a class/function (for composite ' +
- 'components) but got: number. ' +
- 'Check your code at **.'
+ '(for built-in components) or a class/function (for composite ' +
+ 'components) but got: number. ' +
+ 'Check your code at **.',
);
void ;
expect(console.error.calls.count()).toBe(4);
@@ -298,8 +296,8 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed prop type: The prop `prop` is marked as required in ' +
- '`RequiredPropComponent`, but its value is `null`.\n' +
- ' in RequiredPropComponent (at **)'
+ '`RequiredPropComponent`, but its value is `null`.\n' +
+ ' in RequiredPropComponent (at **)',
);
});
@@ -311,8 +309,8 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed prop type: The prop `prop` is marked as required in ' +
- '`RequiredPropComponent`, but its value is `null`.\n' +
- ' in RequiredPropComponent (at **)'
+ '`RequiredPropComponent`, but its value is `null`.\n' +
+ ' in RequiredPropComponent (at **)',
);
});
@@ -325,16 +323,16 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(2);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(0)[0])).toBe(
'Warning: Failed prop type: ' +
- 'The prop `prop` is marked as required in `RequiredPropComponent`, but ' +
- 'its value is `undefined`.\n' +
- ' in RequiredPropComponent (at **)'
+ 'The prop `prop` is marked as required in `RequiredPropComponent`, but ' +
+ 'its value is `undefined`.\n' +
+ ' in RequiredPropComponent (at **)',
);
expect(normalizeCodeLocInfo(console.error.calls.argsFor(1)[0])).toBe(
'Warning: Failed prop type: ' +
- 'Invalid prop `prop` of type `number` supplied to ' +
- '`RequiredPropComponent`, expected `string`.\n' +
- ' in RequiredPropComponent (at **)'
+ 'Invalid prop `prop` of type `number` supplied to ' +
+ '`RequiredPropComponent`, expected `string`.\n' +
+ ' in RequiredPropComponent (at **)',
);
ReactTestUtils.renderIntoDocument();
@@ -361,7 +359,7 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'NullPropTypeComponent: prop type `prop` is invalid; it must be a ' +
- 'function, usually from React.PropTypes.'
+ 'function, usually from React.PropTypes.',
);
});
@@ -379,7 +377,7 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'NullContextTypeComponent: context type `prop` is invalid; it must ' +
- 'be a function, usually from React.PropTypes.'
+ 'be a function, usually from React.PropTypes.',
);
});
@@ -397,8 +395,7 @@ describe('ReactJSXElementValidator', () => {
expect(console.error.calls.count()).toBe(1);
expect(console.error.calls.argsFor(0)[0]).toContain(
'getDefaultProps is only used on classic React.createClass definitions.' +
- ' Use a static property named `defaultProps` instead.'
+ ' Use a static property named `defaultProps` instead.',
);
});
-
});
diff --git a/src/renderers/art/ReactART.js b/src/renderers/art/ReactART.js
index be85e1f238..b2d977a3ae 100644
--- a/src/renderers/art/ReactART.js
+++ b/src/renderers/art/ReactART.js
@@ -12,7 +12,7 @@
'use strict';
require('art/modes/current').setCurrent(
- require('art/modes/fast-noSideEffects') // Flip this to DOM mode for debugging
+ require('art/modes/fast-noSideEffects'), // Flip this to DOM mode for debugging
);
const Transform = require('art/core/transform');
@@ -67,8 +67,10 @@ function createComponent(name) {
*/
function injectAfter(parentNode, referenceNode, node) {
let beforeNode;
- if (node.parentNode === parentNode &&
- node.previousSibling === referenceNode) {
+ if (
+ node.parentNode === parentNode &&
+ node.previousSibling === referenceNode
+ ) {
return;
}
if (referenceNode == null) {
@@ -83,7 +85,7 @@ function injectAfter(parentNode, referenceNode, node) {
// checks and the behavior isn't well-defined.
invariant(
node !== beforeNode,
- 'ReactART: Can not insert node before itself'
+ 'ReactART: Can not insert node before itself',
);
node.injectBefore(beforeNode);
} else if (node.parentNode !== parentNode) {
@@ -94,7 +96,6 @@ function injectAfter(parentNode, referenceNode, node) {
// ContainerMixin for components that can hold ART nodes
const ContainerMixin = assign({}, ReactMultiChild.Mixin, {
-
/**
* Moves a child component to the supplied index.
*
@@ -153,11 +154,7 @@ const ContainerMixin = assign({}, ReactMultiChild.Mixin, {
// Shorthands
mountAndInjectChildren: function(children, transaction, context) {
- const mountedImages = this.mountChildren(
- children,
- transaction,
- context
- );
+ const mountedImages = this.mountChildren(children, transaction, context);
// Each mount image corresponds to one of the flattened children
let i = 0;
for (let key in this._renderedChildren) {
@@ -168,15 +165,13 @@ const ContainerMixin = assign({}, ReactMultiChild.Mixin, {
i++;
}
}
- }
-
+ },
});
// Surface is a React DOM Component, not an ART component. It serves as the
// entry point into the ART reconciler.
const Surface = React.createClass({
-
displayName: 'Surface',
mixins: [ContainerMixin],
@@ -192,15 +187,17 @@ const Surface = React.createClass({
this,
this.props.children,
transaction,
- ReactInstanceMap.get(this)._context
+ ReactInstanceMap.get(this)._context,
);
ReactUpdates.ReactReconcileTransaction.release(transaction);
},
componentDidUpdate: function(oldProps) {
const node = this.node;
- if (this.props.width != oldProps.width ||
- this.props.height != oldProps.height) {
+ if (
+ this.props.width != oldProps.width ||
+ this.props.height != oldProps.height
+ ) {
node.resize(+this.props.width, +this.props.height);
}
@@ -210,7 +207,7 @@ const Surface = React.createClass({
this,
this.props.children,
transaction,
- ReactInstanceMap.get(this)._context
+ ReactInstanceMap.get(this)._context,
);
ReactUpdates.ReactReconcileTransaction.release(transaction);
@@ -241,8 +238,7 @@ const Surface = React.createClass({
title={props.title}
/>
);
- }
-
+ },
});
// Various nodes that can go into a surface
@@ -253,11 +249,10 @@ const EventTypes = {
onMouseOut: 'mouseout',
onMouseUp: 'mouseup',
onMouseDown: 'mousedown',
- onClick: 'click'
+ onClick: 'click',
};
const NodeMixin = {
-
construct: function(element) {
this._currentElement = element;
},
@@ -312,10 +307,12 @@ const NodeMixin = {
applyNodeProps: function(oldProps, props) {
const node = this.node;
- const scaleX = props.scaleX != null ? props.scaleX :
- props.scale != null ? props.scale : 1;
- const scaleY = props.scaleY != null ? props.scaleY :
- props.scale != null ? props.scale : 1;
+ const scaleX = props.scaleX != null
+ ? props.scaleX
+ : props.scale != null ? props.scale : 1;
+ const scaleY = props.scaleY != null
+ ? props.scaleY
+ : props.scale != null ? props.scale : 1;
pooledTransform
.transformTo(1, 0, 0, 1, 0, 0)
@@ -327,9 +324,14 @@ const NodeMixin = {
pooledTransform.transform(props.transform);
}
- if (node.xx !== pooledTransform.xx || node.yx !== pooledTransform.yx ||
- node.xy !== pooledTransform.xy || node.yy !== pooledTransform.yy ||
- node.x !== pooledTransform.x || node.y !== pooledTransform.y) {
+ if (
+ node.xx !== pooledTransform.xx ||
+ node.yx !== pooledTransform.yx ||
+ node.xy !== pooledTransform.xy ||
+ node.yy !== pooledTransform.yy ||
+ node.x !== pooledTransform.x ||
+ node.y !== pooledTransform.y
+ ) {
node.transformTo(pooledTransform);
}
@@ -357,21 +359,19 @@ const NodeMixin = {
mountComponentIntoNode: function(rootID, container) {
throw new Error(
'You cannot render an ART component standalone. ' +
- 'You need to wrap it in a Surface.'
+ 'You need to wrap it in a Surface.',
);
- }
-
+ },
};
// Group
const Group = createComponent('Group', NodeMixin, ContainerMixin, {
-
mountComponent: function(
transaction,
nativeParent,
nativeContainerInfo,
- context
+ context,
) {
this.node = Mode.Group();
const props = this._currentElement.props;
@@ -397,55 +397,54 @@ const Group = createComponent('Group', NodeMixin, ContainerMixin, {
unmountComponent: function() {
this.destroyEventListeners();
this.unmountChildren();
- }
-
+ },
});
// ClippingRectangle
const ClippingRectangle = createComponent(
- 'ClippingRectangle', NodeMixin, ContainerMixin, {
+ 'ClippingRectangle',
+ NodeMixin,
+ ContainerMixin,
+ {
+ mountComponent: function(
+ transaction,
+ nativeParent,
+ nativeContainerInfo,
+ context,
+ ) {
+ this.node = Mode.ClippingRectangle();
+ const props = this._currentElement.props;
+ this.applyClippingProps(emptyObject, props);
+ this.mountAndInjectChildren(props.children, transaction, context);
+ return this.node;
+ },
- mountComponent: function(
- transaction,
- nativeParent,
- nativeContainerInfo,
- context
- ) {
- this.node = Mode.ClippingRectangle();
- const props = this._currentElement.props;
- this.applyClippingProps(emptyObject, props);
- this.mountAndInjectChildren(props.children, transaction, context);
- return this.node;
+ receiveComponent: function(nextComponent, transaction, context) {
+ const props = nextComponent.props;
+ const oldProps = this._currentElement.props;
+ this.applyClippingProps(oldProps, props);
+ this.updateChildren(props.children, transaction, context);
+ this._currentElement = nextComponent;
+ },
+
+ applyClippingProps: function(oldProps, props) {
+ this.node.width = props.width;
+ this.node.height = props.height;
+ this.node.x = props.x;
+ this.node.y = props.y;
+ this.applyNodeProps(oldProps, props);
+ },
+
+ unmountComponent: function() {
+ this.destroyEventListeners();
+ this.unmountChildren();
+ },
},
-
- receiveComponent: function(nextComponent, transaction, context) {
- const props = nextComponent.props;
- const oldProps = this._currentElement.props;
- this.applyClippingProps(oldProps, props);
- this.updateChildren(props.children, transaction, context);
- this._currentElement = nextComponent;
- },
-
- applyClippingProps: function(oldProps, props) {
- this.node.width = props.width;
- this.node.height = props.height;
- this.node.x = props.x;
- this.node.y = props.y;
- this.applyNodeProps(oldProps, props);
- },
-
- unmountComponent: function() {
- this.destroyEventListeners();
- this.unmountChildren();
- }
-
-});
-
+);
// Renderables
const RenderableMixin = assign({}, NodeMixin, {
-
applyRenderableProps: function(oldProps, props) {
if (oldProps.fill !== props.fill) {
if (props.fill && props.fill.applyFill) {
@@ -468,7 +467,7 @@ const RenderableMixin = assign({}, NodeMixin, {
props.strokeWidth,
props.strokeCap,
props.strokeJoin,
- props.strokeDash
+ props.strokeDash,
);
}
this.applyNodeProps(oldProps, props);
@@ -476,14 +475,12 @@ const RenderableMixin = assign({}, NodeMixin, {
unmountComponent: function() {
this.destroyEventListeners();
- }
-
+ },
});
// Shape
const Shape = createComponent('Shape', RenderableMixin, {
-
construct: function(element) {
this._currentElement = element;
this._oldDelta = null;
@@ -494,7 +491,7 @@ const Shape = createComponent('Shape', RenderableMixin, {
transaction,
nativeParent,
nativeContainerInfo,
- context
+ context,
) {
this.node = Mode.Shape();
const props = this._currentElement.props;
@@ -514,30 +511,25 @@ const Shape = createComponent('Shape', RenderableMixin, {
const oldPath = this._oldPath;
const path = props.d || childrenAsString(props.children);
- if (path.delta !== oldDelta ||
- path !== oldPath ||
- oldProps.width !== props.width ||
- oldProps.height !== props.height) {
-
- this.node.draw(
- path,
- props.width,
- props.height
- );
+ if (
+ path.delta !== oldDelta ||
+ path !== oldPath ||
+ oldProps.width !== props.width ||
+ oldProps.height !== props.height
+ ) {
+ this.node.draw(path, props.width, props.height);
this._oldPath = path;
this._oldDelta = path.delta;
}
this.applyRenderableProps(oldProps, props);
- }
-
+ },
});
// Text
const Text = createComponent('Text', RenderableMixin, {
-
construct: function(element) {
this._currentElement = element;
this._oldString = null;
@@ -547,7 +539,7 @@ const Text = createComponent('Text', RenderableMixin, {
transaction,
nativeParent,
nativeContainerInfo,
- context
+ context,
) {
const props = this._currentElement.props;
const newString = childrenAsString(props.children);
@@ -580,23 +572,19 @@ const Text = createComponent('Text', RenderableMixin, {
const oldString = this._oldString;
const newString = childrenAsString(props.children);
- if (oldString !== newString ||
- !this.isSameFont(oldProps.font, props.font) ||
- oldProps.alignment !== props.alignment ||
- oldProps.path !== props.path) {
- this.node.draw(
- newString,
- props.font,
- props.alignment,
- props.path
- );
+ if (
+ oldString !== newString ||
+ !this.isSameFont(oldProps.font, props.font) ||
+ oldProps.alignment !== props.alignment ||
+ oldProps.path !== props.path
+ ) {
+ this.node.draw(newString, props.font, props.alignment, props.path);
this._oldString = newString;
}
this.applyRenderableProps(oldProps, props);
this._currentElement = nextComponent;
- }
-
+ },
});
// Declarative fill type objects - API design not finalized
diff --git a/src/renderers/art/__tests__/ReactART-test.js b/src/renderers/art/__tests__/ReactART-test.js
index b8cfea1c24..7d9ce37ffe 100644
--- a/src/renderers/art/__tests__/ReactART-test.js
+++ b/src/renderers/art/__tests__/ReactART-test.js
@@ -49,7 +49,6 @@ function testDOMNodeStructure(domNode, expectedStructure) {
}
describe('ReactART', () => {
-
beforeEach(() => {
ARTCurrentMode.setCurrent(ARTSVGMode);
@@ -59,29 +58,33 @@ describe('ReactART', () => {
TestComponent = class extends React.Component {
render() {
-
- var a =
+ var a = (
;
+ />
+ );
- var b =
+ var b = (
M64.564,38.583H54l0.008-5.834c0-3.035,0.293-4.666,4.657-4.666
h5.833V16.429h-9.33c-11.213,0-15.159,5.654-15.159,15.16v6.994
h-6.99v11.652h6.99v33.815H54V50.235h9.331L64.564,38.583z
- ;
+
+ );
var c = ;
@@ -113,22 +116,20 @@ describe('ReactART', () => {
width: '150',
height: '200',
children: [
- { nodeName: 'defs' },
+ {nodeName: 'defs'},
{
nodeName: 'g',
children: [
{
nodeName: 'defs',
- children: [
- { nodeName: 'linearGradient' }
- ]
+ children: [{nodeName: 'linearGradient'}],
},
- { nodeName: 'path' },
- { nodeName: 'path' },
- { nodeName: 'g' }
- ]
- }
- ]
+ {nodeName: 'path'},
+ {nodeName: 'path'},
+ {nodeName: 'g'},
+ ],
+ },
+ ],
};
var realNode = ReactDOM.findDOMNode(instance);
@@ -137,22 +138,25 @@ describe('ReactART', () => {
it('should be able to reorder components', () => {
var container = document.createElement('div');
- var instance = ReactDOM.render(, container);
+ var instance = ReactDOM.render(
+ ,
+ container,
+ );
var expectedStructure = {
nodeName: 'svg',
children: [
- { nodeName: 'defs' },
+ {nodeName: 'defs'},
{
nodeName: 'g',
children: [
- { nodeName: 'defs' },
- { nodeName: 'path', opacity: '0.1' },
- { nodeName: 'path', opacity: Missing },
- { nodeName: 'g' }
- ]
- }
- ]
+ {nodeName: 'defs'},
+ {nodeName: 'path', opacity: '0.1'},
+ {nodeName: 'path', opacity: Missing},
+ {nodeName: 'g'},
+ ],
+ },
+ ],
};
var realNode = ReactDOM.findDOMNode(instance);
@@ -163,17 +167,17 @@ describe('ReactART', () => {
var expectedNewStructure = {
nodeName: 'svg',
children: [
- { nodeName: 'defs' },
+ {nodeName: 'defs'},
{
nodeName: 'g',
children: [
- { nodeName: 'defs' },
- { nodeName: 'path', opacity: Missing },
- { nodeName: 'path', opacity: '0.1' },
- { nodeName: 'g' }
- ]
- }
- ]
+ {nodeName: 'defs'},
+ {nodeName: 'path', opacity: Missing},
+ {nodeName: 'path', opacity: '0.1'},
+ {nodeName: 'g'},
+ ],
+ },
+ ],
};
testDOMNodeStructure(realNode, expectedNewStructure);
@@ -187,7 +191,7 @@ describe('ReactART', () => {
var chars = this.props.chars.split('');
return (
- {chars.map((text) => )}
+ {chars.map(text => )}
);
}
@@ -225,7 +229,7 @@ describe('ReactART', () => {
-
+ ,
);
expect(mounted).toBe(true);
});
@@ -294,5 +298,4 @@ describe('ReactART', () => {
ReactDOM.render(, container);
expect(ref.constructor).toBe(CustomShape);
});
-
});
diff --git a/src/renderers/dom/ReactDOM.js b/src/renderers/dom/ReactDOM.js
index ff39dc5aa4..d313e001cd 100644
--- a/src/renderers/dom/ReactDOM.js
+++ b/src/renderers/dom/ReactDOM.js
@@ -43,11 +43,11 @@ var ReactDOM = {
// Allows for debugging when the hook is injected on the page.
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function'
+) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
ComponentTree: {
- getClosestInstanceFromNode:
- ReactDOMComponentTree.getClosestInstanceFromNode,
+ getClosestInstanceFromNode: ReactDOMComponentTree.getClosestInstanceFromNode,
getNodeFromInstance: function(inst) {
// inst is an internal instance (but could be a composite)
if (inst._renderedComponent) {
@@ -68,21 +68,25 @@ if (
if (__DEV__) {
var ExecutionEnvironment = require('ExecutionEnvironment');
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
-
// First check if devtools is not installed
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
// If we're in Chrome or Firefox, provide a download link if not installed.
- if ((navigator.userAgent.indexOf('Chrome') > -1 &&
+ if (
+ (navigator.userAgent.indexOf('Chrome') > -1 &&
navigator.userAgent.indexOf('Edge') === -1) ||
- navigator.userAgent.indexOf('Firefox') > -1) {
+ navigator.userAgent.indexOf('Firefox') > -1
+ ) {
// Firefox does not have the issue with devtools loaded over file://
- var showFileUrlMessage = window.location.protocol.indexOf('http') === -1 &&
+ var showFileUrlMessage =
+ window.location.protocol.indexOf('http') === -1 &&
navigator.userAgent.indexOf('Firefox') === -1;
console.debug(
'Download the React DevTools ' +
- (showFileUrlMessage ? 'and use an HTTP server (instead of a file: URL) ' : '') +
- 'for a better development experience: ' +
- 'https://fb.me/react-devtools'
+ (showFileUrlMessage
+ ? 'and use an HTTP server (instead of a file: URL) '
+ : '') +
+ 'for a better development experience: ' +
+ 'https://fb.me/react-devtools',
);
}
}
@@ -90,10 +94,10 @@ if (__DEV__) {
var testFunc = function testFn() {};
warning(
(testFunc.name || testFunc.toString()).indexOf('testFn') !== -1,
- 'It looks like you\'re using a minified copy of the development build ' +
- 'of React. When deploying React apps to production, make sure to use ' +
- 'the production build which skips development warnings and is faster. ' +
- 'See https://fb.me/react-minification for more details.'
+ "It looks like you're using a minified copy of the development build " +
+ 'of React. When deploying React apps to production, make sure to use ' +
+ 'the production build which skips development warnings and is faster. ' +
+ 'See https://fb.me/react-minification for more details.',
);
// If we're in IE8, check to see if we are in compatibility mode and provide
@@ -104,8 +108,8 @@ if (__DEV__) {
warning(
!ieCompatibilityMode,
'Internet Explorer is running in compatibility mode; please add the ' +
- 'following tag to your HTML to prevent this from happening: ' +
- ''
+ 'following tag to your HTML to prevent this from happening: ' +
+ '',
);
var expectedFeatures = [
@@ -126,7 +130,7 @@ if (__DEV__) {
warning(
false,
'One or more ES5 shims expected by React are not available: ' +
- 'https://fb.me/react-warning-polyfills'
+ 'https://fb.me/react-warning-polyfills',
);
break;
}
diff --git a/src/renderers/dom/__mocks__/ReactDOM.js b/src/renderers/dom/__mocks__/ReactDOM.js
index 00d14eb7f1..c5965c9ec9 100644
--- a/src/renderers/dom/__mocks__/ReactDOM.js
+++ b/src/renderers/dom/__mocks__/ReactDOM.js
@@ -13,5 +13,6 @@ var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
var useFiber = ReactDOMFeatureFlags.useFiber;
-module.exports =
- useFiber ? require('ReactDOMFiber') : require.requireActual('ReactDOM');
+module.exports = useFiber
+ ? require('ReactDOMFiber')
+ : require.requireActual('ReactDOM');
diff --git a/src/renderers/dom/__tests__/ReactDOMProduction-test.js b/src/renderers/dom/__tests__/ReactDOMProduction-test.js
index c25d5e7595..f2b4a7fc12 100644
--- a/src/renderers/dom/__tests__/ReactDOMProduction-test.js
+++ b/src/renderers/dom/__tests__/ReactDOMProduction-test.js
@@ -62,7 +62,7 @@ describe('ReactDOMProduction', () => {
BC
\n' +
- ' (server) dy data-reactid="4">Goodbye world'
+ "You're trying to render a component to the document using " +
+ 'server rendering but the checksum was invalid. This usually ' +
+ 'means you rendered a different component type or props on ' +
+ 'the client from the one on the server, or your render() methods ' +
+ 'are impure. React cannot handle this case due to cross-browser ' +
+ 'quirks by rendering at the document root. You should look for ' +
+ 'environment dependent code in your components and ensure ' +
+ 'the props are the same client and server side:\n' +
+ ' (client) dy data-reactid="4">Hello world\n' +
+ ' (server) dy data-reactid="4">Goodbye world',
);
});
@@ -238,15 +238,15 @@ describe('rendering React components at document', () => {
expect(function() {
ReactDOM.render(, container);
}).toThrowError(
- 'You\'re trying to render a component to the document but you didn\'t ' +
- 'use server rendering. We can\'t do this without using server ' +
- 'rendering due to cross-browser quirks. See ' +
- 'ReactDOMServer.renderToString() for server rendering.'
+ "You're trying to render a component to the document but you didn't " +
+ "use server rendering. We can't do this without using server " +
+ 'rendering due to cross-browser quirks. See ' +
+ 'ReactDOMServer.renderToString() for server rendering.',
);
});
it('supports findDOMNode on full-page components', () => {
- var tree =
+ var tree = (