eslint-plugin-jsdoc 37.4.2 → 37.5.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
CHANGED
|
@@ -8170,7 +8170,8 @@ Defaults to `['ts-check', 'ts-expect-error', 'ts-ignore', 'ts-nocheck']`
|
|
|
8170
8170
|
##### <code>preventAllMultiAsteriskBlocks</code>
|
|
8171
8171
|
|
|
8172
8172
|
A boolean (defaulting to `false`) which if `true` will prevent all
|
|
8173
|
-
|
|
8173
|
+
JSDoc-like blocks with more than two initial asterisks even those without
|
|
8174
|
+
apparent tag content.
|
|
8174
8175
|
|
|
8175
8176
|
|||
|
|
8176
8177
|
|---|---|
|
|
@@ -8711,6 +8712,17 @@ and that rule is for catching blocks which only seem like jsdoc).
|
|
|
8711
8712
|
<a name="eslint-plugin-jsdoc-rules-no-multi-asterisks-options-18"></a>
|
|
8712
8713
|
#### Options
|
|
8713
8714
|
|
|
8715
|
+
<a name="eslint-plugin-jsdoc-rules-no-multi-asterisks-options-18-allowwhitespace-defaults-to-false"></a>
|
|
8716
|
+
##### <code>allowWhitespace</code> (defaults to <code>false</code>)
|
|
8717
|
+
|
|
8718
|
+
Set to `true` if you wish to allow asterisks after a space (as with Markdown):
|
|
8719
|
+
|
|
8720
|
+
```js
|
|
8721
|
+
/**
|
|
8722
|
+
* *bold* text
|
|
8723
|
+
*/
|
|
8724
|
+
```
|
|
8725
|
+
|
|
8714
8726
|
<a name="eslint-plugin-jsdoc-rules-no-multi-asterisks-options-18-preventatmiddlelines-defaults-to-true"></a>
|
|
8715
8727
|
##### <code>preventAtMiddleLines</code> (defaults to <code>true</code>)
|
|
8716
8728
|
|
|
@@ -8822,6 +8834,25 @@ The following patterns are considered problems:
|
|
|
8822
8834
|
* */
|
|
8823
8835
|
// "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtEnd":true}]
|
|
8824
8836
|
// Message: Should be no multiple asterisks on end lines.
|
|
8837
|
+
|
|
8838
|
+
/**
|
|
8839
|
+
* The method does 2 things:
|
|
8840
|
+
* * Thing 1
|
|
8841
|
+
* * Thing 2
|
|
8842
|
+
*/
|
|
8843
|
+
// "jsdoc/no-multi-asterisks": ["error"|"warn", {"allowWhitespace":false}]
|
|
8844
|
+
// Message: Should be no multiple asterisks on middle lines.
|
|
8845
|
+
|
|
8846
|
+
/**
|
|
8847
|
+
* This muti-line comment contains some
|
|
8848
|
+
* *non-standard bold* syntax
|
|
8849
|
+
*/
|
|
8850
|
+
// "jsdoc/no-multi-asterisks": ["error"|"warn", {"allowWhitespace":false}]
|
|
8851
|
+
// Message: Should be no multiple asterisks on middle lines.
|
|
8852
|
+
|
|
8853
|
+
/** Desc. **/
|
|
8854
|
+
// "jsdoc/no-multi-asterisks": ["error"|"warn", {"allowWhitespace":true}]
|
|
8855
|
+
// Message: Should be no multiple asterisks on end lines.
|
|
8825
8856
|
````
|
|
8826
8857
|
|
|
8827
8858
|
The following patterns are not considered problems:
|
|
@@ -8899,6 +8930,25 @@ function foo() {
|
|
|
8899
8930
|
*
|
|
8900
8931
|
* **Bold example:** Hi there.
|
|
8901
8932
|
*/
|
|
8933
|
+
|
|
8934
|
+
/**
|
|
8935
|
+
* The method does 2 things:
|
|
8936
|
+
* * Thing 1
|
|
8937
|
+
* * Thing 2
|
|
8938
|
+
*/
|
|
8939
|
+
// "jsdoc/no-multi-asterisks": ["error"|"warn", {"allowWhitespace":true}]
|
|
8940
|
+
|
|
8941
|
+
/**
|
|
8942
|
+
* This muti-line comment contains some
|
|
8943
|
+
* *non-standard bold* syntax
|
|
8944
|
+
*/
|
|
8945
|
+
// "jsdoc/no-multi-asterisks": ["error"|"warn", {"allowWhitespace":true}]
|
|
8946
|
+
|
|
8947
|
+
/** abc */
|
|
8948
|
+
function foo() {
|
|
8949
|
+
//
|
|
8950
|
+
}
|
|
8951
|
+
// "jsdoc/no-multi-asterisks": ["error"|"warn", {"allowWhitespace":true}]
|
|
8902
8952
|
````
|
|
8903
8953
|
|
|
8904
8954
|
|
|
@@ -9,7 +9,12 @@ var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const middleAsterisksBlockWS = /^([\t ]|\*(?!\*))+/u;
|
|
13
|
+
const middleAsterisksNoBlockWS = /^\*+/u;
|
|
14
|
+
const endAsterisksSingleLineBlockWS = /\*((?:\*|(?: |\t))*)\*$/u;
|
|
15
|
+
const endAsterisksMultipleLineBlockWS = /((?:\*|(?: |\t))*)\*$/u;
|
|
16
|
+
const endAsterisksSingleLineNoBlockWS = /\*(\**)\*$/u;
|
|
17
|
+
const endAsterisksMultipleLineNoBlockWS = /(\**)\*$/u;
|
|
13
18
|
|
|
14
19
|
var _default = (0, _iterateJsdoc.default)(({
|
|
15
20
|
context,
|
|
@@ -17,9 +22,12 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
17
22
|
utils
|
|
18
23
|
}) => {
|
|
19
24
|
const {
|
|
25
|
+
allowWhitespace = false,
|
|
20
26
|
preventAtEnd = true,
|
|
21
27
|
preventAtMiddleLines = true
|
|
22
28
|
} = context.options[0] || {};
|
|
29
|
+
const middleAsterisks = allowWhitespace ? middleAsterisksNoBlockWS : middleAsterisksBlockWS; // eslint-disable-next-line complexity -- Todo
|
|
30
|
+
|
|
23
31
|
jsdoc.source.some(({
|
|
24
32
|
tokens,
|
|
25
33
|
number
|
|
@@ -30,10 +38,12 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
30
38
|
name,
|
|
31
39
|
type,
|
|
32
40
|
description,
|
|
33
|
-
end
|
|
41
|
+
end,
|
|
42
|
+
postDelimiter
|
|
34
43
|
} = tokens;
|
|
35
44
|
|
|
36
|
-
if (preventAtMiddleLines && !end && !tag && !type && !name && middleAsterisks.test(description)) {
|
|
45
|
+
if (preventAtMiddleLines && !end && !tag && !type && !name && (!allowWhitespace && middleAsterisks.test(description) || allowWhitespace && middleAsterisks.test(postDelimiter + description))) {
|
|
46
|
+
// console.log('description', JSON.stringify(description));
|
|
37
47
|
const fix = () => {
|
|
38
48
|
tokens.description = description.replace(middleAsterisks, '');
|
|
39
49
|
};
|
|
@@ -50,8 +60,15 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
50
60
|
|
|
51
61
|
const isSingleLineBlock = delimiter === '/**';
|
|
52
62
|
const delim = isSingleLineBlock ? '*' : delimiter;
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
let endAsterisks;
|
|
64
|
+
|
|
65
|
+
if (allowWhitespace) {
|
|
66
|
+
endAsterisks = isSingleLineBlock ? endAsterisksSingleLineNoBlockWS : endAsterisksMultipleLineNoBlockWS;
|
|
67
|
+
} else {
|
|
68
|
+
endAsterisks = isSingleLineBlock ? endAsterisksSingleLineBlockWS : endAsterisksMultipleLineBlockWS;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const endingAsterisksAndSpaces = (allowWhitespace ? postDelimiter + description + delim : description + delim).match(endAsterisks);
|
|
55
72
|
|
|
56
73
|
if (!endingAsterisksAndSpaces || !isSingleLineBlock && endingAsterisksAndSpaces[1] && !endingAsterisksAndSpaces[1].trim()) {
|
|
57
74
|
return false;
|
|
@@ -81,6 +98,9 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
81
98
|
schema: [{
|
|
82
99
|
additionalProperies: false,
|
|
83
100
|
properties: {
|
|
101
|
+
allowWhitespace: {
|
|
102
|
+
type: 'boolean'
|
|
103
|
+
},
|
|
84
104
|
preventAtEnd: {
|
|
85
105
|
type: 'boolean'
|
|
86
106
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/noMultiAsterisks.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../src/rules/noMultiAsterisks.js"],"names":["middleAsterisksBlockWS","middleAsterisksNoBlockWS","endAsterisksSingleLineBlockWS","endAsterisksMultipleLineBlockWS","endAsterisksSingleLineNoBlockWS","endAsterisksMultipleLineNoBlockWS","context","jsdoc","utils","allowWhitespace","preventAtEnd","preventAtMiddleLines","options","middleAsterisks","source","some","tokens","number","delimiter","tag","name","type","description","end","postDelimiter","test","fix","replace","reportJSDoc","line","isSingleLineBlock","delim","endAsterisks","endingAsterisksAndSpaces","match","trim","endFix","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperies","properties"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,sBAAsB,GAAG,qBAA/B;AACA,MAAMC,wBAAwB,GAAG,OAAjC;AAEA,MAAMC,6BAA6B,GAAG,0BAAtC;AACA,MAAMC,+BAA+B,GAAG,wBAAxC;AAEA,MAAMC,+BAA+B,GAAG,aAAxC;AACA,MAAMC,iCAAiC,GAAG,WAA1C;;eAEe,2BAAa,CAAC;AAC3BC,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA;AAH2B,CAAD,KAItB;AACJ,QAAM;AACJC,IAAAA,eAAe,GAAG,KADd;AAEJC,IAAAA,YAAY,GAAG,IAFX;AAGJC,IAAAA,oBAAoB,GAAG;AAHnB,MAIFL,OAAO,CAACM,OAAR,CAAgB,CAAhB,KAAsB,EAJ1B;AAMA,QAAMC,eAAe,GAAGJ,eAAe,GAAGR,wBAAH,GAA8BD,sBAArE,CAPI,CASJ;;AACAO,EAAAA,KAAK,CAACO,MAAN,CAAaC,IAAb,CAAkB,CAAC;AACjBC,IAAAA,MADiB;AAEjBC,IAAAA;AAFiB,GAAD,KAGZ;AACJ,UAAM;AACJC,MAAAA,SADI;AAEJC,MAAAA,GAFI;AAGJC,MAAAA,IAHI;AAIJC,MAAAA,IAJI;AAKJC,MAAAA,WALI;AAMJC,MAAAA,GANI;AAOJC,MAAAA;AAPI,QAQFR,MARJ;;AAUA,QACEL,oBAAoB,IACpB,CAACY,GADD,IACQ,CAACJ,GADT,IACgB,CAACE,IADjB,IACyB,CAACD,IAD1B,K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,GAAmB,EAAnB;AACD;;AAEDF,MAAAA,MAAM,CAACM,WAAP,GAAqB,CAACA,WAAW,GAAGS,KAAf,EAAsBJ,OAAtB,CAA8BK,YAA9B,EAA4C,EAA5C,CAArB;AACD,KAND;;AAQAxB,IAAAA,KAAK,CAACoB,WAAN,CACE,+CADF,EAEE;AACEC,MAAAA,IAAI,EAAEZ;AADR,KAFF,EAKEmB,MALF,EAME,IANF;AASA,WAAO,IAAP;AACD,GAnFD;AAoFD,CAlGc,EAkGZ;AACDC,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJjB,MAAAA,WAAW,EAAE,EADT;AAEJkB,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,OAAO,EAAE,MALL;AAMJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,mBAAmB,EAAE,KADvB;AAEEC,MAAAA,UAAU,EAAE;AACVnC,QAAAA,eAAe,EAAE;AACfY,UAAAA,IAAI,EAAE;AADS,SADP;AAIVX,QAAAA,YAAY,EAAE;AACZW,UAAAA,IAAI,EAAE;AADM,SAJJ;AAOVV,QAAAA,oBAAoB,EAAE;AACpBU,UAAAA,IAAI,EAAE;AADc;AAPZ,OAFd;AAaEA,MAAAA,IAAI,EAAE;AAbR,KADM,CANJ;AAuBJA,IAAAA,IAAI,EAAE;AAvBF;AAFL,CAlGY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst middleAsterisksBlockWS = /^([\\t ]|\\*(?!\\*))+/u;\nconst middleAsterisksNoBlockWS = /^\\*+/u;\n\nconst endAsterisksSingleLineBlockWS = /\\*((?:\\*|(?: |\\t))*)\\*$/u;\nconst endAsterisksMultipleLineBlockWS = /((?:\\*|(?: |\\t))*)\\*$/u;\n\nconst endAsterisksSingleLineNoBlockWS = /\\*(\\**)\\*$/u;\nconst endAsterisksMultipleLineNoBlockWS = /(\\**)\\*$/u;\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const {\n allowWhitespace = false,\n preventAtEnd = true,\n preventAtMiddleLines = true,\n } = context.options[0] || {};\n\n const middleAsterisks = allowWhitespace ? middleAsterisksNoBlockWS : middleAsterisksBlockWS;\n\n // eslint-disable-next-line complexity -- Todo\n jsdoc.source.some(({\n tokens,\n number,\n }) => {\n const {\n delimiter,\n tag,\n name,\n type,\n description,\n end,\n postDelimiter,\n } = tokens;\n\n if (\n preventAtMiddleLines &&\n !end && !tag && !type && !name &&\n (\n !allowWhitespace && middleAsterisks.test(description) ||\n allowWhitespace && middleAsterisks.test(postDelimiter + description)\n )\n ) {\n // console.log('description', JSON.stringify(description));\n const fix = () => {\n tokens.description = description.replace(middleAsterisks, '');\n };\n\n utils.reportJSDoc(\n 'Should be no multiple asterisks on middle lines.',\n {\n line: number,\n },\n fix,\n true,\n );\n\n return true;\n }\n\n if (!preventAtEnd || !end) {\n return false;\n }\n\n const isSingleLineBlock = delimiter === '/**';\n const delim = isSingleLineBlock ? '*' : delimiter;\n let endAsterisks;\n if (allowWhitespace) {\n endAsterisks = isSingleLineBlock ? endAsterisksSingleLineNoBlockWS : endAsterisksMultipleLineNoBlockWS;\n } else {\n endAsterisks = isSingleLineBlock ? endAsterisksSingleLineBlockWS : endAsterisksMultipleLineBlockWS;\n }\n\n const endingAsterisksAndSpaces = (\n allowWhitespace ? postDelimiter + description + delim : description + delim\n ).match(\n endAsterisks,\n );\n\n if (\n !endingAsterisksAndSpaces ||\n !isSingleLineBlock && endingAsterisksAndSpaces[1] && !endingAsterisksAndSpaces[1].trim()\n ) {\n return false;\n }\n\n const endFix = () => {\n if (!isSingleLineBlock) {\n tokens.delimiter = '';\n }\n\n tokens.description = (description + delim).replace(endAsterisks, '');\n };\n\n utils.reportJSDoc(\n 'Should be no multiple asterisks on end lines.',\n {\n line: number,\n },\n endFix,\n true,\n );\n\n return true;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: '',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-multi-asterisks',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperies: false,\n properties: {\n allowWhitespace: {\n type: 'boolean',\n },\n preventAtEnd: {\n type: 'boolean',\n },\n preventAtMiddleLines: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"noMultiAsterisks.js"}
|
package/package.json
CHANGED
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"test-index": "cross-env BABEL_ENV=test mocha --recursive --require @babel/register --reporter progress --timeout 12000 test/rules/index.js",
|
|
109
109
|
"test-no-cov": "cross-env BABEL_ENV=test mocha --reporter dot --recursive --require @babel/register --timeout 12000"
|
|
110
110
|
},
|
|
111
|
-
"version": "37.
|
|
111
|
+
"version": "37.5.0"
|
|
112
112
|
}
|