Skip to content

Commit 9d0e447

Browse files
authored
docs: recommend util.promisify instead of pify and util.callbackify over nodeify (#492)
1 parent fa482cc commit 9d0e447

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,23 @@ or start with the recommended rule set:
9898
✅ Set in the `recommended` configuration.\
9999
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
100100

101-
| Name                      | Description | 💼 | ⚠️ | 🚫 | 🔧 |
102-
| :------------------------------------------------------------------- | :------------------------------------------------------------------------------------- | :-- | :-- | :-- | :-- |
103-
| [always-return](docs/rules/always-return.md) | Require returning inside each `then()` to create readable and reusable Promise chains. || | | |
104-
| [avoid-new](docs/rules/avoid-new.md) | Disallow creating `new` promises outside of utility libs (use [pify][] instead). | | || |
105-
| [catch-or-return](docs/rules/catch-or-return.md) | Enforce the use of `catch()` on un-returned promises. || | | |
106-
| [no-callback-in-promise](docs/rules/no-callback-in-promise.md) | Disallow calling `cb()` inside of a `then()` (use [nodeify][] instead). | || | |
107-
| [no-multiple-resolved](docs/rules/no-multiple-resolved.md) | Disallow creating new promises with paths that resolve multiple times. | | | | |
108-
| [no-native](docs/rules/no-native.md) | Require creating a `Promise` constructor before using it in an ES5 environment. | | || |
109-
| [no-nesting](docs/rules/no-nesting.md) | Disallow nested `then()` or `catch()` statements. | || | |
110-
| [no-new-statics](docs/rules/no-new-statics.md) | Disallow calling `new` on a Promise static method. || | | 🔧 |
111-
| [no-promise-in-callback](docs/rules/no-promise-in-callback.md) | Disallow using promises inside of callbacks. | || | |
112-
| [no-return-in-finally](docs/rules/no-return-in-finally.md) | Disallow return statements in `finally()`. | || | |
113-
| [no-return-wrap](docs/rules/no-return-wrap.md) | Disallow wrapping values in `Promise.resolve` or `Promise.reject` when not needed. || | | |
114-
| [param-names](docs/rules/param-names.md) | Enforce consistent param names and ordering when creating new promises. || | | |
115-
| [prefer-await-to-callbacks](docs/rules/prefer-await-to-callbacks.md) | Prefer `async`/`await` to the callback pattern. | | | | |
116-
| [prefer-await-to-then](docs/rules/prefer-await-to-then.md) | Prefer `await` to `then()`/`catch()`/`finally()` for reading Promise values. | | | | |
117-
| [valid-params](docs/rules/valid-params.md) | Enforces the proper number of arguments are passed to Promise functions. | || | |
101+
| Name                      | Description | 💼 | ⚠️ | 🚫 | 🔧 |
102+
| :------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :-- | :-- | :-- | :-- |
103+
| [always-return](docs/rules/always-return.md) | Require returning inside each `then()` to create readable and reusable Promise chains. || | | |
104+
| [avoid-new](docs/rules/avoid-new.md) | Disallow creating `new` promises outside of utility libs (use [util.promisify][] instead). | | || |
105+
| [catch-or-return](docs/rules/catch-or-return.md) | Enforce the use of `catch()` on un-returned promises. || | | |
106+
| [no-callback-in-promise](docs/rules/no-callback-in-promise.md) | Disallow calling `cb()` inside of a `then()` (use [util.callbackify][] instead). | || | |
107+
| [no-multiple-resolved](docs/rules/no-multiple-resolved.md) | Disallow creating new promises with paths that resolve multiple times. | | | | |
108+
| [no-native](docs/rules/no-native.md) | Require creating a `Promise` constructor before using it in an ES5 environment. | | || |
109+
| [no-nesting](docs/rules/no-nesting.md) | Disallow nested `then()` or `catch()` statements. | || | |
110+
| [no-new-statics](docs/rules/no-new-statics.md) | Disallow calling `new` on a Promise static method. || | | 🔧 |
111+
| [no-promise-in-callback](docs/rules/no-promise-in-callback.md) | Disallow using promises inside of callbacks. | || | |
112+
| [no-return-in-finally](docs/rules/no-return-in-finally.md) | Disallow return statements in `finally()`. | || | |
113+
| [no-return-wrap](docs/rules/no-return-wrap.md) | Disallow wrapping values in `Promise.resolve` or `Promise.reject` when not needed. || | | |
114+
| [param-names](docs/rules/param-names.md) | Enforce consistent param names and ordering when creating new promises. || | | |
115+
| [prefer-await-to-callbacks](docs/rules/prefer-await-to-callbacks.md) | Prefer `async`/`await` to the callback pattern. | | | | |
116+
| [prefer-await-to-then](docs/rules/prefer-await-to-then.md) | Prefer `await` to `then()`/`catch()`/`finally()` for reading Promise values. | | | | |
117+
| [valid-params](docs/rules/valid-params.md) | Enforces the proper number of arguments are passed to Promise functions. | || | |
118118

119119
<!-- end auto-generated rules list -->
120120

@@ -129,8 +129,10 @@ or start with the recommended rule set:
129129
- (c) MMXV jden <mailto:[email protected]> - ISC license.
130130
- (c) 2016 Jamund Ferguson <mailto:[email protected]> - ISC license.
131131

132-
[nodeify]: https://www.npmjs.com/package/nodeify
133-
[pify]: https://www.npmjs.com/package/pify
132+
[util.callbackify]:
133+
https://nodejs.org/docs/latest/api/util.html#utilcallbackifyoriginal
134+
[util.promisify]:
135+
https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original
134136
[@aaditmshah]: https://github.com/aaditmshah
135137
[@macklinu]: https://github.com/macklinu
136138
[@xjamundx]: https://github.com/xjamundx

docs/rules/avoid-new.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Disallow creating `new` promises outside of utility libs (use [pify][] instead) (`promise/avoid-new`)
1+
# Disallow creating `new` promises outside of utility libs (use [util.promisify][] instead) (`promise/avoid-new`)
22

33
🚫 This rule is _disabled_ in the following configs: ✅ `flat/recommended`, ✅
44
`recommended`.
55

66
<!-- end auto-generated rule header -->
77

8-
[pify]: https://www.npmjs.com/package/pify
8+
[util.promisify]:
9+
https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original

docs/rules/no-callback-in-promise.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallow calling `cb()` inside of a `then()` (use [nodeify][] instead) (`promise/no-callback-in-promise`)
1+
# Disallow calling `cb()` inside of a `then()` (use [util.callbackify][] instead) (`promise/no-callback-in-promise`)
22

33
⚠️ This rule _warns_ in the following configs: ✅ `flat/recommended`, ✅
44
`recommended`.
@@ -80,4 +80,5 @@ callback code instead of combining the approaches.
8080

8181
String list of callback function names to exempt.
8282

83-
[nodeify]: https://www.npmjs.com/package/nodeify
83+
[util.callbackify]:
84+
https://nodejs.org/docs/latest/api/util.html#utilcallbackifyoriginal

rules/avoid-new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
type: 'suggestion',
1313
docs: {
1414
description:
15-
'Disallow creating `new` promises outside of utility libs (use [pify][] instead).',
15+
'Disallow creating `new` promises outside of utility libs (use [util.promisify][] instead).',
1616
url: getDocsUrl('avoid-new'),
1717
},
1818
schema: [],

rules/no-callback-in-promise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
type: 'suggestion',
1919
docs: {
2020
description:
21-
'Disallow calling `cb()` inside of a `then()` (use [nodeify][] instead).',
21+
'Disallow calling `cb()` inside of a `then()` (use [util.callbackify][] instead).',
2222
url: getDocsUrl('no-callback-in-promise'),
2323
},
2424
messages: {

0 commit comments

Comments
 (0)