Skip to content

Commit

Permalink
Add custom ESLint rule to prevent passing getState into dispatch (mat…
Browse files Browse the repository at this point in the history
…termost#4976)

* Add custom ESLint rule to prevent passing getState into dispatch

* Update package.json
  • Loading branch information
hmhealey committed Mar 11, 2020
1 parent b9931ae commit 6a7b5a6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
9 changes: 3 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"extends": [
"./node_modules/eslint-config-mattermost/.eslintrc.json",
"./node_modules/eslint-config-mattermost/.eslintrc-react.json",
"plugin:mattermost/react",
"plugin:cypress/recommended"
],
"plugins": [
"mattermost",
"import",
"cypress"
],
Expand Down Expand Up @@ -67,10 +67,7 @@
{
"files": ["**/*.tsx", "**/*.ts"],
"extends": [
"./node_modules/eslint-config-mattermost/.eslintrc.json",
"./node_modules/eslint-config-mattermost/.eslintrc-react.json",
"plugin:@typescript-eslint/recommended",
"plugin:cypress/recommended"
"plugin:@typescript-eslint/recommended"
],
"rules": {
"comma-dangle": 0,
Expand Down
22 changes: 11 additions & 11 deletions actions/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function setItem(name, value) {
dispatch({
type: StorageTypes.SET_ITEM,
data: {prefix, name, value, timestamp: new Date()},
}, getState);
});
return {data: true};
};
}
Expand All @@ -23,47 +23,47 @@ export function removeItem(name) {
dispatch({
type: StorageTypes.REMOVE_ITEM,
data: {prefix, name},
}, getState);
});
return {data: true};
};
}

export function setGlobalItem(name, value) {
return (dispatch, getState) => {
return (dispatch) => {
dispatch({
type: StorageTypes.SET_GLOBAL_ITEM,
data: {name, value, timestamp: new Date()},
}, getState);
});
return {data: true};
};
}

export function removeGlobalItem(name) {
return (dispatch, getState) => {
return (dispatch) => {
dispatch({
type: StorageTypes.REMOVE_GLOBAL_ITEM,
data: {name},
}, getState);
});
return {data: true};
};
}

export function clear(options = {exclude: []}) {
return (dispatch, getState) => {
return (dispatch) => {
dispatch({
type: StorageTypes.CLEAR,
data: options,
}, getState);
});
return {data: true};
};
}

export function actionOnGlobalItemsWithPrefix(prefix, action) {
return (dispatch, getState) => {
return (dispatch) => {
dispatch({
type: StorageTypes.ACTION_ON_GLOBAL_ITEMS_WITH_PREFIX,
data: {prefix, action},
}, getState);
});
return {data: true};
};
}
Expand All @@ -75,7 +75,7 @@ export function actionOnItemsWithPrefix(prefix, action) {
dispatch({
type: StorageTypes.ACTION_ON_ITEMS_WITH_PREFIX,
data: {globalPrefix, prefix, action},
}, getState);
});
return {data: true};
};
}
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@
"enzyme-adapter-react-16": "1.14.0",
"enzyme-to-json": "3.4.3",
"eslint": "6.6.0",
"eslint-config-mattermost": "github:mattermost/eslint-config-mattermost#8f9eb1414bf9ebfb509359bddddfad9788ca3c3c",
"eslint-import-resolver-webpack": "0.11.1",
"eslint-plugin-cypress": "2.7.0",
"eslint-plugin-header": "3.0.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-mattermost": "github:mattermost/eslint-plugin-mattermost#070ce792d105482ffb2b27cfc0b7e78b3d20acee",
"eslint-plugin-react": "7.16.0",
"exports-loader": "0.7.0",
"file-loader": "4.2.0",
Expand Down

0 comments on commit 6a7b5a6

Please sign in to comment.