ESLint rules

This commit is contained in:
Amine Ben hammou
2018-04-18 19:24:38 +02:00
parent 2c96f1902e
commit 1855a3a481

View File

@@ -72,14 +72,11 @@ const ListingItem = React.createClass({
if (action.name === 'trash') { if (action.name === 'trash') {
customAction = ( customAction = (
<span key={`action-${index}`} className="trash"> <span key={`action-${action.name}`} className="trash">
{(!isFirst) ? ' | ' : ''} {(!isFirst) ? ' | ' : ''}
<a <a
href="javascript:;" href="javascript:;"
onClick={this.handleTrashItem.bind( onClick={() => this.handleTrashItem(this.props.item.id)}
null,
this.props.item.id
)}
> >
{MailPoet.I18n.t('moveToTrash')} {MailPoet.I18n.t('moveToTrash')}
</a> </a>
@@ -89,7 +86,8 @@ const ListingItem = React.createClass({
customAction = ( customAction = (
<span <span
onClick={this.props.onRefreshItems} onClick={this.props.onRefreshItems}
key={`action-${index}`} className={action.name} key={`action-${action.name}`}
className={action.name}
role="button" role="button"
tabIndex={index} tabIndex={index}
> >
@@ -100,7 +98,8 @@ const ListingItem = React.createClass({
} else if (action.link) { } else if (action.link) {
customAction = ( customAction = (
<span <span
key={`action-${index}`} className={action.name} key={`action-${action.name}`}
className={action.name}
> >
{(!isFirst) ? ' | ' : ''} {(!isFirst) ? ' | ' : ''}
{ action.link(this.props.item) } { action.link(this.props.item) }
@@ -109,15 +108,15 @@ const ListingItem = React.createClass({
} else { } else {
customAction = ( customAction = (
<span <span
key={`action-${index}`} className={action.name} key={`action-${action.name}`}
className={action.name}
> >
{(!isFirst) ? ' | ' : ''} {(!isFirst) ? ' | ' : ''}
<a href="javascript:;" onClick={ <a
href="javascript:;"
onClick={
(action.onClick !== undefined) (action.onClick !== undefined)
? action.onClick.bind(null, ? () => action.onClick(this.props.item, this.props.onRefreshItems)
this.props.item,
this.props.onRefreshItems
)
: false : false
} }
>{ action.label }</a> >{ action.label }</a>
@@ -148,10 +147,7 @@ const ListingItem = React.createClass({
<span> <span>
<a <a
href="javascript:;" href="javascript:;"
onClick={this.handleRestoreItem.bind( onClick={() => this.handleRestoreItem(this.props.item.id)}
null,
this.props.item.id
)}
>{MailPoet.I18n.t('restore')}</a> >{MailPoet.I18n.t('restore')}</a>
</span> </span>
{ ' | ' } { ' | ' }
@@ -159,16 +155,14 @@ const ListingItem = React.createClass({
<a <a
className="submitdelete" className="submitdelete"
href="javascript:;" href="javascript:;"
onClick={this.handleDeleteItem.bind( onClick={() => this.handleDeleteItem(this.props.item.id)}
null,
this.props.item.id
)}
>{MailPoet.I18n.t('deletePermanently')}</a> >{MailPoet.I18n.t('deletePermanently')}</a>
</span> </span>
</div> </div>
<button <button
onClick={this.handleToggleItem.bind(null, this.props.item.id)} onClick={() => this.handleToggleItem(this.props.item.id)}
className="toggle-row" type="button" className="toggle-row"
type="button"
> >
<span className="screen-reader-text">{MailPoet.I18n.t('showMoreDetails')}</span> <span className="screen-reader-text">{MailPoet.I18n.t('showMoreDetails')}</span>
</button> </button>
@@ -181,8 +175,9 @@ const ListingItem = React.createClass({
{ itemActions } { itemActions }
</div> </div>
<button <button
onClick={this.handleToggleItem.bind(null, this.props.item.id)} onClick={() => this.handleToggleItem(this.props.item.id)}
className="toggle-row" type="button" className="toggle-row"
type="button"
> >
<span className="screen-reader-text">{MailPoet.I18n.t('showMoreDetails')}</span> <span className="screen-reader-text">{MailPoet.I18n.t('showMoreDetails')}</span>
</button> </button>
@@ -269,7 +264,7 @@ const ListingItems = React.createClass({
</td> </td>
</tr> </tr>
{this.props.items.map((item, index) => { {this.props.items.map((item) => {
const renderItem = item; const renderItem = item;
renderItem.id = parseInt(item.id, 10); renderItem.id = parseInt(item.id, 10);
renderItem.selected = (this.props.selected_ids.indexOf(renderItem.id) !== -1); renderItem.selected = (this.props.selected_ids.indexOf(renderItem.id) !== -1);
@@ -287,7 +282,7 @@ const ListingItems = React.createClass({
is_selectable={this.props.is_selectable} is_selectable={this.props.is_selectable}
item_actions={this.props.item_actions} item_actions={this.props.item_actions}
group={this.props.group} group={this.props.group}
key={`item-${renderItem.id}-${index}`} key={`item-${renderItem.id}-${item.id}`}
item={renderItem} item={renderItem}
/> />
); );
@@ -439,7 +434,7 @@ const Listing = React.createClass({
return ret; return ret;
}, },
componentDidMount: function componentDidMount() { componentDidMount: function componentDidMount() {
if (this.isMounted()) { this.isComponentMounted = true;
const params = this.props.params || {}; const params = this.props.params || {};
this.initWithParams(params); this.initWithParams(params);
@@ -448,14 +443,16 @@ const Listing = React.createClass({
this.getItems(); this.getItems();
}); });
} }
} },
componentWillUnmount: function componentWillUnmount() {
this.isComponentMounted = false;
}, },
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
const params = nextProps.params || {}; const params = nextProps.params || {};
this.initWithParams(params); this.initWithParams(params);
}, },
getItems: function getItems() { getItems: function getItems() {
if (this.isMounted()) { if (this.isComponentMounted) {
this.setState({ loading: true }); this.setState({ loading: true });
this.clearSelection(); this.clearSelection();