eslint-plugin-jsdoc 39.3.5 → 39.3.12
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 +273 -52
- package/dist/WarnSettings.js +0 -5
- package/dist/WarnSettings.js.map +1 -1
- package/dist/alignTransform.js +69 -61
- package/dist/alignTransform.js.map +1 -1
- package/dist/bin/generateRule.js +7 -26
- package/dist/bin/generateRule.js.map +1 -1
- package/dist/defaultTagOrder.js +30 -14
- package/dist/defaultTagOrder.js.map +1 -1
- package/dist/exportParser.js +34 -143
- package/dist/exportParser.js.map +1 -1
- package/dist/generateRule.js +7 -26
- package/dist/generateRule.js.map +1 -1
- package/dist/getDefaultTagStructureForMode.js +189 -93
- package/dist/getDefaultTagStructureForMode.js.map +1 -1
- package/dist/index.js +0 -51
- package/dist/index.js.map +1 -1
- package/dist/iterateJsdoc.js +44 -207
- package/dist/iterateJsdoc.js.map +1 -1
- package/dist/jsdocUtils.js +72 -221
- package/dist/jsdocUtils.js.map +1 -1
- package/dist/rules/checkAccess.js +0 -8
- package/dist/rules/checkAccess.js.map +1 -1
- package/dist/rules/checkAlignment.js +0 -8
- package/dist/rules/checkAlignment.js.map +1 -1
- package/dist/rules/checkExamples.js +25 -63
- package/dist/rules/checkExamples.js.map +1 -1
- package/dist/rules/checkIndentation.js +0 -7
- package/dist/rules/checkIndentation.js.map +1 -1
- package/dist/rules/checkLineAlignment.js +9 -30
- package/dist/rules/checkLineAlignment.js.map +1 -1
- package/dist/rules/checkParamNames.js +9 -47
- package/dist/rules/checkParamNames.js.map +1 -1
- package/dist/rules/checkPropertyNames.js +1 -18
- package/dist/rules/checkPropertyNames.js.map +1 -1
- package/dist/rules/checkSyntax.js +2 -5
- package/dist/rules/checkSyntax.js.map +1 -1
- package/dist/rules/checkTagNames.js +0 -18
- package/dist/rules/checkTagNames.js.map +1 -1
- package/dist/rules/checkTypes.js +17 -46
- package/dist/rules/checkTypes.js.map +1 -1
- package/dist/rules/checkValues.js +0 -18
- package/dist/rules/checkValues.js.map +1 -1
- package/dist/rules/emptyTags.js +6 -11
- package/dist/rules/emptyTags.js.map +1 -1
- package/dist/rules/implementsOnClasses.js +0 -6
- package/dist/rules/implementsOnClasses.js.map +1 -1
- package/dist/rules/matchDescription.js +0 -20
- package/dist/rules/matchDescription.js.map +1 -1
- package/dist/rules/matchName.js +2 -17
- package/dist/rules/matchName.js.map +1 -1
- package/dist/rules/multilineBlocks.js +10 -34
- package/dist/rules/multilineBlocks.js.map +1 -1
- package/dist/rules/newlineAfterDescription.js +0 -8
- package/dist/rules/newlineAfterDescription.js.map +1 -1
- package/dist/rules/noBadBlocks.js +2 -16
- package/dist/rules/noBadBlocks.js.map +1 -1
- package/dist/rules/noDefaults.js +0 -7
- package/dist/rules/noDefaults.js.map +1 -1
- package/dist/rules/noMissingSyntax.js +2 -16
- package/dist/rules/noMissingSyntax.js.map +1 -1
- package/dist/rules/noMultiAsterisks.js +2 -16
- package/dist/rules/noMultiAsterisks.js.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +3 -9
- package/dist/rules/noRestrictedSyntax.js.map +1 -1
- package/dist/rules/noTypes.js +0 -7
- package/dist/rules/noTypes.js.map +1 -1
- package/dist/rules/noUndefinedTypes.js +13 -34
- package/dist/rules/noUndefinedTypes.js.map +1 -1
- package/dist/rules/requireAsteriskPrefix.js +2 -26
- package/dist/rules/requireAsteriskPrefix.js.map +1 -1
- package/dist/rules/requireDescription.js +0 -17
- package/dist/rules/requireDescription.js.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +13 -34
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
- package/dist/rules/requireExample.js +0 -9
- package/dist/rules/requireExample.js.map +1 -1
- package/dist/rules/requireFileOverview.js +0 -16
- package/dist/rules/requireFileOverview.js.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +2 -16
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
- package/dist/rules/requireJsdoc.js +13 -58
- package/dist/rules/requireJsdoc.js.map +1 -1
- package/dist/rules/requireParam.js +6 -53
- package/dist/rules/requireParam.js.map +1 -1
- package/dist/rules/requireParamDescription.js +0 -4
- package/dist/rules/requireParamDescription.js.map +1 -1
- package/dist/rules/requireParamName.js +0 -4
- package/dist/rules/requireParamName.js.map +1 -1
- package/dist/rules/requireParamType.js +0 -4
- package/dist/rules/requireParamType.js.map +1 -1
- package/dist/rules/requireProperty.js +0 -9
- package/dist/rules/requireProperty.js.map +1 -1
- package/dist/rules/requirePropertyDescription.js +0 -4
- package/dist/rules/requirePropertyDescription.js.map +1 -1
- package/dist/rules/requirePropertyName.js +0 -4
- package/dist/rules/requirePropertyName.js.map +1 -1
- package/dist/rules/requirePropertyType.js +0 -4
- package/dist/rules/requirePropertyType.js.map +1 -1
- package/dist/rules/requireReturns.js +13 -23
- package/dist/rules/requireReturns.js.map +1 -1
- package/dist/rules/requireReturnsCheck.js +12 -20
- package/dist/rules/requireReturnsCheck.js.map +1 -1
- package/dist/rules/requireReturnsDescription.js +0 -6
- package/dist/rules/requireReturnsDescription.js.map +1 -1
- package/dist/rules/requireReturnsType.js +0 -4
- package/dist/rules/requireReturnsType.js.map +1 -1
- package/dist/rules/requireThrows.js +6 -15
- package/dist/rules/requireThrows.js.map +1 -1
- package/dist/rules/requireYields.js +13 -29
- package/dist/rules/requireYields.js.map +1 -1
- package/dist/rules/requireYieldsCheck.js +8 -29
- package/dist/rules/requireYieldsCheck.js.map +1 -1
- package/dist/rules/sortTags.js +17 -30
- package/dist/rules/sortTags.js.map +1 -1
- package/dist/rules/tagLines.js +0 -26
- package/dist/rules/tagLines.js.map +1 -1
- package/dist/rules/validTypes.js +22 -53
- package/dist/rules/validTypes.js.map +1 -1
- package/dist/tagNames.js +7 -4
- package/dist/tagNames.js.map +1 -1
- package/dist/utils/hasReturnValue.js +22 -66
- package/dist/utils/hasReturnValue.js.map +1 -1
- package/package.json +16 -16
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = (0, _iterateJsdoc.default)(({
|
|
13
10
|
context,
|
|
14
11
|
jsdoc,
|
|
@@ -34,28 +31,24 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
34
31
|
tag
|
|
35
32
|
} = tokens;
|
|
36
33
|
const sourceLength = jsdoc.source.length;
|
|
37
|
-
|
|
38
34
|
const isInvalidSingleLine = tagName => {
|
|
39
35
|
return noSingleLineBlocks && (!tagName || !singleLineTags.includes(tagName) && !singleLineTags.includes('*'));
|
|
40
36
|
};
|
|
41
|
-
|
|
42
37
|
if (sourceLength === 1) {
|
|
43
38
|
if (!isInvalidSingleLine(tag.slice(1))) {
|
|
44
39
|
return;
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
const fixer = () => {
|
|
48
42
|
utils.makeMultiline();
|
|
49
43
|
};
|
|
50
|
-
|
|
51
44
|
utils.reportJSDoc('Single line blocks are not permitted by your configuration.', null, fixer, true);
|
|
52
45
|
return;
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
const lineChecks = () => {
|
|
56
48
|
if (noZeroLineText && (tag || description)) {
|
|
57
49
|
const fixer = () => {
|
|
58
|
-
const line = {
|
|
50
|
+
const line = {
|
|
51
|
+
...tokens
|
|
59
52
|
};
|
|
60
53
|
utils.emptyTokens(tokens);
|
|
61
54
|
const {
|
|
@@ -64,53 +57,47 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
64
57
|
start
|
|
65
58
|
}
|
|
66
59
|
} = jsdoc.source[1];
|
|
67
|
-
utils.addLine(1, {
|
|
60
|
+
utils.addLine(1, {
|
|
61
|
+
...line,
|
|
68
62
|
delimiter,
|
|
69
63
|
start
|
|
70
64
|
});
|
|
71
65
|
};
|
|
72
|
-
|
|
73
66
|
utils.reportJSDoc('Should have no text on the "0th" line (after the `/**`).', null, fixer);
|
|
74
67
|
return;
|
|
75
68
|
}
|
|
76
|
-
|
|
77
69
|
const finalLine = jsdoc.source[jsdoc.source.length - 1];
|
|
78
70
|
const finalLineTokens = finalLine.tokens;
|
|
79
|
-
|
|
80
71
|
if (noFinalLineText && finalLineTokens.description.trim()) {
|
|
81
72
|
const fixer = () => {
|
|
82
|
-
const line = {
|
|
73
|
+
const line = {
|
|
74
|
+
...finalLineTokens
|
|
83
75
|
};
|
|
84
76
|
line.description = line.description.trimEnd();
|
|
85
77
|
const {
|
|
86
78
|
delimiter
|
|
87
79
|
} = line;
|
|
88
|
-
|
|
89
80
|
for (const prop of ['delimiter', 'postDelimiter', 'tag', 'type', 'lineEnd', 'postType', 'postTag', 'name', 'postName', 'description']) {
|
|
90
81
|
finalLineTokens[prop] = '';
|
|
91
82
|
}
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
utils.addLine(jsdoc.source.length - 1, {
|
|
84
|
+
...line,
|
|
94
85
|
delimiter,
|
|
95
86
|
end: ''
|
|
96
87
|
});
|
|
97
88
|
};
|
|
98
|
-
|
|
99
89
|
utils.reportJSDoc('Should have no text on the final line (before the `*/`).', null, fixer);
|
|
100
90
|
}
|
|
101
91
|
};
|
|
102
|
-
|
|
103
92
|
if (noMultilineBlocks) {
|
|
104
93
|
if (jsdoc.tags.length && (multilineTags.includes('*') || utils.hasATag(multilineTags))) {
|
|
105
94
|
lineChecks();
|
|
106
95
|
return;
|
|
107
96
|
}
|
|
108
|
-
|
|
109
97
|
if (jsdoc.description.length >= minimumLengthForMultiline) {
|
|
110
98
|
lineChecks();
|
|
111
99
|
return;
|
|
112
100
|
}
|
|
113
|
-
|
|
114
101
|
if (noSingleLineBlocks && (!jsdoc.tags.length || !utils.filterTags(({
|
|
115
102
|
tag: tg
|
|
116
103
|
}) => {
|
|
@@ -119,7 +106,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
119
106
|
utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' + 'your configuration but fixing would result in a single ' + 'line block which you have prohibited with `noSingleLineBlocks`.');
|
|
120
107
|
return;
|
|
121
108
|
}
|
|
122
|
-
|
|
123
109
|
if (jsdoc.tags.length > 1) {
|
|
124
110
|
if (!allowMultipleTags) {
|
|
125
111
|
utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' + 'your configuration but the block has multiple tags.');
|
|
@@ -150,34 +136,27 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
150
136
|
if (typ) {
|
|
151
137
|
obj.type = typ;
|
|
152
138
|
}
|
|
153
|
-
|
|
154
139
|
if (tg && typ && nme) {
|
|
155
140
|
obj.postType = postType;
|
|
156
141
|
}
|
|
157
|
-
|
|
158
142
|
if (nme) {
|
|
159
143
|
obj.name += nme;
|
|
160
144
|
}
|
|
161
|
-
|
|
162
145
|
if (nme && desc) {
|
|
163
146
|
obj.postName = postName;
|
|
164
147
|
}
|
|
165
|
-
|
|
166
148
|
obj.description += desc;
|
|
167
149
|
const nameOrDescription = obj.description || obj.name;
|
|
168
|
-
|
|
169
150
|
if (nameOrDescription && nameOrDescription.slice(-1) !== ' ') {
|
|
170
151
|
obj.description += ' ';
|
|
171
152
|
}
|
|
153
|
+
obj.lineEnd = lineEnd;
|
|
172
154
|
|
|
173
|
-
|
|
174
|
-
|
|
155
|
+
// Already filtered for multiple tags
|
|
175
156
|
obj.tag += tg;
|
|
176
|
-
|
|
177
157
|
if (tg) {
|
|
178
158
|
obj.postTag = postTag || ' ';
|
|
179
159
|
}
|
|
180
|
-
|
|
181
160
|
return obj;
|
|
182
161
|
}, utils.seedTokens({
|
|
183
162
|
delimiter: '/**',
|
|
@@ -186,12 +165,10 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
186
165
|
}))
|
|
187
166
|
}];
|
|
188
167
|
};
|
|
189
|
-
|
|
190
168
|
utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' + 'your configuration.', null, fixer);
|
|
191
169
|
return;
|
|
192
170
|
}
|
|
193
171
|
}
|
|
194
|
-
|
|
195
172
|
lineChecks();
|
|
196
173
|
}, {
|
|
197
174
|
iterateAllJsdocs: true,
|
|
@@ -245,7 +222,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
245
222
|
type: 'suggestion'
|
|
246
223
|
}
|
|
247
224
|
});
|
|
248
|
-
|
|
249
225
|
exports.default = _default;
|
|
250
226
|
module.exports = exports.default;
|
|
251
227
|
//# sourceMappingURL=multilineBlocks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multilineBlocks.js","names":["iterateJsdoc","context","jsdoc","utils","allowMultipleTags","noFinalLineText","noZeroLineText","noSingleLineBlocks","singleLineTags","noMultilineBlocks","minimumLengthForMultiline","Number","POSITIVE_INFINITY","multilineTags","options","source","tokens","description","tag","sourceLength","length","isInvalidSingleLine","tagName","includes","slice","fixer","makeMultiline","reportJSDoc","lineChecks","line","emptyTokens","delimiter","start","addLine","finalLine","finalLineTokens","trim","trimEnd","prop","end","tags","hasATag","filterTags","tg","number","reduce","obj","desc","type","typ","name","nme","lineEnd","postType","postName","postTag","nameOrDescription","seedTokens","postDelimiter","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperies","properties","anyOf","enum","items"],"sources":["../../src/rules/multilineBlocks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const {\n allowMultipleTags = true,\n noFinalLineText = true,\n noZeroLineText = true,\n noSingleLineBlocks = false,\n singleLineTags = [\n 'lends', 'type',\n ],\n noMultilineBlocks = false,\n minimumLengthForMultiline = Number.POSITIVE_INFINITY,\n multilineTags = [\n '*',\n ],\n } = context.options[0] || {};\n\n const {\n source: [\n {\n tokens,\n },\n ],\n } = jsdoc;\n const {\n description,\n tag,\n } = tokens;\n const sourceLength = jsdoc.source.length;\n\n const isInvalidSingleLine = (tagName) => {\n return noSingleLineBlocks &&\n (!tagName ||\n !singleLineTags.includes(tagName) && !singleLineTags.includes('*'));\n };\n\n if (sourceLength === 1) {\n if (!isInvalidSingleLine(tag.slice(1))) {\n return;\n }\n\n const fixer = () => {\n utils.makeMultiline();\n };\n\n utils.reportJSDoc(\n 'Single line blocks are not permitted by your configuration.',\n null,\n fixer,\n true,\n );\n\n return;\n }\n\n const lineChecks = () => {\n if (\n noZeroLineText &&\n (tag || description)\n ) {\n const fixer = () => {\n const line = {\n ...tokens,\n };\n utils.emptyTokens(tokens);\n const {\n tokens: {\n delimiter,\n start,\n },\n } = jsdoc.source[1];\n utils.addLine(1, {\n ...line,\n delimiter,\n start,\n });\n };\n\n utils.reportJSDoc(\n 'Should have no text on the \"0th\" line (after the `/**`).',\n null,\n fixer,\n );\n\n return;\n }\n\n const finalLine = jsdoc.source[jsdoc.source.length - 1];\n const finalLineTokens = finalLine.tokens;\n if (\n noFinalLineText &&\n finalLineTokens.description.trim()\n ) {\n const fixer = () => {\n const line = {\n ...finalLineTokens,\n };\n line.description = line.description.trimEnd();\n\n const {\n delimiter,\n } = line;\n\n for (const prop of [\n 'delimiter',\n 'postDelimiter',\n 'tag',\n 'type',\n 'lineEnd',\n 'postType',\n 'postTag',\n 'name',\n 'postName',\n 'description',\n ]) {\n finalLineTokens[prop] = '';\n }\n\n utils.addLine(jsdoc.source.length - 1, {\n ...line,\n delimiter,\n end: '',\n });\n };\n\n utils.reportJSDoc(\n 'Should have no text on the final line (before the `*/`).',\n null,\n fixer,\n );\n }\n };\n\n if (noMultilineBlocks) {\n if (\n jsdoc.tags.length &&\n (multilineTags.includes('*') || utils.hasATag(multilineTags))\n ) {\n lineChecks();\n\n return;\n }\n\n if (jsdoc.description.length >= minimumLengthForMultiline) {\n lineChecks();\n\n return;\n }\n\n if (\n noSingleLineBlocks &&\n (!jsdoc.tags.length ||\n !utils.filterTags(({\n tag: tg,\n }) => {\n return !isInvalidSingleLine(tg);\n }).length)\n ) {\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration but fixing would result in a single ' +\n 'line block which you have prohibited with `noSingleLineBlocks`.',\n );\n\n return;\n }\n\n if (jsdoc.tags.length > 1) {\n if (!allowMultipleTags) {\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration but the block has multiple tags.',\n );\n\n return;\n }\n } else if (jsdoc.tags.length === 1 && jsdoc.description.trim()) {\n if (!allowMultipleTags) {\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration but the block has a description with a tag.',\n );\n\n return;\n }\n } else {\n const fixer = () => {\n jsdoc.source = [\n {\n number: 1,\n source: '',\n tokens: jsdoc.source.reduce((obj, {\n tokens: {\n description: desc,\n tag: tg,\n type: typ,\n name: nme,\n lineEnd,\n postType,\n postName,\n postTag,\n },\n }) => {\n if (typ) {\n obj.type = typ;\n }\n\n if (tg && typ && nme) {\n obj.postType = postType;\n }\n\n if (nme) {\n obj.name += nme;\n }\n\n if (nme && desc) {\n obj.postName = postName;\n }\n\n obj.description += desc;\n\n const nameOrDescription = obj.description || obj.name;\n if (\n nameOrDescription && nameOrDescription.slice(-1) !== ' '\n ) {\n obj.description += ' ';\n }\n\n obj.lineEnd = lineEnd;\n\n // Already filtered for multiple tags\n obj.tag += tg;\n if (tg) {\n obj.postTag = postTag || ' ';\n }\n\n return obj;\n }, utils.seedTokens({\n delimiter: '/**',\n end: '*/',\n postDelimiter: ' ',\n })),\n },\n ];\n };\n\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration.',\n null,\n fixer,\n );\n\n return;\n }\n }\n\n lineChecks();\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-multiline-blocks',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperies: false,\n properties: {\n allowMultipleTags: {\n type: 'boolean',\n },\n minimumLengthForMultiline: {\n type: 'integer',\n },\n multilineTags: {\n anyOf: [\n {\n enum: [\n '*',\n ],\n type: 'string',\n }, {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n ],\n },\n noFinalLineText: {\n type: 'boolean',\n },\n noMultilineBlocks: {\n type: 'boolean',\n },\n noSingleLineBlocks: {\n type: 'boolean',\n },\n noZeroLineText: {\n type: 'boolean',\n },\n singleLineTags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;AAAA;;;;eAEe,IAAAA,qBAAA,EAAa,CAAC;EAC3BC,OAD2B;EAE3BC,KAF2B;EAG3BC;AAH2B,CAAD,KAItB;EACJ,MAAM;IACJC,iBAAiB,GAAG,IADhB;IAEJC,eAAe,GAAG,IAFd;IAGJC,cAAc,GAAG,IAHb;IAIJC,kBAAkB,GAAG,KAJjB;IAKJC,cAAc,GAAG,CACf,OADe,EACN,MADM,CALb;IAQJC,iBAAiB,GAAG,KARhB;IASJC,yBAAyB,GAAGC,MAAM,CAACC,iBAT/B;IAUJC,aAAa,GAAG,CACd,GADc;EAVZ,IAaFZ,OAAO,CAACa,OAAR,CAAgB,CAAhB,KAAsB,EAb1B;EAeA,MAAM;IACJC,MAAM,EAAE,CACN;MACEC;IADF,CADM;EADJ,IAMFd,KANJ;EAOA,MAAM;IACJe,WADI;IAEJC;EAFI,IAGFF,MAHJ;EAIA,MAAMG,YAAY,GAAGjB,KAAK,CAACa,MAAN,CAAaK,MAAlC;;EAEA,MAAMC,mBAAmB,GAAIC,OAAD,IAAa;IACvC,OAAOf,kBAAkB,KACtB,CAACe,OAAD,IACD,CAACd,cAAc,CAACe,QAAf,CAAwBD,OAAxB,CAAD,IAAqC,CAACd,cAAc,CAACe,QAAf,CAAwB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AE;UACd0C,IAAI,EAAE;QADQ,CA/BN;QAkCVxC,cAAc,EAAE;UACd6D,KAAK,EAAE;YACLrB,IAAI,EAAE;UADD,CADO;UAIdA,IAAI,EAAE;QAJQ;MAlCN,CAFd;MA2CEA,IAAI,EAAE;IA3CR,CADM,CANJ;IAqDJA,IAAI,EAAE;EArDF;AAFL,CArQY,C"}
|
|
1
|
+
{"version":3,"file":"multilineBlocks.js","names":["iterateJsdoc","context","jsdoc","utils","allowMultipleTags","noFinalLineText","noZeroLineText","noSingleLineBlocks","singleLineTags","noMultilineBlocks","minimumLengthForMultiline","Number","POSITIVE_INFINITY","multilineTags","options","source","tokens","description","tag","sourceLength","length","isInvalidSingleLine","tagName","includes","slice","fixer","makeMultiline","reportJSDoc","lineChecks","line","emptyTokens","delimiter","start","addLine","finalLine","finalLineTokens","trim","trimEnd","prop","end","tags","hasATag","filterTags","tg","number","reduce","obj","desc","type","typ","name","nme","lineEnd","postType","postName","postTag","nameOrDescription","seedTokens","postDelimiter","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperies","properties","anyOf","enum","items"],"sources":["../../src/rules/multilineBlocks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const {\n allowMultipleTags = true,\n noFinalLineText = true,\n noZeroLineText = true,\n noSingleLineBlocks = false,\n singleLineTags = [\n 'lends', 'type',\n ],\n noMultilineBlocks = false,\n minimumLengthForMultiline = Number.POSITIVE_INFINITY,\n multilineTags = [\n '*',\n ],\n } = context.options[0] || {};\n\n const {\n source: [\n {\n tokens,\n },\n ],\n } = jsdoc;\n const {\n description,\n tag,\n } = tokens;\n const sourceLength = jsdoc.source.length;\n\n const isInvalidSingleLine = (tagName) => {\n return noSingleLineBlocks &&\n (!tagName ||\n !singleLineTags.includes(tagName) && !singleLineTags.includes('*'));\n };\n\n if (sourceLength === 1) {\n if (!isInvalidSingleLine(tag.slice(1))) {\n return;\n }\n\n const fixer = () => {\n utils.makeMultiline();\n };\n\n utils.reportJSDoc(\n 'Single line blocks are not permitted by your configuration.',\n null,\n fixer,\n true,\n );\n\n return;\n }\n\n const lineChecks = () => {\n if (\n noZeroLineText &&\n (tag || description)\n ) {\n const fixer = () => {\n const line = {\n ...tokens,\n };\n utils.emptyTokens(tokens);\n const {\n tokens: {\n delimiter,\n start,\n },\n } = jsdoc.source[1];\n utils.addLine(1, {\n ...line,\n delimiter,\n start,\n });\n };\n\n utils.reportJSDoc(\n 'Should have no text on the \"0th\" line (after the `/**`).',\n null,\n fixer,\n );\n\n return;\n }\n\n const finalLine = jsdoc.source[jsdoc.source.length - 1];\n const finalLineTokens = finalLine.tokens;\n if (\n noFinalLineText &&\n finalLineTokens.description.trim()\n ) {\n const fixer = () => {\n const line = {\n ...finalLineTokens,\n };\n line.description = line.description.trimEnd();\n\n const {\n delimiter,\n } = line;\n\n for (const prop of [\n 'delimiter',\n 'postDelimiter',\n 'tag',\n 'type',\n 'lineEnd',\n 'postType',\n 'postTag',\n 'name',\n 'postName',\n 'description',\n ]) {\n finalLineTokens[prop] = '';\n }\n\n utils.addLine(jsdoc.source.length - 1, {\n ...line,\n delimiter,\n end: '',\n });\n };\n\n utils.reportJSDoc(\n 'Should have no text on the final line (before the `*/`).',\n null,\n fixer,\n );\n }\n };\n\n if (noMultilineBlocks) {\n if (\n jsdoc.tags.length &&\n (multilineTags.includes('*') || utils.hasATag(multilineTags))\n ) {\n lineChecks();\n\n return;\n }\n\n if (jsdoc.description.length >= minimumLengthForMultiline) {\n lineChecks();\n\n return;\n }\n\n if (\n noSingleLineBlocks &&\n (!jsdoc.tags.length ||\n !utils.filterTags(({\n tag: tg,\n }) => {\n return !isInvalidSingleLine(tg);\n }).length)\n ) {\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration but fixing would result in a single ' +\n 'line block which you have prohibited with `noSingleLineBlocks`.',\n );\n\n return;\n }\n\n if (jsdoc.tags.length > 1) {\n if (!allowMultipleTags) {\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration but the block has multiple tags.',\n );\n\n return;\n }\n } else if (jsdoc.tags.length === 1 && jsdoc.description.trim()) {\n if (!allowMultipleTags) {\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration but the block has a description with a tag.',\n );\n\n return;\n }\n } else {\n const fixer = () => {\n jsdoc.source = [\n {\n number: 1,\n source: '',\n tokens: jsdoc.source.reduce((obj, {\n tokens: {\n description: desc,\n tag: tg,\n type: typ,\n name: nme,\n lineEnd,\n postType,\n postName,\n postTag,\n },\n }) => {\n if (typ) {\n obj.type = typ;\n }\n\n if (tg && typ && nme) {\n obj.postType = postType;\n }\n\n if (nme) {\n obj.name += nme;\n }\n\n if (nme && desc) {\n obj.postName = postName;\n }\n\n obj.description += desc;\n\n const nameOrDescription = obj.description || obj.name;\n if (\n nameOrDescription && nameOrDescription.slice(-1) !== ' '\n ) {\n obj.description += ' ';\n }\n\n obj.lineEnd = lineEnd;\n\n // Already filtered for multiple tags\n obj.tag += tg;\n if (tg) {\n obj.postTag = postTag || ' ';\n }\n\n return obj;\n }, utils.seedTokens({\n delimiter: '/**',\n end: '*/',\n postDelimiter: ' ',\n })),\n },\n ];\n };\n\n utils.reportJSDoc(\n 'Multiline jsdoc blocks are prohibited by ' +\n 'your configuration.',\n null,\n fixer,\n );\n\n return;\n }\n }\n\n lineChecks();\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-multiline-blocks',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperies: false,\n properties: {\n allowMultipleTags: {\n type: 'boolean',\n },\n minimumLengthForMultiline: {\n type: 'integer',\n },\n multilineTags: {\n anyOf: [\n {\n enum: [\n '*',\n ],\n type: 'string',\n }, {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n ],\n },\n noFinalLineText: {\n type: 'boolean',\n },\n noMultilineBlocks: {\n type: 'boolean',\n },\n noSingleLineBlocks: {\n type: 'boolean',\n },\n noZeroLineText: {\n type: 'boolean',\n },\n singleLineTags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AAA2C;AAAA,eAE5B,IAAAA,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,iBAAiB,GAAG,IAAI;IACxBC,eAAe,GAAG,IAAI;IACtBC,cAAc,GAAG,IAAI;IACrBC,kBAAkB,GAAG,KAAK;IAC1BC,cAAc,GAAG,CACf,OAAO,EAAE,MAAM,CAChB;IACDC,iBAAiB,GAAG,KAAK;IACzBC,yBAAyB,GAAGC,MAAM,CAACC,iBAAiB;IACpDC,aAAa,GAAG,CACd,GAAG;EAEP,CAAC,GAAGZ,OAAO,CAACa,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM;IACJC,MAAM,EAAE,CACN;MACEC;IACF,CAAC;EAEL,CAAC,GAAGd,KAAK;EACT,MAAM;IACJe,WAAW;IACXC;EACF,CAAC,GAAGF,MAAM;EACV,MAAMG,YAAY,GAAGjB,KAAK,CAACa,MAAM,CAACK,MAAM;EAExC,MAAMC,mBAAmB,GAAIC,OAAO,IAAK;IACvC,OAAOf,kBAAkB,KACtB,CAACe,OAAO,IACT,CAACd,cAAc,CAACe,QAAQ,CAACD,OAAO,CAAC,IAAI,CAACd,cAAc,CAACe,QAAQ,CAAC,GAAG,CAAC,CAAC;EACvE,CAAC;EAED,IAAIJ,YAAY,KAAK,CAAC,EAAE;IACtB,IAAI,CAACE,mBAAmB,CAACH,GAAG,CAACM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;MACtC;IACF;IAEA,MAAMC,KAAK,G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AA"}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = (0, _iterateJsdoc.default)(({
|
|
13
10
|
jsdoc,
|
|
14
11
|
report,
|
|
@@ -19,23 +16,19 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
19
16
|
utils
|
|
20
17
|
}) => {
|
|
21
18
|
let always;
|
|
22
|
-
|
|
23
19
|
if (!jsdoc.description.trim() || !jsdoc.tags.length) {
|
|
24
20
|
return;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
if (0 in context.options) {
|
|
28
23
|
always = context.options[0] === 'always';
|
|
29
24
|
} else {
|
|
30
25
|
always = true;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
const {
|
|
34
28
|
description,
|
|
35
29
|
lastDescriptionLine
|
|
36
30
|
} = utils.getDescription();
|
|
37
31
|
const descriptionEndsWithANewline = /\n\r?$/u.test(description);
|
|
38
|
-
|
|
39
32
|
if (always) {
|
|
40
33
|
if (!descriptionEndsWithANewline) {
|
|
41
34
|
const sourceLines = sourceCode.getText(jsdocNode).split('\n');
|
|
@@ -73,7 +66,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
73
66
|
type: 'layout'
|
|
74
67
|
}
|
|
75
68
|
});
|
|
76
|
-
|
|
77
69
|
exports.default = _default;
|
|
78
70
|
module.exports = exports.default;
|
|
79
71
|
//# sourceMappingURL=newlineAfterDescription.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"newlineAfterDescription.js","names":["iterateJsdoc","jsdoc","report","context","jsdocNode","sourceCode","indent","utils","always","description","trim","tags","length","options","lastDescriptionLine","getDescription","descriptionEndsWithANewline","test","sourceLines","getText","split","fixer","injectedLine","endsWith","splice","replaceText","join","line","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type"],"sources":["../../src/rules/newlineAfterDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n jsdocNode,\n sourceCode,\n indent,\n utils,\n}) => {\n let always;\n\n if (!jsdoc.description.trim() || !jsdoc.tags.length) {\n return;\n }\n\n if (0 in context.options) {\n always = context.options[0] === 'always';\n } else {\n always = true;\n }\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n const descriptionEndsWithANewline = (/\\n\\r?$/u).test(description);\n\n if (always) {\n if (!descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n\n report('There must be a newline after the description of the JSDoc block.', (fixer) => {\n // Add the new line\n const injectedLine = `${indent} *` +\n (sourceLines[lastDescriptionLine].endsWith('\\r') ? '\\r' : '');\n sourceLines.splice(lastDescriptionLine + 1, 0, injectedLine);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n }, {\n line: lastDescriptionLine,\n });\n }\n } else if (descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n report('There must be no newline after the description of the JSDoc block.', (fixer) => {\n // Remove the extra line\n sourceLines.splice(lastDescriptionLine, 1);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n }, {\n line: lastDescriptionLine,\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces a consistent padding of the block description.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description',\n },\n fixable: 'whitespace',\n schema: [\n {\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"newlineAfterDescription.js","names":["iterateJsdoc","jsdoc","report","context","jsdocNode","sourceCode","indent","utils","always","description","trim","tags","length","options","lastDescriptionLine","getDescription","descriptionEndsWithANewline","test","sourceLines","getText","split","fixer","injectedLine","endsWith","splice","replaceText","join","line","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type"],"sources":["../../src/rules/newlineAfterDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n jsdocNode,\n sourceCode,\n indent,\n utils,\n}) => {\n let always;\n\n if (!jsdoc.description.trim() || !jsdoc.tags.length) {\n return;\n }\n\n if (0 in context.options) {\n always = context.options[0] === 'always';\n } else {\n always = true;\n }\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n const descriptionEndsWithANewline = (/\\n\\r?$/u).test(description);\n\n if (always) {\n if (!descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n\n report('There must be a newline after the description of the JSDoc block.', (fixer) => {\n // Add the new line\n const injectedLine = `${indent} *` +\n (sourceLines[lastDescriptionLine].endsWith('\\r') ? '\\r' : '');\n sourceLines.splice(lastDescriptionLine + 1, 0, injectedLine);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n }, {\n line: lastDescriptionLine,\n });\n }\n } else if (descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n report('There must be no newline after the description of the JSDoc block.', (fixer) => {\n // Remove the extra line\n sourceLines.splice(lastDescriptionLine, 1);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n }, {\n line: lastDescriptionLine,\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces a consistent padding of the block description.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description',\n },\n fixable: 'whitespace',\n schema: [\n {\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n ],\n type: 'layout',\n },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A2B,EAAE;IACtC,MAAME,WAAW,GAAGb,UAAU,CAACc,OAAO,CAACf,SAAS,CAAC,CAACgB,KAAK,CAAC,IAAI,CAAC;IAC7DlB,MAAM,CAAC,oEAAoE,EAAGmB,KAAK,IAAK;MACtF;MACAH,WAAW,CAACM,MAAM,CAACV,mBAAmB,EAAE,CAAC,CAAC;MAE1C,OAAOO,KAAK,CAACI,WAAW,CAACrB,SAAS,EAAEc,WAAW,CAACQ,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC,EAAE;MACDC,IAAI,EAAEb;IACR,CAAC,CAAC;EACJ;AACF,CAAC,EAAE;EACDc,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJrB,WAAW,EAAE,yDAAyD;MACtEsB,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,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
|
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _commentParser = require("comment-parser");
|
|
9
|
-
|
|
10
8
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
// Neither a single nor 3+ asterisks are valid jsdoc per
|
|
15
11
|
// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code
|
|
16
12
|
const commentRegexp = /^\/\*(?!\*)/u;
|
|
17
13
|
const extraAsteriskCommentRegexp = /^\/\*{3,}/u;
|
|
18
|
-
|
|
19
14
|
var _default = (0, _iterateJsdoc.default)(({
|
|
20
15
|
context,
|
|
21
16
|
sourceCode,
|
|
@@ -30,24 +25,18 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
30
25
|
const nonJsdocNodes = allComments.filter(comment => {
|
|
31
26
|
const commentText = sourceCode.getText(comment);
|
|
32
27
|
let sliceIndex = 2;
|
|
33
|
-
|
|
34
28
|
if (!commentRegexp.test(commentText)) {
|
|
35
29
|
var _extraAsteriskComment;
|
|
36
|
-
|
|
37
30
|
const multiline = (_extraAsteriskComment = extraAsteriskCommentRegexp.exec(commentText)) === null || _extraAsteriskComment === void 0 ? void 0 : _extraAsteriskComment[0];
|
|
38
|
-
|
|
39
31
|
if (!multiline) {
|
|
40
32
|
return false;
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
sliceIndex = multiline.length;
|
|
44
35
|
extraAsterisks = true;
|
|
45
|
-
|
|
46
36
|
if (preventAllMultiAsteriskBlocks) {
|
|
47
37
|
return true;
|
|
48
38
|
}
|
|
49
39
|
}
|
|
50
|
-
|
|
51
40
|
const [{
|
|
52
41
|
tags = {}
|
|
53
42
|
} = {}] = (0, _commentParser.parse)(`${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`);
|
|
@@ -57,19 +46,17 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
57
46
|
return ignore.includes(tag);
|
|
58
47
|
});
|
|
59
48
|
});
|
|
60
|
-
|
|
61
49
|
if (!nonJsdocNodes.length) {
|
|
62
50
|
return;
|
|
63
51
|
}
|
|
64
|
-
|
|
65
52
|
for (const node of nonJsdocNodes) {
|
|
66
|
-
const report = makeReport(context, node);
|
|
53
|
+
const report = makeReport(context, node);
|
|
67
54
|
|
|
55
|
+
// eslint-disable-next-line no-loop-func
|
|
68
56
|
const fix = fixer => {
|
|
69
57
|
const text = sourceCode.getText(node);
|
|
70
58
|
return fixer.replaceText(node, extraAsterisks ? text.replace(extraAsteriskCommentRegexp, '/**') : text.replace('/*', '/**'));
|
|
71
59
|
};
|
|
72
|
-
|
|
73
60
|
report('Expected JSDoc-like comment to begin with two asterisks.', fix);
|
|
74
61
|
}
|
|
75
62
|
}, {
|
|
@@ -98,7 +85,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
98
85
|
type: 'layout'
|
|
99
86
|
}
|
|
100
87
|
});
|
|
101
|
-
|
|
102
88
|
exports.default = _default;
|
|
103
89
|
module.exports = exports.default;
|
|
104
90
|
//# sourceMappingURL=noBadBlocks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noBadBlocks.js","names":["commentRegexp","extraAsteriskCommentRegexp","iterateJsdoc","context","sourceCode","allComments","makeReport","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","sliceIndex","test","multiline","exec","length","tags","commentParser","slice","some","tag","includes","node","report","fix","fixer","text","replaceText","replace","checkFile","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","type"],"sources":["../../src/rules/noBadBlocks.js"],"sourcesContent":["import {\n parse as commentParser,\n} from 'comment-parser';\nimport iterateJsdoc from '../iterateJsdoc';\n\n// Neither a single nor 3+ asterisks are valid jsdoc per\n// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code\nconst commentRegexp = /^\\/\\*(?!\\*)/u;\nconst extraAsteriskCommentRegexp = /^\\/\\*{3,}/u;\n\nexport default iterateJsdoc(({\n context,\n sourceCode,\n allComments,\n makeReport,\n}) => {\n const [\n {\n ignore = [\n 'ts-check',\n 'ts-expect-error',\n 'ts-ignore',\n 'ts-nocheck',\n ],\n preventAllMultiAsteriskBlocks = false,\n } = {},\n ] = context.options;\n\n let extraAsterisks = false;\n const nonJsdocNodes = allComments.filter((comment) => {\n const commentText = sourceCode.getText(comment);\n let sliceIndex = 2;\n if (!commentRegexp.test(commentText)) {\n const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];\n if (!multiline) {\n return false;\n }\n\n sliceIndex = multiline.length;\n extraAsterisks = true;\n if (preventAllMultiAsteriskBlocks) {\n return true;\n }\n }\n\n const [\n {\n tags = {},\n } = {},\n ] = commentParser(\n `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`,\n );\n\n return tags.length && !tags.some(({\n tag,\n }) => {\n return ignore.includes(tag);\n });\n });\n\n if (!nonJsdocNodes.length) {\n return;\n }\n\n for (const node of nonJsdocNodes) {\n const report = makeReport(context, node);\n\n // eslint-disable-next-line no-loop-func\n const fix = (fixer) => {\n const text = sourceCode.getText(node);\n\n return fixer.replaceText(\n node,\n extraAsterisks ?\n text.replace(extraAsteriskCommentRegexp, '/**') :\n text.replace('/*', '/**'),\n );\n };\n\n report('Expected JSDoc-like comment to begin with two asterisks.', fix);\n }\n}, {\n checkFile: true,\n meta: {\n docs: {\n description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-bad-blocks',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n ignore: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n preventAllMultiAsteriskBlocks: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"noBadBlocks.js","names":["commentRegexp","extraAsteriskCommentRegexp","iterateJsdoc","context","sourceCode","allComments","makeReport","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","sliceIndex","test","multiline","exec","length","tags","commentParser","slice","some","tag","includes","node","report","fix","fixer","text","replaceText","replace","checkFile","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","type"],"sources":["../../src/rules/noBadBlocks.js"],"sourcesContent":["import {\n parse as commentParser,\n} from 'comment-parser';\nimport iterateJsdoc from '../iterateJsdoc';\n\n// Neither a single nor 3+ asterisks are valid jsdoc per\n// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code\nconst commentRegexp = /^\\/\\*(?!\\*)/u;\nconst extraAsteriskCommentRegexp = /^\\/\\*{3,}/u;\n\nexport default iterateJsdoc(({\n context,\n sourceCode,\n allComments,\n makeReport,\n}) => {\n const [\n {\n ignore = [\n 'ts-check',\n 'ts-expect-error',\n 'ts-ignore',\n 'ts-nocheck',\n ],\n preventAllMultiAsteriskBlocks = false,\n } = {},\n ] = context.options;\n\n let extraAsterisks = false;\n const nonJsdocNodes = allComments.filter((comment) => {\n const commentText = sourceCode.getText(comment);\n let sliceIndex = 2;\n if (!commentRegexp.test(commentText)) {\n const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];\n if (!multiline) {\n return false;\n }\n\n sliceIndex = multiline.length;\n extraAsterisks = true;\n if (preventAllMultiAsteriskBlocks) {\n return true;\n }\n }\n\n const [\n {\n tags = {},\n } = {},\n ] = commentParser(\n `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`,\n );\n\n return tags.length && !tags.some(({\n tag,\n }) => {\n return ignore.includes(tag);\n });\n });\n\n if (!nonJsdocNodes.length) {\n return;\n }\n\n for (const node of nonJsdocNodes) {\n const report = makeReport(context, node);\n\n // eslint-disable-next-line no-loop-func\n const fix = (fixer) => {\n const text = sourceCode.getText(node);\n\n return fixer.replaceText(\n node,\n extraAsterisks ?\n text.replace(extraAsteriskCommentRegexp, '/**') :\n text.replace('/*', '/**'),\n );\n };\n\n report('Expected JSDoc-like comment to begin with two asterisks.', fix);\n }\n}, {\n checkFile: true,\n meta: {\n docs: {\n description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-bad-blocks',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n ignore: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n preventAllMultiAsteriskBlocks: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA;AA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ACD,GAAG,CAAC;IAC7B,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,IAAI,CAACd,aAAa,CAACS,MAAM,EAAE;IACzB;EACF;EAEA,KAAK,MAAMO,IAAI,IAAIhB,aAAa,EAAE;IAChC,MAAMiB,MAAM,GAAGtB,UAAU,CAACH,OAAO,EAAEwB,IAAI,CAAC;;IAExC;IACA,MAAME,GAAG,GAAIC,KAAK,IAAK;MACrB,MAAMC,IAAI,GAAG3B,UAAU,CAACW,OAAO,CAACY,IAAI,CAAC;MAErC,OAAOG,KAAK,CAACE,WAAW,CACtBL,IAAI,EACJjB,cAAc,GACZqB,IAAI,CAACE,OAAO,CAAChC,0BAA0B,EAAE,KAAK,CAAC,GAC/C8B,IAAI,CAACE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAC5B;IACH,CAAC;IAEDL,MAAM,CAAC,0DAA0D,EAAEC,GAAG,CAAC;EACzE;AACF,CAAC,EAAE;EACDK,SAAS,EAAE,IAAI;EACfC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,kGAAkG;MAC/GC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVnC,MAAM,EAAE;UACNoC,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDpC,6BAA6B,EAAE;UAC7BoC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
|
package/dist/rules/noDefaults.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = (0, _iterateJsdoc.default)(({
|
|
13
10
|
context,
|
|
14
11
|
utils
|
|
@@ -17,7 +14,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
17
14
|
noOptionalParamNames
|
|
18
15
|
} = context.options[0] || {};
|
|
19
16
|
const paramTags = utils.getPresentTags(['param', 'arg', 'argument']);
|
|
20
|
-
|
|
21
17
|
for (const tag of paramTags) {
|
|
22
18
|
if (noOptionalParamNames && tag.optional) {
|
|
23
19
|
utils.reportJSDoc(`Optional param names are not permitted on @${tag.tag}.`, tag, () => {
|
|
@@ -33,9 +29,7 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
const defaultTags = utils.getPresentTags(['default', 'defaultvalue']);
|
|
38
|
-
|
|
39
33
|
for (const tag of defaultTags) {
|
|
40
34
|
if (tag.description.trim()) {
|
|
41
35
|
utils.reportJSDoc(`Default values are not permitted on @${tag.tag}.`, tag, () => {
|
|
@@ -85,7 +79,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
85
79
|
type: 'suggestion'
|
|
86
80
|
}
|
|
87
81
|
});
|
|
88
|
-
|
|
89
82
|
exports.default = _default;
|
|
90
83
|
module.exports = exports.default;
|
|
91
84
|
//# sourceMappingURL=noDefaults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noDefaults.js","names":["iterateJsdoc","context","utils","noOptionalParamNames","options","paramTags","getPresentTags","tag","optional","reportJSDoc","changeTag","name","replace","default","defaultTags","description","trim","postTag","contextDefaults","meta","docs","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","type","comment"],"sources":["../../src/rules/noDefaults.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n utils,\n}) => {\n const {\n noOptionalParamNames,\n } = context.options[0] || {};\n const paramTags = utils.getPresentTags([\n 'param', 'arg', 'argument',\n ]);\n for (const tag of paramTags) {\n if (noOptionalParamNames && tag.optional) {\n utils.reportJSDoc(`Optional param names are not permitted on @${tag.tag}.`, tag, () => {\n utils.changeTag(tag, {\n name: tag.name.replace(/([^=]*)(=.+)?/u, '$1'),\n });\n });\n } else if (tag.default) {\n utils.reportJSDoc(`Defaults are not permitted on @${tag.tag}.`, tag, () => {\n utils.changeTag(tag, {\n name: tag.name.replace(/([^=]*)(=.+)?/u, '[$1]'),\n });\n });\n }\n }\n\n const defaultTags = utils.getPresentTags([\n 'default', 'defaultvalue',\n ]);\n for (const tag of defaultTags) {\n if (tag.description.trim()) {\n utils.reportJSDoc(`Default values are not permitted on @${tag.tag}.`, tag, () => {\n utils.changeTag(tag, {\n description: '',\n postTag: '',\n });\n });\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'This rule reports defaults being used on the relevant portion of `@param` or `@default`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-defaults',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n noOptionalParamNames: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"noDefaults.js","names":["iterateJsdoc","context","utils","noOptionalParamNames","options","paramTags","getPresentTags","tag","optional","reportJSDoc","changeTag","name","replace","default","defaultTags","description","trim","postTag","contextDefaults","meta","docs","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","type","comment"],"sources":["../../src/rules/noDefaults.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n utils,\n}) => {\n const {\n noOptionalParamNames,\n } = context.options[0] || {};\n const paramTags = utils.getPresentTags([\n 'param', 'arg', 'argument',\n ]);\n for (const tag of paramTags) {\n if (noOptionalParamNames && tag.optional) {\n utils.reportJSDoc(`Optional param names are not permitted on @${tag.tag}.`, tag, () => {\n utils.changeTag(tag, {\n name: tag.name.replace(/([^=]*)(=.+)?/u, '$1'),\n });\n });\n } else if (tag.default) {\n utils.reportJSDoc(`Defaults are not permitted on @${tag.tag}.`, tag, () => {\n utils.changeTag(tag, {\n name: tag.name.replace(/([^=]*)(=.+)?/u, '[$1]'),\n });\n });\n }\n }\n\n const defaultTags = utils.getPresentTags([\n 'default', 'defaultvalue',\n ]);\n for (const tag of defaultTags) {\n if (tag.description.trim()) {\n utils.reportJSDoc(`Default values are not permitted on @${tag.tag}.`, tag, () => {\n utils.changeTag(tag, {\n description: '',\n postTag: '',\n });\n });\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'This rule reports defaults being used on the relevant portion of `@param` or `@default`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-defaults',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n noOptionalParamNames: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AAA2C;AAAA,eAE5B,IAAAA,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC;EACF,CAAC,GAAGF,OAAO,CAACG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAC5B,MAAMC,SAAS,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;MACJL,WAAW,EAAE,0FAA0F;MACvGM,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRC,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEC,IAAI,EAAE;YACR,CAAC,EACD;cACEL,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVK,OAAO,EAAE;kBACPD,IAAI,EAAE;gBACR,CAAC;gBACD5B,OAAO,EAAE;kBACP4B,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD1B,oBAAoB,EAAE;UACpB0B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
|
|
@@ -4,31 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _esquery = _interopRequireDefault(require("esquery"));
|
|
9
|
-
|
|
10
8
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
const setDefaults = state => {
|
|
15
11
|
if (!state.selectorMap) {
|
|
16
12
|
state.selectorMap = {};
|
|
17
13
|
}
|
|
18
14
|
};
|
|
19
|
-
|
|
20
15
|
const incrementSelector = (state, selector, comment) => {
|
|
21
16
|
if (!state.selectorMap[selector]) {
|
|
22
17
|
state.selectorMap[selector] = {};
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
if (!state.selectorMap[selector][comment]) {
|
|
26
20
|
state.selectorMap[selector][comment] = 0;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
state.selectorMap[selector][comment]++;
|
|
30
23
|
};
|
|
31
|
-
|
|
32
24
|
var _default = (0, _iterateJsdoc.default)(({
|
|
33
25
|
context,
|
|
34
26
|
node,
|
|
@@ -42,7 +34,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
42
34
|
// Handle error later
|
|
43
35
|
return;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
const {
|
|
47
38
|
contexts
|
|
48
39
|
} = context.options[0];
|
|
@@ -58,7 +49,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
58
49
|
incrementSelector(state, contextStr, comment);
|
|
59
50
|
}, {
|
|
60
51
|
contextSelected: true,
|
|
61
|
-
|
|
62
52
|
exit({
|
|
63
53
|
context,
|
|
64
54
|
state
|
|
@@ -75,17 +65,16 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
75
65
|
});
|
|
76
66
|
return;
|
|
77
67
|
}
|
|
78
|
-
|
|
79
68
|
setDefaults(state);
|
|
80
69
|
const {
|
|
81
70
|
contexts
|
|
82
|
-
} = context.options[0];
|
|
71
|
+
} = context.options[0];
|
|
83
72
|
|
|
73
|
+
// Report when MISSING
|
|
84
74
|
contexts.some(cntxt => {
|
|
85
75
|
const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;
|
|
86
76
|
const comment = (cntxt === null || cntxt === void 0 ? void 0 : cntxt.comment) ?? '';
|
|
87
77
|
const contextKey = contextStr === 'any' ? undefined : contextStr;
|
|
88
|
-
|
|
89
78
|
if ((!state.selectorMap[contextKey] || !state.selectorMap[contextKey][comment] || state.selectorMap[contextKey][comment] < ((cntxt === null || cntxt === void 0 ? void 0 : cntxt.minimum) ?? 1)) && (contextStr !== 'any' || Object.values(state.selectorMap).every(cmmnt => {
|
|
90
79
|
return !cmmnt[comment] || cmmnt[comment] < ((cntxt === null || cntxt === void 0 ? void 0 : cntxt.minimum) ?? 1);
|
|
91
80
|
}))) {
|
|
@@ -107,11 +96,9 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
107
96
|
});
|
|
108
97
|
return true;
|
|
109
98
|
}
|
|
110
|
-
|
|
111
99
|
return false;
|
|
112
100
|
});
|
|
113
101
|
},
|
|
114
|
-
|
|
115
102
|
matchContext: true,
|
|
116
103
|
meta: {
|
|
117
104
|
docs: {
|
|
@@ -153,7 +140,6 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
153
140
|
type: 'suggestion'
|
|
154
141
|
}
|
|
155
142
|
});
|
|
156
|
-
|
|
157
143
|
exports.default = _default;
|
|
158
144
|
module.exports = exports.default;
|
|
159
145
|
//# sourceMappingURL=noMissingSyntax.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noMissingSyntax.js","names":["setDefaults","state","selectorMap","incrementSelector","selector","comment","iterateJsdoc","context","node","info","sourceCode","options","contexts","foundContext","find","cntxt","esquery","matches","parse","visitorKeys","contextStr","contextSelected","exit","length","report","loc","start","column","line","message","some","contextKey","undefined","minimum","Object","values","every","cmmnt","data","end","matchContext","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type"],"sources":["../../src/rules/noMissingSyntax.js"],"sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst setDefaults = (state) => {\n if (!state.selectorMap) {\n state.selectorMap = {};\n }\n};\n\nconst incrementSelector = (state, selector, comment) => {\n if (!state.selectorMap[selector]) {\n state.selectorMap[selector] = {};\n }\n\n if (!state.selectorMap[selector][comment]) {\n state.selectorMap[selector][comment] = 0;\n }\n\n state.selectorMap[selector][comment]++;\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n info: {\n comment,\n },\n sourceCode,\n state,\n}) => {\n if (!context.options[0]) {\n // Handle error later\n return;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n const foundContext = contexts.find((cntxt) => {\n return typeof cntxt === 'string' ?\n esquery.matches(node, esquery.parse(cntxt), null, {\n visitorKeys: sourceCode.visitorKeys,\n }) :\n (!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context), null, {\n visitorKeys: sourceCode.visitorKeys,\n })) &&\n comment === cntxt.comment;\n });\n\n const contextStr = typeof foundContext === 'object' ?\n foundContext.context ?? 'any' :\n foundContext;\n\n setDefaults(state);\n\n incrementSelector(state, contextStr, comment);\n}, {\n contextSelected: true,\n exit ({\n context,\n state,\n }) {\n if (!context.options.length) {\n context.report({\n loc: {\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `context` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n\n const {\n contexts,\n } = context.options[0];\n\n // Report when MISSING\n contexts.some((cntxt) => {\n const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n const comment = cntxt?.comment ?? '';\n\n const contextKey = contextStr === 'any' ? undefined : contextStr;\n\n if (\n (!state.selectorMap[contextKey] ||\n !state.selectorMap[contextKey][comment] ||\n state.selectorMap[contextKey][comment] < (cntxt?.minimum ?? 1)) &&\n (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n return !cmmnt[comment] || cmmnt[comment] < (cntxt?.minimum ?? 1);\n }))\n ) {\n const message = cntxt?.message ?? 'Syntax is required: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n context.report({\n data: {\n comment,\n context: contextStr,\n },\n loc: {\n end: {\n line: 1,\n },\n start: {\n line: 1,\n },\n },\n message,\n });\n\n return true;\n }\n\n return false;\n });\n },\n matchContext: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are always expected.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-missing-syntax',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n minimum: {\n type: 'integer',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"noMissingSyntax.js","names":["setDefaults","state","selectorMap","incrementSelector","selector","comment","iterateJsdoc","context","node","info","sourceCode","options","contexts","foundContext","find","cntxt","esquery","matches","parse","visitorKeys","contextStr","contextSelected","exit","length","report","loc","start","column","line","message","some","contextKey","undefined","minimum","Object","values","every","cmmnt","data","end","matchContext","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type"],"sources":["../../src/rules/noMissingSyntax.js"],"sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst setDefaults = (state) => {\n if (!state.selectorMap) {\n state.selectorMap = {};\n }\n};\n\nconst incrementSelector = (state, selector, comment) => {\n if (!state.selectorMap[selector]) {\n state.selectorMap[selector] = {};\n }\n\n if (!state.selectorMap[selector][comment]) {\n state.selectorMap[selector][comment] = 0;\n }\n\n state.selectorMap[selector][comment]++;\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n info: {\n comment,\n },\n sourceCode,\n state,\n}) => {\n if (!context.options[0]) {\n // Handle error later\n return;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n const foundContext = contexts.find((cntxt) => {\n return typeof cntxt === 'string' ?\n esquery.matches(node, esquery.parse(cntxt), null, {\n visitorKeys: sourceCode.visitorKeys,\n }) :\n (!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context), null, {\n visitorKeys: sourceCode.visitorKeys,\n })) &&\n comment === cntxt.comment;\n });\n\n const contextStr = typeof foundContext === 'object' ?\n foundContext.context ?? 'any' :\n foundContext;\n\n setDefaults(state);\n\n incrementSelector(state, contextStr, comment);\n}, {\n contextSelected: true,\n exit ({\n context,\n state,\n }) {\n if (!context.options.length) {\n context.report({\n loc: {\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `context` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n\n const {\n contexts,\n } = context.options[0];\n\n // Report when MISSING\n contexts.some((cntxt) => {\n const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n const comment = cntxt?.comment ?? '';\n\n const contextKey = contextStr === 'any' ? undefined : contextStr;\n\n if (\n (!state.selectorMap[contextKey] ||\n !state.selectorMap[contextKey][comment] ||\n state.selectorMap[contextKey][comment] < (cntxt?.minimum ?? 1)) &&\n (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n return !cmmnt[comment] || cmmnt[comment] < (cntxt?.minimum ?? 1);\n }))\n ) {\n const message = cntxt?.message ?? 'Syntax is required: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n context.report({\n data: {\n comment,\n context: contextStr,\n },\n loc: {\n end: {\n line: 1,\n },\n start: {\n line: 1,\n },\n },\n message,\n });\n\n return true;\n }\n\n return false;\n });\n },\n matchContext: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are always expected.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-missing-syntax',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n minimum: {\n type: 'integer',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AACA;AAA2C;AAE3C,MAAMA,WAAW,GAAIC,KAAK,IAAK;EAC7B,IAAI,CAACA,KAAK,CAACC,WAAW,EAAE;IACtBD,KAAK,CAACC,WAAW,GAAG,CAAC,CAAC;EACxB;AACF,CAAC;AAED,MAAMC,iBAAiB,GAAG,CAACF,K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