eslint-plugin-jsdoc 39.7.5 → 39.9.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.
- package/README.md +226 -49
- package/dist/alignTransform.js +3 -0
- package/dist/alignTransform.js.map +1 -1
- package/dist/iterateJsdoc.js +7 -3
- package/dist/iterateJsdoc.js.map +1 -1
- package/dist/jsdocUtils.js +6 -6
- package/dist/jsdocUtils.js.map +1 -1
- package/dist/rules/checkLineAlignment.js +12 -1
- package/dist/rules/checkLineAlignment.js.map +1 -1
- package/dist/rules/noMissingSyntax.js +5 -4
- package/dist/rules/noMissingSyntax.js.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +3 -2
- package/dist/rules/noRestrictedSyntax.js.map +1 -1
- package/dist/rules/requireJsdoc.js +4 -4
- package/dist/rules/requireJsdoc.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ JSDoc linting rules for ESLint.
|
|
|
21
21
|
* [`@override`/`@augments`/`@extends`/`@implements`/`@ignore` Without Accompanying `@param`/`@description`/`@example`/`@returns`/`@throws`/`@yields`](#user-content-eslint-plugin-jsdoc-settings-override-augments-extends-implements-ignore-without-accompanying-param-description-example-returns-throws-yields)
|
|
22
22
|
* [Settings to Configure `check-types` and `no-undefined-types`](#user-content-eslint-plugin-jsdoc-settings-settings-to-configure-check-types-and-no-undefined-types)
|
|
23
23
|
* [`structuredTags`](#user-content-eslint-plugin-jsdoc-settings-structuredtags)
|
|
24
|
+
* [`contexts`](#user-content-eslint-plugin-jsdoc-settings-contexts)
|
|
24
25
|
* [Advanced](#user-content-eslint-plugin-jsdoc-advanced)
|
|
25
26
|
* [AST and Selectors](#user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors)
|
|
26
27
|
* [Rules](#user-content-eslint-plugin-jsdoc-rules)
|
|
@@ -553,6 +554,14 @@ values are objects with the following optional properties:
|
|
|
553
554
|
name (`@throws Some text`); does not require that both exist but
|
|
554
555
|
disallows just an empty tag.
|
|
555
556
|
|
|
557
|
+
<a name="user-content-eslint-plugin-jsdoc-settings-contexts"></a>
|
|
558
|
+
<a name="eslint-plugin-jsdoc-settings-contexts"></a>
|
|
559
|
+
### <code>contexts</code>
|
|
560
|
+
|
|
561
|
+
`settings.jsdoc.contexts` can be used as the default for any rules
|
|
562
|
+
with a `contexts` property option. See the "AST and Selectors" section
|
|
563
|
+
for more on this format.
|
|
564
|
+
|
|
556
565
|
<a name="user-content-eslint-plugin-jsdoc-advanced"></a>
|
|
557
566
|
<a name="eslint-plugin-jsdoc-advanced"></a>
|
|
558
567
|
## Advanced
|
|
@@ -2047,6 +2056,7 @@ An object with any of the following keys set to an integer. Affects spacing:
|
|
|
2047
2056
|
- `postTag` - after the tag (e.g., `* @param `)
|
|
2048
2057
|
- `postType` - after the type (e.g., `* @param {someType} `)
|
|
2049
2058
|
- `postName` - after the name (e.g., `* @param {someType} name `)
|
|
2059
|
+
- `postHyphens` - after any hyphens in the description (e.g., `* @param {someType} name - A description`)
|
|
2050
2060
|
|
|
2051
2061
|
If a spacing is not defined, it defaults to one.
|
|
2052
2062
|
|
|
@@ -2438,6 +2448,66 @@ const fn = ( lorem, sit ) => {}
|
|
|
2438
2448
|
const fn = ( lorem, sit ) => {}
|
|
2439
2449
|
// "jsdoc/check-line-alignment": ["error"|"warn", "always"]
|
|
2440
2450
|
// Message: Expected JSDoc block lines to be aligned.
|
|
2451
|
+
|
|
2452
|
+
/**
|
|
2453
|
+
* Function description.
|
|
2454
|
+
*
|
|
2455
|
+
* @param {string} lorem - Description.
|
|
2456
|
+
* @param {int} sit - Description multi words.
|
|
2457
|
+
*/
|
|
2458
|
+
const fn = ( lorem, sit ) => {}
|
|
2459
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never"]
|
|
2460
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* Function description.
|
|
2464
|
+
*
|
|
2465
|
+
* @param {string} lorem - Description.
|
|
2466
|
+
* @param {int} sit - Description multi words.
|
|
2467
|
+
*/
|
|
2468
|
+
const fn = ( lorem, sit ) => {}
|
|
2469
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postHyphen":2}}]
|
|
2470
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2471
|
+
|
|
2472
|
+
/**
|
|
2473
|
+
* Function description.
|
|
2474
|
+
*
|
|
2475
|
+
* @param {string} lorem - Description.
|
|
2476
|
+
* @param {int} sit - Description multi words.
|
|
2477
|
+
*/
|
|
2478
|
+
const fn = ( lorem, sit ) => {}
|
|
2479
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postHyphen":2}}]
|
|
2480
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2481
|
+
|
|
2482
|
+
/**
|
|
2483
|
+
* Function description.
|
|
2484
|
+
*
|
|
2485
|
+
* @param {string} lorem - Description.
|
|
2486
|
+
* @param {int} sit - Description multi words.
|
|
2487
|
+
*/
|
|
2488
|
+
const fn = ( lorem, sit ) => {}
|
|
2489
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "always",{"customSpacings":{"postHyphen":2}}]
|
|
2490
|
+
// Message: Expected JSDoc block lines to be aligned.
|
|
2491
|
+
|
|
2492
|
+
/**
|
|
2493
|
+
* Function description.
|
|
2494
|
+
*
|
|
2495
|
+
* @param {string} lorem - Description.
|
|
2496
|
+
* @param {int} sit - Description multi words.
|
|
2497
|
+
*/
|
|
2498
|
+
const fn = ( lorem, sit ) => {}
|
|
2499
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "always",{"customSpacings":{"postHyphen":2}}]
|
|
2500
|
+
// Message: Expected JSDoc block lines to be aligned.
|
|
2501
|
+
|
|
2502
|
+
/**
|
|
2503
|
+
* Function description.
|
|
2504
|
+
*
|
|
2505
|
+
* @param {string} lorem - Description.
|
|
2506
|
+
* @param {int} sit - Description multi words.
|
|
2507
|
+
*/
|
|
2508
|
+
const fn = ( lorem, sit ) => {}
|
|
2509
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postHyphen":2}}]
|
|
2510
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2441
2511
|
````
|
|
2442
2512
|
|
|
2443
2513
|
The following patterns are not considered problems:
|
|
@@ -6695,8 +6765,8 @@ function is adhering.
|
|
|
6695
6765
|
<a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10"></a>
|
|
6696
6766
|
#### Options
|
|
6697
6767
|
|
|
6698
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts"></a>
|
|
6699
|
-
<a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts"></a>
|
|
6768
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts-1"></a>
|
|
6769
|
+
<a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts-1"></a>
|
|
6700
6770
|
##### <code>contexts</code>
|
|
6701
6771
|
|
|
6702
6772
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -7030,8 +7100,8 @@ You may also provide an object with `message`:
|
|
|
7030
7100
|
}
|
|
7031
7101
|
```
|
|
7032
7102
|
|
|
7033
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-match-description-options-11-contexts-
|
|
7034
|
-
<a name="eslint-plugin-jsdoc-rules-match-description-options-11-contexts-
|
|
7103
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-match-description-options-11-contexts-2"></a>
|
|
7104
|
+
<a name="eslint-plugin-jsdoc-rules-match-description-options-11-contexts-2"></a>
|
|
7035
7105
|
##### <code>contexts</code>
|
|
7036
7106
|
|
|
7037
7107
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -7845,6 +7915,12 @@ name will actually be part of the description (e.g., for
|
|
|
7845
7915
|
`structuredTags` setting (if `name: false`, this rule will not apply to
|
|
7846
7916
|
that tag).
|
|
7847
7917
|
|
|
7918
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-match-name-fixer"></a>
|
|
7919
|
+
<a name="eslint-plugin-jsdoc-rules-match-name-fixer"></a>
|
|
7920
|
+
#### Fixer
|
|
7921
|
+
|
|
7922
|
+
Will replace `disallowName` with `replacement` if these are provided.
|
|
7923
|
+
|
|
7848
7924
|
<a name="user-content-eslint-plugin-jsdoc-rules-match-name-options-12"></a>
|
|
7849
7925
|
<a name="eslint-plugin-jsdoc-rules-match-name-options-12"></a>
|
|
7850
7926
|
#### Options
|
|
@@ -8855,8 +8931,8 @@ the presence of ES6 default parameters (bearing in mind that such
|
|
|
8855
8931
|
"defaults" are only applied when the supplied value is missing or
|
|
8856
8932
|
`undefined` but not for `null` or other "falsey" values).
|
|
8857
8933
|
|
|
8858
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-
|
|
8859
|
-
<a name="eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-
|
|
8934
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-3"></a>
|
|
8935
|
+
<a name="eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-3"></a>
|
|
8860
8936
|
##### <code>contexts</code>
|
|
8861
8937
|
|
|
8862
8938
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -9046,8 +9122,8 @@ not report if there were only a function declaration of the name "ignoreMe"
|
|
|
9046
9122
|
<a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17"></a>
|
|
9047
9123
|
#### Options
|
|
9048
9124
|
|
|
9049
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-
|
|
9050
|
-
<a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-
|
|
9125
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-4"></a>
|
|
9126
|
+
<a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-4"></a>
|
|
9051
9127
|
##### <code>contexts</code>
|
|
9052
9128
|
|
|
9053
9129
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -9092,6 +9168,15 @@ function quux () {
|
|
|
9092
9168
|
*/
|
|
9093
9169
|
function quux () {
|
|
9094
9170
|
|
|
9171
|
+
}
|
|
9172
|
+
// Settings: {"jsdoc":{"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}}
|
|
9173
|
+
// Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
|
|
9174
|
+
|
|
9175
|
+
/**
|
|
9176
|
+
* @implements {Bar|Foo}
|
|
9177
|
+
*/
|
|
9178
|
+
function quux () {
|
|
9179
|
+
|
|
9095
9180
|
}
|
|
9096
9181
|
// "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
|
|
9097
9182
|
// Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
|
|
@@ -9139,7 +9224,7 @@ function quux () {
|
|
|
9139
9224
|
function quux () {
|
|
9140
9225
|
|
|
9141
9226
|
}
|
|
9142
|
-
// Message: Rule `no-missing-syntax` is missing a `
|
|
9227
|
+
// Message: Rule `no-missing-syntax` is missing a `contexts` option.
|
|
9143
9228
|
|
|
9144
9229
|
/**
|
|
9145
9230
|
* @implements {Bar|Foo}
|
|
@@ -9523,8 +9608,8 @@ is designed to do), you can just use ESLint's rule.
|
|
|
9523
9608
|
<a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19"></a>
|
|
9524
9609
|
#### Options
|
|
9525
9610
|
|
|
9526
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-
|
|
9527
|
-
<a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-
|
|
9611
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-5"></a>
|
|
9612
|
+
<a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-5"></a>
|
|
9528
9613
|
##### <code>contexts</code>
|
|
9529
9614
|
|
|
9530
9615
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -9602,7 +9687,16 @@ function quux () {
|
|
|
9602
9687
|
function quux () {
|
|
9603
9688
|
|
|
9604
9689
|
}
|
|
9605
|
-
// Message: Rule `no-restricted-syntax` is missing a `
|
|
9690
|
+
// Message: Rule `no-restricted-syntax` is missing a `contexts` option.
|
|
9691
|
+
|
|
9692
|
+
/**
|
|
9693
|
+
* @implements {Bar|Foo}
|
|
9694
|
+
*/
|
|
9695
|
+
function quux () {
|
|
9696
|
+
|
|
9697
|
+
}
|
|
9698
|
+
// Settings: {"jsdoc":{"contexts":["FunctionDeclaration"]}}
|
|
9699
|
+
// Message: Rule `no-restricted-syntax` is missing a `contexts` option.
|
|
9606
9700
|
|
|
9607
9701
|
/**
|
|
9608
9702
|
* @param opt_a
|
|
@@ -9692,6 +9786,36 @@ const MyComponent = ({ children }) => {
|
|
|
9692
9786
|
*/
|
|
9693
9787
|
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type!=JsdocTypeStringValue][parsedType.type!=JsdocTypeNumber][parsedType.type!=JsdocTypeName])","context":"any","message":"@type should be limited to numeric or string literals and names"},{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type=JsdocTypeName]:not(*[parsedType.value=/^(true|false|null|undefined|boolean|number|string)$/]))","context":"any","message":"@type names should only be recognized primitive types or literals"}]}]
|
|
9694
9788
|
// Message: @type names should only be recognized primitive types or literals
|
|
9789
|
+
|
|
9790
|
+
/**
|
|
9791
|
+
*
|
|
9792
|
+
*/
|
|
9793
|
+
function test(): string { }
|
|
9794
|
+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"FunctionDeclaration[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with non-void return types must have a @returns tag"}]}]
|
|
9795
|
+
// Message: Functions with non-void return types must have a @returns tag
|
|
9796
|
+
|
|
9797
|
+
/**
|
|
9798
|
+
*
|
|
9799
|
+
*/
|
|
9800
|
+
let test = (): string => { };
|
|
9801
|
+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"ArrowFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with non-void return types must have a @returns tag"}]}]
|
|
9802
|
+
// Message: Functions with non-void return types must have a @returns tag
|
|
9803
|
+
|
|
9804
|
+
/**
|
|
9805
|
+
* @returns
|
|
9806
|
+
*/
|
|
9807
|
+
let test: () => string;
|
|
9808
|
+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]:has(JsdocDescriptionLine)))","context":"VariableDeclaration:has(*[typeAnnotation.typeAnnotation.type=/TSFunctionType/][typeAnnotation.typeAnnotation.returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/])","message":"FunctionType's with non-void return types must have a @returns tag with a description"}]}]
|
|
9809
|
+
// Message: FunctionType's with non-void return types must have a @returns tag with a description
|
|
9810
|
+
|
|
9811
|
+
/**
|
|
9812
|
+
*
|
|
9813
|
+
*/
|
|
9814
|
+
class Test {
|
|
9815
|
+
abstract Test(): string;
|
|
9816
|
+
}
|
|
9817
|
+
// "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"}]}]
|
|
9818
|
+
// Message: methods with non-void return types must have a @returns tag
|
|
9695
9819
|
````
|
|
9696
9820
|
|
|
9697
9821
|
The following patterns are not considered problems:
|
|
@@ -9772,6 +9896,32 @@ function foo(): string;
|
|
|
9772
9896
|
* @type {boolean}
|
|
9773
9897
|
*/
|
|
9774
9898
|
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type!=JsdocTypeStringValue][parsedType.type!=JsdocTypeNumber][parsedType.type!=JsdocTypeName])","context":"any","message":"@type should be limited to numeric or string literals and names"},{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type=JsdocTypeName]:not(*[parsedType.value=/^(true|false|null|undefined|boolean|number|string)$/]))","context":"any","message":"@type names should only be recognized primitive types or literals"}]}]
|
|
9899
|
+
|
|
9900
|
+
/**
|
|
9901
|
+
*
|
|
9902
|
+
*/
|
|
9903
|
+
function test(): void { }
|
|
9904
|
+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"FunctionDeclaration[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with return types must have a @returns tag"}]}]
|
|
9905
|
+
|
|
9906
|
+
/**
|
|
9907
|
+
*
|
|
9908
|
+
*/
|
|
9909
|
+
let test = (): undefined => { };
|
|
9910
|
+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"ArrowFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with non-void return types must have a @returns tag"}]}]
|
|
9911
|
+
|
|
9912
|
+
/**
|
|
9913
|
+
* @returns A description
|
|
9914
|
+
*/
|
|
9915
|
+
let test: () => string;
|
|
9916
|
+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]:has(JsdocDescriptionLine)))","context":"VariableDeclaration:has(*[typeAnnotation.typeAnnotation.type=/TSFunctionType/])","message":"FunctionType's with non-void return types must have a @returns tag"}]}]
|
|
9917
|
+
|
|
9918
|
+
/**
|
|
9919
|
+
*
|
|
9920
|
+
*/
|
|
9921
|
+
class Test {
|
|
9922
|
+
abstract Test(): void;
|
|
9923
|
+
}
|
|
9924
|
+
// "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"}]}]
|
|
9775
9925
|
````
|
|
9776
9926
|
|
|
9777
9927
|
|
|
@@ -9788,8 +9938,8 @@ the type information would be redundant with TypeScript.
|
|
|
9788
9938
|
<a name="eslint-plugin-jsdoc-rules-no-types-options-20"></a>
|
|
9789
9939
|
#### Options
|
|
9790
9940
|
|
|
9791
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-no-types-options-20-contexts-
|
|
9792
|
-
<a name="eslint-plugin-jsdoc-rules-no-types-options-20-contexts-
|
|
9941
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-no-types-options-20-contexts-6"></a>
|
|
9942
|
+
<a name="eslint-plugin-jsdoc-rules-no-types-options-20-contexts-6"></a>
|
|
9793
9943
|
##### <code>contexts</code>
|
|
9794
9944
|
|
|
9795
9945
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -10911,15 +11061,24 @@ Requires that block description, explicit `@description`, and
|
|
|
10911
11061
|
|
|
10912
11062
|
* Description must start with an uppercase alphabetical character.
|
|
10913
11063
|
* Paragraphs must start with an uppercase alphabetical character.
|
|
10914
|
-
* Sentences must end with a period.
|
|
11064
|
+
* Sentences must end with a period, question mark, exclamation mark, or triple backticks.
|
|
10915
11065
|
* Every line in a paragraph (except the first) which starts with an uppercase
|
|
10916
11066
|
character must be preceded by a line ending with a period.
|
|
10917
11067
|
* A colon or semi-colon followed by two line breaks is still part of the
|
|
10918
11068
|
containing paragraph (unlike normal dual line breaks).
|
|
10919
|
-
* Text within inline tags `{...}` are not checked for sentence divisions.
|
|
11069
|
+
* Text within inline tags `{...}` or within triple backticks are not checked for sentence divisions.
|
|
10920
11070
|
* Periods after items within the `abbreviations` option array are not treated
|
|
10921
11071
|
as sentence endings.
|
|
10922
11072
|
|
|
11073
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-description-complete-sentence-fixer-1"></a>
|
|
11074
|
+
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-fixer-1"></a>
|
|
11075
|
+
#### Fixer
|
|
11076
|
+
|
|
11077
|
+
If sentences do not end with terminal punctuation, a period will be added.
|
|
11078
|
+
|
|
11079
|
+
If sentences do not start with an uppercase character, the initial
|
|
11080
|
+
letter will be capitalized.
|
|
11081
|
+
|
|
10923
11082
|
<a name="user-content-eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23"></a>
|
|
10924
11083
|
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23"></a>
|
|
10925
11084
|
#### Options
|
|
@@ -11790,6 +11949,16 @@ class quux {
|
|
|
11790
11949
|
// "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
|
|
11791
11950
|
// Message: Missing JSDoc @description declaration.
|
|
11792
11951
|
|
|
11952
|
+
/**
|
|
11953
|
+
*
|
|
11954
|
+
*/
|
|
11955
|
+
class quux {
|
|
11956
|
+
|
|
11957
|
+
}
|
|
11958
|
+
// Settings: {"jsdoc":{"contexts":["ClassDeclaration"]}}
|
|
11959
|
+
// "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
|
|
11960
|
+
// Message: Missing JSDoc @description declaration.
|
|
11961
|
+
|
|
11793
11962
|
/**
|
|
11794
11963
|
*
|
|
11795
11964
|
*/
|
|
@@ -12274,8 +12443,8 @@ exemption of the rule.
|
|
|
12274
12443
|
Boolean to indicate that no-argument functions should not be reported for
|
|
12275
12444
|
missing `@example` declarations.
|
|
12276
12445
|
|
|
12277
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-example-options-25-contexts-
|
|
12278
|
-
<a name="eslint-plugin-jsdoc-rules-require-example-options-25-contexts-
|
|
12446
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-example-options-25-contexts-7"></a>
|
|
12447
|
+
<a name="eslint-plugin-jsdoc-rules-require-example-options-25-contexts-7"></a>
|
|
12279
12448
|
##### <code>contexts</code>
|
|
12280
12449
|
|
|
12281
12450
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -12313,8 +12482,8 @@ A value indicating whether setters should be checked. Defaults to `false`.
|
|
|
12313
12482
|
A boolean on whether to enable the fixer (which adds an empty `@example` block).
|
|
12314
12483
|
Defaults to `true`.
|
|
12315
12484
|
|
|
12316
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-example-fixer"></a>
|
|
12317
|
-
<a name="eslint-plugin-jsdoc-rules-require-example-fixer"></a>
|
|
12485
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-example-fixer-2"></a>
|
|
12486
|
+
<a name="eslint-plugin-jsdoc-rules-require-example-fixer-2"></a>
|
|
12318
12487
|
#### Fixer
|
|
12319
12488
|
|
|
12320
12489
|
The fixer for `require-example` will add an empty `@example`, but it will still
|
|
@@ -13179,8 +13348,8 @@ An object with the following optional boolean keys which all default to
|
|
|
13179
13348
|
- `FunctionExpression`
|
|
13180
13349
|
- `MethodDefinition`
|
|
13181
13350
|
|
|
13182
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-
|
|
13183
|
-
<a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-
|
|
13351
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-8"></a>
|
|
13352
|
+
<a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-8"></a>
|
|
13184
13353
|
##### <code>contexts</code>
|
|
13185
13354
|
|
|
13186
13355
|
Set this to an array of strings or objects representing the additional AST
|
|
@@ -13380,6 +13549,13 @@ export const test = () => {
|
|
|
13380
13549
|
|
|
13381
13550
|
export const test = () => {
|
|
13382
13551
|
|
|
13552
|
+
};
|
|
13553
|
+
// Settings: {"jsdoc":{"contexts":["ArrowFunctionExpression"]}}
|
|
13554
|
+
// "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true}]
|
|
13555
|
+
// Message: Missing JSDoc comment.
|
|
13556
|
+
|
|
13557
|
+
export const test = () => {
|
|
13558
|
+
|
|
13383
13559
|
};
|
|
13384
13560
|
// "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":[{"context":"ArrowFunctionExpression"}],"publicOnly":true}]
|
|
13385
13561
|
// Message: Missing JSDoc comment.
|
|
@@ -14959,8 +15135,8 @@ string. Defaults to `false`.
|
|
|
14959
15135
|
The description string to set by default for destructured roots. Defaults to
|
|
14960
15136
|
"The root object".
|
|
14961
15137
|
|
|
14962
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-
|
|
14963
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-
|
|
15138
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-9"></a>
|
|
15139
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-9"></a>
|
|
14964
15140
|
##### <code>contexts</code>
|
|
14965
15141
|
|
|
14966
15142
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -15157,8 +15333,8 @@ Requires that all function parameters have names.
|
|
|
15157
15333
|
<a name="eslint-plugin-jsdoc-rules-require-param-name-options-30"></a>
|
|
15158
15334
|
#### Options
|
|
15159
15335
|
|
|
15160
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-
|
|
15161
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-
|
|
15336
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-10"></a>
|
|
15337
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-10"></a>
|
|
15162
15338
|
##### <code>contexts</code>
|
|
15163
15339
|
|
|
15164
15340
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -15317,8 +15493,8 @@ object. Uses `defaultDestructuredRootType` for the type string. Defaults to
|
|
|
15317
15493
|
|
|
15318
15494
|
The type string to set by default for destructured roots. Defaults to "object".
|
|
15319
15495
|
|
|
15320
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-
|
|
15321
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-
|
|
15496
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-11"></a>
|
|
15497
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-11"></a>
|
|
15322
15498
|
##### <code>contexts</code>
|
|
15323
15499
|
|
|
15324
15500
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -15497,16 +15673,16 @@ function quux (foo, {bar: {baz}}) {
|
|
|
15497
15673
|
|
|
15498
15674
|
Requires that all function parameters are documented.
|
|
15499
15675
|
|
|
15500
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15501
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15676
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3"></a>
|
|
15677
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3"></a>
|
|
15502
15678
|
#### Fixer
|
|
15503
15679
|
|
|
15504
15680
|
Adds `@param <name>` for each tag present in the function signature but
|
|
15505
15681
|
missing in the jsdoc. Can be disabled by setting the `enableFixer`
|
|
15506
15682
|
option to `false`.
|
|
15507
15683
|
|
|
15508
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15509
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15684
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-destructured-object-and-array-naming"></a>
|
|
15685
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-destructured-object-and-array-naming"></a>
|
|
15510
15686
|
##### Destructured object and array naming
|
|
15511
15687
|
|
|
15512
15688
|
When the fixer is applied to destructured objects, only the input name is
|
|
@@ -15558,8 +15734,8 @@ function quux ([foo, bar]) {
|
|
|
15558
15734
|
*/
|
|
15559
15735
|
```
|
|
15560
15736
|
|
|
15561
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15562
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15737
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-missing-root-fixing"></a>
|
|
15738
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-missing-root-fixing"></a>
|
|
15563
15739
|
##### Missing root fixing
|
|
15564
15740
|
|
|
15565
15741
|
Note that unless `enableRootFixer` (or `enableFixer`) is set to `false`,
|
|
@@ -15594,8 +15770,8 @@ numeric component).
|
|
|
15594
15770
|
And one can have the count begin at another number (e.g., `1`) by changing
|
|
15595
15771
|
`autoIncrementBase` from the default of `0`.
|
|
15596
15772
|
|
|
15597
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15598
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15773
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-rest-element-restelement-insertions"></a>
|
|
15774
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-rest-element-restelement-insertions"></a>
|
|
15599
15775
|
##### Rest Element (<code>RestElement</code>) insertions
|
|
15600
15776
|
|
|
15601
15777
|
The fixer will automatically report/insert
|
|
@@ -15647,8 +15823,8 @@ function baar ([a, ...extra]) {
|
|
|
15647
15823
|
|
|
15648
15824
|
...because it does not use the `...` syntax in the type.
|
|
15649
15825
|
|
|
15650
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15651
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15826
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-object-rest-property-insertions"></a>
|
|
15827
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-object-rest-property-insertions"></a>
|
|
15652
15828
|
##### Object Rest Property insertions
|
|
15653
15829
|
|
|
15654
15830
|
If the `checkRestProperty` option is set to `true` (`false` by default),
|
|
@@ -15845,8 +16021,8 @@ You could set this regular expression to a more expansive list, or you
|
|
|
15845
16021
|
could restrict it such that even types matching those strings would not
|
|
15846
16022
|
need destructuring.
|
|
15847
16023
|
|
|
15848
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-options-32-contexts-
|
|
15849
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-options-32-contexts-
|
|
16024
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-options-32-contexts-12"></a>
|
|
16025
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-options-32-contexts-12"></a>
|
|
15850
16026
|
##### <code>contexts</code>
|
|
15851
16027
|
|
|
15852
16028
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -17278,8 +17454,8 @@ when their type is a plain `object`, `Object`, or `PlainObject`.
|
|
|
17278
17454
|
Note that any other type, including a subtype of object such as
|
|
17279
17455
|
`object<string, string>`, will not be reported.
|
|
17280
17456
|
|
|
17281
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-property-fixer-
|
|
17282
|
-
<a name="eslint-plugin-jsdoc-rules-require-property-fixer-
|
|
17457
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-property-fixer-4"></a>
|
|
17458
|
+
<a name="eslint-plugin-jsdoc-rules-require-property-fixer-4"></a>
|
|
17283
17459
|
#### Fixer
|
|
17284
17460
|
|
|
17285
17461
|
The fixer for `require-property` will add an empty `@property`.
|
|
@@ -18614,8 +18790,8 @@ or if it is `Promise<void>` or `Promise<undefined>`.
|
|
|
18614
18790
|
<a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34"></a>
|
|
18615
18791
|
#### Options
|
|
18616
18792
|
|
|
18617
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-
|
|
18618
|
-
<a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-
|
|
18793
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-13"></a>
|
|
18794
|
+
<a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-13"></a>
|
|
18619
18795
|
##### <code>contexts</code>
|
|
18620
18796
|
|
|
18621
18797
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -18773,8 +18949,8 @@ Requires that `@returns` tag has `type` value.
|
|
|
18773
18949
|
<a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35"></a>
|
|
18774
18950
|
#### Options
|
|
18775
18951
|
|
|
18776
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-
|
|
18777
|
-
<a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-
|
|
18952
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-14"></a>
|
|
18953
|
+
<a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-14"></a>
|
|
18778
18954
|
##### <code>contexts</code>
|
|
18779
18955
|
|
|
18780
18956
|
Set this to an array of strings representing the AST context (or an object with
|
|
@@ -22564,7 +22740,8 @@ The following tags have their name/namepath portion (the non-whitespace
|
|
|
22564
22740
|
text after the tag name) checked:
|
|
22565
22741
|
|
|
22566
22742
|
1. Name(path)-defining tags requiring namepath: `@event`, `@callback`,
|
|
22567
|
-
`@
|
|
22743
|
+
`@exports` (JSDoc only),
|
|
22744
|
+
`@external`, `@host`, `@name`, `@typedef` (JSDoc only), and `@template`
|
|
22568
22745
|
(TypeScript/Closure only); `@param` (`@arg`, `@argument`) and `@property`
|
|
22569
22746
|
(`@prop`) also fall into this category, but while this rule will check
|
|
22570
22747
|
their namepath validity, we leave the requiring of the name portion
|
|
@@ -22573,11 +22750,11 @@ text after the tag name) checked:
|
|
|
22573
22750
|
1. Name(path)-defining tags (which may have value without namepath or their
|
|
22574
22751
|
namepath can be expressed elsewhere on the block):
|
|
22575
22752
|
`@class`, `@constructor`, `@constant`, `@const`, `@function`, `@func`,
|
|
22576
|
-
`@method`, `@interface` (
|
|
22753
|
+
`@method`, `@interface` (non-Closure only), `@member`, `@var`,
|
|
22577
22754
|
`@mixin`, `@namespace`, `@module` (module paths are not planned for
|
|
22578
22755
|
TypeScript)
|
|
22579
22756
|
1. Name(path)-pointing tags requiring namepath: `@alias`, `@augments`,
|
|
22580
|
-
`@extends
|
|
22757
|
+
`@extends` (JSDoc only), `@lends`, `@memberof`, `@memberof!`, `@mixes`, `@requires`, `@this`
|
|
22581
22758
|
(jsdoc only)
|
|
22582
22759
|
1. Name(path)-pointing tags (which may have value without namepath or their
|
|
22583
22760
|
namepath can be expressed elsewhere on the block): `@listens`, `@fires`,
|
package/dist/alignTransform.js
CHANGED
|
@@ -199,6 +199,9 @@ const alignTransform = ({
|
|
|
199
199
|
tokens
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
+
const postHyphenSpacing = (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postHyphen) ?? 1;
|
|
203
|
+
const hyphenSpacing = /^\s*-\s*/u;
|
|
204
|
+
tokens.description = tokens.description.replace(hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '));
|
|
202
205
|
|
|
203
206
|
// Not align.
|
|
204
207
|
if (!shouldAlign(tags, index, source)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alignTransform.js","names":["rewireSource","util","zeroWidth","name","start","tag","type","shouldAlign","tags","index","source","tokens","replace","includesTag","includes","iterator","previousTag","getWidth","width","Math","max","length","delimiter","Markers","getTypelessInfo","fields","hasNoTypes","every","maxNamedTagLength","map","filter","maxUnnamedTagLength","space","len","padStart","alignTransform","customSpacings","indent","preserveMainDescriptionPostDelimiter","intoTags","alignTokens","typelessInfo","nothingAfter","delim","description","postName","postType","postTag","untypedNameAdjustment","untypedTypeAdjustment","spacings","postDelimiter","update","line","isEmpty","end","reduce"],"sources":["../src/alignTransform.js"],"sourcesContent":["/**\n * Transform based on https://github.com/syavorsky/comment-parser/blob/master/src/transforms/align.ts\n *\n * It contains some customizations to align based on the tags, and some custom options.\n */\n\nimport {\n\n // `comment-parser/primitives` export\n Markers,\n util,\n} from 'comment-parser';\n\nconst {\n rewireSource,\n} = util;\n\nconst zeroWidth = {\n name: 0,\n start: 0,\n tag: 0,\n type: 0,\n};\n\nconst shouldAlign = (tags, index, source) => {\n const tag = source[index].tokens.tag.replace('@', '');\n const includesTag = tags.includes(tag);\n\n if (includesTag) {\n return true;\n }\n\n if (tag !== '') {\n return false;\n }\n\n for (let iterator = index; iterator >= 0; iterator--) {\n const previousTag = source[iterator].tokens.tag.replace('@', '');\n\n if (previousTag !== '') {\n if (tags.includes(previousTag)) {\n return true;\n }\n\n return false;\n }\n }\n\n return true;\n};\n\nconst getWidth = (tags) => {\n return (width, {\n tokens,\n }, index, source) => {\n if (!shouldAlign(tags, index, source)) {\n return width;\n }\n\n return {\n name: Math.max(width.name, tokens.name.length),\n start: tokens.delimiter === Markers.start ? tokens.start.length : width.start,\n tag: Math.max(width.tag, tokens.tag.length),\n type: Math.max(width.type, tokens.type.length),\n };\n };\n};\n\nconst getTypelessInfo = (fields) => {\n const hasNoTypes = fields.tags.every(({\n type,\n }) => {\n return !type;\n });\n const maxNamedTagLength = Math.max(...fields.tags.map(({\n tag,\n name,\n }) => {\n return name.length === 0 ? -1 : tag.length;\n }).filter((length) => {\n return length !== -1;\n })) + 1;\n const maxUnnamedTagLength = Math.max(...fields.tags.map(({\n tag,\n name,\n }) => {\n return name.length === 0 ? tag.length : -1;\n }).filter((length) => {\n return length !== -1;\n })) + 1;\n return {\n hasNoTypes,\n maxNamedTagLength,\n maxUnnamedTagLength,\n };\n};\n\nconst space = (len) => {\n return ''.padStart(len, ' ');\n};\n\nconst alignTransform = ({\n customSpacings,\n tags,\n indent,\n preserveMainDescriptionPostDelimiter,\n}) => {\n let intoTags = false;\n let width;\n\n const alignTokens = (tokens, typelessInfo) => {\n const nothingAfter = {\n delim: false,\n name: false,\n tag: false,\n type: false,\n };\n\n if (tokens.description === '') {\n nothingAfter.name = true;\n tokens.postName = '';\n\n if (tokens.name === '') {\n nothingAfter.type = true;\n tokens.postType = '';\n\n if (tokens.type === '') {\n nothingAfter.tag = true;\n tokens.postTag = '';\n\n /* istanbul ignore next: Never happens because the !intoTags return. But it's here for consistency with the original align transform */\n if (tokens.tag === '') {\n nothingAfter.delim = true;\n }\n }\n }\n }\n\n let untypedNameAdjustment = 0;\n let untypedTypeAdjustment = 0;\n if (typelessInfo.hasNoTypes) {\n nothingAfter.tag = true;\n tokens.postTag = '';\n if (tokens.name === '') {\n untypedNameAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;\n } else {\n untypedNameAdjustment = typelessInfo.maxNamedTagLength > typelessInfo.maxUnnamedTagLength ? 0 :\n Math.max(0, typelessInfo.maxUnnamedTagLength - (tokens.tag.length + tokens.name.length + 1));\n untypedTypeAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;\n }\n }\n\n // Todo: Avoid fixing alignment of blocks with multiline wrapping of type\n if (tokens.tag === '' && tokens.type) {\n return tokens;\n }\n\n const spacings = {\n postDelimiter: customSpacings?.postDelimiter || 1,\n postName: customSpacings?.postName || 1,\n postTag: customSpacings?.postTag || 1,\n postType: customSpacings?.postType || 1,\n };\n\n tokens.postDelimiter = nothingAfter.delim ? '' : space(spacings.postDelimiter);\n\n if (!nothingAfter.tag) {\n tokens.postTag = space(width.tag - tokens.tag.length + spacings.postTag);\n }\n\n if (!nothingAfter.type) {\n tokens.postType = space(width.type - tokens.type.length + spacings.postType + untypedTypeAdjustment);\n }\n\n if (!nothingAfter.name) {\n // If post name is empty for all lines (name width 0), don't add post name spacing.\n tokens.postName = width.name === 0 ? '' : space(width.name - tokens.name.length + spacings.postName + untypedNameAdjustment);\n }\n\n return tokens;\n };\n\n const update = (line, index, source, typelessInfo) => {\n const tokens = {\n ...line.tokens,\n };\n if (tokens.tag !== '') {\n intoTags = true;\n }\n\n const isEmpty =\n tokens.tag === '' &&\n tokens.name === '' &&\n tokens.type === '' &&\n tokens.description === '';\n\n // dangling '*/'\n if (tokens.end === Markers.end && isEmpty) {\n tokens.start = indent + ' ';\n\n return {\n ...line,\n tokens,\n };\n }\n\n /* eslint-disable indent */\n switch (tokens.delimiter) {\n case Markers.start:\n tokens.start = indent;\n break;\n case Markers.delim:\n tokens.start = indent + ' ';\n break;\n default:\n tokens.delimiter = '';\n\n // compensate delimiter\n tokens.start = indent + ' ';\n }\n /* eslint-enable */\n\n if (!intoTags) {\n if (tokens.description === '') {\n tokens.postDelimiter = '';\n } else if (!preserveMainDescriptionPostDelimiter) {\n tokens.postDelimiter = ' ';\n }\n\n return {\n ...line,\n tokens,\n };\n }\n\n // Not align.\n if (!shouldAlign(tags, index, source)) {\n return {\n ...line,\n tokens,\n };\n }\n\n return {\n ...line,\n tokens: alignTokens(tokens, typelessInfo),\n };\n };\n\n return ({\n source,\n ...fields\n }) => {\n width = source.reduce(getWidth(tags), {\n ...zeroWidth,\n });\n\n const typelessInfo = getTypelessInfo(fields);\n\n return rewireSource({\n ...fields,\n source: source.map((line, index) => {\n return update(line, index, source, typelessInfo);\n }),\n });\n };\n};\n\nexport default alignTransform;\n"],"mappings":";;;;;;AAMA;AANA;AACA;AACA;AACA;AACA;;AASA,MAAM;EACJA;AACF,CAAC,GAAGC,mBAAI;AAER,MAAMC,SAAS,GAAG;EAChBC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,GAAG,EAAE,CAAC;EACNC,IAAI,EAAE;AACR,CAAC;AAED,MAAMC,WAAW,GAAG,CAACC,IAAI,EAAEC,KAAK,EAAEC,MAAM,KAAK;EAC3C,MAAML,GAAG,GAAGK,MAAM,CAACD,KAAK,CAAC,CAACE,MAAM,CAACN,GAAG,CAACO,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;EACrD,MAAMC,WAAW,GAAGL,IAAI,CAACM,QAAQ,CAACT,GAAG,CAAC;EAEtC,IAAIQ,WAAW,EAAE;IACf,OAAO,IAAI;EACb;EAEA,IAAIR,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,KAAK;EACd;EAEA,KAAK,IAAIU,QAAQ,GAAGN,KAAK,EAAEM,QAAQ,IAAI,CAAC,EAAEA,QAAQ,EAAE,EAAE;IACpD,MAAMC,WAAW,GAAGN,MAAM,CAACK,QAAQ,CAAC,CAACJ,MAAM,CAACN,GAAG,CAACO,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;IAEhE,IAAII,WAAW,KAAK,EAAE,EAAE;MACtB,IAAIR,IAAI,CAACM,QAAQ,CAACE,WAAW,CAAC,EAAE;QAC9B,OAAO,IAAI;MACb;MAEA,OAAO,KAAK;IACd;EACF;EAEA,OAAO,IAAI;AACb,CAAC;AAED,MAAMC,QAAQ,GAAIT,IAAI,IAAK;EACzB,OAAO,CAACU,KAAK,EAAE;IACbP;EACF,CAAC,EAAEF,KAAK,EAAEC,MAAM,KAAK;IACnB,IAAI,CAACH,WAAW,CAACC,IAAI,EAAEC,KAAK,EAAEC,MAAM,CA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AAC,CAACwB,IAAI,EAAE5C,KAAK,KAAK;QAClC,OAAO2C,MAAM,CAACC,IAAI,EAAE5C,KAAK,EAAEC,MAAM,EAAE+B,YAAY,CAAC;MAClD,CAAC;IACH,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAAC,eAEaN,cAAc;AAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"alignTransform.js","names":["rewireSource","util","zeroWidth","name","start","tag","type","shouldAlign","tags","index","source","tokens","replace","includesTag","includes","iterator","previousTag","getWidth","width","Math","max","length","delimiter","Markers","getTypelessInfo","fields","hasNoTypes","every","maxNamedTagLength","map","filter","maxUnnamedTagLength","space","len","padStart","alignTransform","customSpacings","indent","preserveMainDescriptionPostDelimiter","intoTags","alignTokens","typelessInfo","nothingAfter","delim","description","postName","postType","postTag","untypedNameAdjustment","untypedTypeAdjustment","spacings","postDelimiter","update","line","isEmpty","end","postHyphenSpacing","postHyphen","hyphenSpacing","reduce"],"sources":["../src/alignTransform.js"],"sourcesContent":["/**\n * Transform based on https://github.com/syavorsky/comment-parser/blob/master/src/transforms/align.ts\n *\n * It contains some customizations to align based on the tags, and some custom options.\n */\n\nimport {\n\n // `comment-parser/primitives` export\n Markers,\n util,\n} from 'comment-parser';\n\nconst {\n rewireSource,\n} = util;\n\nconst zeroWidth = {\n name: 0,\n start: 0,\n tag: 0,\n type: 0,\n};\n\nconst shouldAlign = (tags, index, source) => {\n const tag = source[index].tokens.tag.replace('@', '');\n const includesTag = tags.includes(tag);\n\n if (includesTag) {\n return true;\n }\n\n if (tag !== '') {\n return false;\n }\n\n for (let iterator = index; iterator >= 0; iterator--) {\n const previousTag = source[iterator].tokens.tag.replace('@', '');\n\n if (previousTag !== '') {\n if (tags.includes(previousTag)) {\n return true;\n }\n\n return false;\n }\n }\n\n return true;\n};\n\nconst getWidth = (tags) => {\n return (width, {\n tokens,\n }, index, source) => {\n if (!shouldAlign(tags, index, source)) {\n return width;\n }\n\n return {\n name: Math.max(width.name, tokens.name.length),\n start: tokens.delimiter === Markers.start ? tokens.start.length : width.start,\n tag: Math.max(width.tag, tokens.tag.length),\n type: Math.max(width.type, tokens.type.length),\n };\n };\n};\n\nconst getTypelessInfo = (fields) => {\n const hasNoTypes = fields.tags.every(({\n type,\n }) => {\n return !type;\n });\n const maxNamedTagLength = Math.max(...fields.tags.map(({\n tag,\n name,\n }) => {\n return name.length === 0 ? -1 : tag.length;\n }).filter((length) => {\n return length !== -1;\n })) + 1;\n const maxUnnamedTagLength = Math.max(...fields.tags.map(({\n tag,\n name,\n }) => {\n return name.length === 0 ? tag.length : -1;\n }).filter((length) => {\n return length !== -1;\n })) + 1;\n return {\n hasNoTypes,\n maxNamedTagLength,\n maxUnnamedTagLength,\n };\n};\n\nconst space = (len) => {\n return ''.padStart(len, ' ');\n};\n\nconst alignTransform = ({\n customSpacings,\n tags,\n indent,\n preserveMainDescriptionPostDelimiter,\n}) => {\n let intoTags = false;\n let width;\n\n const alignTokens = (tokens, typelessInfo) => {\n const nothingAfter = {\n delim: false,\n name: false,\n tag: false,\n type: false,\n };\n\n if (tokens.description === '') {\n nothingAfter.name = true;\n tokens.postName = '';\n\n if (tokens.name === '') {\n nothingAfter.type = true;\n tokens.postType = '';\n\n if (tokens.type === '') {\n nothingAfter.tag = true;\n tokens.postTag = '';\n\n /* istanbul ignore next: Never happens because the !intoTags return. But it's here for consistency with the original align transform */\n if (tokens.tag === '') {\n nothingAfter.delim = true;\n }\n }\n }\n }\n\n let untypedNameAdjustment = 0;\n let untypedTypeAdjustment = 0;\n if (typelessInfo.hasNoTypes) {\n nothingAfter.tag = true;\n tokens.postTag = '';\n if (tokens.name === '') {\n untypedNameAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;\n } else {\n untypedNameAdjustment = typelessInfo.maxNamedTagLength > typelessInfo.maxUnnamedTagLength ? 0 :\n Math.max(0, typelessInfo.maxUnnamedTagLength - (tokens.tag.length + tokens.name.length + 1));\n untypedTypeAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;\n }\n }\n\n // Todo: Avoid fixing alignment of blocks with multiline wrapping of type\n if (tokens.tag === '' && tokens.type) {\n return tokens;\n }\n\n const spacings = {\n postDelimiter: customSpacings?.postDelimiter || 1,\n postName: customSpacings?.postName || 1,\n postTag: customSpacings?.postTag || 1,\n postType: customSpacings?.postType || 1,\n };\n\n tokens.postDelimiter = nothingAfter.delim ? '' : space(spacings.postDelimiter);\n\n if (!nothingAfter.tag) {\n tokens.postTag = space(width.tag - tokens.tag.length + spacings.postTag);\n }\n\n if (!nothingAfter.type) {\n tokens.postType = space(width.type - tokens.type.length + spacings.postType + untypedTypeAdjustment);\n }\n\n if (!nothingAfter.name) {\n // If post name is empty for all lines (name width 0), don't add post name spacing.\n tokens.postName = width.name === 0 ? '' : space(width.name - tokens.name.length + spacings.postName + untypedNameAdjustment);\n }\n\n return tokens;\n };\n\n const update = (line, index, source, typelessInfo) => {\n const tokens = {\n ...line.tokens,\n };\n if (tokens.tag !== '') {\n intoTags = true;\n }\n\n const isEmpty =\n tokens.tag === '' &&\n tokens.name === '' &&\n tokens.type === '' &&\n tokens.description === '';\n\n // dangling '*/'\n if (tokens.end === Markers.end && isEmpty) {\n tokens.start = indent + ' ';\n\n return {\n ...line,\n tokens,\n };\n }\n\n /* eslint-disable indent */\n switch (tokens.delimiter) {\n case Markers.start:\n tokens.start = indent;\n break;\n case Markers.delim:\n tokens.start = indent + ' ';\n break;\n default:\n tokens.delimiter = '';\n\n // compensate delimiter\n tokens.start = indent + ' ';\n }\n /* eslint-enable */\n\n if (!intoTags) {\n if (tokens.description === '') {\n tokens.postDelimiter = '';\n } else if (!preserveMainDescriptionPostDelimiter) {\n tokens.postDelimiter = ' ';\n }\n\n return {\n ...line,\n tokens,\n };\n }\n\n const postHyphenSpacing = customSpacings?.postHyphen ?? 1;\n const hyphenSpacing = /^\\s*-\\s*/u;\n tokens.description = tokens.description.replace(\n hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '),\n );\n\n // Not align.\n if (!shouldAlign(tags, index, source)) {\n return {\n ...line,\n tokens,\n };\n }\n\n return {\n ...line,\n tokens: alignTokens(tokens, typelessInfo),\n };\n };\n\n return ({\n source,\n ...fields\n }) => {\n width = source.reduce(getWidth(tags), {\n ...zeroWidth,\n });\n\n const typelessInfo = getTypelessInfo(fields);\n\n return rewireSource({\n ...fields,\n source: source.map((line, index) => {\n return update(line, index, source, typelessInfo);\n }),\n });\n };\n};\n\nexport default alignTransform;\n"],"mappings":";;;;;;AAMA;AANA;AACA;AACA;AACA;AACA;;AASA,MAAM;EACJA;AACF,CAAC,GAAGC,mBAAI;AAER,MAAMC,SAAS,GAAG;EAChBC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,GAAG,EAAE,CAAC;EACNC,IAAI,EAAE;AACR,CAAC;AAED,MAAMC,WAAW,GAAG,CAACC,IAAI,EAAEC,KAAK,EAAEC,MAAM,KAAK;EAC3C,MAAML,GAAG,GAAGK,MAAM,CAACD,KAAK,CAAC,CAACE,MAAM,CAACN,GAAG,CAACO,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;EACrD,MAAMC,WAAW,GAAGL,IAAI,CAACM,QAAQ,CAACT,GAAG,CAAC;EAEtC,IAAIQ,WAAW,EAAE;IACf,OAAO,IAAI;EACb;EAEA,IAAIR,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,KAAK;EACd;EAEA,KAAK,IAAIU,QAAQ,GAAGN,KAAK,EAAEM,QAAQ,IAAI,CAAC,EAAEA,QAAQ,EAAE,EAAE;IACpD,MAAMC,WAAW,GAAGN,MAAM,CAACK,QAAQ,CAAC,CAACJ,MAAM,CAACN,GAAG,CAACO,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;IAEhE,IAAII,WAAW,KAAK,EAAE,EAAE;MACtB,IAAIR,IAAI,CAACM,QAAQ,CAACE,WAAW,CAAC,EAAE;QAC9B,OAAO,IAAI;MACb;MAEA,OAAO,KAAK;IACd;EACF;EAEA,OAAO,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