-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(param-names): fix incorrect description location (#137)
- Loading branch information
Showing
2 changed files
with
26 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
# Enforce consistent param names when creating new promises (param-names) | ||
|
||
Enforce standard parameter names for Promise constructors | ||
|
||
:wrench: The `--fix` option on the command line can automatically fix some of | ||
the problems reported by this rule. | ||
|
||
#### Valid | ||
|
||
```js | ||
new Promise(function (resolve) { ... }) | ||
new Promise(function (resolve, reject) { ... }) | ||
``` | ||
|
||
#### Invalid | ||
|
||
```js | ||
new Promise(function (reject, resolve) { ... }) // incorrect order | ||
new Promise(function (ok, fail) { ... }) // non-standard parameter names | ||
``` | ||
|
||
Ensures that `new Promise()` is instantiated with the parameter names | ||
`resolve, reject` to avoid confusion with order such as `reject, resolve`. The | ||
Promise constructor uses the | ||
[RevealingConstructor pattern](https://blog.domenic.me/the-revealing-constructor-pattern/). | ||
Using the same parameter names as the language specification makes code more | ||
uniform and easier to understand. |