Added few eslint rules checking promises

Summary:
Added rules to ensure we properly propagate errors from promises.

Also found and fixed a place where promise function parameter was mismatched.

Reviewed By: mweststrate

Differential Revision: D28537820

fbshipit-source-id: b93f44274fc76544049813f645508cb78e432880
This commit is contained in:
Anton Nikolaev
2021-05-19 09:29:41 -07:00
committed by Facebook GitHub Bot
parent c897d92df8
commit 3f55ceac8f
4 changed files with 19 additions and 2 deletions

View File

@@ -43,6 +43,7 @@ module.exports = {
'node',
'react-hooks',
'flipper',
'promise',
],
rules: {
// disable rules from eslint-config-fbjs
@@ -96,6 +97,14 @@ module.exports = {
'flipper/no-relative-imports-across-packages': [2],
'flipper/no-electron-remote-imports': [1],
'flipper/no-console-error-without-context': [1],
// promise rules, see https://github.com/xjamundx/eslint-plugin-promise for details on each of them
'promise/catch-or-return': 'warn',
'promise/no-nesting': 'warn',
'promise/no-promise-in-callback': 'warn',
'promise/no-callback-in-promise': 'warn',
'promise/no-return-in-finally': 'warn',
'promise/valid-params': 'error',
},
settings: {
'import/resolver': {

View File

@@ -147,6 +147,7 @@
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.2.0",
"expand-tilde": "^2.0.2",

View File

@@ -193,9 +193,11 @@ app.on('ready', () => {
console.log('Force updating DevTools');
}
// Redux
await installExtension(REDUX_DEVTOOLS.id).catch((e: any) => {
await installExtension(REDUX_DEVTOOLS.id, {
loadExtensionOptions: {allowFileAccess: true, forceDownload},
}).catch((e: any) => {
console.error('Failed to install Redux devtools extension', e);
}, forceDownload);
});
// React
// Fix for extension loading (see D27685981)
// Work around per https://github.com/electron/electron/issues/23662#issuecomment-787420799

View File

@@ -6049,6 +6049,11 @@ eslint-plugin-prettier@^3.4.0:
dependencies:
prettier-linter-helpers "^1.0.0"
eslint-plugin-promise@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-5.1.0.tgz#fb2188fb734e4557993733b41aa1a688f46c6f24"
integrity sha512-NGmI6BH5L12pl7ScQHbg7tvtk4wPxxj8yPHH47NvSmMtFneC077PSeY3huFj06ZWZvtbfxSPt3RuOQD5XcR4ng==
eslint-plugin-react-hooks@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556"