Skip to content

Commit c41de17

Browse files
Reorganize imports and add eslint rules (mattermost#87)
* reorganize imports and add eslint rules * rebase and fix conflicts
1 parent 38d0d3e commit c41de17

File tree

494 files changed

+2578
-2296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

494 files changed

+2578
-2296
lines changed

.eslintrc.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
},
1313
"parser": "babel-eslint",
1414
"plugins": [
15-
"react"
15+
"react",
16+
"import"
1617
],
1718
"env": {
1819
"browser": true,
@@ -28,6 +29,9 @@
2829
"before": true,
2930
"after": true
3031
},
32+
"settings": {
33+
"import/resolver": "webpack"
34+
},
3135
"rules": {
3236
"array-bracket-spacing": [2, "never"],
3337
"array-callback-return": 2,
@@ -59,6 +63,8 @@
5963
"global-require": 2,
6064
"guard-for-in": 2,
6165
"id-blacklist": 0,
66+
"import/no-unresolved": 2,
67+
"import/order": ["error", {"newlines-between": "always-and-inside-groups", "groups": ["builtin", "external", ["internal", "parent"], "sibling", "index"]}],
6268
"indent": [2, 4, {"SwitchCase": 0}],
6369
"jsx-quotes": [2, "prefer-single"],
6470
"key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "strict"}],

actions/admin_actions.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

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

8+
import {clientLogout} from 'actions/global_actions.jsx';
69
import store from 'stores/redux_store.jsx';
10+
711
const dispatch = store.dispatch;
812
const getState = store.getState;
913

10-
import * as AdminActions from 'mattermost-redux/actions/admin';
11-
import * as UserActions from 'mattermost-redux/actions/users';
12-
import {Client4} from 'mattermost-redux/client';
13-
1414
export function saveConfig(config, success, error) {
1515
AdminActions.updateConfig(config)(dispatch, getState).then(
1616
(data) => {

actions/channel_actions.jsx

+15-18
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

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

10-
import * as GlobalActions from 'actions/global_actions.jsx';
11-
import * as PostActions from 'actions/post_actions.jsx';
6+
import * as ChannelActions from 'mattermost-redux/actions/channels';
7+
import {deletePreferences, savePreferences} from 'mattermost-redux/actions/preferences';
8+
import {Client4} from 'mattermost-redux/client';
9+
import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/channels';
1210

13-
import {loadProfilesForSidebar, loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
1411
import {trackEvent} from 'actions/diagnostics_actions.jsx';
12+
import * as GlobalActions from 'actions/global_actions.jsx';
13+
import * as PostActions from 'actions/post_actions.jsx';
14+
import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions.jsx';
15+
import ChannelStore from 'stores/channel_store.jsx';
16+
import PreferenceStore from 'stores/preference_store.jsx';
17+
import store from 'stores/redux_store.jsx';
18+
import TeamStore from 'stores/team_store.jsx';
19+
import UserStore from 'stores/user_store.jsx';
1520

21+
import * as ChannelUtils from 'utils/channel_utils.jsx';
22+
import {Constants, Preferences} from 'utils/constants.jsx';
1623
import * as UserAgent from 'utils/user_agent.jsx';
1724
import * as Utils from 'utils/utils.jsx';
18-
import {Constants, Preferences} from 'utils/constants.jsx';
19-
20-
import {browserHistory} from 'react-router/es6';
2125

22-
import store from 'stores/redux_store.jsx';
2326
const dispatch = store.dispatch;
2427
const getState = store.getState;
2528

26-
import * as ChannelActions from 'mattermost-redux/actions/channels';
27-
import {savePreferences, deletePreferences} from 'mattermost-redux/actions/preferences';
28-
import {Client4} from 'mattermost-redux/client';
29-
30-
import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/channels';
31-
3229
export function goToChannel(channel) {
3330
if (channel.fake) {
3431
const user = UserStore.getProfileByUsername(channel.display_name);

actions/emoji_actions.jsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

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

67
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
8+
import store from 'stores/redux_store.jsx';
9+
import UserStore from 'stores/user_store.jsx';
10+
711
import {ActionTypes} from 'utils/constants.jsx';
812

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

1516
export async function loadEmoji(getProfiles = true) {
1617
const data = await EmojiActions.getAllCustomEmojis()(dispatch, getState);

actions/file_actions.jsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
// See License.txt for license information.
33

44
import {batchActions} from 'redux-batched-actions';
5-
import request from 'superagent';
6-
7-
import store from 'stores/redux_store.jsx';
85

9-
import * as Utils from 'utils/utils.jsx';
6+
import request from 'superagent';
107

118
import {FileTypes} from 'mattermost-redux/action_types';
12-
import {forceLogoutIfNecessary} from 'mattermost-redux/actions/helpers';
139
import {getLogErrorAction} from 'mattermost-redux/actions/errors';
10+
import {forceLogoutIfNecessary} from 'mattermost-redux/actions/helpers';
1411
import {Client4} from 'mattermost-redux/client';
1512

13+
import store from 'stores/redux_store.jsx';
14+
15+
import * as Utils from 'utils/utils.jsx';
16+
1617
export function uploadFile(file, name, channelId, clientId, successCallback, errorCallback) {
1718
const {dispatch, getState} = store;
1819

actions/global_actions.jsx

+18-21
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,41 @@
11
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

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

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

13-
import {handleNewPost} from 'actions/post_actions.jsx';
14-
import {loadProfilesForSidebar, loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
1511
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
12+
import {trackEvent} from 'actions/diagnostics_actions.jsx';
13+
import {handleNewPost} from 'actions/post_actions.jsx';
1614
import {stopPeriodicStatusUpdates} from 'actions/status_actions.jsx';
15+
import {loadNewDMIfNeeded, loadNewGMIfNeeded, loadProfilesForSidebar} from 'actions/user_actions.jsx';
1716
import * as WebsocketActions from 'actions/websocket_actions.jsx';
18-
import {trackEvent} from 'actions/diagnostics_actions.jsx';
17+
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
18+
import BrowserStore from 'stores/browser_store.jsx';
19+
import ChannelStore from 'stores/channel_store.jsx';
20+
import ErrorStore from 'stores/error_store.jsx';
21+
import store from 'stores/redux_store.jsx';
22+
import SearchStore from 'stores/search_store.jsx';
23+
import TeamStore from 'stores/team_store.jsx';
24+
import UserStore from 'stores/user_store.jsx';
25+
26+
import WebSocketClient from 'client/web_websocket_client.jsx';
1927

2028
import {ActionTypes, Constants, ErrorPageTypes} from 'utils/constants.jsx';
2129
import EventTypes from 'utils/event_types.jsx';
22-
23-
import WebSocketClient from 'client/web_websocket_client.jsx';
2430
import {sortTeamsByDisplayName} from 'utils/team_utils.jsx';
2531
import * as Utils from 'utils/utils.jsx';
2632

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

31-
// Redux actions
32-
import store from 'stores/redux_store.jsx';
3336
const dispatch = store.dispatch;
3437
const getState = store.getState;
3538

36-
import {Client4} from 'mattermost-redux/client';
37-
38-
import {removeUserFromTeam} from 'mattermost-redux/actions/teams';
39-
import {viewChannel, getChannelStats, getMyChannelMember, getChannelAndMyMember, createDirectChannel, joinChannel} from 'mattermost-redux/actions/channels';
40-
import {getPostThread} from 'mattermost-redux/actions/posts';
41-
4239
export function emitChannelClickEvent(channel) {
4340
function userVisitedFakeChannel(chan, success, fail) {
4441
const currentUserId = UserStore.getCurrentId();

actions/integration_actions.jsx

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

4-
import UserStore from 'stores/user_store.jsx';
4+
import request from 'superagent';
5+
6+
import * as IntegrationActions from 'mattermost-redux/actions/integrations';
7+
import {getProfilesByIds} from 'mattermost-redux/actions/users';
8+
import {Client4} from 'mattermost-redux/client';
9+
10+
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
11+
import store from 'stores/redux_store.jsx';
512
import TeamStore from 'stores/team_store.jsx';
13+
import UserStore from 'stores/user_store.jsx';
614

7-
import * as UserAgent from 'utils/user_agent.jsx';
815
import {ActionTypes} from 'utils/constants.jsx';
9-
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
16+
import * as UserAgent from 'utils/user_agent.jsx';
1017

11-
import store from 'stores/redux_store.jsx';
1218
const dispatch = store.dispatch;
1319
const getState = store.getState;
1420

15-
import {Client4} from 'mattermost-redux/client';
16-
17-
import {getProfilesByIds} from 'mattermost-redux/actions/users';
18-
import * as IntegrationActions from 'mattermost-redux/actions/integrations';
19-
20-
import request from 'superagent';
21-
2221
export function loadIncomingHooks(complete) {
2322
IntegrationActions.getIncomingHooks('', 0, 10000)(dispatch, getState).then(
2423
(data) => {

actions/job_actions.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import * as JobsActions from 'mattermost-redux/actions/jobs';
55

66
import store from 'stores/redux_store.jsx';
7+
78
const dispatch = store.dispatch;
89
const getState = store.getState;
910

actions/notification_actions.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

4-
import Constants, {NotificationLevels} from 'utils/constants.jsx';
5-
import UserStore from 'stores/user_store.jsx';
64
import ChannelStore from 'stores/channel_store.jsx';
75
import NotificationStore from 'stores/notification_store.jsx';
6+
import UserStore from 'stores/user_store.jsx';
87

8+
import Constants, {NotificationLevels} from 'utils/constants.jsx';
99
import {isSystemMessage} from 'utils/post_utils.jsx';
10-
import {isWindowsApp, isMacApp, isMobileApp} from 'utils/user_agent.jsx';
10+
import {isMacApp, isMobileApp, isWindowsApp} from 'utils/user_agent.jsx';
1111
import * as Utils from 'utils/utils.jsx';
1212

1313
export function sendDesktopNotification(post, msgProps) {

actions/oauth_actions.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

4+
import * as IntegrationActions from 'mattermost-redux/actions/integrations';
5+
46
import store from 'stores/redux_store.jsx';
7+
58
const dispatch = store.dispatch;
69
const getState = store.getState;
710

8-
import * as IntegrationActions from 'mattermost-redux/actions/integrations';
9-
1011
export function deleteOAuthApp(id, success, error) {
1112
IntegrationActions.deleteOAuthApp(id)(dispatch, getState).then(
1213
(data) => {

actions/post_actions.jsx

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

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

7+
import {PostTypes} from 'mattermost-redux/action_types';
8+
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
9+
import * as PostActions from 'mattermost-redux/actions/posts';
10+
import {Client4} from 'mattermost-redux/client';
11+
import * as Selectors from 'mattermost-redux/selectors/entities/posts';
12+
13+
import {sendDesktopNotification} from 'actions/notification_actions.jsx';
14+
import {loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
15+
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
616
import ChannelStore from 'stores/channel_store.jsx';
7-
import UserStore from 'stores/user_store.jsx';
817
import PostStore from 'stores/post_store.jsx';
18+
import store from 'stores/redux_store.jsx';
919
import TeamStore from 'stores/team_store.jsx';
10-
11-
import {loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
12-
import {sendDesktopNotification} from 'actions/notification_actions.jsx';
20+
import UserStore from 'stores/user_store.jsx';
1321

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

17-
import {browserHistory} from 'react-router/es6';
18-
19-
// Redux actions
20-
import store from 'stores/redux_store.jsx';
2125
const dispatch = store.dispatch;
2226
const getState = store.getState;
2327

24-
import * as PostActions from 'mattermost-redux/actions/posts';
25-
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
26-
27-
import {Client4} from 'mattermost-redux/client';
28-
29-
import {PostTypes} from 'mattermost-redux/action_types';
30-
import * as Selectors from 'mattermost-redux/selectors/entities/posts';
31-
import {batchActions} from 'redux-batched-actions';
32-
3328
export function handleNewPost(post, msg) {
3429
let websocketMessageProps = {};
3530
if (msg) {

actions/status_actions.jsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

4+
import {getStatusesByIds} from 'mattermost-redux/actions/users';
5+
46
import ChannelStore from 'stores/channel_store.jsx';
57
import PostStore from 'stores/post_store.jsx';
68
import PreferenceStore from 'stores/preference_store.jsx';
9+
import store from 'stores/redux_store.jsx';
710
import UserStore from 'stores/user_store.jsx';
811

9-
import {Preferences, Constants} from 'utils/constants.jsx';
12+
import {Constants, Preferences} from 'utils/constants.jsx';
1013

11-
// Redux actions
12-
import store from 'stores/redux_store.jsx';
1314
const dispatch = store.dispatch;
1415
const getState = store.getState;
1516

16-
import {getStatusesByIds} from 'mattermost-redux/actions/users';
17-
1817
export function loadStatusesForChannel(channelId = ChannelStore.getCurrentId()) {
1918
const postList = PostStore.getVisiblePosts(channelId);
2019
if (!postList || !postList.posts) {

actions/team_actions.jsx

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
22
// See License.txt for license information.
33

4-
import TeamStore from 'stores/team_store.jsx';
5-
import ChannelStore from 'stores/channel_store.jsx';
6-
74
import {browserHistory} from 'react-router/es6';
85

9-
// Redux actions
10-
import store from 'stores/redux_store.jsx';
11-
const dispatch = store.dispatch;
12-
const getState = store.getState;
13-
14-
import {Client4} from 'mattermost-redux/client';
15-
16-
import {getUser} from 'mattermost-redux/actions/users';
6+
import {TeamTypes} from 'mattermost-redux/action_types';
177
import {viewChannel} from 'mattermost-redux/actions/channels';
188
import * as TeamActions from 'mattermost-redux/actions/teams';
9+
import {getUser} from 'mattermost-redux/actions/users';
10+
import {Client4} from 'mattermost-redux/client';
1911

20-
import {TeamTypes} from 'mattermost-redux/action_types';
12+
import ChannelStore from 'stores/channel_store.jsx';
13+
import store from 'stores/redux_store.jsx';
14+
import TeamStore from 'stores/team_store.jsx';
15+
16+
const dispatch = store.dispatch;
17+
const getState = store.getState;
2118

2219
export function checkIfTeamExists(teamName, onSuccess, onError) {
2320
TeamActions.checkIfTeamExists(teamName)(dispatch, getState).then(

0 commit comments

Comments
 (0)