@@ -2333,45 +2333,59 @@ tag should be linted with the `matchDescription` value (or the default).
2333
2333
```
2334
2334
2335
2335
If you wish to override the main function description without changing the
2336
- default ` mainDescription ` , you may use ` tags ` with ` main description ` :
2336
+ default ` match-description ` , you may use ` mainDescription ` :
2337
2337
2338
2338
``` js
2339
2339
{
2340
- ' jsdoc/match-description' : [' error' , {tags: {
2341
- ' main description' : ' [A-Z].*\\ .' ,
2342
- param: true ,
2343
- returns: true
2344
- }}]
2340
+ ' jsdoc/match-description' : [' error' , {
2341
+ mainDescription: ' [A-Z].*\\ .' ,
2342
+ tags: {
2343
+ param: true ,
2344
+ returns: true
2345
+ }
2346
+ }]
2345
2347
}
2346
2348
```
2347
2349
2348
- There is no need to add ` "main description" : true` , as by default, the main
2350
+ There is no need to add ` mainDescription : true` , as by default, the main
2349
2351
function (and only the main function) is linted, though you may disable checking
2350
2352
it by setting it to ` false ` .
2351
2353
2352
2354
<a name =" eslint-plugin-jsdoc-rules-match-description-options-1-contexts " ></a >
2353
2355
##### <code >contexts</code >
2354
2356
2355
- Set this to a string or array of strings representing the AST context
2357
+ Set this to an array of strings representing the AST context
2356
2358
where you wish the rule to be applied (e.g., ` ClassDeclaration ` for ES6 classes).
2357
-
2358
- <a name =" eslint-plugin-jsdoc-rules-match-description-options-1-nodefaults " ></a >
2359
- ##### <code >noDefaults</code >
2360
-
2361
- By default, ` contexts ` will permit ` ArrowFunctionExpression ` ,
2362
- ` FunctionDeclaration ` , and ` FunctionExpression ` . Set this instead to ` true ` to
2363
- have ` contexts ` override these.
2359
+ Overrides the defaults.
2364
2360
2365
2361
|||
2366
2362
| ---| ---|
2367
2363
| Context| ` ArrowFunctionExpression ` , ` FunctionDeclaration ` , ` FunctionExpression ` ; others when ` contexts ` option enabled|
2368
2364
| Tags| N/A by default but see ` tags ` options|
2369
2365
| Settings||
2370
- | Options| ` contexts ` , ` noDefaults ` , ` tags ` (allows for 'param', 'arg', 'argument', 'returns', 'return'), ` matchDescription ` |
2366
+ | Options| ` contexts ` , ` tags ` (allows for 'param', 'arg', 'argument', 'returns', 'return'), ` matchDescription ` |
2371
2367
2372
2368
The following patterns are considered problems:
2373
2369
2374
2370
```` js
2371
+ /**
2372
+ * foo.
2373
+ */
2374
+ const q = class {
2375
+
2376
+ }
2377
+ // Options: [{"contexts":["ClassExpression"]}]
2378
+ // Message: JSDoc description does not satisfy the regex pattern.
2379
+
2380
+ /**
2381
+ * foo.
2382
+ */
2383
+ const q = {
2384
+
2385
+ };
2386
+ // Options: [{"contexts":["ObjectExpression"]}]
2387
+ // Message: JSDoc description does not satisfy the regex pattern.
2388
+
2375
2389
/**
2376
2390
* foo.
2377
2391
*/
@@ -2395,8 +2409,6 @@ function quux () {
2395
2409
2396
2410
}
2397
2411
// Options: [{"matchDescription":"[А-Я][А-я]+\\."}]
2398
- <<<<<< < HEAD
2399
- ====== =
2400
2412
// Message: JSDoc description does not satisfy the regex pattern.
2401
2413
2402
2414
/**
@@ -2405,8 +2417,7 @@ function quux () {
2405
2417
function quux () {
2406
2418
2407
2419
}
2408
- // Options: [{"tags":{"main description":"[А-Я][А-я]+\\.","param":true}}]
2409
- >>>>>> > feat (match- description): allow ` main description: string|boolean` to override or disable main description separate from default
2420
+ // Options: [{"mainDescription":"[А-Я][А-я]+\\.","tags":{"param":true}}]
2410
2421
// Message: JSDoc description does not satisfy the regex pattern.
2411
2422
2412
2423
/**
@@ -2436,7 +2447,7 @@ function quux (foo) {
2436
2447
function quux (foo ) {
2437
2448
2438
2449
}
2439
- // Options: [{"tags":{"main description":" ^[a-zA-Z]*$","param":true}}]
2450
+ // Options: [{"mainDescription":" ^[a-zA-Z]*$","tags":{ "param":true}}]
2440
2451
// Message: JSDoc description does not satisfy the regex pattern.
2441
2452
2442
2453
/**
@@ -2447,7 +2458,7 @@ function quux (foo) {
2447
2458
function quux (foo ) {
2448
2459
2449
2460
}
2450
- // Options: [{"tags":{"main description":false, "param":true}}]
2461
+ // Options: [{"mainDescription":false,"tags":{ "param":true}}]
2451
2462
// Message: JSDoc description does not satisfy the regex pattern.
2452
2463
2453
2464
/**
@@ -2550,8 +2561,6 @@ function quux () {
2550
2561
2551
2562
}
2552
2563
// Options: [{"tags":{"param":"[А-Я][А-я]+\\."}}]
2553
- <<<<<< < HEAD
2554
- ====== =
2555
2564
// Message: JSDoc description does not satisfy the regex pattern.
2556
2565
2557
2566
/**
@@ -2560,8 +2569,7 @@ function quux () {
2560
2569
class quux {
2561
2570
2562
2571
}
2563
- // Options: [{"contexts":["ClassDeclaration"],"noDefaults":true}]
2564
- >>>>>> > feat (match- description): allow ` main description: string|boolean` to override or disable main description separate from default
2572
+ // Options: [{"contexts":["ClassDeclaration"]}]
2565
2573
// Message: JSDoc description does not satisfy the regex pattern.
2566
2574
2567
2575
class MyClass {
@@ -2570,7 +2578,7 @@ class MyClass {
2570
2578
*/
2571
2579
myClassField = 1
2572
2580
}
2573
- // Options: [{"contexts":["ClassProperty"],"noDefaults":true }]
2581
+ // Options: [{"contexts":["ClassProperty"]}]
2574
2582
// Message: JSDoc description does not satisfy the regex pattern.
2575
2583
2576
2584
/**
@@ -2579,7 +2587,7 @@ class MyClass {
2579
2587
interface quux {
2580
2588
2581
2589
}
2582
- // Options: [{"contexts":["TSInterfaceDeclaration"],"noDefaults":true }]
2590
+ // Options: [{"contexts":["TSInterfaceDeclaration"]}]
2583
2591
// Message: JSDoc description does not satisfy the regex pattern.
2584
2592
2585
2593
const myObject = {
@@ -2588,7 +2596,7 @@ const myObject = {
2588
2596
*/
2589
2597
myProp: true
2590
2598
};
2591
- // Options: [{"contexts":["Property"],"noDefaults":true }]
2599
+ // Options: [{"contexts":["Property"]}]
2592
2600
// Message: JSDoc description does not satisfy the regex pattern.
2593
2601
````
2594
2602
@@ -2725,47 +2733,62 @@ function quux () {
2725
2733
function quux () {
2726
2734
2727
2735
}
2728
- // Options: [{"tags":{"main description": false} }]
2736
+ // Options: [{"mainDescription": false}]
2729
2737
2730
2738
/**
2731
2739
* foo.
2732
2740
*/
2733
2741
class quux {
2734
2742
2735
2743
}
2736
- // Message: JSDoc description does not satisfy the regex pattern.
2737
2744
2738
2745
/**
2739
2746
* foo.
2740
2747
*/
2741
2748
class quux {
2742
2749
2743
2750
}
2744
- // Options: [{"tags":{"main description": true} }]
2751
+ // Options: [{"mainDescription": true}]
2745
2752
2746
2753
class MyClass {
2747
2754
/**
2748
2755
* Abc.
2749
2756
*/
2750
2757
myClassField = 1
2751
2758
}
2752
- // Options: [{"contexts":["ClassProperty"],"noDefaults":true }]
2759
+ // Options: [{"contexts":["ClassProperty"]}]
2753
2760
2754
2761
/**
2755
2762
* Foo.
2756
2763
*/
2757
2764
interface quux {
2758
2765
2759
2766
}
2760
- // Options: [{"contexts":["TSInterfaceDeclaration"],"noDefaults":true }]
2767
+ // Options: [{"contexts":["TSInterfaceDeclaration"]}]
2761
2768
2762
2769
const myObject = {
2763
2770
/**
2764
2771
* Bad description
2765
2772
*/
2766
2773
myProp: true
2767
2774
};
2768
- // Options: [{"contexts":[],"noDefaults":true}]
2775
+ // Options: [{"contexts":[]}]
2776
+
2777
+ /**
2778
+ * foo.
2779
+ */
2780
+ const q = class {
2781
+
2782
+ }
2783
+ // Options: [{"contexts":[]}]
2784
+
2785
+ /**
2786
+ * foo.
2787
+ */
2788
+ const q = {
2789
+
2790
+ };
2791
+ // Options: [{"contexts":[]}]
2769
2792
````
2770
2793
2771
2794
@@ -3505,20 +3528,18 @@ Requires that all functions have a description.
3505
3528
3506
3529
An options object may have any of the following properties:
3507
3530
3508
- - ` contexts ` - Set to a string or array of strings representing the AST context
3531
+ - ` contexts ` - Set to an array of strings representing the AST context
3509
3532
where you wish the rule to be applied (e.g., ` ClassDeclaration ` for ES6 classes).
3533
+ Overrides the defaults.
3510
3534
- ` exemptedBy ` - Array of tags (e.g., ` ['type'] ` ) whose presence on the document
3511
3535
block avoids the need for a ` @description ` .
3512
- - ` noDefaults ` - By default, ` contexts ` will permit ` ArrowFunctionExpression ` ,
3513
- ` FunctionDeclaration ` , and ` FunctionExpression ` . Set this instead to ` true ` to
3514
- have ` contexts ` override these.
3515
3536
3516
3537
|||
3517
3538
| ---| ---|
3518
3539
| Context| ` ArrowFunctionExpression ` , ` FunctionDeclaration ` , ` FunctionExpression ` ; others when ` contexts ` option enabled|
3519
3540
| Tags| ` description ` |
3520
3541
| Aliases| ` desc ` |
3521
- | Options| ` contexts ` , ` exemptedBy ` , ` noDefaults ` |
3542
+ | Options| ` contexts ` , ` exemptedBy ` |
3522
3543
3523
3544
The following patterns are considered problems:
3524
3545
@@ -3537,7 +3558,7 @@ function quux () {
3537
3558
class quux {
3538
3559
3539
3560
}
3540
- // Options: [{"contexts":"ClassDeclaration"}]
3561
+ // Options: [{"contexts":[ "ClassDeclaration"] }]
3541
3562
// Message: Missing JSDoc @description declaration.
3542
3563
3543
3564
/**
@@ -3546,7 +3567,7 @@ class quux {
3546
3567
class quux {
3547
3568
3548
3569
}
3549
- // Options: [{"contexts":"ClassDeclaration","noDefaults":true }]
3570
+ // Options: [{"contexts":[ "ClassDeclaration"] }]
3550
3571
// Message: Missing JSDoc @description declaration.
3551
3572
3552
3573
/**
@@ -3572,9 +3593,8 @@ function quux () {
3572
3593
interface quux {
3573
3594
3574
3595
}
3575
- // Options: [{"contexts":["TSInterfaceDeclaration"],"noDefaults":true }]
3596
+ // Options: [{"contexts":["TSInterfaceDeclaration"]}]
3576
3597
// Message: Missing JSDoc @description declaration.
3577
- <<<<<< < HEAD
3578
3598
3579
3599
/**
3580
3600
*
@@ -3593,8 +3613,6 @@ var quux = {
3593
3613
};
3594
3614
// Options: [{"contexts":["ObjectExpression"]}]
3595
3615
// Message: Missing JSDoc @description declaration.
3596
- ====== =
3597
- >>>>>> > fix (match- description): tighten default regex to require punctuation at the end even if only a single character
3598
3616
````
3599
3617
3600
3618
The following patterns are not considered problems:
@@ -3640,7 +3658,7 @@ class quux {
3640
3658
function quux () {
3641
3659
3642
3660
}
3643
- // Options: [{"noDefaults":true }]
3661
+ // Options: [{"contexts":["ClassDeclaration"] }]
3644
3662
3645
3663
/**
3646
3664
* @type {MyCallback}
@@ -3656,7 +3674,6 @@ function quux () {
3656
3674
interface quux {
3657
3675
3658
3676
}
3659
- <<<<<< < HEAD
3660
3677
3661
3678
/**
3662
3679
*
@@ -3671,9 +3688,6 @@ var quux = class {
3671
3688
var quux = {
3672
3689
3673
3690
};
3674
- ====== =
3675
- // Message: Missing JSDoc @description declaration.
3676
- >>>>>> > fix (match- description): tighten default regex to require punctuation at the end even if only a single character
3677
3691
````
3678
3692
3679
3693
@@ -3941,10 +3955,8 @@ be checked by the rule.
3941
3955
- ` FunctionExpression `
3942
3956
- ` MethodDefinition `
3943
3957
3944
- - ` contexts ` - Set this to a string or array of strings representing the additional
3958
+ - ` contexts ` - Set this to an array of strings representing the additional
3945
3959
AST context where you wish the rule to be applied (e.g., ` Property ` for properties).
3946
- Note that unlike ` require-description ` and ` match-description ` , this rule has no
3947
- ` noDefaults ` option because its defaults are instead set up by ` require ` .
3948
3960
3949
3961
|||
3950
3962
| ---| ---|
0 commit comments