Skip to content

Commit 99c7fbd

Browse files
committed
feat: add require-rejects rule; fixes #755
1 parent 03adf63 commit 99c7fbd

File tree

16 files changed

+1206
-10
lines changed

16 files changed

+1206
-10
lines changed

.README/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ export default [
8484
'type',
8585
],
8686
},
87+
rejects: {
88+
required: [
89+
'type',
90+
],
91+
},
8792
},
8893
*/
8994
}
@@ -262,6 +267,7 @@ Finally, enable all of the rules that you would like to use.
262267
"jsdoc/require-property-name": 1, // Recommended
263268
"jsdoc/require-property-type": 1, // Recommended in non-TS configs
264269
"jsdoc/require-property": 1, // Recommended
270+
"jsdoc/require-rejects": 1, // Recommended
265271
"jsdoc/require-returns-check": 1, // Recommended
266272
"jsdoc/require-returns-description": 1, // Recommended
267273
"jsdoc/require-returns-type": 1, // Recommended in non-TS configs

.README/rules/require-rejects.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# `require-rejects`
2+
3+
Requires a (non-standard) `@rejects` tag be added for detectable `Promise`
4+
rejections.
5+
6+
## Options
7+
8+
{"gitdown": "options"}
9+
10+
|||
11+
|---|---|
12+
|Context|everywhere|
13+
|Tags|``|
14+
|Recommended|false|
15+
|Settings||
16+
|Options|`contexts`, `exemptedBy`|
17+
18+
## Failing examples
19+
20+
<!-- assertions-failing requireRejects -->
21+
22+
## Passing examples
23+
24+
<!-- assertions-passing requireRejects -->

.README/rules/require-throws.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
Requires that throw statements are documented.
66

7-
Note that since throw statements within async functions end up as rejected
8-
Promises, they are not considered as throw statements for the purposes of this
9-
rule. See [issue 755](https://github.com/gajus/eslint-plugin-jsdoc/issues/755)
10-
for our desire for a separate tag to document rejection types and see
7+
See
118
[this discussion](https://stackoverflow.com/questions/50071115/typescript-promise-rejection-type)
129
on why TypeScript doesn't offer such a feature.
1310

11+
Note that since throw statements within async functions end up as rejected
12+
`Promise`'s, they are not considered as throw statements for the purposes of
13+
this rule. See the `require-rejects` rule for a non-standard way to document
14+
`Promise` rejections.
15+
1416
## Options
1517

1618
{"gitdown": "options"}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export default [
103103
'type',
104104
],
105105
},
106+
rejects: {
107+
required: [
108+
'type',
109+
],
110+
},
106111
},
107112
*/
108113
}
@@ -289,6 +294,7 @@ Finally, enable all of the rules that you would like to use.
289294
"jsdoc/require-property-name": 1, // Recommended
290295
"jsdoc/require-property-type": 1, // Recommended in non-TS configs
291296
"jsdoc/require-property": 1, // Recommended
297+
"jsdoc/require-rejects": 1, // Recommended
292298
"jsdoc/require-returns-check": 1, // Recommended
293299
"jsdoc/require-returns-description": 1, // Recommended
294300
"jsdoc/require-returns-type": 1, // Recommended in non-TS configs
@@ -484,6 +490,7 @@ non-default-recommended fixer).
484490
|:heavy_check_mark:|| [require-property-description](./docs/rules/require-property-description.md#readme) | Requires that each `@property` tag has a `description` value. |
485491
|:heavy_check_mark:|| [require-property-name](./docs/rules/require-property-name.md#readme) | Requires that all `@property` tags have names. |
486492
|:heavy_check_mark: (Off in TS; On in TS flavor)|| [require-property-type](./docs/rules/require-property-type.md#readme) | Requires that each `@property` tag has a type value (in curly brackets). |
493+
||| [require-rejects](./docs/rules/require-rejects.md#readme) | Requires that Promise rejections are documented with `@rejects` tags. |
487494
|:heavy_check_mark:|:wrench:| [require-returns](./docs/rules/require-returns.md#readme) | Requires that returns are documented with `@returns`. |
488495
|:heavy_check_mark:|| [require-returns-check](./docs/rules/require-returns-check.md#readme) | Requires a return statement in function body if a `@returns` tag is specified in JSDoc comment(and reports if multiple `@returns` tags are present). |
489496
|:heavy_check_mark:|| [require-returns-description](./docs/rules/require-returns-description.md#readme) | Requires that the `@returns` tag has a `description` value (not including `void`/`undefined` type returns). |

0 commit comments

Comments
 (0)