eslint-plugin-jsdoc 3.15.0 → 3.15.1

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.
package/README.md CHANGED
@@ -23,16 +23,17 @@ JSDoc linting rules for ESLint.
23
23
  * [`check-types`](#eslint-plugin-jsdoc-rules-check-types)
24
24
  * [`newline-after-description`](#eslint-plugin-jsdoc-rules-newline-after-description)
25
25
  * [`no-undefined-types`](#eslint-plugin-jsdoc-rules-no-undefined-types)
26
- * [`require-description`](#eslint-plugin-jsdoc-rules-require-description)
27
26
  * [`require-description-complete-sentence`](#eslint-plugin-jsdoc-rules-require-description-complete-sentence)
27
+ * [`require-description`](#eslint-plugin-jsdoc-rules-require-description)
28
28
  * [`require-example`](#eslint-plugin-jsdoc-rules-require-example)
29
29
  * [`require-hyphen-before-param-description`](#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description)
30
- * [`require-param`](#eslint-plugin-jsdoc-rules-require-param)
31
30
  * [`require-param-description`](#eslint-plugin-jsdoc-rules-require-param-description)
32
31
  * [`require-param-name`](#eslint-plugin-jsdoc-rules-require-param-name)
33
32
  * [`require-param-type`](#eslint-plugin-jsdoc-rules-require-param-type)
33
+ * [`require-param`](#eslint-plugin-jsdoc-rules-require-param)
34
34
  * [`require-returns-description`](#eslint-plugin-jsdoc-rules-require-returns-description)
35
35
  * [`require-returns-type`](#eslint-plugin-jsdoc-rules-require-returns-type)
36
+ * [`require-returns`](#eslint-plugin-jsdoc-rules-require-returns)
36
37
  * [`valid-types`](#eslint-plugin-jsdoc-rules-valid-types)
37
38
 
38
39
 
@@ -56,6 +57,7 @@ This table maps the rules between `eslint-plugin-jsdoc` and `jscs-jsdoc`.
56
57
  | [`require-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-description) | [`requireParamDescription`](https://github.com/jscs-dev/jscs-jsdoc#requireparamdescription) |
57
58
  | [`require-param-name`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-name) | N/A |
58
59
  | [`require-param-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-type) | [`requireParamTypes`](https://github.com/jscs-dev/jscs-jsdoc#requireparamtypes) |
60
+ | [`require-returns`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns) | [`requireReturn`](https://github.com/jscs-dev/jscs-jsdoc#requirereturn) |
59
61
  | [`require-returns-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-description) | [`requireReturnDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirereturndescription) |
60
62
  | [`require-returns-type`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-type) | [`requireReturnTypes`](https://github.com/jscs-dev/jscs-jsdoc#requirereturntypes) |
61
63
  | [`valid-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-valid-types) | N/A |
@@ -114,6 +116,7 @@ Finally, enable all of the rules that you would like to use.
114
116
  "jsdoc/require-param-description": 1,
115
117
  "jsdoc/require-param-name": 1,
116
118
  "jsdoc/require-param-type": 1,
119
+ "jsdoc/require-returns": 1,
117
120
  "jsdoc/require-returns-description": 1,
118
121
  "jsdoc/require-returns-type": 1,
119
122
  "jsdoc/valid-types": 1
@@ -309,7 +312,7 @@ command.
309
312
 
310
313
  The following patterns are considered problems:
311
314
 
312
- ```js
315
+ ````js
313
316
  /**
314
317
  * @example alert('hello')
315
318
  */
@@ -328,7 +331,7 @@ function quux () {
328
331
 
329
332
  }
330
333
  // Settings: {"jsdoc":{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}}
331
- // Message: undefined
334
+ // Message: @example error (semi): Extra semicolon.
332
335
 
333
336
  /**
334
337
  * @example
@@ -338,7 +341,7 @@ function quux () {
338
341
 
339
342
  }
340
343
  // Settings: {"jsdoc":{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}}
341
- // Message: undefined
344
+ // Message: @example error (semi): Extra semicolon.
342
345
 
343
346
  /**
344
347
  * @example ```
@@ -348,7 +351,7 @@ function quux () {
348
351
 
349
352
  }
350
353
  // Settings: {"jsdoc":{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```\njs ([\\s\\S]*)```"}}
351
- // Message: undefined
354
+ // Message: @example error (semi): Extra semicolon.
352
355
 
353
356
  /**
354
357
  * @example <b>Not JavaScript</b>
@@ -363,7 +366,7 @@ function quux2 () {
363
366
 
364
367
  }
365
368
  // Settings: {"jsdoc":{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"rejectExampleCodeRegex":"^\\s*<.*>$"}}
366
- // Message: undefined
369
+ // Message: @example error (semi): Extra semicolon.
367
370
 
368
371
  /**
369
372
  * @example
@@ -373,7 +376,7 @@ function quux () {
373
376
 
374
377
  }
375
378
  // Settings: {"jsdoc":{"baseConfig":{"rules":{"no-undef":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}}
376
- // Message: undefined
379
+ // Message: @example error (semi): Extra semicolon.
377
380
 
378
381
  /**
379
382
  * @example <caption>Valid usage</caption>
@@ -386,7 +389,7 @@ function quux () {
386
389
 
387
390
  }
388
391
  // Settings: {"jsdoc":{"captionRequired":true,"eslintrcForExamples":false}}
389
- // Message: undefined
392
+ // Message: Caption is expected for examples.
390
393
 
391
394
  /**
392
395
  * @example quux();
@@ -395,14 +398,14 @@ function quux () {
395
398
 
396
399
  }
397
400
  // Settings: {"jsdoc":{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}}
398
- // Message: undefined
401
+ // Message: @example error (indent): Expected indentation of 0 spaces but found 1.
399
402
 
400
403
  /**
401
404
  * @example test() // eslint-disable-line semi
402
405
  */
403
406
  function quux () {}
404
407
  // Settings: {"jsdoc":{"eslintrcForExamples":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":true}}
405
- // Message: undefined
408
+ // Message: @example error: Unused eslint-disable directive (no problems were reported from 'semi').
406
409
 
407
410
  /**
408
411
  * @example
@@ -410,12 +413,12 @@ function quux () {}
410
413
  */
411
414
  function quux () {}
412
415
  // Settings: {"jsdoc":{"allowInlineConfig":false,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}}
413
- // Message: undefined
414
- ```
416
+ // Message: @example error (semi): Missing semicolon.
417
+ ````
415
418
 
416
419
  The following patterns are not considered problems:
417
420
 
418
- ```js
421
+ ````js
419
422
  /**
420
423
  * @example ```js
421
424
  alert('hello');
@@ -476,7 +479,7 @@ function quux () {}
476
479
  */
477
480
  function quux () {}
478
481
  // Settings: {"jsdoc":{"allowInlineConfig":true,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}}
479
- ```
482
+ ````
480
483
 
481
484
 
482
485
  <a name="eslint-plugin-jsdoc-rules-check-param-names"></a>
@@ -491,7 +494,7 @@ Ensures that parameter names in JSDoc match those in the function declaration.
491
494
 
492
495
  The following patterns are considered problems:
493
496
 
494
- ```js
497
+ ````js
495
498
  /**
496
499
  * @param Foo
497
500
  */
@@ -552,11 +555,11 @@ function quux (foo) {
552
555
 
553
556
  }
554
557
  // Message: @param "bar" does not match an existing function parameter.
555
- ```
558
+ ````
556
559
 
557
560
  The following patterns are not considered problems:
558
561
 
559
- ```js
562
+ ````js
560
563
  /**
561
564
  *
562
565
  */
@@ -633,7 +636,7 @@ function quux ([a, b] = []) {
633
636
  function assign (employees) {
634
637
 
635
638
  };
636
- ```
639
+ ````
637
640
 
638
641
 
639
642
  <a name="eslint-plugin-jsdoc-rules-check-param-names-deconstructing-function-parameter"></a>
@@ -736,7 +739,7 @@ version
736
739
 
737
740
  The following patterns are considered problems:
738
741
 
739
- ```js
742
+ ````js
740
743
  /**
741
744
  * @Param
742
745
  */
@@ -796,11 +799,11 @@ function quux (foo) {
796
799
  }
797
800
  // Settings: {"jsdoc":{"additionalTagNames":{"customTags":["bar"]}}}
798
801
  // Message: Invalid JSDoc tag name "baz".
799
- ```
802
+ ````
800
803
 
801
804
  The following patterns are not considered problems:
802
805
 
803
- ```js
806
+ ````js
804
807
  /**
805
808
  * @param foo
806
809
  */
@@ -897,7 +900,7 @@ function quux (foo) {
897
900
  * @version
898
901
  */
899
902
  function quux (foo) {}
900
- ```
903
+ ````
901
904
 
902
905
 
903
906
  <a name="eslint-plugin-jsdoc-rules-check-types"></a>
@@ -955,7 +958,7 @@ String | **string** | **string** | `("test") instanceof String` -> **`false`**
955
958
 
956
959
  The following patterns are considered problems:
957
960
 
958
- ```js
961
+ ````js
959
962
  /**
960
963
  * @param {Number} foo
961
964
  */
@@ -987,11 +990,11 @@ function quux (foo, bar, baz) {
987
990
 
988
991
  }
989
992
  // Message: Invalid JSDoc @param "foo" type "Number".
990
- ```
993
+ ````
991
994
 
992
995
  The following patterns are not considered problems:
993
996
 
994
- ```js
997
+ ````js
995
998
  /**
996
999
  * @param {number} foo
997
1000
  * @param {Bar} bar
@@ -1016,7 +1019,7 @@ function quux (foo, bar, baz) {
1016
1019
  function quux (foo, bar, baz) {
1017
1020
 
1018
1021
  }
1019
- ```
1022
+ ````
1020
1023
 
1021
1024
 
1022
1025
  <a name="eslint-plugin-jsdoc-rules-newline-after-description"></a>
@@ -1033,7 +1036,7 @@ This rule takes one argument. If it is `"always"` then a problem is raised when
1033
1036
 
1034
1037
  The following patterns are considered problems:
1035
1038
 
1036
- ```js
1039
+ ````js
1037
1040
  /**
1038
1041
  * Foo.
1039
1042
  *
@@ -1058,11 +1061,11 @@ function quux () {
1058
1061
  }
1059
1062
  // Options: ["never"]
1060
1063
  // Message: There must be no newline after the description of the JSDoc block.
1061
- ```
1064
+ ````
1062
1065
 
1063
1066
  The following patterns are not considered problems:
1064
1067
 
1065
- ```js
1068
+ ````js
1066
1069
  /**
1067
1070
  * Foo.
1068
1071
  */
@@ -1097,7 +1100,7 @@ function quux () {
1097
1100
 
1098
1101
  }
1099
1102
  // Options: ["never"]
1100
- ```
1103
+ ````
1101
1104
 
1102
1105
 
1103
1106
  <a name="eslint-plugin-jsdoc-rules-no-undefined-types"></a>
@@ -1115,7 +1118,7 @@ When enabling this rule, types in jsdoc comments will resolve as used variables,
1115
1118
 
1116
1119
  The following patterns are considered problems:
1117
1120
 
1118
- ```js
1121
+ ````js
1119
1122
  /**
1120
1123
  * @param {strnig} foo - Bar.
1121
1124
  */
@@ -1123,11 +1126,11 @@ function quux(foo) {
1123
1126
 
1124
1127
  }
1125
1128
  // Message: The type 'strnig' is undefined.
1126
- ```
1129
+ ````
1127
1130
 
1128
1131
  The following patterns are not considered problems:
1129
1132
 
1130
- ```js
1133
+ ````js
1131
1134
  /**
1132
1135
  * @param {string} foo - Bar.
1133
1136
  */
@@ -1194,72 +1197,7 @@ function quux(foo) {
1194
1197
  function quux(foo) {
1195
1198
 
1196
1199
  }
1197
- ```
1198
-
1199
-
1200
- <a name="eslint-plugin-jsdoc-rules-require-description"></a>
1201
- ### <code>require-description</code>
1202
-
1203
- Requires that all functions have a description.
1204
-
1205
- * All functions must have a `@description` tag.
1206
- * Every description tag must have a non-empty description that explains the purpose of the method.
1207
-
1208
- |||
1209
- |---|---|
1210
- |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1211
- |Tags|`class`, `example`|
1212
-
1213
- The following patterns are considered problems:
1214
-
1215
- ```js
1216
- /**
1217
- *
1218
- */
1219
- function quux () {
1220
-
1221
- }
1222
- // Message: Missing JSDoc @description declaration.
1223
-
1224
- /**
1225
- * @description
1226
- */
1227
- function quux () {
1228
-
1229
- }
1230
- // Message: Missing JSDoc @description description.
1231
- ```
1232
-
1233
- The following patterns are not considered problems:
1234
-
1235
- ```js
1236
- /**
1237
- * @description
1238
- * // arbitrary description content
1239
- */
1240
- function quux () {
1241
-
1242
- }
1243
-
1244
- /**
1245
- * @description
1246
- * quux(); // does something useful
1247
- */
1248
- function quux () {
1249
-
1250
- }
1251
-
1252
- /**
1253
- * @description <caption>Valid usage</caption>
1254
- * quux(); // does something useful
1255
- *
1256
- * @description <caption>Invalid usage</caption>
1257
- * quux('random unwanted arg'); // results in an error
1258
- */
1259
- function quux () {
1260
-
1261
- }
1262
- ```
1200
+ ````
1263
1201
 
1264
1202
 
1265
1203
  <a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence"></a>
@@ -1279,7 +1217,7 @@ Requires that block description and tag description are written in complete sent
1279
1217
 
1280
1218
  The following patterns are considered problems:
1281
1219
 
1282
- ```js
1220
+ ````js
1283
1221
  /**
1284
1222
  * foo.
1285
1223
  */
@@ -1425,11 +1363,11 @@ function quux (foo) {
1425
1363
 
1426
1364
  }
1427
1365
  // Message: Sentence should start with an uppercase character.
1428
- ```
1366
+ ````
1429
1367
 
1430
1368
  The following patterns are not considered problems:
1431
1369
 
1432
- ```js
1370
+ ````js
1433
1371
  /**
1434
1372
  * @param foo - Foo.
1435
1373
  */
@@ -1524,7 +1462,72 @@ function quux () {
1524
1462
  function quux () {
1525
1463
 
1526
1464
  }
1527
- ```
1465
+ ````
1466
+
1467
+
1468
+ <a name="eslint-plugin-jsdoc-rules-require-description"></a>
1469
+ ### <code>require-description</code>
1470
+
1471
+ Requires that all functions have a description.
1472
+
1473
+ * All functions must have a `@description` tag.
1474
+ * Every description tag must have a non-empty description that explains the purpose of the method.
1475
+
1476
+ |||
1477
+ |---|---|
1478
+ |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1479
+ |Tags|`class`, `example`|
1480
+
1481
+ The following patterns are considered problems:
1482
+
1483
+ ````js
1484
+ /**
1485
+ *
1486
+ */
1487
+ function quux () {
1488
+
1489
+ }
1490
+ // Message: Missing JSDoc @description declaration.
1491
+
1492
+ /**
1493
+ * @description
1494
+ */
1495
+ function quux () {
1496
+
1497
+ }
1498
+ // Message: Missing JSDoc @description description.
1499
+ ````
1500
+
1501
+ The following patterns are not considered problems:
1502
+
1503
+ ````js
1504
+ /**
1505
+ * @description
1506
+ * // arbitrary description content
1507
+ */
1508
+ function quux () {
1509
+
1510
+ }
1511
+
1512
+ /**
1513
+ * @description
1514
+ * quux(); // does something useful
1515
+ */
1516
+ function quux () {
1517
+
1518
+ }
1519
+
1520
+ /**
1521
+ * @description <caption>Valid usage</caption>
1522
+ * quux(); // does something useful
1523
+ *
1524
+ * @description <caption>Invalid usage</caption>
1525
+ * quux('random unwanted arg'); // results in an error
1526
+ */
1527
+ function quux () {
1528
+
1529
+ }
1530
+ ````
1528
1531
 
1529
1532
 
1530
1533
  <a name="eslint-plugin-jsdoc-rules-require-example"></a>
@@ -1542,7 +1545,7 @@ Requires that all functions have examples.
1542
1545
 
1543
1546
  The following patterns are considered problems:
1544
1547
 
1545
- ```js
1548
+ ````js
1546
1549
  /**
1547
1550
  *
1548
1551
  */
@@ -1558,11 +1561,11 @@ function quux () {
1558
1561
 
1559
1562
  }
1560
1563
  // Message: Missing JSDoc @example description.
1561
- ```
1564
+ ````
1562
1565
 
1563
1566
  The following patterns are not considered problems:
1564
1567
 
1565
- ```js
1568
+ ````js
1566
1569
  /**
1567
1570
  * @example
1568
1571
  * // arbitrary example content
@@ -1589,7 +1592,7 @@ function quux () {
1589
1592
  function quux () {
1590
1593
 
1591
1594
  }
1592
- ```
1595
+ ````
1593
1596
 
1594
1597
 
1595
1598
  <a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description"></a>
@@ -1604,7 +1607,7 @@ Requires a hyphen before the `@param` description.
1604
1607
 
1605
1608
  The following patterns are considered problems:
1606
1609
 
1607
- ```js
1610
+ ````js
1608
1611
  /**
1609
1612
  * @param foo Foo.
1610
1613
  */
@@ -1612,24 +1615,24 @@ function quux () {
1612
1615
 
1613
1616
  }
1614
1617
  // Message: There must be a hyphen before @param description.
1615
- ```
1618
+ ````
1616
1619
 
1617
1620
  The following patterns are not considered problems:
1618
1621
 
1619
- ```js
1622
+ ````js
1620
1623
  /**
1621
1624
  * @param foo - Foo.
1622
1625
  */
1623
1626
  function quux () {
1624
1627
 
1625
1628
  }
1626
- ```
1629
+ ````
1627
1630
 
1628
1631
 
1629
- <a name="eslint-plugin-jsdoc-rules-require-param"></a>
1630
- ### <code>require-param</code>
1632
+ <a name="eslint-plugin-jsdoc-rules-require-param-description"></a>
1633
+ ### <code>require-param-description</code>
1631
1634
 
1632
- Requires that all function parameters are documented.
1635
+ Requires that `@param` tag has `description` value.
1633
1636
 
1634
1637
  |||
1635
1638
  |---|---|
@@ -1638,92 +1641,245 @@ Requires that all function parameters are documented.
1638
1641
 
1639
1642
  The following patterns are considered problems:
1640
1643
 
1641
- ```js
1644
+ ````js
1642
1645
  /**
1643
- *
1646
+ * @param foo
1644
1647
  */
1645
1648
  function quux (foo) {
1646
1649
 
1647
1650
  }
1648
- // Message: Missing JSDoc @param "foo" declaration.
1651
+ // Message: Missing JSDoc @param "foo" description.
1649
1652
 
1650
1653
  /**
1651
- *
1654
+ * @arg foo
1652
1655
  */
1653
1656
  function quux (foo) {
1654
1657
 
1655
1658
  }
1656
1659
  // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
1657
- // Message: Missing JSDoc @arg "foo" declaration.
1660
+ // Message: Missing JSDoc @arg "foo" description.
1661
+ ````
1662
+
1663
+ The following patterns are not considered problems:
1658
1664
 
1665
+ ````js
1659
1666
  /**
1660
- * @param foo
1667
+ *
1661
1668
  */
1662
- function quux (foo, bar) {
1669
+ function quux (foo) {
1663
1670
 
1664
1671
  }
1665
- // Message: Missing JSDoc @param "bar" declaration.
1666
1672
 
1667
1673
  /**
1668
- * @override
1674
+ * @param foo Foo.
1669
1675
  */
1670
1676
  function quux (foo) {
1671
1677
 
1672
1678
  }
1673
- // Message: Missing JSDoc @param "foo" declaration.
1679
+ ````
1680
+
1674
1681
 
1682
+ <a name="eslint-plugin-jsdoc-rules-require-param-name"></a>
1683
+ ### <code>require-param-name</code>
1684
+
1685
+ Requires that all function parameters have name.
1686
+
1687
+ > The `@param` tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in curly brackets, and a description of the parameter.
1688
+ >
1689
+ > [JSDoc](http://usejsdoc.org/tags-param.html#overview)
1690
+
1691
+ |||
1692
+ |---|---|
1693
+ |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1694
+ |Tags|`param`|
1695
+
1696
+ The following patterns are considered problems:
1697
+
1698
+ ````js
1675
1699
  /**
1676
- * @implements
1700
+ * @param
1677
1701
  */
1678
1702
  function quux (foo) {
1679
1703
 
1680
1704
  }
1681
- // Message: Missing JSDoc @param "foo" declaration.
1705
+ // Message: There must be an identifier after @param type.
1682
1706
 
1683
1707
  /**
1684
- * @augments
1708
+ * @param {string}
1685
1709
  */
1686
1710
  function quux (foo) {
1687
1711
 
1688
1712
  }
1689
- // Message: Missing JSDoc @param "foo" declaration.
1713
+ // Message: There must be an identifier after @param tag.
1714
+ ````
1690
1715
 
1716
+ The following patterns are not considered problems:
1717
+
1718
+ ````js
1691
1719
  /**
1692
- * @extends
1720
+ * @param foo
1693
1721
  */
1694
1722
  function quux (foo) {
1695
1723
 
1696
1724
  }
1697
- // Message: Missing JSDoc @param "foo" declaration.
1698
1725
 
1699
1726
  /**
1700
- * @override
1727
+ * @param {string} foo
1701
1728
  */
1702
- class A {
1703
- /**
1704
- *
1705
- */
1706
- quux (foo) {
1729
+ function quux (foo) {
1707
1730
 
1708
- }
1709
1731
  }
1710
- // Message: Missing JSDoc @param "foo" declaration.
1732
+ ````
1733
+
1734
+
1735
+ <a name="eslint-plugin-jsdoc-rules-require-param-type"></a>
1736
+ ### <code>require-param-type</code>
1737
+
1738
+ Requires that `@param` tag has `type` value.
1739
+
1740
+ |||
1741
+ |---|---|
1742
+ |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1743
+ |Tags|`param`|
1744
+
1745
+ The following patterns are considered problems:
1711
1746
 
1747
+ ````js
1712
1748
  /**
1713
- * @implements
1749
+ * @param foo
1714
1750
  */
1715
- class A {
1716
- /**
1717
- *
1718
- */
1719
- quux (foo) {
1751
+ function quux (foo) {
1720
1752
 
1721
- }
1722
1753
  }
1723
- // Message: Missing JSDoc @param "foo" declaration.
1754
+ // Message: Missing JSDoc @param "foo" type.
1724
1755
 
1725
1756
  /**
1726
- * @augments
1757
+ * @arg foo
1758
+ */
1759
+ function quux (foo) {
1760
+
1761
+ }
1762
+ // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
1763
+ // Message: Missing JSDoc @arg "foo" type.
1764
+ ````
1765
+
1766
+ The following patterns are not considered problems:
1767
+
1768
+ ````js
1769
+ /**
1770
+ *
1771
+ */
1772
+ function quux (foo) {
1773
+
1774
+ }
1775
+
1776
+ /**
1777
+ * @param {number} foo
1778
+ */
1779
+ function quux (foo) {
1780
+
1781
+ }
1782
+ ````
1783
+
1784
+
1785
+ <a name="eslint-plugin-jsdoc-rules-require-param"></a>
1786
+ ### <code>require-param</code>
1787
+
1788
+ Requires that all function parameters are documented.
1789
+
1790
+ |||
1791
+ |---|---|
1792
+ |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1793
+ |Tags|`param`|
1794
+
1795
+ The following patterns are considered problems:
1796
+
1797
+ ````js
1798
+ /**
1799
+ *
1800
+ */
1801
+ function quux (foo) {
1802
+
1803
+ }
1804
+ // Message: Missing JSDoc @param "foo" declaration.
1805
+
1806
+ /**
1807
+ *
1808
+ */
1809
+ function quux (foo) {
1810
+
1811
+ }
1812
+ // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
1813
+ // Message: Missing JSDoc @arg "foo" declaration.
1814
+
1815
+ /**
1816
+ * @param foo
1817
+ */
1818
+ function quux (foo, bar) {
1819
+
1820
+ }
1821
+ // Message: Missing JSDoc @param "bar" declaration.
1822
+
1823
+ /**
1824
+ * @override
1825
+ */
1826
+ function quux (foo) {
1827
+
1828
+ }
1829
+ // Message: Missing JSDoc @param "foo" declaration.
1830
+
1831
+ /**
1832
+ * @implements
1833
+ */
1834
+ function quux (foo) {
1835
+
1836
+ }
1837
+ // Message: Missing JSDoc @param "foo" declaration.
1838
+
1839
+ /**
1840
+ * @augments
1841
+ */
1842
+ function quux (foo) {
1843
+
1844
+ }
1845
+ // Message: Missing JSDoc @param "foo" declaration.
1846
+
1847
+ /**
1848
+ * @extends
1849
+ */
1850
+ function quux (foo) {
1851
+
1852
+ }
1853
+ // Message: Missing JSDoc @param "foo" declaration.
1854
+
1855
+ /**
1856
+ * @override
1857
+ */
1858
+ class A {
1859
+ /**
1860
+ *
1861
+ */
1862
+ quux (foo) {
1863
+
1864
+ }
1865
+ }
1866
+ // Message: Missing JSDoc @param "foo" declaration.
1867
+
1868
+ /**
1869
+ * @implements
1870
+ */
1871
+ class A {
1872
+ /**
1873
+ *
1874
+ */
1875
+ quux (foo) {
1876
+
1877
+ }
1878
+ }
1879
+ // Message: Missing JSDoc @param "foo" declaration.
1880
+
1881
+ /**
1882
+ * @augments
1727
1883
  */
1728
1884
  class A {
1729
1885
  /**
@@ -1747,11 +1903,11 @@ class A {
1747
1903
  }
1748
1904
  }
1749
1905
  // Message: Missing JSDoc @param "foo" declaration.
1750
- ```
1906
+ ````
1751
1907
 
1752
1908
  The following patterns are not considered problems:
1753
1909
 
1754
- ```js
1910
+ ````js
1755
1911
  /**
1756
1912
  * @param foo
1757
1913
  */
@@ -1937,261 +2093,422 @@ class A {
1937
2093
 
1938
2094
  }
1939
2095
  }
1940
- ```
2096
+ ````
1941
2097
 
1942
2098
 
1943
- <a name="eslint-plugin-jsdoc-rules-require-param-description"></a>
1944
- ### <code>require-param-description</code>
2099
+ <a name="eslint-plugin-jsdoc-rules-require-returns-description"></a>
2100
+ ### <code>require-returns-description</code>
1945
2101
 
1946
- Requires that `@param` tag has `description` value.
2102
+ Requires that `@returns` tag has `description` value.
1947
2103
 
1948
2104
  |||
1949
2105
  |---|---|
1950
2106
  |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1951
- |Tags|`param`|
2107
+ |Tags|`returns`|
1952
2108
 
1953
2109
  The following patterns are considered problems:
1954
2110
 
1955
- ```js
2111
+ ````js
1956
2112
  /**
1957
- * @param foo
2113
+ * @returns
1958
2114
  */
1959
2115
  function quux (foo) {
1960
2116
 
1961
2117
  }
1962
- // Message: Missing JSDoc @param "foo" description.
2118
+ // Message: Missing JSDoc @returns description.
1963
2119
 
1964
2120
  /**
1965
- * @arg foo
2121
+ * @return
1966
2122
  */
1967
2123
  function quux (foo) {
1968
2124
 
1969
2125
  }
1970
- // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
1971
- // Message: Missing JSDoc @arg "foo" description.
1972
- ```
2126
+ // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
2127
+ // Message: Missing JSDoc @return description.
2128
+ ````
1973
2129
 
1974
2130
  The following patterns are not considered problems:
1975
2131
 
1976
- ```js
2132
+ ````js
1977
2133
  /**
1978
2134
  *
1979
2135
  */
1980
- function quux (foo) {
2136
+ function quux () {
1981
2137
 
1982
2138
  }
1983
2139
 
1984
2140
  /**
1985
- * @param foo Foo.
2141
+ * @returns Foo.
1986
2142
  */
1987
- function quux (foo) {
2143
+ function quux () {
1988
2144
 
1989
2145
  }
1990
- ```
1991
-
2146
+ ````
1992
2147
 
1993
- <a name="eslint-plugin-jsdoc-rules-require-param-name"></a>
1994
- ### <code>require-param-name</code>
1995
2148
 
1996
- Requires that all function parameters have name.
2149
+ <a name="eslint-plugin-jsdoc-rules-require-returns-type"></a>
2150
+ ### <code>require-returns-type</code>
1997
2151
 
1998
- > The `@param` tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in curly brackets, and a description of the parameter.
1999
- >
2000
- > [JSDoc](http://usejsdoc.org/tags-param.html#overview)
2152
+ Requires that `@returns` tag has `type` value.
2001
2153
 
2002
2154
  |||
2003
2155
  |---|---|
2004
2156
  |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
2005
- |Tags|`param`|
2157
+ |Tags|`returns`|
2006
2158
 
2007
2159
  The following patterns are considered problems:
2008
2160
 
2009
- ```js
2161
+ ````js
2010
2162
  /**
2011
- * @param
2163
+ * @returns
2012
2164
  */
2013
- function quux (foo) {
2165
+ function quux () {
2014
2166
 
2015
2167
  }
2016
- // Message: There must be an identifier after @param type.
2168
+ // Message: Missing JSDoc @returns type.
2017
2169
 
2018
2170
  /**
2019
- * @param {string}
2171
+ * @returns Foo.
2020
2172
  */
2021
- function quux (foo) {
2173
+ function quux () {
2022
2174
 
2023
2175
  }
2024
- // Message: There must be an identifier after @param tag.
2025
- ```
2026
-
2027
- The following patterns are not considered problems:
2176
+ // Message: Missing JSDoc @returns type.
2028
2177
 
2029
- ```js
2030
2178
  /**
2031
- * @param foo
2179
+ * @return Foo.
2032
2180
  */
2033
- function quux (foo) {
2181
+ function quux () {
2034
2182
 
2035
2183
  }
2184
+ // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
2185
+ // Message: Missing JSDoc @return type.
2186
+ ````
2036
2187
 
2188
+ The following patterns are not considered problems:
2189
+
2190
+ ````js
2037
2191
  /**
2038
- * @param {string} foo
2192
+ * @returns {number}
2039
2193
  */
2040
- function quux (foo) {
2194
+ function quux () {
2041
2195
 
2042
2196
  }
2043
- ```
2197
+ ````
2044
2198
 
2045
2199
 
2046
- <a name="eslint-plugin-jsdoc-rules-require-param-type"></a>
2047
- ### <code>require-param-type</code>
2200
+ <a name="eslint-plugin-jsdoc-rules-require-returns"></a>
2201
+ ### <code>require-returns</code>
2048
2202
 
2049
- Requires that `@param` tag has `type` value.
2203
+ Requires returns are documented.
2050
2204
 
2051
2205
  |||
2052
2206
  |---|---|
2053
2207
  |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
2054
- |Tags|`param`|
2208
+ |Tags|`returns`|
2055
2209
 
2056
2210
  The following patterns are considered problems:
2057
2211
 
2058
- ```js
2212
+ ````js
2059
2213
  /**
2060
- * @param foo
2214
+ *
2061
2215
  */
2062
2216
  function quux (foo) {
2063
2217
 
2064
2218
  }
2065
- // Message: Missing JSDoc @param "foo" type.
2219
+ // Message: Missing JSDoc @param "foo" declaration.
2066
2220
 
2067
2221
  /**
2068
- * @arg foo
2222
+ *
2069
2223
  */
2070
2224
  function quux (foo) {
2071
2225
 
2072
2226
  }
2073
2227
  // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
2074
- // Message: Missing JSDoc @arg "foo" type.
2075
- ```
2228
+ // Message: Missing JSDoc @arg "foo" declaration.
2229
+
2230
+ /**
2231
+ * @param foo
2232
+ */
2233
+ function quux (foo, bar) {
2234
+
2235
+ }
2236
+ // Message: Missing JSDoc @param "bar" declaration.
2237
+
2238
+ /**
2239
+ * @override
2240
+ */
2241
+ function quux (foo) {
2242
+
2243
+ }
2244
+ // Message: Missing JSDoc @param "foo" declaration.
2245
+
2246
+ /**
2247
+ * @implements
2248
+ */
2249
+ function quux (foo) {
2250
+
2251
+ }
2252
+ // Message: Missing JSDoc @param "foo" declaration.
2253
+
2254
+ /**
2255
+ * @augments
2256
+ */
2257
+ function quux (foo) {
2258
+
2259
+ }
2260
+ // Message: Missing JSDoc @param "foo" declaration.
2261
+
2262
+ /**
2263
+ * @extends
2264
+ */
2265
+ function quux (foo) {
2266
+
2267
+ }
2268
+ // Message: Missing JSDoc @param "foo" declaration.
2269
+
2270
+ /**
2271
+ * @override
2272
+ */
2273
+ class A {
2274
+ /**
2275
+ *
2276
+ */
2277
+ quux (foo) {
2278
+
2279
+ }
2280
+ }
2281
+ // Message: Missing JSDoc @param "foo" declaration.
2282
+
2283
+ /**
2284
+ * @implements
2285
+ */
2286
+ class A {
2287
+ /**
2288
+ *
2289
+ */
2290
+ quux (foo) {
2291
+
2292
+ }
2293
+ }
2294
+ // Message: Missing JSDoc @param "foo" declaration.
2295
+
2296
+ /**
2297
+ * @augments
2298
+ */
2299
+ class A {
2300
+ /**
2301
+ *
2302
+ */
2303
+ quux (foo) {
2304
+
2305
+ }
2306
+ }
2307
+ // Message: Missing JSDoc @param "foo" declaration.
2308
+
2309
+ /**
2310
+ * @extends
2311
+ */
2312
+ class A {
2313
+ /**
2314
+ *
2315
+ */
2316
+ quux (foo) {
2317
+
2318
+ }
2319
+ }
2320
+ // Message: Missing JSDoc @param "foo" declaration.
2321
+ ````
2076
2322
 
2077
2323
  The following patterns are not considered problems:
2078
2324
 
2079
- ```js
2325
+ ````js
2080
2326
  /**
2081
- *
2327
+ * @param foo
2082
2328
  */
2083
2329
  function quux (foo) {
2084
2330
 
2085
2331
  }
2086
2332
 
2087
2333
  /**
2088
- * @param {number} foo
2334
+ * @inheritdoc
2089
2335
  */
2090
2336
  function quux (foo) {
2091
2337
 
2092
2338
  }
2093
- ```
2094
2339
 
2340
+ /**
2341
+ * @arg foo
2342
+ */
2343
+ function quux (foo) {
2095
2344
 
2096
- <a name="eslint-plugin-jsdoc-rules-require-returns-description"></a>
2097
- ### <code>require-returns-description</code>
2345
+ }
2346
+ // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
2098
2347
 
2099
- Requires that `@returns` tag has `description` value.
2348
+ /**
2349
+ * @override
2350
+ * @param foo
2351
+ */
2352
+ function quux (foo) {
2100
2353
 
2101
- |||
2102
- |---|---|
2103
- |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
2104
- |Tags|`returns`|
2354
+ }
2105
2355
 
2106
- The following patterns are considered problems:
2356
+ /**
2357
+ * @override
2358
+ */
2359
+ function quux (foo) {
2360
+
2361
+ }
2362
+ // Settings: {"jsdoc":{"allowOverrideWithoutParam":true}}
2107
2363
 
2108
- ```js
2109
2364
  /**
2110
- * @returns
2365
+ * @implements
2111
2366
  */
2112
2367
  function quux (foo) {
2113
2368
 
2114
2369
  }
2115
- // Message: Missing JSDoc @returns description.
2370
+ // Settings: {"jsdoc":{"allowImplementsWithoutParam":true}}
2116
2371
 
2117
2372
  /**
2118
- * @return
2373
+ * @implements
2374
+ * @param foo
2119
2375
  */
2120
2376
  function quux (foo) {
2121
2377
 
2122
2378
  }
2123
- // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
2124
- // Message: Missing JSDoc @return description.
2125
- ```
2126
2379
 
2127
- The following patterns are not considered problems:
2380
+ /**
2381
+ * @augments
2382
+ */
2383
+ function quux (foo) {
2384
+
2385
+ }
2386
+ // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2128
2387
 
2129
- ```js
2130
2388
  /**
2131
- *
2389
+ * @augments
2390
+ * @param foo
2132
2391
  */
2133
- function quux () {
2392
+ function quux (foo) {
2134
2393
 
2135
2394
  }
2136
2395
 
2137
2396
  /**
2138
- * @returns Foo.
2397
+ * @extends
2139
2398
  */
2140
- function quux () {
2399
+ function quux (foo) {
2141
2400
 
2142
2401
  }
2143
- ```
2402
+ // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2144
2403
 
2404
+ /**
2405
+ * @extends
2406
+ * @param foo
2407
+ */
2408
+ function quux (foo) {
2145
2409
 
2146
- <a name="eslint-plugin-jsdoc-rules-require-returns-type"></a>
2147
- ### <code>require-returns-type</code>
2410
+ }
2148
2411
 
2149
- Requires that `@returns` tag has `type` value.
2412
+ /**
2413
+ * @override
2414
+ */
2415
+ class A {
2416
+ /**
2417
+ * @param foo
2418
+ */
2419
+ quux (foo) {
2150
2420
 
2151
- |||
2152
- |---|---|
2153
- |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
2154
- |Tags|`returns`|
2421
+ }
2422
+ }
2155
2423
 
2156
- The following patterns are considered problems:
2424
+ /**
2425
+ * @override
2426
+ */
2427
+ class A {
2428
+ /**
2429
+ *
2430
+ */
2431
+ quux (foo) {
2432
+
2433
+ }
2434
+ }
2435
+ // Settings: {"jsdoc":{"allowOverrideWithoutParam":true}}
2157
2436
 
2158
- ```js
2159
2437
  /**
2160
- * @returns
2438
+ * @implements
2161
2439
  */
2162
- function quux () {
2440
+ class A {
2441
+ /**
2442
+ *
2443
+ */
2444
+ quux (foo) {
2163
2445
 
2446
+ }
2164
2447
  }
2165
- // Message: Missing JSDoc @returns type.
2448
+ // Settings: {"jsdoc":{"allowImplementsWithoutParam":true}}
2166
2449
 
2167
2450
  /**
2168
- * @returns Foo.
2451
+ * @implements
2169
2452
  */
2170
- function quux () {
2453
+ class A {
2454
+ /**
2455
+ * @param foo
2456
+ */
2457
+ quux (foo) {
2171
2458
 
2459
+ }
2172
2460
  }
2173
- // Message: Missing JSDoc @returns type.
2174
2461
 
2175
2462
  /**
2176
- * @return Foo.
2463
+ * @augments
2177
2464
  */
2178
- function quux () {
2465
+ class A {
2466
+ /**
2467
+ *
2468
+ */
2469
+ quux (foo) {
2179
2470
 
2471
+ }
2180
2472
  }
2181
- // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
2182
- // Message: Missing JSDoc @return type.
2183
- ```
2473
+ // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2184
2474
 
2185
- The following patterns are not considered problems:
2475
+ /**
2476
+ * @augments
2477
+ */
2478
+ class A {
2479
+ /**
2480
+ * @param foo
2481
+ */
2482
+ quux (foo) {
2483
+
2484
+ }
2485
+ }
2186
2486
 
2187
- ```js
2188
2487
  /**
2189
- * @returns {number}
2488
+ * @extends
2190
2489
  */
2191
- function quux () {
2490
+ class A {
2491
+ /**
2492
+ *
2493
+ */
2494
+ quux (foo) {
2192
2495
 
2496
+ }
2193
2497
  }
2194
- ```
2498
+ // Settings: {"jsdoc":{"allowAugmentsExtendsWithoutParam":true}}
2499
+
2500
+ /**
2501
+ * @extends
2502
+ */
2503
+ class A {
2504
+ /**
2505
+ * @param foo
2506
+ */
2507
+ quux (foo) {
2508
+
2509
+ }
2510
+ }
2511
+ ````
2195
2512
 
2196
2513
 
2197
2514
  <a name="eslint-plugin-jsdoc-rules-valid-types"></a>
@@ -2206,7 +2523,7 @@ Requires all types to be valid JSDoc or Closure compiler types without syntax er
2206
2523
 
2207
2524
  The following patterns are considered problems:
2208
2525
 
2209
- ```js
2526
+ ````js
2210
2527
  /**
2211
2528
  * @param {Array<string} foo
2212
2529
  */
@@ -2214,11 +2531,11 @@ function quux() {
2214
2531
 
2215
2532
  }
2216
2533
  // Message: Syntax error in type: Array<string
2217
- ```
2534
+ ````
2218
2535
 
2219
2536
  The following patterns are not considered problems:
2220
2537
 
2221
- ```js
2538
+ ````js
2222
2539
  /**
2223
2540
  * @param {Array<string>} foo
2224
2541
  */
@@ -2239,6 +2556,6 @@ function quux() {
2239
2556
  function quux() {
2240
2557
 
2241
2558
  }
2242
- ```
2559
+ ````
2243
2560
 
2244
2561
 
@@ -80,7 +80,7 @@ var updateDocuments = function updateDocuments(assertions) {
80
80
  throw new Error('No assertions available for rule "' + ruleName + '".');
81
81
  }
82
82
 
83
- return 'The following patterns are considered problems:\n\n```js\n' + ruleAssertions.invalid.join('\n\n') + '\n```\n\nThe following patterns are not considered problems:\n\n```js\n' + ruleAssertions.valid.join('\n\n') + '\n```\n';
83
+ return 'The following patterns are considered problems:\n\n````js\n' + ruleAssertions.invalid.join('\n\n') + '\n````\n\nThe following patterns are not considered problems:\n\n````js\n' + ruleAssertions.valid.join('\n\n') + '\n````\n';
84
84
  });
85
85
 
86
86
  _fs.default.writeFileSync(readmeDocumentPath, documentBody);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bin/readme-assertions.js"],"names":["trimCode","code","lines","_","trim","split","indendation","length","match","indentSize","map","line","index","slice","join","formatCodeSnippet","setup","paragraphs","push","settings","JSON","stringify","options","errors","message","getAssertions","assertionFiles","glob","sync","path","resolve","__dirname","assertionNames","filePath","basename","assertionCodes","codes","require","invalid","valid","zipObject","updateDocuments","assertions","readmeDocumentPath","documentBody","fs","readFileSync","replace","assertionsBlock","ruleName","ruleAssertions","Error","writeFileSync"],"mappings":";;AAGA;;AACA;;AACA;;A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,CAAjB;AACA,QAAM0C,cAAc,GAAGR,UAAU,CAACO,QAAD,CAAjC;;AAEA,QAAI,CAACC,cAAL,EAAqB;AACnB,YAAM,IAAIC,KAAJ,CAAU,uCAAuCF,QAAvC,GAAkD,IAA5D,CAAN;AACD;;AAED,WAAO,+DAA+DC,cAAc,CAACZ,OAAf,CAAuBxB,IAAvB,CAA4B,MAA5B,CAA/D,GACL,yEADK,GACuEoC,cAAc,CAACX,KAAf,CAAqBzB,IAArB,CAA0B,MAA1B,CADvE,GAC2G,SADlH;AAED,GAVc,CAAf;;AAYA+B,cAAGO,aAAH,CAAiBT,kBAAjB,EAAqCC,YAArC;AACD,CAlBD;;AAoBAH,eAAe,CAAChB,aAAa,EAAd,CAAf","sourcesContent":["/**\n * This script is used to inline assertions into the README.md documents.\n */\nimport path from 'path';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport glob from 'glob';\n\nconst trimCode = (code) => {\n let lines = _.trim(code).split('\\n');\n\n const indendation = lines[lines.length - 1].match(/^\\s+/);\n\n const indentSize = indendation ? indendation[0].length : 0;\n\n lines = _.map(lines, (line, index) => {\n if (index === 0) {\n return line;\n }\n\n return line.slice(indentSize);\n });\n\n return lines.join('\\n');\n};\n\nconst formatCodeSnippet = (setup) => {\n const paragraphs = [];\n\n paragraphs.push(trimCode(setup.code));\n\n if (setup.settings) {\n paragraphs.push('// Settings: ' + JSON.stringify(setup.settings));\n }\n\n if (setup.options) {\n paragraphs.push('// Options: ' + JSON.stringify(setup.options));\n }\n\n if (setup.errors) {\n paragraphs.push('// Message: ' + setup.errors[0].message);\n }\n\n return paragraphs.join('\\n');\n};\n\nconst getAssertions = () => {\n const assertionFiles = glob.sync(path.resolve(__dirname, '../../test/rules/assertions/*.js'));\n\n const assertionNames = _.map(assertionFiles, (filePath) => {\n return path.basename(filePath, '.js');\n });\n\n const assertionCodes = _.map(assertionFiles, (filePath) => {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const codes = require(filePath);\n\n return {\n invalid: _.map(codes.invalid, formatCodeSnippet),\n valid: _.map(codes.valid, formatCodeSnippet)\n };\n });\n\n return _.zipObject(assertionNames, assertionCodes);\n};\n\nconst updateDocuments = (assertions) => {\n const readmeDocumentPath = path.join(__dirname, '../../README.md');\n\n let documentBody = fs.readFileSync(readmeDocumentPath, 'utf8');\n\n documentBody = documentBody.replace(/<!-- assertions ([a-z]+?) -->/ig, (assertionsBlock) => {\n const ruleName = assertionsBlock.match(/assertions ([a-z]+)/i)[1];\n const ruleAssertions = assertions[ruleName];\n\n if (!ruleAssertions) {\n throw new Error('No assertions available for rule \"' + ruleName + '\".');\n }\n\n return 'The following patterns are considered problems:\\n\\n```js\\n' + ruleAssertions.invalid.join('\\n\\n') +\n '\\n```\\n\\nThe following patterns are not considered problems:\\n\\n```js\\n' + ruleAssertions.valid.join('\\n\\n') + '\\n```\\n';\n });\n\n fs.writeFileSync(readmeDocumentPath, documentBody);\n};\n\nupdateDocuments(getAssertions());\n"],"file":"readme-assertions.js"}
1
+ {"version":3,"sources":["../../src/bin/readme-assertions.js"],"names":["trimCode","code","lines","_","trim","split","indendation","length","match","indentSize","map","line","index","slice","join","formatCodeSnippet","setup","paragraphs","push","settings","JSON","stringify","options","errors","message","getAssertions","assertionFiles","glob","sync","path","resolve","__dirname","assertionNames","filePath","basename","assertionCodes","codes","require","invalid","valid","zipObject","updateDocuments","assertions","readmeDocumentPath","documentBody","fs","readFileSync","replace","assertionsBlock","ruleName","ruleAssertions","Error","writeFileSync"],"mappings":";;AAGA;;AACA;;AACA;;AACA;;;;AANA;;;AAQA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,IAAD,EAAU;AACzB,MAAIC,KAAK,GAAGC,gBAAEC,IAAF,CAAOH,IAAP,EAAaI,KAAb,CAAmB,IAAnB,CAAZ;;AAEA,MAAMC,WAAW,GAAGJ,KAAK,CAACA,KAAK,CAACK,MAAN,GAAe,CAAhB,CAAL,CAAwBC,KAAxB,CAA8B,MAA9B,CAApB;AAEA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Af,CAAqBzB,IAArB,CAA0B,MAA1B,CADzE,GAC6G,UADpH;AAED,GAVc,CAAf;;AAYA+B,cAAGO,aAAH,CAAiBT,kBAAjB,EAAqCC,YAArC;AACD,CAlBD;;AAoBAH,eAAe,CAAChB,aAAa,EAAd,CAAf","sourcesContent":["/**\n * This script is used to inline assertions into the README.md documents.\n */\nimport path from 'path';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport glob from 'glob';\n\nconst trimCode = (code) => {\n let lines = _.trim(code).split('\\n');\n\n const indendation = lines[lines.length - 1].match(/^\\s+/);\n\n const indentSize = indendation ? indendation[0].length : 0;\n\n lines = _.map(lines, (line, index) => {\n if (index === 0) {\n return line;\n }\n\n return line.slice(indentSize);\n });\n\n return lines.join('\\n');\n};\n\nconst formatCodeSnippet = (setup) => {\n const paragraphs = [];\n\n paragraphs.push(trimCode(setup.code));\n\n if (setup.settings) {\n paragraphs.push('// Settings: ' + JSON.stringify(setup.settings));\n }\n\n if (setup.options) {\n paragraphs.push('// Options: ' + JSON.stringify(setup.options));\n }\n\n if (setup.errors) {\n paragraphs.push('// Message: ' + setup.errors[0].message);\n }\n\n return paragraphs.join('\\n');\n};\n\nconst getAssertions = () => {\n const assertionFiles = glob.sync(path.resolve(__dirname, '../../test/rules/assertions/*.js'));\n\n const assertionNames = _.map(assertionFiles, (filePath) => {\n return path.basename(filePath, '.js');\n });\n\n const assertionCodes = _.map(assertionFiles, (filePath) => {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const codes = require(filePath);\n\n return {\n invalid: _.map(codes.invalid, formatCodeSnippet),\n valid: _.map(codes.valid, formatCodeSnippet)\n };\n });\n\n return _.zipObject(assertionNames, assertionCodes);\n};\n\nconst updateDocuments = (assertions) => {\n const readmeDocumentPath = path.join(__dirname, '../../README.md');\n\n let documentBody = fs.readFileSync(readmeDocumentPath, 'utf8');\n\n documentBody = documentBody.replace(/<!-- assertions ([a-z]+?) -->/ig, (assertionsBlock) => {\n const ruleName = assertionsBlock.match(/assertions ([a-z]+)/i)[1];\n const ruleAssertions = assertions[ruleName];\n\n if (!ruleAssertions) {\n throw new Error('No assertions available for rule \"' + ruleName + '\".');\n }\n\n return 'The following patterns are considered problems:\\n\\n````js\\n' + ruleAssertions.invalid.join('\\n\\n') +\n '\\n````\\n\\nThe following patterns are not considered problems:\\n\\n````js\\n' + ruleAssertions.valid.join('\\n\\n') + '\\n````\\n';\n });\n\n fs.writeFileSync(readmeDocumentPath, documentBody);\n};\n\nupdateDocuments(getAssertions());\n"],"file":"readme-assertions.js"}
package/package.json CHANGED
@@ -60,5 +60,5 @@
60
60
  "lint": "eslint ./src ./test",
61
61
  "test": "mocha --recursive --require @babel/register"
62
62
  },
63
- "version": "3.15.0"
63
+ "version": "3.15.1"
64
64
  }