mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix most lint warnings/errors
This commit is contained in:
committed by
Paul O’Shannessy
parent
48333acba6
commit
3156458041
@@ -16,6 +16,8 @@
|
||||
* @providesModule ReactComponent
|
||||
*/
|
||||
|
||||
/*jslint evil: true */
|
||||
|
||||
"use strict";
|
||||
|
||||
var ReactCurrentOwner = require('ReactCurrentOwner');
|
||||
@@ -125,7 +127,9 @@ function assignKey(groupingIndex, child, index) {
|
||||
function tryToReuseArray(children) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
if (isEmptyChild(child)) return false;
|
||||
if (isEmptyChild(child)) {
|
||||
return false;
|
||||
}
|
||||
assignKey(0, child, i);
|
||||
}
|
||||
return true;
|
||||
@@ -142,7 +146,9 @@ function tryToReuseArray(children) {
|
||||
function appendNestedChildren(groupingIndex, sourceArray, targetArray) {
|
||||
for (var i = 0; i < sourceArray.length; i++) {
|
||||
var child = sourceArray[i];
|
||||
if (isEmptyChild(child)) continue;
|
||||
if (isEmptyChild(child)) {
|
||||
continue;
|
||||
}
|
||||
assignKey(groupingIndex, child, i);
|
||||
// TODO: Invalid components like strings could possibly need
|
||||
// keys assigned to them here. Usually they're not stateful but
|
||||
@@ -338,9 +344,13 @@ var ReactComponent = {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
if (Array.isArray(child)) {
|
||||
if (child.length === 0) continue;
|
||||
if (child.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetArray === null) targetArray = [];
|
||||
if (targetArray === null) {
|
||||
targetArray = [];
|
||||
}
|
||||
appendNestedChildren(i - 1, child, targetArray);
|
||||
|
||||
} else if (!isEmptyChild(child)) {
|
||||
@@ -352,7 +362,9 @@ var ReactComponent = {
|
||||
child._key = createKey(child.props.key, i - 1);
|
||||
}
|
||||
|
||||
if (targetArray === null) targetArray = [];
|
||||
if (targetArray === null) {
|
||||
targetArray = [];
|
||||
}
|
||||
targetArray.push(child);
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ var ReactCurrentOwner = {
|
||||
*/
|
||||
getDepth: function() {
|
||||
var owner = ReactCurrentOwner.current;
|
||||
if (!owner) return 0;
|
||||
if (!owner) {
|
||||
return 0;
|
||||
}
|
||||
return owner._compositionLevel;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
/*jslint evil: true */
|
||||
|
||||
"use strict";
|
||||
|
||||
var React = require('React');
|
||||
@@ -81,27 +83,30 @@ describe('ref swapping', function() {
|
||||
theBird: <div class="bird" />
|
||||
}}</div>
|
||||
);
|
||||
// Warm the cache with theDog
|
||||
myDiv.setProps({
|
||||
children: {
|
||||
theDog: <div class="dogbeforedelete" />, // Warm the cache with theDog
|
||||
theDog: <div class="dogbeforedelete" />,
|
||||
theBird: <div class="bird" />
|
||||
}
|
||||
});
|
||||
myDiv.setProps({
|
||||
children: { // This better purge that cache
|
||||
theBird: <div class="bird" />
|
||||
}
|
||||
});
|
||||
// Now, put the dog back.
|
||||
// Remove theDog - this should purge the cache
|
||||
myDiv.setProps({
|
||||
children: {
|
||||
theDog: <div class="dog" />, // This is a different node than before
|
||||
theBird: <div class="bird" />
|
||||
}
|
||||
});
|
||||
// Now, put theDog back. It's now a different DOM node.
|
||||
myDiv.setProps({
|
||||
children: { // className changed to bigdog.
|
||||
theDog: <div class="bigdog" />, // but will it use the proper element
|
||||
children: {
|
||||
theDog: <div class="dog" />,
|
||||
theBird: <div class="bird" />
|
||||
}
|
||||
});
|
||||
// Change the className of theDog. It will use the same element
|
||||
myDiv.setProps({
|
||||
children: {
|
||||
theDog: <div class="bigdog" />,
|
||||
theBird: <div class="bird" />
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
var React = require('React');
|
||||
var ReactTestUtils = require('ReactTestUtils');
|
||||
|
||||
var reactComponentExpect= require('reactComponentExpect');
|
||||
|
||||
/**
|
||||
* Ensure that all callbacks are invoked, passing this unique argument.
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var ReactMount = require('ReactMount');
|
||||
var React = require('React');
|
||||
var ReactTestUtils = require('ReactTestUtils');
|
||||
var ReactMount = require('ReactMount');
|
||||
|
||||
var reactComponentExpect = require('reactComponentExpect');
|
||||
|
||||
describe('ReactMount', function() {
|
||||
it("should destroy a react root upon request", function() {
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
/*jslint evil: true */
|
||||
|
||||
"use strict";
|
||||
|
||||
require('mock-modules');
|
||||
|
||||
var React = require('React');
|
||||
var ReactTestUtils = require('ReactTestUtils');
|
||||
var ReactTextComponent = require('ReactTextComponent');
|
||||
|
||||
var reactComponentExpect = require('reactComponentExpect');
|
||||
|
||||
@@ -141,7 +142,7 @@ describe('ReactMultiChildText', function() {
|
||||
assertMultiChild(d, 'hello', 'goodbye');
|
||||
});
|
||||
|
||||
it('should render zero string as text node then switch to spans', function() {
|
||||
it('should render zero string as text node then switch to spans', function() {
|
||||
var d = renderSingleTextChild('0');
|
||||
// false should act exactly as a null child
|
||||
assertNodeText(d, '0');
|
||||
@@ -149,7 +150,7 @@ describe('ReactMultiChildText', function() {
|
||||
assertMultiChild(d, 'hello', 'goodbye');
|
||||
});
|
||||
|
||||
it('should render zero number as text node then switch to spans', function() {
|
||||
it('should render zero number as text node then switch to spans', function() {
|
||||
var d = renderSingleTextChild('0');
|
||||
// false should act exactly as a null child
|
||||
assertNodeText(d, 0);
|
||||
|
||||
@@ -26,7 +26,7 @@ function typeCheck(declaration, value) {
|
||||
if (arguments.length > 1) {
|
||||
props.testProp = value;
|
||||
}
|
||||
return declaration.bind(this, props, 'testProp', 'testComponent');
|
||||
return declaration.bind(null, props, 'testProp', 'testComponent');
|
||||
}
|
||||
|
||||
describe('Primitive Types', function() {
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
* @providesModule DOMChildrenOperations
|
||||
*/
|
||||
|
||||
// Empty blocks improve readability so disable that warning
|
||||
// jshint -W035
|
||||
|
||||
"use strict";
|
||||
|
||||
var Danger = require('Danger');
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
* @providesModule Danger
|
||||
*/
|
||||
|
||||
/*jslint evil: true */
|
||||
|
||||
"use strict";
|
||||
|
||||
var ExecutionEnvironment = require('ExecutionEnvironment');
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
/*jslint evil: true */
|
||||
|
||||
"use strict";
|
||||
|
||||
var React = require('React');
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var ExecutionEnvironment = require('ExecutionEnvironment');
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
/*jslint evil: true */
|
||||
|
||||
"use strict";
|
||||
|
||||
require('mock-modules')
|
||||
@@ -147,7 +149,7 @@ describe('ReactServerRendering', function() {
|
||||
return (
|
||||
<span ref="span" onClick={this.click}>Name: {this.props.name}</span>
|
||||
);
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
var element = document.createElement('div');
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var PooledClass = require('PooledClass');
|
||||
|
||||
var emptyFunction = require('emptyFunction');
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var SyntheticUIEvent = require('SyntheticUIEvent');
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var SyntheticUIEvent = require('SyntheticUIEvent');
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var BrowserEnv = require('BrowserEnv');
|
||||
var SyntheticUIEvent = require('SyntheticUIEvent');
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var SyntheticEvent = require('SyntheticEvent');
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var SyntheticUIEvent = require('SyntheticUIEvent');
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var SyntheticEvent = require('SyntheticEvent');
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* @typechecks
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var SyntheticMouseEvent = require('SyntheticMouseEvent');
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,8 +72,9 @@ var EnterLeaveEventPlugin = {
|
||||
var from, to;
|
||||
if (topLevelType === topLevelTypes.topMouseOut) {
|
||||
from = topLevelTarget;
|
||||
to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement)
|
||||
|| ExecutionEnvironment.global;
|
||||
to =
|
||||
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
|
||||
ExecutionEnvironment.global;
|
||||
} else {
|
||||
from = ExecutionEnvironment.global;
|
||||
to = topLevelTarget;
|
||||
|
||||
@@ -23,9 +23,6 @@ require('mock-modules')
|
||||
|
||||
var ImmutableObject;
|
||||
|
||||
var expectSeriallyEqual = function(one, two) {
|
||||
};
|
||||
|
||||
/**
|
||||
* To perform performance testing of using `ImmutableObject` vs. not using
|
||||
* `ImmutableObject`, such testing must be done with __DEV__ set to false.
|
||||
@@ -270,7 +267,7 @@ describe('ImmutableObject', function() {
|
||||
});
|
||||
expect(afterIO).toBeSeriallyEqualTo({
|
||||
a: {b: {}, c: 'C', d: 'd', e: {f: 'F', g: 'G'}, h: 'H'}
|
||||
})
|
||||
});
|
||||
expect(afterIO).not.toBe(beforeIO);
|
||||
expect(afterIO.a).not.toBe(beforeIO.a);
|
||||
expect(afterIO.a.e).not.toBe(beforeIO.a.e);
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
* @providesModule mergeDeepInto
|
||||
*/
|
||||
|
||||
// Empty blocks improve readability so disable that warning
|
||||
// jshint -W035
|
||||
|
||||
"use strict";
|
||||
|
||||
var keyMirror = require('keyMirror');
|
||||
|
||||
Reference in New Issue
Block a user