Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Prettier #9101

Merged
merged 9 commits into from Mar 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .eslintrc.js
Expand Up @@ -23,7 +23,7 @@ module.exports = {
'dot-notation': ERROR,
'eol-last': ERROR,
'eqeqeq': [ERROR, 'allow-null'],
'indent': [ERROR, 2, {SwitchCase: 1}],
'indent': OFF,
'jsx-quotes': [ERROR, 'prefer-double'],
'keyword-spacing': [ERROR, {after: true, before: true}],
'no-bitwise': OFF,
Expand All @@ -33,9 +33,10 @@ module.exports = {
'no-shadow': ERROR,
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, {args: 'none'}],
'no-useless-concat': OFF,
'quotes': [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true }],
'space-before-blocks': ERROR,
'space-before-function-paren': [ERROR, {anonymous: 'never', named: 'never'}],
'space-before-function-paren': OFF,

// React & JSX
// Our transforms set this automatically
Expand Down
1 change: 1 addition & 0 deletions src/__mocks__/InitializeCore.js
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
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
Whitespace-only changes.
Empty file modified src/__mocks__/flattenStyle.js
Whitespace-only changes.
10 changes: 5 additions & 5 deletions src/addons/ReactFragment.js
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
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
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);
});

});
14 changes: 6 additions & 8 deletions src/addons/__tests__/ReactFragment-test.js
Expand Up @@ -16,7 +16,6 @@ var ReactDOM;
var ReactFragment;

describe('ReactFragment', () => {

beforeEach(() => {
React = require('react');
ReactDOM = require('react-dom');
Expand All @@ -35,7 +34,7 @@ describe('ReactFragment', () => {
'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.'
'the React add-ons.',
);
});

Expand All @@ -55,7 +54,7 @@ describe('ReactFragment', () => {
'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`.'
'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.',
);
});

});
8 changes: 4 additions & 4 deletions src/addons/__tests__/renderSubtreeIntoContainer-test.js
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() {
expect(
function() {
renderSubtreeIntoContainer(this, <Component />, portal);
}.bind(this)).not.toThrow();
}.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');
});

});
40 changes: 22 additions & 18 deletions src/addons/__tests__/update-test.js
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,13 +130,15 @@ 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({
expect(
update(
{
a: 'b',
c: {
d: 'e',
Expand All @@ -147,16 +148,19 @@ describe('update', () => {
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},
l: {$apply: x => x * 2},
},
},
})).toEqual({
),
).toEqual({
a: 'b',
c: {
d: 'm',
Expand All @@ -173,13 +177,13 @@ describe('update', () => {
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: ...}?'
'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
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;