Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions docs/extractCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ var CODE_SAMPLE = /```[\S]+\s*[\s\S]*?```/g;
var PARTS = /```[\S]+\s*\/\/\s+(.+?)\n([\s\S]*?)```/;

function truncate(s, n) {
n = n || 256
if (s.length < n) {
return s;
}
return s.substring(0, n) + '...';
n = n || 256
if (s.length < n) {
return s;
}
return s.substring(0, n) + '...';
}

function main(dest, filenames) {
if (!dest) {
throw new Error('no dest provided');
}
filenames.map(function (filename) {
var content = fs.readFileSync(filename).toString('utf8');
var codeSamples = content.match(CODE_SAMPLE);
if (!dest) {
throw new Error('no dest provided');
}
filenames.map(function(filename) {
var content = fs.readFileSync(filename).toString('utf8');
var codeSamples = content.match(CODE_SAMPLE);

codeSamples.map(function (codeSample) {
// Do a little jank preprocessing
codeSample = codeSample.replace('<!--', '//').replace(' -->', '');
var extracted = codeSample.match(PARTS);
if (!extracted) {
throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample));
}
var filename = extracted[1];
var content = extracted[2].replace(/\*\*/g, '');
fs.writeFileSync(argv.dest + '/' + filename, content);
});
codeSamples.map(function(codeSample) {
// Do a little jank preprocessing
codeSample = codeSample.replace('<!--', '//').replace(' -->', '');
var extracted = codeSample.match(PARTS);
if (!extracted) {
throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample));
}
var filename = extracted[1];
var content = extracted[2].replace(/\*\*/g, '');
fs.writeFileSync(argv.dest + '/' + filename, content);
});
});
}

main(argv.dest, argv._);
main(argv.dest, argv._);
2 changes: 1 addition & 1 deletion src/addons/__tests__/update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('update', function() {
expect(update([1, 4, 3], {$splice: [[1, 1, 2]]})).toEqual([1, 2, 3]);
expect(update.bind(null, [], {$splice: 1})).toThrow(
'Invariant Violation: update(): expected spec of $splice to be an ' +
'array of arrays; got 1. Did you forget to wrap your parameters in an '+
'array of arrays; got 1. Did you forget to wrap your parameters in an ' +
'array?'
);
expect(update.bind(null, [], {$splice: [1]})).toThrow(
Expand Down
2 changes: 1 addition & 1 deletion src/browser/__tests__/findDOMNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('findDOMNode', function() {
});

it('findDOMNode should reject unmounted objects with render func', function() {
expect(function() {React.findDOMNode({render: function(){}});})
expect(function() {React.findDOMNode({render: function() {}});})
.toThrow('Invariant Violation: Component (with keys: render) ' +
'contains `render` method but is not mounted in the DOM'
);
Expand Down
6 changes: 3 additions & 3 deletions src/browser/ui/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('ReactDOMComponent', function() {
var genMarkup;

function quoteRegexp(str) {
return (str+'').replace(/([.?*+\^$\[\]\\(){}|-])/g, "\\$1");
return (str + '').replace(/([.?*+\^$\[\]\\(){}|-])/g, "\\$1");
}

beforeEach(function() {
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('ReactDOMComponent', function() {
var genMarkup;

function quoteRegexp(str) {
return (str+'').replace(/([.?*+\^$\[\]\\(){}|-])/g, "\\$1");
return (str + '').replace(/([.?*+\^$\[\]\\(){}|-])/g, "\\$1");
}

beforeEach(function() {
Expand Down Expand Up @@ -491,7 +491,7 @@ describe('ReactDOMComponent', function() {
var ReactTestUtils = require('ReactTestUtils');

spyOn(console, 'warn');
ReactTestUtils.renderIntoDocument(<div onScroll={function(){}} />);
ReactTestUtils.renderIntoDocument(<div onScroll={function() {}} />);
expect(console.warn.calls.length).toBe(1);
expect(console.warn.mostRecentCall.args[0]).toBe(
'Warning: This browser doesn\'t support the `onScroll` event'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('ReactElementValidator', function() {
expect(console.warn.calls.length).toBe(2);
});

it('should warn if a fragment is used without the wrapper', function () {
it('should warn if a fragment is used without the wrapper', function() {
spyOn(console, 'warn');
var child = React.createElement('span');
React.createElement('div', null, { a: child, b: child });
Expand Down
6 changes: 3 additions & 3 deletions src/core/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ describe('ReactCompositeComponent', function() {

it('should warn when shouldComponentUpdate() returns undefined', function() {
var Component = React.createClass({
getInitialState: function () {
getInitialState: function() {
return {bogus: false};
},

Expand Down Expand Up @@ -623,8 +623,8 @@ describe('ReactCompositeComponent', function() {

expect(console.warn.argsForCall.length).toBe(1);
expect(console.warn.argsForCall[0][0]).toBe(
'Warning: owner-based and parent-based contexts differ '+
'(values: `bar` vs `undefined`) for key (foo) '+
'Warning: owner-based and parent-based contexts differ ' +
'(values: `bar` vs `undefined`) for key (foo) ' +
'while mounting Component (see: http://fb.me/react-context-by-parent)'
);

Expand Down
8 changes: 4 additions & 4 deletions src/core/__tests__/ReactCompositeComponentNestedState-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('ReactCompositeComponentNestedState-state', function() {

handleColor: function(color) {
this.props.logger('parent-handleColor', this.state.color);
this.setState({ color: color }, function () {
this.setState({ color: color }, function() {
this.props.logger('parent-after-setState', this.state.color);
});
},
Expand All @@ -55,11 +55,11 @@ describe('ReactCompositeComponentNestedState-state', function() {
handleHue: function(shade, color) {
this.props.logger('handleHue', this.state.hue, this.props.color);
this.props.onSelectColor(color);
this.setState(function (state, props) {
this.setState(function(state, props) {
this.props.logger('setState-this', this.state.hue, this.props.color);
this.props.logger('setState-args', state.hue, props.color);
return { hue: shade + ' ' + props.color }
}, function () {
}, function() {
this.props.logger('after-setState', this.state.hue, this.props.color);
});
},
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('ReactCompositeComponentNestedState-state', function() {
[ 'setState-args', 'dark blue', 'green' ],
[ 'render', 'light green', 'green' ],
[ 'parent-after-setState', 'green' ],
[ 'after-setState', 'light green', 'green' ],
[ 'after-setState', 'light green', 'green' ]
]);
});
});
12 changes: 6 additions & 6 deletions src/core/__tests__/ReactCompositeComponentState-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ describe('ReactCompositeComponent-state', function() {

componentWillMount: function() {
this.peekAtState('componentWillMount-start');
this.setState(function (state) {
this.setState(function(state) {
this.peekAtState('before-setState-sunrise', state);
});
this.setState(
{color: 'sunrise'},
this.peekAtCallback('setState-sunrise')
);
this.setState(function (state) {
this.setState(function(state) {
this.peekAtState('after-setState-sunrise', state);
});
this.peekAtState('componentWillMount-after-sunrise');
this.setState(
{color: 'orange'},
this.peekAtCallback('setState-orange')
);
this.setState(function (state) {
this.setState(function(state) {
this.peekAtState('after-setState-orange', state);
});
this.peekAtState('componentWillMount-end');
Expand All @@ -90,19 +90,19 @@ describe('ReactCompositeComponent-state', function() {
componentWillReceiveProps: function(newProps) {
this.peekAtState('componentWillReceiveProps-start');
if (newProps.nextColor) {
this.setState(function (state) {
this.setState(function(state) {
this.peekAtState('before-setState-receiveProps', state);
return {color: newProps.nextColor};
});
this.replaceState({ color: undefined });
this.setState(
function (state) {
function(state) {
this.peekAtState('before-setState-again-receiveProps', state);
return {color: newProps.nextColor};
},
this.peekAtCallback('setState-receiveProps')
);
this.setState(function (state) {
this.setState(function(state) {
this.peekAtState('after-setState-receiveProps', state);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/ReactMultiChildReconcile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function verifyDomOrderingAccurate(parentInstance, statusDisplays) {
var statusDisplayNodes = containerNode.childNodes;
var i;
var orderedDomIds = [];
for (i=0; i < statusDisplayNodes.length; i++) {
for (i = 0; i < statusDisplayNodes.length; i++) {
orderedDomIds.push(ReactMount.getID(statusDisplayNodes[i]));
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/refs-destruction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

var React = require('React');
var ReactTestUtils = require('ReactTestUtils');
var reactComponentExpect= require('reactComponentExpect');
var reactComponentExpect = require('reactComponentExpect');

var TestComponent = React.createClass({
render: function() {
Expand Down
4 changes: 2 additions & 2 deletions src/core/__tests__/refs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
var React = require('React');
var ReactTestUtils = require('ReactTestUtils');

var reactComponentExpect= require('reactComponentExpect');
var reactComponentExpect = require('reactComponentExpect');


/**
Expand All @@ -34,7 +34,7 @@ var ClickCounter = React.createClass({
render: function() {
var children = [];
var i;
for (i=0; i < this.state.count; i++) {
for (i = 0; i < this.state.count; i++) {
children.push(
<div
className="clickLogDiv"
Expand Down
2 changes: 1 addition & 1 deletion src/test/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ var ReactTestUtils = {
var all =
ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
if (all.length !== 1) {
throw new Error('Did not find exactly one match '+
throw new Error('Did not find exactly one match ' +
'(found: ' + all.length + ') for class:' + className
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ function makeComponent(metadata) {
f._isMockFunction = true;

f.mock = {
calls : calls,
instances : instances
calls: calls,
instances: instances
};

f.mockClear = function() {
Expand Down Expand Up @@ -218,7 +218,7 @@ function _getMetadata(component, _refs) {
return null;
}

var metadata = {type : type};
var metadata = {type: type};
if (type == 'constant') {
metadata.value = component;
return metadata;
Expand Down
4 changes: 2 additions & 2 deletions src/test/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

if (typeof console == 'undefined') {
this.console = {
error: function(e){
error: function(e) {
postMessage(JSON.stringify({
type: 'error',
message: e.message,
stack: e.stack
}));
},
log: function(message){
log: function(message) {
postMessage(JSON.stringify({
type: 'log',
message: message
Expand Down
2 changes: 1 addition & 1 deletion src/utils/__tests__/OrderedMap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var hasUndefinedStringKey = [
var hasPositiveNumericKey = [
{uniqueID: 'notANumber', data: []},
{uniqueID: '5', data: []},
{uniqueID: 'notAnotherNumber',data: []}
{uniqueID: 'notAnotherNumber', data: []}
];

var hasZeroStringKey = [
Expand Down
4 changes: 2 additions & 2 deletions src/utils/__tests__/ReactChildren-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ describe('ReactChildren', function() {
expect(numberOfChildren).toBe(6);
});

it('should warn if a fragment is used without the wrapper', function () {
it('should warn if a fragment is used without the wrapper', function() {
spyOn(console, 'warn');
var child = React.createElement('span');
ReactChildren.forEach({ a: child, b: child}, function(c) {
Expand All @@ -431,7 +431,7 @@ describe('ReactChildren', function() {
expect(console.warn.calls[0].args[0]).toContain('use of a keyed object');
});

it('should warn if a fragment is accessed', function () {
it('should warn if a fragment is accessed', function() {
spyOn(console, 'warn');
var child = React.createElement('span');
var frag = ReactChildren.map([ child, child ], function(c) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/__tests__/traverseAllChildren-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ describe('traverseAllChildren', function() {
return {
next: function() {
if (i++ < 3) {
return { value: <div key={'#'+i} />, done: false };
return { value: <div key={'#' + i} />, done: false };
} else {
return { value: undefined, done: true };
}
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('traverseAllChildren', function() {
return {
next: function() {
if (i++ < 3) {
return { value: ['#'+i, <div />], done: false };
return { value: ['#' + i, <div />], done: false };
} else {
return { value: undefined, done: true };
}
Expand Down
4 changes: 2 additions & 2 deletions vendor/fbtransform/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ function runCli(argv) {
var source = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
process.stdin.on('data', function(chunk) {
source += chunk;
});
process.stdin.on('end', function () {
process.stdin.on('end', function() {
try {
source = transformAll(source, options, excludes);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion vendor/fbtransform/transforms/__tests__/react-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ describe('react jsx', function() {

it('should not throw for unknown hyphenated tags', function() {
var code = '<x-component />;';
expect(function(){transform(code);}).not.toThrow();
expect(function() {transform(code);}).not.toThrow();
});

it('calls assign with a new target object for spreads', function() {
Expand Down
4 changes: 2 additions & 2 deletions vendor/fbtransform/transforms/xjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ function renderXJSLiteral(object, isLast, state, start, end) {

var lastNonEmptyLine = 0;

lines.forEach(function (line, index) {
lines.forEach(function(line, index) {
if (line.match(/[^ \t]/)) {
lastNonEmptyLine = index;
}
});

lines.forEach(function (line, index) {
lines.forEach(function(line, index) {
var isFirstLine = index === 0;
var isLastLine = index === lines.length - 1;
var isLastNonEmptyLine = index === lastNonEmptyLine;
Expand Down