. 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', () => {
B
C
,
- container
+ container,
);
expect(container.firstChild).toBe(inst);
@@ -75,7 +75,7 @@ describe('ReactDOMProduction', () => {