From 5c35c2631e59f895a7b0fb6761c1cae7aee60466 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 19 Nov 2015 18:10:08 -0500 Subject: Upgrading ESLint and adding some more rules. Refactoring to meet these new rules --- web/react/.eslintignore | 3 --- web/react/.eslintrc | 13 +++++++++++-- web/react/components/access_history_modal.jsx | 12 ++++++++---- web/react/components/admin_console/admin_controller.jsx | 10 +++++++++- web/react/components/command_list.jsx | 6 +++--- web/react/components/msg_typing.jsx | 3 ++- web/react/package.json | 6 +++--- web/react/stores/preference_store.jsx | 4 +++- web/react/utils/channel_intro_mssages.jsx | 6 +++--- 9 files changed, 42 insertions(+), 21 deletions(-) delete mode 100644 web/react/.eslintignore (limited to 'web') diff --git a/web/react/.eslintignore b/web/react/.eslintignore deleted file mode 100644 index 25a7df331..000000000 --- a/web/react/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -**/*.json -components/toggle_modal_button.jsx -stores/modal_store.jsx diff --git a/web/react/.eslintrc b/web/react/.eslintrc index d4d28e863..29ca97faf 100644 --- a/web/react/.eslintrc +++ b/web/react/.eslintrc @@ -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 } } diff --git a/web/react/components/access_history_modal.jsx b/web/react/components/access_history_modal.jsx index 65b80dfb7..61504a968 100644 --- a/web/react/components/access_history_modal.jsx +++ b/web/react/components/access_history_modal.jsx @@ -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; diff --git a/web/react/components/admin_console/admin_controller.jsx b/web/react/components/admin_console/admin_controller.jsx index 8e0ab0555..3c3f03f5a 100644 --- a/web/react/components/admin_console/admin_controller.jsx +++ b/web/react/components/admin_console/admin_controller.jsx @@ -189,4 +189,12 @@ export default class AdminController extends React.Component { ); } -} \ No newline at end of file +} + +AdminController.defaultProps = { +}; + +AdminController.propTypes = { + tab: React.PropTypes.string, + teamId: React.PropTypes.string +}; diff --git a/web/react/components/command_list.jsx b/web/react/components/command_list.jsx index a6d9d5d70..9b479b973 100644 --- a/web/react/components/command_list.jsx +++ b/web/react/components/command_list.jsx @@ -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; } diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index ccf8a2445..eed85ade6 100644 --- a/web/react/components/msg_typing.jsx +++ b/web/react/components/msg_typing.jsx @@ -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}); } diff --git a/web/react/package.json b/web/react/package.json index de59b48ac..21ccb36ec 100644 --- a/web/react/package.json +++ b/web/react/package.json @@ -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": "", diff --git a/web/react/stores/preference_store.jsx b/web/react/stores/preference_store.jsx index f630d150d..cc353be6c 100644 --- a/web/react/stores/preference_store.jsx +++ b/web/react/stores/preference_store.jsx @@ -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; + } } } } diff --git a/web/react/utils/channel_intro_mssages.jsx b/web/react/utils/channel_intro_mssages.jsx index 28a458e3f..281c65b1b 100644 --- a/web/react/utils/channel_intro_mssages.jsx +++ b/web/react/utils/channel_intro_mssages.jsx @@ -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 (

{'Beginning of ' + channel.display_name}

@@ -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 = ''; -- cgit v1.2.3-1-g7c22