fix(lint): Fix new eslint rule introduced with babel-eslint upgrade.

See https://phabricator.babeljs.io/T6925
This commit is contained in:
Juan Tejada 2016-02-01 20:06:29 -08:00
parent d9c4739f78
commit 6a14d5b561
8 changed files with 80 additions and 80 deletions

View file

@ -7,7 +7,7 @@ class TemplatePicker extends React.Component {
static propTypes = { static propTypes = {
draftClientId: React.PropTypes.string, draftClientId: React.PropTypes.string,
} };
constructor() { constructor() {
super(); super();
@ -49,20 +49,20 @@ class TemplatePicker extends React.Component {
searchValue: newSearch, searchValue: newSearch,
templates: this._filteredTemplates(newSearch), templates: this._filteredTemplates(newSearch),
}); });
} };
_onChooseTemplate = (template) => { _onChooseTemplate = (template) => {
Actions.insertTemplateId({templateId: template.id, draftClientId: this.props.draftClientId}); Actions.insertTemplateId({templateId: template.id, draftClientId: this.props.draftClientId});
return this.refs.popover.close(); return this.refs.popover.close();
} };
_onManageTemplates = () => { _onManageTemplates = () => {
return Actions.showTemplates(); return Actions.showTemplates();
} };
_onNewTemplate = () => { _onNewTemplate = () => {
return Actions.createTemplate({draftClientId: this.props.draftClientId}); return Actions.createTemplate({draftClientId: this.props.draftClientId});
} };
render() { render() {
const button = ( const button = (

View file

@ -1,11 +1,11 @@
import {DraftStore, React} from 'nylas-exports'; import {DraftStore, React} from 'nylas-exports';
class TemplateStatusBar extends React.Component { class TemplateStatusBar extends React.Component {
static displayName = 'TemplateStatusBar' static displayName = 'TemplateStatusBar';
static propTypes = { static propTypes = {
draftClientId: React.PropTypes.string, draftClientId: React.PropTypes.string,
} };
constructor() { constructor() {
super(); super();
@ -34,7 +34,7 @@ class TemplateStatusBar extends React.Component {
textAlign: 'center', textAlign: 'center',
width: 580, width: 580,
margin: 'auto', margin: 'auto',
} };
_onDraftChange() { _onDraftChange() {
this.setState({draft: this._proxy.draft()}); this.setState({draft: this._proxy.draft()});

View file

@ -28,7 +28,7 @@ import {ScrollRegion, Contenteditable} from 'nylas-component-kit';
*/ */
class ComposerEditor extends Component { class ComposerEditor extends Component {
static displayName = 'ComposerEditor' static displayName = 'ComposerEditor';
/** /**
* This function will return the {DOMRect} for the parent component * This function will return the {DOMRect} for the parent component
@ -78,7 +78,7 @@ class ComposerEditor extends Component {
scrollTo: PropTypes.func, scrollTo: PropTypes.func,
getComposerBoundingRect: PropTypes.func, getComposerBoundingRect: PropTypes.func,
}), }),
} };
constructor(props) { constructor(props) {
super(props); super(props);
@ -193,7 +193,7 @@ class ComposerEditor extends Component {
clientId: this.props.draftClientId, clientId: this.props.draftClientId,
position: ScrollRegion.ScrollPosition.Bottom, position: ScrollRegion.ScrollPosition.Bottom,
}); });
} };
/** /**
* @private * @private
@ -208,7 +208,7 @@ class ComposerEditor extends Component {
const parentRect = this.props.parentActions.getComposerBoundingRect(); const parentRect = this.props.parentActions.getComposerBoundingRect();
const selfRect = editableNode.getBoundingClientRect(); const selfRect = editableNode.getBoundingClientRect();
return Math.abs(parentRect.bottom - selfRect.bottom) <= 250; return Math.abs(parentRect.bottom - selfRect.bottom) <= 250;
} };
/** /**
* @private * @private
@ -253,14 +253,14 @@ class ComposerEditor extends Component {
this.props.parentActions.scrollTo({rect}); this.props.parentActions.scrollTo({rect});
} }
} }
} };
// Handlers // Handlers
_onExtensionsChanged = ()=> { _onExtensionsChanged = ()=> {
this.setState({extensions: ExtensionRegistry.Composer.extensions()}); this.setState({extensions: ExtensionRegistry.Composer.extensions()});
} };
// Renderers // Renderers

View file

@ -8,7 +8,7 @@ class PreferencesAccountDetails extends Component {
static propTypes = { static propTypes = {
account: PropTypes.object, account: PropTypes.object,
onAccountUpdated: PropTypes.func.isRequired, onAccountUpdated: PropTypes.func.isRequired,
} };
constructor(props) { constructor(props) {
super(props); super(props);
@ -60,14 +60,14 @@ class PreferencesAccountDetails extends Component {
_saveChanges = ()=> { _saveChanges = ()=> {
this.props.onAccountUpdated(this.props.account, this.state); this.props.onAccountUpdated(this.props.account, this.state);
} };
// Handlers // Handlers
_onAccountLabelUpdated = (event)=> { _onAccountLabelUpdated = (event)=> {
this.setState({label: event.target.value}); this.setState({label: event.target.value});
} };
_onAccountAliasCreated = (newAlias)=> { _onAccountAliasCreated = (newAlias)=> {
const coercedAlias = this._makeAlias(newAlias); const coercedAlias = this._makeAlias(newAlias);
@ -75,7 +75,7 @@ class PreferencesAccountDetails extends Component {
this.setState({aliases}, ()=> { this.setState({aliases}, ()=> {
this._saveChanges(); this._saveChanges();
}); });
} };
_onAccountAliasUpdated = (newAlias, alias, idx)=> { _onAccountAliasUpdated = (newAlias, alias, idx)=> {
const coercedAlias = this._makeAlias(newAlias); const coercedAlias = this._makeAlias(newAlias);
@ -88,7 +88,7 @@ class PreferencesAccountDetails extends Component {
this.setState({aliases, defaultAlias}, ()=> { this.setState({aliases, defaultAlias}, ()=> {
this._saveChanges(); this._saveChanges();
}); });
} };
_onAccountAliasRemoved = (alias, idx)=> { _onAccountAliasRemoved = (alias, idx)=> {
const aliases = this.state.aliases.slice(); const aliases = this.state.aliases.slice();
@ -100,14 +100,14 @@ class PreferencesAccountDetails extends Component {
this.setState({aliases, defaultAlias}, ()=> { this.setState({aliases, defaultAlias}, ()=> {
this._saveChanges(); this._saveChanges();
}); });
} };
_onDefaultAliasSelected = (event)=> { _onDefaultAliasSelected = (event)=> {
const defaultAlias = event.target.value === 'None' ? null : event.target.value; const defaultAlias = event.target.value === 'None' ? null : event.target.value;
this.setState({defaultAlias}, ()=> { this.setState({defaultAlias}, ()=> {
this._saveChanges(); this._saveChanges();
}); });
} };
// Renderers // Renderers

View file

@ -10,7 +10,7 @@ class PreferencesAccountList extends Component {
onReorderAccount: PropTypes.func.isRequired, onReorderAccount: PropTypes.func.isRequired,
onSelectAccount: PropTypes.func.isRequired, onSelectAccount: PropTypes.func.isRequired,
onRemoveAccount: PropTypes.func.isRequired, onRemoveAccount: PropTypes.func.isRequired,
} };
_renderAccount = (account)=> { _renderAccount = (account)=> {
const label = account.label; const label = account.label;
@ -34,7 +34,7 @@ class PreferencesAccountList extends Component {
</Flexbox> </Flexbox>
</div> </div>
); );
} };
render() { render() {
if (!this.props.accounts) { if (!this.props.accounts) {

View file

@ -40,7 +40,7 @@ import React, {Component, PropTypes} from 'react';
* @class EditableList * @class EditableList
*/ */
class EditableList extends Component { class EditableList extends Component {
static displayName = 'EditableList' static displayName = 'EditableList';
/** /**
* If provided, this function will be called when the add button is clicked, * If provided, this function will be called when the add button is clicked,
@ -102,7 +102,7 @@ class EditableList extends Component {
/* Optional, if you choose to control selection externally */ /* Optional, if you choose to control selection externally */
selected: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), selected: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
onSelectItem: PropTypes.func, onSelectItem: PropTypes.func,
} };
static defaultProps = { static defaultProps = {
items: [], items: [],
@ -113,7 +113,7 @@ class EditableList extends Component {
onDeleteItem: ()=> {}, onDeleteItem: ()=> {},
onItemEdited: ()=> {}, onItemEdited: ()=> {},
onItemCreated: ()=> {}, onItemCreated: ()=> {},
} };
constructor(props) { constructor(props) {
super(props); super(props);
@ -132,20 +132,20 @@ class EditableList extends Component {
this.props.onItemCreated(value); this.props.onItemCreated(value);
} }
}); });
} };
_updateItem = (value, originalItem, idx)=> { _updateItem = (value, originalItem, idx)=> {
this._clearEditingState(()=> { this._clearEditingState(()=> {
this.props.onItemEdited(value, originalItem, idx); this.props.onItemEdited(value, originalItem, idx);
}); });
} };
_getSelectedItem = ()=> { _getSelectedItem = ()=> {
if (this.props.onSelectItem) { if (this.props.onSelectItem) {
return this.props.selected; return this.props.selected;
} }
return this.state.selected; return this.state.selected;
} };
_selectItem = (item, idx)=> { _selectItem = (item, idx)=> {
if (this.props.onSelectItem) { if (this.props.onSelectItem) {
@ -153,26 +153,26 @@ class EditableList extends Component {
} else { } else {
this.setState({selected: item}); this.setState({selected: item});
} }
} };
_clearEditingState = (callback)=> { _clearEditingState = (callback)=> {
this._setStateAndFocus({editingIndex: null}, callback); this._setStateAndFocus({editingIndex: null}, callback);
} };
_clearCreatingState = (callback)=> { _clearCreatingState = (callback)=> {
this._setStateAndFocus({creatingItem: false}, callback); this._setStateAndFocus({creatingItem: false}, callback);
} };
_setStateAndFocus = (state, callback = ()=> {})=> { _setStateAndFocus = (state, callback = ()=> {})=> {
this.setState(state, ()=> { this.setState(state, ()=> {
this._focusSelf(); this._focusSelf();
callback(); callback();
}); });
} };
_focusSelf = ()=> { _focusSelf = ()=> {
React.findDOMNode(this).focus(); React.findDOMNode(this).focus();
} };
/** /**
* @private Scrolls to the dom node of the item at the provided index * @private Scrolls to the dom node of the item at the provided index
@ -183,20 +183,20 @@ class EditableList extends Component {
const list = this.refs.itemsWrapper; const list = this.refs.itemsWrapper;
const nodes = React.findDOMNode(list).querySelectorAll('.list-item'); const nodes = React.findDOMNode(list).querySelectorAll('.list-item');
list.scrollTo(nodes[idx]); list.scrollTo(nodes[idx]);
} };
// Handlers // Handlers
_onEditInputBlur = (event, item, idx)=> { _onEditInputBlur = (event, item, idx)=> {
this._updateItem(event.target.value, item, idx); this._updateItem(event.target.value, item, idx);
} };
_onEditInputFocus = (event)=> { _onEditInputFocus = (event)=> {
const input = event.target; const input = event.target;
// Move cursor to the end of the input // Move cursor to the end of the input
input.selectionStart = input.selectionEnd = input.value.length; input.selectionStart = input.selectionEnd = input.value.length;
} };
_onEditInputKeyDown = (event, item, idx)=> { _onEditInputKeyDown = (event, item, idx)=> {
event.stopPropagation(); event.stopPropagation();
@ -205,11 +205,11 @@ class EditableList extends Component {
} else if (event.key === 'Escape') { } else if (event.key === 'Escape') {
this._clearEditingState(); this._clearEditingState();
} }
} };
_onCreateInputBlur = (event)=> { _onCreateInputBlur = (event)=> {
this._createItem(event.target.value); this._createItem(event.target.value);
} };
_onCreateInputKeyDown = (event)=> { _onCreateInputKeyDown = (event)=> {
event.stopPropagation(); event.stopPropagation();
@ -218,15 +218,15 @@ class EditableList extends Component {
} else if (event.key === 'Escape') { } else if (event.key === 'Escape') {
this._clearCreatingState(); this._clearCreatingState();
} }
} };
_onItemClick = (event, item, idx)=> { _onItemClick = (event, item, idx)=> {
this._selectItem(item, idx); this._selectItem(item, idx);
} };
_onItemEdit = (event, item, idx)=> { _onItemEdit = (event, item, idx)=> {
this.setState({editingIndex: idx}); this.setState({editingIndex: idx});
} };
_listKeymapHandlers = ()=> { _listKeymapHandlers = ()=> {
const _shift = (dir) => { const _shift = (dir) => {
@ -249,7 +249,7 @@ class EditableList extends Component {
_shift(1); _shift(1);
}, },
}; };
} };
_onCreateItem = ()=> { _onCreateItem = ()=> {
if (this.props.onCreateItem) { if (this.props.onCreateItem) {
@ -257,7 +257,7 @@ class EditableList extends Component {
} else { } else {
this.setState({creatingItem: true}); this.setState({creatingItem: true});
} }
} };
_onDeleteItem = ()=> { _onDeleteItem = ()=> {
const selectedItem = this._getSelectedItem(); const selectedItem = this._getSelectedItem();
@ -273,7 +273,7 @@ class EditableList extends Component {
this._selectItem(this.props.items[newIndex], newIndex); this._selectItem(this.props.items[newIndex], newIndex);
} }
} }
} };
_onItemDragStart = (event)=> { _onItemDragStart = (event)=> {
if (!this.props.onReorderItem) { if (!this.props.onReorderItem) {
@ -291,7 +291,7 @@ class EditableList extends Component {
event.dataTransfer.setData('editablelist-index', row.dataset.itemIdx); event.dataTransfer.setData('editablelist-index', row.dataset.itemIdx);
event.dataTransfer.setData('editablelist-reactid', wrapperId); event.dataTransfer.setData('editablelist-reactid', wrapperId);
event.dataTransfer.effectAllowed = "move"; event.dataTransfer.effectAllowed = "move";
} };
_onDragOver = (event)=> { _onDragOver = (event)=> {
const wrapperNode = React.findDOMNode(this.refs.itemsWrapper); const wrapperNode = React.findDOMNode(this.refs.itemsWrapper);
@ -317,11 +317,11 @@ class EditableList extends Component {
if (this.state.dropInsertionIndex !== dropInsertionIndex) { if (this.state.dropInsertionIndex !== dropInsertionIndex) {
this.setState({dropInsertionIndex: dropInsertionIndex}); this.setState({dropInsertionIndex: dropInsertionIndex});
} }
} };
_onDragLeave = ()=> { _onDragLeave = ()=> {
this.setState({dropInsertionIndex: -1}); this.setState({dropInsertionIndex: -1});
} };
_onDrop = (event)=> { _onDrop = (event)=> {
if (this.state.dropInsertionIndex !== -1) { if (this.state.dropInsertionIndex !== -1) {
@ -338,7 +338,7 @@ class EditableList extends Component {
this.setState({dropInsertionIndex: -1}); this.setState({dropInsertionIndex: -1});
} }
} }
} };
// Renderers // Renderers
@ -357,7 +357,7 @@ class EditableList extends Component {
onFocus={onInputFocus} onFocus={onInputFocus}
onKeyDown={_.partial(onInputKeyDown, _, item, idx)} /> onKeyDown={_.partial(onInputKeyDown, _, item, idx)} />
); );
} };
/** /**
* @private Will render the create input with the provided input props. * @private Will render the create input with the provided input props.
@ -377,7 +377,7 @@ class EditableList extends Component {
<input {...props}/> <input {...props}/>
</div> </div>
); );
} };
// handlers object for testing // handlers object for testing
_renderItem = (item, idx, {editingIndex} = this.state, handlers = {})=> { _renderItem = (item, idx, {editingIndex} = this.state, handlers = {})=> {
@ -417,7 +417,7 @@ class EditableList extends Component {
onClick={_.partial(onEdit, _, item, idx)} /> onClick={_.partial(onEdit, _, item, idx)} />
</div> </div>
); );
} };
_renderButtons = ()=> { _renderButtons = ()=> {
const deleteClasses = classNames({ const deleteClasses = classNames({
@ -434,13 +434,13 @@ class EditableList extends Component {
</div> </div>
</div> </div>
); );
} };
_renderDropInsertion = ()=> { _renderDropInsertion = ()=> {
return ( return (
<div className="insertion-point"><div></div></div> <div className="insertion-point"><div></div></div>
) )
} };
render() { render() {
let items = this.props.items.map( (item, idx)=> this._renderItem(item, idx)); let items = this.props.items.map( (item, idx)=> this._renderItem(item, idx));

View file

@ -61,7 +61,7 @@ const CounterStyles = {
* @class OutlineViewItem * @class OutlineViewItem
*/ */
class OutlineViewItem extends Component { class OutlineViewItem extends Component {
static displayName = 'OutlineView' static displayName = 'OutlineView';
/** /**
* If provided, this function will be called when receiving a drop. It must * If provided, this function will be called when receiving a drop. It must
@ -129,7 +129,7 @@ class OutlineViewItem extends Component {
onDelete: PropTypes.func, onDelete: PropTypes.func,
onEdited: PropTypes.func, onEdited: PropTypes.func,
}).isRequired, }).isRequired,
} };
constructor(props) { constructor(props) {
@ -174,63 +174,63 @@ class OutlineViewItem extends Component {
return item[method](item, ...args); return item[method](item, ...args);
} }
return undefined; return undefined;
} };
_shouldShowContextMenu = ()=> { _shouldShowContextMenu = ()=> {
return this.props.item.onDelete != null || this.props.item.onEdited != null; return this.props.item.onDelete != null || this.props.item.onEdited != null;
} };
_shouldAcceptDrop = (event)=> { _shouldAcceptDrop = (event)=> {
return this._runCallback('shouldAcceptDrop', event); return this._runCallback('shouldAcceptDrop', event);
} };
_clearEditingState = (event)=> { _clearEditingState = (event)=> {
this.setState({editing: false}); this.setState({editing: false});
this._runCallback('onInputCleared', event); this._runCallback('onInputCleared', event);
} };
// Handlers // Handlers
_onDragStateChange = ({isDropping})=> { _onDragStateChange = ({isDropping})=> {
this.setState({isDropping}); this.setState({isDropping});
} };
_onDrop = (event)=> { _onDrop = (event)=> {
this._runCallback('onDrop', event); this._runCallback('onDrop', event);
} };
_onCollapseToggled = ()=> { _onCollapseToggled = ()=> {
this._runCallback('onCollapseToggled'); this._runCallback('onCollapseToggled');
} };
_onClick = (event)=> { _onClick = (event)=> {
event.preventDefault(); event.preventDefault();
this._runCallback('onSelect'); this._runCallback('onSelect');
} };
_onDelete = ()=> { _onDelete = ()=> {
this._runCallback('onDelete'); this._runCallback('onDelete');
} };
_onEdited = (value)=> { _onEdited = (value)=> {
this._runCallback('onEdited', value); this._runCallback('onEdited', value);
} };
_onEdit = ()=> { _onEdit = ()=> {
if (this.props.item.onEdited) { if (this.props.item.onEdited) {
this.setState({editing: true}); this.setState({editing: true});
} }
} };
_onInputFocus = (event)=> { _onInputFocus = (event)=> {
const input = event.target; const input = event.target;
input.selectionStart = input.selectionEnd = input.value.length; input.selectionStart = input.selectionEnd = input.value.length;
} };
_onInputBlur = (event)=> { _onInputBlur = (event)=> {
this._clearEditingState(event); this._clearEditingState(event);
} };
_onInputKeyDown = (event)=> { _onInputKeyDown = (event)=> {
if (event.key === 'Escape') { if (event.key === 'Escape') {
@ -240,7 +240,7 @@ class OutlineViewItem extends Component {
this._onEdited(event.target.value); this._onEdited(event.target.value);
this._clearEditingState(event); this._clearEditingState(event);
} }
} };
_onShowContextMenu = (event)=> { _onShowContextMenu = (event)=> {
event.stopPropagation() event.stopPropagation()
@ -264,7 +264,7 @@ class OutlineViewItem extends Component {
})); }));
} }
menu.popup(remote.getCurrentWindow()); menu.popup(remote.getCurrentWindow());
} };
// Renderers // Renderers

View file

@ -29,7 +29,7 @@ import OutlineViewItem from './outline-view-item';
* @class OutlineView * @class OutlineView
*/ */
class OutlineView extends Component { class OutlineView extends Component {
static displayName = 'OutlineView' static displayName = 'OutlineView';
/** /**
* If provided, this function will be called when an item has been created. * If provided, this function will be called when an item has been created.
@ -49,45 +49,45 @@ class OutlineView extends Component {
collapsed: PropTypes.bool, collapsed: PropTypes.bool,
onItemCreated: PropTypes.func, onItemCreated: PropTypes.func,
onCollapseToggled: PropTypes.func, onCollapseToggled: PropTypes.func,
} };
static defaultProps = { static defaultProps = {
title: '', title: '',
items: [], items: [],
} };
state = { state = {
showCreateInput: false, showCreateInput: false,
} };
// Handlers // Handlers
_onCreateButtonMouseDown = ()=> { _onCreateButtonMouseDown = ()=> {
this._clickingCreateButton = true; this._clickingCreateButton = true;
} };
_onCreateButtonClicked = ()=> { _onCreateButtonClicked = ()=> {
this._clickingCreateButton = false; this._clickingCreateButton = false;
this.setState({showCreateInput: !this.state.showCreateInput}); this.setState({showCreateInput: !this.state.showCreateInput});
} };
_onCollapseToggled = ()=> { _onCollapseToggled = ()=> {
if (this.props.onCollapseToggled) { if (this.props.onCollapseToggled) {
this.props.onCollapseToggled(this.props); this.props.onCollapseToggled(this.props);
} }
} };
_onItemCreated = (item, value)=> { _onItemCreated = (item, value)=> {
this.setState({showCreateInput: false}); this.setState({showCreateInput: false});
this.props.onItemCreated(value) this.props.onItemCreated(value)
} };
_onCreateInputCleared = ()=> { _onCreateInputCleared = ()=> {
if (!this._clickingCreateButton) { if (!this._clickingCreateButton) {
this.setState({showCreateInput: false}); this.setState({showCreateInput: false});
} }
} };
// Renderers // Renderers