eslint-plugin-jsdoc 39.7.4 → 39.8.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 +230 -56
- package/dist/alignTransform.js +3 -0
- package/dist/alignTransform.js.map +1 -1
- package/dist/rules/checkLineAlignment.js +12 -1
- package/dist/rules/checkLineAlignment.js.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +25 -7
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2047,6 +2047,7 @@ An object with any of the following keys set to an integer. Affects spacing:
|
|
|
2047
2047
|
- `postTag` - after the tag (e.g., `* @param `)
|
|
2048
2048
|
- `postType` - after the type (e.g., `* @param {someType} `)
|
|
2049
2049
|
- `postName` - after the name (e.g., `* @param {someType} name `)
|
|
2050
|
+
- `postHyphens` - after any hyphens in the description (e.g., `* @param {someType} name - A description`)
|
|
2050
2051
|
|
|
2051
2052
|
If a spacing is not defined, it defaults to one.
|
|
2052
2053
|
|
|
@@ -2438,6 +2439,66 @@ const fn = ( lorem, sit ) => {}
|
|
|
2438
2439
|
const fn = ( lorem, sit ) => {}
|
|
2439
2440
|
// "jsdoc/check-line-alignment": ["error"|"warn", "always"]
|
|
2440
2441
|
// Message: Expected JSDoc block lines to be aligned.
|
|
2442
|
+
|
|
2443
|
+
/**
|
|
2444
|
+
* Function description.
|
|
2445
|
+
*
|
|
2446
|
+
* @param {string} lorem - Description.
|
|
2447
|
+
* @param {int} sit - Description multi words.
|
|
2448
|
+
*/
|
|
2449
|
+
const fn = ( lorem, sit ) => {}
|
|
2450
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never"]
|
|
2451
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* Function description.
|
|
2455
|
+
*
|
|
2456
|
+
* @param {string} lorem - Description.
|
|
2457
|
+
* @param {int} sit - Description multi words.
|
|
2458
|
+
*/
|
|
2459
|
+
const fn = ( lorem, sit ) => {}
|
|
2460
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postHyphen":2}}]
|
|
2461
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2462
|
+
|
|
2463
|
+
/**
|
|
2464
|
+
* Function description.
|
|
2465
|
+
*
|
|
2466
|
+
* @param {string} lorem - Description.
|
|
2467
|
+
* @param {int} sit - Description multi words.
|
|
2468
|
+
*/
|
|
2469
|
+
const fn = ( lorem, sit ) => {}
|
|
2470
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postHyphen":2}}]
|
|
2471
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2472
|
+
|
|
2473
|
+
/**
|
|
2474
|
+
* Function description.
|
|
2475
|
+
*
|
|
2476
|
+
* @param {string} lorem - Description.
|
|
2477
|
+
* @param {int} sit - Description multi words.
|
|
2478
|
+
*/
|
|
2479
|
+
const fn = ( lorem, sit ) => {}
|
|
2480
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "always",{"customSpacings":{"postHyphen":2}}]
|
|
2481
|
+
// Message: Expected JSDoc block lines to be aligned.
|
|
2482
|
+
|
|
2483
|
+
/**
|
|
2484
|
+
* Function description.
|
|
2485
|
+
*
|
|
2486
|
+
* @param {string} lorem - Description.
|
|
2487
|
+
* @param {int} sit - Description multi words.
|
|
2488
|
+
*/
|
|
2489
|
+
const fn = ( lorem, sit ) => {}
|
|
2490
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "always",{"customSpacings":{"postHyphen":2}}]
|
|
2491
|
+
// Message: Expected JSDoc block lines to be aligned.
|
|
2492
|
+
|
|
2493
|
+
/**
|
|
2494
|
+
* Function description.
|
|
2495
|
+
*
|
|
2496
|
+
* @param {string} lorem - Description.
|
|
2497
|
+
* @param {int} sit - Description multi words.
|
|
2498
|
+
*/
|
|
2499
|
+
const fn = ( lorem, sit ) => {}
|
|
2500
|
+
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postHyphen":2}}]
|
|
2501
|
+
// Message: Expected JSDoc block lines to not be aligned.
|
|
2441
2502
|
````
|
|
2442
2503
|
|
|
2443
2504
|
The following patterns are not considered problems:
|
|
@@ -7845,6 +7906,12 @@ name will actually be part of the description (e.g., for
|
|
|
7845
7906
|
`structuredTags` setting (if `name: false`, this rule will not apply to
|
|
7846
7907
|
that tag).
|
|
7847
7908
|
|
|
7909
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-match-name-fixer"></a>
|
|
7910
|
+
<a name="eslint-plugin-jsdoc-rules-match-name-fixer"></a>
|
|
7911
|
+
#### Fixer
|
|
7912
|
+
|
|
7913
|
+
Will replace `disallowName` with `replacement` if these are provided.
|
|
7914
|
+
|
|
7848
7915
|
<a name="user-content-eslint-plugin-jsdoc-rules-match-name-options-12"></a>
|
|
7849
7916
|
<a name="eslint-plugin-jsdoc-rules-match-name-options-12"></a>
|
|
7850
7917
|
#### Options
|
|
@@ -9692,6 +9759,36 @@ const MyComponent = ({ children }) => {
|
|
|
9692
9759
|
*/
|
|
9693
9760
|
// "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
9761
|
// Message: @type names should only be recognized primitive types or literals
|
|
9762
|
+
|
|
9763
|
+
/**
|
|
9764
|
+
*
|
|
9765
|
+
*/
|
|
9766
|
+
function test(): string { }
|
|
9767
|
+
// "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"}]}]
|
|
9768
|
+
// Message: Functions with non-void return types must have a @returns tag
|
|
9769
|
+
|
|
9770
|
+
/**
|
|
9771
|
+
*
|
|
9772
|
+
*/
|
|
9773
|
+
let test = (): string => { };
|
|
9774
|
+
// "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"}]}]
|
|
9775
|
+
// Message: Functions with non-void return types must have a @returns tag
|
|
9776
|
+
|
|
9777
|
+
/**
|
|
9778
|
+
* @returns
|
|
9779
|
+
*/
|
|
9780
|
+
let test: () => string;
|
|
9781
|
+
// "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"}]}]
|
|
9782
|
+
// Message: FunctionType's with non-void return types must have a @returns tag with a description
|
|
9783
|
+
|
|
9784
|
+
/**
|
|
9785
|
+
*
|
|
9786
|
+
*/
|
|
9787
|
+
class Test {
|
|
9788
|
+
abstract Test(): string;
|
|
9789
|
+
}
|
|
9790
|
+
// "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"}]}]
|
|
9791
|
+
// Message: methods with non-void return types must have a @returns tag
|
|
9695
9792
|
````
|
|
9696
9793
|
|
|
9697
9794
|
The following patterns are not considered problems:
|
|
@@ -9772,6 +9869,32 @@ function foo(): string;
|
|
|
9772
9869
|
* @type {boolean}
|
|
9773
9870
|
*/
|
|
9774
9871
|
// "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"}]}]
|
|
9872
|
+
|
|
9873
|
+
/**
|
|
9874
|
+
*
|
|
9875
|
+
*/
|
|
9876
|
+
function test(): void { }
|
|
9877
|
+
// "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"}]}]
|
|
9878
|
+
|
|
9879
|
+
/**
|
|
9880
|
+
*
|
|
9881
|
+
*/
|
|
9882
|
+
let test = (): undefined => { };
|
|
9883
|
+
// "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"}]}]
|
|
9884
|
+
|
|
9885
|
+
/**
|
|
9886
|
+
* @returns A description
|
|
9887
|
+
*/
|
|
9888
|
+
let test: () => string;
|
|
9889
|
+
// "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"}]}]
|
|
9890
|
+
|
|
9891
|
+
/**
|
|
9892
|
+
*
|
|
9893
|
+
*/
|
|
9894
|
+
class Test {
|
|
9895
|
+
abstract Test(): void;
|
|
9896
|
+
}
|
|
9897
|
+
// "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
9898
|
````
|
|
9776
9899
|
|
|
9777
9900
|
|
|
@@ -10911,15 +11034,24 @@ Requires that block description, explicit `@description`, and
|
|
|
10911
11034
|
|
|
10912
11035
|
* Description must start with an uppercase alphabetical character.
|
|
10913
11036
|
* Paragraphs must start with an uppercase alphabetical character.
|
|
10914
|
-
* Sentences must end with a period.
|
|
11037
|
+
* Sentences must end with a period, question mark, exclamation mark, or triple backticks.
|
|
10915
11038
|
* Every line in a paragraph (except the first) which starts with an uppercase
|
|
10916
11039
|
character must be preceded by a line ending with a period.
|
|
10917
11040
|
* A colon or semi-colon followed by two line breaks is still part of the
|
|
10918
11041
|
containing paragraph (unlike normal dual line breaks).
|
|
10919
|
-
* Text within inline tags `{...}` are not checked for sentence divisions.
|
|
11042
|
+
* Text within inline tags `{...}` or within triple backticks are not checked for sentence divisions.
|
|
10920
11043
|
* Periods after items within the `abbreviations` option array are not treated
|
|
10921
11044
|
as sentence endings.
|
|
10922
11045
|
|
|
11046
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-description-complete-sentence-fixer-1"></a>
|
|
11047
|
+
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-fixer-1"></a>
|
|
11048
|
+
#### Fixer
|
|
11049
|
+
|
|
11050
|
+
If sentences do not end with terminal punctuation, a period will be added.
|
|
11051
|
+
|
|
11052
|
+
If sentences do not start with an uppercase character, the initial
|
|
11053
|
+
letter will be capitalized.
|
|
11054
|
+
|
|
10923
11055
|
<a name="user-content-eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23"></a>
|
|
10924
11056
|
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23"></a>
|
|
10925
11057
|
#### Options
|
|
@@ -10981,7 +11113,7 @@ The following patterns are considered problems:
|
|
|
10981
11113
|
function quux () {
|
|
10982
11114
|
|
|
10983
11115
|
}
|
|
10984
|
-
// Message:
|
|
11116
|
+
// Message: Sentences should start with an uppercase character.
|
|
10985
11117
|
|
|
10986
11118
|
/**
|
|
10987
11119
|
* foo?
|
|
@@ -10989,7 +11121,7 @@ function quux () {
|
|
|
10989
11121
|
function quux () {
|
|
10990
11122
|
|
|
10991
11123
|
}
|
|
10992
|
-
// Message:
|
|
11124
|
+
// Message: Sentences should start with an uppercase character.
|
|
10993
11125
|
|
|
10994
11126
|
/**
|
|
10995
11127
|
* @description foo.
|
|
@@ -10997,7 +11129,7 @@ function quux () {
|
|
|
10997
11129
|
function quux () {
|
|
10998
11130
|
|
|
10999
11131
|
}
|
|
11000
|
-
// Message:
|
|
11132
|
+
// Message: Sentences should start with an uppercase character.
|
|
11001
11133
|
|
|
11002
11134
|
/**
|
|
11003
11135
|
* Foo)
|
|
@@ -11005,7 +11137,7 @@ function quux () {
|
|
|
11005
11137
|
function quux () {
|
|
11006
11138
|
|
|
11007
11139
|
}
|
|
11008
|
-
// Message:
|
|
11140
|
+
// Message: Sentences must end with a period.
|
|
11009
11141
|
|
|
11010
11142
|
/**
|
|
11011
11143
|
* `foo` is a variable
|
|
@@ -11013,7 +11145,7 @@ function quux () {
|
|
|
11013
11145
|
function quux () {
|
|
11014
11146
|
|
|
11015
11147
|
}
|
|
11016
|
-
// Message:
|
|
11148
|
+
// Message: Sentences must end with a period.
|
|
11017
11149
|
|
|
11018
11150
|
/**
|
|
11019
11151
|
* Foo.
|
|
@@ -11023,7 +11155,7 @@ function quux () {
|
|
|
11023
11155
|
function quux () {
|
|
11024
11156
|
|
|
11025
11157
|
}
|
|
11026
|
-
// Message:
|
|
11158
|
+
// Message: Sentences should start with an uppercase character.
|
|
11027
11159
|
|
|
11028
11160
|
/**
|
|
11029
11161
|
* тест.
|
|
@@ -11031,7 +11163,7 @@ function quux () {
|
|
|
11031
11163
|
function quux () {
|
|
11032
11164
|
|
|
11033
11165
|
}
|
|
11034
|
-
// Message:
|
|
11166
|
+
// Message: Sentences should start with an uppercase character.
|
|
11035
11167
|
|
|
11036
11168
|
/**
|
|
11037
11169
|
* Foo
|
|
@@ -11039,7 +11171,7 @@ function quux () {
|
|
|
11039
11171
|
function quux () {
|
|
11040
11172
|
|
|
11041
11173
|
}
|
|
11042
|
-
// Message:
|
|
11174
|
+
// Message: Sentences must end with a period.
|
|
11043
11175
|
|
|
11044
11176
|
/**
|
|
11045
11177
|
* Foo
|
|
@@ -11049,7 +11181,7 @@ function quux () {
|
|
|
11049
11181
|
function quux () {
|
|
11050
11182
|
|
|
11051
11183
|
}
|
|
11052
|
-
// Message:
|
|
11184
|
+
// Message: Sentences must end with a period.
|
|
11053
11185
|
|
|
11054
11186
|
/**
|
|
11055
11187
|
* Foo
|
|
@@ -11059,7 +11191,7 @@ function quux () {
|
|
|
11059
11191
|
|
|
11060
11192
|
}
|
|
11061
11193
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"newlineBeforeCapsAssumesBadSentenceEnd":true}]
|
|
11062
|
-
// Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
|
|
11194
|
+
// Message: A line of text is started with an uppercase character, but the preceding line does not end the sentence.
|
|
11063
11195
|
|
|
11064
11196
|
/**
|
|
11065
11197
|
* Foo.
|
|
@@ -11069,7 +11201,7 @@ function quux () {
|
|
|
11069
11201
|
function quux (foo) {
|
|
11070
11202
|
|
|
11071
11203
|
}
|
|
11072
|
-
// Message:
|
|
11204
|
+
// Message: Sentences should start with an uppercase character.
|
|
11073
11205
|
|
|
11074
11206
|
/**
|
|
11075
11207
|
* Foo.
|
|
@@ -11079,7 +11211,7 @@ function quux (foo) {
|
|
|
11079
11211
|
function quux (foo) {
|
|
11080
11212
|
|
|
11081
11213
|
}
|
|
11082
|
-
// Message:
|
|
11214
|
+
// Message: Sentences should start with an uppercase character.
|
|
11083
11215
|
|
|
11084
11216
|
/**
|
|
11085
11217
|
* {@see Foo.bar} buz
|
|
@@ -11087,7 +11219,7 @@ function quux (foo) {
|
|
|
11087
11219
|
function quux (foo) {
|
|
11088
11220
|
|
|
11089
11221
|
}
|
|
11090
|
-
// Message:
|
|
11222
|
+
// Message: Sentences should start with an uppercase character.
|
|
11091
11223
|
|
|
11092
11224
|
/**
|
|
11093
11225
|
* Foo.
|
|
@@ -11097,7 +11229,7 @@ function quux (foo) {
|
|
|
11097
11229
|
function quux (foo) {
|
|
11098
11230
|
|
|
11099
11231
|
}
|
|
11100
|
-
// Message:
|
|
11232
|
+
// Message: Sentences should start with an uppercase character.
|
|
11101
11233
|
|
|
11102
11234
|
/**
|
|
11103
11235
|
* Foo.
|
|
@@ -11107,7 +11239,7 @@ function quux (foo) {
|
|
|
11107
11239
|
function quux (foo) {
|
|
11108
11240
|
|
|
11109
11241
|
}
|
|
11110
|
-
// Message:
|
|
11242
|
+
// Message: Sentences should start with an uppercase character.
|
|
11111
11243
|
|
|
11112
11244
|
/**
|
|
11113
11245
|
* lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
|
|
@@ -11120,7 +11252,7 @@ function quux (foo) {
|
|
|
11120
11252
|
function longDescription (foo) {
|
|
11121
11253
|
|
|
11122
11254
|
}
|
|
11123
|
-
// Message:
|
|
11255
|
+
// Message: Sentences should start with an uppercase character.
|
|
11124
11256
|
|
|
11125
11257
|
/**
|
|
11126
11258
|
* @arg {number} foo - Foo
|
|
@@ -11128,7 +11260,7 @@ function longDescription (foo) {
|
|
|
11128
11260
|
function quux (foo) {
|
|
11129
11261
|
|
|
11130
11262
|
}
|
|
11131
|
-
// Message:
|
|
11263
|
+
// Message: Sentences must end with a period.
|
|
11132
11264
|
|
|
11133
11265
|
/**
|
|
11134
11266
|
* @argument {number} foo - Foo
|
|
@@ -11136,7 +11268,7 @@ function quux (foo) {
|
|
|
11136
11268
|
function quux (foo) {
|
|
11137
11269
|
|
|
11138
11270
|
}
|
|
11139
|
-
// Message:
|
|
11271
|
+
// Message: Sentences must end with a period.
|
|
11140
11272
|
|
|
11141
11273
|
/**
|
|
11142
11274
|
* @return {number} foo
|
|
@@ -11144,7 +11276,7 @@ function quux (foo) {
|
|
|
11144
11276
|
function quux (foo) {
|
|
11145
11277
|
|
|
11146
11278
|
}
|
|
11147
|
-
// Message:
|
|
11279
|
+
// Message: Sentences should start with an uppercase character.
|
|
11148
11280
|
|
|
11149
11281
|
/**
|
|
11150
11282
|
* Returns bar.
|
|
@@ -11154,13 +11286,13 @@ function quux (foo) {
|
|
|
11154
11286
|
function quux (foo) {
|
|
11155
11287
|
|
|
11156
11288
|
}
|
|
11157
|
-
// Message:
|
|
11289
|
+
// Message: Sentences should start with an uppercase character.
|
|
11158
11290
|
|
|
11159
11291
|
/**
|
|
11160
11292
|
* @throws {object} Hello World
|
|
11161
11293
|
* hello world
|
|
11162
11294
|
*/
|
|
11163
|
-
// Message:
|
|
11295
|
+
// Message: Sentences must end with a period.
|
|
11164
11296
|
|
|
11165
11297
|
/**
|
|
11166
11298
|
* @summary Foo
|
|
@@ -11168,7 +11300,7 @@ function quux (foo) {
|
|
|
11168
11300
|
function quux () {
|
|
11169
11301
|
|
|
11170
11302
|
}
|
|
11171
|
-
// Message:
|
|
11303
|
+
// Message: Sentences must end with a period.
|
|
11172
11304
|
|
|
11173
11305
|
/**
|
|
11174
11306
|
* @throws {SomeType} Foo
|
|
@@ -11176,7 +11308,7 @@ function quux () {
|
|
|
11176
11308
|
function quux () {
|
|
11177
11309
|
|
|
11178
11310
|
}
|
|
11179
|
-
// Message:
|
|
11311
|
+
// Message: Sentences must end with a period.
|
|
11180
11312
|
|
|
11181
11313
|
/**
|
|
11182
11314
|
* @see Foo
|
|
@@ -11185,7 +11317,7 @@ function quux () {
|
|
|
11185
11317
|
|
|
11186
11318
|
}
|
|
11187
11319
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["see"]}]
|
|
11188
|
-
// Message:
|
|
11320
|
+
// Message: Sentences must end with a period.
|
|
11189
11321
|
|
|
11190
11322
|
/**
|
|
11191
11323
|
* @param foo Foo bar
|
|
@@ -11195,7 +11327,7 @@ function quux (foo) {
|
|
|
11195
11327
|
}
|
|
11196
11328
|
// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
|
|
11197
11329
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["param"]}]
|
|
11198
|
-
// Message:
|
|
11330
|
+
// Message: Sentences must end with a period.
|
|
11199
11331
|
|
|
11200
11332
|
/**
|
|
11201
11333
|
* Sorry, but this isn't a complete sentence, Mr.
|
|
@@ -11204,7 +11336,7 @@ function quux () {
|
|
|
11204
11336
|
|
|
11205
11337
|
}
|
|
11206
11338
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
|
|
11207
|
-
// Message:
|
|
11339
|
+
// Message: Sentences must end with a period.
|
|
11208
11340
|
|
|
11209
11341
|
/**
|
|
11210
11342
|
* Sorry, but this isn't a complete sentence Mr.
|
|
@@ -11213,7 +11345,7 @@ function quux () {
|
|
|
11213
11345
|
|
|
11214
11346
|
}
|
|
11215
11347
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr."]}]
|
|
11216
|
-
// Message:
|
|
11348
|
+
// Message: Sentences must end with a period.
|
|
11217
11349
|
|
|
11218
11350
|
/**
|
|
11219
11351
|
* Sorry, but this isn't a complete sentence Mr.
|
|
@@ -11222,7 +11354,7 @@ function quux () {
|
|
|
11222
11354
|
|
|
11223
11355
|
}
|
|
11224
11356
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
|
|
11225
|
-
// Message:
|
|
11357
|
+
// Message: Sentences must end with a period.
|
|
11226
11358
|
|
|
11227
11359
|
/**
|
|
11228
11360
|
* Sorry, but this isn't a complete sentence Mr. and Mrs.
|
|
@@ -11231,7 +11363,7 @@ function quux () {
|
|
|
11231
11363
|
|
|
11232
11364
|
}
|
|
11233
11365
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr","Mrs"]}]
|
|
11234
|
-
// Message:
|
|
11366
|
+
// Message: Sentences must end with a period.
|
|
11235
11367
|
|
|
11236
11368
|
/**
|
|
11237
11369
|
* This is a complete sentence. But this isn't, Mr.
|
|
@@ -11240,7 +11372,7 @@ function quux () {
|
|
|
11240
11372
|
|
|
11241
11373
|
}
|
|
11242
11374
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
|
|
11243
|
-
// Message:
|
|
11375
|
+
// Message: Sentences must end with a period.
|
|
11244
11376
|
|
|
11245
11377
|
/**
|
|
11246
11378
|
* This is a complete Mr. sentence. But this isn't, Mr.
|
|
@@ -11249,7 +11381,7 @@ function quux () {
|
|
|
11249
11381
|
|
|
11250
11382
|
}
|
|
11251
11383
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
|
|
11252
|
-
// Message:
|
|
11384
|
+
// Message: Sentences must end with a period.
|
|
11253
11385
|
|
|
11254
11386
|
/**
|
|
11255
11387
|
* This is a complete Mr. sentence.
|
|
@@ -11257,7 +11389,7 @@ function quux () {
|
|
|
11257
11389
|
function quux () {
|
|
11258
11390
|
|
|
11259
11391
|
}
|
|
11260
|
-
// Message:
|
|
11392
|
+
// Message: Sentences should start with an uppercase character.
|
|
11261
11393
|
|
|
11262
11394
|
/**
|
|
11263
11395
|
* This is fun, i.e. enjoyable, but not superlatively so, e.g. not
|
|
@@ -11266,7 +11398,7 @@ function quux () {
|
|
|
11266
11398
|
function quux () {
|
|
11267
11399
|
|
|
11268
11400
|
}
|
|
11269
|
-
// Message:
|
|
11401
|
+
// Message: Sentences should start with an uppercase character.
|
|
11270
11402
|
|
|
11271
11403
|
/**
|
|
11272
11404
|
* Do not have dynamic content; e.g. homepage. Here a simple unique id
|
|
@@ -11275,7 +11407,7 @@ function quux () {
|
|
|
11275
11407
|
function quux () {
|
|
11276
11408
|
|
|
11277
11409
|
}
|
|
11278
|
-
// Message:
|
|
11410
|
+
// Message: Sentences should start with an uppercase character.
|
|
11279
11411
|
|
|
11280
11412
|
/**
|
|
11281
11413
|
* Implements support for the
|
|
@@ -11284,7 +11416,7 @@ function quux () {
|
|
|
11284
11416
|
function speak() {
|
|
11285
11417
|
}
|
|
11286
11418
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"newlineBeforeCapsAssumesBadSentenceEnd":true}]
|
|
11287
|
-
// Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
|
|
11419
|
+
// Message: A line of text is started with an uppercase character, but the preceding line does not end the sentence.
|
|
11288
11420
|
|
|
11289
11421
|
/**
|
|
11290
11422
|
* Foo.
|
|
@@ -11295,7 +11427,7 @@ function quux (foo) {
|
|
|
11295
11427
|
|
|
11296
11428
|
}
|
|
11297
11429
|
// "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["template"]}]
|
|
11298
|
-
// Message:
|
|
11430
|
+
// Message: Sentences should start with an uppercase character.
|
|
11299
11431
|
|
|
11300
11432
|
/**
|
|
11301
11433
|
* Just a component.
|
|
@@ -11303,7 +11435,7 @@ function quux (foo) {
|
|
|
11303
11435
|
* @return {ReactElement}.
|
|
11304
11436
|
*/
|
|
11305
11437
|
function quux () {}
|
|
11306
|
-
// Message:
|
|
11438
|
+
// Message: Sentences must be more than punctuation.
|
|
11307
11439
|
````
|
|
11308
11440
|
|
|
11309
11441
|
The following patterns are not considered problems:
|
|
@@ -11641,6 +11773,47 @@ export default (foo) => {
|
|
|
11641
11773
|
*/
|
|
11642
11774
|
function quux () {
|
|
11643
11775
|
|
|
11776
|
+
}
|
|
11777
|
+
|
|
11778
|
+
/**
|
|
11779
|
+
* He wanted a few items: a jacket and shirt...
|
|
11780
|
+
*/
|
|
11781
|
+
function quux () {
|
|
11782
|
+
|
|
11783
|
+
}
|
|
11784
|
+
|
|
11785
|
+
/**
|
|
11786
|
+
* The code in question was...
|
|
11787
|
+
* ```
|
|
11788
|
+
* alert('hello');
|
|
11789
|
+
* ```
|
|
11790
|
+
*/
|
|
11791
|
+
function quux () {
|
|
11792
|
+
|
|
11793
|
+
}
|
|
11794
|
+
|
|
11795
|
+
/**
|
|
11796
|
+
* @param {number|string|Date|Object|OverType|WhateverElse} multiType -
|
|
11797
|
+
* Nice long explanation...
|
|
11798
|
+
*/
|
|
11799
|
+
function test (multiType) {
|
|
11800
|
+
}
|
|
11801
|
+
|
|
11802
|
+
/**
|
|
11803
|
+
* Any kind of fowl (e.g., a duck).
|
|
11804
|
+
*/
|
|
11805
|
+
function quux () {}
|
|
11806
|
+
|
|
11807
|
+
/**
|
|
11808
|
+
* The code in question was...
|
|
11809
|
+
* ```
|
|
11810
|
+
* do something
|
|
11811
|
+
*
|
|
11812
|
+
* interesting
|
|
11813
|
+
* ```
|
|
11814
|
+
*/
|
|
11815
|
+
function quux () {
|
|
11816
|
+
|
|
11644
11817
|
}
|
|
11645
11818
|
````
|
|
11646
11819
|
|
|
@@ -12272,8 +12445,8 @@ A value indicating whether setters should be checked. Defaults to `false`.
|
|
|
12272
12445
|
A boolean on whether to enable the fixer (which adds an empty `@example` block).
|
|
12273
12446
|
Defaults to `true`.
|
|
12274
12447
|
|
|
12275
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-example-fixer"></a>
|
|
12276
|
-
<a name="eslint-plugin-jsdoc-rules-require-example-fixer"></a>
|
|
12448
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-example-fixer-2"></a>
|
|
12449
|
+
<a name="eslint-plugin-jsdoc-rules-require-example-fixer-2"></a>
|
|
12277
12450
|
#### Fixer
|
|
12278
12451
|
|
|
12279
12452
|
The fixer for `require-example` will add an empty `@example`, but it will still
|
|
@@ -15456,16 +15629,16 @@ function quux (foo, {bar: {baz}}) {
|
|
|
15456
15629
|
|
|
15457
15630
|
Requires that all function parameters are documented.
|
|
15458
15631
|
|
|
15459
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15460
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15632
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3"></a>
|
|
15633
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3"></a>
|
|
15461
15634
|
#### Fixer
|
|
15462
15635
|
|
|
15463
15636
|
Adds `@param <name>` for each tag present in the function signature but
|
|
15464
15637
|
missing in the jsdoc. Can be disabled by setting the `enableFixer`
|
|
15465
15638
|
option to `false`.
|
|
15466
15639
|
|
|
15467
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15468
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15640
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-destructured-object-and-array-naming"></a>
|
|
15641
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-destructured-object-and-array-naming"></a>
|
|
15469
15642
|
##### Destructured object and array naming
|
|
15470
15643
|
|
|
15471
15644
|
When the fixer is applied to destructured objects, only the input name is
|
|
@@ -15517,8 +15690,8 @@ function quux ([foo, bar]) {
|
|
|
15517
15690
|
*/
|
|
15518
15691
|
```
|
|
15519
15692
|
|
|
15520
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15521
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15693
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-missing-root-fixing"></a>
|
|
15694
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-missing-root-fixing"></a>
|
|
15522
15695
|
##### Missing root fixing
|
|
15523
15696
|
|
|
15524
15697
|
Note that unless `enableRootFixer` (or `enableFixer`) is set to `false`,
|
|
@@ -15553,8 +15726,8 @@ numeric component).
|
|
|
15553
15726
|
And one can have the count begin at another number (e.g., `1`) by changing
|
|
15554
15727
|
`autoIncrementBase` from the default of `0`.
|
|
15555
15728
|
|
|
15556
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15557
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15729
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-rest-element-restelement-insertions"></a>
|
|
15730
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-rest-element-restelement-insertions"></a>
|
|
15558
15731
|
##### Rest Element (<code>RestElement</code>) insertions
|
|
15559
15732
|
|
|
15560
15733
|
The fixer will automatically report/insert
|
|
@@ -15606,8 +15779,8 @@ function baar ([a, ...extra]) {
|
|
|
15606
15779
|
|
|
15607
15780
|
...because it does not use the `...` syntax in the type.
|
|
15608
15781
|
|
|
15609
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15610
|
-
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-
|
|
15782
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-param-fixer-3-object-rest-property-insertions"></a>
|
|
15783
|
+
<a name="eslint-plugin-jsdoc-rules-require-param-fixer-3-object-rest-property-insertions"></a>
|
|
15611
15784
|
##### Object Rest Property insertions
|
|
15612
15785
|
|
|
15613
15786
|
If the `checkRestProperty` option is set to `true` (`false` by default),
|
|
@@ -17237,8 +17410,8 @@ when their type is a plain `object`, `Object`, or `PlainObject`.
|
|
|
17237
17410
|
Note that any other type, including a subtype of object such as
|
|
17238
17411
|
`object<string, string>`, will not be reported.
|
|
17239
17412
|
|
|
17240
|
-
<a name="user-content-eslint-plugin-jsdoc-rules-require-property-fixer-
|
|
17241
|
-
<a name="eslint-plugin-jsdoc-rules-require-property-fixer-
|
|
17413
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-require-property-fixer-4"></a>
|
|
17414
|
+
<a name="eslint-plugin-jsdoc-rules-require-property-fixer-4"></a>
|
|
17242
17415
|
#### Fixer
|
|
17243
17416
|
|
|
17244
17417
|
The fixer for `require-property` will add an empty `@property`.
|
|
@@ -22523,7 +22696,8 @@ The following tags have their name/namepath portion (the non-whitespace
|
|
|
22523
22696
|
text after the tag name) checked:
|
|
22524
22697
|
|
|
22525
22698
|
1. Name(path)-defining tags requiring namepath: `@event`, `@callback`,
|
|
22526
|
-
`@
|
|
22699
|
+
`@exports` (JSDoc only),
|
|
22700
|
+
`@external`, `@host`, `@name`, `@typedef` (JSDoc only), and `@template`
|
|
22527
22701
|
(TypeScript/Closure only); `@param` (`@arg`, `@argument`) and `@property`
|
|
22528
22702
|
(`@prop`) also fall into this category, but while this rule will check
|
|
22529
22703
|
their namepath validity, we leave the requiring of the name portion
|
|
@@ -22532,11 +22706,11 @@ text after the tag name) checked:
|
|
|
22532
22706
|
1. Name(path)-defining tags (which may have value without namepath or their
|
|
22533
22707
|
namepath can be expressed elsewhere on the block):
|
|
22534
22708
|
`@class`, `@constructor`, `@constant`, `@const`, `@function`, `@func`,
|
|
22535
|
-
`@method`, `@interface` (
|
|
22709
|
+
`@method`, `@interface` (non-Closure only), `@member`, `@var`,
|
|
22536
22710
|
`@mixin`, `@namespace`, `@module` (module paths are not planned for
|
|
22537
22711
|
TypeScript)
|
|
22538
22712
|
1. Name(path)-pointing tags requiring namepath: `@alias`, `@augments`,
|
|
22539
|
-
`@extends
|
|
22713
|
+
`@extends` (JSDoc only), `@lends`, `@memberof`, `@memberof!`, `@mixes`, `@requires`, `@this`
|
|
22540
22714
|
(jsdoc only)
|
|
22541
22715
|
1. Name(path)-pointing tags (which may have value without namepath or their
|
|
22542
22716
|
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;AAC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T,IAAI,CAAC,EAAE;MACpC,GAAGN;IACL,CAAC,CAAC;IAEF,MAAMuC,YAAY,GAAGjB,eAAe,CAACC,MAAM,CAAC;IAE5C,OAAOzB,YAAY,CAAC;MAClB,GAAGyB,MAAM;MACTf,MAAM,EAAEA,MAAM,CAACmB,GAAG,CAAC,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,OA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AAM,CAACiC,WAAW,CAAChC,OAAO,CAC7C8C,aAAa,EAAE,GAAG,GAAG,EAAE,CAACxB,QAAQ,CAACsB,iBAAiB,EAAE,GAAG,CAAC,CACzD;;IAED;IACA,IAAI,CAACjD,WAAW,CAACC,IAAI,EAAEC,KAAK,EAAEC,MAAM,CAAC,EAAE;MACrC,OAAO;QACL,GAAG2C,IAAI;QACP1C;MACF,CAAC;IACH;IAEA,OAAO;MACL,GAAG0C,IAAI;MACP1C,MAAM,EAAE6B,WAAW,CAAC7B,MAAM,EAAE8B,YAAY;IAC1C,CAAC;EACH,CAAC;EAED,OAAO,CAAC;IACN/B,MAAM;IACN,GAAGe;EACL,CAAC,KAAK;IACJP,KAAK,GAAGR,MAAM,CAACiD,MAAM,CAAC1C,QAAQ,CAACT,IAAI,CAAC,EAAE;MACpC,GAAGN;IACL,CAAC,CAAC;IAEF,MAAMuC,YAAY,GAAGjB,eAAe,CAACC,MAAM,CAAC;IAE5C,OAAOzB,YAAY,CAAC;MAClB,GAAGyB,MAAM;MACTf,MAAM,EAAEA,MAAM,CAACmB,GAAG,CAAC,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"}
|
|
@@ -51,6 +51,10 @@ const checkNotAlignedPerTag = (utils, tag, customSpacings) => {
|
|
|
51
51
|
return ret && (callbck || !contentProp);
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
|
+
const postHyphenSpacing = (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postHyphen) ?? 1;
|
|
55
|
+
const exactHyphenSpacing = new RegExp(`^\\s*-\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\s)`, 'u');
|
|
56
|
+
const hasNoHyphen = !/^\s*-/u.test(tokens.description);
|
|
57
|
+
const hasExactHyphenSpacing = exactHyphenSpacing.test(tokens.description);
|
|
54
58
|
|
|
55
59
|
// If checking alignment on multiple lines, need to check other `source`
|
|
56
60
|
// items
|
|
@@ -69,7 +73,7 @@ const checkNotAlignedPerTag = (utils, tag, customSpacings) => {
|
|
|
69
73
|
// 2. There is a (single) space, no immediate content, and yet another
|
|
70
74
|
// space is found subsequently (not separated by intervening content)
|
|
71
75
|
spacerPropVal && !contentPropVal && followedBySpace(idx);
|
|
72
|
-
});
|
|
76
|
+
}) && (hasNoHyphen || hasExactHyphenSpacing);
|
|
73
77
|
if (ok) {
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
@@ -89,6 +93,10 @@ const checkNotAlignedPerTag = (utils, tag, customSpacings) => {
|
|
|
89
93
|
tokens[spacerProp] = '';
|
|
90
94
|
}
|
|
91
95
|
}
|
|
96
|
+
if (!hasExactHyphenSpacing) {
|
|
97
|
+
const hyphenSpacing = /^\s*-\s*/u;
|
|
98
|
+
tokens.description = tokens.description.replace(hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '));
|
|
99
|
+
}
|
|
92
100
|
utils.setTag(tag, tokens);
|
|
93
101
|
};
|
|
94
102
|
utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);
|
|
@@ -172,6 +180,9 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
172
180
|
postDelimiter: {
|
|
173
181
|
type: 'integer'
|
|
174
182
|
},
|
|
183
|
+
postHyphen: {
|
|
184
|
+
type: 'integer'
|
|
185
|
+
},
|
|
175
186
|
postName: {
|
|
176
187
|
type: 'integer'
|
|
177
188
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkLineAlignment.js","names":["flow","commentFlow","transforms","checkNotAlignedPerTag","utils","tag","customSpacings","spacerProps","contentProps","mightHaveNamepath","tagMightHaveNamepath","tokens","source","followedBySpace","idx","callbck","nextIndex","slice","some","spacerProp","innerIdx","contentProp","spacePropVal","ret","ok","contentPropVal","spacerPropVal","spacing","length","fix","entries","padStart","hasSpace","contentPrp","setTag","reportJSDoc","checkAlignment","indent","jsdoc","jsdocNode","preserveMainDescriptionPostDelimiter","report","tags","transform","alignTransform","transformedJsdoc","comment","value","formatted","stringify","trimStart","fixer","replaceText","iterateJsdoc","context","applicableTags","options","includes","foundTags","getPresentTags","iterateAllJsdocs","meta","docs","description","url","fixable","schema","enum","type","additionalProperties","properties","postDelimiter","postName","postTag","postType","default","items"],"sources":["../../src/rules/checkLineAlignment.js"],"sourcesContent":["import {\n transforms,\n} from 'comment-parser';\nimport alignTransform from '../alignTransform';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst {\n flow: commentFlow,\n} = transforms;\n\nconst checkNotAlignedPerTag = (utils, tag, customSpacings) => {\n /*\n start +\n delimiter +\n postDelimiter +\n tag +\n postTag +\n type +\n postType +\n name +\n postName +\n description +\n end +\n lineEnd\n */\n let spacerProps;\n let contentProps;\n const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag);\n if (mightHaveNamepath) {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType', 'postName',\n ];\n contentProps = [\n 'tag', 'type', 'name', 'description',\n ];\n } else {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType',\n ];\n contentProps = [\n 'tag', 'type', 'description',\n ];\n }\n\n const {\n tokens,\n } = tag.source[0];\n\n const followedBySpace = (idx, callbck) => {\n const nextIndex = idx + 1;\n\n return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => {\n const contentProp = contentProps[nextIndex + innerIdx];\n\n const spacePropVal = tokens[spacerProp];\n\n const ret = spacePropVal;\n\n if (callbck) {\n callbck(!ret, contentProp);\n }\n\n return ret && (callbck || !contentProp);\n });\n };\n\n // If checking alignment on multiple lines, need to check other `source`\n // items\n // Go through `post*` spacing properties and exit to indicate problem if\n // extra spacing detected\n const ok = !spacerProps.some((spacerProp, idx) => {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n const spacerPropVal = tokens[spacerProp];\n const spacing = customSpacings?.[spacerProp] || 1;\n\n // There will be extra alignment if...\n\n // 1. The spaces don't match the space it should have (1 or custom spacing) OR\n return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 ||\n\n // 2. There is a (single) space, no immediate content, and yet another\n // space is found subsequently (not separated by intervening content)\n spacerPropVal && !contentPropVal && followedBySpace(idx);\n });\n if (ok) {\n return;\n }\n\n const fix = () => {\n for (const [\n idx,\n spacerProp,\n ] of spacerProps.entries()) {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n\n if (contentPropVal) {\n const spacing = customSpacings?.[spacerProp] || 1;\n tokens[spacerProp] = ''.padStart(spacing, ' ');\n followedBySpace(idx, (hasSpace, contentPrp) => {\n if (hasSpace) {\n tokens[contentPrp] = '';\n }\n });\n } else {\n tokens[spacerProp] = '';\n }\n }\n\n utils.setTag(tag, tokens);\n };\n\n utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);\n};\n\nconst checkAlignment = ({\n customSpacings,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags,\n utils,\n}) => {\n const transform = commentFlow(\n alignTransform({\n customSpacings,\n indent,\n preserveMainDescriptionPostDelimiter,\n tags,\n }),\n );\n const transformedJsdoc = transform(jsdoc);\n\n const comment = '/*' + jsdocNode.value + '*/';\n const formatted = utils.stringify(transformedJsdoc)\n .trimStart();\n\n if (comment !== formatted) {\n report(\n 'Expected JSDoc block lines to be aligned.',\n (fixer) => {\n return fixer.replaceText(jsdocNode, formatted);\n },\n );\n }\n};\n\nexport default iterateJsdoc(({\n indent,\n jsdoc,\n jsdocNode,\n report,\n context,\n utils,\n}) => {\n const {\n tags: applicableTags = [\n 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return',\n ],\n preserveMainDescriptionPostDelimiter,\n customSpacings,\n } = context.options[1] || {};\n\n if (context.options[0] === 'always') {\n // Skip if it contains only a single line.\n if (!jsdocNode.value.includes('\\n')) {\n return;\n }\n\n checkAlignment({\n customSpacings,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags: applicableTags,\n utils,\n });\n\n return;\n }\n\n const foundTags = utils.getPresentTags(applicableTags);\n for (const tag of foundTags) {\n checkNotAlignedPerTag(utils, tag, customSpacings);\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block lines.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-line-alignment',\n },\n fixable: 'whitespace',\n schema: [\n {\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n customSpacings: {\n additionalProperties: false,\n properties: {\n postDelimiter: {\n type: 'integer',\n },\n postName: {\n type: 'integer',\n },\n postTag: {\n type: 'integer',\n },\n postType: {\n type: 'integer',\n },\n },\n },\n preserveMainDescriptionPostDelimiter: {\n default: false,\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA;AAGA;AACA;AAA2C;AAE3C,MAAM;EACJA,IAAI,EAAEC;AACR,CAAC,GAAGC,yBAAU;AAEd,MAAMC,qBAAqB,GAAG,CAACC,KAAK,EAAEC,GAAG,EAAEC,cAAc,KAAK;EAC5D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,WAAW;EACf,IAAIC,YAAY;EAChB,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,oBAAoB,CAACL,GAAG,CAACA,GAAG,CAAC;EAC7D,IAAII,iBAAiB,EAAE;IACrBF,WAAW,GAAG,CACZ,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CACnD;IACDC,YAAY,GAAG,CACb,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CACrC;EACH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,CAAC,EAAE;EACDsD,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,iDAAiD;MAC9DC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,YAAY;IACrBC,MAAM,EAAE,CACN;MACEC,IAAI,EAAE,CACJ,QAAQ,EAAE,OAAO,CAClB;MACDC,IAAI,EAAE;IACR,CAAC,EACD;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVhE,cAAc,EAAE;UACd+D,oBAAoB,EAAE,KAAK;UAC3BC,UAAU,EAAE;YACVC,aAAa,EAAE;cACbH,IAAI,EAAE;YACR,CAAC;YACDI,QAAQ,EAAE;cACRJ,IAAI,EAAE;YACR,CAAC;YACDK,OAAO,EAAE;cACPL,IAAI,EAAE;YACR,CAAC;YACDM,QAAQ,EAAE;cACRN,IAAI,EAAE;YACR;UACF;QACF,CAAC;QACD5B,oCAAoC,EAAE;UACpCmC,OAAO,EAAE,KAAK;UACdP,IAAI,EAAE;QACR,CAAC;QACD1B,IAAI,EAAE;UACJkC,KAAK,EAAE;YACLR,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"checkLineAlignment.js","names":["flow","commentFlow","transforms","checkNotAlignedPerTag","utils","tag","customSpacings","spacerProps","contentProps","mightHaveNamepath","tagMightHaveNamepath","tokens","source","followedBySpace","idx","callbck","nextIndex","slice","some","spacerProp","innerIdx","contentProp","spacePropVal","ret","postHyphenSpacing","postHyphen","exactHyphenSpacing","RegExp","hasNoHyphen","test","description","hasExactHyphenSpacing","ok","contentPropVal","spacerPropVal","spacing","length","fix","entries","padStart","hasSpace","contentPrp","hyphenSpacing","replace","setTag","reportJSDoc","checkAlignment","indent","jsdoc","jsdocNode","preserveMainDescriptionPostDelimiter","report","tags","transform","alignTransform","transformedJsdoc","comment","value","formatted","stringify","trimStart","fixer","replaceText","iterateJsdoc","context","applicableTags","options","includes","foundTags","getPresentTags","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type","additionalProperties","properties","postDelimiter","postName","postTag","postType","default","items"],"sources":["../../src/rules/checkLineAlignment.js"],"sourcesContent":["import {\n transforms,\n} from 'comment-parser';\nimport alignTransform from '../alignTransform';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst {\n flow: commentFlow,\n} = transforms;\n\nconst checkNotAlignedPerTag = (utils, tag, customSpacings) => {\n /*\n start +\n delimiter +\n postDelimiter +\n tag +\n postTag +\n type +\n postType +\n name +\n postName +\n description +\n end +\n lineEnd\n */\n let spacerProps;\n let contentProps;\n const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag);\n if (mightHaveNamepath) {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType', 'postName',\n ];\n contentProps = [\n 'tag', 'type', 'name', 'description',\n ];\n } else {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType',\n ];\n contentProps = [\n 'tag', 'type', 'description',\n ];\n }\n\n const {\n tokens,\n } = tag.source[0];\n\n const followedBySpace = (idx, callbck) => {\n const nextIndex = idx + 1;\n\n return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => {\n const contentProp = contentProps[nextIndex + innerIdx];\n\n const spacePropVal = tokens[spacerProp];\n\n const ret = spacePropVal;\n\n if (callbck) {\n callbck(!ret, contentProp);\n }\n\n return ret && (callbck || !contentProp);\n });\n };\n\n const postHyphenSpacing = customSpacings?.postHyphen ?? 1;\n const exactHyphenSpacing = new RegExp(`^\\\\s*-\\\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\\\s)`, 'u');\n const hasNoHyphen = !(/^\\s*-/u).test(tokens.description);\n const hasExactHyphenSpacing = exactHyphenSpacing.test(\n tokens.description,\n );\n\n // If checking alignment on multiple lines, need to check other `source`\n // items\n // Go through `post*` spacing properties and exit to indicate problem if\n // extra spacing detected\n const ok = !spacerProps.some((spacerProp, idx) => {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n const spacerPropVal = tokens[spacerProp];\n const spacing = customSpacings?.[spacerProp] || 1;\n\n // There will be extra alignment if...\n\n // 1. The spaces don't match the space it should have (1 or custom spacing) OR\n return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 ||\n\n // 2. There is a (single) space, no immediate content, and yet another\n // space is found subsequently (not separated by intervening content)\n spacerPropVal && !contentPropVal && followedBySpace(idx);\n }) && (hasNoHyphen || hasExactHyphenSpacing);\n if (ok) {\n return;\n }\n\n const fix = () => {\n for (const [\n idx,\n spacerProp,\n ] of spacerProps.entries()) {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n\n if (contentPropVal) {\n const spacing = customSpacings?.[spacerProp] || 1;\n tokens[spacerProp] = ''.padStart(spacing, ' ');\n followedBySpace(idx, (hasSpace, contentPrp) => {\n if (hasSpace) {\n tokens[contentPrp] = '';\n }\n });\n } else {\n tokens[spacerProp] = '';\n }\n }\n\n if (!hasExactHyphenSpacing) {\n const hyphenSpacing = /^\\s*-\\s*/u;\n tokens.description = tokens.description.replace(\n hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '),\n );\n }\n\n utils.setTag(tag, tokens);\n };\n\n utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);\n};\n\nconst checkAlignment = ({\n customSpacings,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags,\n utils,\n}) => {\n const transform = commentFlow(\n alignTransform({\n customSpacings,\n indent,\n preserveMainDescriptionPostDelimiter,\n tags,\n }),\n );\n const transformedJsdoc = transform(jsdoc);\n\n const comment = '/*' + jsdocNode.value + '*/';\n const formatted = utils.stringify(transformedJsdoc)\n .trimStart();\n\n if (comment !== formatted) {\n report(\n 'Expected JSDoc block lines to be aligned.',\n (fixer) => {\n return fixer.replaceText(jsdocNode, formatted);\n },\n );\n }\n};\n\nexport default iterateJsdoc(({\n indent,\n jsdoc,\n jsdocNode,\n report,\n context,\n utils,\n}) => {\n const {\n tags: applicableTags = [\n 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return',\n ],\n preserveMainDescriptionPostDelimiter,\n customSpacings,\n } = context.options[1] || {};\n\n if (context.options[0] === 'always') {\n // Skip if it contains only a single line.\n if (!jsdocNode.value.includes('\\n')) {\n return;\n }\n\n checkAlignment({\n customSpacings,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags: applicableTags,\n utils,\n });\n\n return;\n }\n\n const foundTags = utils.getPresentTags(applicableTags);\n for (const tag of foundTags) {\n checkNotAlignedPerTag(utils, tag, customSpacings);\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block lines.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-line-alignment',\n },\n fixable: 'whitespace',\n schema: [\n {\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n customSpacings: {\n additionalProperties: false,\n properties: {\n postDelimiter: {\n type: 'integer',\n },\n postHyphen: {\n type: 'integer',\n },\n postName: {\n type: 'integer',\n },\n postTag: {\n type: 'integer',\n },\n postType: {\n type: 'integer',\n },\n },\n },\n preserveMainDescriptionPostDelimiter: {\n default: false,\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA;AAGA;AACA;AAA2C;AAE3C,MAAM;EACJA,IAAI,EAAEC;AACR,CAAC,GAAGC,yBAAU;AAEd,MAAMC,qBAAqB,GAAG,CAACC,KAAK,EAAEC,GAAG,EAAEC,cAAc,KAAK;EAC5D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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;MAC3BC,UAAU,EAAE;QACVzE,cAAc,EAAE;UACdwE,oBAAoB,EAAE,KAAK;UAC3BC,UAAU,EAAE;YACVC,aAAa,EAAE;cACbH,IAAI,EAAE;YACR,CAAC;YACDpD,UAAU,EAAE;cACVoD,IAAI,EAAE;YACR,CAAC;YACDI,QAAQ,EAAE;cACRJ,IAAI,EAAE;YACR,CAAC;YACDK,OAAO,EAAE;cACPL,IAAI,EAAE;YACR,CAAC;YACDM,QAAQ,EAAE;cACRN,IAAI,EAAE;YACR;UACF;QACF,CAAC;QACD3B,oCAAoC,EAAE;UACpCkC,OAAO,EAAE,KAAK;UACdP,IAAI,EAAE;QACR,CAAC;QACDzB,IAAI,EAAE;UACJiC,KAAK,EAAE;YACLR,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
|
|
@@ -76,7 +76,7 @@ const validateDescription = (description, reportOrig, jsdocNode, abbreviationsRe
|
|
|
76
76
|
return $1 + capitalize(beginning);
|
|
77
77
|
});
|
|
78
78
|
} else {
|
|
79
|
-
text = text.replace(new RegExp('((?:[
|
|
79
|
+
text = text.replace(new RegExp('((?:[.?!]|\\*|\\})\\s*)' + (0, _escapeStringRegexp.default)(beginning), 'u'), '$1' + capitalize(beginning));
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
return fixer.replaceText(jsdocNode, text);
|
|
@@ -95,20 +95,20 @@ const validateDescription = (description, reportOrig, jsdocNode, abbreviationsRe
|
|
|
95
95
|
if (sentences.some(sentence => {
|
|
96
96
|
return /^[.?!]$/u.test(sentence);
|
|
97
97
|
})) {
|
|
98
|
-
report('
|
|
98
|
+
report('Sentences must be more than punctuation.', null, tag);
|
|
99
99
|
}
|
|
100
100
|
if (sentences.some(sentence => {
|
|
101
101
|
return !/^\s*$/u.test(sentence) && !isCapitalized(sentence) && !isTable(sentence);
|
|
102
102
|
})) {
|
|
103
|
-
report('
|
|
103
|
+
report('Sentences should start with an uppercase character.', fix, tag);
|
|
104
104
|
}
|
|
105
105
|
const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');
|
|
106
|
-
if (!/[
|
|
107
|
-
report('
|
|
106
|
+
if (!/(?:[.?!|]|```)\s*$/u.test(paragraphNoAbbreviations)) {
|
|
107
|
+
report('Sentences must end with a period.', fix, tag);
|
|
108
108
|
return true;
|
|
109
109
|
}
|
|
110
110
|
if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {
|
|
111
|
-
report('A line of text is started with an uppercase character, but preceding line does not end the sentence.', null, tag);
|
|
111
|
+
report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag);
|
|
112
112
|
return true;
|
|
113
113
|
}
|
|
114
114
|
return false;
|
|
@@ -130,9 +130,27 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
130
130
|
const abbreviationsRegex = abbreviations.length ? new RegExp('\\b' + abbreviations.map(abbreviation => {
|
|
131
131
|
return (0, _escapeStringRegexp.default)(abbreviation.replace(/\.$/ug, '') + '.');
|
|
132
132
|
}).join('|') + '(?:$|\\s)', 'gu') : '';
|
|
133
|
-
|
|
133
|
+
let {
|
|
134
134
|
description
|
|
135
135
|
} = utils.getDescription();
|
|
136
|
+
const indices = [...description.matchAll(/```[\s\S]*```/gu)].map(match => {
|
|
137
|
+
const {
|
|
138
|
+
index
|
|
139
|
+
} = match;
|
|
140
|
+
const [{
|
|
141
|
+
length
|
|
142
|
+
}] = match;
|
|
143
|
+
return {
|
|
144
|
+
index,
|
|
145
|
+
length
|
|
146
|
+
};
|
|
147
|
+
}).reverse();
|
|
148
|
+
for (const {
|
|
149
|
+
index,
|
|
150
|
+
length
|
|
151
|
+
} of indices) {
|
|
152
|
+
description = description.slice(0, index) + description.slice(index + length);
|
|
153
|
+
}
|
|
136
154
|
if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {
|
|
137
155
|
line: jsdoc.source[0].number + 1
|
|
138
156
|
}, newlineBeforeCapsAssumesBadSentenceEnd)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireDescriptionCompleteSentence.js","names":["otherDescriptiveTags","Set","extractParagraphs","text","split","extractSentences","abbreviationsRegex","txt","replace","sentenceEndGrouping","puncts","matchAll","map","sentEnd","sentence","idx","test","isNewLinePrecededByAPeriod","lastLineEndsSentence","lines","some","line","isCapitalized","str","toUpperCase","isTable","charAt","capitalize","slice","validateDescription","description","reportOrig","jsdocNode","sourceCode","tag","newlineBeforeCapsAssumesBadSentenceEnd","paragraphs","filter","Boolean","paragraph","parIdx","sentences","fix","fixer","getText","pop","RegExp","escapeStringRegexp","sentence_","beginning","reg","_$0","$1","replaceText","report","msg","tagObj","source","number","column","paragraphNoAbbreviations","iterateJsdoc","context","jsdoc","utils","options","abbreviations","length","abbreviation","join","getDescription","forEachPreferredTag","matchingJsdocTag","desc","name","getTagDescription","trim","tagsWithNames","getTagsByType","tags","tagsWithoutNames","filterTags","tagName","has","hasOptionTag","trimEnd","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","type"],"sources":["../../src/rules/requireDescriptionCompleteSentence.js"],"sourcesContent":["import escapeStringRegexp from 'escape-string-regexp';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst otherDescriptiveTags = new Set([\n // 'copyright' and 'see' might be good addition, but as the former may be\n // sensitive text, and the latter may have just a link, they are not\n // included by default\n 'summary', 'file', 'fileoverview', 'overview', 'classdesc', 'todo',\n 'deprecated', 'throws', 'exception', 'yields', 'yield',\n]);\n\nconst extractParagraphs = (text) => {\n return text.split(/(?<![;:])\\n\\n/u);\n};\n\nconst extractSentences = (text, abbreviationsRegex) => {\n const txt = text\n // Remove all {} tags.\n .replace(/\\{[\\s\\S]*?\\}\\s*/gu, '')\n\n // Remove custom abbreviations\n .replace(abbreviationsRegex, '');\n\n const sentenceEndGrouping = /([.?!])(?:\\s+|$)/ug;\n\n const puncts = [\n ...txt.matchAll(sentenceEndGrouping),\n ].map((sentEnd) => {\n return sentEnd[0];\n });\n\n return txt\n .split(/[.?!](?:\\s+|$)/u)\n\n // Re-add the dot.\n .map((sentence, idx) => {\n return !puncts[idx] && /^\\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;\n });\n};\n\nconst isNewLinePrecededByAPeriod = (text) => {\n let lastLineEndsSentence;\n\n const lines = text.split('\\n');\n\n return !lines.some((line) => {\n if (lastLineEndsSentence === false && /^[A-Z][a-z]/u.test(line)) {\n return true;\n }\n\n lastLineEndsSentence = /[.:?!|]$/u.test(line);\n\n return false;\n });\n};\n\nconst isCapitalized = (str) => {\n return str[0] === str[0].toUpperCase();\n};\n\nconst isTable = (str) => {\n return str.charAt() === '|';\n};\n\nconst capitalize = (str) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nconst validateDescription = (\n description, reportOrig, jsdocNode, abbreviationsRegex,\n sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,\n) => {\n if (!description || (/^\\n+$/u).test(description)) {\n return false;\n }\n\n const paragraphs = extractParagraphs(description).filter(Boolean);\n\n return paragraphs.some((paragraph, parIdx) => {\n const sentences = extractSentences(paragraph, abbreviationsRegex);\n\n const fix = (fixer) => {\n let text = sourceCode.getText(jsdocNode);\n\n if (!/[.:?!]$/u.test(paragraph)) {\n const line = paragraph.split('\\n').filter(Boolean).pop();\n\n text = text.replace(new RegExp(`${escapeStringRegexp(line)}$`, 'mu'), `${line}.`);\n }\n\n for (const sentence of sentences.filter((sentence_) => {\n return !(/^\\s*$/u).test(sentence_) && !isCapitalized(sentence_) &&\n !isTable(sentence_);\n })) {\n const beginning = sentence.split('\\n')[0];\n\n if (tag.tag) {\n const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'u');\n\n text = text.replace(reg, (_$0, $1) => {\n return $1 + capitalize(beginning);\n });\n } else {\n text = text.replace(new RegExp('((?:[.!?]|\\\\*|\\\\})\\\\s*)' + escapeStringRegexp(beginning), 'u'), '$1' + capitalize(beginning));\n }\n }\n\n return fixer.replaceText(jsdocNode, text);\n };\n\n const report = (msg, fixer, tagObj) => {\n if ('line' in tagObj) {\n tagObj.line += parIdx * 2;\n } else {\n tagObj.source[0].number += parIdx * 2;\n }\n\n // Avoid errors if old column doesn't exist here\n tagObj.column = 0;\n reportOrig(msg, fixer, tagObj);\n };\n\n if (sentences.some((sentence) => {\n return (/^[.?!]$/u).test(sentence);\n })) {\n report('Sentence must be more than punctuation.', null, tag);\n }\n\n if (sentences.some((sentence) => {\n return !(/^\\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);\n })) {\n report('Sentence should start with an uppercase character.', fix, tag);\n }\n\n const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');\n\n if (!/[.!?|]\\s*$/u.test(paragraphNoAbbreviations)) {\n report('Sentence must end with a period.', fix, tag);\n\n return true;\n }\n\n if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {\n report('A line of text is started with an uppercase character, but preceding line does not end the sentence.', null, tag);\n\n return true;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n context,\n jsdoc,\n report,\n jsdocNode,\n utils,\n}) => {\n const options = context.options[0] || {};\n const {\n abbreviations = [],\n newlineBeforeCapsAssumesBadSentenceEnd = false,\n } = options;\n\n const abbreviationsRegex = abbreviations.length ?\n new RegExp('\\\\b' + abbreviations.map((abbreviation) => {\n return escapeStringRegexp(abbreviation.replace(/\\.$/ug, '') + '.');\n }).join('|') + '(?:$|\\\\s)', 'gu') :\n '';\n\n const {\n description,\n } = utils.getDescription();\n\n if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {\n line: jsdoc.source[0].number + 1,\n }, newlineBeforeCapsAssumesBadSentenceEnd)) {\n return;\n }\n\n utils.forEachPreferredTag('description', (matchingJsdocTag) => {\n const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim();\n validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd);\n }, true);\n\n const {\n tagsWithNames,\n } = utils.getTagsByType(jsdoc.tags);\n const tagsWithoutNames = utils.filterTags(({\n tag: tagName,\n }) => {\n return otherDescriptiveTags.has(tagName) ||\n utils.hasOptionTag(tagName) && !tagsWithNames.some(({\n tag,\n }) => {\n // If user accidentally adds tags with names (or like `returns`\n // get parsed as having names), do not add to this list\n return tag === tagName;\n });\n });\n\n tagsWithNames.some((tag) => {\n const desc = utils.getTagDescription(tag).replace(/^- /u, '').trimEnd();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n abbreviations: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n newlineBeforeCapsAssumesBadSentenceEnd: {\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AACA;AAA2C;AAE3C,MAAMA,oBAAoB,GAAG,IAAIC,GAAG,CAAC;AACnC;AACA;AACA;AACA,SAAS,EAAE,MAAM,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uI;MACpJ2D,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV3B,aAAa,EAAE;UACb4B,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD5D,sCAAsC,EAAE;UACtC4D,IAAI,EAAE;QACR,CAAC;QACDhB,IAAI,EAAE;UACJe,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"requireDescriptionCompleteSentence.js","names":["otherDescriptiveTags","Set","extractParagraphs","text","split","extractSentences","abbreviationsRegex","txt","replace","sentenceEndGrouping","puncts","matchAll","map","sentEnd","sentence","idx","test","isNewLinePrecededByAPeriod","lastLineEndsSentence","lines","some","line","isCapitalized","str","toUpperCase","isTable","charAt","capitalize","slice","validateDescription","description","reportOrig","jsdocNode","sourceCode","tag","newlineBeforeCapsAssumesBadSentenceEnd","paragraphs","filter","Boolean","paragraph","parIdx","sentences","fix","fixer","getText","pop","RegExp","escapeStringRegexp","sentence_","beginning","reg","_$0","$1","replaceText","report","msg","tagObj","source","number","column","paragraphNoAbbreviations","iterateJsdoc","context","jsdoc","utils","options","abbreviations","length","abbreviation","join","getDescription","indices","match","index","reverse","forEachPreferredTag","matchingJsdocTag","desc","name","getTagDescription","trim","tagsWithNames","getTagsByType","tags","tagsWithoutNames","filterTags","tagName","has","hasOptionTag","trimEnd","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","type"],"sources":["../../src/rules/requireDescriptionCompleteSentence.js"],"sourcesContent":["import escapeStringRegexp from 'escape-string-regexp';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst otherDescriptiveTags = new Set([\n // 'copyright' and 'see' might be good addition, but as the former may be\n // sensitive text, and the latter may have just a link, they are not\n // included by default\n 'summary', 'file', 'fileoverview', 'overview', 'classdesc', 'todo',\n 'deprecated', 'throws', 'exception', 'yields', 'yield',\n]);\n\nconst extractParagraphs = (text) => {\n return text.split(/(?<![;:])\\n\\n/u);\n};\n\nconst extractSentences = (text, abbreviationsRegex) => {\n const txt = text\n // Remove all {} tags.\n .replace(/\\{[\\s\\S]*?\\}\\s*/gu, '')\n\n // Remove custom abbreviations\n .replace(abbreviationsRegex, '');\n\n const sentenceEndGrouping = /([.?!])(?:\\s+|$)/ug;\n\n const puncts = [\n ...txt.matchAll(sentenceEndGrouping),\n ].map((sentEnd) => {\n return sentEnd[0];\n });\n\n return txt\n .split(/[.?!](?:\\s+|$)/u)\n\n // Re-add the dot.\n .map((sentence, idx) => {\n return !puncts[idx] && /^\\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;\n });\n};\n\nconst isNewLinePrecededByAPeriod = (text) => {\n let lastLineEndsSentence;\n\n const lines = text.split('\\n');\n\n return !lines.some((line) => {\n if (lastLineEndsSentence === false && /^[A-Z][a-z]/u.test(line)) {\n return true;\n }\n\n lastLineEndsSentence = /[.:?!|]$/u.test(line);\n\n return false;\n });\n};\n\nconst isCapitalized = (str) => {\n return str[0] === str[0].toUpperCase();\n};\n\nconst isTable = (str) => {\n return str.charAt() === '|';\n};\n\nconst capitalize = (str) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nconst validateDescription = (\n description, reportOrig, jsdocNode, abbreviationsRegex,\n sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,\n) => {\n if (!description || (/^\\n+$/u).test(description)) {\n return false;\n }\n\n const paragraphs = extractParagraphs(description).filter(Boolean);\n\n return paragraphs.some((paragraph, parIdx) => {\n const sentences = extractSentences(paragraph, abbreviationsRegex);\n\n const fix = (fixer) => {\n let text = sourceCode.getText(jsdocNode);\n\n if (!/[.:?!]$/u.test(paragraph)) {\n const line = paragraph.split('\\n').filter(Boolean).pop();\n\n text = text.replace(new RegExp(`${escapeStringRegexp(line)}$`, 'mu'), `${line}.`);\n }\n\n for (const sentence of sentences.filter((sentence_) => {\n return !(/^\\s*$/u).test(sentence_) && !isCapitalized(sentence_) &&\n !isTable(sentence_);\n })) {\n const beginning = sentence.split('\\n')[0];\n\n if (tag.tag) {\n const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'u');\n\n text = text.replace(reg, (_$0, $1) => {\n return $1 + capitalize(beginning);\n });\n } else {\n text = text.replace(new RegExp('((?:[.?!]|\\\\*|\\\\})\\\\s*)' + escapeStringRegexp(beginning), 'u'), '$1' + capitalize(beginning));\n }\n }\n\n return fixer.replaceText(jsdocNode, text);\n };\n\n const report = (msg, fixer, tagObj) => {\n if ('line' in tagObj) {\n tagObj.line += parIdx * 2;\n } else {\n tagObj.source[0].number += parIdx * 2;\n }\n\n // Avoid errors if old column doesn't exist here\n tagObj.column = 0;\n reportOrig(msg, fixer, tagObj);\n };\n\n if (sentences.some((sentence) => {\n return (/^[.?!]$/u).test(sentence);\n })) {\n report('Sentences must be more than punctuation.', null, tag);\n }\n\n if (sentences.some((sentence) => {\n return !(/^\\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);\n })) {\n report('Sentences should start with an uppercase character.', fix, tag);\n }\n\n const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');\n\n if (!/(?:[.?!|]|```)\\s*$/u.test(paragraphNoAbbreviations)) {\n report('Sentences must end with a period.', fix, tag);\n\n return true;\n }\n\n if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {\n report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag);\n\n return true;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n context,\n jsdoc,\n report,\n jsdocNode,\n utils,\n}) => {\n const options = context.options[0] || {};\n const {\n abbreviations = [],\n newlineBeforeCapsAssumesBadSentenceEnd = false,\n } = options;\n\n const abbreviationsRegex = abbreviations.length ?\n new RegExp('\\\\b' + abbreviations.map((abbreviation) => {\n return escapeStringRegexp(abbreviation.replace(/\\.$/ug, '') + '.');\n }).join('|') + '(?:$|\\\\s)', 'gu') :\n '';\n\n let {\n description,\n } = utils.getDescription();\n\n const indices = [\n ...description.matchAll(/```[\\s\\S]*```/gu),\n ].map((match) => {\n const {\n index,\n } = match;\n const [\n {\n length,\n },\n ] = match;\n return {\n index,\n length,\n };\n }).reverse();\n\n for (const {\n index,\n length,\n } of indices) {\n description = description.slice(0, index) + description.slice(index + length);\n }\n\n if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {\n line: jsdoc.source[0].number + 1,\n }, newlineBeforeCapsAssumesBadSentenceEnd)) {\n return;\n }\n\n utils.forEachPreferredTag('description', (matchingJsdocTag) => {\n const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim();\n validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd);\n }, true);\n\n const {\n tagsWithNames,\n } = utils.getTagsByType(jsdoc.tags);\n const tagsWithoutNames = utils.filterTags(({\n tag: tagName,\n }) => {\n return otherDescriptiveTags.has(tagName) ||\n utils.hasOptionTag(tagName) && !tagsWithNames.some(({\n tag,\n }) => {\n // If user accidentally adds tags with names (or like `returns`\n // get parsed as having names), do not add to this list\n return tag === tagName;\n });\n });\n\n tagsWithNames.some((tag) => {\n const desc = utils.getTagDescription(tag).replace(/^- /u, '').trimEnd();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n abbreviations: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n newlineBeforeCapsAssumesBadSentenceEnd: {\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AACA;AAA2C;AAE3C,MAAMA,oBAAoB,GAAG,IAAIC,GAAG,CAAC;AACnC;AACA;AACA;AACA,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAClE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CACvD,CAAC;AAEF,MAAMC,iBAAiB,GAAIC,IAAI,IAAK;EAClC,OAAOA,IAAI,CAACC,KAAK,CAAC,gBAAgB,CAAC;AACrC,CAAC;AAED,MAAMC,gBAAgB,GAAG,CAACF,IAAI,EAAEG,kBAAkB,KAAK;EACrD,MAAMC,GAAG,GAAGJ;EACV;EAAA,CACCK,OAAO,CAAC,mBAAmB,EAAE,EAAE;;EAEhC;EAAA,CACCA,OAAO,CAACF,kBAAkB,EAAE,EAAE,CAAC;EAElC,MAAMG,mBAAmB,GAAG,oBAAoB;EAEhD,MAAMC,MAAM,GAAG,CACb,GAAGH,GAAG,CAACI,QAAQ,CAACF,mBAAmB,CAAC,CACrC,CAACG,GAAG,CAAEC,OAAO,IAAK;IACjB,OAAOA,OAAO,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC;EAEF,OAAON,GAAG,CACPH,KAAK,CAAC,iBAAiB;;EAExB;EAAA,C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