diff --git a/package-lock.json b/package-lock.json index df066f7..a94c1f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "eslint-plugin-jsdoc": "50.6.0", "eslint-plugin-n": "17.14.0", "eslint-plugin-prefer-arrow": "1.2.3", - "eslint-plugin-promise": "7.1.0", + "eslint-plugin-promise": "7.2.1", "eslint-plugin-rxjs": "5.0.3", "eslint-plugin-security": "3.0.1", "eslint-plugin-simple-import-sort": "12.1.1", @@ -62,7 +62,7 @@ "eslint-plugin-jsdoc": "^50.6.0", "eslint-plugin-n": "^17.14.0", "eslint-plugin-prefer-arrow": "^1.2.3", - "eslint-plugin-promise": "^7.1.0", + "eslint-plugin-promise": "^7.2.1", "eslint-plugin-rxjs": "^5.0.3", "eslint-plugin-security": "^3.0.1", "eslint-plugin-simple-import-sort": "^12.1.1", @@ -4626,11 +4626,14 @@ } }, "node_modules/eslint-plugin-promise": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.1.0.tgz", - "integrity": "sha512-8trNmPxdAy3W620WKDpaS65NlM5yAumod6XeC4LOb+jxlkG4IVcp68c6dXY2ev+uT4U1PtG57YDV6EGAXN0GbQ==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.2.1.tgz", + "integrity": "sha512-SWKjd+EuvWkYaS+uN2csvj0KoP43YTu7+phKQ5v+xw6+A0gutVX2yqCeCkC3uLCJFiPfR2dD8Es5L7yUsmvEaA==", "dev": true, "license": "ISC", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0" + }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, diff --git a/package.json b/package.json index b73cdaa..a0bcb13 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "eslint-plugin-jsdoc": "^50.6.0", "eslint-plugin-n": "^17.14.0", "eslint-plugin-prefer-arrow": "^1.2.3", - "eslint-plugin-promise": "^7.1.0", + "eslint-plugin-promise": "^7.2.1", "eslint-plugin-rxjs": "^5.0.3", "eslint-plugin-security": "^3.0.1", "eslint-plugin-simple-import-sort": "^12.1.1", @@ -98,7 +98,7 @@ "eslint-plugin-jsdoc": "50.6.0", "eslint-plugin-n": "17.14.0", "eslint-plugin-prefer-arrow": "1.2.3", - "eslint-plugin-promise": "7.1.0", + "eslint-plugin-promise": "7.2.1", "eslint-plugin-rxjs": "5.0.3", "eslint-plugin-security": "3.0.1", "eslint-plugin-simple-import-sort": "12.1.1", diff --git a/src/rules/promise/index.adoc b/src/rules/promise/index.adoc index f5836ac..3ffbc86 100644 --- a/src/rules/promise/index.adoc +++ b/src/rules/promise/index.adoc @@ -70,15 +70,11 @@ to enforce best practices for JavaScript promises. | Error -| `link:{eslint-promise-rules}/spec-only.md[promise/spec-only]` -| -| -| Error - -| `link:{eslint-promise-rules}/valid-params.md[promise/valid-params]` +| `link:{eslint-promise-rules}/prefer-await-to-callbacks.md[promise/prefer-await-to-callbacks]` | | -| Error +| Off +4+| Requires ES2017 `async`/`await`. | `link:{eslint-promise-rules}/prefer-await-to-then.md[promise/prefer-await-to-then]` | @@ -88,10 +84,19 @@ to enforce best practices for JavaScript promises. and would be turned off either way, as Promises should be preferred. -| `link:{eslint-promise-rules}/prefer-await-to-callbacks.md[promise/prefer-await-to-callbacks]` +| `link:{eslint-promise-rules}/prefer-catch.md[promise/prefer-catch]` | | -| Off -4+| Requires ES2017 `async`/`await`. +| Warning + +| `link:{eslint-promise-rules}/spec-only.md[promise/spec-only]` +| +| +| Error + +| `link:{eslint-promise-rules}/valid-params.md[promise/valid-params]` +| +| +| Error |=== diff --git a/src/rules/promise/index.ts b/src/rules/promise/index.ts index 19a98ab..172ed92 100644 --- a/src/rules/promise/index.ts +++ b/src/rules/promise/index.ts @@ -6,18 +6,29 @@ export const promiseConfig = { promise: eslintPluginPromise, }, rules: { - 'promise/catch-or-return': 'error', + 'promise/catch-or-return': ['error', { + allowThen: false, + allowThenStrict: false, + allowFinally: true, + }], 'promise/no-return-wrap': 'error', 'promise/param-names': 'warn', - 'promise/always-return': 'error', + 'promise/always-return': ['error', { + ignoreAssignmentVariable: [ + 'globalThis', + ], + }], 'promise/no-multiple-resolved': 'error', 'promise/no-native': 'off', 'promise/no-nesting': 'error', 'promise/no-promise-in-callback': 'error', - 'promise/no-callback-in-promise': 'error', + 'promise/no-callback-in-promise': ['error', { + timeoutsErr: false, + }], 'promise/avoid-new': 'off', 'promise/no-new-statics': 'warn', 'promise/no-return-in-finally': 'error', + 'promise/prefer-catch': 'warn', 'promise/spec-only': ['error', { allowedMethods: [], }],