diff --git a/.eslintrc.es6.json b/.eslintrc.es6.json index b67c6de5f3..3816843181 100644 --- a/.eslintrc.es6.json +++ b/.eslintrc.es6.json @@ -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, diff --git a/assets/js/src/form/fields/date.jsx b/assets/js/src/form/fields/date.jsx index 06880238d1..3fa778a765 100644 --- a/assets/js/src/form/fields/date.jsx +++ b/assets/js/src/form/fields/date.jsx @@ -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 ({ data.field.description }

); @@ -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 = (); break; @@ -70,7 +70,7 @@ define([ break; } - if(inline === true) { + if (inline === true) { return ( { 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 = (

{ this.props.field.tip }

); diff --git a/assets/js/src/form/fields/selection.jsx b/assets/js/src/form/fields/selection.jsx index 9ec6057009..9816d47f3a 100644 --- a/assets/js/src/form/fields/selection.jsx +++ b/assets/js/src/form/fields/selection.jsx @@ -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; diff --git a/assets/js/src/form/form.jsx b/assets/js/src/form/form.jsx index 00a6cec0a7..7ef4bb7ca0 100644 --- a/assets/js/src/form/form.jsx +++ b/assets/js/src/form/form.jsx @@ -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 (

@@ -202,7 +202,7 @@ define( }); let actions = false; - if(this.props.children) { + if (this.props.children) { actions = this.props.children; } else { actions = ( diff --git a/assets/js/src/forms/forms.jsx b/assets/js/src/forms/forms.jsx index f6414c3ac6..88bb6b2e20 100644 --- a/assets/js/src/forms/forms.jsx +++ b/assets/js/src/forms/forms.jsx @@ -14,7 +14,7 @@ const App = React.createClass({ const container = document.getElementById('forms_container'); -if(container) { +if (container) { ReactDOM.render(( diff --git a/assets/js/src/help-tooltip.jsx b/assets/js/src/help-tooltip.jsx index 7a555c9312..b02bd6e87b 100644 --- a/assets/js/src/help-tooltip.jsx +++ b/assets/js/src/help-tooltip.jsx @@ -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 = ( diff --git a/assets/js/src/listing/bulk_actions.jsx b/assets/js/src/listing/bulk_actions.jsx index 724407f65b..27031b1e4e 100644 --- a/assets/js/src/listing/bulk_actions.jsx +++ b/assets/js/src/listing/bulk_actions.jsx @@ -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; } diff --git a/assets/js/src/listing/groups.jsx b/assets/js/src/listing/groups.jsx index 725de12c53..d0bc261e88 100644 --- a/assets/js/src/listing/groups.jsx +++ b/assets/js/src/listing/groups.jsx @@ -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; } diff --git a/assets/js/src/listing/header.jsx b/assets/js/src/listing/header.jsx index 3731e7a605..f2247eb846 100644 --- a/assets/js/src/listing/header.jsx +++ b/assets/js/src/listing/header.jsx @@ -26,7 +26,7 @@ const ListingHeader = React.createClass({ let checkbox; - if(this.props.is_selectable === true) { + if (this.props.is_selectable === true) { checkbox = ( @@ -68,7 +68,7 @@ const ListingColumn = React.createClass({ ); let label; - if(this.props.column.sortable === true) { + if (this.props.column.sortable === true) { label = ( { this.props.column.label } diff --git a/assets/js/src/listing/listing.jsx b/assets/js/src/listing/listing.jsx index ae8f1c2da7..81e98178e0 100644 --- a/assets/js/src/listing/listing.jsx +++ b/assets/js/src/listing/listing.jsx @@ -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 } diff --git a/assets/js/src/listing/pages.jsx b/assets/js/src/listing/pages.jsx index 7e96349e18..8ffba8a4f7 100644 --- a/assets/js/src/listing/pages.jsx +++ b/assets/js/src/listing/pages.jsx @@ -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([ ); - 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 = ( 2) { + if (this.props.page > 2) { firstPage = ( { step.label } ); diff --git a/assets/js/src/newsletters/listings/notification.jsx b/assets/js/src/newsletters/listings/notification.jsx index 6a22b94fb0..daa70d538b 100644 --- a/assets/js/src/newsletters/listings/notification.jsx +++ b/assets/js/src/newsletters/listings/notification.jsx @@ -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 ( { MailPoet.I18n.t('sendingToSegmentsNotSpecified') } diff --git a/assets/js/src/newsletters/listings/standard.jsx b/assets/js/src/newsletters/listings/standard.jsx index b1eef2d1c6..b45f9404bc 100644 --- a/assets/js/src/newsletters/listings/standard.jsx +++ b/assets/js/src/newsletters/listings/standard.jsx @@ -98,7 +98,7 @@ const bulk_actions = [ ]; const confirmEdit = (newsletter) => { - if( + if ( !newsletter.queue || newsletter.status != 'sending' || newsletter.queue.status !== null diff --git a/assets/js/src/newsletters/newsletters.jsx b/assets/js/src/newsletters/newsletters.jsx index f04a1ecbb2..6ad74ba6eb 100644 --- a/assets/js/src/newsletters/newsletters.jsx +++ b/assets/js/src/newsletters/newsletters.jsx @@ -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); diff --git a/assets/js/src/newsletters/send.jsx b/assets/js/src/newsletters/send.jsx index c0dc3517bb..a2edb47c6d 100644 --- a/assets/js/src/newsletters/send.jsx +++ b/assets/js/src/newsletters/send.jsx @@ -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(() => { diff --git a/assets/js/src/newsletters/templates.jsx b/assets/js/src/newsletters/templates.jsx index c66f2e4e50..76f893d5c4 100644 --- a/assets/js/src/newsletters/templates.jsx +++ b/assets/js/src/newsletters/templates.jsx @@ -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') diff --git a/assets/js/src/newsletters/types.jsx b/assets/js/src/newsletters/types.jsx index 9d70e6d616..1cf6818a85 100644 --- a/assets/js/src/newsletters/types.jsx +++ b/assets/js/src/newsletters/types.jsx @@ -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, diff --git a/assets/js/src/segments/list.jsx b/assets/js/src/segments/list.jsx index 7e75a55551..f727d0f1d7 100644 --- a/assets/js/src/segments/list.jsx +++ b/assets/js/src/segments/list.jsx @@ -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 } diff --git a/assets/js/src/segments/segments.jsx b/assets/js/src/segments/segments.jsx index 523ffcac42..e2c393908e 100644 --- a/assets/js/src/segments/segments.jsx +++ b/assets/js/src/segments/segments.jsx @@ -16,7 +16,7 @@ const App = React.createClass({ const container = document.getElementById('segments_container'); -if(container) { +if (container) { ReactDOM.render(( diff --git a/assets/js/src/subscribers/form.jsx b/assets/js/src/subscribers/form.jsx index d45f5a8ff6..b1d4c26e41 100644 --- a/assets/js/src/subscribers/form.jsx +++ b/assets/js/src/subscribers/form.jsx @@ -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'); diff --git a/assets/js/src/subscribers/list.jsx b/assets/js/src/subscribers/list.jsx index 5a5a33988a..667327e960 100644 --- a/assets/js/src/subscribers/list.jsx +++ b/assets/js/src/subscribers/list.jsx @@ -262,7 +262,7 @@ const SubscriberList = React.createClass({ let status = ''; - switch(subscriber.status) { + switch (subscriber.status) { case 'subscribed': status = MailPoet.I18n.t('subscribed'); break; diff --git a/assets/js/src/subscribers/subscribers.jsx b/assets/js/src/subscribers/subscribers.jsx index 38d84fd13a..2bcfb5914a 100644 --- a/assets/js/src/subscribers/subscribers.jsx +++ b/assets/js/src/subscribers/subscribers.jsx @@ -15,7 +15,7 @@ const App = React.createClass({ const container = document.getElementById('subscribers_container'); -if(container) { +if (container) { ReactDOM.render((