@@ -3788,26 +3788,33 @@ function quux () {
3788
3788
3789
3789
Requires that all functions have a description.
3790
3790
3791
- * All functions must have a ` @description ` tag.
3792
- * Every description tag must have a non-empty description that explains the purpose of the method.
3791
+ * All functions must have an implicit description or have the option
3792
+ ` descriptionStyle ` set to ` tag ` .
3793
+ * Every jsdoc block description (or description tag if ` descriptionStyle ` is
3794
+ ` "tag" ` ) must have a non-empty description that explains the purpose of the
3795
+ method.
3793
3796
3794
3797
<a name =" eslint-plugin-jsdoc-rules-require-description-options-6 " ></a >
3795
3798
#### Options
3796
3799
3797
3800
An options object may have any of the following properties:
3798
3801
3799
3802
- ` contexts ` - Set to an array of strings representing the AST context
3800
- where you wish the rule to be applied (e.g., ` ClassDeclaration ` for ES6 classes).
3801
- Overrides the default contexts (see below).
3802
- - ` exemptedBy ` - Array of tags (e.g., ` ['type'] ` ) whose presence on the document
3803
- block avoids the need for a ` @description ` . Defaults to an empty array.
3803
+ where you wish the rule to be applied (e.g., ` ClassDeclaration ` for ES6
3804
+ classes). Overrides the default contexts (see below).
3805
+ - ` exemptedBy ` - Array of tags (e.g., ` ['type'] ` ) whose presence on the
3806
+ document block avoids the need for a ` @description ` . Defaults to an
3807
+ empty array.
3808
+ - ` descriptionStyle ` - Whether to accept implicit descriptions (` "body" ` ) or
3809
+ ` @description ` tags (` "tag" ` ) as satisfying the rule. Set to ` "any" ` to
3810
+ accept either style. Defaults to ` "body" ` .
3804
3811
3805
3812
|||
3806
3813
| ---| ---|
3807
3814
| Context| ` ArrowFunctionExpression ` , ` FunctionDeclaration ` , ` FunctionExpression ` ; others when ` contexts ` option enabled|
3808
- | Tags| ` description ` |
3815
+ | Tags| ` description ` or jsdoc block |
3809
3816
| Aliases| ` desc ` |
3810
- | Options| ` contexts ` , ` exemptedBy ` |
3817
+ | Options| ` contexts ` , ` exemptedBy ` , ` descriptionStyle ` |
3811
3818
| Settings| ` overrideReplacesDocs ` , ` augmentsExtendsReplacesDocs ` , ` implementsReplacesDocs ` |
3812
3819
3813
3820
The following patterns are considered problems:
@@ -3819,15 +3826,34 @@ The following patterns are considered problems:
3819
3826
function quux () {
3820
3827
3821
3828
}
3829
+ // Options: [{"descriptionStyle":"tag"}]
3822
3830
// Message: Missing JSDoc @description declaration.
3823
3831
3832
+ /**
3833
+ *
3834
+ */
3835
+ function quux () {
3836
+
3837
+ }
3838
+ // Options: [{"descriptionStyle":"any"}]
3839
+ // Message: Missing JSDoc block description or @description declaration.
3840
+
3841
+ /**
3842
+ *
3843
+ */
3844
+ function quux () {
3845
+
3846
+ }
3847
+ // Options: [{"descriptionStyle":"body"}]
3848
+ // Message: Missing JSDoc block description.
3849
+
3824
3850
/**
3825
3851
*
3826
3852
*/
3827
3853
class quux {
3828
3854
3829
3855
}
3830
- // Options: [{"contexts":["ClassDeclaration"]}]
3856
+ // Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag" }]
3831
3857
// Message: Missing JSDoc @description declaration.
3832
3858
3833
3859
/**
@@ -3836,7 +3862,7 @@ class quux {
3836
3862
class quux {
3837
3863
3838
3864
}
3839
- // Options: [{"contexts":["ClassDeclaration"]}]
3865
+ // Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag" }]
3840
3866
// Message: Missing JSDoc @description declaration.
3841
3867
3842
3868
/**
@@ -3845,7 +3871,7 @@ class quux {
3845
3871
class quux {
3846
3872
3847
3873
}
3848
- // Options: [{"contexts":["ClassDeclaration"]}]
3874
+ // Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag" }]
3849
3875
// Message: Missing JSDoc @description declaration.
3850
3876
3851
3877
/**
@@ -3854,6 +3880,7 @@ class quux {
3854
3880
function quux () {
3855
3881
3856
3882
}
3883
+ // Options: [{"descriptionStyle":"tag"}]
3857
3884
// Message: Missing JSDoc @description description.
3858
3885
3859
3886
/**
@@ -3862,7 +3889,7 @@ function quux () {
3862
3889
interface quux {
3863
3890
3864
3891
}
3865
- // Options: [{"contexts":["TSInterfaceDeclaration"]}]
3892
+ // Options: [{"contexts":["TSInterfaceDeclaration"],"descriptionStyle":"tag" }]
3866
3893
// Message: Missing JSDoc @description declaration.
3867
3894
3868
3895
/**
@@ -3871,7 +3898,7 @@ interface quux {
3871
3898
var quux = class {
3872
3899
3873
3900
};
3874
- // Options: [{"contexts":["ClassExpression"]}]
3901
+ // Options: [{"contexts":["ClassExpression"],"descriptionStyle":"tag" }]
3875
3902
// Message: Missing JSDoc @description declaration.
3876
3903
3877
3904
/**
@@ -3880,7 +3907,7 @@ var quux = class {
3880
3907
var quux = {
3881
3908
3882
3909
};
3883
- // Options: [{"contexts":["ObjectExpression"]}]
3910
+ // Options: [{"contexts":["ObjectExpression"],"descriptionStyle":"tag" }]
3884
3911
// Message: Missing JSDoc @description declaration.
3885
3912
3886
3913
/**
@@ -3890,6 +3917,7 @@ function quux () {
3890
3917
3891
3918
}
3892
3919
// Settings: {"jsdoc":{"tagNamePreference":{"description":{"message":"Please avoid `{{tagName}}`; use `{{replacement}}` instead","replacement":"someDesc"}}}}
3920
+ // Options: [{"descriptionStyle":"tag"}]
3893
3921
// Message: Missing JSDoc @someDesc description.
3894
3922
3895
3923
/**
@@ -3899,6 +3927,7 @@ function quux () {
3899
3927
3900
3928
}
3901
3929
// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
3930
+ // Options: [{"descriptionStyle":"tag"}]
3902
3931
// Message: Unexpected tag `@description`
3903
3932
````
3904
3933
@@ -3912,6 +3941,7 @@ The following patterns are not considered problems:
3912
3941
function quux () {
3913
3942
3914
3943
}
3944
+ // Options: [{"descriptionStyle":"tag"}]
3915
3945
3916
3946
/**
3917
3947
* @description
@@ -3920,6 +3950,7 @@ function quux () {
3920
3950
function quux () {
3921
3951
3922
3952
}
3953
+ // Options: [{"descriptionStyle":"tag"}]
3923
3954
3924
3955
/**
3925
3956
* @description <caption>Valid usage</caption>
@@ -3931,13 +3962,15 @@ function quux () {
3931
3962
function quux () {
3932
3963
3933
3964
}
3965
+ // Options: [{"descriptionStyle":"tag"}]
3934
3966
3935
3967
/**
3936
3968
*
3937
3969
*/
3938
3970
class quux {
3939
3971
3940
3972
}
3973
+ // Options: [{"descriptionStyle":"tag"}]
3941
3974
3942
3975
/**
3943
3976
*
@@ -3961,20 +3994,54 @@ function quux () {
3961
3994
interface quux {
3962
3995
3963
3996
}
3997
+ // Options: [{"descriptionStyle":"tag"}]
3964
3998
3965
3999
/**
3966
4000
*
3967
4001
*/
3968
4002
var quux = class {
3969
4003
3970
4004
};
4005
+ // Options: [{"descriptionStyle":"tag"}]
3971
4006
3972
4007
/**
3973
4008
*
3974
4009
*/
3975
4010
var quux = {
3976
4011
3977
4012
};
4013
+ // Options: [{"descriptionStyle":"tag"}]
4014
+
4015
+ /**
4016
+ * Has an implicit description
4017
+ */
4018
+ function quux () {
4019
+
4020
+ }
4021
+ // Options: [{"descriptionStyle":"body"}]
4022
+
4023
+ /**
4024
+ * Has an implicit description
4025
+ */
4026
+ function quux () {
4027
+
4028
+ }
4029
+
4030
+ /**
4031
+ * Has an implicit description
4032
+ */
4033
+ function quux () {
4034
+
4035
+ }
4036
+ // Options: [{"descriptionStyle":"any"}]
4037
+
4038
+ /**
4039
+ * @description Has an explicit description
4040
+ */
4041
+ function quux () {
4042
+
4043
+ }
4044
+ // Options: [{"descriptionStyle":"any"}]
3978
4045
````
3979
4046
3980
4047
0 commit comments