@@ -33,6 +33,7 @@ JSDoc linting rules for ESLint.
33
33
* [ ` require-param ` ] ( #eslint-plugin-jsdoc-rules-require-param )
34
34
* [ ` require-returns-description ` ] ( #eslint-plugin-jsdoc-rules-require-returns-description )
35
35
* [ ` require-returns-type ` ] ( #eslint-plugin-jsdoc-rules-require-returns-type )
36
+ * [ ` require-returns-check ` ] ( #eslint-plugin-jsdoc-rules-require-returns-check )
36
37
* [ ` require-returns ` ] ( #eslint-plugin-jsdoc-rules-require-returns )
37
38
* [ ` valid-types ` ] ( #eslint-plugin-jsdoc-rules-valid-types )
38
39
@@ -58,6 +59,7 @@ This table maps the rules between `eslint-plugin-jsdoc` and `jscs-jsdoc`.
58
59
| [ ` require-param-name ` ] ( https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-name ) | N/A |
59
60
| [ ` require-param-type ` ] ( https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type ) | [ ` requireParamTypes ` ] ( https://github.com/jscs-dev/jscs-jsdoc#requireparamtypes ) |
60
61
| [ ` require-returns ` ] ( https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns ) | [ ` requireReturn ` ] ( https://github.com/jscs-dev/jscs-jsdoc#requirereturn ) |
62
+ | [ ` require-returns-check ` ] ( https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-check ) | [ ` requireReturn ` ] ( https://github.com/jscs-dev/jscs-jsdoc#requirereturncheck ) |
61
63
| [ ` require-returns-description ` ] ( https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-description ) | [ ` requireReturnDescription ` ] ( https://github.com/jscs-dev/jscs-jsdoc#requirereturndescription ) |
62
64
| [ ` require-returns-type ` ] ( https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type ) | [ ` requireReturnTypes ` ] ( https://github.com/jscs-dev/jscs-jsdoc#requirereturntypes ) |
63
65
| [ ` valid-types ` ] ( https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-valid-types ) | N/A |
@@ -117,6 +119,7 @@ Finally, enable all of the rules that you would like to use.
117
119
"jsdoc/require-param-name" : 1 ,
118
120
"jsdoc/require-param-type" : 1 ,
119
121
"jsdoc/require-returns" : 1 ,
122
+ "jsdoc/require-returns-check" : 1 ,
120
123
"jsdoc/require-returns-description" : 1 ,
121
124
"jsdoc/require-returns-type" : 1 ,
122
125
"jsdoc/valid-types" : 1
@@ -376,7 +379,7 @@ function quux () {
376
379
377
380
}
378
381
// Settings: {"jsdoc":{"baseConfig":{"rules":{"no-undef":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}}
379
- // Message: @example error (semi ): Extra semicolon .
382
+ // Message: @example error (no-undef ): 'quux' is not defined .
380
383
381
384
/**
382
385
* @example <caption> Valid usage </caption>
@@ -2197,10 +2200,10 @@ function quux () {
2197
2200
````
2198
2201
2199
2202
2200
- <a name =" eslint-plugin-jsdoc-rules-require-returns " ></a >
2201
- ### <code >require-returns</code >
2203
+ <a name =" eslint-plugin-jsdoc-rules-require-returns-check " ></a >
2204
+ ### <code >require-returns-check </code >
2202
2205
2203
- Requires returns are documented .
2206
+ Checks if the return expression exists in function body and in the comment .
2204
2207
2205
2208
|||
2206
2209
| ---| ---|
@@ -2211,302 +2214,106 @@ The following patterns are considered problems:
2211
2214
2212
2215
```` js
2213
2216
/**
2214
- *
2215
- */
2216
- function quux (foo ) {
2217
-
2218
- }
2219
- // Message: Missing JSDoc @param "foo" declaration.
2220
-
2221
- /**
2222
- *
2223
- */
2224
- function quux (foo ) {
2225
-
2226
- }
2227
- // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
2228
- // Message: Missing JSDoc @arg "foo" declaration.
2229
-
2230
- /**
2231
- * @param foo
2232
- */
2233
- function quux (foo , bar ) {
2234
-
2235
- }
2236
- // Message: Missing JSDoc @param "bar" declaration.
2237
-
2238
- /**
2239
- * @override
2240
- */
2241
- function quux (foo ) {
2242
-
2243
- }
2244
- // Message: Missing JSDoc @param "foo" declaration.
2245
-
2246
- /**
2247
- * @implements
2248
- */
2249
- function quux (foo ) {
2250
-
2251
- }
2252
- // Message: Missing JSDoc @param "foo" declaration.
2253
-
2254
- /**
2255
- * @augments
2217
+ * @returns
2256
2218
*/
2257
2219
function quux (foo ) {
2258
2220
2259
2221
}
2260
- // Message: Missing JSDoc @param "foo" declaration.
2222
+ // Message: Present JSDoc @returns declaration but not available return expression in function .
2261
2223
2262
2224
/**
2263
- * @extends
2225
+ * @return
2264
2226
*/
2265
2227
function quux (foo ) {
2266
2228
2267
2229
}
2268
- // Message: Missing JSDoc @param "foo" declaration.
2269
-
2270
- /**
2271
- * @override
2272
- */
2273
- class A {
2274
- /**
2275
- *
2276
- */
2277
- quux (foo ) {
2278
-
2279
- }
2280
- }
2281
- // Message: Missing JSDoc @param "foo" declaration.
2282
-
2283
- /**
2284
- * @implements
2285
- */
2286
- class A {
2287
- /**
2288
- *
2289
- */
2290
- quux (foo ) {
2291
-
2292
- }
2293
- }
2294
- // Message: Missing JSDoc @param "foo" declaration.
2295
-
2296
- /**
2297
- * @augments
2298
- */
2299
- class A {
2300
- /**
2301
- *
2302
- */
2303
- quux (foo ) {
2304
-
2305
- }
2306
- }
2307
- // Message: Missing JSDoc @param "foo" declaration.
2308
-
2309
- /**
2310
- * @extends
2311
- */
2312
- class A {
2313
- /**
2314
- *
2315
- */
2316
- quux (foo ) {
2317
-
2318
- }
2319
- }
2320
- // Message: Missing JSDoc @param "foo" declaration.
2230
+ // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
2231
+ // Message: Present JSDoc @return declaration but not available return expression in function.
2321
2232
````
2322
2233
2323
2234
The following patterns are not considered problems:
2324
2235
2325
2236
```` js
2326
2237
/**
2327
- * @param foo
2328
- */
2329
- function quux (foo ) {
2330
-
2331
- }
2332
-
2333
- /**
2334
- * @inheritdoc
2335
- */
2336
- function quux (foo ) {
2337
-
2338
- }
2339
-
2340
- /**
2341
- * @arg foo
2238
+ * @returns Foo.
2342
2239
*/
2343
- function quux (foo ) {
2240
+ function quux () {
2344
2241
2242
+ return foo;
2345
2243
}
2346
- // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
2347
2244
2348
2245
/**
2349
- * @override
2350
- * @param foo
2246
+ * @returns {void} Foo.
2351
2247
*/
2352
- function quux (foo ) {
2248
+ function quux () {
2353
2249
2250
+ return foo;
2354
2251
}
2355
2252
2356
2253
/**
2357
- * @override
2254
+ * @returns {undefined} Foo.
2358
2255
*/
2359
- function quux (foo ) {
2256
+ function quux () {
2360
2257
2258
+ return foo;
2361
2259
}
2362
- // Settings: {"jsdoc":{"allowOverrideWithoutParam":true}}
2363
2260
2364
2261
/**
2365
- * @implements
2262
+ *
2366
2263
*/
2367
- function quux (foo ) {
2368
-
2264
+ function quux () {
2369
2265
}
2370
- // Settings: {"jsdoc":{"allowImplementsWithoutParam":true}}
2266
+ ````
2371
2267
2372
- /**
2373
- * @implements
2374
- * @param foo
2375
- */
2376
- function quux (foo ) {
2377
2268
2378
- }
2379
-
2380
- /**
2381
- * @augments
2382
- */
2383
- function quux (foo ) {
2269
+ <a name =" eslint-plugin-jsdoc-rules-require-returns " ></a >
2270
+ ### <code >require-returns</code >
2384
2271
2385
- }
2386
- // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2272
+ Requires returns are documented.
2387
2273
2388
- /**
2389
- * @augments
2390
- * @param foo
2391
- */
2392
- function quux (foo ) {
2274
+ |||
2275
+ | ---| ---|
2276
+ | Context| ` ArrowFunctionExpression ` , ` FunctionDeclaration ` , ` FunctionExpression ` |
2277
+ | Tags| ` returns ` |
2393
2278
2394
- }
2279
+ The following patterns are considered problems:
2395
2280
2281
+ ```` js
2396
2282
/**
2397
- * @extends
2283
+ *
2398
2284
*/
2399
2285
function quux (foo ) {
2400
2286
2287
+ return foo;
2401
2288
}
2402
- // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2289
+ // Message: Missing JSDoc @returns declaration.
2403
2290
2404
2291
/**
2405
- * @extends
2406
- * @param foo
2292
+ *
2407
2293
*/
2408
2294
function quux (foo ) {
2409
2295
2296
+ return foo;
2410
2297
}
2298
+ // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
2299
+ // Message: Missing JSDoc @return declaration.
2300
+ ````
2411
2301
2412
- /**
2413
- * @override
2414
- */
2415
- class A {
2416
- /**
2417
- * @param foo
2418
- */
2419
- quux (foo ) {
2420
-
2421
- }
2422
- }
2423
-
2424
- /**
2425
- * @override
2426
- */
2427
- class A {
2428
- /**
2429
- *
2430
- */
2431
- quux (foo ) {
2432
-
2433
- }
2434
- }
2435
- // Settings: {"jsdoc":{"allowOverrideWithoutParam":true}}
2436
-
2437
- /**
2438
- * @implements
2439
- */
2440
- class A {
2441
- /**
2442
- *
2443
- */
2444
- quux (foo ) {
2445
-
2446
- }
2447
- }
2448
- // Settings: {"jsdoc":{"allowImplementsWithoutParam":true}}
2449
-
2450
- /**
2451
- * @implements
2452
- */
2453
- class A {
2454
- /**
2455
- * @param foo
2456
- */
2457
- quux (foo ) {
2458
-
2459
- }
2460
- }
2461
-
2462
- /**
2463
- * @augments
2464
- */
2465
- class A {
2466
- /**
2467
- *
2468
- */
2469
- quux (foo ) {
2470
-
2471
- }
2472
- }
2473
- // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2474
-
2475
- /**
2476
- * @augments
2477
- */
2478
- class A {
2479
- /**
2480
- * @param foo
2481
- */
2482
- quux (foo ) {
2483
-
2484
- }
2485
- }
2302
+ The following patterns are not considered problems:
2486
2303
2304
+ ```` js
2487
2305
/**
2488
- * @extends
2306
+ * @returns Foo.
2489
2307
*/
2490
- class A {
2491
- /**
2492
- *
2493
- */
2494
- quux (foo ) {
2308
+ function quux () {
2495
2309
2496
- }
2310
+ return foo;
2497
2311
}
2498
- // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2499
2312
2500
2313
/**
2501
- * @extends
2314
+ *
2502
2315
*/
2503
- class A {
2504
- /**
2505
- * @param foo
2506
- */
2507
- quux (foo ) {
2508
-
2509
- }
2316
+ function quux () {
2510
2317
}
2511
2318
````
2512
2319
0 commit comments