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

Этот коммит содержится в:
Christopher Speller
2015-11-19 18:10:08 -05:00
родитель c22e8129b0
Коммит 5c35c2631e
9 изменённых файлов: 42 добавлений и 21 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@@ -190,3 +190,11 @@ export default class AdminController extends React.Component {
); );
} }
} }
AdminController.defaultProps = {
};
AdminController.propTypes = {
tab: React.PropTypes.string,
teamId: React.PropTypes.string
};

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@@ -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 ( return (
<div className='channel-intro'> <div className='channel-intro'>
<h4 className='channel-intro__title'>{'Beginning of ' + channel.display_name}</h4> <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(); const team = TeamStore.getCurrent();
let inviteModalLink; let inviteModalLink;
if (team.type === Constants.INVITE_TEAM) { 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 uiName = channel.display_name;
var creatorName = ''; var creatorName = '';