@samitouri / QOS-React-2 / commits / ecb34de574

Upgrade ESLint, fix code

Paul O’Shannessy committed Aug 10, 2015 at 16:44 UTC ecb34de5747a6d4578dc4be920a033db9f81370f
22 files changed +115 -84
.eslintrc
+2 -2
@@ -27,10 +27,10 @@ globals:
27 rules:
28 # ERRORS
29 space-before-blocks: 2
30 - indent: [2, 2, indentSwitchCase: true]
30 + indent: [2, 2, {SwitchCase: 1}]
31 brace-style: 2
32 space-after-keywords: 2
33 - strict: 2
33 + strict: [2, global]
34 comma-dangle: [2, always-multiline]
35 # Make this a warning for now. We do this in a few places so we might need to
36 # disable
docs/_js/examples/.eslintrc
+1
@@ -2,5 +2,6 @@
2 rules:
3 block-scoped-var: 0
4 no-undef: 0
5 + strict: 0
6 react/react-in-jsx-scope: 0
7 react/jsx-no-undef: 0
eslint-rules/__tests__/warning-and-invariant-args-test.js
+4 -5
@@ -11,11 +11,11 @@
11
12 'use strict';
13
14 -var eslint = require('eslint');
15 -var ESLintTester = require('eslint-tester');
16 -var eslintTester = new ESLintTester(eslint.linter);
14 +var rule = require('../warning-and-invariant-args');
15 +var RuleTester = require('eslint').RuleTester;
16 +var ruleTester = new RuleTester();
17
18 -eslintTester.addRuleTest('eslint-rules/warning-and-invariant-args', {
18 +ruleTester.run('eslint-rules/warning-and-invariant-args', rule, {
19 valid: [
20 "warning(true, 'hello, world');",
21 "warning(true, 'expected %s, got %s', 42, 24);",
@@ -100,4 +100,3 @@ eslintTester.addRuleTest('eslint-rules/warning-and-invariant-args', {
100 },
101 ],
102 });
103 -
grunt/config/npm.js
+2
@@ -1 +1,3 @@
1 +'use strict';
2 +
3 exports.pack = {};
grunt/tasks/release.js
+3 -2
@@ -127,13 +127,14 @@ function docs() {
127 function msg() {
128 // Just output a friendly reminder message for the rest of the process
129 grunt.log.subhead('Release *almost* complete...');
130 - [
130 + var steps = [
131 'Still todo:',
132 '* put files on CDN',
133 '* push changes to git repositories',
134 '* publish npm module (`npm publish .`)',
135 '* announce it on FB/Twitter/mailing list',
136 - ].forEach(function(ln) {
136 + ];
137 + steps.forEach(function(ln) {
138 grunt.log.writeln(ln);
139 });
140 }
package.json
+3 -4
@@ -4,7 +4,7 @@
4 "version": "0.14.0-beta3",
5 "devDependencies": {
6 "babel": "^5.8.3",
7 - "babel-eslint": "^3.1.25",
7 + "babel-eslint": "^4.0.5",
8 "benchmark": "^1.0.0",
9 "browserify": "^9.0.3",
10 "bundle-collapser": "^1.1.1",
@@ -12,10 +12,9 @@
12 "del": "^1.2.0",
13 "derequire": "^2.0.0",
14 "envify": "^3.0.0",
15 - "eslint": "^0.24.1",
16 - "eslint-plugin-react": "^2.5.0",
15 + "eslint": "^1.1.0",
16 + "eslint-plugin-react": "^3.2.1",
17 "eslint-plugin-react-internal": "file:eslint-rules",
18 - "eslint-tester": "^0.7.0",
18 "fbjs": "0.1.0-alpha.4",
19 "grunt": "^0.4.5",
20 "grunt-cli": "^0.1.13",
packages/react-dom/index.js
+2
@@ -1 +1,3 @@
1 +'use strict';
2 +
3 module.exports = require('react/lib/ReactDOM');
packages/react-dom/server.js
+2
@@ -1 +1,3 @@
1 +'use strict';
2 +
3 module.exports = require('react/lib/ReactDOMServer');
packages/react/addons.js
+2
@@ -1,3 +1,5 @@
1 +'use strict';
2 +
3 var warning = require('fbjs/lib/warning');
4 warning(
5 false,
scripts/jest/environment.js
+1
@@ -1 +1,2 @@
1 +/* eslint-disable */
2 __DEV__ = true;
src/renderers/dom/client/ReactMount.js
+13 -11
@@ -257,12 +257,13 @@ function findDeepestCachedAncestor(targetID) {
257 * @param {boolean} shouldReuseMarkup If true, do not insert markup
258 */
259 function mountComponentIntoNode(
260 - componentInstance,
261 - rootID,
262 - container,
263 - transaction,
264 - shouldReuseMarkup,
265 - context) {
260 + componentInstance,
261 + rootID,
262 + container,
263 + transaction,
264 + shouldReuseMarkup,
265 + context
266 +) {
267 if (__DEV__) {
268 if (context === emptyObject) {
269 context = {};
@@ -287,11 +288,12 @@ function mountComponentIntoNode(
288 * @param {boolean} shouldReuseMarkup If true, do not insert markup
289 */
290 function batchedMountComponentIntoNode(
290 - componentInstance,
291 - rootID,
292 - container,
293 - shouldReuseMarkup,
294 - context) {
291 + componentInstance,
292 + rootID,
293 + container,
294 + shouldReuseMarkup,
295 + context
296 +) {
297 var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
298 transaction.perform(
299 mountComponentIntoNode,
src/renderers/dom/client/eventPlugins/ChangeEventPlugin.js
+24 -18
@@ -115,17 +115,19 @@ function stopWatchingForChangeEventIE8() {
115 }
116
117 function getTargetIDForChangeEvent(
118 - topLevelType,
119 - topLevelTarget,
120 - topLevelTargetID) {
118 + topLevelType,
119 + topLevelTarget,
120 + topLevelTargetID
121 +) {
122 if (topLevelType === topLevelTypes.topChange) {
123 return topLevelTargetID;
124 }
125 }
126 function handleEventsForChangeEventIE8(
126 - topLevelType,
127 - topLevelTarget,
128 - topLevelTargetID) {
127 + topLevelType,
128 + topLevelTarget,
129 + topLevelTargetID
130 +) {
131 if (topLevelType === topLevelTypes.topFocus) {
132 // stopWatching() should be a noop here but we call it just in case we
133 // missed a blur event somehow.
@@ -222,9 +224,10 @@ function handlePropertyChange(nativeEvent) {
224 * If a `change` event should be fired, returns the target's ID.
225 */
226 function getTargetIDForInputEvent(
225 - topLevelType,
226 - topLevelTarget,
227 - topLevelTargetID) {
227 + topLevelType,
228 + topLevelTarget,
229 + topLevelTargetID
230 +) {
231 if (topLevelType === topLevelTypes.topInput) {
232 // In modern browsers (i.e., not IE8 or IE9), the input event is exactly
233 // what we want so fall through here and trigger an abstract event
@@ -234,9 +237,10 @@ function getTargetIDForInputEvent(
237
238 // For IE8 and IE9.
239 function handleEventsForInputEventIE(
237 - topLevelType,
238 - topLevelTarget,
239 - topLevelTargetID) {
240 + topLevelType,
241 + topLevelTarget,
242 + topLevelTargetID
243 +) {
244 if (topLevelType === topLevelTypes.topFocus) {
245 // In IE8, we can capture almost all .value changes by adding a
246 // propertychange handler and looking for events with propertyName
@@ -260,9 +264,10 @@ function handleEventsForInputEventIE(
264
265 // For IE8 and IE9.
266 function getTargetIDForInputEventIE(
263 - topLevelType,
264 - topLevelTarget,
265 - topLevelTargetID) {
267 + topLevelType,
268 + topLevelTarget,
269 + topLevelTargetID
270 +) {
271 if (topLevelType === topLevelTypes.topSelectionChange ||
272 topLevelType === topLevelTypes.topKeyUp ||
273 topLevelType === topLevelTypes.topKeyDown) {
@@ -298,9 +303,10 @@ function shouldUseClickEvent(elem) {
303 }
304
305 function getTargetIDForClickEvent(
301 - topLevelType,
302 - topLevelTarget,
303 - topLevelTargetID) {
306 + topLevelType,
307 + topLevelTarget,
308 + topLevelTargetID
309 +) {
310 if (topLevelType === topLevelTypes.topClick) {
311 return topLevelTargetID;
312 }
src/renderers/dom/client/syntheticEvents/SyntheticCompositionEvent.js
+2 -1
@@ -32,7 +32,8 @@ function SyntheticCompositionEvent(
32 dispatchConfig,
33 dispatchMarker,
34 nativeEvent,
35 - nativeEventTarget) {
35 + nativeEventTarget
36 +) {
37 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
38 }
39
src/renderers/dom/client/syntheticEvents/SyntheticInputEvent.js
+2 -1
@@ -33,7 +33,8 @@ function SyntheticInputEvent(
33 dispatchConfig,
34 dispatchMarker,
35 nativeEvent,
36 - nativeEventTarget) {
36 + nativeEventTarget
37 +) {
38 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
39 }
40
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+3 -3
@@ -478,9 +478,9 @@ describe('ReactDOMComponent', function() {
478
479 it('should not duplicate uppercased selfclosing tags', function() {
480 var Container = React.createClass({
481 - render: function() {
482 - return React.createElement('BR', null);
483 - },
481 + render: function() {
482 + return React.createElement('BR', null);
483 + },
484 });
485 var returnedValue = React.renderToString(<Container/>);
486 expect(returnedValue).not.toContain('</BR>');
src/renderers/shared/event/eventPlugins/ResponderEventPlugin.js
+5 -4
@@ -323,10 +323,11 @@ to return true:wantsResponderID| |
323 * @return {*} An accumulation of synthetic events.
324 */
325 function setResponderAndExtractTransfer(
326 - topLevelType,
327 - topLevelTargetID,
328 - nativeEvent,
329 - nativeEventTarget) {
326 + topLevelType,
327 + topLevelTargetID,
328 + nativeEvent,
329 + nativeEventTarget
330 +) {
331 var shouldSetEventType =
332 isStartish(topLevelType) ? eventTypes.startShouldSetResponder :
333 isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder :
src/renderers/shared/event/eventPlugins/__tests__/ResponderEventPlugin-test.js
+7 -2
@@ -66,8 +66,13 @@ var antiSubsequence = function(arr, indices) {
66 * Helper for creating touch test config data.
67 * @param allTouchHandles
68 */
69 -var _touchConfig =
70 - function(topType, targetNodeHandle, allTouchHandles, changedIndices, eventTarget) {
69 +var _touchConfig = function(
70 + topType,
71 + targetNodeHandle,
72 + allTouchHandles,
73 + changedIndices,
74 + eventTarget
75 +) {
76 var allTouchObjects = allTouchHandles.map(touch);
77 var changedTouchObjects = subsequence(allTouchObjects, changedIndices);
78 var activeTouchObjects =
src/renderers/shared/reconciler/ReactUpdates.js
+28 -26
@@ -74,32 +74,34 @@ function ReactUpdatesFlushTransaction() {
74
75 assign(
76 ReactUpdatesFlushTransaction.prototype,
77 - Transaction.Mixin, {
78 - getTransactionWrappers: function() {
79 - return TRANSACTION_WRAPPERS;
80 - },
81 -
82 - destructor: function() {
83 - this.dirtyComponentsLength = null;
84 - CallbackQueue.release(this.callbackQueue);
85 - this.callbackQueue = null;
86 - ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
87 - this.reconcileTransaction = null;
88 - },
89 -
90 - perform: function(method, scope, a) {
91 - // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
92 - // with this transaction's wrappers around it.
93 - return Transaction.Mixin.perform.call(
94 - this,
95 - this.reconcileTransaction.perform,
96 - this.reconcileTransaction,
97 - method,
98 - scope,
99 - a
100 - );
101 - },
102 -});
77 + Transaction.Mixin,
78 + {
79 + getTransactionWrappers: function() {
80 + return TRANSACTION_WRAPPERS;
81 + },
82 +
83 + destructor: function() {
84 + this.dirtyComponentsLength = null;
85 + CallbackQueue.release(this.callbackQueue);
86 + this.callbackQueue = null;
87 + ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
88 + this.reconcileTransaction = null;
89 + },
90 +
91 + perform: function(method, scope, a) {
92 + // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
93 + // with this transaction's wrappers around it.
94 + return Transaction.Mixin.perform.call(
95 + this,
96 + this.reconcileTransaction.perform,
97 + this.reconcileTransaction,
98 + method,
99 + scope,
100 + a
101 + );
102 + },
103 + }
104 +);
105
106 PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
107
src/renderers/shared/reconciler/__tests__/ReactComponent-test.js
+2
@@ -224,6 +224,7 @@ describe('ReactComponent', function() {
224 log.push('start unmount');
225 React.unmountComponentAtNode(el);
226
227 + /* eslint-disable indent */
228 expect(log).toEqual([
229 'start mount',
230 'inner 1 render',
@@ -251,6 +252,7 @@ describe('ReactComponent', function() {
252 'ref 2 got null',
253 'inner 2 componentWillUnmount',
254 ]);
255 + /* eslint-enable indent */
256 });
257
258 it('fires the callback after a component is rendered', function() {
src/renderers/shared/reconciler/__tests__/ReactUpdates-test.js
+3 -1
@@ -409,7 +409,7 @@ describe('ReactUpdates', function() {
409 ref="switcherDiv"
410 style={{
411 display: this.state.tabKey === child.key ? '' : 'none',
412 - }}>
412 + }}>
413 {child}
414 </div>
415 </Box>
@@ -601,6 +601,7 @@ describe('ReactUpdates', function() {
601 });
602 });
603
604 + /* eslint-disable indent */
605 expect(updates).toEqual([
606 'Outer-render-0',
607 'Inner-render-0-0',
@@ -627,6 +628,7 @@ describe('ReactUpdates', function() {
628 'Inner-callback-2',
629 'Outer-callback-2',
630 ]);
631 + /* eslint-enable indent */
632 });
633
634 it('should flush updates in the correct order across roots', function() {
src/shared/utils/__tests__/OrderedMap-test.js
+3 -3
@@ -616,9 +616,9 @@ describe('OrderedMap', function() {
616 expect(res.get('dog')).toBe(undefined);
617 };
618 result = OrderedMap.fromArray([
619 - {uniqueID: 'two', val: 'secondOM2'},
620 - {uniqueID: 'three', val: 'third'},
621 - ], extractUniqueID).merge(oneTwo);
619 + {uniqueID: 'two', val: 'secondOM2'},
620 + {uniqueID: 'three', val: 'third'},
621 + ], extractUniqueID).merge(oneTwo);
622 testTwoThreeMergedWithOneTwo(result);
623
624 });
src/test/__tests__/ReactTestUtils-test.js
+1 -1
@@ -163,7 +163,7 @@ describe('ReactTestUtils', function() {
163
164 var shallowRenderer = ReactTestUtils.createRenderer();
165 shallowRenderer.render(<SimpleComponent />, {
166 - name: 'foo',
166 + name: 'foo',
167 });
168 var result = shallowRenderer.getRenderOutput();
169 expect(result).toEqual(<div>foo</div>);