eslint-plugin-jsdoc 46.2.5 → 46.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"matchDescription.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","matchDescriptionDefault","stringOrDefault","value","userDefault","_default","iterateJsdoc","jsdoc","report","context","utils","mainDescription","matchDescription","message","tags","options","validateDescription","desc","tag","mainDescriptionMatch","errorMessage","match","Object","hasOwn","tagValue","tagName","regex","getRegexFromString","test","line","source","number","description","getDescription","keys","length","hasOptionTag","Boolean","forEachPreferredTag","matchingJsdocTag","targetTagName","name","getTagDescription","trim","whitelistedTags","filterTags","tagsWithNames","tagsWithoutNames","getTagsByType","some","replace","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","oneOf","format","patternProperties","enum","exports","module"],"sources":["../../src/rules/matchDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n// If supporting Node >= 10, we could loosen the default to this for the\n// initial letter: \\\\p{Upper}\nconst matchDescriptionDefault = '^\\n?([A-Z`\\\\d_][\\\\s\\\\S]*[.?!`]\\\\s*)?$';\n\n/**\n * @param {string} value\n * @param {string} userDefault\n * @returns {string}\n */\nconst stringOrDefault = (value, userDefault) => {\n return typeof value === 'string' ?\n value :\n userDefault || matchDescriptionDefault;\n};\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n utils,\n}) => {\n const {\n mainDescription,\n matchDescription,\n message,\n tags,\n } = context.options[0] || {};\n\n /**\n * @param {string} desc\n * @param {import('comment-parser').Spec} [tag]\n * @returns {void}\n */\n const validateDescription = (desc, tag) => {\n let mainDescriptionMatch = mainDescription;\n let errorMessage = message;\n if (typeof mainDescription === 'object') {\n mainDescriptionMatch = mainDescription.match;\n errorMessage = mainDescription.message;\n }\n\n if (mainDescriptionMatch === false && (\n !tag || !Object.hasOwn(tags, tag.tag))\n ) {\n return;\n }\n\n let tagValue = mainDescriptionMatch;\n if (tag) {\n const tagName = tag.tag;\n if (typeof tags[tagName] === 'object') {\n tagValue = tags[tagName].match;\n errorMessage = tags[tagName].message;\n } else {\n tagValue = tags[tagName];\n }\n }\n\n const regex = utils.getRegexFromString(\n stringOrDefault(tagValue, matchDescription),\n );\n\n if (!regex.test(desc)) {\n report(\n errorMessage || 'JSDoc description does not satisfy the regex pattern.',\n null,\n tag || {\n // Add one as description would typically be into block\n line: jsdoc.source[0].number + 1,\n },\n );\n }\n };\n\n const {\n description,\n } = utils.getDescription();\n if (description) {\n validateDescription(description);\n }\n\n if (!tags || !Object.keys(tags).length) {\n return;\n }\n\n /**\n * @param {string} tagName\n * @returns {boolean}\n */\n const hasOptionTag = (tagName) => {\n return Boolean(tags[tagName]);\n };\n\n utils.forEachPreferredTag('description', (matchingJsdocTag, targetTagName) => {\n const desc = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim();\n if (hasOptionTag(targetTagName)) {\n validateDescription(desc, matchingJsdocTag);\n }\n }, true);\n\n const whitelistedTags = utils.filterTags(({\n tag: tagName,\n }) => {\n return hasOptionTag(tagName);\n });\n const {\n tagsWithNames,\n tagsWithoutNames,\n } = utils.getTagsByType(whitelistedTags);\n\n tagsWithNames.some((tag) => {\n const desc = /** @type {string} */ (\n utils.getTagDescription(tag)\n ).replace(/^[- ]*/u, '')\n .trim();\n\n return validateDescription(desc, tag);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = (tag.name + ' ' + utils.getTagDescription(tag)).trim();\n\n return validateDescription(desc, tag);\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Enforces a regular expression pattern on descriptions.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/match-description.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n mainDescription: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n matchDescription: {\n format: 'regex',\n type: 'string',\n },\n message: {\n type: 'string',\n },\n tags: {\n patternProperties: {\n '.*': {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C;AACA;AACA,MAAMG,uBAAuB,GAAG,uCAAuC;;AAEvE;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGA,CAACC,KAAK,EAAEC,WAAW,KAAK;EAC9C,OAAO,OAAOD,KAAK,KAAK,QAAQ,GAC9BA,KAAK,GACLC,WAAW,IAAIH,uBAAuB;AAC1C,CAAC;AAAC,IAAAI,QAAA,GAEa,IAAAC,qBAAY,EAAC,CAAC;EAC3BC,KAAK;EACLC,MAAM;EACNC,OAAO;EACPC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,eAAe;IACfC,gBAAgB;IAChBC,OAAO;IACPC;EACF,CAAC,GA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AO;UACfH,IAAI,EAAE;QACR,CAAC;QACDhD,OAAO,EAAE;UACPgD,IAAI,EAAE;QACR,CAAC;QACD/C,IAAI,EAAE;UACJmD,iBAAiB,EAAE;YACjB,IAAI,EAAE;cACJF,KAAK,EAAE,CACL;gBACEC,MAAM,EAAE,OAAO;gBACfH,IAAI,EAAE;cACR,CAAC,EACD;gBACEK,IAAI,EAAE,CACJ,IAAI,CACL;gBACDL,IAAI,EAAE;cACR,CAAC,EACD;gBACEL,oBAAoB,EAAE,KAAK;gBAC3BC,UAAU,EAAE;kBACVpC,KAAK,EAAE;oBACL0C,KAAK,EAAE,CACL;sBACEC,MAAM,EAAE,OAAO;sBACfH,IAAI,EAAE;oBACR,CAAC,EACD;sBACEK,IAAI,EAAE,CACJ,IAAI,CACL;sBACDL,IAAI,EAAE;oBACR,CAAC;kBAEL,CAAC;kBACDhD,OAAO,EAAE;oBACPgD,IAAI,EAAE;kBACR;gBACF,CAAC;gBACDA,IAAI,EAAE;cACR,CAAC;YAEL;UACF,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAM,OAAA,CAAAnE,OAAA,GAAAK,QAAA;AAAA+D,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAnE,OAAA"}
1
+ {"version":3,"file":"matchDescription.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","matchDescriptionDefault","stringOrDefault","value","userDefault","_default","iterateJsdoc","jsdoc","report","context","utils","mainDescription","matchDescription","message","nonemptyTags","tags","options","validateDescription","desc","tag","mainDescriptionMatch","errorMessage","match","Object","hasOwn","tagValue","tagName","regex","getRegexFromString","test","line","source","number","description","getDescription","hasNoTag","forEachPreferredTag","matchingJsdocTag","targetTagName","name","getTagDescription","trim","keys","length","hasOptionTag","Boolean","whitelistedTags","filterTags","tagsWithNames","tagsWithoutNames","getTagsByType","some","replace","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","oneOf","format","patternProperties","enum","exports","module"],"sources":["../../src/rules/matchDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n// If supporting Node >= 10, we could loosen the default to this for the\n// initial letter: \\\\p{Upper}\nconst matchDescriptionDefault = '^\\n?([A-Z`\\\\d_][\\\\s\\\\S]*[.?!`]\\\\s*)?$';\n\n/**\n * @param {string} value\n * @param {string} userDefault\n * @returns {string}\n */\nconst stringOrDefault = (value, userDefault) => {\n return typeof value === 'string' ?\n value :\n userDefault || matchDescriptionDefault;\n};\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n utils,\n}) => {\n const {\n mainDescription,\n matchDescription,\n message,\n nonemptyTags = true,\n tags = {},\n } = context.options[0] || {};\n\n /**\n * @param {string} desc\n * @param {import('comment-parser').Spec} [tag]\n * @returns {void}\n */\n const validateDescription = (desc, tag) => {\n let mainDescriptionMatch = mainDescription;\n let errorMessage = message;\n if (typeof mainDescription === 'object') {\n mainDescriptionMatch = mainDescription.match;\n errorMessage = mainDescription.message;\n }\n\n if (mainDescriptionMatch === false && (\n !tag || !Object.hasOwn(tags, tag.tag))\n ) {\n return;\n }\n\n let tagValue = mainDescriptionMatch;\n if (tag) {\n const tagName = tag.tag;\n if (typeof tags[tagName] === 'object') {\n tagValue = tags[tagName].match;\n errorMessage = tags[tagName].message;\n } else {\n tagValue = tags[tagName];\n }\n }\n\n const regex = utils.getRegexFromString(\n stringOrDefault(tagValue, matchDescription),\n );\n\n if (!regex.test(desc)) {\n report(\n errorMessage || 'JSDoc description does not satisfy the regex pattern.',\n null,\n tag || {\n // Add one as description would typically be into block\n line: jsdoc.source[0].number + 1,\n },\n );\n }\n };\n\n const {\n description,\n } = utils.getDescription();\n if (description) {\n validateDescription(description);\n }\n\n /**\n * @param {string} tagName\n * @returns {boolean}\n */\n const hasNoTag = (tagName) => {\n return !tags[tagName];\n };\n\n for (const tag of [\n 'description',\n 'summary',\n 'file',\n 'classdesc',\n ]) {\n utils.forEachPreferredTag(tag, (matchingJsdocTag, targetTagName) => {\n const desc = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim();\n if (hasNoTag(targetTagName)) {\n validateDescription(desc, matchingJsdocTag);\n }\n }, true);\n }\n\n if (nonemptyTags) {\n for (const tag of [\n 'copyright',\n 'example',\n 'see',\n 'throws',\n 'todo',\n 'yields',\n ]) {\n utils.forEachPreferredTag(tag, (matchingJsdocTag, targetTagName) => {\n const desc = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim();\n\n if (hasNoTag(targetTagName) && !(/.+/u).test(desc)) {\n report(\n 'JSDoc description must not be empty.',\n null,\n matchingJsdocTag,\n );\n }\n });\n }\n }\n\n if (!Object.keys(tags).length) {\n return;\n }\n\n /**\n * @param {string} tagName\n * @returns {boolean}\n */\n const hasOptionTag = (tagName) => {\n return Boolean(tags[tagName]);\n };\n\n const whitelistedTags = utils.filterTags(({\n tag: tagName,\n }) => {\n return hasOptionTag(tagName);\n });\n const {\n tagsWithNames,\n tagsWithoutNames,\n } = utils.getTagsByType(whitelistedTags);\n\n tagsWithNames.some((tag) => {\n const desc = /** @type {string} */ (\n utils.getTagDescription(tag)\n ).replace(/^[- ]*/u, '')\n .trim();\n\n return validateDescription(desc, tag);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = (tag.name + ' ' + utils.getTagDescription(tag)).trim();\n\n return validateDescription(desc, tag);\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Enforces a regular expression pattern on descriptions.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/match-description.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n mainDescription: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n matchDescription: {\n format: 'regex',\n type: 'string',\n },\n message: {\n type: 'string',\n },\n nonemptyTags: {\n type: 'boolean',\n },\n tags: {\n patternProperties: {\n '.*': {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C;AACA;AACA,MAAMG,uBAAuB,GAAG,uCAAuC;;AAEvE;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGA,CAACC,KAAK,EAAEC,WAAW,KAAK;EAC9C,OAAO,OAAOD,KAAK,KAAK,QAAQ,GAC9BA,KAAK,GACLC,WAAW,IAAIH,uBAAuB;AAC1C,CAAC;AAAC,IAAAI,QAAA,GAEa,IAAAC,qBAAY,EAAC,CAAC;EAC3BC,KAAK;EACLC,MAAM;EACNC,OAAO;EACPC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,eAAe;IACfC,gBAAgB;IAChBC,OAAO;IACPC,YAAY,GAAG,IAAI;IACnBC,IAAI,GAAG,CAAC;EACV,CA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EAAE;oBACR,CAAC,EACD;sBACEK,IAAI,EAAE,CACJ,IAAI,CACL;sBACDL,IAAI,EAAE;oBACR,CAAC;kBAEL,CAAC;kBACDlD,OAAO,EAAE;oBACPkD,IAAI,EAAE;kBACR;gBACF,CAAC;gBACDA,IAAI,EAAE;cACR,CAAC;YAEL;UACF,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAM,OAAA,CAAArE,OAAA,GAAAK,QAAA;AAAAiE,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAArE,OAAA"}
@@ -5,6 +5,7 @@
5
5
  * [Options](#user-content-match-description-options)
6
6
  * [`matchDescription`](#user-content-match-description-options-matchdescription)
7
7
  * [`message`](#user-content-match-description-options-message)
8
+ * [`nonemptyTags`](#user-content-match-description-options-nonemptytags)
8
9
  * [`tags`](#user-content-match-description-options-tags)
9
10
  * [`mainDescription`](#user-content-match-description-options-maindescription)
10
11
  * [`contexts`](#user-content-match-description-options-contexts)
@@ -21,8 +22,14 @@ by our supported Node versions):
21
22
 
22
23
  ``^\n?([A-Z`\\d_][\\s\\S]*[.?!`]\\s*)?$``
23
24
 
24
- Applies to the jsdoc block description and `@description` (or `@desc`)
25
- by default but the `tags` option (see below) may be used to match other tags.
25
+ Applies by default to the jsdoc block description and to the following tags:
26
+
27
+ - `@description`/`@desc`
28
+ - `@summary`
29
+ - `@file`/`@fileoverview`/`@overview`
30
+ - `@classdesc`
31
+
32
+ In addition, the `tags` option (see below) may be used to match other tags.
26
33
 
27
34
  The default (and all regex options) defaults to using (only) the `u` flag, so
28
35
  to add your own flags, encapsulate your expression as a string, but like a
@@ -71,6 +78,23 @@ You may provide a custom default message by using the following format:
71
78
  This can be overridden per tag or for the main block description by setting
72
79
  `message` within `tags` or `mainDescription`, respectively.
73
80
 
81
+ <a name="user-content-match-description-options-nonemptytags"></a>
82
+ <a name="match-description-options-nonemptytags"></a>
83
+ ### <code>nonemptyTags</code>
84
+
85
+ If not set to `false`, will enforce that the following tags have at least
86
+ some content:
87
+
88
+ - `@copyright`
89
+ - `@example`
90
+ - `@see`
91
+ - `@todo`
92
+ - `@throws`/`@exception`
93
+ - `@yields`/`@yield`
94
+
95
+ If you supply your own tag description for any of the above tags in `tags`,
96
+ your description will take precedence.
97
+
74
98
  <a name="user-content-match-description-options-tags"></a>
75
99
  <a name="match-description-options-tags"></a>
76
100
  ### <code>tags</code>
@@ -186,7 +210,7 @@ section of our README for more on the expected format.
186
210
  |Aliases|`@desc`|
187
211
  |Recommended|false|
188
212
  |Settings||
189
- |Options|`contexts`, `mainDescription`, `matchDescription`, `message`, `tags`|
213
+ |Options|`contexts`, `mainDescription`, `matchDescription`, `message`, `nonemptyTags`, `tags`|
190
214
 
191
215
  <a name="user-content-match-description-failing-examples"></a>
192
216
  <a name="match-description-failing-examples"></a>
@@ -335,7 +359,6 @@ function quux (foo) {
335
359
  function quux () {
336
360
 
337
361
  }
338
- // "jsdoc/match-description": ["error"|"warn", {"tags":{"summary":true}}]
339
362
  // Message: JSDoc description does not satisfy the regex pattern.
340
363
 
341
364
  /**
@@ -368,7 +391,6 @@ function quux () {
368
391
  function quux (foo) {
369
392
 
370
393
  }
371
- // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
372
394
  // Message: JSDoc description does not satisfy the regex pattern.
373
395
 
374
396
  /**
@@ -602,6 +624,13 @@ function quux () {
602
624
  function foo(): string;
603
625
  // "jsdoc/match-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine=0]"}],"matchDescription":"^\\S[\\s\\S]*\\S$"}]
604
626
  // Message: JSDoc description does not satisfy the regex pattern.
627
+
628
+ /**
629
+ * @copyright
630
+ */
631
+ function quux () {
632
+ }
633
+ // Message: JSDoc description must not be empty.
605
634
  ````
606
635
 
607
636
 
@@ -722,7 +751,6 @@ function quux () {
722
751
  function quux () {
723
752
 
724
753
  }
725
- // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
726
754
 
727
755
  /**
728
756
  * @description Foo
@@ -732,13 +760,11 @@ function quux () {
732
760
  function quux () {
733
761
 
734
762
  }
735
- // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
736
763
 
737
764
  /** @description Foo bar. */
738
765
  function quux () {
739
766
 
740
767
  }
741
- // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
742
768
 
743
769
  /**
744
770
  * @description Foo
@@ -747,7 +773,6 @@ function quux () {
747
773
  function quux () {
748
774
 
749
775
  }
750
- // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
751
776
 
752
777
  /**
753
778
  * Foo. {@see Math.sin}.
@@ -872,7 +897,7 @@ const q = {
872
897
  // "jsdoc/match-description": ["error"|"warn", {"contexts":[]}]
873
898
 
874
899
  /**
875
- * @description foo.
900
+ * @deprecated foo.
876
901
  */
877
902
  function quux () {
878
903
 
@@ -887,7 +912,6 @@ function quux () {
887
912
  function quux () {
888
913
 
889
914
  }
890
- // "jsdoc/match-description": ["error"|"warn", {"tags":{"summary":true}}]
891
915
 
892
916
  /**
893
917
  * Foo.
@@ -975,5 +999,12 @@ function foo(): string;
975
999
  */
976
1000
  function foo(): void;
977
1001
  // "jsdoc/match-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine!=0]:not(:has(JsdocTag))"}],"matchDescription":"^\\S[\\s\\S]*\\S$"}]
1002
+
1003
+ /**
1004
+ * @copyright
1005
+ */
1006
+ function quux () {
1007
+ }
1008
+ // "jsdoc/match-description": ["error"|"warn", {"nonemptyTags":false}]
978
1009
  ````
979
1010
 
@@ -178,6 +178,12 @@ function quux () {}
178
178
  */
179
179
  // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","replacement":""}]}]
180
180
  // Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
181
+
182
+ /**
183
+ * @template
184
+ */
185
+ // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^$/","tags":["template"]}]}]
186
+ // Message: Only allowing names not matching `/^$/u` but found "".
181
187
  ````
182
188
 
183
189
 
@@ -373,5 +373,11 @@ class Test {
373
373
  abstract Test(): void;
374
374
  }
375
375
  // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"TSEmptyBodyFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"methods with non-void return types must have a @returns tag"}]}]
376
+
377
+ /**
378
+ * @private
379
+ */
380
+ function quux () {}
381
+ // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(JsdocBlock:has(JsdocTag[tag=/private|protected|public/]))","context":"any","message":"Access modifier tags must be present"}]}]
376
382
  ````
377
383
 
@@ -8,7 +8,8 @@
8
8
  * [Passing examples](#user-content-require-description-passing-examples)
9
9
 
10
10
 
11
- Requires that all functions have a description.
11
+ Requires that all functions (or optionally other structures) with a JSDoc block
12
+ have a description.
12
13
 
13
14
  * All functions must have an implicit description (e.g., text above tags) or
14
15
  have the option `descriptionStyle` set to `tag` (requiring `@description`
package/package.json CHANGED
@@ -136,5 +136,5 @@
136
136
  "test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
137
137
  "test-index": "npm run test-no-cov -- test/rules/index.js"
138
138
  },
139
- "version": "46.2.5"
139
+ "version": "46.3.0"
140
140
  }