@@ -491,7 +491,7 @@ syntax highlighting). The following options determine whether a given
491
491
so you may wish to use ` (?:...) ` groups where you do not wish the
492
492
first such group treated as one to include. If no parenthetical group
493
493
exists or matches, the whole matching expression will be used.
494
- An example might be ```` "^```(?:js|javascript)([\\s\\S]*)```$" ````
494
+ An example might be ```` "^```(?:js|javascript)([\\s\\S]*)```\s* $" ````
495
495
to only match explicitly fenced JavaScript blocks.
496
496
* ` rejectExampleCodeRegex ` - Regex blacklist which rejects
497
497
non-lintable examples (has priority over ` exampleCodeRegex ` ). An example
@@ -502,6 +502,25 @@ If neither is in use, all examples will be matched. Note also that even if
502
502
` captionRequired ` is not set, any initial ` <caption> ` will be stripped out
503
503
before doing the regex matching.
504
504
505
+ <a name =" eslint-plugin-jsdoc-rules-options-paddedindent " ></a >
506
+ #### <code >paddedIndent</code >
507
+
508
+ This integer property allows one to add a fixed amount of whitespace at the
509
+ beginning of the second or later lines of the example to be stripped so as
510
+ to avoid linting issues with the decorative whitespace. For example, if set
511
+ to a value of ` 4 ` , the initial whitespace below will not trigger ` indent `
512
+ rule errors as the extra 4 spaces on each subsequent line will be stripped
513
+ out before evaluation.
514
+
515
+ ``` js
516
+ /**
517
+ * @example
518
+ * anArray .filter ((a ) => {
519
+ * return a .b ;
520
+ * });
521
+ */
522
+ ```
523
+
505
524
<a name =" eslint-plugin-jsdoc-rules-options-reportunuseddisabledirectives " ></a >
506
525
#### <code >reportUnusedDisableDirectives</code >
507
526
@@ -604,6 +623,7 @@ function quux () {
604
623
605
624
/**
606
625
* @example
626
+ *
607
627
* ` ` ` js alert('hello'); ` ` `
608
628
*/
609
629
function quux () {
@@ -644,7 +664,7 @@ function quux () {
644
664
function quux2 () {
645
665
646
666
}
647
- // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"rejectExampleCodeRegex":"^\\s*<.*>$"}]
667
+ // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"rejectExampleCodeRegex":"^\\s*<.*>\\s* $"}]
648
668
// Message: @example error (semi): Extra semicolon.
649
669
650
670
/**
@@ -696,7 +716,7 @@ function quux () {}
696
716
697
717
/**
698
718
* @example const i = 5 ;
699
- * quux2 ()
719
+ * quux2 ()
700
720
*/
701
721
function quux2 () {
702
722
@@ -706,7 +726,18 @@ function quux2 () {
706
726
707
727
/**
708
728
* @example const i = 5 ;
709
- * quux2 ()
729
+ * quux2 ()
730
+ */
731
+ function quux2 () {
732
+
733
+ }
734
+ // Options: [{"paddedIndent":2}]
735
+ // Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
736
+
737
+ /**
738
+ * @example
739
+ * const i = 5 ;
740
+ * quux2 ()
710
741
*/
711
742
function quux2 () {
712
743
@@ -715,7 +746,7 @@ function quux2 () {
715
746
716
747
/**
717
748
* @example const i = 5 ;
718
- * quux2 ()
749
+ * quux2 ()
719
750
*/
720
751
function quux2 () {
721
752
@@ -825,6 +856,15 @@ var quux = {
825
856
826
857
};
827
858
// Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
859
+
860
+ /**
861
+ * @example
862
+ * foo (function (err ) {
863
+ * throw err;
864
+ * });
865
+ */
866
+ function quux () {}
867
+ // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}]
828
868
````
829
869
830
870
@@ -3139,6 +3179,23 @@ function quux () {
3139
3179
}
3140
3180
// Options: ["never"]
3141
3181
// Message: There must be no newline after the description of the JSDoc block.
3182
+
3183
+ /**
3184
+ * A.
3185
+ *
3186
+ * @typedef {Object} A
3187
+ * @prop {boolean} a A.
3188
+ */
3189
+ // Options: ["never"]
3190
+ // Message: There must be no newline after the description of the JSDoc block.
3191
+
3192
+ /**
3193
+ * A.
3194
+ * @typedef {Object} A
3195
+ * @prop {boolean} a A.
3196
+ */
3197
+ // Options: ["always"]
3198
+ // Message: There must be a newline after the description of the JSDoc block.
3142
3199
````
3143
3200
3144
3201
The following patterns are not considered problems:
@@ -3370,6 +3427,14 @@ class Bar {
3370
3427
}
3371
3428
}
3372
3429
// Message: The type 'TEMPLATE_TYPE' is undefined.
3430
+
3431
+ /**
3432
+ * @type {strnig}
3433
+ */
3434
+ var quux = {
3435
+
3436
+ };
3437
+ // Message: The type 'strnig' is undefined.
3373
3438
````
3374
3439
3375
3440
The following patterns are not considered problems:
@@ -5981,6 +6046,8 @@ export class SomeClass {
5981
6046
5982
6047
Checks if the return expression exists in function body and in the comment.
5983
6048
6049
+ Will also report if multiple `@returns` tags are present.
6050
+
5984
6051
|||
5985
6052
|---|---|
5986
6053
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
@@ -6440,6 +6507,8 @@ function quux () {
6440
6507
6441
6508
Requires returns are documented.
6442
6509
6510
+ Will also report if multiple ` @returns ` tags are present.
6511
+
6443
6512
<a name =" eslint-plugin-jsdoc-rules-require-returns-options-11 " ></a >
6444
6513
#### Options
6445
6514
0 commit comments