Skip to content

Commit 7e155be

Browse files
authored
fix(typescript): add rule descriptions (#1516)
1 parent 6b20133 commit 7e155be

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/bin/generateRuleTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ for (const [
1313
rule,
1414
] of Object.entries(index.rules)) {
1515
if (rule.meta?.schema?.[0]) {
16+
str += ` /** ${rule.meta.docs.description} */\n`;
1617
str += ` "jsdoc/${ruleName}": `;
1718
const ts = await compile({
1819
items: rule.meta.schema,

src/rules.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface Rules {
2+
/** Reports invalid alignment of JSDoc block asterisks. */
23
"jsdoc/check-alignment":
34
| []
45
| [
@@ -7,6 +8,7 @@ export interface Rules {
78
}
89
];
910

11+
/** Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules. */
1012
"jsdoc/check-examples":
1113
| []
1214
| [
@@ -33,6 +35,7 @@ export interface Rules {
3335
}
3436
];
3537

38+
/** Reports invalid padding inside JSDoc blocks. */
3639
"jsdoc/check-indentation":
3740
| []
3841
| [
@@ -41,6 +44,7 @@ export interface Rules {
4144
}
4245
];
4346

47+
/** Reports invalid alignment of JSDoc block lines. */
4448
"jsdoc/check-line-alignment":
4549
| []
4650
| ["always" | "never" | "any"]
@@ -61,6 +65,7 @@ export interface Rules {
6165
}
6266
];
6367

68+
/** Ensures that parameter names in JSDoc match those in the function declaration. */
6469
"jsdoc/check-param-names":
6570
| []
6671
| [
@@ -76,6 +81,7 @@ export interface Rules {
7681
}
7782
];
7883

84+
/** Ensures that property names in JSDoc are not duplicated on the same block and that nested properties have defined roots. */
7985
"jsdoc/check-property-names":
8086
| []
8187
| [
@@ -84,6 +90,7 @@ export interface Rules {
8490
}
8591
];
8692

93+
/** Reports invalid block tag names. */
8794
"jsdoc/check-tag-names":
8895
| []
8996
| [
@@ -95,6 +102,7 @@ export interface Rules {
95102
}
96103
];
97104

105+
/** Reports invalid types. */
98106
"jsdoc/check-types":
99107
| []
100108
| [
@@ -108,6 +116,7 @@ export interface Rules {
108116
}
109117
];
110118

119+
/** This rule checks the values for a handful of tags: `@version`, `@since`, `@license` and `@author`. */
111120
"jsdoc/check-values":
112121
| []
113122
| [
@@ -119,6 +128,7 @@ export interface Rules {
119128
}
120129
];
121130

131+
/** Converts non-JSDoc comments preceding or following nodes into JSDoc ones */
122132
"jsdoc/convert-to-jsdoc-comments":
123133
| []
124134
| [
@@ -151,6 +161,7 @@ export interface Rules {
151161
}
152162
];
153163

164+
/** Expects specific tags to be empty of any content. */
154165
"jsdoc/empty-tags":
155166
| []
156167
| [
@@ -159,6 +170,7 @@ export interface Rules {
159170
}
160171
];
161172

173+
/** Reports an issue with any non-constructor function using `@implements`. */
162174
"jsdoc/implements-on-classes":
163175
| []
164176
| [
@@ -173,6 +185,7 @@ export interface Rules {
173185
}
174186
];
175187

188+
/** This rule reports doc comments that only restate their attached name. */
176189
"jsdoc/informative-docs":
177190
| []
178191
| [
@@ -189,6 +202,7 @@ export interface Rules {
189202
}
190203
];
191204

205+
/** Enforces minimum number of newlines before JSDoc comment blocks */
192206
"jsdoc/lines-before-block":
193207
| []
194208
| [
@@ -201,6 +215,7 @@ export interface Rules {
201215
}
202216
];
203217

218+
/** Enforces a regular expression pattern on descriptions. */
204219
"jsdoc/match-description":
205220
| []
206221
| [
@@ -238,6 +253,7 @@ export interface Rules {
238253
}
239254
];
240255

256+
/** Reports the name portion of a JSDoc tag if matching or not matching a given regular expression. */
241257
"jsdoc/match-name":
242258
| []
243259
| [
@@ -254,6 +270,7 @@ export interface Rules {
254270
}
255271
];
256272

273+
/** Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks. */
257274
"jsdoc/multiline-blocks":
258275
| []
259276
| [
@@ -270,6 +287,7 @@ export interface Rules {
270287
}
271288
];
272289

290+
/** This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block. */
273291
"jsdoc/no-bad-blocks":
274292
| []
275293
| [
@@ -279,6 +297,7 @@ export interface Rules {
279297
}
280298
];
281299

300+
/** Removes empty blocks with nothing but possibly line breaks */
282301
"jsdoc/no-blank-blocks":
283302
| []
284303
| [
@@ -287,6 +306,7 @@ export interface Rules {
287306
}
288307
];
289308

309+
/** This rule reports defaults being used on the relevant portion of `@param` or `@default`. */
290310
"jsdoc/no-defaults":
291311
| []
292312
| [
@@ -302,6 +322,7 @@ export interface Rules {
302322
}
303323
];
304324

325+
/** Reports when certain comment structures are always expected. */
305326
"jsdoc/no-missing-syntax":
306327
| []
307328
| [
@@ -318,6 +339,7 @@ export interface Rules {
318339
}
319340
];
320341

342+
/** Prevents use of multiple asterisks at the beginning of lines. */
321343
"jsdoc/no-multi-asterisks":
322344
| []
323345
| [
@@ -328,6 +350,7 @@ export interface Rules {
328350
}
329351
];
330352

353+
/** Reports when certain comment structures are present. */
331354
"jsdoc/no-restricted-syntax":
332355
| []
333356
| [
@@ -343,6 +366,7 @@ export interface Rules {
343366
}
344367
];
345368

369+
/** This rule reports types being used on `@param` or `@returns`. */
346370
"jsdoc/no-types":
347371
| []
348372
| [
@@ -357,6 +381,7 @@ export interface Rules {
357381
}
358382
];
359383

384+
/** Checks that types in jsdoc comments are defined. */
360385
"jsdoc/no-undefined-types":
361386
| []
362387
| [
@@ -367,6 +392,7 @@ export interface Rules {
367392
}
368393
];
369394

395+
/** Requires that each JSDoc line starts with an `*`. */
370396
"jsdoc/require-asterisk-prefix":
371397
| []
372398
| ["always" | "never" | "any"]
@@ -381,6 +407,7 @@ export interface Rules {
381407
}
382408
];
383409

410+
/** Requires that all functions have a description. */
384411
"jsdoc/require-description":
385412
| []
386413
| [
@@ -400,6 +427,7 @@ export interface Rules {
400427
}
401428
];
402429

430+
/** Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences. */
403431
"jsdoc/require-description-complete-sentence":
404432
| []
405433
| [
@@ -410,6 +438,7 @@ export interface Rules {
410438
}
411439
];
412440

441+
/** Requires that all functions have examples. */
413442
"jsdoc/require-example":
414443
| []
415444
| [
@@ -430,6 +459,7 @@ export interface Rules {
430459
}
431460
];
432461

462+
/** Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file. */
433463
"jsdoc/require-file-overview":
434464
| []
435465
| [
@@ -448,6 +478,7 @@ export interface Rules {
448478
}
449479
];
450480

481+
/** Requires a hyphen before the `@param` description. */
451482
"jsdoc/require-hyphen-before-param-description":
452483
| []
453484
| ["always" | "never"]
@@ -466,6 +497,7 @@ export interface Rules {
466497
}
467498
];
468499

500+
/** Require JSDoc comments */
469501
"jsdoc/require-jsdoc":
470502
| []
471503
| [
@@ -507,6 +539,7 @@ export interface Rules {
507539
}
508540
];
509541

542+
/** Requires that all function parameters are documented. */
510543
"jsdoc/require-param":
511544
| []
512545
| [
@@ -536,6 +569,7 @@ export interface Rules {
536569
}
537570
];
538571

572+
/** Requires that each `@param` tag has a `description` value. */
539573
"jsdoc/require-param-description":
540574
| []
541575
| [
@@ -552,6 +586,7 @@ export interface Rules {
552586
}
553587
];
554588

589+
/** Requires that all function parameters have names. */
555590
"jsdoc/require-param-name":
556591
| []
557592
| [
@@ -566,6 +601,7 @@ export interface Rules {
566601
}
567602
];
568603

604+
/** Requires that each `@param` tag has a `type` value. */
569605
"jsdoc/require-param-type":
570606
| []
571607
| [
@@ -582,6 +618,7 @@ export interface Rules {
582618
}
583619
];
584620

621+
/** Requires that returns are documented. */
585622
"jsdoc/require-returns":
586623
| []
587624
| [
@@ -611,6 +648,7 @@ export interface Rules {
611648
}
612649
];
613650

651+
/** Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment. */
614652
"jsdoc/require-returns-check":
615653
| []
616654
| [
@@ -621,6 +659,7 @@ export interface Rules {
621659
}
622660
];
623661

662+
/** Requires that the `@returns` tag has a `description` value. */
624663
"jsdoc/require-returns-description":
625664
| []
626665
| [
@@ -635,6 +674,7 @@ export interface Rules {
635674
}
636675
];
637676

677+
/** Requires that `@returns` tag has `type` value. */
638678
"jsdoc/require-returns-type":
639679
| []
640680
| [
@@ -649,6 +689,7 @@ export interface Rules {
649689
}
650690
];
651691

692+
/** Requires template tags for each generic type parameter */
652693
"jsdoc/require-template":
653694
| []
654695
| [
@@ -658,6 +699,7 @@ export interface Rules {
658699
}
659700
];
660701

702+
/** Requires that throw statements are documented. */
661703
"jsdoc/require-throws":
662704
| []
663705
| [
@@ -673,6 +715,7 @@ export interface Rules {
673715
}
674716
];
675717

718+
/** Requires yields are documented. */
676719
"jsdoc/require-yields":
677720
| []
678721
| [
@@ -693,6 +736,7 @@ export interface Rules {
693736
}
694737
];
695738

739+
/** Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment. */
696740
"jsdoc/require-yields-check":
697741
| []
698742
| [
@@ -710,6 +754,7 @@ export interface Rules {
710754
}
711755
];
712756

757+
/** Sorts tags by a specified sequence according to tag name. */
713758
"jsdoc/sort-tags":
714759
| []
715760
| [
@@ -724,6 +769,7 @@ export interface Rules {
724769
}
725770
];
726771

772+
/** Enforces lines (or no lines) between tags. */
727773
"jsdoc/tag-lines":
728774
| []
729775
| ["always" | "any" | "never"]
@@ -747,6 +793,7 @@ export interface Rules {
747793
}
748794
];
749795

796+
/** Auto-escape certain characters that are input within block and tag descriptions. */
750797
"jsdoc/text-escaping":
751798
| []
752799
| [
@@ -756,6 +803,7 @@ export interface Rules {
756803
}
757804
];
758805

806+
/** Formats JSDoc type values. */
759807
"jsdoc/type-formatting":
760808
| []
761809
| [
@@ -776,6 +824,7 @@ export interface Rules {
776824
}
777825
];
778826

827+
/** Requires all types to be valid JSDoc or Closure compiler types without syntax errors. */
779828
"jsdoc/valid-types":
780829
| []
781830
| [

0 commit comments

Comments
 (0)