From 589a2a64ac9756d215c09883a695d0f75df2397a Mon Sep 17 00:00:00 2001 From: Patrick Taylor Date: Wed, 17 Jul 2024 14:58:12 +0100 Subject: [PATCH] =?UTF-8?q?Configured=20`eslint-plugin-promise`=20?= =?UTF-8?q?=F0=9F=AA=86=20(#11)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .depcheckrc | 1 + config/eslint/build-config.ts | 3 +++ config/eslint/rules/promise.ts | 22 ++++++++++++++++++++++ package.json | 2 ++ yarn.lock | 5 +++++ 5 files changed, 33 insertions(+) create mode 100644 config/eslint/rules/promise.ts diff --git a/.depcheckrc b/.depcheckrc index 815b091..c0aef18 100644 --- a/.depcheckrc +++ b/.depcheckrc @@ -1,6 +1,7 @@ ignores: [ "eslint-plugin-eslint-comments", "eslint-plugin-inclusive-language", + "eslint-plugin-promise", "eslint-plugin-sort-destructure-keys", "eslint-plugin-sort-exports", "@types/jest", diff --git a/config/eslint/build-config.ts b/config/eslint/build-config.ts index cec368e..3e6c423 100644 --- a/config/eslint/build-config.ts +++ b/config/eslint/build-config.ts @@ -1,5 +1,6 @@ import ESLintComments from './rules/eslint-comments' import InclusiveLanguage from './rules/inclusive-language' +import PromiseRules from './rules/promise' import SortDestructureKeys from './rules/sort-destructure-keys' import SortExports from './rules/sort-exports' @@ -7,12 +8,14 @@ const buildConfig = () => ({ plugins: [ 'eslint-comments', 'inclusive-language', + 'promise', 'sort-destructure-keys', 'sort-exports', ], rules: { ...ESLintComments, ...InclusiveLanguage, + ...PromiseRules, ...SortDestructureKeys, ...SortExports, }, diff --git a/config/eslint/rules/promise.ts b/config/eslint/rules/promise.ts new file mode 100644 index 0000000..3af2329 --- /dev/null +++ b/config/eslint/rules/promise.ts @@ -0,0 +1,22 @@ +// https://github.com/eslint-community/eslint-plugin-promise + +export default { + 'promise/always-return': 2, + 'promise/avoid-new': 0, + 'promise/catch-or-return': 2, + 'promise/no-callback-in-promise': 2, + 'promise/no-multiple-resolved': 2, + 'promise/no-native': 0, + 'promise/no-nesting': 2, + 'promise/no-new-statics': 2, + 'promise/no-promise-in-callback': 2, + 'promise/no-return-in-finally': 2, + 'promise/no-return-wrap': 2, + 'promise/param-names': [2, { + rejectPattern: '^_?reject', + resolvePattern: '^_?resolve', + }], + 'promise/prefer-await-to-callbacks': 0, + 'promise/prefer-await-to-then': 0, + 'promise/valid-params': 2, +} diff --git a/package.json b/package.json index 1349f94..961a2e2 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "eslint": "9.4.0", "eslint-plugin-eslint-comments": "3.2.0", "eslint-plugin-inclusive-language": "2.2.1", + "eslint-plugin-promise": "6.4.0", "eslint-plugin-sort-destructure-keys": "2.0.0", "eslint-plugin-sort-exports": "0.9.1", "glob": "10.4.1", @@ -61,6 +62,7 @@ "eslint", "eslint-plugin-eslint-comments", "eslint-plugin-inclusive-language", + "eslint-plugin-promise", "eslint-plugin-sort-destructure-keys", "eslint-plugin-sort-exports", "lint", diff --git a/yarn.lock b/yarn.lock index b17d458..bc296f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2409,6 +2409,11 @@ eslint-plugin-inclusive-language@2.2.1: dependencies: humps "^2.0.1" +eslint-plugin-promise@6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-6.4.0.tgz#54926d53c79541efe9cea6ac1d823a58bbed1106" + integrity sha512-/KWWRaD3fGkVCZsdR0RU53PSthFmoHVhZl+y9+6DqeDLSikLdlUVpVEAmI6iCRR5QyOjBYBqHZV/bdv4DJ4Gtw== + eslint-plugin-sort-destructure-keys@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/eslint-plugin-sort-destructure-keys/-/eslint-plugin-sort-destructure-keys-2.0.0.tgz#23d26e3db4a8fb73fcd0dfceb2de4c517e6d603f"