Fix ES6 keyword-spacing eslint rule [MAILPOET-1082]

This commit is contained in:
stoletniy
2017-09-18 18:20:55 +03:00
parent 0cdae52c66
commit 44d0341fb2
26 changed files with 81 additions and 82 deletions

View File

@ -40,7 +40,6 @@
"no-bitwise": 0,
"arrow-body-style": 0,
"prefer-template": 0,
"keyword-spacing": 0,
"default-case": 0,
"array-callback-return": 0,
"consistent-return": 0,

View File

@ -123,7 +123,7 @@ define([
? this.props.item[this.props.field.name].trim()
: '';
if(value === '') {
if (value === '') {
return;
}
@ -140,7 +140,7 @@ define([
let value;
switch(dateType) {
switch (dateType) {
case 'year_month_day':
value = {
year: this.state.year,
@ -202,7 +202,7 @@ define([
const dateSelects = dateFormats[dateType][0].split('/');
const fields = dateSelects.map((type) => {
switch(type) {
switch (type) {
case 'YYYY':
return (<FormFieldDateYear
onValueChange={this.onValueChange.bind(this)}

View File

@ -23,7 +23,7 @@ define([
const FormField = React.createClass({
renderField: function (data, inline = false) {
let description = false;
if(data.field.description) {
if (data.field.description) {
description = (
<p className="description">{ data.field.description }</p>
);
@ -32,11 +32,11 @@ define([
let field = false;
let dataField = data.field;
if(data.field['field'] !== undefined) {
if (data.field['field'] !== undefined) {
dataField = jQuery.merge(dataField, data.field.field);
}
switch(dataField.type) {
switch (dataField.type) {
case 'text':
field = (<FormFieldText {...data} />);
break;
@ -70,7 +70,7 @@ define([
break;
}
if(inline === true) {
if (inline === true) {
return (
<span key={'field-' + (data.index || 0)}>
{ field }
@ -89,7 +89,7 @@ define([
render: function () {
let field = false;
if(this.props.field['fields'] !== undefined) {
if (this.props.field['fields'] !== undefined) {
field = this.props.field.fields.map((subfield, index) => {
return this.renderField({
index: index,
@ -103,7 +103,7 @@ define([
}
let tip = false;
if(this.props.field.tip) {
if (this.props.field.tip) {
tip = (
<p className="description">{ this.props.field.tip }</p>
);

View File

@ -26,12 +26,12 @@ define([
return (this.state.select2 === true);
},
componentDidMount: function () {
if(this.allowMultipleValues()) {
if (this.allowMultipleValues()) {
this.setupSelect2();
}
},
componentDidUpdate: function (prevProps) {
if(
if (
(this.props.item !== undefined && prevProps.item !== undefined)
&& (this.props.item.id !== prevProps.item.id)
) {
@ -41,27 +41,27 @@ define([
}
},
componentWillUnmount: function () {
if(this.allowMultipleValues()) {
if (this.allowMultipleValues()) {
this.destroySelect2();
}
},
destroySelect2: function () {
if(this.isSelect2Initialized()) {
if (this.isSelect2Initialized()) {
jQuery('#'+this.refs.select.id).select2('destroy');
}
},
setupSelect2: function () {
if(this.isSelect2Initialized()) {
if (this.isSelect2Initialized()) {
return;
}
const select2 = jQuery('#'+this.refs.select.id).select2({
width: (this.props.width || ''),
templateResult: function (item) {
if(item.element && item.element.selected) {
if (item.element && item.element.selected) {
return null;
} else {
if(item.title) {
if (item.title) {
return item.title;
} else {
return item.text;
@ -75,7 +75,7 @@ define([
hasRemoved = true;
});
select2.on('select2:opening', (e) => {
if(hasRemoved === true) {
if (hasRemoved === true) {
hasRemoved = false;
e.preventDefault();
}
@ -86,9 +86,9 @@ define([
this.setState({ select2: true });
},
getSelectedValues: function () {
if(this.props.field['selected'] !== undefined) {
if (this.props.field['selected'] !== undefined) {
return this.props.field['selected'](this.props.item);
} else if(this.props.item !== undefined && this.props.field.name !== undefined) {
} else if (this.props.item !== undefined && this.props.field.name !== undefined) {
if (this.allowMultipleValues()) {
if (Array.isArray(this.props.item[this.props.field.name])) {
return this.props.item[this.props.field.name].map((item) => {
@ -102,11 +102,11 @@ define([
return null;
},
loadCachedItems: function () {
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
if (typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
let items = window['mailpoet_'+this.props.field.endpoint];
if(this.props.field['filter'] !== undefined) {
if (this.props.field['filter'] !== undefined) {
items = items.filter(this.props.field.filter);
}
@ -117,8 +117,8 @@ define([
},
handleChange: function (e) {
let value;
if(this.props.onValueChange !== undefined) {
if(this.props.field.multiple) {
if (this.props.onValueChange !== undefined) {
if (this.props.field.multiple) {
value = jQuery('#'+this.refs.select.id).val();
} else {
value = e.target.value;
@ -133,19 +133,19 @@ define([
}
},
getLabel: function (item) {
if(this.props.field['getLabel'] !== undefined) {
if (this.props.field['getLabel'] !== undefined) {
return this.props.field.getLabel(item, this.props.item);
}
return item.name;
},
getSearchLabel: function (item) {
if(this.props.field['getSearchLabel'] !== undefined) {
if (this.props.field['getSearchLabel'] !== undefined) {
return this.props.field.getSearchLabel(item, this.props.item);
}
return null;
},
getValue: function (item) {
if(this.props.field['getValue'] !== undefined) {
if (this.props.field['getValue'] !== undefined) {
return this.props.field.getValue(item, this.props.item);
}
return item.id;
@ -154,7 +154,7 @@ define([
// this function may be used to transform the placeholder value into
// desired value.
transformChangedValue: function (value) {
if(typeof this.props.field['transformChangedValue'] === 'function') {
if (typeof this.props.field['transformChangedValue'] === 'function') {
return this.props.field.transformChangedValue.call(this, value);
} else {
return value;

View File

@ -39,8 +39,8 @@ define(
return this.props.errors ? this.props.errors : this.state.errors;
},
componentDidMount: function () {
if(this.isMounted()) {
if(this.props.params.id !== undefined) {
if (this.isMounted()) {
if (this.props.params.id !== undefined) {
this.loadItem(this.props.params.id);
} else {
this.setState({
@ -50,7 +50,7 @@ define(
}
},
componentWillReceiveProps: function (props) {
if(props.params.id === undefined) {
if (props.params.id === undefined) {
this.setState({
loading: false,
item: {},
@ -90,8 +90,8 @@ define(
e.preventDefault();
// handle validation
if(this.props.isValid !== undefined) {
if(this.props.isValid() === false) {
if (this.props.isValid !== undefined) {
if (this.props.isValid() === false) {
return;
}
}
@ -101,7 +101,7 @@ define(
// only get values from displayed fields
const item = {};
this.props.fields.map((field) => {
if(field['fields'] !== undefined) {
if (field['fields'] !== undefined) {
field.fields.map((subfield) => {
item[subfield.name] = this.state.item[subfield.name];
});
@ -110,7 +110,7 @@ define(
}
});
// set id if specified
if(this.props.params.id !== undefined) {
if (this.props.params.id !== undefined) {
item.id = this.props.params.id;
}
@ -122,19 +122,19 @@ define(
}).always(() => {
this.setState({ loading: false });
}).done(() => {
if(this.props.onSuccess !== undefined) {
if (this.props.onSuccess !== undefined) {
this.props.onSuccess();
} else {
this.context.router.push('/');
}
if(this.props.params.id !== undefined) {
if (this.props.params.id !== undefined) {
this.props.messages.onUpdate();
} else {
this.props.messages.onCreate();
}
}).fail((response) => {
if(response.errors.length > 0) {
if (response.errors.length > 0) {
this.setState({ errors: response.errors });
}
});
@ -156,7 +156,7 @@ define(
},
render: function () {
let errors;
if(this.getErrors() !== undefined) {
if (this.getErrors() !== undefined) {
errors = this.getErrors().map((error, index) => {
return (
<p key={'error-'+index} className="mailpoet_error">
@ -202,7 +202,7 @@ define(
});
let actions = false;
if(this.props.children) {
if (this.props.children) {
actions = this.props.children;
} else {
actions = (

View File

@ -14,7 +14,7 @@ const App = React.createClass({
const container = document.getElementById('forms_container');
if(container) {
if (container) {
ReactDOM.render((
<Router history={history}>
<Route path="/" component={App}>

View File

@ -6,11 +6,11 @@ function Tooltip(props) {
let tooltipId = props.tooltipId;
let tooltip = props.tooltip;
// tooltip ID must be unique, defaults to tooltip text
if(!props.tooltipId && typeof props.tooltip === 'string') {
if (!props.tooltipId && typeof props.tooltip === 'string') {
tooltipId = props.tooltip;
}
if(typeof props.tooltip === 'string') {
if (typeof props.tooltip === 'string') {
tooltip = (<span
style={{
pointerEvents: 'all',

View File

@ -16,7 +16,7 @@ const App = React.createClass({
const container = document.getElementById('help_container');
if(container) {
if (container) {
ReactDOM.render((
<Router history={history}>

View File

@ -21,7 +21,7 @@ define([
const action = this.getSelectedAction();
// action on select callback
if(action !== null && action['onSelect'] !== undefined) {
if (action !== null && action['onSelect'] !== undefined) {
this.setState({
extra: action.onSelect(e),
});
@ -33,7 +33,7 @@ define([
const action = this.getSelectedAction();
if(action === null) {
if (action === null) {
return;
}
@ -48,11 +48,11 @@ define([
data.action = this.state.action;
let onSuccess = function () {};
if(action['onSuccess'] !== undefined) {
if (action['onSuccess'] !== undefined) {
onSuccess = action.onSuccess;
}
if(data.action) {
if (data.action) {
const promise = this.props.onBulkAction(selected_ids, data);
if (promise !== false) {
promise.then(onSuccess);
@ -66,19 +66,19 @@ define([
},
getSelectedAction: function () {
const selected_action = this.refs.action.value;
if(selected_action.length > 0) {
if (selected_action.length > 0) {
const action = this.props.bulk_actions.filter((action) => {
return (action.name === selected_action);
});
if(action.length > 0) {
if (action.length > 0) {
return action[0];
}
}
return null;
},
render: function () {
if(this.props.bulk_actions.length === 0) {
if (this.props.bulk_actions.length === 0) {
return null;
}

View File

@ -6,7 +6,7 @@ define(['react', 'classnames'], (React, classNames) => {
},
render: function () {
const groups = this.props.groups.map((group, index) => {
if(group.name === 'trash' && group.count === 0) {
if (group.name === 'trash' && group.count === 0) {
return false;
}

View File

@ -26,7 +26,7 @@ const ListingHeader = React.createClass({
let checkbox;
if(this.props.is_selectable === true) {
if (this.props.is_selectable === true) {
checkbox = (
<th
className="manage-column column-cb check-column">
@ -68,7 +68,7 @@ const ListingColumn = React.createClass({
);
let label;
if(this.props.column.sortable === true) {
if (this.props.column.sortable === true) {
label = (
<a onClick={this.handleSort}>
<span>{ this.props.column.label }</span>

View File

@ -321,7 +321,7 @@ const Listing = React.createClass({
if (params.splat) {
params.splat.split('/').map((param) => {
const [key, value] = this.getParam(param);
switch(key) {
switch (key) {
case 'filter':
const filters = {};
value.split('&').map((pair) => {
@ -489,7 +489,7 @@ const Listing = React.createClass({
}
});
}).fail((response) => {
if(response.errors.length > 0) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
@ -631,7 +631,7 @@ const Listing = React.createClass({
}).done(() => {
this.getItems();
}).fail((response) => {
if(response.errors.length > 0) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }

View File

@ -41,7 +41,7 @@ define([
return Math.min(Math.max(1, Math.abs(~~page)), this.getLastPage());
},
handleSetManualPage: function (e) {
if(e.which === 13) {
if (e.which === 13) {
this.setPage(this.state.page);
}
},
@ -57,7 +57,7 @@ define([
return Math.ceil(this.props.count / this.props.limit);
},
render: function () {
if(this.props.count === 0) {
if (this.props.count === 0) {
return false;
} else {
let pagination = false;
@ -74,8 +74,8 @@ define([
<span aria-hidden="true" className="tablenav-pages-navspan">»</span>
);
if(this.props.limit > 0 && this.props.count > this.props.limit) {
if(this.props.page > 1) {
if (this.props.limit > 0 && this.props.count > this.props.limit) {
if (this.props.page > 1) {
previousPage = (
<a href="javascript:;"
onClick={this.setPreviousPage}
@ -86,7 +86,7 @@ define([
);
}
if(this.props.page > 2) {
if (this.props.page > 2) {
firstPage = (
<a href="javascript:;"
onClick={this.setFirstPage}
@ -97,7 +97,7 @@ define([
);
}
if(this.props.page < this.getLastPage()) {
if (this.props.page < this.getLastPage()) {
nextPage = (
<a href="javascript:;"
onClick={this.setNextPage}
@ -108,7 +108,7 @@ define([
);
}
if(this.props.page < this.getLastPage() - 1) {
if (this.props.page < this.getLastPage() - 1) {
lastPage = (
<a href="javascript:;"
onClick={this.setLastPage}
@ -120,7 +120,7 @@ define([
}
let pageValue = this.props.page;
if(this.state.page !== null) {
if (this.state.page !== null) {
pageValue = this.state.page;
}

View File

@ -17,7 +17,7 @@ define([
this.refs.search.value = nextProps.search;
},
render: function () {
if(this.props.search === false) {
if (this.props.search === false) {
return false;
} else {
return (

View File

@ -46,7 +46,7 @@ define(
let label = step.label;
if(step['link'] !== undefined && this.props.step !== step.name) {
if (step['link'] !== undefined && this.props.step !== step.name) {
label = (
<Link to={step.link}>{ step.label }</Link>
);

View File

@ -203,7 +203,7 @@ const NewsletterListNotification = React.createClass({
});
// check if the user has specified segments to send to
if(segments.length === 0) {
if (segments.length === 0) {
return (
<span className="mailpoet_error">
{ MailPoet.I18n.t('sendingToSegmentsNotSpecified') }

View File

@ -98,7 +98,7 @@ const bulk_actions = [
];
const confirmEdit = (newsletter) => {
if(
if (
!newsletter.queue
|| newsletter.status != 'sending'
|| newsletter.queue.status !== null

View File

@ -26,7 +26,7 @@ const App = React.createClass({
const container = document.getElementById('newsletters_container');
if(container) {
if (container) {
let extra_routes = [];
extra_routes = Hooks.applyFilters('mailpoet_newsletters_before_router', extra_routes);

View File

@ -46,7 +46,7 @@ define(
return type.getSendButtonOptions(this.state.item);
},
getSubtype: function (newsletter) {
switch(newsletter.type) {
switch (newsletter.type) {
case 'notification': return NotificationNewsletterFields;
case 'welcome': return WelcomeNewsletterFields;
default: return StandardNewsletterFields;
@ -56,7 +56,7 @@ define(
return jQuery('#mailpoet_newsletter').parsley().isValid();
},
componentDidMount: function () {
if(this.isMounted()) {
if (this.isMounted()) {
this.loadItem(this.props.params.id);
}
jQuery('#mailpoet_newsletter').parsley();
@ -92,7 +92,7 @@ define(
handleSend: function (e) {
e.preventDefault();
if(!this.isValid()) {
if (!this.isValid()) {
jQuery('#mailpoet_newsletter').parsley().validate();
} else {
this._save(e).done(() => {
@ -174,7 +174,7 @@ define(
},
handleResume: function (e) {
e.preventDefault();
if(!this.isValid()) {
if (!this.isValid()) {
jQuery('#mailpoet_newsletter').parsley().validate();
} else {
this._save(e).done(() => {

View File

@ -132,7 +132,7 @@ define(
});
}
}).fail((response) => {
if(response.errors.length > 0) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
@ -175,7 +175,7 @@ define(
},
handleDeleteTemplate: function (template) {
this.setState({ loading: true });
if(
if (
window.confirm(
(
MailPoet.I18n.t('confirmTemplateDeletion')

View File

@ -18,7 +18,7 @@ define(
router: React.PropTypes.object.isRequired,
},
setupNewsletter: function (type) {
if(type !== undefined) {
if (type !== undefined) {
this.context.router.push(`/new/${type}`);
MailPoet.trackEvent('Emails > Type selected', {
'MailPoet Free version': window.mailpoet_version,

View File

@ -164,7 +164,7 @@ const item_actions = [
refresh();
}).fail((response) => {
MailPoet.Modal.loading(false);
if(response.errors.length > 0) {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }

View File

@ -16,7 +16,7 @@ const App = React.createClass({
const container = document.getElementById('segments_container');
if(container) {
if (container) {
ReactDOM.render((
<Router history={history}>
<Route path="/" component={App}>

View File

@ -123,7 +123,7 @@ define(
}
// add placeholders for selects (date, select)
switch(custom_field.type) {
switch (custom_field.type) {
case 'date':
field.year_placeholder = MailPoet.I18n.t('year');
field.month_placeholder = MailPoet.I18n.t('month');

View File

@ -262,7 +262,7 @@ const SubscriberList = React.createClass({
let status = '';
switch(subscriber.status) {
switch (subscriber.status) {
case 'subscribed':
status = MailPoet.I18n.t('subscribed');
break;

View File

@ -15,7 +15,7 @@ const App = React.createClass({
const container = document.getElementById('subscribers_container');
if(container) {
if (container) {
ReactDOM.render((
<Router history={history}>
<Route path="/" component={App}>