Skip to content

Commit

Permalink
Upgrade ESLint, fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
zpao committed Aug 11, 2015
1 parent 2f07935 commit ecb34de
Show file tree
Hide file tree
Showing 22 changed files with 115 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ globals:
rules:
# ERRORS
space-before-blocks: 2
indent: [2, 2, indentSwitchCase: true]
indent: [2, 2, {SwitchCase: 1}]
brace-style: 2
space-after-keywords: 2
strict: 2
strict: [2, global]
comma-dangle: [2, always-multiline]
# Make this a warning for now. We do this in a few places so we might need to
# disable
Expand Down
1 change: 1 addition & 0 deletions docs/_js/examples/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
rules:
block-scoped-var: 0
no-undef: 0
strict: 0
react/react-in-jsx-scope: 0
react/jsx-no-undef: 0
9 changes: 4 additions & 5 deletions eslint-rules/__tests__/warning-and-invariant-args-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

'use strict';

var eslint = require('eslint');
var ESLintTester = require('eslint-tester');
var eslintTester = new ESLintTester(eslint.linter);
var rule = require('../warning-and-invariant-args');
var RuleTester = require('eslint').RuleTester;
var ruleTester = new RuleTester();

eslintTester.addRuleTest('eslint-rules/warning-and-invariant-args', {
ruleTester.run('eslint-rules/warning-and-invariant-args', rule, {
valid: [
"warning(true, 'hello, world');",
"warning(true, 'expected %s, got %s', 42, 24);",
Expand Down Expand Up @@ -100,4 +100,3 @@ eslintTester.addRuleTest('eslint-rules/warning-and-invariant-args', {
},
],
});

2 changes: 2 additions & 0 deletions grunt/config/npm.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict';

exports.pack = {};
5 changes: 3 additions & 2 deletions grunt/tasks/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ function docs() {
function msg() {
// Just output a friendly reminder message for the rest of the process
grunt.log.subhead('Release *almost* complete...');
[
var steps = [
'Still todo:',
'* put files on CDN',
'* push changes to git repositories',
'* publish npm module (`npm publish .`)',
'* announce it on FB/Twitter/mailing list',
].forEach(function(ln) {
];
steps.forEach(function(ln) {
grunt.log.writeln(ln);
});
}
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
"version": "0.14.0-beta3",
"devDependencies": {
"babel": "^5.8.3",
"babel-eslint": "^3.1.25",
"babel-eslint": "^4.0.5",
"benchmark": "^1.0.0",
"browserify": "^9.0.3",
"bundle-collapser": "^1.1.1",
"coffee-script": "^1.8.0",
"del": "^1.2.0",
"derequire": "^2.0.0",
"envify": "^3.0.0",
"eslint": "^0.24.1",
"eslint-plugin-react": "^2.5.0",
"eslint": "^1.1.0",
"eslint-plugin-react": "^3.2.1",
"eslint-plugin-react-internal": "file:eslint-rules",
"eslint-tester": "^0.7.0",
"fbjs": "0.1.0-alpha.4",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict';

module.exports = require('react/lib/ReactDOM');
2 changes: 2 additions & 0 deletions packages/react-dom/server.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
'use strict';

module.exports = require('react/lib/ReactDOMServer');
2 changes: 2 additions & 0 deletions packages/react/addons.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var warning = require('fbjs/lib/warning');
warning(
false,
Expand Down
1 change: 1 addition & 0 deletions scripts/jest/environment.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* eslint-disable */
__DEV__ = true;
24 changes: 13 additions & 11 deletions src/renderers/dom/client/ReactMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,13 @@ function findDeepestCachedAncestor(targetID) {
* @param {boolean} shouldReuseMarkup If true, do not insert markup
*/
function mountComponentIntoNode(
componentInstance,
rootID,
container,
transaction,
shouldReuseMarkup,
context) {
componentInstance,
rootID,
container,
transaction,
shouldReuseMarkup,
context
) {
if (__DEV__) {
if (context === emptyObject) {
context = {};
Expand All @@ -287,11 +288,12 @@ function mountComponentIntoNode(
* @param {boolean} shouldReuseMarkup If true, do not insert markup
*/
function batchedMountComponentIntoNode(
componentInstance,
rootID,
container,
shouldReuseMarkup,
context) {
componentInstance,
rootID,
container,
shouldReuseMarkup,
context
) {
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
transaction.perform(
mountComponentIntoNode,
Expand Down
42 changes: 24 additions & 18 deletions src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,19 @@ function stopWatchingForChangeEventIE8() {
}

function getTargetIDForChangeEvent(
topLevelType,
topLevelTarget,
topLevelTargetID) {
topLevelType,
topLevelTarget,
topLevelTargetID
) {
if (topLevelType === topLevelTypes.topChange) {
return topLevelTargetID;
}
}
function handleEventsForChangeEventIE8(
topLevelType,
topLevelTarget,
topLevelTargetID) {
topLevelType,
topLevelTarget,
topLevelTargetID
) {
if (topLevelType === topLevelTypes.topFocus) {
// stopWatching() should be a noop here but we call it just in case we
// missed a blur event somehow.
Expand Down Expand Up @@ -222,9 +224,10 @@ function handlePropertyChange(nativeEvent) {
* If a `change` event should be fired, returns the target's ID.
*/
function getTargetIDForInputEvent(
topLevelType,
topLevelTarget,
topLevelTargetID) {
topLevelType,
topLevelTarget,
topLevelTargetID
) {
if (topLevelType === topLevelTypes.topInput) {
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
// what we want so fall through here and trigger an abstract event
Expand All @@ -234,9 +237,10 @@ function getTargetIDForInputEvent(

// For IE8 and IE9.
function handleEventsForInputEventIE(
topLevelType,
topLevelTarget,
topLevelTargetID) {
topLevelType,
topLevelTarget,
topLevelTargetID
) {
if (topLevelType === topLevelTypes.topFocus) {
// In IE8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
Expand All @@ -260,9 +264,10 @@ function handleEventsForInputEventIE(

// For IE8 and IE9.
function getTargetIDForInputEventIE(
topLevelType,
topLevelTarget,
topLevelTargetID) {
topLevelType,
topLevelTarget,
topLevelTargetID
) {
if (topLevelType === topLevelTypes.topSelectionChange ||
topLevelType === topLevelTypes.topKeyUp ||
topLevelType === topLevelTypes.topKeyDown) {
Expand Down Expand Up @@ -298,9 +303,10 @@ function shouldUseClickEvent(elem) {
}

function getTargetIDForClickEvent(
topLevelType,
topLevelTarget,
topLevelTargetID) {
topLevelType,
topLevelTarget,
topLevelTargetID
) {
if (topLevelType === topLevelTypes.topClick) {
return topLevelTargetID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function SyntheticCompositionEvent(
dispatchConfig,
dispatchMarker,
nativeEvent,
nativeEventTarget) {
nativeEventTarget
) {
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function SyntheticInputEvent(
dispatchConfig,
dispatchMarker,
nativeEvent,
nativeEventTarget) {
nativeEventTarget
) {
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
}

Expand Down
6 changes: 3 additions & 3 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ describe('ReactDOMComponent', function() {

it('should not duplicate uppercased selfclosing tags', function() {
var Container = React.createClass({
render: function() {
return React.createElement('BR', null);
},
render: function() {
return React.createElement('BR', null);
},
});
var returnedValue = React.renderToString(<Container/>);
expect(returnedValue).not.toContain('</BR>');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,11 @@ to return true:wantsResponderID| |
* @return {*} An accumulation of synthetic events.
*/
function setResponderAndExtractTransfer(
topLevelType,
topLevelTargetID,
nativeEvent,
nativeEventTarget) {
topLevelType,
topLevelTargetID,
nativeEvent,
nativeEventTarget
) {
var shouldSetEventType =
isStartish(topLevelType) ? eventTypes.startShouldSetResponder :
isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ var antiSubsequence = function(arr, indices) {
* Helper for creating touch test config data.
* @param allTouchHandles
*/
var _touchConfig =
function(topType, targetNodeHandle, allTouchHandles, changedIndices, eventTarget) {
var _touchConfig = function(
topType,
targetNodeHandle,
allTouchHandles,
changedIndices,
eventTarget
) {
var allTouchObjects = allTouchHandles.map(touch);
var changedTouchObjects = subsequence(allTouchObjects, changedIndices);
var activeTouchObjects =
Expand Down
54 changes: 28 additions & 26 deletions src/renderers/shared/reconciler/ReactUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,34 @@ function ReactUpdatesFlushTransaction() {

assign(
ReactUpdatesFlushTransaction.prototype,
Transaction.Mixin, {
getTransactionWrappers: function() {
return TRANSACTION_WRAPPERS;
},

destructor: function() {
this.dirtyComponentsLength = null;
CallbackQueue.release(this.callbackQueue);
this.callbackQueue = null;
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
this.reconcileTransaction = null;
},

perform: function(method, scope, a) {
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
// with this transaction's wrappers around it.
return Transaction.Mixin.perform.call(
this,
this.reconcileTransaction.perform,
this.reconcileTransaction,
method,
scope,
a
);
},
});
Transaction.Mixin,
{
getTransactionWrappers: function() {
return TRANSACTION_WRAPPERS;
},

destructor: function() {
this.dirtyComponentsLength = null;
CallbackQueue.release(this.callbackQueue);
this.callbackQueue = null;
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
this.reconcileTransaction = null;
},

perform: function(method, scope, a) {
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
// with this transaction's wrappers around it.
return Transaction.Mixin.perform.call(
this,
this.reconcileTransaction.perform,
this.reconcileTransaction,
method,
scope,
a
);
},
}
);

PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ describe('ReactComponent', function() {
log.push('start unmount');
React.unmountComponentAtNode(el);

/* eslint-disable indent */
expect(log).toEqual([
'start mount',
'inner 1 render',
Expand Down Expand Up @@ -251,6 +252,7 @@ describe('ReactComponent', function() {
'ref 2 got null',
'inner 2 componentWillUnmount',
]);
/* eslint-enable indent */
});

it('fires the callback after a component is rendered', function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ describe('ReactUpdates', function() {
ref="switcherDiv"
style={{
display: this.state.tabKey === child.key ? '' : 'none',
}}>
}}>
{child}
</div>
</Box>
Expand Down Expand Up @@ -601,6 +601,7 @@ describe('ReactUpdates', function() {
});
});

/* eslint-disable indent */
expect(updates).toEqual([
'Outer-render-0',
'Inner-render-0-0',
Expand All @@ -627,6 +628,7 @@ describe('ReactUpdates', function() {
'Inner-callback-2',
'Outer-callback-2',
]);
/* eslint-enable indent */
});

it('should flush updates in the correct order across roots', function() {
Expand Down
Loading

0 comments on commit ecb34de

Please sign in to comment.