File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,28 @@ function doSomethingElse() {
3232
3333##### ` allowThen `
3434
35- You can pass an ` { allowThen: true } ` as an option to this rule to allow for
36- ` .then(null, fn) ` to be used instead of ` catch() ` at the end of the promise
37- chain.
35+ The second argument to ` then() ` can also be used to handle a promise rejection,
36+ but it won't catch any errors from the first argument callback. Because of this,
37+ this rule reports usage of ` then() ` with two arguments without ` catch() ` by
38+ default.
39+
40+ However, you can use ` { allowThen: true } ` to allow using ` then() ` with two
41+ arguments instead of ` catch() ` to handle promise rejections.
42+
43+ Examples of ** incorrect** code for the default ` { allowThen: false } ` option:
44+
45+ ``` js
46+ myPromise .then (doSomething, handleErrors)
47+ myPromise .then (null , handleErrors)
48+ ```
49+
50+ Examples of ** correct** code for the ` { allowThen: true } ` option:
51+
52+ ``` js
53+ myPromise .then (doSomething, handleErrors)
54+ myPromise .then (null , handleErrors)
55+ myPromise .then (doSomething).catch (handleErrors)
56+ ```
3857
3958##### ` allowFinally `
4059
You can’t perform that action at this time.
0 commit comments