From 5573f6e31e3efd8477249242cfddb39a8666f728 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Thu, 4 May 2023 13:45:10 +0200 Subject: [PATCH 1/3] Add eslint-plugin-promise to base package The plugin is added to the eslint configuration, with the no-multiple-resolved rule enabled. This avoids situations where both `resolve()` and `reject()` can be called, due to a missing `return` statement. --- packages/base/README.md | 1 + packages/base/package.json | 2 ++ packages/base/src/index.js | 4 +++- yarn.lock | 11 +++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/base/README.md b/packages/base/README.md index bba425b0..f722e438 100644 --- a/packages/base/README.md +++ b/packages/base/README.md @@ -14,6 +14,7 @@ yarn add --dev \ eslint-plugin-import@^2.26.0 \ eslint-plugin-jsdoc@^39.6.2 \ eslint-plugin-prettier@^4.2.1 \ + eslint-plugin-promise@^6.1.1 \ prettier@^2.7.1 ``` diff --git a/packages/base/package.json b/packages/base/package.json index 940652a6..31348032 100644 --- a/packages/base/package.json +++ b/packages/base/package.json @@ -28,6 +28,7 @@ "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsdoc": "^39.6.2", "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-promise": "^6.1.1", "prettier": "^2.7.1" }, "peerDependencies": { @@ -36,6 +37,7 @@ "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsdoc": "^39.6.2", "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-promise": "^6.1.1", "prettier": "^2.7.1" }, "engines": { diff --git a/packages/base/src/index.js b/packages/base/src/index.js index 1305b129..9da71a9d 100644 --- a/packages/base/src/index.js +++ b/packages/base/src/index.js @@ -20,7 +20,7 @@ module.exports = { sourceType: 'script', }, - plugins: ['jsdoc', 'prettier'], + plugins: ['jsdoc', 'prettier', 'promise'], extends: [ 'eslint:recommended', @@ -394,5 +394,7 @@ module.exports = { 'jsdoc/require-yields-check': 'error', 'jsdoc/tag-lines': 'error', 'jsdoc/valid-types': 'error', + + 'promise/no-multiple-resolved': 'error', }, }; diff --git a/yarn.lock b/yarn.lock index 88b89069..000a4d08 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1033,6 +1033,7 @@ __metadata: eslint-plugin-import: ^2.26.0 eslint-plugin-jsdoc: ^39.6.2 eslint-plugin-prettier: ^4.2.1 + eslint-plugin-promise: ^6.1.1 prettier: ^2.7.1 peerDependencies: eslint: ^8.27.0 @@ -1040,6 +1041,7 @@ __metadata: eslint-plugin-import: ^2.26.0 eslint-plugin-jsdoc: ^39.6.2 eslint-plugin-prettier: ^4.2.1 + eslint-plugin-promise: ^6.1.1 prettier: ^2.7.1 languageName: unknown linkType: soft @@ -2717,6 +2719,15 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-promise@npm:^6.1.1": + version: 6.1.1 + resolution: "eslint-plugin-promise@npm:6.1.1" + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + checksum: 46b9a4f79dae5539987922afc27cc17cbccdecf4f0ba19c0ccbf911b0e31853e9f39d9959eefb9637461b52772afa1a482f1f87ff16c1ba38bdb6fcf21897e9a + languageName: node + linkType: hard + "eslint-scope@npm:^5.1.1": version: 5.1.1 resolution: "eslint-scope@npm:5.1.1" From 48e25532000e5ad0eb454498cabfeaf833a34271 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Thu, 4 May 2023 13:46:07 +0200 Subject: [PATCH 2/3] Update `rules-snapshot.json` to include the new rule --- packages/base/rules-snapshot.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base/rules-snapshot.json b/packages/base/rules-snapshot.json index 751cdaea..e1ddea4e 100644 --- a/packages/base/rules-snapshot.json +++ b/packages/base/rules-snapshot.json @@ -3320,6 +3320,7 @@ "usePrettierrc": true } ], + "promise/no-multiple-resolved": "error", "quote-props": "off", "quotes": "off", "radix": "error", From 51d0a39d0e2af7c9c397aa88126d93d2f169c2c0 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Thu, 4 May 2023 13:48:30 +0200 Subject: [PATCH 3/3] Update all READMEs to include the new plugin --- packages/browser/README.md | 1 + packages/commonjs/README.md | 1 + packages/jest/README.md | 1 + packages/mocha/README.md | 1 + packages/nodejs/README.md | 1 + packages/typescript/README.md | 1 + 6 files changed, 6 insertions(+) diff --git a/packages/browser/README.md b/packages/browser/README.md index 85b3938a..f5611971 100644 --- a/packages/browser/README.md +++ b/packages/browser/README.md @@ -15,6 +15,7 @@ yarn add --dev \ eslint-plugin-import@^2.26.0 \ eslint-plugin-jsdoc@^39.6.2 \ eslint-plugin-prettier@^4.2.1 \ + eslint-plugin-promise@^6.1.1 \ prettier@^2.7.1 ``` diff --git a/packages/commonjs/README.md b/packages/commonjs/README.md index 6f0af4d1..04b708e0 100644 --- a/packages/commonjs/README.md +++ b/packages/commonjs/README.md @@ -13,6 +13,7 @@ yarn add --dev \ eslint-plugin-import@^2.26.0 \ eslint-plugin-jsdoc@^39.6.2 \ eslint-plugin-prettier@^4.2.1 \ + eslint-plugin-promise@^6.1.1 \ prettier@^2.7.1 ``` diff --git a/packages/jest/README.md b/packages/jest/README.md index 077f1a26..e1f21844 100644 --- a/packages/jest/README.md +++ b/packages/jest/README.md @@ -14,6 +14,7 @@ yarn add --dev \ eslint-plugin-jsdoc@^39.6.2 \ eslint-plugin-jest@^27.1.5 \ eslint-plugin-prettier@^4.2.1 \ + eslint-plugin-promise@^6.1.1 \ prettier@^2.7.1 ``` diff --git a/packages/mocha/README.md b/packages/mocha/README.md index b4432e02..07b8087f 100644 --- a/packages/mocha/README.md +++ b/packages/mocha/README.md @@ -14,6 +14,7 @@ yarn add --dev \ eslint-plugin-jsdoc@^39.6.2 \ eslint-plugin-mocha@^10.1.0 \ eslint-plugin-prettier@^4.2.1 \ + eslint-plugin-promise@^6.1.1 \ prettier@^2.7.1 ``` diff --git a/packages/nodejs/README.md b/packages/nodejs/README.md index b519b9cb..ff38236d 100644 --- a/packages/nodejs/README.md +++ b/packages/nodejs/README.md @@ -14,6 +14,7 @@ yarn add --dev \ eslint-plugin-jsdoc@^39.6.2 \ eslint-plugin-node@^11.1.0 \ eslint-plugin-prettier@^4.2.1 \ + eslint-plugin-promise@^6.1.1 \ prettier@^2.7.1 ``` diff --git a/packages/typescript/README.md b/packages/typescript/README.md index 6edcdc47..01d254db 100644 --- a/packages/typescript/README.md +++ b/packages/typescript/README.md @@ -15,6 +15,7 @@ yarn add --dev \ eslint-plugin-import@^2.26.0 \ eslint-plugin-jsdoc@^39.6.2 \ eslint-plugin-prettier@^4.2.1 \ + eslint-plugin-promise@^6.1.1 \ prettier@^2.7.1 ```