From c67ee054e5d46ee2b79c1d94c3248f068c6a9130 Mon Sep 17 00:00:00 2001 From: Jacopo Tomasone Date: Fri, 24 Mar 2017 15:47:48 +0000 Subject: [PATCH] Framework: Upgrade ESLint computed-property-spacing to error (#11431) Remove `computed-property-spacing` rule --- client/components/drop-zone/test/index.jsx | 4 +- .../forms/counted-textarea/test/index.jsx | 26 ++--- .../forms/multi-checkbox/test/index.jsx | 22 ++-- client/components/forms/range/test/index.jsx | 4 +- .../components/site-users-fetcher/index.jsx | 4 +- client/components/theme/test/index.jsx | 12 +- .../plugins/after-the-deadline/core.js | 56 +++++----- .../plugins/after-the-deadline/plugin.js | 2 +- .../tinymce/plugins/insert-menu/plugin.jsx | 4 +- .../tinymce/plugins/wpcom-charmap/charmap.jsx | 6 +- .../tinymce/plugins/wpcom-view/plugin.js | 10 +- .../tinymce/plugins/wpeditimage/plugin.js | 46 ++++---- .../tinymce/plugins/wptextpattern/plugin.js | 6 +- client/devdocs/main.jsx | 2 +- .../lib/cart/store/test/fake-wpcom/index.js | 8 +- client/lib/credit-card-details/masking.js | 2 +- .../email-followers/test/lib/mock-actions.js | 6 +- client/lib/email-followers/test/store.js | 2 +- client/lib/embeds/store.js | 6 +- client/lib/followers/test/lib/mock-actions.js | 6 +- client/lib/followers/test/store.js | 2 +- client/lib/highlight/index.js | 2 +- client/lib/importer/common.js | 4 +- client/lib/keyboard-shortcuts/index.js | 8 +- client/lib/keyboard-shortcuts/menu.jsx | 4 +- client/lib/load-script/index.js | 2 +- client/lib/media/utils.js | 6 +- client/lib/menu-data/menu-data.js | 20 ++-- client/lib/menu-data/test/menu-data.js | 104 +++++++++--------- client/lib/mixins/data-observe/test/index.js | 2 +- client/lib/mixins/render-visualizer/index.js | 2 +- client/lib/plugins/utils.js | 2 +- client/lib/post-metadata/index.js | 2 +- client/lib/posts/post-list-cache-store.js | 2 +- client/lib/posts/post-list-store.js | 4 +- client/lib/posts/utils.js | 2 +- client/lib/scroll-to/test/index.js | 8 +- client/lib/shortcode/index.js | 30 ++--- client/lib/sites-list/test/fixtures/data.js | 2 +- client/lib/tree-convert/index.js | 4 +- client/lib/tree-convert/test/index.js | 16 +-- client/lib/tree-convert/tree-traverser.js | 2 +- client/lib/users/test/fixtures/actions.js | 8 +- client/lib/users/test/store.js | 16 +-- client/lib/viewers/test/fixtures/actions.js | 4 +- client/lib/viewers/test/store.js | 2 +- client/lib/wporg/jsonp.js | 8 +- .../blogs-settings/index.jsx | 2 +- .../settings-form/device-selector.jsx | 2 +- .../settings-form/locales.js | 4 +- .../settings-form/stream-options.jsx | 2 +- client/my-sites/ads/form-earnings.jsx | 8 +- .../menus/item-options/test/posts.jsx | 2 +- client/my-sites/menus/menu-editable-item.jsx | 2 +- .../my-sites/menus/menu-item-drop-target.jsx | 2 +- .../plugins/plugin-remove-button/index.jsx | 3 +- .../sharing/buttons/preview-widget.js | 8 +- .../upgrades/checkout/privacy-protection.jsx | 2 +- client/post-editor/editor-revisions/index.jsx | 2 +- client/signup/utils.js | 4 +- client/state/application/reducer.js | 4 +- client/state/comments/test/actions.js | 10 +- client/state/comments/test/selectors.js | 4 +- client/state/comments/utils.js | 2 +- client/state/reader/posts/test/selectors.js | 2 +- 65 files changed, 283 insertions(+), 284 deletions(-) diff --git a/client/components/drop-zone/test/index.jsx b/client/components/drop-zone/test/index.jsx index 6653f88a63263..b11033752790e 100644 --- a/client/components/drop-zone/test/index.jsx +++ b/client/components/drop-zone/test/index.jsx @@ -168,7 +168,7 @@ describe( 'index', function() { window.dispatchEvent( dropEvent ); expect( spyDrop.calledOnce ).to.be.ok; - expect( spyDrop.getCall( 0 ).args[0] ).to.eql( dropEvent ); + expect( spyDrop.getCall( 0 ).args[ 0 ] ).to.eql( dropEvent ); } ); it( 'should call onFilesDrop with the files array when a drop occurs', function() { @@ -185,7 +185,7 @@ describe( 'index', function() { window.dispatchEvent( dropEvent ); expect( spyDrop.calledOnce ).to.be.ok; - expect( spyDrop.getCall( 0 ).args[0] ).to.eql( [ 1, 2, 3 ] ); + expect( spyDrop.getCall( 0 ).args[ 0 ] ).to.eql( [ 1, 2, 3 ] ); } ); it( 'should not call onFilesDrop if onVerifyValidTransfer returns false', function() { diff --git a/client/components/forms/counted-textarea/test/index.jsx b/client/components/forms/counted-textarea/test/index.jsx index 9dd8d2c2900b3..7f4ea84b56644 100644 --- a/client/components/forms/counted-textarea/test/index.jsx +++ b/client/components/forms/counted-textarea/test/index.jsx @@ -27,7 +27,7 @@ describe( 'index', function() { expect( result.props.className ).to.equal( 'counted-textarea' ); expect( result.props.children ).to.have.length( 2 ); - expect( result.props.children[1].props.children[0] ).to.equal( '12 characters' ); + expect( result.props.children[ 1 ].props.children[ 0 ] ).to.equal( '12 characters' ); } ); it( 'should render warning styles when the acceptable length is exceeded', function() { @@ -57,9 +57,9 @@ describe( 'index', function() { result = renderer.getRenderOutput(); expect( result.props.children ).to.have.length( 2 ); - expect( result.props.children[0].props.value ).to.equal( value ); - expect( result.props.children[0].props.placeholder ).to.equal( placeholder ); - expect( result.props.children[0].props.className ).to.equal( 'counted-textarea__input' ); + expect( result.props.children[ 0 ].props.value ).to.equal( value ); + expect( result.props.children[ 0 ].props.placeholder ).to.equal( placeholder ); + expect( result.props.children[ 0 ].props.className ).to.equal( 'counted-textarea__input' ); } ); it( 'should not use the placeholder as the counted item if value is empty and countPlaceholderLength is not set', function() { @@ -70,7 +70,7 @@ describe( 'index', function() { renderer.render( ); result = renderer.getRenderOutput(); - expect( result.props.children[1].props.children[0] ).to.equal( '0 characters' ); + expect( result.props.children[ 1 ].props.children[ 0 ] ).to.equal( '0 characters' ); } ); it( 'should use the placeholder as the counted item if value is empty and countPlaceholderLength is true', function() { @@ -81,7 +81,7 @@ describe( 'index', function() { renderer.render( ); result = renderer.getRenderOutput(); - expect( result.props.children[1].props.children[0] ).to.equal( '16 characters' ); + expect( result.props.children[ 1 ].props.children[ 0 ] ).to.equal( '16 characters' ); } ); it( 'should use the value as the counted item if value is set', function() { @@ -92,7 +92,7 @@ describe( 'index', function() { renderer.render( ); result = renderer.getRenderOutput(); - expect( result.props.children[1].props.children[0] ).to.equal( '12 characters' ); + expect( result.props.children[ 1 ].props.children[ 0 ] ).to.equal( '12 characters' ); } ); it( 'should not pass acceptableLength prop to the child textarea', function() { @@ -104,9 +104,9 @@ describe( 'index', function() { result = renderer.getRenderOutput(); expect( result.props.children ).to.have.length( 2 ); - expect( result.props.children[0].props.value ).to.equal( value ); - expect( result.props.children[0].props.acceptableLength ).to.be.undefined; - expect( result.props.children[0].props.className ).to.equal( 'counted-textarea__input' ); + expect( result.props.children[ 0 ].props.value ).to.equal( value ); + expect( result.props.children[ 0 ].props.acceptableLength ).to.be.undefined; + expect( result.props.children[ 0 ].props.className ).to.equal( 'counted-textarea__input' ); } ); it( 'should render a reversed count when set to showRemainingCount', function() { @@ -119,7 +119,7 @@ describe( 'index', function() { expect( result.props.className ).to.equal( 'counted-textarea' ); expect( result.props.children ).to.have.length( 2 ); - expect( result.props.children[1].props.children[0] ).to.equal( '128 characters remaining' ); + expect( result.props.children[ 1 ].props.children[ 0 ] ).to.equal( '128 characters remaining' ); } ); it( 'should render additional panel content when set', function() { @@ -133,7 +133,7 @@ describe( 'index', function() { expect( result.props.className ).to.equal( 'counted-textarea' ); expect( result.props.children ).to.have.length( 2 ); - expect( result.props.children[1].props.children[0] ).to.equal( '128 characters remaining' ); - expect( result.props.children[1].props.children[1][1] ).to.equal( 'Extra stuff' ); + expect( result.props.children[ 1 ].props.children[ 0 ] ).to.equal( '128 characters remaining' ); + expect( result.props.children[ 1 ].props.children[ 1 ][ 1 ] ).to.equal( 'Extra stuff' ); } ); } ); diff --git a/client/components/forms/multi-checkbox/test/index.jsx b/client/components/forms/multi-checkbox/test/index.jsx index 45405d7926e66..826e549a4a9d0 100644 --- a/client/components/forms/multi-checkbox/test/index.jsx +++ b/client/components/forms/multi-checkbox/test/index.jsx @@ -31,34 +31,34 @@ describe( 'index', function() { } ); it( 'should accept an array of checked values', function() { - var checkboxes = TestUtils.renderIntoDocument( ), + var checkboxes = TestUtils.renderIntoDocument( ), labels = TestUtils.scryRenderedDOMComponentsWithTag( checkboxes, 'label' ); - assert.equal( true, labels[0].querySelector( 'input' ).checked ); - assert.equal( false, labels[1].querySelector( 'input' ).checked ); + assert.equal( true, labels[ 0 ].querySelector( 'input' ).checked ); + assert.equal( false, labels[ 1 ].querySelector( 'input' ).checked ); } ); it( 'should accept an array of defaultChecked', function() { - var checkboxes = TestUtils.renderIntoDocument( ), + var checkboxes = TestUtils.renderIntoDocument( ), labels = TestUtils.scryRenderedDOMComponentsWithTag( checkboxes, 'label' ); - assert.equal( true, labels[0].querySelector( 'input' ).checked ); - assert.equal( false, labels[1].querySelector( 'input' ).checked ); + assert.equal( true, labels[ 0 ].querySelector( 'input' ).checked ); + assert.equal( false, labels[ 1 ].querySelector( 'input' ).checked ); } ); it( 'should accept an onChange event handler', function( done ) { var checkboxes = TestUtils.renderIntoDocument( ), labels = TestUtils.scryRenderedDOMComponentsWithTag( checkboxes, 'label' ); - TestUtils.Simulate.change( labels[0].querySelector( 'input' ), { + TestUtils.Simulate.change( labels[ 0 ].querySelector( 'input' ), { target: { - value: options[0].value, + value: options[ 0 ].value, checked: true } } ); function finishTest( event ) { - assert.deepEqual( [ options[0].value ], event.value ); + assert.deepEqual( [ options[ 0 ].value ], event.value ); done(); } } ); @@ -67,8 +67,8 @@ describe( 'index', function() { var checkboxes = TestUtils.renderIntoDocument( ), labels = TestUtils.scryRenderedDOMComponentsWithTag( checkboxes, 'label' ); - assert.ok( labels[0].querySelector( 'input' ).disabled ); - assert.ok( labels[1].querySelector( 'input' ).disabled ); + assert.ok( labels[ 0 ].querySelector( 'input' ).disabled ); + assert.ok( labels[ 1 ].querySelector( 'input' ).disabled ); } ); it( 'should transfer props to the rendered element', function() { diff --git a/client/components/forms/range/test/index.jsx b/client/components/forms/range/test/index.jsx index 985f0f152d54c..1cb367dc25974 100644 --- a/client/components/forms/range/test/index.jsx +++ b/client/components/forms/range/test/index.jsx @@ -28,7 +28,7 @@ describe( 'index', function() { content = TestUtils.scryRenderedDOMComponentsWithClass( range, 'range__content' ); expect( content ).to.have.length( 1 ); - expect( content[0].getAttribute( 'class' ) ).to.contain( 'is-min' ); + expect( content[ 0 ].getAttribute( 'class' ) ).to.contain( 'is-min' ); } ); it( 'should render ending content if passed a `maxContent` prop', function() { @@ -41,7 +41,7 @@ describe( 'index', function() { content = TestUtils.scryRenderedDOMComponentsWithClass( range, 'range__content' ); expect( content ).to.have.length( 1 ); - expect( content[0].getAttribute( 'class' ) ).to.contain( 'is-max' ); + expect( content[ 0 ].getAttribute( 'class' ) ).to.contain( 'is-max' ); } ); it( 'should render a value label if passed a truthy `showValueLabel` prop', function() { diff --git a/client/components/site-users-fetcher/index.jsx b/client/components/site-users-fetcher/index.jsx index ed8ad4a351a34..4d6b71b1c430c 100644 --- a/client/components/site-users-fetcher/index.jsx +++ b/client/components/site-users-fetcher/index.jsx @@ -102,9 +102,9 @@ module.exports = React.createClass( { } return Object.assign( {}, paginationData, { - users: this.props.exclude ? users[0] : users, + users: this.props.exclude ? users[ 0 ] : users, fetchOptions: fetchOptions, - excludedUsers: this.props.exclude ? users[1] : [] + excludedUsers: this.props.exclude ? users[ 1 ] : [] } ); }, diff --git a/client/components/theme/test/index.jsx b/client/components/theme/test/index.jsx index 6a211f40cb1ea..d9aeceb195020 100644 --- a/client/components/theme/test/index.jsx +++ b/client/components/theme/test/index.jsx @@ -61,16 +61,16 @@ describe( 'Theme', function() { assert( this.themeNode.nodeName === 'DIV', 'nodeName doesn\'t equal "DIV"' ); assert.include( this.themeNode.className, 'theme is-actionable', 'className does not contain "theme is-actionable"' ); - assert( this.themeNode.getElementsByTagName( 'h2' )[0].textContent === 'Theme name' ); + assert( this.themeNode.getElementsByTagName( 'h2' )[ 0 ].textContent === 'Theme name' ); } ); it( 'should render a screenshot', function() { - var imgNode = this.themeNode.getElementsByTagName( 'img' )[0]; + var imgNode = this.themeNode.getElementsByTagName( 'img' )[ 0 ]; assert.include( imgNode.getAttribute( 'src' ), '/theme/screenshot.png' ); } ); it( 'should call onScreenshotClick() on click on screenshot', function() { - var imgNode = this.themeNode.getElementsByTagName( 'img' )[0]; + var imgNode = this.themeNode.getElementsByTagName( 'img' )[ 0 ]; TestUtils.Simulate.click( imgNode ); assert( this.props.onScreenshotClick.calledOnce, 'onClick did not trigger onScreenshotClick' ); } ); @@ -83,8 +83,8 @@ describe( 'Theme', function() { var more = this.themeNode.getElementsByClassName( 'theme__more-button' ); assert( more.length === 1, 'More button container not found' ); - assert( more[0].getElementsByTagName( 'button' ).length === 1, 'More button not found' ); - TestUtils.Simulate.click( more[0].getElementsByTagName( 'button' )[0] ); + assert( more[ 0 ].getElementsByTagName( 'button' ).length === 1, 'More button not found' ); + TestUtils.Simulate.click( more[ 0 ].getElementsByTagName( 'button' )[ 0 ] ); assert( togglePopoverStub.calledOnce, 'More button press does not trigger state toggle' ); } ); } ); @@ -128,7 +128,7 @@ describe( 'Theme', function() { } ); it( 'should show a price', function() { - assert( this.themeNode.getElementsByClassName( 'theme-badge__price' )[0].textContent === '$50' ); + assert( this.themeNode.getElementsByClassName( 'theme-badge__price' )[ 0 ].textContent === '$50' ); } ); } ); } ); diff --git a/client/components/tinymce/plugins/after-the-deadline/core.js b/client/components/tinymce/plugins/after-the-deadline/core.js index 85af3cbafd16d..1ad71b05c9238 100644 --- a/client/components/tinymce/plugins/after-the-deadline/core.js +++ b/client/components/tinymce/plugins/after-the-deadline/core.js @@ -47,18 +47,18 @@ AtDCore.prototype.showTypes = function( strings ) { /* set some default types that we want to make optional */ /* grammar checker options */ - types['Double Negatives'] = 1; - types['Hidden Verbs'] = 1; - types['Passive voice'] = 1; - types['Bias Language'] = 1; + types[ 'Double Negatives' ] = 1; + types[ 'Hidden Verbs' ] = 1; + types[ 'Passive voice' ] = 1; + types[ 'Bias Language' ] = 1; /* style checker options */ - types['Cliches'] = 1; // eslint-disable-line dot-notation - types['Complex Expression'] = 1; - types['Diacritical Marks'] = 1; - types['Jargon Language'] = 1; - types['Phrases to Avoid'] = 1; - types['Redundant Expression'] = 1; + types[ 'Cliches' ] = 1; // eslint-disable-line dot-notation + types[ 'Complex Expression' ] = 1; + types[ 'Diacritical Marks' ] = 1; + types[ 'Jargon Language' ] = 1; + types[ 'Phrases to Avoid' ] = 1; + types[ 'Redundant Expression' ] = 1; this.map( show_types, function( type ) { types[ type ] = undefined; @@ -104,7 +104,7 @@ AtDCore.prototype.addToErrorStructure = function( errors, list, type, seps ) { this.map( list, function( error ) { var tokens = error.word.split( /\s+/ ); var pre = error.pre; - var first = tokens[0]; + var first = tokens[ 0 ]; if ( errors[ '__' + first ] === undefined ) { errors[ '__' + first ] = {}; @@ -155,7 +155,7 @@ AtDCore.prototype.processXML = function( responseXML ) { types = {}; this.map( this.ignore_types, function( type ) { - types[type] = 1; + types[ type ] = 1; } ); /* save suggestions in the editor object */ @@ -212,7 +212,7 @@ AtDCore.prototype.processXML = function( responseXML ) { suggestion.moreinfo = errorUrl + '&theme=tinymce'; } - if ( types[errorDescription] === undefined ) { + if ( types[ errorDescription ] === undefined ) { if ( errorType === 'suggestion' ) { enrichment.push( { word: errorString, pre: errorContext } ); } @@ -284,18 +284,18 @@ function TokenIterator( tokens ) { } TokenIterator.prototype.next = function() { - var current = this.tokens[this.index]; + var current = this.tokens[ this.index ]; this.count = this.last; this.last += current.length + 1; this.index++; /* strip single quotes from token, AtD does this when presenting errors */ if ( current !== '' ) { - if ( current[0] === '\'' ) { + if ( current[ 0 ] === '\'' ) { current = current.substring( 1, current.length ); } - if ( current[current.length - 1] === '\'' ) { + if ( current[ current.length - 1 ] === '\'' ) { current = current.substring( 0, current.length - 1 ); } } @@ -316,7 +316,7 @@ TokenIterator.prototype.skip = function( m, n ) { this.last += n; if ( this.index < this.tokens.length ) { - this.count = this.last - this.tokens[this.index].length; + this.count = this.last - this.tokens[ this.index ].length; } }; @@ -376,9 +376,9 @@ AtDCore.prototype.markMyWords = function( container_nodes, errors ) { } // capture the replacement of the matched string - captured.push( parent.create( match[0].replace( regexp, replacement ) ) ); + captured.push( parent.create( match[ 0 ].replace( regexp, replacement ) ) ); - cursor = index + match[0].length; + cursor = index + match[ 0 ].length; if ( cursor < text.length ) { // capture right text node @@ -414,11 +414,11 @@ AtDCore.prototype.markMyWords = function( container_nodes, errors ) { while ( iterator.hasNext() ) { token = iterator.next(); - current = errors['__' + token]; + current = errors[ '__' + token ]; if ( current !== undefined && current.pretoks !== undefined ) { defaults = current.defaults; - current = current.pretoks['__' + previous]; + current = current.pretoks[ '__' + previous ]; done = false; prev = v.substr( 0, iterator.getCount() ); @@ -453,8 +453,8 @@ AtDCore.prototype.markMyWords = function( container_nodes, errors ) { newNode = n; for ( x = 0; x < doReplaces.length; x++ ) { - regexp = doReplaces[x][0]; - result = doReplaces[x][1]; + regexp = doReplaces[ x ][ 0 ]; + result = doReplaces[ x ][ 1 ]; /* it's assumed that this function is only being called on text nodes (nodeType == 3), the iterating is necessary because eventually the whole thing gets wrapped in an mceItemHidden span and from there it's necessary to @@ -498,14 +498,14 @@ AtDCore.prototype.markMyWords = function( container_nodes, errors ) { contents = parent.contents( node ); for ( y = 0; y < contents.length; y++ ) { - if ( contents[y].nodeType === 3 && regexp.test( contents[y].nodeValue ) ) { - if ( parent.isIE() && contents[y].nodeValue.length > 0 && contents[y].nodeValue.substr( 0, 1 ) === ' ' ) { - nnode = parent.create( emptySpan + contents[y].nodeValue.substr( 1, contents[y].nodeValue.length - 1 ).replace( regexp, result ), true ); + if ( contents[ y ].nodeType === 3 && regexp.test( contents[ y ].nodeValue ) ) { + if ( parent.isIE() && contents[ y ].nodeValue.length > 0 && contents[ y ].nodeValue.substr( 0, 1 ) === ' ' ) { + nnode = parent.create( emptySpan + contents[ y ].nodeValue.substr( 1, contents[ y ].nodeValue.length - 1 ).replace( regexp, result ), true ); } else { - nnode = parent.create( contents[y].nodeValue.replace( regexp, result ), true ); + nnode = parent.create( contents[ y ].nodeValue.replace( regexp, result ), true ); } - parent.replaceWith( contents[y], nnode ); + parent.replaceWith( contents[ y ], nnode ); parent.removeParent( nnode ); ecount++; diff --git a/client/components/tinymce/plugins/after-the-deadline/plugin.js b/client/components/tinymce/plugins/after-the-deadline/plugin.js index 60d7c6139b0fa..71382494555ea 100644 --- a/client/components/tinymce/plugins/after-the-deadline/plugin.js +++ b/client/components/tinymce/plugins/after-the-deadline/plugin.js @@ -186,7 +186,7 @@ function plugin( editor ) { i = nodes.length; while ( i-- ) { // reversed - node = nodes[i]; + node = nodes[ i ]; if ( node.className && regex.test( node.className ) ) { editor.dom.remove( node, true ); diff --git a/client/components/tinymce/plugins/insert-menu/plugin.jsx b/client/components/tinymce/plugins/insert-menu/plugin.jsx index e276e6b9563ed..db80cae30145c 100644 --- a/client/components/tinymce/plugins/insert-menu/plugin.jsx +++ b/client/components/tinymce/plugins/insert-menu/plugin.jsx @@ -24,12 +24,12 @@ const initialize = editor => { type: 'splitbutton', title: i18n.translate( 'Insert content' ), classes: 'btn wpcom-insert-menu insert-menu', - cmd: menuItems[0].cmd, + cmd: menuItems[ 0 ].cmd, menu: menuItems.map( ( { name } ) => editor.menuItems[ name ] ), onPostRender() { ReactDOM.render( , - this.$el[0].children[0] + this.$el[ 0 ].children[ 0 ] ); } } ); diff --git a/client/components/tinymce/plugins/wpcom-charmap/charmap.jsx b/client/components/tinymce/plugins/wpcom-charmap/charmap.jsx index 1e0157b5849ff..ee93f2928483f 100644 --- a/client/components/tinymce/plugins/wpcom-charmap/charmap.jsx +++ b/client/components/tinymce/plugins/wpcom-charmap/charmap.jsx @@ -294,12 +294,12 @@ export default React.createClass( { renderCell( cell ) { return (
- { String.fromCharCode( parseInt( cell[0], 10 ) ) } + { String.fromCharCode( parseInt( cell[ 0 ], 10 ) ) }
); }, diff --git a/client/components/tinymce/plugins/wpcom-view/plugin.js b/client/components/tinymce/plugins/wpcom-view/plugin.js index b22a164de70f3..0dc108c2ffc2d 100644 --- a/client/components/tinymce/plugins/wpcom-view/plugin.js +++ b/client/components/tinymce/plugins/wpcom-view/plugin.js @@ -98,7 +98,7 @@ function wpview( editor ) { onResize: debounce( triggerNodeChanged, 500 ) } ) ), - $view.find( '.wpview-body' )[0] + $view.find( '.wpview-body' )[ 0 ] ); $view.attr( 'data-wpview-rendered', '' ); @@ -137,7 +137,7 @@ function wpview( editor ) { var location = before ? 'before' : 'after', offset = before ? 0 : 1; deselect(); - editor.selection.setCursorLocation( editor.dom.select( '.wpview-selection-' + location, view )[0], offset ); + editor.selection.setCursorLocation( editor.dom.select( '.wpview-selection-' + location, view )[ 0 ], offset ); editor.nodeChanged(); } @@ -169,7 +169,7 @@ function wpview( editor ) { function removeView( view ) { editor.undoManager.transact( function() { handleEnter( view ); - ReactDom.unmountComponentAtNode( $( view ).find( '.wpview-body' )[0] ); + ReactDom.unmountComponentAtNode( $( view ).find( '.wpview-body' )[ 0 ] ); editor.dom.remove( view ); editor.focus(); } ); @@ -200,7 +200,7 @@ function wpview( editor ) { contenteditable: 'true' }, getText( viewNode ) ); - editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard ); + editor.dom.select( '.wpview-body', viewNode )[ 0 ].appendChild( clipboard ); // Both of the following are necessary to prevent manipulating the selection/focus dom.bind( clipboard, 'beforedeactivate focusin focusout', _stop ); @@ -226,7 +226,7 @@ function wpview( editor ) { dom = editor.dom; if ( selected ) { - clipboard = editor.dom.select( '.wpview-clipboard', selected )[0]; + clipboard = editor.dom.select( '.wpview-clipboard', selected )[ 0 ]; dom.unbind( clipboard ); dom.remove( clipboard ); diff --git a/client/components/tinymce/plugins/wpeditimage/plugin.js b/client/components/tinymce/plugins/wpeditimage/plugin.js index d109db1d8f24c..c717bcfe8b5d0 100644 --- a/client/components/tinymce/plugins/wpeditimage/plugin.js +++ b/client/components/tinymce/plugins/wpeditimage/plugin.js @@ -106,46 +106,46 @@ function wpEditImage( editor ) { id = b.match( /id=['"]([^'"]*)['"] ?/ ); if ( id ) { - b = b.replace( id[0], '' ); + b = b.replace( id[ 0 ], '' ); } align = b.match( /align=['"]([^'"]*)['"] ?/ ); if ( align ) { - b = b.replace( align[0], '' ); + b = b.replace( align[ 0 ], '' ); } classes = b.match( /class=['"]([^'"]*)['"] ?/ ); if ( classes ) { - b = b.replace( classes[0], '' ); + b = b.replace( classes[ 0 ], '' ); } width = b.match( /width=['"]([0-9]*)['"] ?/ ); if ( width ) { - b = b.replace( width[0], '' ); + b = b.replace( width[ 0 ], '' ); } c = trim( c ); img = c.match( /((?:]+>)?]+>(?:<\/a>)?)([\s\S]*)/i ); - if ( img && img[2] ) { - caption = trim( img[2] ); - img = trim( img[1] ); + if ( img && img[ 2 ] ) { + caption = trim( img[ 2 ] ); + img = trim( img[ 1 ] ); } else { // old captions shortcode style caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' ); img = c; } - id = ( id && id[1] ) ? id[1].replace( /[<>&]+/g, '' ) : ''; - align = ( align && align[1] ) ? align[1] : 'alignnone'; - classes = ( classes && classes[1] ) ? ' ' + classes[1].replace( /[<>&]+/g, '' ) : ''; + id = ( id && id[ 1 ] ) ? id[ 1 ].replace( /[<>&]+/g, '' ) : ''; + align = ( align && align[ 1 ] ) ? align[ 1 ] : 'alignnone'; + classes = ( classes && classes[ 1 ] ) ? ' ' + classes[ 1 ].replace( /[<>&]+/g, '' ) : ''; if ( ! width && img ) { width = img.match( /width=['"]([0-9]*)['"]/ ); } - if ( width && width[1] ) { - width = width[1]; + if ( width && width[ 1 ] ) { + width = width[ 1 ]; } if ( ! width || ! caption ) { @@ -171,8 +171,8 @@ function wpEditImage( editor ) { // Try to return the caption text as a paragraph. out = b.match( /
]+>([\s\S]+?)<\/dd>/i ); - if ( out && out[1] ) { - return '

' + out[1] + '

'; + if ( out && out[ 1 ] ) { + return '

' + out[ 1 ] + '

'; } return ''; @@ -182,21 +182,21 @@ function wpEditImage( editor ) { var id, classes, align, width; width = c.match( /width="([0-9]*)"/ ); - width = ( width && width[1] ) ? width[1] : ''; + width = ( width && width[ 1 ] ) ? width[ 1 ] : ''; classes = b.match( /class="([^"]*)"/ ); - classes = ( classes && classes[1] ) ? classes[1] : ''; + classes = ( classes && classes[ 1 ] ) ? classes[ 1 ] : ''; align = classes.match( /align[a-z]+/i ) || 'alignnone'; if ( ! width || ! caption ) { - if ( 'alignnone' !== align[0] ) { - c = c.replace( />(.*?)<\/mark>/ ); if ( markMatch ) { - return {markMatch[1]}; + return { markMatch[ 1 ] }; } else { return part; } diff --git a/client/lib/cart/store/test/fake-wpcom/index.js b/client/lib/cart/store/test/fake-wpcom/index.js index 5f8d8857de730..a96abfefb6af2 100644 --- a/client/lib/cart/store/test/fake-wpcom/index.js +++ b/client/lib/cart/store/test/fake-wpcom/index.js @@ -10,20 +10,20 @@ function FakeWPCOM() { FakeWPCOM.prototype.cart = function() { var arrayArguments = toArray( arguments ), - method = arrayArguments[1]; + method = arrayArguments[ 1 ]; if ( method === 'POST' ) { this._requests.push( { isResolved: false, method: method, - cart: arrayArguments[2], - callback: arrayArguments[3] + cart: arrayArguments[ 2 ], + callback: arrayArguments[ 3 ] } ); } else { this._requests.push( { isResolved: false, method: method, - callback: arrayArguments[2] + callback: arrayArguments[ 2 ] } ); } }; diff --git a/client/lib/credit-card-details/masking.js b/client/lib/credit-card-details/masking.js index 2884572a0795c..68baa72665da0 100644 --- a/client/lib/credit-card-details/masking.js +++ b/client/lib/credit-card-details/masking.js @@ -5,7 +5,7 @@ var identity = require( 'lodash/identity' ); var fieldMasks = {}; -fieldMasks['expiration-date'] = { +fieldMasks[ 'expiration-date' ] = { mask: function( previousValue, nextValue ) { // If the user is deleting from the value then don't modify it if ( previousValue && previousValue.length > nextValue.length ) { diff --git a/client/lib/email-followers/test/lib/mock-actions.js b/client/lib/email-followers/test/lib/mock-actions.js index cb7f7a96dc787..57676573938ac 100644 --- a/client/lib/email-followers/test/lib/mock-actions.js +++ b/client/lib/email-followers/test/lib/mock-actions.js @@ -28,18 +28,18 @@ module.exports = { removeFollower: { type: 'REMOVE_EMAIL_FOLLOWER', siteId: site.ID, - follower: followerData.subscribers[0] + follower: followerData.subscribers[ 0 ] }, removeFollowerSuccess: { type: 'RECEIVE_REMOVE_EMAIL_FOLLOWER_SUCCESS', siteId: site.ID, - follower: followerData.subscribers[0] + follower: followerData.subscribers[ 0 ] }, removeFollowerError: { type: 'RECEIVE_REMOVE_EMAIL_FOLLOWER_ERROR', siteId: site.ID, - follower: followerData.subscribers[0] + follower: followerData.subscribers[ 0 ] } }; diff --git a/client/lib/email-followers/test/store.js b/client/lib/email-followers/test/store.js index abec937c2de14..9d1af896eb544 100644 --- a/client/lib/email-followers/test/store.js +++ b/client/lib/email-followers/test/store.js @@ -38,7 +38,7 @@ describe( 'Email Followers Store', function() { it( 'The store should return an array of objects when fetching email followers', function() { var followers = EmailFollowersStore.getFollowers( options ); assert.isArray( followers ); - assert.isObject( followers[0] ); + assert.isObject( followers[ 0 ] ); } ); it( 'Fetching more email followers should update the array in the store', function() { diff --git a/client/lib/embeds/store.js b/client/lib/embeds/store.js index 6f016bc093f7b..a00066a228493 100644 --- a/client/lib/embeds/store.js +++ b/client/lib/embeds/store.js @@ -28,7 +28,7 @@ class PostEditEmbedsStore extends ReduceStore { case 'FETCH_EMBED': state = Object.assign( {}, state, { - [action.url]: { + [ action.url ]: { status: 'LOADING' } } ); @@ -37,13 +37,13 @@ class PostEditEmbedsStore extends ReduceStore { case 'RECEIVE_EMBED': if ( action.error ) { state = Object.assign( {}, state, { - [action.url]: { + [ action.url ]: { status: 'ERROR' } } ); } else if ( action.data ) { state = Object.assign( {}, state, { - [action.url]: { + [ action.url ]: { status: 'LOADED', body: action.data.result, scripts: action.data.scripts, diff --git a/client/lib/followers/test/lib/mock-actions.js b/client/lib/followers/test/lib/mock-actions.js index c68a26fd7dee0..e5717de793b53 100644 --- a/client/lib/followers/test/lib/mock-actions.js +++ b/client/lib/followers/test/lib/mock-actions.js @@ -28,18 +28,18 @@ module.exports = { removeFollower: { type: 'REMOVE_FOLLOWER', siteId: site.ID, - follower: followerData.subscribers[0] + follower: followerData.subscribers[ 0 ] }, removeFollowerSuccess: { type: 'RECEIVE_REMOVE_FOLLOWER_SUCCESS', siteId: site.ID, - follower: followerData.subscribers[0] + follower: followerData.subscribers[ 0 ] }, removeFollowerError: { type: 'RECEIVE_REMOVE_FOLLOWER_ERROR', siteId: site.ID, - follower: followerData.subscribers[0] + follower: followerData.subscribers[ 0 ] } }; diff --git a/client/lib/followers/test/store.js b/client/lib/followers/test/store.js index fc09459bd77ee..bedac8784a545 100644 --- a/client/lib/followers/test/store.js +++ b/client/lib/followers/test/store.js @@ -38,7 +38,7 @@ describe( 'WPCOM Followers Store', function() { it( 'The store should return an array of objects when fetching followers', function() { var followers = FollowersStore.getFollowers( options ); assert.isArray( followers ); - assert.isObject( followers[0] ); + assert.isObject( followers[ 0 ] ); } ); it( 'Fetching more followers should update the array in the store', function() { diff --git a/client/lib/highlight/index.js b/client/lib/highlight/index.js index e5eef723c0b9a..af84e685045ec 100644 --- a/client/lib/highlight/index.js +++ b/client/lib/highlight/index.js @@ -73,7 +73,7 @@ function walk( node, term, wrapperNode ) { children = toArray( node.childNodes ); for ( var i = 0; i < children.length; i++ ) { - walk( children[i], term, wrapperNode ); + walk( children[ i ], term, wrapperNode ); } } else if ( node.nodeName === '#text' ) { diff --git a/client/lib/importer/common.js b/client/lib/importer/common.js index 12f87d23906b8..af9fc04e157a1 100644 --- a/client/lib/importer/common.js +++ b/client/lib/importer/common.js @@ -24,14 +24,14 @@ function apiToAppState( state ) { return find( importerStateMap, ( [ , api ] ) => api === state - )[0]; + )[ 0 ]; } function appStateToApi( state ) { return find( importerStateMap, ( [ appState ] ) => appState === state - )[1]; + )[ 1 ]; } function generateSourceAuthorIds( customData ) { diff --git a/client/lib/keyboard-shortcuts/index.js b/client/lib/keyboard-shortcuts/index.js index 6acf518a4227b..024d689448173 100644 --- a/client/lib/keyboard-shortcuts/index.js +++ b/client/lib/keyboard-shortcuts/index.js @@ -80,7 +80,7 @@ KeyboardShortcuts.prototype.bindShortcut = function( eventName, keys, type, chec keyCombinations = [], matches; - if ( typeof keys[0] === 'string' ) { + if ( typeof keys[ 0 ] === 'string' ) { // this is a single key combination keyCombinations = [ keys ]; } else { @@ -90,11 +90,11 @@ KeyboardShortcuts.prototype.bindShortcut = function( eventName, keys, type, chec keyCombinations.forEach( function( keys ) { if ( 'sequence' === type ) { - keymaster( keys[1], function( event, handler ) { - if ( self.lastKey === keys[0] && self.lastKeyTime > Date.now() - self.timeLimit ) { + keymaster( keys[ 1 ], function( event, handler ) { + if ( self.lastKey === keys[ 0 ] && self.lastKeyTime > Date.now() - self.timeLimit ) { self.emitEvent( eventName, event, handler ); - self.lastKey = keys[1]; + self.lastKey = keys[ 1 ]; self.lastKeyTime = Date.now(); // return false at the end of a sequence to prevent other shortcuts from firing diff --git a/client/lib/keyboard-shortcuts/menu.jsx b/client/lib/keyboard-shortcuts/menu.jsx index 28c75829bce5e..1517a56fc97f5 100644 --- a/client/lib/keyboard-shortcuts/menu.jsx +++ b/client/lib/keyboard-shortcuts/menu.jsx @@ -84,9 +84,9 @@ module.exports = React.createClass({ return shortcutsByCategory.map( function( category ) { var classes = {}; - classes['keyboard-shortcuts__category'] = true; + classes[ 'keyboard-shortcuts__category' ] = true; classes[ category.className ] = true; - classes['keyboard-shortcuts__category-disabled'] = category.disabled; + classes[ 'keyboard-shortcuts__category-disabled' ] = category.disabled; return (
  • diff --git a/client/lib/load-script/index.js b/client/lib/load-script/index.js index 4253ff0fbe8dc..374244e146294 100644 --- a/client/lib/load-script/index.js +++ b/client/lib/load-script/index.js @@ -46,7 +46,7 @@ var loadScript = function( url, callback ) { callbacksForURLsInProgress[ url ] = [ callback ]; script.onload = script.onreadystatechange = script.onerror = handleCompletedRequest; - document.getElementsByTagName( 'head' )[0].appendChild( script ); + document.getElementsByTagName( 'head' )[ 0 ].appendChild( script ); }; var loadjQueryDependentScript = function( scriptURL, callback ) { diff --git a/client/lib/media/utils.js b/client/lib/media/utils.js index d84529ff8fa95..531a5814a5534 100644 --- a/client/lib/media/utils.js +++ b/client/lib/media/utils.js @@ -141,7 +141,7 @@ const MediaUtils = { mimePrefixMatch = mimeType.match( /^([^\/]+)\// ); if ( mimePrefixMatch ) { - return mimePrefixMatch[1]; + return mimePrefixMatch[ 1 ]; } }, @@ -478,12 +478,12 @@ const MediaUtils = { if ( ! HTMLCanvasElement.prototype.toBlob ) { Object.defineProperty( HTMLCanvasElement.prototype, 'toBlob', { value: function( polyfillCallback, polyfillType, polyfillQuality ) { - const binStr = atob( this.toDataURL( polyfillType, polyfillQuality ).split( ',' )[1] ), + const binStr = atob( this.toDataURL( polyfillType, polyfillQuality ).split( ',' )[ 1 ] ), len = binStr.length, arr = new Uint8Array( len ); for ( let i = 0; i < len; i++ ) { - arr[i] = binStr.charCodeAt( i ); + arr[ i ] = binStr.charCodeAt( i ); } polyfillCallback( new Blob( [ arr ], { diff --git a/client/lib/menu-data/menu-data.js b/client/lib/menu-data/menu-data.js index 30c1b13951277..1e2aa83d3e380 100644 --- a/client/lib/menu-data/menu-data.js +++ b/client/lib/menu-data/menu-data.js @@ -325,12 +325,12 @@ MenuData.prototype.isValidMenu = function( menu ) { MenuData.prototype.getPrimaryLocation = function( ) { var primaryLocation; - if ( ! this.data.locations || ! this.data.locations[0] ) { + if ( ! this.data.locations || ! this.data.locations[ 0 ] ) { return false; } primaryLocation = find( this.data.locations, { name: 'primary' } ); - return ( primaryLocation || this.data.locations[0] ).name; + return ( primaryLocation || this.data.locations[ 0 ] ).name; }; MenuData.prototype.getMenu = function( locationName ) { @@ -494,7 +494,7 @@ MenuData.prototype.deleteMenu = function( menu, callback ) { menusBackup = this.data.menus.slice(); menuIndex = findIndex( this.data.menus, { id: menu.id } ); - this.deletedMenu = this.data.menus.splice( menuIndex, 1 )[0]; + this.deletedMenu = this.data.menus.splice( menuIndex, 1 )[ 0 ]; this.emit( 'change' ); this.emit( 'saving' ); @@ -634,7 +634,7 @@ MenuData.prototype.moveItem = function( sourceId, targetId, position ) { } // Traverse items tree to remove & reattach 'item' - this.data.menus[i] = Traverser.traverse( menu, [ + this.data.menus[ i ] = Traverser.traverse( menu, [ Traverser.remover( source.id ), Traverser.inserter( source, target.id, position ) ] ); @@ -696,7 +696,7 @@ MenuData.prototype.find = function( criterion, menus ) { menus = menus || this.data.menus; for ( i = 0; i < menus.length; i++ ) { - if ( result = Traverser.find( menus[i], predicate ) ) { // eslint-disable-line no-cond-assign + if ( result = Traverser.find( menus[ i ], predicate ) ) { // eslint-disable-line no-cond-assign return result; } } @@ -712,7 +712,7 @@ MenuData.prototype.replaceItem = function( criterion, newItem, menus ) { menus = menus || this.data.menus; for ( i = 0; i < menus.length; i++ ) { - Traverser.replaceItem( menus[i], newItem, predicate ); + Traverser.replaceItem( menus[ i ], newItem, predicate ); } }; @@ -799,7 +799,7 @@ MenuData.prototype.addItem = function( item, targetId, position, menuId ) { menu.items = [ item ]; } - this.data.menus[i] = menu; + this.data.menus[ i ] = menu; this.change(); return true; }, this ); @@ -860,7 +860,7 @@ MenuData.prototype._incrementMenuName = function( menus ) { menuNumbers = menus.concat( deletedMenus ).map( function( menu ) { var matches; if ( matches = menu.name.match( RegExp( '^' + menuString + ' (\\d+)$' ) ) ) { // eslint-disable-line no-cond-assign - return Number( matches[1] ); + return Number( matches[ 1 ] ); } return 0; } ); @@ -882,8 +882,8 @@ MenuData.prototype.isAncestor = function( ancestor, descendent ) { MenuData.prototype.replaceMenu = function( newMenu ) { this.data.menus.some( function( menu, i ) { if ( menu.id === newMenu.id ) { - this.data.menus[i] = newMenu; - debug( 'replaced menu', this.data.menus[i] ); + this.data.menus[ i ] = newMenu; + debug( 'replaced menu', this.data.menus[ i ] ); return true; } }, this ); diff --git a/client/lib/menu-data/test/menu-data.js b/client/lib/menu-data/test/menu-data.js index fa86736906070..f13a729a8c7e4 100644 --- a/client/lib/menu-data/test/menu-data.js +++ b/client/lib/menu-data/test/menu-data.js @@ -82,9 +82,9 @@ describe( 'MenuData', function() { menu = { items: [ item ] }, interceptedMenu = this.menuData.interceptSaveForHomepageLink( menu ); - expect( interceptedMenu.items[0].type ).to.equal( 'custom' ); - expect( interceptedMenu.items[0].type_family ).to.equal( 'custom' ); - expect( interceptedMenu.items[0].url ).to.equal( 'http://example.com/' ); + expect( interceptedMenu.items[ 0 ].type ).to.equal( 'custom' ); + expect( interceptedMenu.items[ 0 ].type_family ).to.equal( 'custom' ); + expect( interceptedMenu.items[ 0 ].url ).to.equal( 'http://example.com/' ); } ); } ); @@ -96,7 +96,7 @@ describe( 'MenuData', function() { } ); it( 'should convert the home link to page item', function () { var pageItemOriginal = this.menuData.generateHomePageMenuItem(), - interceptedItem = this.menuData.interceptLoadForHomepageLink( this.menu ).items[0]; + interceptedItem = this.menuData.interceptLoadForHomepageLink( this.menu ).items[ 0 ]; expect( interceptedItem.type ).to.equal( 'page' ); expect( interceptedItem.type_family ).to.equal( 'post_type' ); @@ -107,7 +107,7 @@ describe( 'MenuData', function() { it( 'should match home link ending without /', function () { var interceptedItem; this.menuItem.url = this.menuData.site.URL.replace( /\/$/, '' ); - interceptedItem = this.menuData.interceptLoadForHomepageLink( this.menu ).items[0]; + interceptedItem = this.menuData.interceptLoadForHomepageLink( this.menu ).items[ 0 ]; expect( interceptedItem.type ).to.equal( 'page' ); @@ -116,7 +116,7 @@ describe( 'MenuData', function() { it( 'should match home link ending with /', function () { var interceptedItem; this.menuItem.url = this.menuData.site.URL + '/'; - interceptedItem = this.menuData.interceptLoadForHomepageLink( this.menu ).items[0]; + interceptedItem = this.menuData.interceptLoadForHomepageLink( this.menu ).items[ 0 ]; expect( interceptedItem.type ).to.equal( 'page' ); @@ -150,12 +150,12 @@ describe( 'MenuData', function() { it ( 'should decode HTML entities', function() { this.menuData.fetch(); - assert( this.menuData.data.menus[1].name === 'Menu 2 &c.', 'Ampersand in menu name not decoded' ); - assert( this.menuData.data.menus[2].description === 'The third menu is dull & boring', 'Ampersand in menu description not decoded' ); - assert( this.menuData.data.menus[1].items[0].name === 'Item 21 & counting', 'Ampersand in menu item name not decoded' ); + assert( this.menuData.data.menus[ 1 ].name === 'Menu 2 &c.', 'Ampersand in menu name not decoded' ); + assert( this.menuData.data.menus[ 2 ].description === 'The third menu is dull & boring', 'Ampersand in menu description not decoded' ); + assert( this.menuData.data.menus[ 1 ].items[ 0 ].name === 'Item 21 & counting', 'Ampersand in menu item name not decoded' ); - assert( this.menuData.data.locations[2].name === 'social&lite', 'Ampersand in location name not decoded' ); - assert( this.menuData.data.locations[0].description === 'Top & Primary Menu', 'Ampersand in location description not decoded' ); + assert( this.menuData.data.locations[ 2 ].name === 'social&lite', 'Ampersand in location name not decoded' ); + assert( this.menuData.data.locations[ 0 ].description === 'Top & Primary Menu', 'Ampersand in location description not decoded' ); } ); } ); @@ -195,7 +195,7 @@ describe( 'MenuData', function() { // Update an item var menu = this.menuData.getMenu( 'primary' ), - item = menu.items[0]; + item = menu.items[ 0 ]; this.itemID = item.id; item.name = 'Homer'; @@ -217,14 +217,14 @@ describe( 'MenuData', function() { describe( 'moveItemsToParent', function() { it( 'should move one item to a different parent', function() { var menu = this.menuData.getMenu( 'primary' ), - itemToMove = menu.items[1].items[0].items[1].items[0], - itemToMoveTo = menu.items[1].items[1]; + itemToMove = menu.items[ 1 ].items[ 0 ].items[ 1 ].items[ 0 ], + itemToMoveTo = menu.items[ 1 ].items[ 1 ]; this.menuData.moveItemsToParent( itemToMove, itemToMoveTo ); menu = this.menuData.getMenu( 'primary' ); - expect( find( menu.items[1].items[1].items, { name: 'Space invader designs' } ) ).to.be.ok; + expect( find( menu.items[ 1 ].items[ 1 ].items, { name: 'Space invader designs' } ) ).to.be.ok; } ); } ); @@ -232,66 +232,66 @@ describe( 'MenuData', function() { it( 'should move an item and insert it before a target', function() { var menu = this.menuData.getMenu( 'primary' ), - itemToMove = menu.items[2], // About us - itemToMoveTo = menu.items[0], // Home + itemToMove = menu.items[ 2 ], // About us + itemToMoveTo = menu.items[ 0 ], // Home items; this.menuData.moveItem( itemToMove.id, itemToMoveTo.id, 'before' ); items = this.menuData.getMenu( 'primary' ).items; - expect( items[0] ).to.have.property( 'name', 'About us' ); - expect( items[1] ).to.have.property( 'name', 'Home' ); - expect( items[2] ).to.have.property( 'name', 'Products' ); + expect( items[ 0 ] ).to.have.property( 'name', 'About us' ); + expect( items[ 1 ] ).to.have.property( 'name', 'Home' ); + expect( items[ 2 ] ).to.have.property( 'name', 'Products' ); } ); it( 'should move an item and insert it after a target', function() { var menu = this.menuData.getMenu( 'primary' ), - itemToMove = menu.items[1], // Products - itemToMoveTo = menu.items[2], // About us + itemToMove = menu.items[ 1 ], // Products + itemToMoveTo = menu.items[ 2 ], // About us items; this.menuData.moveItem( itemToMove.id, itemToMoveTo.id, 'after' ); items = this.menuData.getMenu( 'primary' ).items; - expect( items[0] ).to.have.property( 'name', 'Home' ); - expect( items[1] ).to.have.property( 'name', 'About us' ); - expect( items[2] ).to.have.property( 'name', 'Products' ); + expect( items[ 0 ] ).to.have.property( 'name', 'Home' ); + expect( items[ 1 ] ).to.have.property( 'name', 'About us' ); + expect( items[ 2 ] ).to.have.property( 'name', 'Products' ); } ); it( 'should move an item to a different parent', function() { var menu = this.menuData.getMenu( 'primary' ), // Products > Socks > 80s socks > Space invader designs - itemToMove = menu.items[1].items[0].items[1].items[0], - itemToMoveTo = menu.items[2].items[0]; // Location + itemToMove = menu.items[ 1 ].items[ 0 ].items[ 1 ].items[ 0 ], + itemToMoveTo = menu.items[ 2 ].items[ 0 ]; // Location this.menuData.moveItem( itemToMove.id, itemToMoveTo.id, 'child' ); menu = this.menuData.getMenu( 'primary' ); - expect( menu.items[1].items[0].items[1].items ).to.be.empty; - expect( menu.items[2].items[0].items[0] ).to.have.property( 'name', 'Space invader designs' ); + expect( menu.items[ 1 ].items[ 0 ].items[ 1 ].items ).to.be.empty; + expect( menu.items[ 2 ].items[ 0 ].items[ 0 ] ).to.have.property( 'name', 'Space invader designs' ); } ); it( 'should move subtree of an item', function() { var menu = this.menuData.getMenu( 'primary' ), - itemToMove = menu.items[1], // Products - itemToMoveTo = menu.items[0], // Home + itemToMove = menu.items[ 1 ], // Products + itemToMoveTo = menu.items[ 0 ], // Home items; this.menuData.moveItem( itemToMove.id, itemToMoveTo.id, 'before' ); items = this.menuData.getMenu( 'primary' ).items; - expect( items[0].items[0] ).to.have.property( 'name', 'Socks' ); + expect( items[ 0 ].items[ 0 ] ).to.have.property( 'name', 'Socks' ); } ); it ( 'should insert child item as last child', function() { var menu = this.menuData.getMenu( 'primary' ), // Products > Socks > 80s socks > Space invader designs - itemToMove = menu.items[1].items[0].items[1].items[0], - itemToMoveTo = menu.items[2]; // About us + itemToMove = menu.items[ 1 ].items[ 0 ].items[ 1 ].items[ 0 ], + itemToMoveTo = menu.items[ 2 ]; // About us this.menuData.moveItem( itemToMove.id, itemToMoveTo.id, 'child' ); menu = this.menuData.getMenu( 'primary' ); - expect( menu.items[2].items[1] ).to.have.property( 'name', 'Space invader designs' ); + expect( menu.items[ 2 ].items[ 1 ] ).to.have.property( 'name', 'Space invader designs' ); } ); it ( 'should be able to move an item into its own descendent subtree', function() { @@ -333,7 +333,7 @@ describe( 'MenuData', function() { } ); it( 'should add the item', function() { - expect( this.menu.items[1].name ).to.equal( 'Newsletter' ); + expect( this.menu.items[ 1 ].name ).to.equal( 'Newsletter' ); } ); it( 'should raise a change event', function() { @@ -350,7 +350,7 @@ describe( 'MenuData', function() { } ); it( 'should add the item', function() { - expect( this.menu.items[1].items[0].items[1].name ).to.equal( 'Socks with polka dots' ); + expect( this.menu.items[ 1 ].items[ 0 ].items[ 1 ].name ).to.equal( 'Socks with polka dots' ); } ); it( 'should raise a change event', function() { @@ -367,7 +367,7 @@ describe( 'MenuData', function() { } ); it( 'should add the item', function() { - expect( this.aboutUs.items[1] ).to.have.property( 'name', 'The Search for Sock' ); + expect( this.aboutUs.items[ 1 ] ).to.have.property( 'name', 'The Search for Sock' ); } ); it( 'should raise a change event', function() { @@ -385,7 +385,7 @@ describe( 'MenuData', function() { context( 'when the item has no children', function() { beforeEach( function() { var menu = this.menuData.getMenu( 'primary' ), - item = menu.items[0]; + item = menu.items[ 0 ]; this.menuData.deleteMenuItem( item ); } ); @@ -393,7 +393,7 @@ describe( 'MenuData', function() { it( 'should delete the item', function() { var menu = this.menuData.getMenu( 'primary' ); - expect( menu.items[0].name ).not.to.equal( 'Home' ); + expect( menu.items[ 0 ].name ).not.to.equal( 'Home' ); } ); it( 'should raise a change event', function() { @@ -455,7 +455,7 @@ describe( 'MenuData', function() { } ); it( 'should add a new menu', function() { - var newName = this.menuData.get().menus[3].name; + var newName = this.menuData.get().menus[ 3 ].name; expect( newName ).to.equal( 'Foo' ); } ); @@ -467,7 +467,7 @@ describe( 'MenuData', function() { } ); it( 'should return an incremented new menu name', function() { - var newName = this.menuData.get().menus[3].name; + var newName = this.menuData.get().menus[ 3 ].name; expect( newName ).to.equal( 'Menu 4' ); } ); @@ -477,7 +477,7 @@ describe( 'MenuData', function() { this.menuData.data.menus = []; this.menuData.addNewMenu( 'Menu' ); - newName = this.menuData.get().menus[0].name; + newName = this.menuData.get().menus[ 0 ].name; expect( newName ).to.equal( 'Menu 1' ); } ); @@ -504,7 +504,7 @@ describe( 'MenuData', function() { describe( 'allocateClientIDs', function() { it( 'should populate all item.id fields in a menu with new values', function() { - var originalMenu = fixtures.menusFlat.menus[0], + var originalMenu = fixtures.menusFlat.menus[ 0 ], menu = this.menuData.allocateClientIDs( cloneDeep( originalMenu ) ); deepMapValues( menu.items, function( value, propertyPath ) { @@ -515,7 +515,7 @@ describe( 'MenuData', function() { } ); it( 'should store original id in server_id field', function() { - var originalMenu = fixtures.menusFlat.menus[0], + var originalMenu = fixtures.menusFlat.menus[ 0 ], menu = this.menuData.allocateClientIDs( cloneDeep( originalMenu ) ); deepMapValues( menu.items, function( value, propertyPath ) { @@ -527,7 +527,7 @@ describe( 'MenuData', function() { } ); it( 'should leave the menu\'s own ID untouched', function() { - var originalMenu = fixtures.menusFlat.menus[0], + var originalMenu = fixtures.menusFlat.menus[ 0 ], menu = this.menuData.allocateClientIDs( cloneDeep( originalMenu ) ); expect( menu.id ).to.equal( originalMenu.id ); @@ -536,11 +536,11 @@ describe( 'MenuData', function() { describe( 'restoreServerIDs', function() { it( 'should populate item.id fields with original values', function() { - var originalMenu = fixtures.menusFlat.menus[0]; + var originalMenu = fixtures.menusFlat.menus[ 0 ]; - this.menuData.restoreServerIDs( this.menuData.data.menus[0] ); + this.menuData.restoreServerIDs( this.menuData.data.menus[ 0 ] ); - deepMapValues( this.menuData.data.menus[0].items, function( value, propertyPath ) { + deepMapValues( this.menuData.data.menus[ 0 ].items, function( value, propertyPath ) { if ( 'id' === last( propertyPath ) ) { expect( value ).to.equal( get( originalMenu.items, propertyPath ) ); } @@ -548,11 +548,11 @@ describe( 'MenuData', function() { } ); it( 'should leave the menu\'s own ID untouched', function() { - var originalMenu = fixtures.menusFlat.menus[0]; + var originalMenu = fixtures.menusFlat.menus[ 0 ]; - this.menuData.restoreServerIDs( this.menuData.data.menus[0] ); + this.menuData.restoreServerIDs( this.menuData.data.menus[ 0 ] ); - expect( this.menuData.data.menus[0].id ).to.equal( originalMenu.id ); + expect( this.menuData.data.menus[ 0 ].id ).to.equal( originalMenu.id ); } ); } ); diff --git a/client/lib/mixins/data-observe/test/index.js b/client/lib/mixins/data-observe/test/index.js index 96a811d0d938e..04db91dfaf129 100644 --- a/client/lib/mixins/data-observe/test/index.js +++ b/client/lib/mixins/data-observe/test/index.js @@ -94,7 +94,7 @@ function mockContext() { update: 'callback' }; propNames.forEach( function( name ) { - context.props[name] = mockEventEmitter( context, name ); + context.props[ name ] = mockEventEmitter( context, name ); } ); return context; } diff --git a/client/lib/mixins/render-visualizer/index.js b/client/lib/mixins/render-visualizer/index.js index 01af4f0d4104a..2f2e8091eabfd 100644 --- a/client/lib/mixins/render-visualizer/index.js +++ b/client/lib/mixins/render-visualizer/index.js @@ -178,7 +178,7 @@ var RenderVisualizerMixin = { removeRenderLogNode: function() { if ( this.renderLogContainer ) { - document.getElementsByTagName( 'body' )[0].removeChild( this.renderLogContainer ); + document.getElementsByTagName( 'body' )[ 0 ].removeChild( this.renderLogContainer ); } }, diff --git a/client/lib/plugins/utils.js b/client/lib/plugins/utils.js index b54b7e20d193a..7dacda9963702 100644 --- a/client/lib/plugins/utils.js +++ b/client/lib/plugins/utils.js @@ -164,7 +164,7 @@ PluginUtils = { case 'sections': let cleanItem = {}; for ( let sectionKey of Object.keys( item ) ) { - cleanItem[ sectionKey] = sanitizeHtml( item[ sectionKey ], { + cleanItem[ sectionKey ] = sanitizeHtml( item[ sectionKey ], { allowedTags: [ 'h4', 'h5', 'h6', 'blockquote', 'code', 'b', 'i', 'em', 'strong', 'a', 'p', 'img', 'ul', 'ol', 'li' ], allowedAttributes: { a: [ 'href', 'target', 'rel' ], img: [ 'src' ] }, allowedSchemes: [ 'http', 'https' ], diff --git a/client/lib/post-metadata/index.js b/client/lib/post-metadata/index.js index a2b07c2f07716..de9669f4613b2 100644 --- a/client/lib/post-metadata/index.js +++ b/client/lib/post-metadata/index.js @@ -26,7 +26,7 @@ function getConnectionIdsByPattern( metadata, pattern ) { return metadata.filter( function( meta ) { return pattern.test( meta.key ) && 1 === parseInt( meta.value, 10 ); } ).map( function( meta ) { - return parseInt( meta.key.match( pattern )[1], 10 ); + return parseInt( meta.key.match( pattern )[ 1 ], 10 ); } ); } diff --git a/client/lib/posts/post-list-cache-store.js b/client/lib/posts/post-list-cache-store.js index 68e9479b4c23c..0a71695dcf732 100644 --- a/client/lib/posts/post-list-cache-store.js +++ b/client/lib/posts/post-list-cache-store.js @@ -158,7 +158,7 @@ export function getCanonicalList( listKey, requestKey ) { return false; } const keys = Object.keys( stream ); - if ( keys[0] !== requestKey ) { + if ( keys[ 0 ] !== requestKey ) { // requests processing out of order, clear cache delete cache[ listKey ]; delete _canonicalCache[ listKey ]; diff --git a/client/lib/posts/post-list-store.js b/client/lib/posts/post-list-store.js index 57559580117e2..5b86606ebaace 100644 --- a/client/lib/posts/post-list-store.js +++ b/client/lib/posts/post-list-store.js @@ -58,12 +58,12 @@ export function getRemovedPosts( currentList, newPosts ) { return []; } - const overlapBegin = currentList.indexOf( newPosts[0] ); + const overlapBegin = currentList.indexOf( newPosts[ 0 ] ); if ( overlapBegin === -1 ) { return getRemovedPosts( currentList, newPosts.slice( 1 ) ); } - const overlapEnd = currentList.indexOf( newPosts.slice( -1 )[0] ); + const overlapEnd = currentList.indexOf( newPosts.slice( -1 )[ 0 ] ); if ( overlapEnd === -1 ) { return getRemovedPosts( currentList, newPosts.slice( 0, -1 ) ); } diff --git a/client/lib/posts/utils.js b/client/lib/posts/utils.js index 8af383b0d41a3..ee03e5a8aa06b 100644 --- a/client/lib/posts/utils.js +++ b/client/lib/posts/utils.js @@ -49,7 +49,7 @@ var utils = { } if ( site.options && site.options.frame_nonce ) { parsed = url.parse( previewUrl, true ); - parsed.query['frame-nonce'] = site.options.frame_nonce; + parsed.query[ 'frame-nonce' ] = site.options.frame_nonce; delete parsed.search; previewUrl = url.format( parsed ); } diff --git a/client/lib/scroll-to/test/index.js b/client/lib/scroll-to/test/index.js index e5cc720a7c178..96a6e7d734cf9 100644 --- a/client/lib/scroll-to/test/index.js +++ b/client/lib/scroll-to/test/index.js @@ -29,8 +29,8 @@ describe( 'scroll-to', () => { y: 300, duration: 1, onComplete: () => { - expect( window.scrollTo.lastCall.args[0] ).to.equal( 500 ); - expect( window.scrollTo.lastCall.args[1] ).to.equal( 300 ); + expect( window.scrollTo.lastCall.args[ 0 ] ).to.equal( 500 ); + expect( window.scrollTo.lastCall.args[ 1 ] ).to.equal( 300 ); done(); } } ); @@ -41,8 +41,8 @@ describe( 'scroll-to', () => { y: 100, duration: 1, onComplete: () => { - expect( window.scrollTo.lastCall.args[0] ).to.equal( 0 ); - expect( window.scrollTo.lastCall.args[1] ).to.equal( 100 ); + expect( window.scrollTo.lastCall.args[ 0 ] ).to.equal( 0 ); + expect( window.scrollTo.lastCall.args[ 1 ] ).to.equal( 100 ); done(); } } ); diff --git a/client/lib/shortcode/index.js b/client/lib/shortcode/index.js index 223a67614a822..2b0f160d1d24b 100644 --- a/client/lib/shortcode/index.js +++ b/client/lib/shortcode/index.js @@ -33,16 +33,16 @@ Shortcode.parseAttributes = memoize( function( text ) { // Match and normalize attributes. while ( ( match = REGEXP_ATTR_STRING.exec( text ) ) ) { - if ( match[1] ) { - named[ match[1].toLowerCase() ] = match[2]; - } else if ( match[3] ) { - named[ match[3].toLowerCase() ] = match[4]; - } else if ( match[5] ) { - named[ match[5].toLowerCase() ] = match[6]; - } else if ( match[7] ) { - numeric.push( match[7] ); - } else if ( match[8] ) { - numeric.push( match[8] ); + if ( match[ 1 ] ) { + named[ match[ 1 ].toLowerCase() ] = match[ 2 ]; + } else if ( match[ 3 ] ) { + named[ match[ 3 ].toLowerCase() ] = match[ 4 ]; + } else if ( match[ 5 ] ) { + named[ match[ 5 ].toLowerCase() ] = match[ 6 ]; + } else if ( match[ 7 ] ) { + numeric.push( match[ 7 ] ); + } else if ( match[ 8 ] ) { + numeric.push( match[ 8 ] ); } } @@ -210,25 +210,25 @@ Shortcode.next = function( tag, text, index ) { } // If we matched an escaped shortcode, try again. - if ( '[' === match[1] && ']' === match[7] ) { + if ( '[' === match[ 1 ] && ']' === match[ 7 ] ) { return Shortcode.next( tag, text, re.lastIndex ); } result = { index: match.index, - content: match[0], - shortcode: Shortcode.parse( match[0] ) + content: match[ 0 ], + shortcode: Shortcode.parse( match[ 0 ] ) }; // If we matched a leading `[`, strip it from the match // and increment the index accordingly. - if ( match[1] ) { + if ( match[ 1 ] ) { result.content = result.content.slice( 1 ); result.index++; } // If we matched a trailing `]`, strip it from the match. - if ( match[7] ) { + if ( match[ 7 ] ) { result.content = result.content.slice( 0, -1 ); } diff --git a/client/lib/sites-list/test/fixtures/data.js b/client/lib/sites-list/test/fixtures/data.js index 7708c3a053ef8..2bbab0a7dd236 100644 --- a/client/lib/sites-list/test/fixtures/data.js +++ b/client/lib/sites-list/test/fixtures/data.js @@ -261,7 +261,7 @@ export const original = [ export const updated = cloneDeep( original ); -updated[0].name = 'Checkout this new name'; +updated[ 0 ].name = 'Checkout this new name'; updated.push( { 'ID': 43889156, diff --git a/client/lib/tree-convert/index.js b/client/lib/tree-convert/index.js index 2bd7374e50363..54ca58c50d259 100644 --- a/client/lib/tree-convert/index.js +++ b/client/lib/tree-convert/index.js @@ -28,14 +28,14 @@ TreeConvert.prototype.treeify = function( items ) { indexedNodes = {}; items.forEach( function( item, i ) { - indexedNodes[items[i][ this.key ]] = item; + indexedNodes[ items[ i ][ this.key ] ] = item; }, this ); items.forEach( function( item ) { var parentNode; if ( item.parent > 0 && indexedNodes[ item.parent ] ) { - parentNode = indexedNodes[item.parent]; + parentNode = indexedNodes[ item.parent ]; parentNode.items = parentNode.items || []; parentNode.items.push( item ); } else { diff --git a/client/lib/tree-convert/test/index.js b/client/lib/tree-convert/test/index.js index 639cf8efbca1e..eb666f61f7b61 100644 --- a/client/lib/tree-convert/test/index.js +++ b/client/lib/tree-convert/test/index.js @@ -15,7 +15,7 @@ describe( 'TreeConvert', () => { beforeEach( () => { converter = TreeConvert(); - menu = cloneDeep( menusFlat.menus[0] ); + menu = cloneDeep( menusFlat.menus[ 0 ] ); } ); describe( 'treeify', () => { @@ -23,19 +23,19 @@ describe( 'TreeConvert', () => { const treeified = converter.treeify( menu.items ); expect( treeified ).to.have.length( 3 ); - expect( treeified[2].items ).to.be.instanceOf( Array ); + expect( treeified[ 2 ].items ).to.be.instanceOf( Array ); } ); it( 'should order sibling items by their "order" property', () => { const treeified = converter.treeify( menu.items ); - expect( treeified[1].items[0] ).to.have.property( 'name', 'Socks' ); + expect( treeified[ 1 ].items[ 0 ] ).to.have.property( 'name', 'Socks' ); } ); it( 'should remove the "order" property from items, since order will be implicit', () => { const treeified = converter.treeify( menu.items ); - expect( treeified[1].items[0] ).not.to.have.property( 'order' ); + expect( treeified[ 1 ].items[ 0 ] ).not.to.have.property( 'order' ); } ); it( 'should handle bad parent data, falling back to parent 0', () => { @@ -44,7 +44,7 @@ describe( 'TreeConvert', () => { // "About us" should become a top-level item expect( treeified ).to.have.length( 3 ); - expect( treeified[2] ).to.have.property( 'name', 'About us' ); + expect( treeified[ 2 ] ).to.have.property( 'name', 'About us' ); } ); } ); @@ -60,15 +60,15 @@ describe( 'TreeConvert', () => { const treeified = converter.treeify( menu.items ), list = converter.untreeify( treeified ); - expect( list[0] ).to.have.property( 'order' ); + expect( list[ 0 ] ).to.have.property( 'order' ); } ); it( 'should not modify the original object', () => { const treeified = converter.treeify( menu.items ); - expect( treeified[1] ).to.have.property( 'items' ); + expect( treeified[ 1 ] ).to.have.property( 'items' ); converter.untreeify( treeified ); - expect( treeified[1] ).to.have.property( 'items' ); + expect( treeified[ 1 ] ).to.have.property( 'items' ); } ); } ); } ); diff --git a/client/lib/tree-convert/tree-traverser.js b/client/lib/tree-convert/tree-traverser.js index 9543a7fee55b1..7eec4ee56120e 100644 --- a/client/lib/tree-convert/tree-traverser.js +++ b/client/lib/tree-convert/tree-traverser.js @@ -70,7 +70,7 @@ function replaceItem( node, newNode, predicate ) { function mapFindAny( array, fn ) { var i, result, length = array.length; for ( i = 0; i < length; i++ ) { - if ( result = fn( array[i] ) ) { // eslint-disable-line no-cond-assign + if ( result = fn( array[ i ] ) ) { // eslint-disable-line no-cond-assign return result; } } diff --git a/client/lib/users/test/fixtures/actions.js b/client/lib/users/test/fixtures/actions.js index f8cb46060cc5f..a35c39b60c849 100644 --- a/client/lib/users/test/fixtures/actions.js +++ b/client/lib/users/test/fixtures/actions.js @@ -48,14 +48,14 @@ module.exports = { type: 'DELETE_SITE_USER', action: 'DELETE_SITE_USER', siteId: site.ID, - user: usersData.users[0], + user: usersData.users[ 0 ], }, deleteUserError: { type: 'RECEIVE_DELETE_SITE_USER_FAILURE', action: 'DELETE_SITE_USER', siteId: site.ID, - user: usersData.users[0], + user: usersData.users[ 0 ], error: true }, @@ -63,14 +63,14 @@ module.exports = { type: 'RECEIVE_DELETE_SITE_USER_SUCCESS', action: 'DELETE_SITE_USER', siteId: site.ID, - user: usersData.users[0], + user: usersData.users[ 0 ], data: { success: true } }, updateUserError: { type: 'RECEIVE_UPDATE_SITE_USER_FAILURE', siteId: site.ID, - user: usersData.users[0], + user: usersData.users[ 0 ], error: true }, diff --git a/client/lib/users/test/store.js b/client/lib/users/test/store.js index eee794790cf24..e870d7937ef6c 100644 --- a/client/lib/users/test/store.js +++ b/client/lib/users/test/store.js @@ -39,16 +39,16 @@ describe( 'Users Store', () => { } ); it( 'Should return undefined when user not in store', () => { - assert.isUndefined( UsersStore.getUserByLogin( siteId, usersData.users[0].login ) ); + assert.isUndefined( UsersStore.getUserByLogin( siteId, usersData.users[ 0 ].login ) ); } ); it( 'Should return a user object when the user exists', () => { let user; Dispatcher.handleServerAction( actions.fetched ); - user = UsersStore.getUserByLogin( siteId, usersData.users[0].login ); + user = UsersStore.getUserByLogin( siteId, usersData.users[ 0 ].login ); assert.isObject( user ); - assert.equal( user.ID, usersData.users[0].ID ); + assert.equal( user.ID, usersData.users[ 0 ].ID ); } ); } ); @@ -66,11 +66,11 @@ describe( 'Users Store', () => { it( 'The users store should return an array of objects when fetching users', () => { assert.isArray( users ); - assert.isObject( users[0] ); + assert.isObject( users[ 0 ] ); } ); it( 'A user object from the store should contain an array of roles', () => { - assert.isArray( users[0].roles ); + assert.isArray( users[ 0 ].roles ); } ); it( 'Re-fetching a list of users when a users was deleted from the site should result in a smaller array', () => { @@ -142,7 +142,7 @@ describe( 'Users Store', () => { // The last two users should have a 'contributor' role updatedUsers.slice( -2, 2 ).forEach( user => { - assert.equal( user.roles[0], 'contributor' ); + assert.equal( user.roles[ 0 ], 'contributor' ); } ); } ); } ); @@ -163,7 +163,7 @@ describe( 'Users Store', () => { } ); it( 'Error should restore the updated user', () => { - const userId = usersData.users[0].ID, + const userId = usersData.users[ 0 ].ID, user = UsersStore.getUser( siteId, userId ); let userAgain, userRestored; @@ -184,7 +184,7 @@ describe( 'Users Store', () => { beforeEach( function() { Dispatcher.handleServerAction( actions.fetched ); - userId = usersData.users[0].ID; + userId = usersData.users[ 0 ].ID; } ); it( 'Should delete a specific user', () => { diff --git a/client/lib/viewers/test/fixtures/actions.js b/client/lib/viewers/test/fixtures/actions.js index 8449fe95d46aa..e0a20850513e6 100644 --- a/client/lib/viewers/test/fixtures/actions.js +++ b/client/lib/viewers/test/fixtures/actions.js @@ -30,12 +30,12 @@ module.exports = { removeViewer: { type: 'REMOVE_VIEWER', siteId: site.ID, - viewer: viewerData.viewers[0] + viewer: viewerData.viewers[ 0 ] }, removeViewerError: { type: 'RECEIVE_REMOVE_VIEWER_ERROR', siteId: site.ID, - viewer: viewerData.viewers[0] + viewer: viewerData.viewers[ 0 ] } }; diff --git a/client/lib/viewers/test/store.js b/client/lib/viewers/test/store.js index f90e08dbb8c53..fe13da4773680 100644 --- a/client/lib/viewers/test/store.js +++ b/client/lib/viewers/test/store.js @@ -53,7 +53,7 @@ describe( 'Viewers Store', () => { viewers = ViewersStore.getViewers( siteId ); assert.isArray( viewers, 'viewers is an array' ); - assert.isObject( viewers[0] ); + assert.isObject( viewers[ 0 ] ); } ); } ); diff --git a/client/lib/wporg/jsonp.js b/client/lib/wporg/jsonp.js index 741b7626399fc..0f275348e8f90 100644 --- a/client/lib/wporg/jsonp.js +++ b/client/lib/wporg/jsonp.js @@ -34,7 +34,7 @@ function jsonp( url, query, fn ) { var prefix = '__jp', timeout = 60000, enc = encodeURIComponent, - target = document.getElementsByTagName( 'script' )[0] || document.head, + target = document.getElementsByTagName( 'script' )[ 0 ] || document.head, script, timer, id; @@ -56,19 +56,19 @@ function jsonp( url, query, fn ) { script.parentNode.removeChild( script ); } - window[id] = noop; + window[ id ] = noop; if ( timer ) { clearTimeout( timer ); } } function cancel() { - if ( window[id] ) { + if ( window[ id ] ) { cleanup(); } } - window[id] = function( data ) { + window[ id ] = function( data ) { debug( 'jsonp got', data ); cleanup(); if ( fn ) { diff --git a/client/me/notification-settings/blogs-settings/index.jsx b/client/me/notification-settings/blogs-settings/index.jsx index 8b1afe74b5fbc..a70e0f5a19e8f 100644 --- a/client/me/notification-settings/blogs-settings/index.jsx +++ b/client/me/notification-settings/blogs-settings/index.jsx @@ -56,7 +56,7 @@ export default React.createClass( { } if ( this.props.blogs.get().length === 1 ) { - return renderBlog( this.props.blogs.get()[0], null, true ); + return renderBlog( this.props.blogs.get()[ 0 ], null, true ); } return ( diff --git a/client/me/notification-settings/settings-form/device-selector.jsx b/client/me/notification-settings/settings-form/device-selector.jsx index 0cda8962987cc..5299a5766fc67 100644 --- a/client/me/notification-settings/settings-form/device-selector.jsx +++ b/client/me/notification-settings/settings-form/device-selector.jsx @@ -23,7 +23,7 @@ export default React.createClass( { render() { if ( this.props.devices.get().length === 1 ) { - return ( ); + return ( ); } return ( diff --git a/client/me/notification-settings/settings-form/locales.js b/client/me/notification-settings/settings-form/locales.js index 2d673c5b79719..d865b7b74d023 100644 --- a/client/me/notification-settings/settings-form/locales.js +++ b/client/me/notification-settings/settings-form/locales.js @@ -17,9 +17,9 @@ export const settingLabels = { }; export const getLabelForStream = stream => stream in streamLabels - ? streamLabels[stream].call() + ? streamLabels[ stream ].call() : null; export const getLabelForSetting = setting => setting in settingLabels - ? settingLabels[setting].call() + ? settingLabels[ setting ].call() : null; diff --git a/client/me/notification-settings/settings-form/stream-options.jsx b/client/me/notification-settings/settings-form/stream-options.jsx index 951b163bc4f56..677804abe68da 100644 --- a/client/me/notification-settings/settings-form/stream-options.jsx +++ b/client/me/notification-settings/settings-form/stream-options.jsx @@ -34,7 +34,7 @@ export default React.createClass( { return (
      { this.props.settingKeys.map( ( setting, index ) => { - const isException = this.props.stream in NOTIFICATIONS_EXCEPTIONS && NOTIFICATIONS_EXCEPTIONS[this.props.stream].indexOf( setting ) >= 0; + const isException = this.props.stream in NOTIFICATIONS_EXCEPTIONS && NOTIFICATIONS_EXCEPTIONS[ this.props.stream ].indexOf( setting ) >= 0; return (
    • { isException ? null : { diff --git a/client/my-sites/ads/form-earnings.jsx b/client/my-sites/ads/form-earnings.jsx index 4bcb7c878bd1f..6a6a602e05131 100644 --- a/client/my-sites/ads/form-earnings.jsx +++ b/client/my-sites/ads/form-earnings.jsx @@ -142,7 +142,7 @@ module.exports = React.createClass( { swapYearMonth: function( date ) { var splits = date.split( '-' ); - return splits[1] + '-' + splits[0]; + return splits[ 1 ] + '-' + splits[ 0 ]; }, getStatus: function( status ) { @@ -240,9 +240,9 @@ module.exports = React.createClass( { rows.push( { this.swapYearMonth( period ) } - ${ this.numberFormat( earnings[period].amount, 2 ) } - { earnings[period].pageviews } - { this.getStatus( earnings[period].status ) } + ${ this.numberFormat( earnings[ period ].amount, 2 ) } + { earnings[ period ].pageviews } + { this.getStatus( earnings[ period ].status ) } ); } diff --git a/client/my-sites/menus/item-options/test/posts.jsx b/client/my-sites/menus/item-options/test/posts.jsx index d4c6a5c62cf92..f805437cb342a 100644 --- a/client/my-sites/menus/item-options/test/posts.jsx +++ b/client/my-sites/menus/item-options/test/posts.jsx @@ -39,7 +39,7 @@ describe( 'Posts', function() { it( 'should inject when the menu type is "page"', function() { const postsNode = new Posts( {posts: [], type: 'page' } ); const injectedPosts = postsNode.maybeInjectPosts(); - chai.expect( injectedPosts[0] ).to.equal( this.itemToInject ); + chai.expect( injectedPosts[ 0 ] ).to.equal( this.itemToInject ); } ); it( 'should not inject when the menu type is not "page"', function() { diff --git a/client/my-sites/menus/menu-editable-item.jsx b/client/my-sites/menus/menu-editable-item.jsx index f789bf04a8746..be87676712a74 100644 --- a/client/my-sites/menus/menu-editable-item.jsx +++ b/client/my-sites/menus/menu-editable-item.jsx @@ -189,7 +189,7 @@ var MenuEditableItem = React.createClass( { }, renderItemOptions: function() { - return this.state.itemType && this[this.state.itemType.renderer]( this.state.itemType ); + return this.state.itemType && this[ this.state.itemType.renderer ]( this.state.itemType ); }, renderLinkOptions: function( itemType ) { diff --git a/client/my-sites/menus/menu-item-drop-target.jsx b/client/my-sites/menus/menu-item-drop-target.jsx index 004b62cade5c9..b3a07412ef1be 100644 --- a/client/my-sites/menus/menu-item-drop-target.jsx +++ b/client/my-sites/menus/menu-item-drop-target.jsx @@ -15,7 +15,7 @@ var MenuItemDropTarget = React.createClass( { onClick: function() { var positionText = { before: 'above', after: 'below', child: 'to children' }, - actionText = 'Clicked ' + this.props.operation + ' menu item ' + positionText[this.props.position]; + actionText = 'Clicked ' + this.props.operation + ' menu item ' + positionText[ this.props.position ]; analytics.ga.recordEvent( 'Menus', actionText ); this.props.action(); diff --git a/client/my-sites/plugins/plugin-remove-button/index.jsx b/client/my-sites/plugins/plugin-remove-button/index.jsx index 4894a816e35f1..6caf8524ea9ee 100644 --- a/client/my-sites/plugins/plugin-remove-button/index.jsx +++ b/client/my-sites/plugins/plugin-remove-button/index.jsx @@ -98,7 +98,7 @@ module.exports = React.createClass( { } else { html.push(

      - { this.translate( '%(pluginName)s cannot be removed. %(reason)s', { args: { pluginName: this.props.plugin.name, reason: reasons[0] } } ) } + { this.translate( '%(pluginName)s cannot be removed. %(reason)s', { args: { pluginName: this.props.plugin.name, reason: reasons[ 0 ] } } ) }

      ); } @@ -161,4 +161,3 @@ module.exports = React.createClass( { return this.renderButton(); } } ); - diff --git a/client/my-sites/sharing/buttons/preview-widget.js b/client/my-sites/sharing/buttons/preview-widget.js index 8eeeb6ca51615..4a6c1fe1e1ed3 100644 --- a/client/my-sites/sharing/buttons/preview-widget.js +++ b/client/my-sites/sharing/buttons/preview-widget.js @@ -20,11 +20,11 @@ module.exports = { // Custom buttons previews are specified by index using the // name and a URL to the icon index = numberOfCustomButtons++; - query['custom[' + index + '][name]'] = encodeURIComponent( button.name ); - query['custom[' + index + '][icon]'] = encodeURIComponent( button.icon ); + query[ 'custom[' + index + '][name]' ] = encodeURIComponent( button.name ); + query[ 'custom[' + index + '][icon]' ] = encodeURIComponent( button.icon ); } else { - query['service[]'] = query['service[]'] || []; - query['service[]'].push( button.ID ); + query[ 'service[]' ] = query[ 'service[]' ] || []; + query[ 'service[]' ].push( button.ID ); } } ); diff --git a/client/my-sites/upgrades/checkout/privacy-protection.jsx b/client/my-sites/upgrades/checkout/privacy-protection.jsx index 5b6c569d34af8..61b0ce86ec679 100644 --- a/client/my-sites/upgrades/checkout/privacy-protection.jsx +++ b/client/my-sites/upgrades/checkout/privacy-protection.jsx @@ -43,7 +43,7 @@ module.exports = React.createClass( { render: function() { const domainRegistrations = cartItems.getDomainRegistrations( this.props.cart ), numberOfDomainRegistrations = domainRegistrations.length, - firstDomainToRegister = domainRegistrations[0], + firstDomainToRegister = domainRegistrations[ 0 ], hasOneFreePrivacy = this.hasDomainPartOfPlan() && numberOfDomainRegistrations === 1, privacyText = this.translate( "Privacy Protection hides your personal information in your domain's public records, to protect your identity and prevent spam." diff --git a/client/post-editor/editor-revisions/index.jsx b/client/post-editor/editor-revisions/index.jsx index 430b7079782ff..c86fdbd15a398 100644 --- a/client/post-editor/editor-revisions/index.jsx +++ b/client/post-editor/editor-revisions/index.jsx @@ -27,7 +27,7 @@ export default React.createClass( { return null; } - const lastRevision = this.props.revisions[0]; + const lastRevision = this.props.revisions[ 0 ]; const revisionsLink = this.props.adminUrl + 'revision.php?revision=' + lastRevision; return ( diff --git a/client/signup/utils.js b/client/signup/utils.js index 49f3aaac864fd..c457adcdae446 100644 --- a/client/signup/utils.js +++ b/client/signup/utils.js @@ -111,13 +111,13 @@ function getValueFromProgressStore( { signupProgress, stepName, fieldName } ) { signupProgress, step => step.stepName === stepName ); - return siteStepProgress ? siteStepProgress[fieldName] : null; + return siteStepProgress ? siteStepProgress[ fieldName ] : null; } function mergeFormWithValue( { form, fieldName, fieldValue} ) { if ( ! formState.getFieldValue( form, fieldName ) ) { return merge( form, { - [fieldName]: { value: fieldValue } + [ fieldName ]: { value: fieldValue } } ); } return form; diff --git a/client/state/application/reducer.js b/client/state/application/reducer.js index 12a7e8bc34c63..2ffead9b9cbb1 100644 --- a/client/state/application/reducer.js +++ b/client/state/application/reducer.js @@ -13,8 +13,8 @@ import { import { createReducer } from 'state/utils'; export const connectionState = createReducer( 'CHECKING', { - [CONNECTION_LOST]: () => 'OFFLINE', - [CONNECTION_RESTORED]: () => 'ONLINE' + [ CONNECTION_LOST ]: () => 'OFFLINE', + [ CONNECTION_RESTORED ]: () => 'ONLINE' } ); export default combineReducers( { diff --git a/client/state/comments/test/actions.js b/client/state/comments/test/actions.js index 031e806df688a..d6ac3bd386355 100644 --- a/client/state/comments/test/actions.js +++ b/client/state/comments/test/actions.js @@ -169,25 +169,25 @@ describe( 'actions', () => { const reqPromise = writeCommentThunk( dispatchSpy ); - const firstSpyCallArg = dispatchSpy.args[0][0]; + const firstSpyCallArg = dispatchSpy.args[ 0 ][ 0 ]; expect( firstSpyCallArg.type ).to.eql( COMMENTS_RECEIVE ); - expect( firstSpyCallArg.comments[0].ID.indexOf( 'placeholder-' ) ).to.equal( 0 ); + expect( firstSpyCallArg.comments[ 0 ].ID.indexOf( 'placeholder-' ) ).to.equal( 0 ); return reqPromise.then( ( comment ) => { expect( comment ).to.be.object; expect( comment ).to.not.equal( undefined ); expect( comment ).to.not.equal( null ); - const secondSpyCallArg = dispatchSpy.args[1][0]; - const thirdSpyCallArg = dispatchSpy.args[2][0]; + const secondSpyCallArg = dispatchSpy.args[ 1 ][ 0 ]; + const thirdSpyCallArg = dispatchSpy.args[ 2 ][ 0 ]; expect( secondSpyCallArg.type ).to.eql( COMMENTS_REMOVE ); expect( secondSpyCallArg.commentId.indexOf( 'placeholder-' ) ).to.equal( 0 ); expect( thirdSpyCallArg.type ).to.eql( COMMENTS_RECEIVE ); expect( thirdSpyCallArg.comments.length ).to.eql( 1 ); - expect( thirdSpyCallArg.comments[0].ID ).to.be.a.number; + expect( thirdSpyCallArg.comments[ 0 ].ID ).to.be.a.number; } ); } ); } ); // writeComment diff --git a/client/state/comments/test/selectors.js b/client/state/comments/test/selectors.js index 877979454086d..d70d78d6527e3 100644 --- a/client/state/comments/test/selectors.js +++ b/client/state/comments/test/selectors.js @@ -32,7 +32,7 @@ describe( 'selectors', () => { } }, 1, 1 ); - expect( res ).to.be.eql( new Date( commentItems[0].date ) ); + expect( res ).to.be.eql( new Date( commentItems[ 0 ].date ) ); } ); it( 'should return undefined if no comment items', () => { @@ -63,7 +63,7 @@ describe( 'selectors', () => { } }, 1, 1 ); - expect( res ).to.be.eql( new Date( commentItems[1].date ) ); + expect( res ).to.be.eql( new Date( commentItems[ 1 ].date ) ); } ); it( 'should return undefined if no comment items', () => { diff --git a/client/state/comments/utils.js b/client/state/comments/utils.js index e4b5ede39085c..2d6a1ec415c21 100644 --- a/client/state/comments/utils.js +++ b/client/state/comments/utils.js @@ -22,7 +22,7 @@ export function getCommentParentKey( siteId, postId ) { */ export function createRequestId( siteId, postId, query ) { const queryKeys = Object.keys( query ).sort(); - const queryString = queryKeys.map( ( key ) => `${ key }=${ query[key] }` ).join( '-' ); + const queryString = queryKeys.map( ( key ) => `${ key }=${ query[ key ] }` ).join( '-' ); return `${siteId}-${postId}-${ queryString }`; } diff --git a/client/state/reader/posts/test/selectors.js b/client/state/reader/posts/test/selectors.js index ba4caff29cfac..faa4ecf0fa53e 100644 --- a/client/state/reader/posts/test/selectors.js +++ b/client/state/reader/posts/test/selectors.js @@ -84,7 +84,7 @@ describe( 'selectors', () => { } }; expect( getPostBySiteAndId( stateTree, 1, 1 ) ) - .to.equal( stateTree.reader.posts.items['2'] ); + .to.equal( stateTree.reader.posts.items[ '2' ] ); } ); } ); } );