Fix a bunch of lint complaints

This commit is contained in:
Richard van der Hoff 2017-01-24 22:41:52 +00:00
parent 86276450f6
commit 770820e6fa
11 changed files with 43 additions and 25 deletions

1
.eslintignore Normal file
View file

@ -0,0 +1 @@
src/component-index.js

View file

@ -26,7 +26,7 @@ var UserSettingsStore = require('../../UserSettingsStore');
var GeminiScrollbar = require('react-gemini-scrollbar'); var GeminiScrollbar = require('react-gemini-scrollbar');
var Email = require('../../email'); var Email = require('../../email');
var AddThreepid = require('../../AddThreepid'); var AddThreepid = require('../../AddThreepid');
var AccessibleButton = require('../views/elements/AccessibleButton'); import AccessibleButton from '../views/elements/AccessibleButton';
// if this looks like a release, use the 'version' from package.json; else use // if this looks like a release, use the 'version' from package.json; else use
// the git sha. // the git sha.

View file

@ -19,7 +19,7 @@ limitations under the License.
var React = require('react'); var React = require('react');
var AvatarLogic = require("../../../Avatar"); var AvatarLogic = require("../../../Avatar");
import sdk from '../../../index'; import sdk from '../../../index';
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'BaseAvatar', displayName: 'BaseAvatar',

View file

@ -24,7 +24,7 @@ var DMRoomMap = require('../../../utils/DMRoomMap');
var rate_limited_func = require("../../../ratelimitedfunc"); var rate_limited_func = require("../../../ratelimitedfunc");
var dis = require("../../../dispatcher"); var dis = require("../../../dispatcher");
var Modal = require('../../../Modal'); var Modal = require('../../../Modal');
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
const TRUNCATE_QUERY_LIST = 40; const TRUNCATE_QUERY_LIST = 40;
@ -437,7 +437,8 @@ module.exports = React.createClass({
<div className="mx_Dialog_title"> <div className="mx_Dialog_title">
{this.props.title} {this.props.title}
</div> </div>
<AccessibleButton className="mx_ChatInviteDialog_cancel" onClick={this.onCancel} > <AccessibleButton className="mx_ChatInviteDialog_cancel"
onClick={this.onCancel} >
<TintableSvg src="img/icons-close-button.svg" width="35" height="35" /> <TintableSvg src="img/icons-close-button.svg" width="35" height="35" />
</AccessibleButton> </AccessibleButton>
<div className="mx_ChatInviteDialog_label"> <div className="mx_ChatInviteDialog_label">

View file

@ -17,8 +17,12 @@
import React from 'react'; import React from 'react';
/** /**
* AccessibleButton is a generic wrapper for any element that should be treated as a button. * AccessibleButton is a generic wrapper for any element that should be treated
* Identifies the element as a button, setting proper tab indexing and keyboard activation behavior. * as a button. Identifies the element as a button, setting proper tab
* indexing and keyboard activation behavior.
*
* @param {Object} props react element properties
* @returns {Object} rendered react
*/ */
export default function AccessibleButton(props) { export default function AccessibleButton(props) {
const {element, onClick, children, ...restProps} = props; const {element, onClick, children, ...restProps} = props;
@ -26,7 +30,7 @@ export default function AccessibleButton(props) {
restProps.onKeyDown = function(e) { restProps.onKeyDown = function(e) {
if (e.keyCode == 13 || e.keyCode == 32) return onClick(); if (e.keyCode == 13 || e.keyCode == 32) return onClick();
}; };
restProps.tabIndex = restProps.tabIndex || "0"; restProps.tabIndex = restProps.tabIndex || "0";
restProps.role = "button"; restProps.role = "button";
return React.createElement(element, restProps, children); return React.createElement(element, restProps, children);
} }
@ -44,7 +48,7 @@ AccessibleButton.propTypes = {
}; };
AccessibleButton.defaultProps = { AccessibleButton.defaultProps = {
element: 'div' element: 'div',
}; };
AccessibleButton.displayName = "AccessibleButton"; AccessibleButton.displayName = "AccessibleButton";

View file

@ -20,7 +20,7 @@ var React = require('react');
var MatrixClientPeg = require('../../../MatrixClientPeg'); var MatrixClientPeg = require('../../../MatrixClientPeg');
var sdk = require('../../../index'); var sdk = require('../../../index');
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
var PRESENCE_CLASS = { var PRESENCE_CLASS = {

View file

@ -35,7 +35,7 @@ var DMRoomMap = require('../../../utils/DMRoomMap');
var Unread = require('../../../Unread'); var Unread = require('../../../Unread');
var Receipt = require('../../../utils/Receipt'); var Receipt = require('../../../utils/Receipt');
var WithMatrixClient = require('../../../wrappers/WithMatrixClient'); var WithMatrixClient = require('../../../wrappers/WithMatrixClient');
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
module.exports = WithMatrixClient(React.createClass({ module.exports = WithMatrixClient(React.createClass({
displayName: 'MemberInfo', displayName: 'MemberInfo',
@ -636,20 +636,31 @@ module.exports = WithMatrixClient(React.createClass({
} }
if (this.state.can.kick) { if (this.state.can.kick) {
kickButton = <AccessibleButton className="mx_MemberInfo_field" onClick={this.onKick}> const membership = this.props.member.membership;
{ this.props.member.membership === "invite" ? "Disinvite" : "Kick" } const kickLabel = membership === "invite" ? "Disinvite" : "Kick";
</AccessibleButton>; kickButton = (
<AccessibleButton className="mx_MemberInfo_field"
onClick={this.onKick}>
{kickLabel}
</AccessibleButton>
);
} }
if (this.state.can.ban) { if (this.state.can.ban) {
banButton = <AccessibleButton className="mx_MemberInfo_field" onClick={this.onBan}> banButton = (
Ban <AccessibleButton className="mx_MemberInfo_field"
</AccessibleButton>; onClick={this.onBan}>
Ban
</AccessibleButton>
);
} }
if (this.state.can.mute) { if (this.state.can.mute) {
var muteLabel = this.state.muted ? "Unmute" : "Mute"; const muteLabel = this.state.muted ? "Unmute" : "Mute";
muteButton = <AccessibleButton className="mx_MemberInfo_field" onClick={this.onMuteToggle}> muteButton = (
{muteLabel} <AccessibleButton className="mx_MemberInfo_field"
</AccessibleButton>; onClick={this.onMuteToggle}>
{muteLabel}
</AccessibleButton>
);
} }
if (this.state.can.toggleMod) { if (this.state.can.toggleMod) {
var giveOpLabel = this.state.isTargetMod ? "Revoke Moderator" : "Make Moderator"; var giveOpLabel = this.state.isTargetMod ? "Revoke Moderator" : "Make Moderator";

View file

@ -26,7 +26,7 @@ var rate_limited_func = require('../../../ratelimitedfunc');
var linkify = require('linkifyjs'); var linkify = require('linkifyjs');
var linkifyElement = require('linkifyjs/element'); var linkifyElement = require('linkifyjs/element');
var linkifyMatrix = require('../../../linkify-matrix'); var linkifyMatrix = require('../../../linkify-matrix');
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
linkifyMatrix(linkify); linkifyMatrix(linkify);

View file

@ -26,7 +26,7 @@ var sdk = require('../../../index');
var ContextualMenu = require('../../structures/ContextualMenu'); var ContextualMenu = require('../../structures/ContextualMenu');
var RoomNotifs = require('../../../RoomNotifs'); var RoomNotifs = require('../../../RoomNotifs');
var FormattingUtils = require('../../../utils/FormattingUtils'); var FormattingUtils = require('../../../utils/FormattingUtils');
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
var UserSettingsStore = require('../../../UserSettingsStore'); var UserSettingsStore = require('../../../UserSettingsStore');
module.exports = React.createClass({ module.exports = React.createClass({

View file

@ -19,7 +19,7 @@ limitations under the License.
var React = require('react'); var React = require('react');
var sdk = require('../../../index'); var sdk = require('../../../index');
var dis = require("../../../dispatcher"); var dis = require("../../../dispatcher");
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
/* /*
* A stripped-down room header used for things like the user settings * A stripped-down room header used for things like the user settings

View file

@ -19,7 +19,7 @@ limitations under the License.
var React = require('react'); var React = require('react');
var MatrixClientPeg = require("../../../MatrixClientPeg"); var MatrixClientPeg = require("../../../MatrixClientPeg");
var sdk = require("../../../index"); var sdk = require("../../../index");
var AccessibleButton = require('../elements/AccessibleButton'); import AccessibleButton from '../elements/AccessibleButton';
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'ChangePassword', displayName: 'ChangePassword',
@ -137,7 +137,8 @@ module.exports = React.createClass({
<input id="password2" type="password" ref="confirm_input" /> <input id="password2" type="password" ref="confirm_input" />
</div> </div>
</div> </div>
<AccessibleButton className={buttonClassName} onClick={this.onClickChange}> <AccessibleButton className={buttonClassName}
onClick={this.onClickChange}>
Change Password Change Password
</AccessibleButton> </AccessibleButton>
</div> </div>