Skip to content

Commit

Permalink
Reorganize imports and add eslint rules (mattermost#87)
Browse files Browse the repository at this point in the history
* reorganize imports and add eslint rules

* rebase and fix conflicts
  • Loading branch information
saturninoabril committed Oct 5, 2017
1 parent 38d0d3e commit c41de17
Show file tree
Hide file tree
Showing 494 changed files with 2,578 additions and 2,296 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"parser": "babel-eslint",
"plugins": [
"react"
"react",
"import"
],
"env": {
"browser": true,
Expand All @@ -28,6 +29,9 @@
"before": true,
"after": true
},
"settings": {
"import/resolver": "webpack"
},
"rules": {
"array-bracket-spacing": [2, "never"],
"array-callback-return": 2,
Expand Down Expand Up @@ -59,6 +63,8 @@
"global-require": 2,
"guard-for-in": 2,
"id-blacklist": 0,
"import/no-unresolved": 2,
"import/order": ["error", {"newlines-between": "always-and-inside-groups", "groups": ["builtin", "external", ["internal", "parent"], "sibling", "index"]}],
"indent": [2, 4, {"SwitchCase": 0}],
"jsx-quotes": [2, "prefer-single"],
"key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "strict"}],
Expand Down
10 changes: 5 additions & 5 deletions actions/admin_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import {clientLogout} from 'actions/global_actions.jsx';
import * as AdminActions from 'mattermost-redux/actions/admin';
import * as UserActions from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';

import {clientLogout} from 'actions/global_actions.jsx';
import store from 'stores/redux_store.jsx';

const dispatch = store.dispatch;
const getState = store.getState;

import * as AdminActions from 'mattermost-redux/actions/admin';
import * as UserActions from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';

export function saveConfig(config, success, error) {
AdminActions.updateConfig(config)(dispatch, getState).then(
(data) => {
Expand Down
33 changes: 15 additions & 18 deletions actions/channel_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import * as ChannelUtils from 'utils/channel_utils.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import {browserHistory} from 'react-router/es6';

import * as GlobalActions from 'actions/global_actions.jsx';
import * as PostActions from 'actions/post_actions.jsx';
import * as ChannelActions from 'mattermost-redux/actions/channels';
import {deletePreferences, savePreferences} from 'mattermost-redux/actions/preferences';
import {Client4} from 'mattermost-redux/client';
import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/channels';

import {loadProfilesForSidebar, loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import * as PostActions from 'actions/post_actions.jsx';
import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';

import * as ChannelUtils from 'utils/channel_utils.jsx';
import {Constants, Preferences} from 'utils/constants.jsx';
import * as UserAgent from 'utils/user_agent.jsx';
import * as Utils from 'utils/utils.jsx';
import {Constants, Preferences} from 'utils/constants.jsx';

import {browserHistory} from 'react-router/es6';

import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;

import * as ChannelActions from 'mattermost-redux/actions/channels';
import {savePreferences, deletePreferences} from 'mattermost-redux/actions/preferences';
import {Client4} from 'mattermost-redux/client';

import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/channels';

export function goToChannel(channel) {
if (channel.fake) {
const user = UserStore.getProfileByUsername(channel.display_name);
Expand Down
9 changes: 5 additions & 4 deletions actions/emoji_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import UserStore from 'stores/user_store.jsx';
import * as EmojiActions from 'mattermost-redux/actions/emojis';
import {getProfilesByIds} from 'mattermost-redux/actions/users';

import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import store from 'stores/redux_store.jsx';
import UserStore from 'stores/user_store.jsx';

import {ActionTypes} from 'utils/constants.jsx';

import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;
import {getProfilesByIds} from 'mattermost-redux/actions/users';
import * as EmojiActions from 'mattermost-redux/actions/emojis';

export async function loadEmoji(getProfiles = true) {
const data = await EmojiActions.getAllCustomEmojis()(dispatch, getState);
Expand Down
11 changes: 6 additions & 5 deletions actions/file_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
// See License.txt for license information.

import {batchActions} from 'redux-batched-actions';
import request from 'superagent';

import store from 'stores/redux_store.jsx';

import * as Utils from 'utils/utils.jsx';
import request from 'superagent';

import {FileTypes} from 'mattermost-redux/action_types';
import {forceLogoutIfNecessary} from 'mattermost-redux/actions/helpers';
import {getLogErrorAction} from 'mattermost-redux/actions/errors';
import {forceLogoutIfNecessary} from 'mattermost-redux/actions/helpers';
import {Client4} from 'mattermost-redux/client';

import store from 'stores/redux_store.jsx';

import * as Utils from 'utils/utils.jsx';

export function uploadFile(file, name, channelId, clientId, successCallback, errorCallback) {
const {dispatch, getState} = store;

Expand Down
39 changes: 18 additions & 21 deletions actions/global_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {browserHistory} from 'react-router/es6';

import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import SearchStore from 'stores/search_store.jsx';
import {createDirectChannel, getChannelAndMyMember, getChannelStats, getMyChannelMember, joinChannel, viewChannel} from 'mattermost-redux/actions/channels';
import {getPostThread} from 'mattermost-redux/actions/posts';
import {removeUserFromTeam} from 'mattermost-redux/actions/teams';
import {Client4} from 'mattermost-redux/client';

import {handleNewPost} from 'actions/post_actions.jsx';
import {loadProfilesForSidebar, loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import {handleNewPost} from 'actions/post_actions.jsx';
import {stopPeriodicStatusUpdates} from 'actions/status_actions.jsx';
import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions.jsx';
import * as WebsocketActions from 'actions/websocket_actions.jsx';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
import store from 'stores/redux_store.jsx';
import SearchStore from 'stores/search_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';

import WebSocketClient from 'client/web_websocket_client.jsx';

import {ActionTypes, Constants, ErrorPageTypes} from 'utils/constants.jsx';
import EventTypes from 'utils/event_types.jsx';

import WebSocketClient from 'client/web_websocket_client.jsx';
import {sortTeamsByDisplayName} from 'utils/team_utils.jsx';
import * as Utils from 'utils/utils.jsx';

import en from 'i18n/en.json';
import * as I18n from 'i18n/i18n.jsx';
import {browserHistory} from 'react-router/es6';

// Redux actions
import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;

import {Client4} from 'mattermost-redux/client';

import {removeUserFromTeam} from 'mattermost-redux/actions/teams';
import {viewChannel, getChannelStats, getMyChannelMember, getChannelAndMyMember, createDirectChannel, joinChannel} from 'mattermost-redux/actions/channels';
import {getPostThread} from 'mattermost-redux/actions/posts';

export function emitChannelClickEvent(channel) {
function userVisitedFakeChannel(chan, success, fail) {
const currentUserId = UserStore.getCurrentId();
Expand Down
21 changes: 10 additions & 11 deletions actions/integration_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import UserStore from 'stores/user_store.jsx';
import request from 'superagent';

import * as IntegrationActions from 'mattermost-redux/actions/integrations';
import {getProfilesByIds} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';

import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import UserStore from 'stores/user_store.jsx';

import * as UserAgent from 'utils/user_agent.jsx';
import {ActionTypes} from 'utils/constants.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import * as UserAgent from 'utils/user_agent.jsx';

import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;

import {Client4} from 'mattermost-redux/client';

import {getProfilesByIds} from 'mattermost-redux/actions/users';
import * as IntegrationActions from 'mattermost-redux/actions/integrations';

import request from 'superagent';

export function loadIncomingHooks(complete) {
IntegrationActions.getIncomingHooks('', 0, 10000)(dispatch, getState).then(
(data) => {
Expand Down
1 change: 1 addition & 0 deletions actions/job_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as JobsActions from 'mattermost-redux/actions/jobs';

import store from 'stores/redux_store.jsx';

const dispatch = store.dispatch;
const getState = store.getState;

Expand Down
6 changes: 3 additions & 3 deletions actions/notification_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import Constants, {NotificationLevels} from 'utils/constants.jsx';
import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import NotificationStore from 'stores/notification_store.jsx';
import UserStore from 'stores/user_store.jsx';

import Constants, {NotificationLevels} from 'utils/constants.jsx';
import {isSystemMessage} from 'utils/post_utils.jsx';
import {isWindowsApp, isMacApp, isMobileApp} from 'utils/user_agent.jsx';
import {isMacApp, isMobileApp, isWindowsApp} from 'utils/user_agent.jsx';
import * as Utils from 'utils/utils.jsx';

export function sendDesktopNotification(post, msgProps) {
Expand Down
5 changes: 3 additions & 2 deletions actions/oauth_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import * as IntegrationActions from 'mattermost-redux/actions/integrations';

import store from 'stores/redux_store.jsx';

const dispatch = store.dispatch;
const getState = store.getState;

import * as IntegrationActions from 'mattermost-redux/actions/integrations';

export function deleteOAuthApp(id, success, error) {
IntegrationActions.deleteOAuthApp(id)(dispatch, getState).then(
(data) => {
Expand Down
31 changes: 13 additions & 18 deletions actions/post_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {browserHistory} from 'react-router/es6';
import {batchActions} from 'redux-batched-actions';

import {PostTypes} from 'mattermost-redux/action_types';
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
import * as PostActions from 'mattermost-redux/actions/posts';
import {Client4} from 'mattermost-redux/client';
import * as Selectors from 'mattermost-redux/selectors/entities/posts';

import {sendDesktopNotification} from 'actions/notification_actions.jsx';
import {loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
import PostStore from 'stores/post_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';

import {loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
import {sendDesktopNotification} from 'actions/notification_actions.jsx';
import UserStore from 'stores/user_store.jsx';

import {ActionTypes, Constants} from 'utils/constants.jsx';
import {EMOJI_PATTERN} from 'utils/emoticons.jsx';

import {browserHistory} from 'react-router/es6';

// Redux actions
import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;

import * as PostActions from 'mattermost-redux/actions/posts';
import {getMyChannelMember} from 'mattermost-redux/actions/channels';

import {Client4} from 'mattermost-redux/client';

import {PostTypes} from 'mattermost-redux/action_types';
import * as Selectors from 'mattermost-redux/selectors/entities/posts';
import {batchActions} from 'redux-batched-actions';

export function handleNewPost(post, msg) {
let websocketMessageProps = {};
if (msg) {
Expand Down
9 changes: 4 additions & 5 deletions actions/status_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import {getStatusesByIds} from 'mattermost-redux/actions/users';

import ChannelStore from 'stores/channel_store.jsx';
import PostStore from 'stores/post_store.jsx';
import PreferenceStore from 'stores/preference_store.jsx';
import store from 'stores/redux_store.jsx';
import UserStore from 'stores/user_store.jsx';

import {Preferences, Constants} from 'utils/constants.jsx';
import {Constants, Preferences} from 'utils/constants.jsx';

// Redux actions
import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;

import {getStatusesByIds} from 'mattermost-redux/actions/users';

export function loadStatusesForChannel(channelId = ChannelStore.getCurrentId()) {
const postList = PostStore.getVisiblePosts(channelId);
if (!postList || !postList.posts) {
Expand Down
21 changes: 9 additions & 12 deletions actions/team_actions.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import TeamStore from 'stores/team_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';

import {browserHistory} from 'react-router/es6';

// Redux actions
import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;

import {Client4} from 'mattermost-redux/client';

import {getUser} from 'mattermost-redux/actions/users';
import {TeamTypes} from 'mattermost-redux/action_types';
import {viewChannel} from 'mattermost-redux/actions/channels';
import * as TeamActions from 'mattermost-redux/actions/teams';
import {getUser} from 'mattermost-redux/actions/users';
import {Client4} from 'mattermost-redux/client';

import {TeamTypes} from 'mattermost-redux/action_types';
import ChannelStore from 'stores/channel_store.jsx';
import store from 'stores/redux_store.jsx';
import TeamStore from 'stores/team_store.jsx';

const dispatch = store.dispatch;
const getState = store.getState;

export function checkIfTeamExists(teamName, onSuccess, onError) {
TeamActions.checkIfTeamExists(teamName)(dispatch, getState).then(
Expand Down
Loading

0 comments on commit c41de17

Please sign in to comment.