eslint-plugin-jsdoc 60.0.0 → 60.1.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 +1 -1
- package/dist/rules/tagLines.cjs +71 -3
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules.d.ts +9 -1
- package/package.json +1 -1
- package/src/rules/tagLines.js +88 -3
- package/src/rules.d.ts +9 -1
package/README.md
CHANGED
|
@@ -489,7 +489,7 @@ non-default-recommended fixer).
|
|
|
489
489
|
||| [require-yields-description](./docs/rules/require-yields-description.md#readme) | Requires a description for `@yields` tags |
|
|
490
490
|
|:heavy_check_mark:|| [require-yields-type](./docs/rules/require-yields-type.md#readme) | Requires a type for `@yields` tags |
|
|
491
491
|
||:wrench:| [sort-tags](./docs/rules/sort-tags.md#readme) | Sorts tags by a specified sequence according to tag name, optionally adding line breaks between tag groups. |
|
|
492
|
-
|:heavy_check_mark:|:wrench:| [tag-lines](./docs/rules/tag-lines.md#readme) | Enforces lines (or no lines) between tags. |
|
|
492
|
+
|:heavy_check_mark:|:wrench:| [tag-lines](./docs/rules/tag-lines.md#readme) | Enforces lines (or no lines) before, after, or between tags. |
|
|
493
493
|
||:wrench:| [text-escaping](./docs/rules/text-escaping.md#readme) | Auto-escape certain characters that are input within block and tag descriptions. |
|
|
494
494
|
||:wrench:| [type-formatting](./docs/rules/type-formatting.md#readme) | Formats JSDoc type values. |
|
|
495
495
|
|:heavy_check_mark:|| [valid-types](./docs/rules/valid-types.md#readme) | Requires all types/namepaths to be valid JSDoc, Closure compiler, or TypeScript types (configurable in settings). |
|
package/dist/rules/tagLines.cjs
CHANGED
|
@@ -6,6 +6,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
/**
|
|
10
|
+
* @param {{
|
|
11
|
+
* maxBlockLines: null|number,
|
|
12
|
+
* startLines: null|number,
|
|
13
|
+
* utils: import('../iterateJsdoc.js').Utils
|
|
14
|
+
* }} cfg
|
|
15
|
+
*/
|
|
16
|
+
const checkMaxBlockLines = ({
|
|
17
|
+
maxBlockLines,
|
|
18
|
+
startLines,
|
|
19
|
+
utils
|
|
20
|
+
}) => {
|
|
21
|
+
if (typeof maxBlockLines !== 'number') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (typeof startLines === 'number' && maxBlockLines < startLines) {
|
|
25
|
+
utils.reportJSDoc('If set to a number, `maxBlockLines` must be greater than or equal to `startLines`.');
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
description
|
|
30
|
+
} = utils.getDescription();
|
|
31
|
+
const excessBlockLinesRegex = new RegExp('\n{' + (maxBlockLines + 2) + ',}', 'v');
|
|
32
|
+
const excessBlockLinesMatch = description.match(excessBlockLinesRegex);
|
|
33
|
+
const excessBlockLines = excessBlockLinesMatch?.[0]?.length ?? 0;
|
|
34
|
+
if (excessBlockLinesMatch) {
|
|
35
|
+
const excessIndexLine = description.slice(0, excessBlockLinesMatch.index).match(/\n/gv)?.length ?? 0;
|
|
36
|
+
utils.reportJSDoc(`Expected a maximum of ${maxBlockLines} line${maxBlockLines === 1 ? '' : 's'} within block description`, {
|
|
37
|
+
line: excessIndexLine
|
|
38
|
+
}, () => {
|
|
39
|
+
utils.setBlockDescription((info, seedTokens, descLines) => {
|
|
40
|
+
return [...descLines.slice(0, excessIndexLine), ...descLines.slice(excessIndexLine + excessBlockLines - 1 - maxBlockLines)].map(desc => {
|
|
41
|
+
return {
|
|
42
|
+
number: 0,
|
|
43
|
+
source: '',
|
|
44
|
+
tokens: seedTokens({
|
|
45
|
+
...info,
|
|
46
|
+
description: desc,
|
|
47
|
+
postDelimiter: desc.trim() ? ' ' : ''
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
9
57
|
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
10
58
|
context,
|
|
11
59
|
jsdoc,
|
|
@@ -15,6 +63,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
15
63
|
applyToEndTag = true,
|
|
16
64
|
count = 1,
|
|
17
65
|
endLines = 0,
|
|
66
|
+
maxBlockLines = null,
|
|
18
67
|
startLines = 0,
|
|
19
68
|
tags = {}
|
|
20
69
|
} = {}] = context.options;
|
|
@@ -152,6 +201,13 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
152
201
|
}
|
|
153
202
|
return false;
|
|
154
203
|
});
|
|
204
|
+
if (checkMaxBlockLines({
|
|
205
|
+
maxBlockLines,
|
|
206
|
+
startLines,
|
|
207
|
+
utils
|
|
208
|
+
})) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
155
211
|
if (typeof startLines === 'number') {
|
|
156
212
|
if (!jsdoc.tags.length) {
|
|
157
213
|
return;
|
|
@@ -166,7 +222,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
166
222
|
const trailingLines = description.match(/\n+$/v)?.[0]?.length;
|
|
167
223
|
const trailingDiff = (trailingLines ?? 0) - startLines;
|
|
168
224
|
if (trailingDiff > 0) {
|
|
169
|
-
utils.reportJSDoc(`Expected only ${startLines} line after block description`, {
|
|
225
|
+
utils.reportJSDoc(`Expected only ${startLines} line${startLines === 1 ? '' : 's'} after block description`, {
|
|
170
226
|
line: lastDescriptionLine - trailingDiff
|
|
171
227
|
}, () => {
|
|
172
228
|
utils.setBlockDescription((info, seedTokens, descLines) => {
|
|
@@ -211,13 +267,13 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
211
267
|
iterateAllJsdocs: true,
|
|
212
268
|
meta: {
|
|
213
269
|
docs: {
|
|
214
|
-
description: 'Enforces lines (or no lines) between tags.',
|
|
270
|
+
description: 'Enforces lines (or no lines) before, after, or between tags.',
|
|
215
271
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md#repos-sticky-header'
|
|
216
272
|
},
|
|
217
273
|
fixable: 'code',
|
|
218
274
|
schema: [{
|
|
219
275
|
description: `Defaults to "never". "any" is only useful with \`tags\` (allowing non-enforcement of lines except
|
|
220
|
-
for particular tags) or with \`startLines\` or \`
|
|
276
|
+
for particular tags) or with \`startLines\`, \`endLines\`, or \`maxBlockLines\`. It is also
|
|
221
277
|
necessary if using the linebreak-setting options of the \`sort-tags\` rule
|
|
222
278
|
so that the two rules won't conflict in both attempting to set lines
|
|
223
279
|
between tags.`,
|
|
@@ -249,6 +305,18 @@ Defaults to 1.`,
|
|
|
249
305
|
final tag only.
|
|
250
306
|
|
|
251
307
|
Defaults to \`0\`.`
|
|
308
|
+
},
|
|
309
|
+
maxBlockLines: {
|
|
310
|
+
anyOf: [{
|
|
311
|
+
type: 'integer'
|
|
312
|
+
}, {
|
|
313
|
+
type: 'null'
|
|
314
|
+
}],
|
|
315
|
+
description: `If not set to \`null\`, will enforce a maximum number of lines to the given count anywhere in the block description.
|
|
316
|
+
|
|
317
|
+
Note that if non-\`null\`, \`maxBlockLines\` must be greater than or equal to \`startLines\`.
|
|
318
|
+
|
|
319
|
+
Defaults to \`null\`.`
|
|
252
320
|
},
|
|
253
321
|
startLines: {
|
|
254
322
|
anyOf: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tagLines.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","jsdoc","utils","alwaysNever","applyToEndTag","count","endLines","startLines","tags","options","some","tg","tagIdx","lastTag","lastEmpty","reportIndex","emptyLinesCount","idx","tokens","description","end","name","tag","type","source","entries","includes","slice","lines","empty","length","lineDiff","fixer","removeTag","tagSourceOffset","reportJSDoc","line","number","addLines","currentTag","tagSourceIdx","splice","push","currentTg","tagCount","defaultAlways","overrideAlways","fixCount","lastDescriptionLine","getDescription","test","trailingLines","match","trailingDiff","setBlockDescription","info","seedTokens","descLines","map","desc","postDelimiter","trim","Array","from","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","additionalProperties","properties","anyOf","patternProperties","module"],"sources":["../../src/rules/tagLines.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const [\n alwaysNever = 'never',\n {\n applyToEndTag = true,\n count = 1,\n endLines = 0,\n startLines = 0,\n tags = {},\n } = {},\n ] = context.options;\n\n jsdoc.tags.some((tg, tagIdx) => {\n let lastTag;\n\n /**\n * @type {null|import('../iterateJsdoc.js').Integer}\n */\n let lastEmpty = null;\n\n /**\n * @type {null|import('../iterateJsdoc.js').Integer}\n */\n let reportIndex = null;\n let emptyLinesCount = 0;\n for (const [\n idx,\n {\n tokens: {\n description,\n end,\n name,\n tag,\n type,\n },\n },\n ] of tg.source.entries()) {\n // May be text after a line break within a tag description\n if (description) {\n reportIndex = null;\n }\n\n if (lastTag && [\n 'always', 'any',\n ].includes(tags[lastTag.slice(1)]?.lines)) {\n continue;\n }\n\n const empty = !tag && !name && !type && !description;\n if (\n empty && !end &&\n (alwaysNever === 'never' ||\n lastTag && tags[lastTag.slice(1)]?.lines === 'never'\n )\n ) {\n reportIndex = idx;\n\n continue;\n }\n\n if (!end) {\n if (empty) {\n emptyLinesCount++;\n } else {\n emptyLinesCount = 0;\n }\n\n lastEmpty = empty ? idx : null;\n }\n\n lastTag = tag;\n }\n\n if (\n typeof endLines === 'number' &&\n lastEmpty !== null && tagIdx === jsdoc.tags.length - 1\n ) {\n const lineDiff = endLines - emptyLinesCount;\n\n if (lineDiff < 0) {\n const fixer = () => {\n utils.removeTag(tagIdx, {\n tagSourceOffset: /** @type {import('../iterateJsdoc.js').Integer} */ (\n lastEmpty\n ) + lineDiff + 1,\n });\n };\n\n utils.reportJSDoc(\n `Expected ${endLines} trailing lines`,\n {\n line: tg.source[lastEmpty].number + lineDiff + 1,\n },\n fixer,\n );\n } else if (lineDiff > 0) {\n const fixer = () => {\n utils.addLines(\n tagIdx,\n /** @type {import('../iterateJsdoc.js').Integer} */ (lastEmpty),\n endLines - emptyLinesCount,\n );\n };\n\n utils.reportJSDoc(\n `Expected ${endLines} trailing lines`,\n {\n line: tg.source[lastEmpty].number,\n },\n fixer,\n );\n }\n\n return true;\n }\n\n if (reportIndex !== null) {\n const fixer = () => {\n utils.removeTag(tagIdx, {\n tagSourceOffset: /** @type {import('../iterateJsdoc.js').Integer} */ (\n reportIndex\n ),\n });\n };\n\n utils.reportJSDoc(\n 'Expected no lines between tags',\n {\n line: tg.source[0].number + 1,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n\n (applyToEndTag ? jsdoc.tags : jsdoc.tags.slice(0, -1)).some((tg, tagIdx) => {\n /**\n * @type {{\n * idx: import('../iterateJsdoc.js').Integer,\n * number: import('../iterateJsdoc.js').Integer\n * }[]}\n */\n const lines = [];\n\n let currentTag;\n let tagSourceIdx = 0;\n for (const [\n idx,\n {\n number,\n tokens: {\n description,\n end,\n name,\n tag,\n type,\n },\n },\n ] of tg.source.entries()) {\n if (description) {\n lines.splice(0);\n tagSourceIdx = idx;\n }\n\n if (tag) {\n currentTag = tag;\n }\n\n if (!tag && !name && !type && !description && !end) {\n lines.push({\n idx,\n number,\n });\n }\n }\n\n const currentTg = currentTag && tags[currentTag.slice(1)];\n const tagCount = currentTg?.count;\n\n const defaultAlways = alwaysNever === 'always' && currentTg?.lines !== 'never' &&\n currentTg?.lines !== 'any' && lines.length < count;\n\n let overrideAlways;\n let fixCount = count;\n if (!defaultAlways) {\n fixCount = typeof tagCount === 'number' ? tagCount : count;\n overrideAlways = currentTg?.lines === 'always' &&\n lines.length < fixCount;\n }\n\n if (defaultAlways || overrideAlways) {\n const fixer = () => {\n utils.addLines(tagIdx, lines[lines.length - 1]?.idx || tagSourceIdx + 1, fixCount - lines.length);\n };\n\n const line = lines[lines.length - 1]?.number || tg.source[tagSourceIdx].number;\n utils.reportJSDoc(\n `Expected ${fixCount} line${fixCount === 1 ? '' : 's'} between tags but found ${lines.length}`,\n {\n line,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n\n if (typeof startLines === 'number') {\n if (!jsdoc.tags.length) {\n return;\n }\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n if (!(/\\S/v).test(description)) {\n return;\n }\n\n const trailingLines = description.match(/\\n+$/v)?.[0]?.length;\n const trailingDiff = (trailingLines ?? 0) - startLines;\n if (trailingDiff > 0) {\n utils.reportJSDoc(\n `Expected only ${startLines} line after block description`,\n {\n line: lastDescriptionLine - trailingDiff,\n },\n () => {\n utils.setBlockDescription((info, seedTokens, descLines) => {\n return descLines.slice(0, -trailingDiff).map((desc) => {\n return {\n number: 0,\n source: '',\n tokens: seedTokens({\n ...info,\n description: desc,\n postDelimiter: desc.trim() ? info.postDelimiter : '',\n }),\n };\n });\n });\n },\n );\n } else if (trailingDiff < 0) {\n utils.reportJSDoc(\n `Expected ${startLines} lines after block description`,\n {\n line: lastDescriptionLine,\n },\n () => {\n utils.setBlockDescription((info, seedTokens, descLines) => {\n return [\n ...descLines,\n ...Array.from({\n length: -trailingDiff,\n }, () => {\n return '';\n }),\n ].map((desc) => {\n return {\n number: 0,\n source: '',\n tokens: seedTokens({\n ...info,\n description: desc,\n postDelimiter: desc.trim() ? info.postDelimiter : '',\n }),\n };\n });\n });\n },\n );\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces lines (or no lines) between tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n description: `Defaults to \"never\". \"any\" is only useful with \\`tags\\` (allowing non-enforcement of lines except\nfor particular tags) or with \\`startLines\\` or \\`endLines\\`. It is also\nnecessary if using the linebreak-setting options of the \\`sort-tags\\` rule\nso that the two rules won't conflict in both attempting to set lines\nbetween tags.`,\n enum: [\n 'always', 'any', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n applyToEndTag: {\n description: `Set to \\`false\\` and use with \"always\" to indicate the normal lines to be\nadded after tags should not be added after the final tag.\n\nDefaults to \\`true\\`.`,\n type: 'boolean',\n },\n count: {\n description: `Use with \"always\" to indicate the number of lines to require be present.\n\nDefaults to 1.`,\n type: 'integer',\n },\n endLines: {\n anyOf: [\n {\n type: 'integer',\n },\n {\n type: 'null',\n },\n ],\n description: `If not set to \\`null\\`, will enforce end lines to the given count on the\nfinal tag only.\n\nDefaults to \\`0\\`.`,\n },\n startLines: {\n anyOf: [\n {\n type: 'integer',\n },\n {\n type: 'null',\n },\n ],\n description: `If not set to \\`null\\`, will enforce end lines to the given count before the\nfirst tag only, unless there is only whitespace content, in which case,\na line count will not be enforced.\n\nDefaults to \\`0\\`.`,\n },\n tags: {\n description: `Overrides the default behavior depending on specific tags.\n\nAn object whose keys are tag names and whose values are objects with the\nfollowing keys:\n\n1. \\`lines\\` - Set to \\`always\\`, \\`never\\`, or \\`any\\` to override.\n2. \\`count\\` - Overrides main \\`count\\` (for \"always\")\n\nDefaults to empty object.`,\n patternProperties: {\n '.*': {\n additionalProperties: false,\n properties: {\n count: {\n type: 'integer',\n },\n lines: {\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n },\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qB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AAU,EAAE;UACVkE,KAAK,EAAE,CACL;YACElD,IAAI,EAAE;UACR,CAAC,EACD;YACEA,IAAI,EAAE;UACR,CAAC,CACF;UACDJ,WAAW,EAAE;AACzB;AACA;AACA;AACA;QACU,CAAC;QACDX,IAAI,EAAE;UACJW,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;UACduD,iBAAiB,EAAE;YACjB,IAAI,EAAE;cACJH,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVnE,KAAK,EAAE;kBACLkB,IAAI,EAAE;gBACR,CAAC;gBACDK,KAAK,EAAE;kBACL0C,IAAI,EAAE,CACJ,QAAQ,EAAE,OAAO,EAAE,KAAK,CACzB;kBACD/C,IAAI,EAAE;gBACR;cACF;YACF;UACF,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoD,MAAA,CAAA7E,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"tagLines.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","checkMaxBlockLines","maxBlockLines","startLines","utils","reportJSDoc","description","getDescription","excessBlockLinesRegex","RegExp","excessBlockLinesMatch","match","excessBlockLines","length","excessIndexLine","slice","index","line","setBlockDescription","info","seedTokens","descLines","map","desc","number","source","tokens","postDelimiter","trim","_default","exports","iterateJsdoc","context","jsdoc","alwaysNever","applyToEndTag","count","endLines","tags","options","some","tg","tagIdx","lastTag","lastEmpty","reportIndex","emptyLinesCount","idx","end","name","tag","type","entries","includes","lines","empty","lineDiff","fixer","removeTag","tagSourceOffset","addLines","currentTag","tagSourceIdx","splice","push","currentTg","tagCount","defaultAlways","overrideAlways","fixCount","lastDescriptionLine","test","trailingLines","trailingDiff","Array","from","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","additionalProperties","properties","anyOf","patternProperties","module"],"sources":["../../src/rules/tagLines.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {{\n * maxBlockLines: null|number,\n * startLines: null|number,\n * utils: import('../iterateJsdoc.js').Utils\n * }} cfg\n */\nconst checkMaxBlockLines = ({\n maxBlockLines,\n startLines,\n utils,\n}) => {\n if (typeof maxBlockLines !== 'number') {\n return false;\n }\n\n if (typeof startLines === 'number' && maxBlockLines < startLines) {\n utils.reportJSDoc(\n 'If set to a number, `maxBlockLines` must be greater than or equal to `startLines`.',\n );\n return true;\n }\n\n const {\n description,\n } = utils.getDescription();\n const excessBlockLinesRegex = new RegExp('\\n{' + (maxBlockLines + 2) + ',}', 'v');\n const excessBlockLinesMatch = description.match(excessBlockLinesRegex);\n const excessBlockLines = excessBlockLinesMatch?.[0]?.length ?? 0;\n if (excessBlockLinesMatch) {\n const excessIndexLine = description.slice(0, excessBlockLinesMatch.index).match(/\\n/gv)?.length ?? 0;\n utils.reportJSDoc(\n `Expected a maximum of ${maxBlockLines} line${maxBlockLines === 1 ? '' : 's'} within block description`,\n {\n line: excessIndexLine,\n },\n () => {\n utils.setBlockDescription((info, seedTokens, descLines) => {\n return [\n ...descLines.slice(0, excessIndexLine),\n ...descLines.slice(excessIndexLine + excessBlockLines - 1 - maxBlockLines),\n ].map((desc) => {\n return {\n number: 0,\n source: '',\n tokens: seedTokens({\n ...info,\n description: desc,\n postDelimiter: desc.trim() ? ' ' : '',\n }),\n };\n });\n });\n },\n );\n return true;\n }\n\n return false;\n};\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const [\n alwaysNever = 'never',\n {\n applyToEndTag = true,\n count = 1,\n endLines = 0,\n maxBlockLines = null,\n startLines = 0,\n tags = {},\n } = {},\n ] = context.options;\n\n jsdoc.tags.some((tg, tagIdx) => {\n let lastTag;\n\n /**\n * @type {null|import('../iterateJsdoc.js').Integer}\n */\n let lastEmpty = null;\n\n /**\n * @type {null|import('../iterateJsdoc.js').Integer}\n */\n let reportIndex = null;\n let emptyLinesCount = 0;\n for (const [\n idx,\n {\n tokens: {\n description,\n end,\n name,\n tag,\n type,\n },\n },\n ] of tg.source.entries()) {\n // May be text after a line break within a tag description\n if (description) {\n reportIndex = null;\n }\n\n if (lastTag && [\n 'always', 'any',\n ].includes(tags[lastTag.slice(1)]?.lines)) {\n continue;\n }\n\n const empty = !tag && !name && !type && !description;\n if (\n empty && !end &&\n (alwaysNever === 'never' ||\n lastTag && tags[lastTag.slice(1)]?.lines === 'never'\n )\n ) {\n reportIndex = idx;\n\n continue;\n }\n\n if (!end) {\n if (empty) {\n emptyLinesCount++;\n } else {\n emptyLinesCount = 0;\n }\n\n lastEmpty = empty ? idx : null;\n }\n\n lastTag = tag;\n }\n\n if (\n typeof endLines === 'number' &&\n lastEmpty !== null && tagIdx === jsdoc.tags.length - 1\n ) {\n const lineDiff = endLines - emptyLinesCount;\n\n if (lineDiff < 0) {\n const fixer = () => {\n utils.removeTag(tagIdx, {\n tagSourceOffset: /** @type {import('../iterateJsdoc.js').Integer} */ (\n lastEmpty\n ) + lineDiff + 1,\n });\n };\n\n utils.reportJSDoc(\n `Expected ${endLines} trailing lines`,\n {\n line: tg.source[lastEmpty].number + lineDiff + 1,\n },\n fixer,\n );\n } else if (lineDiff > 0) {\n const fixer = () => {\n utils.addLines(\n tagIdx,\n /** @type {import('../iterateJsdoc.js').Integer} */ (lastEmpty),\n endLines - emptyLinesCount,\n );\n };\n\n utils.reportJSDoc(\n `Expected ${endLines} trailing lines`,\n {\n line: tg.source[lastEmpty].number,\n },\n fixer,\n );\n }\n\n return true;\n }\n\n if (reportIndex !== null) {\n const fixer = () => {\n utils.removeTag(tagIdx, {\n tagSourceOffset: /** @type {import('../iterateJsdoc.js').Integer} */ (\n reportIndex\n ),\n });\n };\n\n utils.reportJSDoc(\n 'Expected no lines between tags',\n {\n line: tg.source[0].number + 1,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n\n (applyToEndTag ? jsdoc.tags : jsdoc.tags.slice(0, -1)).some((tg, tagIdx) => {\n /**\n * @type {{\n * idx: import('../iterateJsdoc.js').Integer,\n * number: import('../iterateJsdoc.js').Integer\n * }[]}\n */\n const lines = [];\n\n let currentTag;\n let tagSourceIdx = 0;\n for (const [\n idx,\n {\n number,\n tokens: {\n description,\n end,\n name,\n tag,\n type,\n },\n },\n ] of tg.source.entries()) {\n if (description) {\n lines.splice(0);\n tagSourceIdx = idx;\n }\n\n if (tag) {\n currentTag = tag;\n }\n\n if (!tag && !name && !type && !description && !end) {\n lines.push({\n idx,\n number,\n });\n }\n }\n\n const currentTg = currentTag && tags[currentTag.slice(1)];\n const tagCount = currentTg?.count;\n\n const defaultAlways = alwaysNever === 'always' && currentTg?.lines !== 'never' &&\n currentTg?.lines !== 'any' && lines.length < count;\n\n let overrideAlways;\n let fixCount = count;\n if (!defaultAlways) {\n fixCount = typeof tagCount === 'number' ? tagCount : count;\n overrideAlways = currentTg?.lines === 'always' &&\n lines.length < fixCount;\n }\n\n if (defaultAlways || overrideAlways) {\n const fixer = () => {\n utils.addLines(tagIdx, lines[lines.length - 1]?.idx || tagSourceIdx + 1, fixCount - lines.length);\n };\n\n const line = lines[lines.length - 1]?.number || tg.source[tagSourceIdx].number;\n utils.reportJSDoc(\n `Expected ${fixCount} line${fixCount === 1 ? '' : 's'} between tags but found ${lines.length}`,\n {\n line,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n\n if (checkMaxBlockLines({\n maxBlockLines,\n startLines,\n utils,\n })) {\n return;\n }\n\n if (typeof startLines === 'number') {\n if (!jsdoc.tags.length) {\n return;\n }\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n if (!(/\\S/v).test(description)) {\n return;\n }\n\n const trailingLines = description.match(/\\n+$/v)?.[0]?.length;\n const trailingDiff = (trailingLines ?? 0) - startLines;\n if (trailingDiff > 0) {\n utils.reportJSDoc(\n `Expected only ${startLines} line${startLines === 1 ? '' : 's'} after block description`,\n {\n line: lastDescriptionLine - trailingDiff,\n },\n () => {\n utils.setBlockDescription((info, seedTokens, descLines) => {\n return descLines.slice(0, -trailingDiff).map((desc) => {\n return {\n number: 0,\n source: '',\n tokens: seedTokens({\n ...info,\n description: desc,\n postDelimiter: desc.trim() ? info.postDelimiter : '',\n }),\n };\n });\n });\n },\n );\n } else if (trailingDiff < 0) {\n utils.reportJSDoc(\n `Expected ${startLines} lines after block description`,\n {\n line: lastDescriptionLine,\n },\n () => {\n utils.setBlockDescription((info, seedTokens, descLines) => {\n return [\n ...descLines,\n ...Array.from({\n length: -trailingDiff,\n }, () => {\n return '';\n }),\n ].map((desc) => {\n return {\n number: 0,\n source: '',\n tokens: seedTokens({\n ...info,\n description: desc,\n postDelimiter: desc.trim() ? info.postDelimiter : '',\n }),\n };\n });\n });\n },\n );\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces lines (or no lines) before, after, or between tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n description: `Defaults to \"never\". \"any\" is only useful with \\`tags\\` (allowing non-enforcement of lines except\nfor particular tags) or with \\`startLines\\`, \\`endLines\\`, or \\`maxBlockLines\\`. It is also\nnecessary if using the linebreak-setting options of the \\`sort-tags\\` rule\nso that the two rules won't conflict in both attempting to set lines\nbetween tags.`,\n enum: [\n 'always', 'any', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n applyToEndTag: {\n description: `Set to \\`false\\` and use with \"always\" to indicate the normal lines to be\nadded after tags should not be added after the final tag.\n\nDefaults to \\`true\\`.`,\n type: 'boolean',\n },\n count: {\n description: `Use with \"always\" to indicate the number of lines to require be present.\n\nDefaults to 1.`,\n type: 'integer',\n },\n endLines: {\n anyOf: [\n {\n type: 'integer',\n },\n {\n type: 'null',\n },\n ],\n description: `If not set to \\`null\\`, will enforce end lines to the given count on the\nfinal tag only.\n\nDefaults to \\`0\\`.`,\n },\n maxBlockLines: {\n anyOf: [\n {\n type: 'integer',\n },\n {\n type: 'null',\n },\n ],\n description: `If not set to \\`null\\`, will enforce a maximum number of lines to the given count anywhere in the block description.\n\nNote that if non-\\`null\\`, \\`maxBlockLines\\` must be greater than or equal to \\`startLines\\`.\n\nDefaults to \\`null\\`.`,\n },\n startLines: {\n anyOf: [\n {\n type: 'integer',\n },\n {\n type: 'null',\n },\n ],\n description: `If not set to \\`null\\`, will enforce end lines to the given count before the\nfirst tag only, unless there is only whitespace content, in which case,\na line count will not be enforced.\n\nDefaults to \\`0\\`.`,\n },\n tags: {\n description: `Overrides the default behavior depending on specific tags.\n\nAn object whose keys are tag names and whose values are objects with the\nfollowing keys:\n\n1. \\`lines\\` - Set to \\`always\\`, \\`never\\`, or \\`any\\` to override.\n2. \\`count\\` - Overrides main \\`count\\` (for \"always\")\n\nDefaults to empty object.`,\n patternProperties: {\n '.*': {\n additionalProperties: false,\n properties: {\n count: {\n type: 'integer',\n },\n lines: {\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n },\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,kBAAkB,GAAGA,CAAC;EAC1BC,aAAa;EACbC,UAAU;EACVC;AACF,CAAC,KAAK;EACJ,IAAI,OAAOF,aAAa,KAAK,QAAQ,EAAE;IACrC,OAAO,KAAK;EACd;EAEA,IAAI,OAAOC,UAAU,KAAK,QAAQ,IAAID,aAAa,GAAGC,UAAU,EAAE;IAChEC,KAAK,CAACC,WAAW,CACf,oFACF,CAAC;IACD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;AACzB;AACA;AACA,sBAAsB;UACV6C,IAAI,EAAE;QACR,CAAC;QACDf,KAAK,EAAE;UACL9B,WAAW,EAAE;AACzB;AACA,eAAe;UACH6C,IAAI,EAAE;QACR,CAAC;QACDd,QAAQ,EAAE;UACRgD,KAAK,EAAE,CACL;YACElC,IAAI,EAAE;UACR,CAAC,EACD;YACEA,IAAI,EAAE;UACR,CAAC,CACF;UACD7C,WAAW,EAAE;AACzB;AACA;AACA;QACU,CAAC;QACDJ,aAAa,EAAE;UACbmF,KAAK,EAAE,CACL;YACElC,IAAI,EAAE;UACR,CAAC,EACD;YACEA,IAAI,EAAE;UACR,CAAC,CACF;UACD7C,WAAW,EAAE;AACzB;AACA;AACA;AACA;QACU,CAAC;QACDH,UAAU,EAAE;UACVkF,KAAK,EAAE,CACL;YACElC,IAAI,EAAE;UACR,CAAC,EACD;YACEA,IAAI,EAAE;UACR,CAAC,CACF;UACD7C,WAAW,EAAE;AACzB;AACA;AACA;AACA;QACU,CAAC;QACDgC,IAAI,EAAE;UACJhC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;UACdgF,iBAAiB,EAAE;YACjB,IAAI,EAAE;cACJH,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVhD,KAAK,EAAE;kBACLe,IAAI,EAAE;gBACR,CAAC;gBACDG,KAAK,EAAE;kBACL4B,IAAI,EAAE,CACJ,QAAQ,EAAE,OAAO,EAAE,KAAK,CACzB;kBACD/B,IAAI,EAAE;gBACR;cACF;YACF;UACF,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoC,MAAA,CAAAzD,OAAA,GAAAA,OAAA,CAAA9B,OAAA","ignoreList":[]}
|
package/dist/rules.d.ts
CHANGED
|
@@ -2826,7 +2826,7 @@ export interface Rules {
|
|
|
2826
2826
|
}
|
|
2827
2827
|
];
|
|
2828
2828
|
|
|
2829
|
-
/** Enforces lines (or no lines) between tags. */
|
|
2829
|
+
/** Enforces lines (or no lines) before, after, or between tags. */
|
|
2830
2830
|
"jsdoc/tag-lines":
|
|
2831
2831
|
| []
|
|
2832
2832
|
| ["always" | "any" | "never"]
|
|
@@ -2853,6 +2853,14 @@ export interface Rules {
|
|
|
2853
2853
|
* Defaults to `0`.
|
|
2854
2854
|
*/
|
|
2855
2855
|
endLines?: number | null;
|
|
2856
|
+
/**
|
|
2857
|
+
* If not set to `null`, will enforce a maximum number of lines to the given count anywhere in the block description.
|
|
2858
|
+
*
|
|
2859
|
+
* Note that if non-`null`, `maxBlockLines` must be greater than or equal to `startLines`.
|
|
2860
|
+
*
|
|
2861
|
+
* Defaults to `null`.
|
|
2862
|
+
*/
|
|
2863
|
+
maxBlockLines?: number | null;
|
|
2856
2864
|
/**
|
|
2857
2865
|
* If not set to `null`, will enforce end lines to the given count before the
|
|
2858
2866
|
* first tag only, unless there is only whitespace content, in which case,
|
package/package.json
CHANGED
package/src/rules/tagLines.js
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @param {{
|
|
5
|
+
* maxBlockLines: null|number,
|
|
6
|
+
* startLines: null|number,
|
|
7
|
+
* utils: import('../iterateJsdoc.js').Utils
|
|
8
|
+
* }} cfg
|
|
9
|
+
*/
|
|
10
|
+
const checkMaxBlockLines = ({
|
|
11
|
+
maxBlockLines,
|
|
12
|
+
startLines,
|
|
13
|
+
utils,
|
|
14
|
+
}) => {
|
|
15
|
+
if (typeof maxBlockLines !== 'number') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof startLines === 'number' && maxBlockLines < startLines) {
|
|
20
|
+
utils.reportJSDoc(
|
|
21
|
+
'If set to a number, `maxBlockLines` must be greater than or equal to `startLines`.',
|
|
22
|
+
);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
description,
|
|
28
|
+
} = utils.getDescription();
|
|
29
|
+
const excessBlockLinesRegex = new RegExp('\n{' + (maxBlockLines + 2) + ',}', 'v');
|
|
30
|
+
const excessBlockLinesMatch = description.match(excessBlockLinesRegex);
|
|
31
|
+
const excessBlockLines = excessBlockLinesMatch?.[0]?.length ?? 0;
|
|
32
|
+
if (excessBlockLinesMatch) {
|
|
33
|
+
const excessIndexLine = description.slice(0, excessBlockLinesMatch.index).match(/\n/gv)?.length ?? 0;
|
|
34
|
+
utils.reportJSDoc(
|
|
35
|
+
`Expected a maximum of ${maxBlockLines} line${maxBlockLines === 1 ? '' : 's'} within block description`,
|
|
36
|
+
{
|
|
37
|
+
line: excessIndexLine,
|
|
38
|
+
},
|
|
39
|
+
() => {
|
|
40
|
+
utils.setBlockDescription((info, seedTokens, descLines) => {
|
|
41
|
+
return [
|
|
42
|
+
...descLines.slice(0, excessIndexLine),
|
|
43
|
+
...descLines.slice(excessIndexLine + excessBlockLines - 1 - maxBlockLines),
|
|
44
|
+
].map((desc) => {
|
|
45
|
+
return {
|
|
46
|
+
number: 0,
|
|
47
|
+
source: '',
|
|
48
|
+
tokens: seedTokens({
|
|
49
|
+
...info,
|
|
50
|
+
description: desc,
|
|
51
|
+
postDelimiter: desc.trim() ? ' ' : '',
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
|
|
3
64
|
export default iterateJsdoc(({
|
|
4
65
|
context,
|
|
5
66
|
jsdoc,
|
|
@@ -11,6 +72,7 @@ export default iterateJsdoc(({
|
|
|
11
72
|
applyToEndTag = true,
|
|
12
73
|
count = 1,
|
|
13
74
|
endLines = 0,
|
|
75
|
+
maxBlockLines = null,
|
|
14
76
|
startLines = 0,
|
|
15
77
|
tags = {},
|
|
16
78
|
} = {},
|
|
@@ -218,6 +280,14 @@ export default iterateJsdoc(({
|
|
|
218
280
|
return false;
|
|
219
281
|
});
|
|
220
282
|
|
|
283
|
+
if (checkMaxBlockLines({
|
|
284
|
+
maxBlockLines,
|
|
285
|
+
startLines,
|
|
286
|
+
utils,
|
|
287
|
+
})) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
221
291
|
if (typeof startLines === 'number') {
|
|
222
292
|
if (!jsdoc.tags.length) {
|
|
223
293
|
return;
|
|
@@ -235,7 +305,7 @@ export default iterateJsdoc(({
|
|
|
235
305
|
const trailingDiff = (trailingLines ?? 0) - startLines;
|
|
236
306
|
if (trailingDiff > 0) {
|
|
237
307
|
utils.reportJSDoc(
|
|
238
|
-
`Expected only ${startLines} line after block description`,
|
|
308
|
+
`Expected only ${startLines} line${startLines === 1 ? '' : 's'} after block description`,
|
|
239
309
|
{
|
|
240
310
|
line: lastDescriptionLine - trailingDiff,
|
|
241
311
|
},
|
|
@@ -290,14 +360,14 @@ export default iterateJsdoc(({
|
|
|
290
360
|
iterateAllJsdocs: true,
|
|
291
361
|
meta: {
|
|
292
362
|
docs: {
|
|
293
|
-
description: 'Enforces lines (or no lines) between tags.',
|
|
363
|
+
description: 'Enforces lines (or no lines) before, after, or between tags.',
|
|
294
364
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md#repos-sticky-header',
|
|
295
365
|
},
|
|
296
366
|
fixable: 'code',
|
|
297
367
|
schema: [
|
|
298
368
|
{
|
|
299
369
|
description: `Defaults to "never". "any" is only useful with \`tags\` (allowing non-enforcement of lines except
|
|
300
|
-
for particular tags) or with \`startLines\` or \`
|
|
370
|
+
for particular tags) or with \`startLines\`, \`endLines\`, or \`maxBlockLines\`. It is also
|
|
301
371
|
necessary if using the linebreak-setting options of the \`sort-tags\` rule
|
|
302
372
|
so that the two rules won't conflict in both attempting to set lines
|
|
303
373
|
between tags.`,
|
|
@@ -335,6 +405,21 @@ Defaults to 1.`,
|
|
|
335
405
|
final tag only.
|
|
336
406
|
|
|
337
407
|
Defaults to \`0\`.`,
|
|
408
|
+
},
|
|
409
|
+
maxBlockLines: {
|
|
410
|
+
anyOf: [
|
|
411
|
+
{
|
|
412
|
+
type: 'integer',
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
type: 'null',
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
description: `If not set to \`null\`, will enforce a maximum number of lines to the given count anywhere in the block description.
|
|
419
|
+
|
|
420
|
+
Note that if non-\`null\`, \`maxBlockLines\` must be greater than or equal to \`startLines\`.
|
|
421
|
+
|
|
422
|
+
Defaults to \`null\`.`,
|
|
338
423
|
},
|
|
339
424
|
startLines: {
|
|
340
425
|
anyOf: [
|
package/src/rules.d.ts
CHANGED
|
@@ -2826,7 +2826,7 @@ export interface Rules {
|
|
|
2826
2826
|
}
|
|
2827
2827
|
];
|
|
2828
2828
|
|
|
2829
|
-
/** Enforces lines (or no lines) between tags. */
|
|
2829
|
+
/** Enforces lines (or no lines) before, after, or between tags. */
|
|
2830
2830
|
"jsdoc/tag-lines":
|
|
2831
2831
|
| []
|
|
2832
2832
|
| ["always" | "any" | "never"]
|
|
@@ -2853,6 +2853,14 @@ export interface Rules {
|
|
|
2853
2853
|
* Defaults to `0`.
|
|
2854
2854
|
*/
|
|
2855
2855
|
endLines?: number | null;
|
|
2856
|
+
/**
|
|
2857
|
+
* If not set to `null`, will enforce a maximum number of lines to the given count anywhere in the block description.
|
|
2858
|
+
*
|
|
2859
|
+
* Note that if non-`null`, `maxBlockLines` must be greater than or equal to `startLines`.
|
|
2860
|
+
*
|
|
2861
|
+
* Defaults to `null`.
|
|
2862
|
+
*/
|
|
2863
|
+
maxBlockLines?: number | null;
|
|
2856
2864
|
/**
|
|
2857
2865
|
* If not set to `null`, will enforce end lines to the given count before the
|
|
2858
2866
|
* first tag only, unless there is only whitespace content, in which case,
|