Skip to content

Commit 38770c4

Browse files
authored
fix(require-yields-*, require-throws-*): ensure alias of throws (exception) and of yields (yield) are checked; fixes #1559 (#1560)
1 parent 0837647 commit 38770c4

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

docs/rules/require-yields-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ The following patterns are considered problems:
2323
* @yields
2424
*/
2525
// Message: @yields should have a type
26+
27+
/**
28+
* @yield
29+
*/
30+
// Message: @yields should have a type
2631
````
2732

2833

src/index-cjs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ index.rules = {
205205
'require-throws-description': buildForbidRuleDefinition({
206206
contexts: [
207207
{
208-
comment: 'JsdocBlock:has(JsdocTag[tag=throws]:not([description!=""]))',
208+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([description!=""]))',
209209
context: 'any',
210210
message: '@throws should have a description',
211211
},
@@ -216,7 +216,7 @@ index.rules = {
216216
'require-throws-type': buildForbidRuleDefinition({
217217
contexts: [
218218
{
219-
comment: 'JsdocBlock:has(JsdocTag[tag=throws]:not([parsedType.type]))',
219+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([parsedType.type]))',
220220
context: 'any',
221221
message: '@throws should have a type',
222222
},
@@ -229,7 +229,7 @@ index.rules = {
229229
'require-yields-description': buildForbidRuleDefinition({
230230
contexts: [
231231
{
232-
comment: 'JsdocBlock:has(JsdocTag[tag=yields]:not([name!=""]):not([description!=""]))',
232+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([name!=""]):not([description!=""]))',
233233
context: 'any',
234234
message: '@yields should have a description',
235235
},
@@ -240,7 +240,7 @@ index.rules = {
240240
'require-yields-type': buildForbidRuleDefinition({
241241
contexts: [
242242
{
243-
comment: 'JsdocBlock:has(JsdocTag[tag=yields]:not([parsedType.type]))',
243+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([parsedType.type]))',
244244
context: 'any',
245245
message: '@yields should have a type',
246246
},

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ index.rules = {
211211
'require-throws-description': buildForbidRuleDefinition({
212212
contexts: [
213213
{
214-
comment: 'JsdocBlock:has(JsdocTag[tag=throws]:not([description!=""]))',
214+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([description!=""]))',
215215
context: 'any',
216216
message: '@throws should have a description',
217217
},
@@ -222,7 +222,7 @@ index.rules = {
222222
'require-throws-type': buildForbidRuleDefinition({
223223
contexts: [
224224
{
225-
comment: 'JsdocBlock:has(JsdocTag[tag=throws]:not([parsedType.type]))',
225+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([parsedType.type]))',
226226
context: 'any',
227227
message: '@throws should have a type',
228228
},
@@ -235,7 +235,7 @@ index.rules = {
235235
'require-yields-description': buildForbidRuleDefinition({
236236
contexts: [
237237
{
238-
comment: 'JsdocBlock:has(JsdocTag[tag=yields]:not([name!=""]):not([description!=""]))',
238+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([name!=""]):not([description!=""]))',
239239
context: 'any',
240240
message: '@yields should have a description',
241241
},
@@ -246,7 +246,7 @@ index.rules = {
246246
'require-yields-type': buildForbidRuleDefinition({
247247
contexts: [
248248
{
249-
comment: 'JsdocBlock:has(JsdocTag[tag=yields]:not([parsedType.type]))',
249+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([parsedType.type]))',
250250
context: 'any',
251251
message: '@yields should have a type',
252252
},

test/rules/assertions/requireYieldsType.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ export default {
1313
},
1414
],
1515
},
16+
{
17+
code: `
18+
/**
19+
* @yield
20+
*/
21+
`,
22+
errors: [
23+
{
24+
line: 2,
25+
message: '@yields should have a type',
26+
},
27+
],
28+
},
1629
],
1730
valid: [
1831
{

0 commit comments

Comments
 (0)