diff --git a/.eslintignore b/.eslintignore index b9ab089727..a2f320ee44 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,7 +1,9 @@ # We can probably lint these later but not important at this point src/vendor src/vendor_deprecated -# estraverse stumbles on XJSSpreadAttribute so just ignore tests for now +# eslint uses JSX* node types to determine if using JSX. esprima-fb still uses +# XJS* nodes. When we fix that (https://github.com/facebook/esprima/pull/85) we +# can enable linting the tests and fix those errors. src/**/__tests__/** # This should be enabled but that folder has too much in it that doesn't belong src/test diff --git a/package.json b/package.json index 6f14eaa037..ea57cf03b0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "envify": "^3.0.0", "es3ify": "~0.1.2", "es5-shim": "^4.0.0", - "eslint": "0.11.0-alpha.0", + "eslint": "^0.14.1", + "esprima-fb": "^10001.1.0-dev-harmony-fb", "grunt": "~0.4.2", "grunt-cli": "~0.1.9", "grunt-compare-size": "~0.4.0", diff --git a/src/.eslintrc b/src/.eslintrc index c9b9b50bc4..699a6b7c93 100644 --- a/src/.eslintrc +++ b/src/.eslintrc @@ -1,7 +1,5 @@ --- -settings: - jsx: true - ecmascript: 6 +parser: esprima-fb env: browser: true @@ -25,9 +23,10 @@ rules: eol-last: 2 dot-notation: 2 consistent-return: 2 + no-unused-vars: [2, args: none] + quotes: [2, 'single'] # WARNINGS - quotes: [1, 'single'] # This is the only one that's hard to track since we don't lint just changes. max-len: [1, 80] @@ -43,8 +42,6 @@ rules: new-cap: 0 # We do this a lot. no-use-before-define: 0 - # We should have this enabled but https://github.com/eslint/eslint/issues/1542 - no-unused-vars: 0 # We do this in a few places to align values key-spacing: 0 diff --git a/src/browser/eventPlugins/BeforeInputEventPlugin.js b/src/browser/eventPlugins/BeforeInputEventPlugin.js index b2fe31f69c..d3c716d80a 100644 --- a/src/browser/eventPlugins/BeforeInputEventPlugin.js +++ b/src/browser/eventPlugins/BeforeInputEventPlugin.js @@ -131,9 +131,6 @@ var eventTypes = { } }; -// Track characters inserted via keypress and composition events. -var fallbackBeforeInputChars = null; - // Track whether we've ever handled a keypress on the space key. var hasSpaceKeypress = false; @@ -437,7 +434,6 @@ function extractBeforeInputEvent( ); event.data = chars; - fallbackBeforeInputChars = null; EventPropagators.accumulateTwoPhaseDispatches(event); return event; } diff --git a/src/browser/eventPlugins/SimpleEventPlugin.js b/src/browser/eventPlugins/SimpleEventPlugin.js index a066e0d7ad..1fe40bacbb 100644 --- a/src/browser/eventPlugins/SimpleEventPlugin.js +++ b/src/browser/eventPlugins/SimpleEventPlugin.js @@ -285,8 +285,8 @@ var topLevelEventsToDispatchConfig = { topWheel: eventTypes.wheel }; -for (var topLevelType in topLevelEventsToDispatchConfig) { - topLevelEventsToDispatchConfig[topLevelType].dependencies = [topLevelType]; +for (var type in topLevelEventsToDispatchConfig) { + topLevelEventsToDispatchConfig[type].dependencies = [type]; } var SimpleEventPlugin = { diff --git a/src/browser/ui/ReactDOMComponent.js b/src/browser/ui/ReactDOMComponent.js index bf3b4b135e..7beeebd2bd 100644 --- a/src/browser/ui/ReactDOMComponent.js +++ b/src/browser/ui/ReactDOMComponent.js @@ -64,7 +64,8 @@ function assertValidProps(props) { invariant( props.dangerouslySetInnerHTML.__html != null, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + - 'Please visit http://fb.me/react-invariant-dangerously-set-inner-html for more information.' + 'Please visit http://fb.me/react-invariant-dangerously-set-inner-html ' + + 'for more information.' ); } if (__DEV__) { diff --git a/src/browser/ui/ReactDOMTextComponent.js b/src/browser/ui/ReactDOMTextComponent.js index 1ec4e39b09..d561646a12 100644 --- a/src/browser/ui/ReactDOMTextComponent.js +++ b/src/browser/ui/ReactDOMTextComponent.js @@ -19,7 +19,6 @@ var ReactDOMComponent = require('ReactDOMComponent'); var assign = require('Object.assign'); var escapeTextContentForBrowser = require('escapeTextContentForBrowser'); -var invariant = require('invariant'); /** * Text nodes violate a couple assumptions that React makes about components: diff --git a/src/browser/ui/dom/DOMPropertyOperations.js b/src/browser/ui/dom/DOMPropertyOperations.js index f94703ea50..192aee1427 100644 --- a/src/browser/ui/dom/DOMPropertyOperations.js +++ b/src/browser/ui/dom/DOMPropertyOperations.js @@ -14,7 +14,6 @@ var DOMProperty = require('DOMProperty'); -var escapeTextContentForBrowser = require('escapeTextContentForBrowser'); var quoteAttributeValueForBrowser = require('quoteAttributeValueForBrowser'); var warning = require('warning'); diff --git a/src/browser/ui/dom/components/__tests__/ReactDOMIframe-test.js b/src/browser/ui/dom/components/__tests__/ReactDOMIframe-test.js index 65f214787c..be455ad24b 100644 --- a/src/browser/ui/dom/components/__tests__/ReactDOMIframe-test.js +++ b/src/browser/ui/dom/components/__tests__/ReactDOMIframe-test.js @@ -10,7 +10,7 @@ * @emails react-core */ -"use strict"; +'use strict'; describe('ReactDOMIframe', function() { var React; diff --git a/src/browser/ui/dom/setTextContent.js b/src/browser/ui/dom/setTextContent.js index c78fe2064e..75cbeb046f 100644 --- a/src/browser/ui/dom/setTextContent.js +++ b/src/browser/ui/dom/setTextContent.js @@ -16,7 +16,7 @@ * @providesModule setTextContent */ -"use strict"; +'use strict'; var ExecutionEnvironment = require('ExecutionEnvironment'); var escapeTextContentForBrowser = require('escapeTextContentForBrowser'); diff --git a/src/classic/types/ReactPropTypes.js b/src/classic/types/ReactPropTypes.js index 969d89d27a..03b2edf394 100644 --- a/src/classic/types/ReactPropTypes.js +++ b/src/classic/types/ReactPropTypes.js @@ -94,7 +94,7 @@ function createChainableTypeChecker(validate) { var locationName = ReactPropTypeLocationNames[location]; if (isRequired) { return new Error( - `Required ${locationName} \`${propName}\` was not specified in `+ + `Required ${locationName} \`${propName}\` was not specified in ` + `\`${componentName}\`.` ); } diff --git a/src/core/ReactCompositeComponent.js b/src/core/ReactCompositeComponent.js index 1382b54a74..ae06ef29c6 100644 --- a/src/core/ReactCompositeComponent.js +++ b/src/core/ReactCompositeComponent.js @@ -564,7 +564,10 @@ var ReactCompositeComponentMixin = { if (__DEV__) { if (nextUnmaskedContext != null) { - this._warnIfContextsDiffer(nextParentElement._context, nextUnmaskedContext); + this._warnIfContextsDiffer( + nextParentElement._context, + nextUnmaskedContext + ); } } @@ -663,7 +666,6 @@ var ReactCompositeComponentMixin = { ) { var inst = this._instance; - var prevElement = this._currentElement; var prevProps = inst.props; var prevState = inst.state; var prevContext = inst.context; diff --git a/src/core/ReactLifeCycle.js b/src/core/ReactLifeCycle.js index cd6a2365af..27e42c1bfd 100644 --- a/src/core/ReactLifeCycle.js +++ b/src/core/ReactLifeCycle.js @@ -9,7 +9,7 @@ * @providesModule ReactLifeCycle */ -"use strict"; +'use strict'; /** * This module manages the bookkeeping when a component is in the process diff --git a/src/core/ReactUpdateQueue.js b/src/core/ReactUpdateQueue.js index 0fbdeff06d..75b07ad840 100644 --- a/src/core/ReactUpdateQueue.js +++ b/src/core/ReactUpdateQueue.js @@ -9,7 +9,7 @@ * @providesModule ReactUpdateQueue */ -"use strict"; +'use strict'; var ReactLifeCycle = require('ReactLifeCycle'); var ReactCurrentOwner = require('ReactCurrentOwner'); @@ -101,7 +101,7 @@ var ReactUpdateQueue = { enqueueCallbackInternal: function(internalInstance, callback) { invariant( - typeof callback === "function", + typeof callback === 'function', 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.' diff --git a/src/event/EventPluginUtils.js b/src/event/EventPluginUtils.js index 34a4a3e998..dc06d947f6 100644 --- a/src/event/EventPluginUtils.js +++ b/src/event/EventPluginUtils.js @@ -115,8 +115,8 @@ function executeDispatch(event, listener, domID) { /** * Standard/simple iteration through an event's collected dispatches. */ -function executeDispatchesInOrder(event, executeDispatch) { - forEachEventDispatch(event, executeDispatch); +function executeDispatchesInOrder(event, cb) { + forEachEventDispatch(event, cb); event._dispatchListeners = null; event._dispatchIDs = null; } diff --git a/src/modern/class/ReactComponent.js b/src/modern/class/ReactComponent.js index 8f29d41309..a3e38f0c6c 100644 --- a/src/modern/class/ReactComponent.js +++ b/src/modern/class/ReactComponent.js @@ -119,9 +119,9 @@ if (__DEV__) { // IE will fail on defineProperty (es5-shim/sham too) } }; - for (var methodName in deprecatedAPIs) { - if (deprecatedAPIs.hasOwnProperty(methodName)) { - defineDeprecationWarning(methodName, deprecatedAPIs[methodName]); + for (var fnName in deprecatedAPIs) { + if (deprecatedAPIs.hasOwnProperty(fnName)) { + defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); } } } diff --git a/src/utils/__tests__/quoteAttributeValueForBrowser-test.js b/src/utils/__tests__/quoteAttributeValueForBrowser-test.js index 1c12ec3d96..30fe4ff830 100644 --- a/src/utils/__tests__/quoteAttributeValueForBrowser-test.js +++ b/src/utils/__tests__/quoteAttributeValueForBrowser-test.js @@ -9,7 +9,7 @@ * @emails react-core */ -"use strict"; +'use strict'; describe('quoteAttributeValueForBrowser', function() { diff --git a/src/utils/quoteAttributeValueForBrowser.js b/src/utils/quoteAttributeValueForBrowser.js index cda7a84063..576b40ae5e 100644 --- a/src/utils/quoteAttributeValueForBrowser.js +++ b/src/utils/quoteAttributeValueForBrowser.js @@ -9,7 +9,7 @@ * @providesModule quoteAttributeValueForBrowser */ -"use strict"; +'use strict'; var escapeTextContentForBrowser = require('escapeTextContentForBrowser');