File tree Expand file tree Collapse file tree 4 files changed +75
-2
lines changed Expand file tree Collapse file tree 4 files changed +75
-2
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,21 @@ templates of this format:
38
38
39
39
Defaults to ` false ` .
40
40
41
+ ### ` exemptedBy `
42
+
43
+ Array of tags (e.g., ` ['type'] ` ) whose presence on the document
44
+ block avoids the need for a ` @template ` . Defaults to an array with
45
+ ` inheritdoc ` . If you set this array, it will overwrite the default,
46
+ so be sure to add back ` inheritdoc ` if you wish its presence to cause
47
+ exemption of the rule.
48
+
41
49
|||
42
50
| ---| ---|
43
51
| Context| everywhere|
44
52
| Tags| ` template ` |
45
53
| Recommended| false|
46
54
| Settings||
47
- | Options| ` requireSeparateTemplates ` |
55
+ | Options| ` exemptedBy ` , ` requireSeparateTemplates ` |
48
56
49
57
## Failing examples
50
58
Original file line number Diff line number Diff line change @@ -44,13 +44,23 @@ templates of this format:
44
44
45
45
Defaults to ` false ` .
46
46
47
+ <a name =" user-content-require-template-options-exemptedby " ></a >
48
+ <a name =" require-template-options-exemptedby " ></a >
49
+ ### <code >exemptedBy</code >
50
+
51
+ Array of tags (e.g., ` ['type'] ` ) whose presence on the document
52
+ block avoids the need for a ` @template ` . Defaults to an array with
53
+ ` inheritdoc ` . If you set this array, it will overwrite the default,
54
+ so be sure to add back ` inheritdoc ` if you wish its presence to cause
55
+ exemption of the rule.
56
+
47
57
|||
48
58
| ---| ---|
49
59
| Context| everywhere|
50
60
| Tags| ` template ` |
51
61
| Recommended| false|
52
62
| Settings||
53
- | Options| ` requireSeparateTemplates ` |
63
+ | Options| ` exemptedBy ` , ` requireSeparateTemplates ` |
54
64
55
65
<a name =" user-content-require-template-failing-examples " ></a >
56
66
<a name =" require-template-failing-examples " ></a >
@@ -362,5 +372,17 @@ export default class <NumType> {
362
372
* @property {U} aNumber number
363
373
* @property {string} parentPath path
364
374
*/
375
+
376
+ /**
377
+ * @type {Something}
378
+ */
379
+ type Pairs <D , V > = [D , V | undefined ];
380
+ // "jsdoc/require-template": ["error"|"warn", {"exemptedBy":["type"]}]
381
+
382
+ /**
383
+ * @inheritdoc
384
+ * @typedef {[D, V | undefined]} Pairs
385
+ */
386
+ // "jsdoc/require-template": ["error"|"warn", {"exemptedBy":["inheritdoc"]}]
365
387
````
366
388
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ export default iterateJsdoc(({
12
12
settings,
13
13
utils,
14
14
} ) => {
15
+ if ( utils . avoidDocs ( ) ) {
16
+ return ;
17
+ }
18
+
15
19
const {
16
20
requireSeparateTemplates = false ,
17
21
} = context . options [ 0 ] || { } ;
@@ -189,6 +193,12 @@ export default iterateJsdoc(({
189
193
{
190
194
additionalProperties : false ,
191
195
properties : {
196
+ exemptedBy : {
197
+ items : {
198
+ type : 'string' ,
199
+ } ,
200
+ type : 'array' ,
201
+ } ,
192
202
requireSeparateTemplates : {
193
203
type : 'boolean' ,
194
204
} ,
Original file line number Diff line number Diff line change @@ -645,5 +645,38 @@ export default /** @type {import('../index.js').TestCases} */ ({
645
645
*/
646
646
` ,
647
647
} ,
648
+ {
649
+ code : `
650
+ /**
651
+ * @type {Something}
652
+ */
653
+ type Pairs<D, V> = [D, V | undefined];
654
+ ` ,
655
+ languageOptions : {
656
+ parser : typescriptEslintParser ,
657
+ } ,
658
+ options : [
659
+ {
660
+ exemptedBy : [
661
+ 'type' ,
662
+ ] ,
663
+ } ,
664
+ ] ,
665
+ } ,
666
+ {
667
+ code : `
668
+ /**
669
+ * @inheritdoc
670
+ * @typedef {[D, V | undefined]} Pairs
671
+ */
672
+ ` ,
673
+ options : [
674
+ {
675
+ exemptedBy : [
676
+ 'inheritdoc' ,
677
+ ] ,
678
+ } ,
679
+ ] ,
680
+ } ,
648
681
] ,
649
682
} ) ;
You can’t perform that action at this time.
0 commit comments