From b7b74b7efe36ef6de3be8a6101ea74cf8e967439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= <paul@oshannessy.com> Date: Wed, 19 Nov 2014 15:24:14 +0000 Subject: [PATCH] Fix lint warnings, style fixups Followup work for recent PRs --- src/browser/server/ReactServerRendering.js | 2 -- src/browser/ui/ReactDOMTextComponent.js | 2 +- .../ui/__tests__/ReactDOMTextComponent-test.js | 2 +- .../components/__tests__/ReactDOMSelect-test.js | 8 +++----- src/core/ReactComponent.js | 2 +- src/core/ReactCompositeComponent.js | 6 +++--- src/core/ReactPropTransferer.js | 4 ---- src/core/ReactRef.js | 17 +++++------------ src/core/__tests__/ReactEmptyComponent-test.js | 1 - src/core/instantiateReactComponent.js | 3 ++- src/core/shouldUpdateReactComponent.js | 2 -- src/test/ReactTestUtils.js | 1 - 12 files changed, 16 insertions(+), 34 deletions(-) diff --git a/src/browser/server/ReactServerRendering.js b/src/browser/server/ReactServerRendering.js index 02482b17ab03a..670d7524129e8 100644 --- a/src/browser/server/ReactServerRendering.js +++ b/src/browser/server/ReactServerRendering.js @@ -23,7 +23,6 @@ var invariant = require('invariant'); /** * @param {ReactElement} element - * @param {?object} context * @return {string} the HTML markup */ function renderToString(element) { @@ -49,7 +48,6 @@ function renderToString(element) { /** * @param {ReactElement} element - * @param {?object} context * @return {string} the HTML markup, without the extra React ID and checksum * (for generating static pages) */ diff --git a/src/browser/ui/ReactDOMTextComponent.js b/src/browser/ui/ReactDOMTextComponent.js index e12ee2753a950..4999d750dbffe 100644 --- a/src/browser/ui/ReactDOMTextComponent.js +++ b/src/browser/ui/ReactDOMTextComponent.js @@ -43,7 +43,7 @@ var ReactDOMTextComponent = function(props) { assign(ReactDOMTextComponent.prototype, { /** - * @param {ReactText} node + * @param {ReactText} text * @internal */ construct: function(text) { diff --git a/src/browser/ui/__tests__/ReactDOMTextComponent-test.js b/src/browser/ui/__tests__/ReactDOMTextComponent-test.js index 269eb0ac6952e..37a1b9822b5bf 100644 --- a/src/browser/ui/__tests__/ReactDOMTextComponent-test.js +++ b/src/browser/ui/__tests__/ReactDOMTextComponent-test.js @@ -36,7 +36,7 @@ describe('ReactDOMTextComponent', function() { expect(foo.tagName).toBe('SPAN'); expect(bar.tagName).toBe('SPAN'); - var inst = React.render(<div>{'baz'}{'qux'}</div>, el); + inst = React.render(<div>{'baz'}{'qux'}</div>, el); // After the update, the spans should have stayed in place (as opposed to // getting unmounted and remounted) expect(inst.getDOMNode().children[0]).toBe(foo); diff --git a/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js b/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js index 7aca652a2f4a4..4f99f99bf9788 100644 --- a/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js +++ b/src/browser/ui/dom/components/__tests__/ReactDOMSelect-test.js @@ -138,9 +138,7 @@ describe('ReactDOMSelect', function() { }); it('should reset child options selected when they are changed and `value` is set', function() { - var stub = - <select multiple={true} value={["a", "b"]}> - </select> + var stub = <select multiple={true} value={["a", "b"]} />; stub = ReactTestUtils.renderIntoDocument(stub); stub.setProps({ @@ -149,9 +147,9 @@ describe('ReactDOMSelect', function() { <option value="b">b</option>, <option value="c">c</option> ] - }) + }); - var node = stub.getDOMNode() + var node = stub.getDOMNode(); expect(node.options[0].selected).toBe(true); // a expect(node.options[1].selected).toBe(true); // b diff --git a/src/core/ReactComponent.js b/src/core/ReactComponent.js index aefed025e4294..678aa7033349b 100644 --- a/src/core/ReactComponent.js +++ b/src/core/ReactComponent.js @@ -180,7 +180,7 @@ var ReactComponent = { invariant( false, 'getPublicInstance should never be called on the base class. It must ' + - 'be overriden.' + 'be overridden.' ); } } diff --git a/src/core/ReactCompositeComponent.js b/src/core/ReactCompositeComponent.js index a65efe7c2ef1b..fed6166db5490 100644 --- a/src/core/ReactCompositeComponent.js +++ b/src/core/ReactCompositeComponent.js @@ -21,12 +21,10 @@ var ReactPerf = require('ReactPerf'); var ReactPropTypeLocations = require('ReactPropTypeLocations'); var ReactUpdates = require('ReactUpdates'); -var emptyObject = require('emptyObject'); var assign = require('Object.assign'); var emptyObject = require('emptyObject'); var invariant = require('invariant'); var keyMirror = require('keyMirror'); -var monitorCodeUse = require('monitorCodeUse'); var shouldUpdateReactComponent = require('shouldUpdateReactComponent'); var warning = require('warning'); @@ -428,7 +426,9 @@ var ReactCompositeComponentMixin = assign({}, _processContext: function(context) { var maskedContext = null; var contextTypes = this._instance.constructor.contextTypes; - if (!contextTypes) return emptyObject; + if (!contextTypes) { + return emptyObject; + } maskedContext = {}; for (var contextName in contextTypes) { maskedContext[contextName] = context[contextName]; diff --git a/src/core/ReactPropTransferer.js b/src/core/ReactPropTransferer.js index b1a3c3d549653..6b9edc364ec2c 100644 --- a/src/core/ReactPropTransferer.js +++ b/src/core/ReactPropTransferer.js @@ -13,11 +13,7 @@ var assign = require('Object.assign'); var emptyFunction = require('emptyFunction'); -var invariant = require('invariant'); var joinClasses = require('joinClasses'); -var warning = require('warning'); - -var didWarn = false; /** * Creates a transfer strategy that will merge prop values using the supplied diff --git a/src/core/ReactRef.js b/src/core/ReactRef.js index b93290703ef3d..d99a91a4cc9e0 100644 --- a/src/core/ReactRef.js +++ b/src/core/ReactRef.js @@ -1,17 +1,10 @@ /** - * Copyright 2013-2014 Facebook, Inc. + * Copyright 2013-2014, Facebook, Inc. + * All rights reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ReactRef */ diff --git a/src/core/__tests__/ReactEmptyComponent-test.js b/src/core/__tests__/ReactEmptyComponent-test.js index 8236db353952b..9882de9e60481 100644 --- a/src/core/__tests__/ReactEmptyComponent-test.js +++ b/src/core/__tests__/ReactEmptyComponent-test.js @@ -232,4 +232,3 @@ describe('ReactEmptyComponent', function() { ); }); }); - diff --git a/src/core/instantiateReactComponent.js b/src/core/instantiateReactComponent.js index 593f54c432f8b..36fef60f55c43 100644 --- a/src/core/instantiateReactComponent.js +++ b/src/core/instantiateReactComponent.js @@ -101,7 +101,8 @@ function instantiateReactComponent(node, parentCompositeType) { } else { invariant( false, - 'Encountered invalid React node of type ' + typeof node + 'Encountered invalid React node of type %s', + typeof node ); } diff --git a/src/core/shouldUpdateReactComponent.js b/src/core/shouldUpdateReactComponent.js index 10c39d9c652e0..90bfd6375e9f6 100644 --- a/src/core/shouldUpdateReactComponent.js +++ b/src/core/shouldUpdateReactComponent.js @@ -12,8 +12,6 @@ "use strict"; -var ReactNativeComponent = require('ReactNativeComponent'); - /** * Given a `prevElement` and `nextElement`, determines if the existing * instance should be updated as opposed to being destroyed or replaced by a new diff --git a/src/test/ReactTestUtils.js b/src/test/ReactTestUtils.js index 8871a8c12ca29..fec6709b538e3 100644 --- a/src/test/ReactTestUtils.js +++ b/src/test/ReactTestUtils.js @@ -25,7 +25,6 @@ var ReactUpdates = require('ReactUpdates'); var SyntheticEvent = require('SyntheticEvent'); var assign = require('Object.assign'); -var instantiateReactComponent = require('instantiateReactComponent'); var topLevelTypes = EventConstants.topLevelTypes;