Add custom rule to prevent passing getState into dispatch (#4010)
* Add custom rule to prevent passing getState into dispatch * Update package.json
This commit is contained in:
parent
0bb573c7e0
commit
f751b552b4
11 changed files with 42 additions and 54 deletions
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
"extends": [
|
||||
"./node_modules/eslint-config-mattermost/.eslintrc.json",
|
||||
"./node_modules/eslint-config-mattermost/.eslintrc-react.json"
|
||||
"plugin:mattermost/react"
|
||||
],
|
||||
"plugins": [
|
||||
"mattermost"
|
||||
],
|
||||
"settings": {
|
||||
"react": {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ export function loadProfilesAndTeamMembersForDMSidebar(teamId) {
|
|||
}
|
||||
|
||||
if (actions.length) {
|
||||
dispatch(batchActions(actions), getState);
|
||||
dispatch(batchActions(actions));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -410,12 +410,10 @@ export function handleSelectChannelByName(channelName, teamName, errorHandler) {
|
|||
}
|
||||
|
||||
export function handlePostDraftChanged(channelId, draft) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ViewTypes.POST_DRAFT_CHANGED,
|
||||
channelId,
|
||||
draft,
|
||||
}, getState);
|
||||
return {
|
||||
type: ViewTypes.POST_DRAFT_CHANGED,
|
||||
channelId,
|
||||
draft,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -830,4 +828,4 @@ function fetchGroupMessageProfilesIfNeeded(state, channel, channelMembers, profi
|
|||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,20 +20,16 @@ import {setCSRFFromCookie} from 'app/utils/security';
|
|||
import {loadConfigAndLicense} from 'app/actions/views/root';
|
||||
|
||||
export function handleLoginIdChanged(loginId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ViewTypes.LOGIN_ID_CHANGED,
|
||||
loginId,
|
||||
}, getState);
|
||||
return {
|
||||
type: ViewTypes.LOGIN_ID_CHANGED,
|
||||
loginId,
|
||||
};
|
||||
}
|
||||
|
||||
export function handlePasswordChanged(password) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ViewTypes.PASSWORD_CHANGED,
|
||||
password,
|
||||
}, getState);
|
||||
return {
|
||||
type: ViewTypes.PASSWORD_CHANGED,
|
||||
password,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@
|
|||
import {ViewTypes} from 'app/constants';
|
||||
|
||||
export function handleSearchDraftChanged(text) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ViewTypes.SEARCH_DRAFT_CHANGED,
|
||||
text,
|
||||
}, getState);
|
||||
return {
|
||||
type: ViewTypes.SEARCH_DRAFT_CHANGED,
|
||||
text,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@ import {GeneralTypes} from 'mattermost-redux/action_types';
|
|||
import {ViewTypes} from 'app/constants';
|
||||
|
||||
export function handleServerUrlChanged(serverUrl) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch(batchActions([
|
||||
{type: GeneralTypes.CLIENT_CONFIG_RESET},
|
||||
{type: GeneralTypes.CLIENT_LICENSE_RESET},
|
||||
{type: ViewTypes.SERVER_URL_CHANGED, serverUrl},
|
||||
]), getState);
|
||||
};
|
||||
return batchActions([
|
||||
{type: GeneralTypes.CLIENT_CONFIG_RESET},
|
||||
{type: GeneralTypes.CLIENT_LICENSE_RESET},
|
||||
{type: ViewTypes.SERVER_URL_CHANGED, serverUrl},
|
||||
]);
|
||||
}
|
||||
|
||||
export function setServerUrl(serverUrl) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ describe('Actions.Views.SelectServer', () => {
|
|||
store = mockStore({});
|
||||
});
|
||||
|
||||
test('handleServerUrlChanged', async () => {
|
||||
test('handleServerUrlChanged', () => {
|
||||
const serverUrl = 'https://mattermost.example.com';
|
||||
const actions = batchActions([
|
||||
{type: GeneralTypes.CLIENT_CONFIG_RESET},
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@
|
|||
import {ViewTypes} from 'app/constants';
|
||||
|
||||
export function handleCommentDraftChanged(rootId, draft) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ViewTypes.COMMENT_DRAFT_CHANGED,
|
||||
rootId,
|
||||
draft,
|
||||
}, getState);
|
||||
return {
|
||||
type: ViewTypes.COMMENT_DRAFT_CHANGED,
|
||||
rootId,
|
||||
draft,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ describe('Actions.Views.Thread', () => {
|
|||
store = mockStore({});
|
||||
});
|
||||
|
||||
test('handleCommentDraftChanged', async () => {
|
||||
test('handleCommentDraftChanged', () => {
|
||||
const rootId = '1234';
|
||||
const draft = 'draft1';
|
||||
const action = {
|
||||
|
|
@ -28,11 +28,11 @@ describe('Actions.Views.Thread', () => {
|
|||
rootId,
|
||||
draft,
|
||||
};
|
||||
await store.dispatch(handleCommentDraftChanged(rootId, draft));
|
||||
store.dispatch(handleCommentDraftChanged(rootId, draft));
|
||||
expect(store.getActions()).toEqual([action]);
|
||||
});
|
||||
|
||||
test('handleCommentDraftSelectionChanged', async () => {
|
||||
test('handleCommentDraftSelectionChanged', () => {
|
||||
const rootId = '1234';
|
||||
const cursorPosition = 'position';
|
||||
const action = {
|
||||
|
|
@ -40,7 +40,7 @@ describe('Actions.Views.Thread', () => {
|
|||
rootId,
|
||||
cursorPosition,
|
||||
};
|
||||
await store.dispatch(handleCommentDraftSelectionChanged(rootId, cursorPosition));
|
||||
store.dispatch(handleCommentDraftSelectionChanged(rootId, cursorPosition));
|
||||
expect(store.getActions()).toEqual([action]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
10
package-lock.json
generated
10
package-lock.json
generated
|
|
@ -6232,11 +6232,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"eslint-config-mattermost": {
|
||||
"version": "github:mattermost/eslint-config-mattermost#8f9eb1414bf9ebfb509359bddddfad9788ca3c3c",
|
||||
"from": "github:mattermost/eslint-config-mattermost",
|
||||
"dev": true
|
||||
},
|
||||
"eslint-plugin-eslint-plugin": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-2.2.0.tgz",
|
||||
|
|
@ -6304,6 +6299,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"eslint-plugin-mattermost": {
|
||||
"version": "github:mattermost/eslint-plugin-mattermost#070ce792d105482ffb2b27cfc0b7e78b3d20acee",
|
||||
"from": "github:mattermost/eslint-plugin-mattermost#070ce792d105482ffb2b27cfc0b7e78b3d20acee",
|
||||
"dev": true
|
||||
},
|
||||
"eslint-plugin-react": {
|
||||
"version": "7.17.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.17.0.tgz",
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@
|
|||
"enzyme-adapter-react-16": "1.15.2",
|
||||
"enzyme-to-json": "3.4.3",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-mattermost": "github:mattermost/eslint-config-mattermost",
|
||||
"eslint-plugin-header": "3.0.0",
|
||||
"eslint-plugin-jest": "23.6.0",
|
||||
"eslint-plugin-mattermost": "github:mattermost/eslint-plugin-mattermost#070ce792d105482ffb2b27cfc0b7e78b3d20acee",
|
||||
"eslint-plugin-react": "7.17.0",
|
||||
"harmony-reflect": "1.6.1",
|
||||
"jest": "24.9.0",
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@ export function getTeamChannels(teamId) {
|
|||
}
|
||||
|
||||
export function extensionSelectTeamId(teamId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ViewTypes.EXTENSION_SELECTED_TEAM_ID,
|
||||
data: teamId,
|
||||
}, getState);
|
||||
return {
|
||||
type: ViewTypes.EXTENSION_SELECTED_TEAM_ID,
|
||||
data: teamId,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue