Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint] Adds rule one-var and autofixes all related errors #47310

Merged
merged 2 commits into from Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .eslintrc.js
Expand Up @@ -215,6 +215,8 @@ module.exports = {

'no-path-concat': 'error',

'one-var': [ 'error', 'never' ],

// TODO: why did we turn this off?
'jest/valid-expect': 'off',

Expand Down
Expand Up @@ -13,10 +13,10 @@ import { __, _x } from '@wordpress/i18n';

const view = ( { attributes, className, isEditView } ) => {
// Expected values in save.
let days = ' ',
hours = ' ',
mins = ' ',
secs = ' ';
let days = ' ';
let hours = ' ';
let mins = ' ';
let secs = ' ';

if ( isEditView ) {
// Zero out.
Expand Down
8 changes: 4 additions & 4 deletions apps/notifications/src/panel/indices-to-html/index.js
Expand Up @@ -23,8 +23,8 @@ import noticon2gridicon from '../utils/noticon2gridicon';
*/
function render_range( new_sub_text, new_sub_range, range_info, range_data, options ) {
// Its time to build the outer shell of the range we're recursing into.
let new_container = null,
type_mappings;
let new_container = null;
let type_mappings;
const new_classes = [];

let range_info_type = range_info.type;
Expand Down Expand Up @@ -183,8 +183,8 @@ function render_range( new_sub_text, new_sub_range, range_info, range_data, opti
* @param {object} options Options for building chunks
*/
function build_chunks( sub_text, sub_ranges, range_data, container, options ) {
let text_start = null,
text_stop = null;
let text_start = null;
let text_stop = null;

const ranges = JSON.parse( JSON.stringify( sub_ranges ) ); // clone through serialization

Expand Down
3 changes: 2 additions & 1 deletion apps/notifications/src/panel/templates/actions.jsx
Expand Up @@ -23,7 +23,8 @@ import { getActions, getReferenceId } from '../helpers/notes';
const getType = ( note ) => ( null === getReferenceId( note, 'comment' ) ? 'post' : 'comment' );

const getInitialReplyValue = ( note, translate ) => {
let ranges, username;
let ranges;
let username;

if ( 'user' === note.subject[ 0 ].ranges[ 0 ].type ) {
// Build the username from the subject line
Expand Down
24 changes: 12 additions & 12 deletions apps/notifications/src/panel/templates/block-user.jsx
Expand Up @@ -35,11 +35,11 @@ export class UserBlock extends React.Component {
* @returns {string} - Time stamp formatted for display or '' if input invalid
*/
getTimeString = ( timestamp ) => {
var DAY_IN_SECONDS = 3600 * 24,
MAX_LENGTH = 15,
parsedTime = Date.parse( timestamp ),
momentTime,
timeString;
var DAY_IN_SECONDS = 3600 * 24;
var MAX_LENGTH = 15;
var parsedTime = Date.parse( timestamp );
var momentTime;
var timeString;

if ( isNaN( parsedTime ) ) {
return '';
Expand All @@ -65,13 +65,13 @@ export class UserBlock extends React.Component {
};

render() {
var grav = this.props.block.media[ 0 ],
home_url = '',
home_title = '',
timeIndicator,
homeTemplate,
followLink,
noteActions;
var grav = this.props.block.media[ 0 ];
var home_url = '';
var home_title = '';
var timeIndicator;
var homeTemplate;
var followLink;
var noteActions;

if ( this.props.block.meta ) {
if ( this.props.block.meta.links ) {
Expand Down
4 changes: 2 additions & 2 deletions apps/notifications/src/panel/templates/body.jsx
Expand Up @@ -52,8 +52,8 @@ export const NoteBody = createReactClass( {
},

UNSAFE_componentWillMount: function () {
var note = this.props.note,
hasReplyBlock;
var note = this.props.note;
var hasReplyBlock;

if ( note.meta && note.meta.ids.reply_comment ) {
hasReplyBlock =
Expand Down
12 changes: 6 additions & 6 deletions apps/notifications/src/panel/templates/comment-reply-input.jsx
Expand Up @@ -150,12 +150,12 @@ const CommentReplyInput = createReactClass( {
},

handleSubmit( event ) {
var wpObject,
submitComment,
component = this,
statusMessage,
successMessage = this.props.translate( 'Reply posted!' ),
linkMessage = this.props.translate( 'View your comment.' );
var wpObject;
var submitComment;
var component = this;
var statusMessage;
var successMessage = this.props.translate( 'Reply posted!' );
var linkMessage = this.props.translate( 'View your comment.' );

if ( event ) {
event.preventDefault();
Expand Down
3 changes: 2 additions & 1 deletion apps/notifications/src/panel/templates/follow-link.jsx
Expand Up @@ -69,7 +69,8 @@ export const FollowLink = createReactClass( {
},

render: function () {
var gridicon_icon, link_text;
var gridicon_icon;
var link_text;

if ( this.state.isFollowing ) {
gridicon_icon = 'reader-following';
Expand Down
3 changes: 2 additions & 1 deletion apps/notifications/src/panel/templates/summary-in-single.jsx
Expand Up @@ -94,7 +94,8 @@ var Header = React.createFactory(

class SummaryInSingle extends React.Component {
render() {
var header_url, parser;
var header_url;
var parser;
if ( ! this.props.note.header || 0 === this.props.note.header.length ) {
return <span />;
}
Expand Down
4 changes: 2 additions & 2 deletions bin/build-metadata.js
Expand Up @@ -216,8 +216,8 @@ function removeAllNumberKeys( obj ) {
function removeRegionCodeAndCountryDialCodeIfSameWithCountryDialCode( countryData ) {
for ( let key in countryData ) {
if ( countryData.hasOwnProperty( key ) ) {
const country = countryData[ key ],
{ countryDialCode, dialCode } = country;
const country = countryData[ key ];
const { countryDialCode, dialCode } = country;
if ( countryDialCode === dialCode ) {
delete country.regionCode;
delete country.countryDialCode;
Expand Down
18 changes: 9 additions & 9 deletions client/blocks/conversations/empty.jsx
Expand Up @@ -30,15 +30,15 @@ class ConversationsEmptyContent extends React.Component {
/* eslint-disable wpcalypso/jsx-classname-namespace */
render() {
const action = (
<a
className="empty-content__action button is-primary"
onClick={ this.recordAction }
href="/read/search"
>
{ this.props.translate( 'Find posts to follow' ) }
</a>
),
secondaryAction = null;
<a
className="empty-content__action button is-primary"
onClick={ this.recordAction }
href="/read/search"
>
{ this.props.translate( 'Find posts to follow' ) }
</a>
);
const secondaryAction = null;

return (
<EmptyContent
Expand Down
6 changes: 3 additions & 3 deletions client/blocks/domain-to-plan-nudge/index.jsx
Expand Up @@ -96,9 +96,9 @@ class DomainToPlanNudge extends Component {
}

export default connect( ( state, props ) => {
const siteId = props.siteId || getSelectedSiteId( state ),
productSlug = PLAN_PERSONAL,
productId = getPlan( PLAN_PERSONAL ).getProductId();
const siteId = props.siteId || getSelectedSiteId( state );
const productSlug = PLAN_PERSONAL;
const productId = getPlan( PLAN_PERSONAL ).getProductId();

return {
isEligible: isEligibleForDomainToPaidPlanUpsell( state, siteId ),
Expand Down
8 changes: 7 additions & 1 deletion client/blocks/edit-gravatar/test/index.jsx
Expand Up @@ -23,7 +23,13 @@ jest.mock( 'lib/oauth-token', () => ( {
jest.mock( 'lib/user', () => () => {} );

describe( 'EditGravatar', () => {
let EditGravatar, FilePicker, Gravatar, ImageEditor, VerifyEmailDialog, DropZone, sandbox;
let EditGravatar;
let FilePicker;
let Gravatar;
let ImageEditor;
let VerifyEmailDialog;
let DropZone;
let sandbox;
const user = {
email_verified: false,
};
Expand Down
4 changes: 2 additions & 2 deletions client/blocks/image-editor/image-editor-buttons.jsx
Expand Up @@ -75,8 +75,8 @@ class ImageEditorButtons extends Component {
}

export default connect( ( state ) => {
const { src } = getImageEditorFileInfo( state ),
hasChanges = imageEditorHasChanges( state );
const { src } = getImageEditorFileInfo( state );
const hasChanges = imageEditorHasChanges( state );

return {
src,
Expand Down
52 changes: 26 additions & 26 deletions client/blocks/image-editor/image-editor-crop.jsx
Expand Up @@ -145,15 +145,15 @@ class ImageEditorCrop extends Component {
return;
}

const rotated = props.degrees % 180 !== 0,
newState = Object.assign( {}, this.state, newValues ),
newWidth = newState.right - newState.left,
newHeight = newState.bottom - newState.top;
const rotated = props.degrees % 180 !== 0;
const newState = Object.assign( {}, this.state, newValues );
const newWidth = newState.right - newState.left;
const newHeight = newState.bottom - newState.top;

let imageWidth,
imageHeight,
finalWidth = newWidth,
finalHeight = newHeight;
let imageWidth;
let imageHeight;
let finalWidth = newWidth;
let finalHeight = newHeight;

switch ( aspectRatio ) {
case AspectRatios.ORIGINAL:
Expand Down Expand Up @@ -218,8 +218,8 @@ class ImageEditorCrop extends Component {
const { right, bottom } = this.state;
const { minCropSize } = this.props;

let top = y,
left = x;
let top = y;
let left = x;

if ( right - left <= minCropSize.width ) {
left = right - minCropSize.width;
Expand All @@ -239,8 +239,8 @@ class ImageEditorCrop extends Component {
const { left, bottom } = this.state;
const { minCropSize } = this.props;

let top = y,
right = x;
let top = y;
let right = x;

if ( right - left <= minCropSize.width ) {
right = left + minCropSize.width;
Expand All @@ -260,8 +260,8 @@ class ImageEditorCrop extends Component {
const { left, top } = this.state;
const { minCropSize } = this.props;

let bottom = y,
right = x;
let bottom = y;
let right = x;

if ( right - left <= minCropSize.width ) {
right = left + minCropSize.width;
Expand All @@ -281,8 +281,8 @@ class ImageEditorCrop extends Component {
const { right, top } = this.state;
const { minCropSize } = this.props;

let bottom = y,
left = x;
let bottom = y;
let left = x;

if ( right - left <= minCropSize.width ) {
left = right - minCropSize.width;
Expand All @@ -299,9 +299,9 @@ class ImageEditorCrop extends Component {
}

onBorderDrag( x, y ) {
const { top, left, right, bottom } = this.state,
width = right - left,
height = bottom - top;
const { top, left, right, bottom } = this.state;
const width = right - left;
const height = bottom - top;

this.setState( {
top: y,
Expand All @@ -316,10 +316,10 @@ class ImageEditorCrop extends Component {

const { topBound, leftBound, rightBound, bottomBound } = this.props.bounds;

const currentTop = top - topBound,
currentLeft = left - leftBound,
currentWidth = right - left,
currentHeight = bottom - top;
const currentTop = top - topBound;
const currentLeft = left - leftBound;
const currentWidth = right - left;
const currentHeight = bottom - top;

const imageWidth = rightBound - leftBound;
let imageHeight = bottomBound - topBound;
Expand Down Expand Up @@ -355,9 +355,9 @@ class ImageEditorCrop extends Component {
render() {
const { top, left, right, bottom } = this.state;

const width = right - left,
height = bottom - top,
handleClassName = 'image-editor__crop-handle';
const width = right - left;
const height = bottom - top;
const handleClassName = 'image-editor__crop-handle';

const { topBound, leftBound, rightBound, bottomBound } = this.props.bounds;

Expand Down
8 changes: 4 additions & 4 deletions client/blocks/image-editor/index.jsx
Expand Up @@ -108,10 +108,10 @@ class ImageEditor extends React.Component {
updateFileInfo = ( media ) => {
const { site } = this.props;

let src,
fileName = 'default',
mimeType = 'image/png',
title = 'default';
let src;
let fileName = 'default';
let mimeType = 'image/png';
let title = 'default';

if ( media ) {
src =
Expand Down
3 changes: 2 additions & 1 deletion client/blocks/image-editor/test/image-editor-toolbar.jsx
Expand Up @@ -17,7 +17,8 @@ import { ImageEditorToolbar } from '../image-editor-toolbar';
import { useSandbox } from 'calypso/test-helpers/use-sinon';

describe( 'ImageEditorToolbar', () => {
let defaultProps, wrapper;
let defaultProps;
let wrapper;

useSandbox( ( sandbox ) => {
defaultProps = {
Expand Down
6 changes: 3 additions & 3 deletions client/blocks/keyring-connect-button/index.js
Expand Up @@ -170,9 +170,9 @@ class KeyringConnectButton extends Component {
const { primary, service, translate } = this.props;
const { isConnecting, isRefreshing } = this.state;
const status = service ? this.getConnectionStatus() : 'unknown';
let localPrimary = false,
warning = false,
label;
let localPrimary = false;
let warning = false;
let label;

const isPending = 'unknown' === status || isRefreshing || isConnecting;

Expand Down
4 changes: 3 additions & 1 deletion client/blocks/post-status/index.jsx
Expand Up @@ -25,7 +25,9 @@ export function PostStatus( { translate, post, showAll, showIcon = true } ) {
}

const { sticky, status } = post;
let text, classModifier, icon;
let text;
let classModifier;
let icon;
if ( sticky ) {
text = translate( 'Sticky' );
classModifier = 'is-sticky';
Expand Down
12 changes: 6 additions & 6 deletions client/blocks/product-purchase-features-list/custom-css.jsx
Expand Up @@ -21,12 +21,12 @@ function isCustomizeEnabled() {
}

function getEditCSSLink( selectedSite ) {
const adminUrl = selectedSite.URL + '/wp-admin/',
customizerInAdmin =
adminUrl +
'customize.php?return=' +
encodeURIComponent( window.location.href ) +
'&section=jetpack_custom_css';
const adminUrl = selectedSite.URL + '/wp-admin/';
const customizerInAdmin =
adminUrl +
'customize.php?return=' +
encodeURIComponent( window.location.href ) +
'&section=jetpack_custom_css';

return isCustomizeEnabled() ? '/customize/custom-css/' + selectedSite.slug : customizerInAdmin;
}
Expand Down