Upgrading ESLint and adding some more rules. Refactoring to meet these new rules

This commit is contained in:
Christopher Speller
2015-11-19 18:10:08 -05:00
parent c22e8129b0
commit 5c35c2631e
9 changed files with 42 additions and 21 deletions

View File

@@ -1,3 +0,0 @@
**/*.json
components/toggle_modal_button.jsx
stores/modal_store.jsx

View File

@@ -27,6 +27,8 @@
},
"rules": {
"comma-dangle": [2, "never"],
"no-arrow-condition": 2,
"no-case-declarations": 2,
"no-cond-assign": [2, "except-parens"],
"no-console": 2,
"no-constant-condition": 2,
@@ -35,14 +37,17 @@
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty": 2,
"no-empty-pattern": 2,
"no-ex-assign": 2,
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-func-assign": 2,
"no-inner-declarations": 0,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-unexpected-multiline": 2,
"no-unreachable": 2,
"no-magic-numbers": [0, { "enforceConst": true, "detectObjects": true } ],
"valid-typeof": 2,
"block-scoped-var": 2,
@@ -150,6 +155,7 @@
// ES6 stuff
"arrow-parens": [2, "always"],
"arrow-body-style": 0,
"arrow-spacing": [2, { "before": true, "after": true }],
"constructor-super": 2,
"generator-star-spacing": [2, {"before": false, "after": true}],
@@ -172,7 +178,9 @@
"react/jsx-closing-bracket-location": [2, { "location": "tag-aligned" }],
"react/jsx-curly-spacing": [2, "never"],
"react/jsx-indent-props": [2, 4],
"react/jsx-key": 2,
"react/jsx-max-props-per-line": [2, { "maximum": 1 }],
"react/jsx-no-bind": 1,
"react/jsx-no-duplicate-props": [2, { "ignoreCase": false }],
"react/jsx-no-literals": 1,
"react/jsx-no-undef": 2,
@@ -181,13 +189,14 @@
"react/no-danger": 0,
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-direct-mutation-state": 2,
"react/no-multi-comp": 2,
"react/no-set-state": 0,
"react/no-unknown-property": 2,
"react/prefer-es6-class": 2,
"react/prop-types": 2,
"react/self-closing-comp": 2,
"react/sort-comp": 0,
"react/wrap-multilines": 2,
"react/no-direct-mutation-state": 2
"react/wrap-multilines": 2
}
}

View File

@@ -106,7 +106,7 @@ export default class AccessHistoryModal extends React.Component {
case '/channels/update_header':
currentAuditDesc = 'Updated the ' + channelName + ' channel/group header';
break;
default:
default: {
let userIdField = [];
let userId = '';
let username = '';
@@ -130,11 +130,12 @@ export default class AccessHistoryModal extends React.Component {
break;
}
}
} else if (currentActionURL.indexOf('/oauth') === 0) {
const oauthInfo = currentAudit.extra_info.split(' ');
switch (currentActionURL) {
case '/oauth/register':
case '/oauth/register': {
const clientIdField = oauthInfo[0].split('=');
if (clientIdField[0] === 'client_id') {
@@ -142,6 +143,7 @@ export default class AccessHistoryModal extends React.Component {
}
break;
}
case '/oauth/allow':
if (oauthInfo[0] === 'attempt') {
currentAuditDesc = 'Attempted to allow a new OAuth service access';
@@ -202,7 +204,7 @@ export default class AccessHistoryModal extends React.Component {
}
break;
case '/users/update_roles':
case '/users/update_roles': {
const userRoles = userInfo[0].split('=')[1];
currentAuditDesc = 'Updated user role(s) to ';
@@ -213,7 +215,8 @@ export default class AccessHistoryModal extends React.Component {
}
break;
case '/users/update_active':
}
case '/users/update_active': {
const updateType = userInfo[0].split('=')[0];
const updateField = userInfo[0].split('=')[1];
@@ -240,6 +243,7 @@ export default class AccessHistoryModal extends React.Component {
}
break;
}
case '/users/send_password_reset':
currentAuditDesc = 'Sent an email to ' + userInfo[0].split('=')[1] + ' to reset your password';
break;

View File

@@ -189,4 +189,12 @@ export default class AdminController extends React.Component {
</div>
);
}
}
}
AdminController.defaultProps = {
};
AdminController.propTypes = {
tab: React.PropTypes.string,
teamId: React.PropTypes.string
};

View File

@@ -13,14 +13,14 @@ export default class CommandList extends React.Component {
this.getSuggestedCommands = this.getSuggestedCommands.bind(this);
this.state = {
suggestions: [ ],
suggestions: [],
cmd: ''
};
}
handleClick(i) {
this.props.addCommand(this.state.suggestions[i].suggestion);
this.setState({suggestions: [ ], cmd: ''});
this.setState({suggestions: [], cmd: ''});
}
addFirstCommand() {
@@ -36,7 +36,7 @@ export default class CommandList extends React.Component {
getSuggestedCommands(cmd) {
if (!cmd || cmd.charAt(0) !== '/') {
this.setState({suggestions: [ ], cmd: ''});
this.setState({suggestions: [], cmd: ''});
return;
}

View File

@@ -74,11 +74,12 @@ export default class MsgTyping extends React.Component {
case 1:
text = users[0] + ' is typing...';
break;
default:
default: {
const last = users.pop();
text = users.join(', ') + ' and ' + last + ' are typing...';
break;
}
}
this.setState({text});
}

View File

@@ -17,9 +17,9 @@
"babelify": "6.3.0",
"uglify-js": "2.4.24",
"watchify": "3.4.0",
"eslint": "1.6.0",
"eslint-plugin-react": "3.5.1",
"babel-eslint": "4.1.4"
"eslint": "1.9.0",
"eslint-plugin-react": "3.9.0",
"babel-eslint": "4.1.5"
},
"scripts": {
"check": "",

View File

@@ -105,7 +105,7 @@ class PreferenceStoreClass extends EventEmitter {
const action = payload.action;
switch (action.type) {
case ActionTypes.RECIEVED_PREFERENCES:
case ActionTypes.RECIEVED_PREFERENCES: {
const preferences = this.getAllPreferences();
for (const preference of action.preferences) {
@@ -114,6 +114,8 @@ class PreferenceStoreClass extends EventEmitter {
this.setAllPreferences(preferences);
this.emitChange(preferences);
break;
}
}
}
}

View File

@@ -71,7 +71,7 @@ export function createDMIntroMessage(channel) {
);
}
export function createOffTopicIntroMessage(channel, showInviteModal) {
export function createOffTopicIntroMessage(channel, showInviteModal) { //eslint-disable-line react/no-multi-comp
return (
<div className='channel-intro'>
<h4 className='channel-intro__title'>{'Beginning of ' + channel.display_name}</h4>
@@ -101,7 +101,7 @@ export function createOffTopicIntroMessage(channel, showInviteModal) {
);
}
export function createDefaultIntroMessage(channel) {
export function createDefaultIntroMessage(channel) { //eslint-disable-line react/no-multi-comp
const team = TeamStore.getCurrent();
let inviteModalLink;
if (team.type === Constants.INVITE_TEAM) {
@@ -154,7 +154,7 @@ export function createDefaultIntroMessage(channel) {
);
}
export function createStandardIntroMessage(channel, showInviteModal) {
export function createStandardIntroMessage(channel, showInviteModal) { //eslint-disable-line react/no-multi-comp
var uiName = channel.display_name;
var creatorName = '';