Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Mar 14, 2017
1 parent 46bcd7f commit 1843f87
Show file tree
Hide file tree
Showing 325 changed files with 12,714 additions and 11,413 deletions.
1 change: 1 addition & 0 deletions src/__mocks__/InitializeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
// Noop

// TODO #10932517: Move all initialization callers back into react-native

6 changes: 3 additions & 3 deletions src/__mocks__/deepDiffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ var deepDiffer = function(one: any, two: any): boolean {
// Short circuit on identical object references instead of traversing them.
return false;
}
if ((typeof one === 'function') && (typeof two === 'function')) {
if (typeof one === 'function' && typeof two === 'function') {
// We consider all functions equal
return false;
}
if ((typeof one !== 'object') || (one === null)) {
if (typeof one !== 'object' || one === null) {
// Primitives can be directly compared
return one !== two;
}
if ((typeof two !== 'object') || (two === null)) {
if (typeof two !== 'object' || two === null) {
// We know they are different because the previous case would have triggered
// otherwise.
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/deepFreezeAndThrowOnMutationInDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

// TODO: move into react or fbjs

var deepFreezeAndThrowOnMutationInDev = function() { };
var deepFreezeAndThrowOnMutationInDev = function() {};

module.exports = deepFreezeAndThrowOnMutationInDev;
2 changes: 1 addition & 1 deletion src/__mocks__/flattenStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

// TODO: Move flattenStyle into react

var flattenStyle = function() { };
var flattenStyle = function() {};

module.exports = flattenStyle;
10 changes: 5 additions & 5 deletions src/addons/ReactFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ var ReactFragment = {
warning(
false,
'React.addons.createFragment only accepts a single object. Got: %s',
object
object,
);
return object;
}
if (ReactElement.isValidElement(object)) {
warning(
false,
'React.addons.createFragment does not accept a ReactElement ' +
'without a wrapper object.'
'without a wrapper object.',
);
return object;
}

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 = [];
Expand All @@ -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;
}
Expand All @@ -77,7 +77,7 @@ var ReactFragment = {
object[key],
result,
key,
emptyFunction.thatReturnsArgument
emptyFunction.thatReturnsArgument,
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/addons/ReactWithAddons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

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');
Expand Down
12 changes: 2 additions & 10 deletions src/addons/__tests__/ReactComponentWithPureRenderMixin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ var ReactComponentWithPureRenderMixin;
var ReactTestUtils;

describe('ReactComponentWithPureRenderMixin', () => {

beforeEach(() => {
React = require('react');
ReactComponentWithPureRenderMixin =
require('ReactComponentWithPureRenderMixin');
ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin');
ReactTestUtils = require('ReactTestUtils');
});

Expand All @@ -35,12 +33,7 @@ describe('ReactComponentWithPureRenderMixin', () => {
}

render() {
return (
<Apple
color={this.state.color}
ref="apple"
/>
);
return <Apple color={this.state.color} ref="apple" />;
}
}

Expand Down Expand Up @@ -141,5 +134,4 @@ describe('ReactComponentWithPureRenderMixin', () => {
instance.setState(getInitialState());
expect(renderCalls).toBe(3);
});

});
22 changes: 10 additions & 12 deletions src/addons/__tests__/ReactFragment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var ReactDOM;
var ReactFragment;

describe('ReactFragment', () => {

beforeEach(() => {
React = require('react');
ReactDOM = require('react-dom');
Expand All @@ -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.',
);
});

Expand All @@ -53,9 +52,9 @@ describe('ReactFragment', () => {
var container = document.createElement('div');
expect(() => ReactDOM.render(<Foo />, 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.\n\nCheck 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.\n\nCheck the render method of `Foo`.',
);
});

Expand All @@ -66,7 +65,7 @@ describe('ReactFragment', () => {

expectDev(console.error.calls.count()).toBe(1);
expectDev(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.',
);
});

Expand All @@ -75,7 +74,7 @@ describe('ReactFragment', () => {
ReactFragment.create(null);
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'React.addons.createFragment only accepts a single object.'
'React.addons.createFragment only accepts a single object.',
);
});

Expand All @@ -84,7 +83,7 @@ describe('ReactFragment', () => {
ReactFragment.create([]);
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'React.addons.createFragment only accepts a single object.'
'React.addons.createFragment only accepts a single object.',
);
});

Expand All @@ -94,8 +93,7 @@ describe('ReactFragment', () => {
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.calls.argsFor(0)[0]).toContain(
'React.addons.createFragment does not accept a ReactElement without a ' +
'wrapper object.'
'wrapper object.',
);
});

});
10 changes: 5 additions & 5 deletions src/addons/__tests__/renderSubtreeIntoContainer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -47,9 +46,11 @@ describe('renderSubtreeIntoContainer', () => {
}

componentDidMount() {
expect(function() {
renderSubtreeIntoContainer(this, <Component />, portal);
}.bind(this)).not.toThrow();
expect(
function() {
renderSubtreeIntoContainer(this, <Component />, portal);
}.bind(this),
).not.toThrow();
}
}

Expand Down Expand Up @@ -296,5 +297,4 @@ describe('renderSubtreeIntoContainer', () => {
ReactDOM.render(<Parent value="foo" />, container);
expect(portal2.textContent).toBe('foo');
});

});
74 changes: 39 additions & 35 deletions src/addons/__tests__/update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
var update = require('update');

describe('update', () => {

describe('$push', () => {
it('pushes', () => {
expect(update([1], {$push: [7]})).toEqual([1, 7]);
Expand All @@ -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.',
);
});
});
Expand All @@ -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.',
);
});
});
Expand All @@ -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',
);
});
});
Expand All @@ -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",
);
});
});
Expand Down Expand Up @@ -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',
Expand All @@ -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',
});
});
});
6 changes: 2 additions & 4 deletions src/addons/shallowCompare.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ var shallowEqual = require('fbjs/lib/shallowEqual');
* See also https://facebook.github.io/react/docs/shallow-compare.html
*/
function shallowCompare(instance, nextProps, nextState) {
return (
!shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState)
);
return !shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState);
}

module.exports = shallowCompare;
Loading

0 comments on commit 1843f87

Please sign in to comment.