From 07cfd6602842efb957b4ab6ab5100bcfb397fc97 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Thu, 19 Feb 2015 00:10:28 -0500 Subject: [PATCH 1/2] lint: remove spaces from object braces --- grunt/config/browserify.js | 2 +- grunt/config/webdriver-all.js | 44 +++++++++---------- grunt/tasks/npm.js | 4 +- grunt/tasks/release.js | 8 ++-- jest/ts-preprocessor.js | 2 +- perf/lib/BrowserPerfRunnerApp.react.js | 4 +- perf/lib/BrowserPerfRunnerContext.react.js | 2 +- perf/lib/todolist.browser.js | 6 +-- perf/tests/setState-callback-5.js | 2 +- perf/tests/setState-callback.js | 2 +- perf/tests/todolist-add.js | 2 +- perf/tests/todolist-do-stuff.js | 2 +- perf/tests/todolist-edit.js | 2 +- perf/tests/todolist-mount.js | 2 +- src/addons/ReactFragment.js | 4 +- src/browser/__tests__/ReactDOM-test.js | 2 +- .../ui/__tests__/ReactDOMComponent-test.js | 30 ++++++------- src/classic/class/__tests__/ReactBind-test.js | 4 +- .../class/__tests__/ReactClass-test.js | 4 +- src/classic/element/ReactElement.js | 2 +- .../element/__tests__/ReactElement-test.js | 12 ++--- .../__tests__/ReactElementValidator-test.js | 12 ++--- .../__tests__/ReactComponentLifeCycle-test.js | 2 +- .../__tests__/ReactCompositeComponent-test.js | 22 +++++----- ...ReactCompositeComponentNestedState-test.js | 8 ++-- .../ReactCompositeComponentState-test.js | 2 +- src/core/__tests__/ReactIdentity-test.js | 4 +- .../__tests__/ReactInstanceHandles-test.js | 10 ++--- .../__tests__/ReactMockedComponent-test.js | 12 ++--- .../ReactMultiChildReconcile-test.js | 22 +++++----- src/core/__tests__/ReactUpdates-test.js | 8 ++-- src/core/__tests__/refs-test.js | 2 +- .../class/__tests__/ReactES6Class-test.js | 38 ++++++++-------- .../element/__tests__/ReactJSXElement-test.js | 6 +-- .../ReactJSXElementValidator-test.js | 14 +++--- src/utils/__tests__/ReactChildren-test.js | 2 +- .../__tests__/traverseAllChildren-test.js | 12 ++--- .../key-mirror/__tests__/keyMirror-test.js | 4 +- .../transforms/__tests__/react-test.js | 6 +-- 39 files changed, 164 insertions(+), 164 deletions(-) diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index 57b49802e920b..52e23706b1d58 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -29,7 +29,7 @@ var LICENSE_TEMPLATE = */'; function minify(src) { - return UglifyJS.minify(src, { fromString: true }).code; + return UglifyJS.minify(src, {fromString: true}).code; } // TODO: move this out to another build step maybe. diff --git a/grunt/config/webdriver-all.js b/grunt/config/webdriver-all.js index a9cf189dad2e0..31434c1490950 100644 --- a/grunt/config/webdriver-all.js +++ b/grunt/config/webdriver-all.js @@ -23,7 +23,7 @@ module.exports = function(props) { exports.local = { webdriver: { - remote: { protocol: 'http:', hostname: '127.0.0.1', port: 9515, path: '/' } + remote: {protocol: 'http:', hostname: '127.0.0.1', port: 9515, path: '/'} }, url: props.url, onStart: props.onStart, @@ -68,33 +68,33 @@ module.exports = function(props) { /*eslint-disable camelcase*/ /* https://saucelabs.com/platforms */ exports.saucelabs_ios = - exports.saucelabs_ios7 = sauceItUp({ browserName: 'iphone', version: '7', platform:'OS X 10.9' }); - exports.saucelabs_ios6_1 = sauceItUp({ browserName: 'iphone', version: '6.1', platform:'OS X 10.8' }); - exports.saucelabs_ios6 = sauceItUp({ browserName: 'iphone', version: '6', platform:'OS X 10.8' }); - exports.saucelabs_ios5_1 = sauceItUp({ browserName: 'iphone', version: '5.1', platform:'OS X 10.8' }); - exports.saucelabs_ios5 = sauceItUp({ browserName: 'iphone', version: '5', platform:'OS X 10.6' }); - exports.saucelabs_ios4 = sauceItUp({ browserName: 'iphone', version: '4', platform:'OS X 10.6' }); + exports.saucelabs_ios7 = sauceItUp({browserName: 'iphone', version: '7', platform:'OS X 10.9'}); + exports.saucelabs_ios6_1 = sauceItUp({browserName: 'iphone', version: '6.1', platform:'OS X 10.8'}); + exports.saucelabs_ios6 = sauceItUp({browserName: 'iphone', version: '6', platform:'OS X 10.8'}); + exports.saucelabs_ios5_1 = sauceItUp({browserName: 'iphone', version: '5.1', platform:'OS X 10.8'}); + exports.saucelabs_ios5 = sauceItUp({browserName: 'iphone', version: '5', platform:'OS X 10.6'}); + exports.saucelabs_ios4 = sauceItUp({browserName: 'iphone', version: '4', platform:'OS X 10.6'}); exports.saucelabs_ipad = - exports.saucelabs_ipad7 = sauceItUp({ browserName: 'ipad', version: '7', platform:'OS X 10.9' }); - exports.saucelabs_ipad6_1 = sauceItUp({ browserName: 'ipad', version: '6.1', platform:'OS X 10.8' }); - exports.saucelabs_ipad6 = sauceItUp({ browserName: 'ipad', version: '6', platform:'OS X 10.8' }); - exports.saucelabs_ipad5_1 = sauceItUp({ browserName: 'ipad', version: '5.1', platform:'OS X 10.8' }); - exports.saucelabs_ipad5 = sauceItUp({ browserName: 'ipad', version: '5', platform:'OS X 10.6' }); - exports.saucelabs_ipad4 = sauceItUp({ browserName: 'ipad', version: '4', platform:'OS X 10.6' }); + exports.saucelabs_ipad7 = sauceItUp({browserName: 'ipad', version: '7', platform:'OS X 10.9'}); + exports.saucelabs_ipad6_1 = sauceItUp({browserName: 'ipad', version: '6.1', platform:'OS X 10.8'}); + exports.saucelabs_ipad6 = sauceItUp({browserName: 'ipad', version: '6', platform:'OS X 10.8'}); + exports.saucelabs_ipad5_1 = sauceItUp({browserName: 'ipad', version: '5.1', platform:'OS X 10.8'}); + exports.saucelabs_ipad5 = sauceItUp({browserName: 'ipad', version: '5', platform:'OS X 10.6'}); + exports.saucelabs_ipad4 = sauceItUp({browserName: 'ipad', version: '4', platform:'OS X 10.6'}); - exports.saucelabs_android = sauceItUp({ browserName: 'android', version: '4.0', platform:'Linux' }); - exports.saucelabs_android_tablet = sauceItUp({ browserName: 'android', version: '4.0', platform:'Linux', 'device-type':'tablet' }); + exports.saucelabs_android = sauceItUp({browserName: 'android', version: '4.0', platform:'Linux'}); + exports.saucelabs_android_tablet = sauceItUp({browserName: 'android', version: '4.0', platform:'Linux', 'device-type':'tablet'}); - exports.saucelabs_safari = sauceItUp({ browserName: 'safari' }); - exports.saucelabs_chrome = sauceItUp({ browserName: 'chrome' }); - exports.saucelabs_firefox = sauceItUp({ browserName: 'firefox' }); + exports.saucelabs_safari = sauceItUp({browserName: 'safari'}); + exports.saucelabs_chrome = sauceItUp({browserName: 'chrome'}); + exports.saucelabs_firefox = sauceItUp({browserName: 'firefox'}); exports.saucelabs_ie = - exports.saucelabs_ie8 = sauceItUp({ browserName: 'internet explorer', version: 8 }); - exports.saucelabs_ie9 = sauceItUp({ browserName: 'internet explorer', version: 9 }); - exports.saucelabs_ie10 = sauceItUp({ browserName: 'internet explorer', version: 10 }); - exports.saucelabs_ie11 = sauceItUp({ browserName: 'internet explorer', version: 11, platform:'Windows 8.1' }); + exports.saucelabs_ie8 = sauceItUp({browserName: 'internet explorer', version: 8}); + exports.saucelabs_ie9 = sauceItUp({browserName: 'internet explorer', version: 9}); + exports.saucelabs_ie10 = sauceItUp({browserName: 'internet explorer', version: 10}); + exports.saucelabs_ie11 = sauceItUp({browserName: 'internet explorer', version: 11, platform:'Windows 8.1'}); /*eslint-enable camelcase*/ function sauceItUp(desiredCapabilities) { diff --git a/grunt/tasks/npm.js b/grunt/tasks/npm.js index 202631778e477..af7b4070fda0d 100644 --- a/grunt/tasks/npm.js +++ b/grunt/tasks/npm.js @@ -59,7 +59,7 @@ module.exports = function() { 'install', '--production', tgz - ], { cwd: dir }, function() { + ], {cwd: dir}, function() { var nodePath = path.join(dir, 'node_modules'); var pkgDir = path.join(nodePath, pkg.name); var doneCount = 2; @@ -83,7 +83,7 @@ module.exports = function() { '/** @jsx React.DOM */
oyez
;' ) + ')' ], { - env: { NODE_PATH: nodePath } + env: {NODE_PATH: nodePath} }, function(result, code) { assert.ok(result.stdout.indexOf( 'React.DOM.div(null, \'oyez\');' diff --git a/grunt/tasks/release.js b/grunt/tasks/release.js index aeb725415b1a6..a144a1af8bdc1 100644 --- a/grunt/tasks/release.js +++ b/grunt/tasks/release.js @@ -30,7 +30,7 @@ function _gitCommitAndTag(cwd, commitMsg, tag, cb) { // `git add -u` to make sure we remove deleted files // `git commit -m {commitMsg}` // `git tag -a {tag}` - var opts = { cwd: cwd}; + var opts = {cwd: cwd}; var gitAddAll = { cmd: 'git', args: ['add', '*'], @@ -91,7 +91,7 @@ function bower() { // clean out the bower folder in case we're removing files var files = grunt.file.expand(BOWER_GLOB); files.forEach(function(file) { - grunt.file.delete(file, { force: true }); + grunt.file.delete(file, {force: true}); }); // Update bower package version and save the file back. @@ -113,7 +113,7 @@ function docs() { var files = grunt.file.expand(GH_PAGES_GLOB); files.forEach(function(file) { - grunt.file.delete(file, { force: true }); + grunt.file.delete(file, {force: true}); }); grunt.file.copy('build/react-' + VERSION + '.zip', 'docs/downloads/react-' + VERSION + '.zip'); @@ -123,7 +123,7 @@ function docs() { var rakeOpts = { cmd: 'rake', args: ['release'], - opts: { cwd: 'docs' } + opts: {cwd: 'docs'} }; grunt.util.spawn(rakeOpts, function() { // Commit the repo. We don't really care about tagging this. diff --git a/jest/ts-preprocessor.js b/jest/ts-preprocessor.js index cc9ede50f7268..7a503c9d85cff 100644 --- a/jest/ts-preprocessor.js +++ b/jest/ts-preprocessor.js @@ -4,7 +4,7 @@ var fs = require('fs'); var path = require('path'); var ts = require('typescript'); -var tsOptions = { module: 'commonjs' }; +var tsOptions = {module: 'commonjs'}; function formatErrorMessage(error) { return ( diff --git a/perf/lib/BrowserPerfRunnerApp.react.js b/perf/lib/BrowserPerfRunnerApp.react.js index e6d83e224f453..5579fe749cffe 100644 --- a/perf/lib/BrowserPerfRunnerApp.react.js +++ b/perf/lib/BrowserPerfRunnerApp.react.js @@ -164,7 +164,7 @@ BrowserPerfRunnerApp.renderBenchmarkCell = function(props, row, col) { return ( React.DOM.td({key:key, style:{textAlign:'center', width:234, verticalAlign:'top'}}, benchmark.error && benchmark.error.message || '', - React.DOM.div({style: benchmark.isTheWinner ? { backgroundColor:'#0A5', color:'#AFA' } : {backgroundColor:'transparent', color:'inherit'}}, + React.DOM.div({style: benchmark.isTheWinner ? {backgroundColor:'#0A5', color:'#AFA'} : {backgroundColor:'transparent', color:'inherit'}}, Math.round(1 / benchmark.stats.mean * 100) / 100, ' op/s ', React.DOM.strong(null, Math.round(benchmark.stats.mean * 1000 * 100) / 100, ' ms/op '), React.DOM.small(null, '(±' + (Math.round(benchmark.stats.rme * 10) / 10) + '%)') @@ -198,7 +198,7 @@ var GridViewTable = React.createClass({ }, _renderCell: function(col) { - return this.props.renderCell({ value:this.props.value }, this._row, col); + return this.props.renderCell({value:this.props.value}, this._row, col); }, _renderRow: function(row) { diff --git a/perf/lib/BrowserPerfRunnerContext.react.js b/perf/lib/BrowserPerfRunnerContext.react.js index 48e8df7d16883..042dfc8e2d54a 100644 --- a/perf/lib/BrowserPerfRunnerContext.react.js +++ b/perf/lib/BrowserPerfRunnerContext.react.js @@ -62,7 +62,7 @@ var BenchmarkQueue = React.createClass({ if (self.props.onCompleteEach) { self.props.onCompleteEach(queueItem); } - self.setState({ queue:queue }); + self.setState({queue:queue}); }); benchmark.run({async:true}); }, diff --git a/perf/lib/todolist.browser.js b/perf/lib/todolist.browser.js index dd7d86a9dafdc..ccb6fb3bc24a7 100644 --- a/perf/lib/todolist.browser.js +++ b/perf/lib/todolist.browser.js @@ -50,7 +50,7 @@ todolist.App = React.createClass({ if (callback) { callback = callback.bind(this, todo); } - this.setState({ timerEvent:'addItem', timerStart:todolist.now(), timerEnd:null, todos:todos }, callback); + this.setState({timerEvent:'addItem', timerStart:todolist.now(), timerEnd:null, todos:todos}, callback); return todo; }, deleteItemById: function(id, callback) { @@ -59,7 +59,7 @@ todolist.App = React.createClass({ return callback && callback(Error('todo with id ' + id + ' not found')); } todo.deleted = true; - this.setState({ timerEvent:'deleteItemById', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos }, callback); + this.setState({timerEvent:'deleteItemById', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos}, callback); }, setItemCompleted: function(id, completed, callback) { var todo = this._getById(id); @@ -67,7 +67,7 @@ todolist.App = React.createClass({ return callback && callback(Error('todo with id ' + id + ' not found')); } todo.completed = completed; - this.setState({ timerEvent:'setItemCompleted', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos }, callback); + this.setState({timerEvent:'setItemCompleted', timerStart:todolist.now(), timerEnd:null, todos:this.state.todos}, callback); }, _getById: function(id) { id = +id; diff --git a/perf/tests/setState-callback-5.js b/perf/tests/setState-callback-5.js index 41670e0ce2661..a2316421230e9 100644 --- a/perf/tests/setState-callback-5.js +++ b/perf/tests/setState-callback-5.js @@ -15,7 +15,7 @@ exports.setup = function() { var AwesomeComponent = React.createClass({ getInitialState: function() { - return { random:null }; + return {random:null}; }, render: function() { if (!setState) { diff --git a/perf/tests/setState-callback.js b/perf/tests/setState-callback.js index fac49a99736b6..2597fe3178fc7 100644 --- a/perf/tests/setState-callback.js +++ b/perf/tests/setState-callback.js @@ -15,7 +15,7 @@ exports.setup = function() { var AwesomeComponent = React.createClass({ getInitialState: function() { - return { random:null }; + return {random:null}; }, render: function() { if (!setState) { diff --git a/perf/tests/todolist-add.js b/perf/tests/todolist-add.js index 2c84e4427e002..28de8a207228f 100644 --- a/perf/tests/todolist-add.js +++ b/perf/tests/todolist-add.js @@ -11,7 +11,7 @@ exports.defer = true; exports.setup = function() { _rootNode = document.createElement('div'); document.body.appendChild(_rootNode); - var appDescriptor = todolist.App({ fakeDataCount: 333 }); + var appDescriptor = todolist.App({fakeDataCount: 333}); _app = React.render(appDescriptor, _rootNode); }; exports.fn = function(deferred) { diff --git a/perf/tests/todolist-do-stuff.js b/perf/tests/todolist-do-stuff.js index 56cc749e142c2..b1c6483d21028 100644 --- a/perf/tests/todolist-do-stuff.js +++ b/perf/tests/todolist-do-stuff.js @@ -13,7 +13,7 @@ exports.defer = true; exports.setup = function() { _rootNode = document.createElement('div'); document.body.appendChild(_rootNode); - var appDescriptor = todolist.App({ fakeDataCount: 333 }); + var appDescriptor = todolist.App({fakeDataCount: 333}); _app = React.render(appDescriptor, _rootNode); }; diff --git a/perf/tests/todolist-edit.js b/perf/tests/todolist-edit.js index 9d313194275e2..7fe7f34b6ec82 100644 --- a/perf/tests/todolist-edit.js +++ b/perf/tests/todolist-edit.js @@ -11,7 +11,7 @@ exports.defer = true; exports.setup = function() { _rootNode = document.createElement('div'); document.body.appendChild(_rootNode); - var appDescriptor = todolist.App({ fakeDataCount: 333 }); + var appDescriptor = todolist.App({fakeDataCount: 333}); _app = React.render(appDescriptor, _rootNode); _todo1 = _app.addItem('Howdy 1!'); _todo2 = _app.addItem('Howdy 2!'); diff --git a/perf/tests/todolist-mount.js b/perf/tests/todolist-mount.js index 0fa7b2cafcaff..0347143b63f22 100644 --- a/perf/tests/todolist-mount.js +++ b/perf/tests/todolist-mount.js @@ -18,7 +18,7 @@ exports.setup = function() { }; exports.fn = function(deferred) { - React.render(todolist.App({ fakeDataCount: 333 }), _rootNode, function() { + React.render(todolist.App({fakeDataCount: 333}), _rootNode, function() { deferred.resolve(); }); }; diff --git a/src/addons/ReactFragment.js b/src/addons/ReactFragment.js index f811ee568aa8d..d674137fd413c 100644 --- a/src/addons/ReactFragment.js +++ b/src/addons/ReactFragment.js @@ -39,13 +39,13 @@ if (__DEV__) { Object.defineProperty( {}, fragmentKey, - { enumerable: false, value: true } + {enumerable: false, value: true} ); Object.defineProperty( {}, 'key', - { enumerable: true, get: dummy } + {enumerable: true, get: dummy} ); canWarnForReactFragment = true; diff --git a/src/browser/__tests__/ReactDOM-test.js b/src/browser/__tests__/ReactDOM-test.js index 0e0e5d4e85037..48d76bf661c6d 100644 --- a/src/browser/__tests__/ReactDOM-test.js +++ b/src/browser/__tests__/ReactDOM-test.js @@ -48,7 +48,7 @@ describe('ReactDOM', function() { */ it("allows a DOM element to be used with a string", function() { - var element = React.createElement('div', { className: 'foo' }); + var element = React.createElement('div', {className: 'foo'}); var instance = ReactTestUtils.renderIntoDocument(element); expect(instance.getDOMNode().tagName).toBe('DIV'); }); diff --git a/src/browser/ui/__tests__/ReactDOMComponent-test.js b/src/browser/ui/__tests__/ReactDOMComponent-test.js index 2e179c9d52c72..8b4a98eb07dac 100644 --- a/src/browser/ui/__tests__/ReactDOMComponent-test.js +++ b/src/browser/ui/__tests__/ReactDOMComponent-test.js @@ -45,14 +45,14 @@ describe('ReactDOMComponent', function() { var stubStyle = container.firstChild.style; // set initial style - var setup = { display: 'block', left: '1', top: 2, fontFamily: 'Arial' }; + var setup = {display: 'block', left: '1', top: 2, fontFamily: 'Arial'}; React.render(
, container); expect(stubStyle.display).toEqual('block'); expect(stubStyle.left).toEqual('1px'); expect(stubStyle.fontFamily).toEqual('Arial'); // reset the style to their default state - var reset = { display: '', left: null, top: false, fontFamily: true }; + var reset = {display: '', left: null, top: false, fontFamily: true}; React.render(
, container); expect(stubStyle.display).toEqual(''); expect(stubStyle.left).toEqual(''); @@ -61,7 +61,7 @@ describe('ReactDOMComponent', function() { }); it("should update styles when mutating style object", function() { - var styles = { display: 'none', fontFamily: 'Arial', lineHeight: 1.2 }; + var styles = {display: 'none', fontFamily: 'Arial', lineHeight: 1.2}; var container = document.createElement('div'); React.render(
, container); @@ -226,7 +226,7 @@ describe('ReactDOMComponent', function() { var ReactReconcileTransaction = require('ReactReconcileTransaction'); var NodeStub = function(initialProps) { - this._currentElement = { props: initialProps }; + this._currentElement = {props: initialProps}; this._rootNodeID = 'test'; }; assign(NodeStub.prototype, ReactDOMComponent.Mixin); @@ -250,9 +250,9 @@ describe('ReactDOMComponent', function() { }); it("should generate the correct markup with className", function() { - expect(genMarkup({ className: 'a' })).toHaveAttribute('class', 'a'); - expect(genMarkup({ className: 'a b' })).toHaveAttribute('class', 'a b'); - expect(genMarkup({ className: '' })).toHaveAttribute('class', ''); + expect(genMarkup({className: 'a'})).toHaveAttribute('class', 'a'); + expect(genMarkup({className: 'a b'})).toHaveAttribute('class', 'a b'); + expect(genMarkup({className: ''})).toHaveAttribute('class', ''); }); it("should escape style names and values", function() { @@ -276,7 +276,7 @@ describe('ReactDOMComponent', function() { var ReactReconcileTransaction = require('ReactReconcileTransaction'); var NodeStub = function(initialProps) { - this._currentElement = { props: initialProps }; + this._currentElement = {props: initialProps}; this._rootNodeID = 'test'; }; assign(NodeStub.prototype, ReactDOMComponent.Mixin); @@ -297,7 +297,7 @@ describe('ReactDOMComponent', function() { it("should handle dangerouslySetInnerHTML", function() { var innerHTML = {__html: 'testContent'}; expect( - genMarkup({ dangerouslySetInnerHTML: innerHTML }) + genMarkup({dangerouslySetInnerHTML: innerHTML}) ).toHaveInnerhtml('testContent'); }); }); @@ -332,7 +332,7 @@ describe('ReactDOMComponent', function() { it("should validate against multiple children props", function() { expect(function() { - mountComponent({ children: '', dangerouslySetInnerHTML: '' }); + mountComponent({children: '', dangerouslySetInnerHTML: ''}); }).toThrow( 'Invariant Violation: Can only set one of `children` or ' + '`props.dangerouslySetInnerHTML`.' @@ -342,7 +342,7 @@ describe('ReactDOMComponent', function() { it('should validate against use of innerHTML', function() { spyOn(console, 'warn'); - mountComponent({ innerHTML: 'Hi Jim!' }); + mountComponent({innerHTML: 'Hi Jim!'}); expect(console.warn.argsForCall.length).toBe(1); expect(console.warn.argsForCall[0][0]).toContain( 'Directly setting property `innerHTML` is not permitted. ' @@ -351,7 +351,7 @@ describe('ReactDOMComponent', function() { it('should validate use of dangerouslySetInnerHTML', function() { expect(function() { - mountComponent({ dangerouslySetInnerHTML: 'Hi Jim!' }); + mountComponent({dangerouslySetInnerHTML: 'Hi Jim!'}); }).toThrow( 'Invariant Violation: ' + '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + @@ -361,7 +361,7 @@ describe('ReactDOMComponent', function() { it('should validate use of dangerouslySetInnerHTML', function() { expect(function() { - mountComponent({ dangerouslySetInnerHTML: {foo: 'bar'} }); + mountComponent({dangerouslySetInnerHTML: {foo: 'bar'} }); }).toThrow( 'Invariant Violation: ' + '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + @@ -371,14 +371,14 @@ describe('ReactDOMComponent', function() { it("should warn about contentEditable and children", function() { spyOn(console, 'warn'); - mountComponent({ contentEditable: true, children: '' }); + mountComponent({contentEditable: true, children: ''}); expect(console.warn.argsForCall.length).toBe(1); expect(console.warn.argsForCall[0][0]).toContain('contentEditable'); }); it("should validate against invalid styles", function() { expect(function() { - mountComponent({ style: 'display: none' }); + mountComponent({style: 'display: none'}); }).toThrow( 'Invariant Violation: The `style` prop expects a mapping from style ' + 'properties to values, not a string. For example, ' + diff --git a/src/classic/class/__tests__/ReactBind-test.js b/src/classic/class/__tests__/ReactBind-test.js index 7e115ae2739cb..6cbd3ef571c10 100644 --- a/src/classic/class/__tests__/ReactBind-test.js +++ b/src/classic/class/__tests__/ReactBind-test.js @@ -149,10 +149,10 @@ describe('autobinding', function() { var TestBindComponent = React.createClass({ getInitialState: function() { - return { foo: 1 }; + return {foo: 1}; }, componentDidMount: function() { - this.setState({ foo: 2 }, this.handleUpdate); + this.setState({foo: 2}, this.handleUpdate); }, handleUpdate: function() { diff --git a/src/classic/class/__tests__/ReactClass-test.js b/src/classic/class/__tests__/ReactClass-test.js index cbc85528b402e..eefe02474fadc 100644 --- a/src/classic/class/__tests__/ReactClass-test.js +++ b/src/classic/class/__tests__/ReactClass-test.js @@ -305,7 +305,7 @@ describe('ReactClass-spec', function() { className: React.PropTypes.string }, getInitialState() { - return { className: this.context.className }; + return {className: this.context.className}; }, render() { return ; @@ -317,7 +317,7 @@ describe('ReactClass-spec', function() { className: React.PropTypes.string }, getChildContext() { - return { className: 'foo' }; + return {className: 'foo'}; }, render() { return ; diff --git a/src/classic/element/ReactElement.js b/src/classic/element/ReactElement.js index f15e2d36d4784..c582f95a6ac5c 100644 --- a/src/classic/element/ReactElement.js +++ b/src/classic/element/ReactElement.js @@ -108,7 +108,7 @@ var ReactElement = function(type, key, ref, owner, context, props) { // an external backing store so that we can freeze the whole object. // This can be replaced with a WeakMap once they are implemented in // commonly used development environments. - this._store = { props: props, originalProps: assign({}, props) }; + this._store = {props: props, originalProps: assign({}, props)}; // To make comparing ReactElements easier for testing purposes, we make // the validation flag non-enumerable (where possible, which should diff --git a/src/classic/element/__tests__/ReactElement-test.js b/src/classic/element/__tests__/ReactElement-test.js index 19a6b2c5993f6..579ec2c0819eb 100644 --- a/src/classic/element/__tests__/ReactElement-test.js +++ b/src/classic/element/__tests__/ReactElement-test.js @@ -56,7 +56,7 @@ describe('ReactElement', function() { }); it('does not reuse the original config object', function() { - var config = { foo: 1 }; + var config = {foo: 1}; var element = React.createFactory(ComponentClass)(config); expect(element.props.foo).toBe(1); config.foo = 2; @@ -95,7 +95,7 @@ describe('ReactElement', function() { foo: React.PropTypes.string }, getChildContext: function() { - return { foo: 'bar' }; + return {foo: 'bar'}; }, render: function() { element = Component(); @@ -107,7 +107,7 @@ describe('ReactElement', function() { React.createElement(Wrapper) ); - expect(element._context).toEqual({ foo: 'bar' }); + expect(element._context).toEqual({foo: 'bar'}); }); it('preserves the owner on the element', function() { @@ -222,7 +222,7 @@ describe('ReactElement', function() { }); it('is indistinguishable from a plain object', function() { - var element = React.createElement('div', { className: 'foo' }); + var element = React.createElement('div', {className: 'foo'}); var object = {}; expect(element.constructor).toBe(object.constructor); }); @@ -239,7 +239,7 @@ describe('ReactElement', function() { var container = document.createElement('div'); var instance = React.render( - React.createElement(Component, { fruit: 'mango' }), + React.createElement(Component, {fruit: 'mango'}), container ); expect(instance.props.fruit).toBe('mango'); @@ -264,7 +264,7 @@ describe('ReactElement', function() { expect(instance.props.prop).toBe('testKey'); var inst2 = ReactTestUtils.renderIntoDocument( - React.createElement(Component, { prop: null }) + React.createElement(Component, {prop: null}) ); expect(inst2.props.prop).toBe(null); }); diff --git a/src/classic/element/__tests__/ReactElementValidator-test.js b/src/classic/element/__tests__/ReactElementValidator-test.js index 2ee825da0c1e3..2794997c058b4 100644 --- a/src/classic/element/__tests__/ReactElementValidator-test.js +++ b/src/classic/element/__tests__/ReactElementValidator-test.js @@ -64,7 +64,7 @@ describe('ReactElementValidator', function() { var ComponentWrapper = React.createClass({ displayName: 'ComponentWrapper', render: function() { - return InnerComponent({ childSet: [ Component(), Component() ] }); + return InnerComponent({childSet: [ Component(), Component() ] }); } }); @@ -90,7 +90,7 @@ describe('ReactElementValidator', function() { return { next: function() { var done = ++i > 2; - return { value: done ? undefined : Component(), done: done }; + return {value: done ? undefined : Component(), done: done}; } }; } @@ -141,7 +141,7 @@ describe('ReactElementValidator', function() { spyOn(console, 'warn'); var Component = React.createFactory(ComponentClass); - Component(null, frag({ 1: Component(), 2: Component() })); + Component(null, frag({1: Component(), 2: Component()})); expect(console.warn.argsForCall.length).toBe(1); expect(console.warn.argsForCall[0][0]).toContain( @@ -159,7 +159,7 @@ describe('ReactElementValidator', function() { return { next: function() { var done = ++i > 2; - return { value: done ? undefined : [i, Component()], done: done }; + return {value: done ? undefined : [i, Component()], done: done}; } }; } @@ -207,7 +207,7 @@ describe('ReactElementValidator', function() { }); var ParentComp = React.createClass({ render: function() { - return React.createElement(MyComp, { color: 123 }); + return React.createElement(MyComp, {color: 123}); } }); ReactTestUtils.renderIntoDocument(React.createElement(ParentComp)); @@ -325,7 +325,7 @@ describe('ReactElementValidator', function() { it('should warn if a fragment is used without the wrapper', function() { spyOn(console, 'warn'); var child = React.createElement('span'); - React.createElement('div', null, { a: child, b: child }); + React.createElement('div', null, {a: child, b: child}); expect(console.warn.calls.length).toBe(1); expect(console.warn.calls[0].args[0]).toContain('use of a keyed object'); }); diff --git a/src/core/__tests__/ReactComponentLifeCycle-test.js b/src/core/__tests__/ReactComponentLifeCycle-test.js index c665a2f24bf11..9f8f14a585830 100644 --- a/src/core/__tests__/ReactComponentLifeCycle-test.js +++ b/src/core/__tests__/ReactComponentLifeCycle-test.js @@ -138,7 +138,7 @@ describe('ReactComponentLifeCycle', function() { var container = document.createElement('div'); var StatefulComponent = React.createClass({ getInitialState: function() { - return { }; + return {}; }, render: function() { return ( diff --git a/src/core/__tests__/ReactCompositeComponent-test.js b/src/core/__tests__/ReactCompositeComponent-test.js index adada42055a68..46bc8c79e0f56 100644 --- a/src/core/__tests__/ReactCompositeComponent-test.js +++ b/src/core/__tests__/ReactCompositeComponent-test.js @@ -303,7 +303,7 @@ describe('ReactCompositeComponent', function() { var Component = React.createClass({ getInitialState: function() { - return { value: 0 }; + return {value: 0}; }, render: function() { return
; @@ -314,12 +314,12 @@ describe('ReactCompositeComponent', function() { expect(instance.setState).not.toBeDefined(); instance = React.render(instance, container); - instance.setState({ value: 1 }); + instance.setState({value: 1}); expect(console.warn.calls.length).toBe(0); React.unmountComponentAtNode(container); - instance.setState({ value: 2 }); + instance.setState({value: 2}); expect(console.warn.calls.length).toBe(1); expect(console.warn.argsForCall[0][0]).toBe( 'Warning: setState(...): Can only update a mounted or ' + @@ -336,11 +336,11 @@ describe('ReactCompositeComponent', function() { var Component = React.createClass({ getInitialState: function() { - return { value: 0 }; + return {value: 0}; }, componentWillUnmount: function() { expect(() => { - this.setState({ value: 2 }, function() { + this.setState({value: 2}, function() { cbCalled = true; }) }).not.toThrow(); @@ -352,7 +352,7 @@ describe('ReactCompositeComponent', function() { var instance = React.render(, container); - instance.setState({ value: 1 }); + instance.setState({value: 1}); expect(console.warn.calls.length).toBe(0); React.unmountComponentAtNode(container); @@ -375,13 +375,13 @@ describe('ReactCompositeComponent', function() { instance = React.render(instance, container); expect(function() { - instance.setProps({ value: 1 }); + instance.setProps({value: 1}); }).not.toThrow(); expect(console.warn.calls.length).toBe(0); React.unmountComponentAtNode(container); expect(function() { - instance.setProps({ value: 2 }); + instance.setProps({value: 2}); }).not.toThrow(); expect(console.warn.calls.length).toBe(1); @@ -757,7 +757,7 @@ describe('ReactCompositeComponent', function() { }, getChildContext: function() { - return { foo: this.props.foo }; + return {foo: this.props.foo}; }, render: function() { return ; } @@ -878,11 +878,11 @@ describe('ReactCompositeComponent', function() { var renders = 0; var Component = React.createClass({ getInitialState: function() { - return { updated: false }; + return {updated: false}; }, componentWillReceiveProps: function(props) { expect(props.update).toBe(1); - this.setState({ updated: true }); + this.setState({updated: true}); }, render: function() { renders++; diff --git a/src/core/__tests__/ReactCompositeComponentNestedState-test.js b/src/core/__tests__/ReactCompositeComponentNestedState-test.js index 2a647a2ad87ec..f17cd4cb8899b 100644 --- a/src/core/__tests__/ReactCompositeComponentNestedState-test.js +++ b/src/core/__tests__/ReactCompositeComponentNestedState-test.js @@ -26,12 +26,12 @@ describe('ReactCompositeComponentNestedState-state', function() { it('should provide up to date values for props', function() { var ParentComponent = React.createClass({ getInitialState: function() { - return { color: 'blue' }; + return {color: 'blue'}; }, handleColor: function(color) { this.props.logger('parent-handleColor', this.state.color); - this.setState({ color: color }, function() { + this.setState({color: color}, function() { this.props.logger('parent-after-setState', this.state.color); }); }, @@ -49,7 +49,7 @@ describe('ReactCompositeComponentNestedState-state', function() { var ChildComponent = React.createClass({ getInitialState: function() { this.props.logger('getInitialState', this.props.color); - return { hue: 'dark ' + this.props.color }; + return {hue: 'dark ' + this.props.color}; }, handleHue: function(shade, color) { @@ -58,7 +58,7 @@ describe('ReactCompositeComponentNestedState-state', function() { this.setState(function(state, props) { this.props.logger('setState-this', this.state.hue, this.props.color); this.props.logger('setState-args', state.hue, props.color); - return { hue: shade + ' ' + props.color } + return {hue: shade + ' ' + props.color} }, function() { this.props.logger('after-setState', this.state.hue, this.props.color); }); diff --git a/src/core/__tests__/ReactCompositeComponentState-test.js b/src/core/__tests__/ReactCompositeComponentState-test.js index ed7e521c246d1..8120c74e60f22 100644 --- a/src/core/__tests__/ReactCompositeComponentState-test.js +++ b/src/core/__tests__/ReactCompositeComponentState-test.js @@ -94,7 +94,7 @@ describe('ReactCompositeComponent-state', function() { this.peekAtState('before-setState-receiveProps', state); return {color: newProps.nextColor}; }); - this.replaceState({ color: undefined }); + this.replaceState({color: undefined}); this.setState( function(state) { this.peekAtState('before-setState-again-receiveProps', state); diff --git a/src/core/__tests__/ReactIdentity-test.js b/src/core/__tests__/ReactIdentity-test.js index c93ecdd450532..52129e9ed9585 100644 --- a/src/core/__tests__/ReactIdentity-test.js +++ b/src/core/__tests__/ReactIdentity-test.js @@ -267,11 +267,11 @@ describe('ReactIdentity', function() { var TestContainer = React.createClass({ getInitialState: function() { - return { swapped: false }; + return {swapped: false}; }, swap: function() { - this.setState({ swapped: true }); + this.setState({swapped: true}); }, render: function() { diff --git a/src/core/__tests__/ReactInstanceHandles-test.js b/src/core/__tests__/ReactInstanceHandles-test.js index 4a1c02d37cb16..2ecf5edcaf95b 100644 --- a/src/core/__tests__/ReactInstanceHandles-test.js +++ b/src/core/__tests__/ReactInstanceHandles-test.js @@ -353,27 +353,27 @@ describe('ReactInstanceHandles', function() { var parent = renderParentIntoDocument(); var ancestors = [ // Common ancestor from window to deep element is ''. - { one: null, + {one: null, two: parent.refs.P_P1_C1.refs.DIV_1, com: null }, // Same as previous - reversed direction. - { one: parent.refs.P_P1_C1.refs.DIV_1, + {one: parent.refs.P_P1_C1.refs.DIV_1, two: null, com: null }, // Common ancestor from window to shallow id is ''. - { one: parent.refs.P, + {one: parent.refs.P, two: null, com: null }, // Common ancestor with self is self. - { one: parent.refs.P_P1_C1.refs.DIV_1, + {one: parent.refs.P_P1_C1.refs.DIV_1, two: parent.refs.P_P1_C1.refs.DIV_1, com: parent.refs.P_P1_C1.refs.DIV_1 }, // Common ancestor with self is self - even if topmost DOM. - { one: parent.refs.P, two: parent.refs.P, com: parent.refs.P }, + {one: parent.refs.P, two: parent.refs.P, com: parent.refs.P}, // Siblings { one: parent.refs.P_P1_C1.refs.DIV_1, diff --git a/src/core/__tests__/ReactMockedComponent-test.js b/src/core/__tests__/ReactMockedComponent-test.js index eb6ea4f78d523..2be35a14a3fb4 100644 --- a/src/core/__tests__/ReactMockedComponent-test.js +++ b/src/core/__tests__/ReactMockedComponent-test.js @@ -30,11 +30,11 @@ describe('ReactMockedComponent', function() { OriginalComponent = React.createClass({ getDefaultProps: function() { - return { bar: 'baz' }; + return {bar: 'baz'}; }, getInitialState: function() { - return { foo: 'bar' }; + return {foo: 'bar'}; }, hasCustomMethod: function() { @@ -65,11 +65,11 @@ describe('ReactMockedComponent', function() { var Wrapper = React.createClass({ getInitialState: function() { - return { foo: 1 }; + return {foo: 1}; }, update: function() { - this.setState({ foo: 2 }); + this.setState({foo: 2}); }, render: function() { @@ -105,11 +105,11 @@ describe('ReactMockedComponent', function() { var Wrapper = React.createClass({ getInitialState: function() { - return { foo: 1 }; + return {foo: 1}; }, update: function() { - this.setState({ foo: 2 }); + this.setState({foo: 2}); }, render: function() { diff --git a/src/core/__tests__/ReactMultiChildReconcile-test.js b/src/core/__tests__/ReactMultiChildReconcile-test.js index 135cacb14ae57..a8fca71d24c17 100644 --- a/src/core/__tests__/ReactMultiChildReconcile-test.js +++ b/src/core/__tests__/ReactMultiChildReconcile-test.js @@ -51,7 +51,7 @@ var getOriginalKey = function(childName) { */ var StatusDisplay = React.createClass({ getInitialState: function() { - return { internalState: Math.random() }; + return {internalState: Math.random()}; }, getStatus: function() { @@ -251,7 +251,7 @@ describe('ReactMultiChildReconcile', function() { var startingInternalState = statusDisplays.jcw.getInternalState(); // Now remove the child. - parentInstance.replaceProps({ usernameToStatus: {} }); + parentInstance.replaceProps({usernameToStatus: {} }); statusDisplays = parentInstance.getStatusDisplays(); expect(statusDisplays.jcw).toBeFalsy(); @@ -271,7 +271,7 @@ describe('ReactMultiChildReconcile', function() { bob: 'bobStatus' }; - testPropsSequence([ { usernameToStatus: usernameToStatus } ]); + testPropsSequence([ {usernameToStatus: usernameToStatus} ]); }); it('should preserve order if children order has not changed', function() { @@ -294,7 +294,7 @@ describe('ReactMultiChildReconcile', function() { it('should transition from zero to one children correctly', function() { var PROPS_SEQUENCE = [ - { usernameToStatus: {} }, + {usernameToStatus: {} }, { usernameToStatus: { first: 'firstStatus' @@ -311,7 +311,7 @@ describe('ReactMultiChildReconcile', function() { first: 'firstStatus' } }, - { usernameToStatus: {} } + {usernameToStatus: {} } ]; testPropsSequence(PROPS_SEQUENCE); }); @@ -323,13 +323,13 @@ describe('ReactMultiChildReconcile', function() { first: 'firstStatus' } }, - { } + {} ]); }); it('should transition from null children to one child', function() { testPropsSequence([ - { }, + {}, { usernameToStatus: { first: 'firstStatus' @@ -341,17 +341,17 @@ describe('ReactMultiChildReconcile', function() { it('should transition from zero children to null children', function() { testPropsSequence([ { - usernameToStatus: { } + usernameToStatus: {} }, - { } + {} ]); }); it('should transition from null children to zero children', function() { testPropsSequence([ - { }, + {}, { - usernameToStatus: { } + usernameToStatus: {} } ]); }); diff --git a/src/core/__tests__/ReactUpdates-test.js b/src/core/__tests__/ReactUpdates-test.js index 998059e9603ed..5056c2e904553 100644 --- a/src/core/__tests__/ReactUpdates-test.js +++ b/src/core/__tests__/ReactUpdates-test.js @@ -858,7 +858,7 @@ describe('ReactUpdates', function() { var B = React.createClass({ getInitialState: function() { - return { updates: 0 }; + return {updates: 0}; }, componentDidMount: function() { componentB = this; @@ -871,7 +871,7 @@ describe('ReactUpdates', function() { var A = React.createClass({ getInitialState: function() { - return { showB: true }; + return {showB: true}; }, render: function() { return this.state.showB ? :
; @@ -883,8 +883,8 @@ describe('ReactUpdates', function() { ReactUpdates.batchedUpdates(function() { // B will have scheduled an update but the batching should ensure that its // update never fires. - componentB.setState({ updates: 1 }); - component.setState({ showB: false }); + componentB.setState({updates: 1}); + component.setState({showB: false}); }); expect(renderCount).toBe(1); diff --git a/src/core/__tests__/refs-test.js b/src/core/__tests__/refs-test.js index e565d767aa7e7..e6731f5096b54 100644 --- a/src/core/__tests__/refs-test.js +++ b/src/core/__tests__/refs-test.js @@ -166,7 +166,7 @@ describe('ref swapping', function() { return {count: 0}; }, moveRef: function() { - this.setState({ count: this.state.count + 1 }); + this.setState({count: this.state.count + 1}); }, render: function() { var count = this.state.count; diff --git a/src/modern/class/__tests__/ReactES6Class-test.js b/src/modern/class/__tests__/ReactES6Class-test.js index 14bdf99a251d7..106d0d125e004 100644 --- a/src/modern/class/__tests__/ReactES6Class-test.js +++ b/src/modern/class/__tests__/ReactES6Class-test.js @@ -69,7 +69,7 @@ describe('ReactES6Class', function() { class Foo extends React.Component { constructor(props) { super(props); - this.state = { bar: this.props.initialValue }; + this.state = {bar: this.props.initialValue}; } render() { return ; @@ -81,10 +81,10 @@ describe('ReactES6Class', function() { it('renders based on state using props in the constructor', function() { class Foo extends React.Component { constructor(props) { - this.state = { bar: props.initialValue }; + this.state = {bar: props.initialValue}; } changeState() { - this.setState({ bar: 'bar' }); + this.setState({bar: 'bar'}); } render() { if (this.state.bar === 'foo') { @@ -102,7 +102,7 @@ describe('ReactES6Class', function() { class Foo extends React.Component { constructor(props, context) { super(props, context); - this.state = { tag: context.tag, className: this.context.className }; + this.state = {tag: context.tag, className: this.context.className}; } render() { var Tag = this.state.tag; @@ -116,7 +116,7 @@ describe('ReactES6Class', function() { class Outer extends React.Component { getChildContext() { - return { tag: 'span', className: 'foo' }; + return {tag: 'span', className: 'foo'}; } render() { return ; @@ -133,10 +133,10 @@ describe('ReactES6Class', function() { var renderCount = 0; class Foo extends React.Component { constructor(props) { - this.state = { bar: props.initialValue }; + this.state = {bar: props.initialValue}; } componentWillMount() { - this.setState({ bar: 'bar' }); + this.setState({bar: 'bar'}); } render() { renderCount++; @@ -179,10 +179,10 @@ describe('ReactES6Class', function() { it('setState through an event handler', function() { class Foo extends React.Component { constructor(props) { - this.state = { bar: props.initialValue }; + this.state = {bar: props.initialValue}; } handleClick() { - this.setState({ bar: 'bar' }); + this.setState({bar: 'bar'}); } render() { return ( @@ -201,10 +201,10 @@ describe('ReactES6Class', function() { it('should not implicitly bind event handlers', function() { class Foo extends React.Component { constructor(props) { - this.state = { bar: props.initialValue }; + this.state = {bar: props.initialValue}; } handleClick() { - this.setState({ bar: 'bar' }); + this.setState({bar: 'bar'}); } render() { return ( @@ -282,10 +282,10 @@ describe('ReactES6Class', function() { lifeCycles = []; // reset test(, 'SPAN', 'bar'); expect(lifeCycles).toEqual([ - 'receive-props', { value: 'bar' }, - 'should-update', { value: 'bar' }, {}, - 'will-update', { value: 'bar' }, {}, - 'did-update', { value: 'foo' }, {} + 'receive-props', {value: 'bar'}, + 'should-update', {value: 'bar'}, {}, + 'will-update', {value: 'bar'}, {}, + 'did-update', {value: 'foo'}, {} ]); lifeCycles = []; // reset React.unmountComponentAtNode(container); @@ -353,7 +353,7 @@ describe('ReactES6Class', function() { expect(() => instance.getDOMNode()).toThrow(); expect(() => instance.replaceState({})).toThrow(); expect(() => instance.isMounted()).toThrow(); - expect(() => instance.setProps({ name: 'bar' })).toThrow(); + expect(() => instance.setProps({name: 'bar'})).toThrow(); expect(console.warn.calls.length).toBe(4); expect(console.warn.calls[0].args[0]).toContain( 'getDOMNode(...) is deprecated in plain JavaScript React classes' @@ -375,16 +375,16 @@ describe('ReactES6Class', function() { return
; } } - Bar.contextTypes = { bar: React.PropTypes.string }; + Bar.contextTypes = {bar: React.PropTypes.string}; class Foo { getChildContext() { - return { bar: 'bar-through-context' }; + return {bar: 'bar-through-context'}; } render() { return ; } } - Foo.childContextTypes = { bar: React.PropTypes.string }; + Foo.childContextTypes = {bar: React.PropTypes.string}; test(, 'DIV', 'bar-through-context'); }); diff --git a/src/modern/element/__tests__/ReactJSXElement-test.js b/src/modern/element/__tests__/ReactJSXElement-test.js index 78ef617f291d9..edffa3243f320 100644 --- a/src/modern/element/__tests__/ReactJSXElement-test.js +++ b/src/modern/element/__tests__/ReactJSXElement-test.js @@ -62,7 +62,7 @@ describe('ReactJSXElement', function() { }); it('does not reuse the object that is spread into props', function() { - var config = { foo: 1 }; + var config = {foo: 1}; var element = ; expect(element.props.foo).toBe(1); config.foo = 2; @@ -161,7 +161,7 @@ describe('ReactJSXElement', function() { return ; } } - Component.defaultProps = { fruit: 'persimmon' }; + Component.defaultProps = {fruit: 'persimmon'}; var container = document.createElement('div'); var instance = React.render( @@ -180,7 +180,7 @@ describe('ReactJSXElement', function() { return {this.props.prop}; } } - Component.defaultProps = { prop: 'testKey' }; + Component.defaultProps = {prop: 'testKey'}; var instance = ReactTestUtils.renderIntoDocument(); expect(instance.props.prop).toBe('testKey'); diff --git a/src/modern/element/__tests__/ReactJSXElementValidator-test.js b/src/modern/element/__tests__/ReactJSXElementValidator-test.js index d664a24d27312..7eed4cbdafabd 100644 --- a/src/modern/element/__tests__/ReactJSXElementValidator-test.js +++ b/src/modern/element/__tests__/ReactJSXElementValidator-test.js @@ -86,7 +86,7 @@ describe('ReactJSXElementValidator', function() { return { next: function() { var done = ++i > 2; - return { value: done ? undefined : , done: done }; + return {value: done ? undefined : , done: done}; } }; } @@ -134,7 +134,7 @@ describe('ReactJSXElementValidator', function() { it('warns for numeric keys on objects as children', function() { spyOn(console, 'warn'); - {frag({ 1: , 2: })}; + {frag({1: , 2: })}; expect(console.warn.argsForCall.length).toBe(1); expect(console.warn.argsForCall[0][0]).toContain( @@ -151,7 +151,7 @@ describe('ReactJSXElementValidator', function() { return { next: function() { var done = ++i > 2; - return { value: done ? undefined : [i, ], done: done }; + return {value: done ? undefined : [i, ], done: done}; } }; } @@ -236,8 +236,8 @@ describe('ReactJSXElementValidator', function() { return {this.props.prop}; } } - Component.defaultProps = { prop: null }; - Component.propTypes = { prop: React.PropTypes.string.isRequired }; + Component.defaultProps = {prop: null}; + Component.propTypes = {prop: React.PropTypes.string.isRequired}; ReactTestUtils.renderIntoDocument(); @@ -256,8 +256,8 @@ describe('ReactJSXElementValidator', function() { return {this.props.prop}; } } - Component.defaultProps = { prop: 'text' }; - Component.propTypes = { prop: React.PropTypes.string.isRequired }; + Component.defaultProps = {prop: 'text'}; + Component.propTypes = {prop: React.PropTypes.string.isRequired}; ReactTestUtils.renderIntoDocument(); diff --git a/src/utils/__tests__/ReactChildren-test.js b/src/utils/__tests__/ReactChildren-test.js index aaf301a17b281..95b60a8460f1b 100644 --- a/src/utils/__tests__/ReactChildren-test.js +++ b/src/utils/__tests__/ReactChildren-test.js @@ -424,7 +424,7 @@ describe('ReactChildren', function() { it('should warn if a fragment is used without the wrapper', function() { spyOn(console, 'warn'); var child = React.createElement('span'); - ReactChildren.forEach({ a: child, b: child}, function(c) { + ReactChildren.forEach({a: child, b: child}, function(c) { expect(c).toBe(child); }); expect(console.warn.calls.length).toBe(1); diff --git a/src/utils/__tests__/traverseAllChildren-test.js b/src/utils/__tests__/traverseAllChildren-test.js index 0d940c062fc5f..ce92d42dde0d3 100644 --- a/src/utils/__tests__/traverseAllChildren-test.js +++ b/src/utils/__tests__/traverseAllChildren-test.js @@ -300,9 +300,9 @@ describe('traverseAllChildren', function() { return { next: function() { if (i++ < 3) { - return { value:
, done: false }; + return {value:
, done: false}; } else { - return { value: undefined, done: true }; + return {value: undefined, done: true}; } } }; @@ -351,9 +351,9 @@ describe('traverseAllChildren', function() { return { next: function() { if (i++ < 3) { - return { value:
, done: false }; + return {value:
, done: false}; } else { - return { value: undefined, done: true }; + return {value: undefined, done: true}; } } }; @@ -404,9 +404,9 @@ describe('traverseAllChildren', function() { return { next: function() { if (i++ < 3) { - return { value: ['#' + i,
], done: false }; + return {value: ['#' + i,
], done: false}; } else { - return { value: undefined, done: true }; + return {value: undefined, done: true}; } } }; diff --git a/src/vendor/key-mirror/__tests__/keyMirror-test.js b/src/vendor/key-mirror/__tests__/keyMirror-test.js index 994341fbace5e..425081e7750dd 100644 --- a/src/vendor/key-mirror/__tests__/keyMirror-test.js +++ b/src/vendor/key-mirror/__tests__/keyMirror-test.js @@ -20,7 +20,7 @@ describe('keyMirror', function() { var mirror = keyMirror({ foo: null, bar: true, - "baz": { some: "object" }, + "baz": {some: "object"}, qux: undefined }); expect('foo' in mirror).toBe(true); @@ -55,7 +55,7 @@ describe('keyMirror', function() { }); it('should work when "constructor" is a key', function() { - var obj = { constructor: true }; + var obj = {constructor: true}; expect(keyMirror.bind(null, obj)).not.toThrow(); var mirror = keyMirror(obj); expect('constructor' in mirror).toBe(true); diff --git a/vendor/fbtransform/transforms/__tests__/react-test.js b/vendor/fbtransform/transforms/__tests__/react-test.js index 67455bbf1a302..fdd26cd7ce535 100644 --- a/vendor/fbtransform/transforms/__tests__/react-test.js +++ b/vendor/fbtransform/transforms/__tests__/react-test.js @@ -350,13 +350,13 @@ describe('react jsx', function() { it('calls assign with an empty object when the spread is first', function() { expectObjectAssign( '' - ).toBeCalledWith({}, x, { y: 2 }); + ).toBeCalledWith({}, x, {y: 2}); }); it('coalesces consecutive properties into a single object', function() { expectObjectAssign( '' - ).toBeCalledWith({}, x, { y: 2, z: true }); + ).toBeCalledWith({}, x, {y: 2, z: true}); }); it('avoids an unnecessary empty object when spread is not first', function() { @@ -374,7 +374,7 @@ describe('react jsx', function() { it('evaluates sequences before passing them to React.__spread', function() { expectObjectAssign( 'Text' - ).toBeCalledWith({x: "1"}, { y: 2 }, {z: 3}); + ).toBeCalledWith({x: "1"}, {y: 2}, {z: 3}); }); }); From eba5d1365c106261a85c806bd8a93b22bd8dafac Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Thu, 19 Feb 2015 00:13:36 -0500 Subject: [PATCH 2/2] lint: remove spaces from array brackets --- .../__tests__/ReactElementValidator-test.js | 6 +- .../__tests__/ReactComponentLifeCycle-test.js | 4 +- ...ReactCompositeComponentNestedState-test.js | 22 ++--- .../ReactCompositeComponentState-test.js | 94 +++++++++---------- .../ReactJSXElementValidator-test.js | 4 +- src/utils/__tests__/ReactChildren-test.js | 4 +- 6 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/classic/element/__tests__/ReactElementValidator-test.js b/src/classic/element/__tests__/ReactElementValidator-test.js index 2794997c058b4..9555335c48d83 100644 --- a/src/classic/element/__tests__/ReactElementValidator-test.js +++ b/src/classic/element/__tests__/ReactElementValidator-test.js @@ -40,7 +40,7 @@ describe('ReactElementValidator', function() { spyOn(console, 'warn'); var Component = React.createFactory(ComponentClass); - Component(null, [ Component(), Component() ]); + Component(null, [Component(), Component()]); expect(console.warn.argsForCall.length).toBe(1); expect(console.warn.argsForCall[0][0]).toContain( @@ -64,7 +64,7 @@ describe('ReactElementValidator', function() { var ComponentWrapper = React.createClass({ displayName: 'ComponentWrapper', render: function() { - return InnerComponent({childSet: [ Component(), Component() ] }); + return InnerComponent({childSet: [Component(), Component()] }); } }); @@ -108,7 +108,7 @@ describe('ReactElementValidator', function() { spyOn(console, 'warn'); var Component = React.createFactory(ComponentClass); - Component(null, [ Component({key: '#1'}), Component({key: '#2'}) ]); + Component(null, [Component({key: '#1'}), Component({key: '#2'})]); expect(console.warn.argsForCall.length).toBe(0); }); diff --git a/src/core/__tests__/ReactComponentLifeCycle-test.js b/src/core/__tests__/ReactComponentLifeCycle-test.js index 9f8f14a585830..e522e8b69b3da 100644 --- a/src/core/__tests__/ReactComponentLifeCycle-test.js +++ b/src/core/__tests__/ReactComponentLifeCycle-test.js @@ -291,10 +291,10 @@ describe('ReactComponentLifeCycle', function() { spyOn(console, 'warn'); var Component = React.createClass({ getInitialState: function() { - return { isMounted: false }; + return {isMounted: false}; }, componentDidMount: function() { - this.setState({ isMounted: true }); + this.setState({isMounted: true}); }, render: function() { if (this.state.isMounted) { diff --git a/src/core/__tests__/ReactCompositeComponentNestedState-test.js b/src/core/__tests__/ReactCompositeComponentNestedState-test.js index f17cd4cb8899b..eb1524faab82a 100644 --- a/src/core/__tests__/ReactCompositeComponentNestedState-test.js +++ b/src/core/__tests__/ReactCompositeComponentNestedState-test.js @@ -99,17 +99,17 @@ describe('ReactCompositeComponentNestedState-state', function() { ); expect(logger.mock.calls).toEqual([ - [ 'parent-render', 'blue' ], - [ 'getInitialState', 'blue' ], - [ 'render', 'dark blue', 'blue' ], - [ 'handleHue', 'dark blue', 'blue' ], - [ 'parent-handleColor', 'blue' ], - [ 'parent-render', 'green' ], - [ 'setState-this', 'dark blue', 'blue' ], - [ 'setState-args', 'dark blue', 'green' ], - [ 'render', 'light green', 'green' ], - [ 'parent-after-setState', 'green' ], - [ 'after-setState', 'light green', 'green' ] + ['parent-render', 'blue'], + ['getInitialState', 'blue'], + ['render', 'dark blue', 'blue'], + ['handleHue', 'dark blue', 'blue'], + ['parent-handleColor', 'blue'], + ['parent-render', 'green'], + ['setState-this', 'dark blue', 'blue'], + ['setState-args', 'dark blue', 'green'], + ['render', 'light green', 'green'], + ['parent-after-setState', 'green'], + ['after-setState', 'light green', 'green'] ]); }); }); diff --git a/src/core/__tests__/ReactCompositeComponentState-test.js b/src/core/__tests__/ReactCompositeComponentState-test.js index 8120c74e60f22..4f6a1e2da73d1 100644 --- a/src/core/__tests__/ReactCompositeComponentState-test.js +++ b/src/core/__tests__/ReactCompositeComponentState-test.js @@ -155,67 +155,67 @@ describe('ReactCompositeComponent-state', function() { expect(stateListener.mock.calls).toEqual([ // there is no state when getInitialState() is called - [ 'getInitialState', null ], - [ 'componentWillMount-start', 'red' ], + ['getInitialState', null], + ['componentWillMount-start', 'red'], // setState()'s only enqueue pending states. - [ 'componentWillMount-after-sunrise', 'red' ], - [ 'componentWillMount-end', 'red' ], + ['componentWillMount-after-sunrise', 'red'], + ['componentWillMount-end', 'red'], // pending state queue is processed - [ 'before-setState-sunrise', 'red' ], - [ 'after-setState-sunrise', 'sunrise' ], - [ 'after-setState-orange', 'orange' ], + ['before-setState-sunrise', 'red'], + ['after-setState-sunrise', 'sunrise'], + ['after-setState-orange', 'orange'], // pending state has been applied - [ 'render', 'orange' ], - [ 'componentDidMount-start', 'orange' ], + ['render', 'orange'], + ['componentDidMount-start', 'orange'], // setState-sunrise and setState-orange should be called here, // after the bug in #1740 // componentDidMount() called setState({color:'yellow'}), which is async. // The update doesn't happen until the next flush. - [ 'componentDidMount-end', 'orange' ], - [ 'shouldComponentUpdate-currentState', 'orange' ], - [ 'shouldComponentUpdate-nextState', 'yellow' ], - [ 'componentWillUpdate-currentState', 'orange' ], - [ 'componentWillUpdate-nextState', 'yellow' ], - [ 'render', 'yellow' ], - [ 'componentDidUpdate-currentState', 'yellow' ], - [ 'componentDidUpdate-prevState', 'orange' ], - [ 'setState-yellow', 'yellow' ], - [ 'initial-callback', 'yellow' ], - [ 'componentWillReceiveProps-start', 'yellow' ], + ['componentDidMount-end', 'orange'], + ['shouldComponentUpdate-currentState', 'orange'], + ['shouldComponentUpdate-nextState', 'yellow'], + ['componentWillUpdate-currentState', 'orange'], + ['componentWillUpdate-nextState', 'yellow'], + ['render', 'yellow'], + ['componentDidUpdate-currentState', 'yellow'], + ['componentDidUpdate-prevState', 'orange'], + ['setState-yellow', 'yellow'], + ['initial-callback', 'yellow'], + ['componentWillReceiveProps-start', 'yellow'], // setState({color:'green'}) only enqueues a pending state. - [ 'componentWillReceiveProps-end', 'yellow' ], + ['componentWillReceiveProps-end', 'yellow'], // pending state queue is processed // before-setState-receiveProps never called, due to replaceState. - [ 'before-setState-again-receiveProps', undefined ], - [ 'after-setState-receiveProps', 'green' ], - [ 'shouldComponentUpdate-currentState', 'yellow' ], - [ 'shouldComponentUpdate-nextState', 'green' ], - [ 'componentWillUpdate-currentState', 'yellow' ], - [ 'componentWillUpdate-nextState', 'green' ], - [ 'render', 'green' ], - [ 'componentDidUpdate-currentState', 'green' ], - [ 'componentDidUpdate-prevState', 'yellow' ], - [ 'setState-receiveProps', 'green' ], - [ 'setProps', 'green' ], + ['before-setState-again-receiveProps', undefined], + ['after-setState-receiveProps', 'green'], + ['shouldComponentUpdate-currentState', 'yellow'], + ['shouldComponentUpdate-nextState', 'green'], + ['componentWillUpdate-currentState', 'yellow'], + ['componentWillUpdate-nextState', 'green'], + ['render', 'green'], + ['componentDidUpdate-currentState', 'green'], + ['componentDidUpdate-prevState', 'yellow'], + ['setState-receiveProps', 'green'], + ['setProps', 'green'], // setFavoriteColor('blue') - [ 'shouldComponentUpdate-currentState', 'green' ], - [ 'shouldComponentUpdate-nextState', 'blue' ], - [ 'componentWillUpdate-currentState', 'green' ], - [ 'componentWillUpdate-nextState', 'blue' ], - [ 'render', 'blue' ], - [ 'componentDidUpdate-currentState', 'blue' ], - [ 'componentDidUpdate-prevState', 'green' ], - [ 'setFavoriteColor', 'blue' ], + ['shouldComponentUpdate-currentState', 'green'], + ['shouldComponentUpdate-nextState', 'blue'], + ['componentWillUpdate-currentState', 'green'], + ['componentWillUpdate-nextState', 'blue'], + ['render', 'blue'], + ['componentDidUpdate-currentState', 'blue'], + ['componentDidUpdate-prevState', 'green'], + ['setFavoriteColor', 'blue'], // forceUpdate() - [ 'componentWillUpdate-currentState', 'blue' ], - [ 'componentWillUpdate-nextState', 'blue' ], - [ 'render', 'blue' ], - [ 'componentDidUpdate-currentState', 'blue' ], - [ 'componentDidUpdate-prevState', 'blue' ], - [ 'forceUpdate', 'blue' ], + ['componentWillUpdate-currentState', 'blue'], + ['componentWillUpdate-nextState', 'blue'], + ['render', 'blue'], + ['componentDidUpdate-currentState', 'blue'], + ['componentDidUpdate-prevState', 'blue'], + ['forceUpdate', 'blue'], // unmountComponent() // state is available within `componentWillUnmount()` - [ 'componentWillUnmount', 'blue' ] + ['componentWillUnmount', 'blue'] ]); }); }); diff --git a/src/modern/element/__tests__/ReactJSXElementValidator-test.js b/src/modern/element/__tests__/ReactJSXElementValidator-test.js index 7eed4cbdafabd..f5d64bccf8745 100644 --- a/src/modern/element/__tests__/ReactJSXElementValidator-test.js +++ b/src/modern/element/__tests__/ReactJSXElementValidator-test.js @@ -61,7 +61,7 @@ describe('ReactJSXElementValidator', function() { render() { return ( , ]} + childSet={[, ]} /> ); } @@ -103,7 +103,7 @@ describe('ReactJSXElementValidator', function() { it('does not warns for arrays of elements with keys', function() { spyOn(console, 'warn'); - {[ , ]}; + {[, ]}; expect(console.warn.argsForCall.length).toBe(0); }); diff --git a/src/utils/__tests__/ReactChildren-test.js b/src/utils/__tests__/ReactChildren-test.js index 95b60a8460f1b..80d266f7748ec 100644 --- a/src/utils/__tests__/ReactChildren-test.js +++ b/src/utils/__tests__/ReactChildren-test.js @@ -434,7 +434,7 @@ describe('ReactChildren', function() { it('should warn if a fragment is accessed', function() { spyOn(console, 'warn'); var child = React.createElement('span'); - var frag = ReactChildren.map([ child, child ], function(c) { + var frag = ReactChildren.map([child, child], function(c) { return c; }); for (var key in frag) { @@ -444,7 +444,7 @@ describe('ReactChildren', function() { expect(console.warn.calls.length).toBe(1); expect(console.warn.calls[0].args[0]).toContain('is an opaque type'); - var frag2 = ReactChildren.map([ child, child ], function(c) { + var frag2 = ReactChildren.map([child, child], function(c) { return c; }); for (var key in frag2) {