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:
committed by
Facebook GitHub Bot
parent
c897d92df8
commit
3f55ceac8f
@@ -43,6 +43,7 @@ module.exports = {
|
|||||||
'node',
|
'node',
|
||||||
'react-hooks',
|
'react-hooks',
|
||||||
'flipper',
|
'flipper',
|
||||||
|
'promise',
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
// disable rules from eslint-config-fbjs
|
// disable rules from eslint-config-fbjs
|
||||||
@@ -96,6 +97,14 @@ module.exports = {
|
|||||||
'flipper/no-relative-imports-across-packages': [2],
|
'flipper/no-relative-imports-across-packages': [2],
|
||||||
'flipper/no-electron-remote-imports': [1],
|
'flipper/no-electron-remote-imports': [1],
|
||||||
'flipper/no-console-error-without-context': [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: {
|
settings: {
|
||||||
'import/resolver': {
|
'import/resolver': {
|
||||||
|
|||||||
@@ -147,6 +147,7 @@
|
|||||||
"eslint-plugin-jsx-a11y": "^6.4.1",
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^3.4.0",
|
"eslint-plugin-prettier": "^3.4.0",
|
||||||
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"eslint-plugin-react": "^7.23.2",
|
"eslint-plugin-react": "^7.23.2",
|
||||||
"eslint-plugin-react-hooks": "^4.2.0",
|
"eslint-plugin-react-hooks": "^4.2.0",
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
|
|||||||
@@ -193,9 +193,11 @@ app.on('ready', () => {
|
|||||||
console.log('Force updating DevTools');
|
console.log('Force updating DevTools');
|
||||||
}
|
}
|
||||||
// Redux
|
// 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);
|
console.error('Failed to install Redux devtools extension', e);
|
||||||
}, forceDownload);
|
});
|
||||||
// React
|
// React
|
||||||
// Fix for extension loading (see D27685981)
|
// Fix for extension loading (see D27685981)
|
||||||
// Work around per https://github.com/electron/electron/issues/23662#issuecomment-787420799
|
// Work around per https://github.com/electron/electron/issues/23662#issuecomment-787420799
|
||||||
|
|||||||
@@ -6049,6 +6049,11 @@ eslint-plugin-prettier@^3.4.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
prettier-linter-helpers "^1.0.0"
|
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:
|
eslint-plugin-react-hooks@^4.2.0:
|
||||||
version "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"
|
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556"
|
||||||
|
|||||||
Reference in New Issue
Block a user