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

Upgrade to newer eslint, use esprima-fb

Eslint now allows us to use a different parser, which allows us to use esprima-fb explicitly. This means we don't have to wait for espree to add things like rest-param parsing. Though we do need eslint to upgrade its rules to handle that AST. I had hoped to enable parsing of our tests but we can't do that until we change esprima-fb's XJS nodes to JSX. While I was here, I also enabled the no-unused-vars rule since eslint understands template strings. I also made the single quote enforcement actually fail instead of just warn.

Paul O’Shannessy committed Feb 9, 2015 at 11:27 UTC dae1dc629272593f342fe22c6c795cb8fdf33d11
18 files changed +29 -32
.eslintignore
+3 -1
@@ -1,7 +1,9 @@
1 # We can probably lint these later but not important at this point
2 src/vendor
3 src/vendor_deprecated
4 -# estraverse stumbles on XJSSpreadAttribute so just ignore tests for now
4 +# eslint uses JSX* node types to determine if using JSX. esprima-fb still uses
5 +# XJS* nodes. When we fix that (https://github.com/facebook/esprima/pull/85) we
6 +# can enable linting the tests and fix those errors.
7 src/**/__tests__/**
8 # This should be enabled but that folder has too much in it that doesn't belong
9 src/test
package.json
+2 -1
@@ -39,7 +39,8 @@
39 "envify": "^3.0.0",
40 "es3ify": "~0.1.2",
41 "es5-shim": "^4.0.0",
42 - "eslint": "0.11.0-alpha.0",
42 + "eslint": "^0.14.1",
43 + "esprima-fb": "^10001.1.0-dev-harmony-fb",
44 "grunt": "~0.4.2",
45 "grunt-cli": "~0.1.9",
46 "grunt-compare-size": "~0.4.0",
src/.eslintrc
+3 -6
@@ -1,7 +1,5 @@
1 ---
2 -settings:
3 - jsx: true
4 - ecmascript: 6
2 +parser: esprima-fb
3
4 env:
5 browser: true
@@ -25,9 +23,10 @@ rules:
23 eol-last: 2
24 dot-notation: 2
25 consistent-return: 2
26 + no-unused-vars: [2, args: none]
27 + quotes: [2, 'single']
28
29 # WARNINGS
30 - quotes: [1, 'single']
30 # This is the only one that's hard to track since we don't lint just changes.
31 max-len: [1, 80]
32
@@ -43,8 +42,6 @@ rules:
42 new-cap: 0
43 # We do this a lot.
44 no-use-before-define: 0
46 - # We should have this enabled but https://github.com/eslint/eslint/issues/1542
47 - no-unused-vars: 0
45 # We do this in a few places to align values
46 key-spacing: 0
47
src/browser/eventPlugins/BeforeInputEventPlugin.js
-4
@@ -131,9 +131,6 @@ var eventTypes = {
131 }
132 };
133
134 -// Track characters inserted via keypress and composition events.
135 -var fallbackBeforeInputChars = null;
136 -
134 // Track whether we've ever handled a keypress on the space key.
135 var hasSpaceKeypress = false;
136
@@ -437,7 +434,6 @@ function extractBeforeInputEvent(
434 );
435
436 event.data = chars;
440 - fallbackBeforeInputChars = null;
437 EventPropagators.accumulateTwoPhaseDispatches(event);
438 return event;
439 }
src/browser/eventPlugins/SimpleEventPlugin.js
+2 -2
@@ -285,8 +285,8 @@ var topLevelEventsToDispatchConfig = {
285 topWheel: eventTypes.wheel
286 };
287
288 -for (var topLevelType in topLevelEventsToDispatchConfig) {
289 - topLevelEventsToDispatchConfig[topLevelType].dependencies = [topLevelType];
288 +for (var type in topLevelEventsToDispatchConfig) {
289 + topLevelEventsToDispatchConfig[type].dependencies = [type];
290 }
291
292 var SimpleEventPlugin = {
src/browser/ui/ReactDOMComponent.js
+2 -1
@@ -64,7 +64,8 @@ function assertValidProps(props) {
64 invariant(
65 props.dangerouslySetInnerHTML.__html != null,
66 '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
67 - 'Please visit http://fb.me/react-invariant-dangerously-set-inner-html for more information.'
67 + 'Please visit http://fb.me/react-invariant-dangerously-set-inner-html ' +
68 + 'for more information.'
69 );
70 }
71 if (__DEV__) {
src/browser/ui/ReactDOMTextComponent.js
-1
@@ -19,7 +19,6 @@ var ReactDOMComponent = require('ReactDOMComponent');
19
20 var assign = require('Object.assign');
21 var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
22 -var invariant = require('invariant');
22
23 /**
24 * Text nodes violate a couple assumptions that React makes about components:
src/browser/ui/dom/DOMPropertyOperations.js
-1
@@ -14,7 +14,6 @@
14
15 var DOMProperty = require('DOMProperty');
16
17 -var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
17 var quoteAttributeValueForBrowser = require('quoteAttributeValueForBrowser');
18 var warning = require('warning');
19
src/browser/ui/dom/components/__tests__/ReactDOMIframe-test.js
+1 -1
@@ -10,7 +10,7 @@
10 * @emails react-core
11 */
12
13 -"use strict";
13 +'use strict';
14
15 describe('ReactDOMIframe', function() {
16 var React;
src/browser/ui/dom/setTextContent.js
+1 -1
@@ -16,7 +16,7 @@
16 * @providesModule setTextContent
17 */
18
19 -"use strict";
19 +'use strict';
20
21 var ExecutionEnvironment = require('ExecutionEnvironment');
22 var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
src/classic/types/ReactPropTypes.js
+1 -1
@@ -94,7 +94,7 @@ function createChainableTypeChecker(validate) {
94 var locationName = ReactPropTypeLocationNames[location];
95 if (isRequired) {
96 return new Error(
97 - `Required ${locationName} \`${propName}\` was not specified in `+
97 + `Required ${locationName} \`${propName}\` was not specified in ` +
98 `\`${componentName}\`.`
99 );
100 }
src/core/ReactCompositeComponent.js
+4 -2
@@ -564,7 +564,10 @@ var ReactCompositeComponentMixin = {
564
565 if (__DEV__) {
566 if (nextUnmaskedContext != null) {
567 - this._warnIfContextsDiffer(nextParentElement._context, nextUnmaskedContext);
567 + this._warnIfContextsDiffer(
568 + nextParentElement._context,
569 + nextUnmaskedContext
570 + );
571 }
572 }
573
@@ -663,7 +666,6 @@ var ReactCompositeComponentMixin = {
666 ) {
667 var inst = this._instance;
668
666 - var prevElement = this._currentElement;
669 var prevProps = inst.props;
670 var prevState = inst.state;
671 var prevContext = inst.context;
src/core/ReactLifeCycle.js
+1 -1
@@ -9,7 +9,7 @@
9 * @providesModule ReactLifeCycle
10 */
11
12 -"use strict";
12 +'use strict';
13
14 /**
15 * This module manages the bookkeeping when a component is in the process
src/core/ReactUpdateQueue.js
+2 -2
@@ -9,7 +9,7 @@
9 * @providesModule ReactUpdateQueue
10 */
11
12 -"use strict";
12 +'use strict';
13
14 var ReactLifeCycle = require('ReactLifeCycle');
15 var ReactCurrentOwner = require('ReactCurrentOwner');
@@ -101,7 +101,7 @@ var ReactUpdateQueue = {
101
102 enqueueCallbackInternal: function(internalInstance, callback) {
103 invariant(
104 - typeof callback === "function",
104 + typeof callback === 'function',
105 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
106 '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
107 'isn\'t callable.'
src/event/EventPluginUtils.js
+2 -2
@@ -115,8 +115,8 @@ function executeDispatch(event, listener, domID) {
115 /**
116 * Standard/simple iteration through an event's collected dispatches.
117 */
118 -function executeDispatchesInOrder(event, executeDispatch) {
119 - forEachEventDispatch(event, executeDispatch);
118 +function executeDispatchesInOrder(event, cb) {
119 + forEachEventDispatch(event, cb);
120 event._dispatchListeners = null;
121 event._dispatchIDs = null;
122 }
src/modern/class/ReactComponent.js
+3 -3
@@ -119,9 +119,9 @@ if (__DEV__) {
119 // IE will fail on defineProperty (es5-shim/sham too)
120 }
121 };
122 - for (var methodName in deprecatedAPIs) {
123 - if (deprecatedAPIs.hasOwnProperty(methodName)) {
124 - defineDeprecationWarning(methodName, deprecatedAPIs[methodName]);
122 + for (var fnName in deprecatedAPIs) {
123 + if (deprecatedAPIs.hasOwnProperty(fnName)) {
124 + defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
125 }
126 }
127 }
src/utils/__tests__/quoteAttributeValueForBrowser-test.js
+1 -1
@@ -9,7 +9,7 @@
9 * @emails react-core
10 */
11
12 -"use strict";
12 +'use strict';
13
14 describe('quoteAttributeValueForBrowser', function() {
15
src/utils/quoteAttributeValueForBrowser.js
+1 -1
@@ -9,7 +9,7 @@
9 * @providesModule quoteAttributeValueForBrowser
10 */
11
12 -"use strict";
12 +'use strict';
13
14 var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
15