@@ -6716,18 +6716,90 @@ Checks that:
6716
6716
as being when the overview tag is not preceded by anything other than
6717
6717
a comment.
6718
6718
6719
+ <a name=" eslint- plugin- jsdoc- rules- require- file- overview- options- 17 " ></a>
6720
+ #### Options
6721
+
6722
+ <a name=" eslint- plugin- jsdoc- rules- require- file- overview- options- 17 - tags- 3 " ></a>
6723
+ ##### <code>tags</code>
6724
+
6725
+ The keys of this object are tag names, and the values are configuration
6726
+ objects indicating what will be checked for these whole-file tags.
6727
+
6728
+ Each configuration object has the following boolean keys (which default
6729
+ to `false` when this option is supplied): `mustExist`, `preventDuplicates`,
6730
+ `initialCommentsOnly`. These correspond to the three items above.
6731
+
6732
+ When no `tags` is present, the default is:
6733
+
6734
+ ```json
6735
+ {
6736
+ " file" : {
6737
+ " initialCommentsOnly" : true,
6738
+ " mustExist" : true,
6739
+ " preventDuplicates" : true,
6740
+ }
6741
+ }
6742
+ ```
6743
+
6744
+ You can add additional tag names and/or override `file` if you supply this
6745
+ option, e.g., in place of or in addition to `file`, giving other potential
6746
+ file global tags like `@license`, `@copyright`, `@author`, `@module` or
6747
+ `@exports`, optionally restricting them to a single use or preventing them
6748
+ from being preceded by anything besides comments.
6749
+
6750
+ For example:
6751
+
6752
+ ```js
6753
+ {
6754
+ " license" : {
6755
+ " mustExist" : true,
6756
+ " preventDuplicates" : true,
6757
+ }
6758
+ }
6759
+ ```
6760
+
6761
+ This would require one and only one `@license` in the file, though because
6762
+ `initialCommentsOnly` is absent and defaults to `false`, the `@license`
6763
+ can be anywhere.
6764
+
6765
+ In the case of `@license`, you can use this rule along with the
6766
+ `check-values` rule (with its `allowedLicenses` or `licensePattern` options),
6767
+ to enforce a license whitelist be present on every JS file.
6768
+
6769
+ Note that if you choose to use `preventDuplicates` with `license`, you still
6770
+ have a way to allow multiple licenses for the whole page by using the SPDX
6771
+ " AND " expression, e.g., `@license (MIT AND GPL-3.0)`.
6772
+
6773
+ Note that the tag names are the main jsdoc tag name, so you should use `file`
6774
+ in this configuration object regardless of whether you have configured
6775
+ `fileoverview` instead of `file` on `tagNamePreference` (i.e., `fileoverview`
6776
+ will be checked, but you must use `file` on the configuration object).
6777
+
6719
6778
|||
6720
6779
|---|---|
6721
6780
|Context|Everywhere|
6722
- |Tags|`file`|
6781
+ |Tags|`file`; others when `tags` set |
6723
6782
|Aliases|`fileoverview`, `overview`|
6783
+ |Options|`tags`|
6724
6784
6725
6785
The following patterns are considered problems:
6726
6786
6727
6787
````js
6728
6788
6729
6789
// Message: Missing @file
6730
6790
6791
+
6792
+ // Options: [{" tags" :{" file" :{" initialCommentsOnly" :true," mustExist" :true," preventDuplicates" :true}}}]
6793
+ // Message: Missing @file
6794
+
6795
+
6796
+ // Options: [{" tags" :{" file" :{" mustExist" :true}}}]
6797
+ // Message: Missing @file
6798
+
6799
+
6800
+ // Options: [{" tags" :{" author" :{" initialCommentsOnly" :false," mustExist" :true," preventDuplicates" :false}}}]
6801
+ // Message: Missing @author
6802
+
6731
6803
/**
6732
6804
*
6733
6805
*/
@@ -6760,6 +6832,14 @@ function quux () {}
6760
6832
// Settings: {" jsdoc" :{" tagNamePreference" :{" file" :false}}}
6761
6833
// Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
6762
6834
6835
+ /**
6836
+ *
6837
+ */
6838
+ function quux () {}
6839
+ // Settings: {" jsdoc" :{" tagNamePreference" :{" file" :false}}}
6840
+ // Options: [{" tags" :{" file" :{" initialCommentsOnly" :false," mustExist" :true," preventDuplicates" :false}}}]
6841
+ // Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
6842
+
6763
6843
/**
6764
6844
*
6765
6845
*/
@@ -6793,12 +6873,48 @@ function bar (b) {}
6793
6873
*/
6794
6874
// Message: Duplicate @file
6795
6875
6876
+ /**
6877
+ * @copyright
6878
+ */
6879
+
6880
+ /**
6881
+ * @copyright
6882
+ */
6883
+ // Options: [{"tags":{"copyright":{"initialCommentsOnly":false,"mustExist":false,"preventDuplicates":true}}}]
6884
+ // Message: Duplicate @copyright
6885
+
6796
6886
function quux () {
6797
6887
}
6798
6888
/**
6799
6889
* @file
6800
6890
*/
6801
6891
// Message: @file should be at the beginning of the file
6892
+
6893
+ function quux () {
6894
+ }
6895
+ /**
6896
+ * @license
6897
+ */
6898
+ // Options: [{"tags":{"license":{"initialCommentsOnly":true,"mustExist":false,"preventDuplicates":false}}}]
6899
+ // Message: @license should be at the beginning of the file
6900
+
6901
+ function quux () {
6902
+ }
6903
+ /**
6904
+ * @license
6905
+ */
6906
+ // Options: [{"tags":{"license":{"initialCommentsOnly":true}}}]
6907
+ // Message: @license should be at the beginning of the file
6908
+
6909
+ /**
6910
+ * @file
6911
+ */
6912
+
6913
+ /**
6914
+ * @file
6915
+ */
6916
+ // Options: [{"tags":{"file":{"initialCommentsOnly":true,"preventDuplicates":true}}}]
6917
+ // Message: Duplicate @file
6802
6918
````
6803
6919
6804
6920
The following patterns are not considered problems:
@@ -6808,6 +6924,15 @@ The following patterns are not considered problems:
6808
6924
* @file
6809
6925
*/
6810
6926
6927
+ /**
6928
+ * @file
6929
+ */
6930
+
6931
+ /**
6932
+ * @file
6933
+ */
6934
+ // Options: [{"tags":{"license":{"initialCommentsOnly":true,"preventDuplicates":true}}}]
6935
+
6811
6936
// Ok preceded by comment
6812
6937
/**
6813
6938
* @file
@@ -6836,6 +6961,38 @@ function quux () {
6836
6961
/**
6837
6962
*
6838
6963
*/
6964
+
6965
+ function quux () {
6966
+ }
6967
+ /**
6968
+ *
6969
+ */
6970
+ // Options: [{"tags":{"license":{"initialCommentsOnly":true,"mustExist":false,"preventDuplicates":false}}}]
6971
+
6972
+ function quux () {
6973
+ }
6974
+ /**
6975
+ *
6976
+ */
6977
+ // Options: [{"tags":{"license":{"initialCommentsOnly":false,"mustExist":false,"preventDuplicates":false}}}]
6978
+
6979
+ function quux () {
6980
+ }
6981
+ /**
6982
+ *
6983
+ */
6984
+ // Options: [{"tags":{"license":{"initialCommentsOnly":false,"mustExist":false,"preventDuplicates":true}}}]
6985
+
6986
+ /**
6987
+ * @license MIT
6988
+ */
6989
+
6990
+ var a
6991
+
6992
+ /**
6993
+ * @type {Array}
6994
+ */
6995
+ // Options: [{"tags":{"license":{"initialCommentsOnly":true,"mustExist":false,"preventDuplicates":false}}}]
6839
6996
````
6840
6997
6841
6998
@@ -6844,7 +7001,7 @@ function quux () {
6844
7001
6845
7002
Requires a hyphen before the `@param` description.
6846
7003
6847
- <a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-17 "></a>
7004
+ <a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-18 "></a>
6848
7005
#### Options
6849
7006
6850
7007
This rule takes one optional string argument. If it is `"always"` then a problem is raised when there is no hyphen before the description. If it is `"never"` then a problem is raised when there is a hyphen before the description. The default value is `"always"`.
@@ -6950,7 +7107,7 @@ function quux () {
6950
7107
Checks for presence of jsdoc comments, on class declarations as well as
6951
7108
functions.
6952
7109
6953
- <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-18 "></a>
7110
+ <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-19 "></a>
6954
7111
#### Options
6955
7112
6956
7113
Accepts one optional options object with the following optional keys.
@@ -7968,10 +8125,10 @@ export default class Foo {
7968
8125
7969
8126
Requires that each `@param` tag has a `description` value.
7970
8127
7971
- <a name="eslint-plugin-jsdoc-rules-require-param-description-options-19 "></a>
8128
+ <a name="eslint-plugin-jsdoc-rules-require-param-description-options-20 "></a>
7972
8129
#### Options
7973
8130
7974
- <a name="eslint-plugin-jsdoc-rules-require-param-description-options-19 -contexts-4"></a>
8131
+ <a name="eslint-plugin-jsdoc-rules-require-param-description-options-20 -contexts-4"></a>
7975
8132
##### <code>contexts</code>
7976
8133
7977
8134
Set this to an array of strings representing the AST context
@@ -8088,10 +8245,10 @@ Requires that all function parameters have names.
8088
8245
>
8089
8246
> [JSDoc](https: // jsdoc.app/tags-param.html#overview)
8090
8247
8091
- < a name= " eslint-plugin-jsdoc-rules-require-param-name-options-20 " >< / a>
8248
+ < a name= " eslint-plugin-jsdoc-rules-require-param-name-options-21 " >< / a>
8092
8249
#### Options
8093
8250
8094
- < a name= " eslint-plugin-jsdoc-rules-require-param-name-options-20 -contexts-5" >< / a>
8251
+ < a name= " eslint-plugin-jsdoc-rules-require-param-name-options-21 -contexts-5" >< / a>
8095
8252
##### < code> contexts< / code>
8096
8253
8097
8254
Set this to an array of strings representing the AST context
@@ -8203,10 +8360,10 @@ function quux (foo) {
8203
8360
8204
8361
Requires that each ` @param` tag has a ` type` value.
8205
8362
8206
- < a name= " eslint-plugin-jsdoc-rules-require-param-type-options-21 " >< / a>
8363
+ < a name= " eslint-plugin-jsdoc-rules-require-param-type-options-22 " >< / a>
8207
8364
#### Options
8208
8365
8209
- < a name= " eslint-plugin-jsdoc-rules-require-param-type-options-21 -contexts-6" >< / a>
8366
+ < a name= " eslint-plugin-jsdoc-rules-require-param-type-options-22 -contexts-6" >< / a>
8210
8367
##### < code> contexts< / code>
8211
8368
8212
8369
Set this to an array of strings representing the AST context
@@ -8319,7 +8476,7 @@ function quux (foo) {
8319
8476
8320
8477
Requires that all function parameters are documented.
8321
8478
8322
- <a name="eslint-plugin-jsdoc-rules-require-param-options-22 "></a>
8479
+ <a name="eslint-plugin-jsdoc-rules-require-param-options-23 "></a>
8323
8480
#### Options
8324
8481
8325
8482
An options object accepts one optional property:
@@ -9563,10 +9720,10 @@ function quux () {
9563
9720
Requires that the ` @returns` tag has a ` description` value . The error
9564
9721
will not be reported if the return value is ` void` or ` undefined` .
9565
9722
9566
- < a name= " eslint-plugin-jsdoc-rules-require-returns-description-options-23 " >< / a>
9723
+ < a name= " eslint-plugin-jsdoc-rules-require-returns-description-options-24 " >< / a>
9567
9724
#### Options
9568
9725
9569
- < a name= " eslint-plugin-jsdoc-rules-require-returns-description-options-23 -contexts-7" >< / a>
9726
+ < a name= " eslint-plugin-jsdoc-rules-require-returns-description-options-24 -contexts-7" >< / a>
9570
9727
##### < code> contexts< / code>
9571
9728
9572
9729
Set this to an array of strings representing the AST context
@@ -9701,10 +9858,10 @@ function quux () {
9701
9858
9702
9859
Requires that ` @returns` tag has ` type` value.
9703
9860
9704
- < a name= " eslint-plugin-jsdoc-rules-require-returns-type-options-24 " >< / a>
9861
+ < a name= " eslint-plugin-jsdoc-rules-require-returns-type-options-25 " >< / a>
9705
9862
#### Options
9706
9863
9707
- < a name= " eslint-plugin-jsdoc-rules-require-returns-type-options-24 -contexts-8" >< / a>
9864
+ < a name= " eslint-plugin-jsdoc-rules-require-returns-type-options-25 -contexts-8" >< / a>
9708
9865
##### < code> contexts< / code>
9709
9866
9710
9867
Set this to an array of strings representing the AST context
@@ -9821,7 +9978,7 @@ Requires returns are documented.
9821
9978
9822
9979
Will also report if multiple ` @returns` tags are present.
9823
9980
9824
- < a name= " eslint-plugin-jsdoc-rules-require-returns-options-25 " >< / a>
9981
+ < a name= " eslint-plugin-jsdoc-rules-require-returns-options-26 " >< / a>
9825
9982
#### Options
9826
9983
9827
9984
- ` exemptedBy` - Array of tags (e .g ., ` ['type']` ) whose presence on the document
@@ -10420,7 +10577,7 @@ Also impacts behaviors on namepath (or event)-defining and pointing tags:
10420
10577
allow `#`, `.`, or `~` at the end (which is not allowed at the end of
10421
10578
normal paths).
10422
10579
10423
- <a name="eslint-plugin-jsdoc-rules-valid-types-options-26 "></a>
10580
+ <a name="eslint-plugin-jsdoc-rules-valid-types-options-27 "></a>
10424
10581
#### Options
10425
10582
10426
10583
- `allowEmptyNamepaths` (default: true) - Set to `false` to disallow
0 commit comments