eslint-plugin-jsdoc 44.2.3 → 44.2.4
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/dist/alignTransform.js +86 -4
- package/dist/alignTransform.js.map +1 -1
- package/dist/exportParser.js +134 -4
- package/dist/exportParser.js.map +1 -1
- package/dist/iterateJsdoc.js +936 -345
- package/dist/iterateJsdoc.js.map +1 -1
- package/dist/jsdocUtils.js +173 -105
- package/dist/jsdocUtils.js.map +1 -1
- package/dist/rules/checkAlignment.js +6 -0
- package/dist/rules/checkAlignment.js.map +1 -1
- package/dist/rules/checkExamples.js +70 -6
- package/dist/rules/checkExamples.js.map +1 -1
- package/dist/rules/checkIndentation.js +11 -1
- package/dist/rules/checkIndentation.js.map +1 -1
- package/dist/rules/checkLineAlignment.js +68 -4
- package/dist/rules/checkLineAlignment.js.map +1 -1
- package/dist/rules/checkParamNames.js +12 -7
- package/dist/rules/checkParamNames.js.map +1 -1
- package/dist/rules/checkPropertyNames.js +13 -7
- package/dist/rules/checkPropertyNames.js.map +1 -1
- package/dist/rules/checkTagNames.js +45 -5
- package/dist/rules/checkTagNames.js.map +1 -1
- package/dist/rules/checkTypes.js +97 -36
- package/dist/rules/checkTypes.js.map +1 -1
- package/dist/rules/checkValues.js +6 -6
- package/dist/rules/checkValues.js.map +1 -1
- package/dist/rules/emptyTags.js +8 -1
- package/dist/rules/emptyTags.js.map +1 -1
- package/dist/rules/informativeDocs.js +26 -7
- package/dist/rules/informativeDocs.js.map +1 -1
- package/dist/rules/matchDescription.js +18 -1
- package/dist/rules/matchDescription.js.map +1 -1
- package/dist/rules/matchName.js +2 -2
- package/dist/rules/matchName.js.map +1 -1
- package/dist/rules/multilineBlocks.js +12 -1
- package/dist/rules/multilineBlocks.js.map +1 -1
- package/dist/rules/noBadBlocks.js +3 -5
- package/dist/rules/noBadBlocks.js.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.js +2 -0
- package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
- package/dist/rules/noMissingSyntax.js +58 -15
- package/dist/rules/noMissingSyntax.js.map +1 -1
- package/dist/rules/noMultiAsterisks.js +1 -6
- package/dist/rules/noMultiAsterisks.js.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +17 -4
- package/dist/rules/noRestrictedSyntax.js.map +1 -1
- package/dist/rules/noTypes.js +3 -0
- package/dist/rules/noTypes.js.map +1 -1
- package/dist/rules/noUndefinedTypes.js +61 -20
- package/dist/rules/noUndefinedTypes.js.map +1 -1
- package/dist/rules/requireAsteriskPrefix.js +20 -0
- package/dist/rules/requireAsteriskPrefix.js.map +1 -1
- package/dist/rules/requireDescription.js +6 -2
- package/dist/rules/requireDescription.js.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +72 -9
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
- package/dist/rules/requireFileOverview.js +9 -4
- package/dist/rules/requireFileOverview.js.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +23 -6
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
- package/dist/rules/requireJsdoc.js +144 -28
- package/dist/rules/requireJsdoc.js.map +1 -1
- package/dist/rules/requireParam.js +46 -2
- package/dist/rules/requireParam.js.map +1 -1
- package/dist/rules/requireProperty.js +1 -1
- package/dist/rules/requireProperty.js.map +1 -1
- package/dist/rules/requireReturns.js +2 -2
- package/dist/rules/requireReturns.js.map +1 -1
- package/dist/rules/requireReturnsCheck.js +9 -2
- package/dist/rules/requireReturnsCheck.js.map +1 -1
- package/dist/rules/requireThrows.js +2 -2
- package/dist/rules/requireThrows.js.map +1 -1
- package/dist/rules/requireYields.js +9 -2
- package/dist/rules/requireYields.js.map +1 -1
- package/dist/rules/requireYieldsCheck.js +19 -5
- package/dist/rules/requireYieldsCheck.js.map +1 -1
- package/dist/rules/sortTags.js +67 -9
- package/dist/rules/sortTags.js.map +1 -1
- package/dist/rules/tagLines.js +22 -3
- package/dist/rules/tagLines.js.map +1 -1
- package/dist/rules/textEscaping.js +16 -2
- package/dist/rules/textEscaping.js.map +1 -1
- package/dist/rules/validTypes.js +25 -8
- package/dist/rules/validTypes.js.map +1 -1
- package/dist/utils/hasReturnValue.js +77 -43
- package/dist/utils/hasReturnValue.js.map +1 -1
- package/docs/rules/check-tag-names.md +15 -0
- package/docs/rules/no-missing-syntax.md +6 -0
- package/docs/rules/require-description-complete-sentence.md +525 -289
- package/docs/rules/require-description.md +289 -525
- package/docs/rules/require-file-overview.md +7 -0
- package/docs/rules/require-jsdoc.md +1 -1
- package/docs/rules/require-param-description.md +116 -1694
- package/docs/rules/require-param-name.md +58 -133
- package/docs/rules/require-param-type.md +119 -55
- package/docs/rules/require-param.md +1700 -111
- package/docs/rules/require-property-description.md +39 -79
- package/docs/rules/require-property-name.md +21 -30
- package/docs/rules/require-property-type.md +21 -21
- package/docs/rules/require-property.md +82 -33
- package/docs/rules/require-returns-check.md +636 -747
- package/docs/rules/require-returns-description.md +61 -933
- package/docs/rules/require-returns-type.md +42 -79
- package/docs/rules/require-returns.md +1081 -61
- package/docs/rules/require-yields-check.md +238 -517
- package/docs/rules/require-yields.md +517 -238
- package/docs/rules/valid-types.md +1 -1
- package/docs/settings.md +1 -1
- package/package.json +5 -4
- package/tsconfig.json +2 -3
|
@@ -31,6 +31,11 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
31
31
|
tag
|
|
32
32
|
} = tokens;
|
|
33
33
|
const sourceLength = jsdoc.source.length;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {string} tagName
|
|
37
|
+
* @returns {boolean}
|
|
38
|
+
*/
|
|
34
39
|
const isInvalidSingleLine = tagName => {
|
|
35
40
|
return noSingleLineBlocks && (!tagName || !singleLineTags.includes(tagName) && !singleLineTags.includes('*'));
|
|
36
41
|
};
|
|
@@ -78,7 +83,13 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
78
83
|
delimiter
|
|
79
84
|
} = line;
|
|
80
85
|
for (const prop of ['delimiter', 'postDelimiter', 'tag', 'type', 'lineEnd', 'postType', 'postTag', 'name', 'postName', 'description']) {
|
|
81
|
-
finalLineTokens[
|
|
86
|
+
finalLineTokens[
|
|
87
|
+
/**
|
|
88
|
+
* @type {"delimiter"|"postDelimiter"|"tag"|"type"|
|
|
89
|
+
* "lineEnd"|"postType"|"postTag"|"name"|
|
|
90
|
+
* "postName"|"description"}
|
|
91
|
+
*/
|
|
92
|
+
prop] = '';
|
|
82
93
|
}
|
|
83
94
|
utils.addLine(jsdoc.source.length - 1, {
|
|
84
95
|
...line,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multilineBlocks.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","_default","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","desc","type","typ","name","nme","lineEnd","postType","postName","postTag","nameOrDescription","seedTokens","postDelimiter","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","anyOf","enum","items","exports","module"],"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 additionalProperties: 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,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAE5B,IAAAC,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,CAAC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E;YACR,CAAC;YACDA,IAAI,EAAE;UACR,CAAC;QAEL,CAAC;QACD1C,eAAe,EAAE;UACf0C,IAAI,EAAE;QACR,CAAC;QACDtC,iBAAiB,EAAE;UACjBsC,IAAI,EAAE;QACR,CAAC;QACDxC,kBAAkB,EAAE;UAClBwC,IAAI,EAAE;QACR,CAAC;QACDzC,cAAc,EAAE;UACdyC,IAAI,EAAE;QACR,CAAC;QACDvC,cAAc,EAAE;UACd4D,KAAK,EAAE;YACLrB,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAsB,OAAA,CAAAvE,OAAA,GAAAC,QAAA;AAAAuE,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAvE,OAAA"}
|
|
1
|
+
{"version":3,"file":"multilineBlocks.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","_default","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","desc","type","typ","name","nme","lineEnd","postType","postName","postTag","nameOrDescription","seedTokens","postDelimiter","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","anyOf","enum","items","exports","module"],"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 /**\n * @param {string} tagName\n * @returns {boolean}\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[\n /**\n * @type {\"delimiter\"|\"postDelimiter\"|\"tag\"|\"type\"|\n * \"lineEnd\"|\"postType\"|\"postTag\"|\"name\"|\n * \"postName\"|\"description\"}\n */ (\n prop\n )\n ] = '';\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 additionalProperties: 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,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAE5B,IAAAC,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,yBAA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,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV7D,iBAAiB,EAAE;UACjB2C,IAAI,EAAE;QACR,CAAC;QACDrC,yBAAyB,EAAE;UACzBqC,IAAI,EAAE;QACR,CAAC;QACDlC,aAAa,EAAE;UACbqD,KAAK,EAAE,CACL;YACEC,IAAI,EAAE,CACJ,GAAG,CACJ;YACDpB,IAAI,EAAE;UACR,CAAC,EAAE;YACDqB,KAAK,EAAE;cACLrB,IAAI,EAAE;YACR,CAAC;YACDA,IAAI,EAAE;UACR,CAAC;QAEL,CAAC;QACD1C,eAAe,EAAE;UACf0C,IAAI,EAAE;QACR,CAAC;QACDtC,iBAAiB,EAAE;UACjBsC,IAAI,EAAE;QACR,CAAC;QACDxC,kBAAkB,EAAE;UAClBwC,IAAI,EAAE;QACR,CAAC;QACDzC,cAAc,EAAE;UACdyC,IAAI,EAAE;QACR,CAAC;QACDvC,cAAc,EAAE;UACd4D,KAAK,EAAE;YACLrB,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAsB,OAAA,CAAAvE,OAAA,GAAAC,QAAA;AAAAuE,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAvE,OAAA"}
|
|
@@ -22,7 +22,7 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
22
22
|
preventAllMultiAsteriskBlocks = false
|
|
23
23
|
} = {}] = context.options;
|
|
24
24
|
let extraAsterisks = false;
|
|
25
|
-
const nonJsdocNodes = allComments.filter(comment => {
|
|
25
|
+
const nonJsdocNodes = /** @type {import('estree').Node[]} */allComments.filter(comment => {
|
|
26
26
|
const commentText = sourceCode.getText(comment);
|
|
27
27
|
let sliceIndex = 2;
|
|
28
28
|
if (!commentRegexp.test(commentText)) {
|
|
@@ -37,9 +37,7 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
37
37
|
return true;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
const [{
|
|
41
|
-
tags = {}
|
|
42
|
-
} = {}] = (0, _commentParser.parse)(`${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`);
|
|
40
|
+
const tags = ((0, _commentParser.parse)(`${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`)[0] || {}).tags ?? [];
|
|
43
41
|
return tags.length && !tags.some(({
|
|
44
42
|
tag
|
|
45
43
|
}) => {
|
|
@@ -50,7 +48,7 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
50
48
|
return;
|
|
51
49
|
}
|
|
52
50
|
for (const node of nonJsdocNodes) {
|
|
53
|
-
const report = makeReport(context, node);
|
|
51
|
+
const report = /** @type {import('../iterateJsdoc.js').MakeReport} */makeReport(context, node);
|
|
54
52
|
|
|
55
53
|
// eslint-disable-next-line no-loop-func
|
|
56
54
|
const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noBadBlocks.js","names":["_commentParser","require","_iterateJsdoc","_interopRequireDefault","obj","__esModule","default","commentRegexp","extraAsteriskCommentRegexp","_default","iterateJsdoc","context","sourceCode","allComments","makeReport","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","sliceIndex","test","_extraAsteriskComment","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","exports","module"],"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
|
|
1
|
+
{"version":3,"file":"noBadBlocks.js","names":["_commentParser","require","_iterateJsdoc","_interopRequireDefault","obj","__esModule","default","commentRegexp","extraAsteriskCommentRegexp","_default","iterateJsdoc","context","sourceCode","allComments","makeReport","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","sliceIndex","test","_extraAsteriskComment","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","exports","module"],"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 = /** @type {import('estree').Node[]} */ (\n allComments\n ).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 tags = (commentParser(\n `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`,\n )[0] || {}).tags ?? [];\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 = /** @type {import('../iterateJsdoc.js').MakeReport} */ (\n makeReport\n )(context, node);\n\n // eslint-disable-next-line no-loop-func\n const fix = /** @type {import('eslint').Rule.ReportFixer} */ (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,IAAAA,cAAA,GAAAC,OAAA;AAGA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA2C,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAA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AD,OAAA,GAAAA,OAAA,CAAAhD,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noBlankBlockDescriptions.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","anyWhitespaceLines","atLeastTwoLinesWhitespace","_default","iterateJsdoc","jsdoc","utils","description","descriptions","lastDescriptionLine","getDescription","regex","tags","length","test","reportJSDoc","line","setBlockDescription","info","seedTokens","tokens","iterateAllJsdocs","meta","docs","url","fixable","schema","type","exports","module"],"sources":["../../src/rules/noBlankBlockDescriptions.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst anyWhitespaceLines = /^\\s*$/u;\nconst atLeastTwoLinesWhitespace = /^[ \\t]*\\n[ \\t]*\\n\\s*$/u;\n\nexport default iterateJsdoc(({\n jsdoc,\n utils,\n}) => {\n const {\n description,\n descriptions,\n lastDescriptionLine,\n } = utils.getDescription();\n\n const regex = jsdoc.tags.length ?\n anyWhitespaceLines :\n atLeastTwoLinesWhitespace;\n\n if (descriptions.length && regex.test(description)) {\n if (jsdoc.tags.length) {\n utils.reportJSDoc(\n 'There should be no blank lines in block descriptions followed by tags.',\n {\n line: lastDescriptionLine,\n },\n () => {\n utils.setBlockDescription(() => {\n // Remove all lines\n return [];\n });\n },\n );\n } else {\n utils.reportJSDoc(\n 'There should be no extra blank lines in block descriptions not followed by tags.',\n {\n line: lastDescriptionLine,\n },\n () => {\n utils.setBlockDescription((info, seedTokens) => {\n return [\n // Keep the starting line\n {\n tokens: seedTokens({\n ...info,\n description: '',\n }),\n },\n ];\n });\n },\n );\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Detects and removes extra lines of a blank block description',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-blank-block-descriptions',\n },\n fixable: 'whitespace',\n schema: [],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C,MAAMG,kBAAkB,GAAG,QAAQ;AACnC,MAAMC,yBAAyB,GAAG,wBAAwB;AAAC,IAAAC,QAAA,GAE5C,IAAAC,qBAAY,EAAC,CAAC;EAC3BC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,WAAW;IACXC,YAAY;IACZC;EACF,CAAC,GAAGH,KAAK,CAACI,cAAc,CAAC,CAAC;EAE1B,MAAMC,KAAK,GAAGN,KAAK,CAACO,IAAI,CAACC,MAAM,GAC7BZ,kBAAkB,GAClBC,yBAAyB;EAE3B,IAAIM,YAAY,CAACK,MAAM,IAAIF,KAAK,CAACG,IAAI,CAACP,WAAW,CAAC,EAAE;IAClD,IAAIF,KAAK,CAACO,IAAI,CAACC,MAAM,EAAE;MACrBP,KAAK,CAACS,WAAW,CACf,wEAAwE,EACxE;QACEC,IAAI,EAAEP;MACR,CAAC,EACD,MAAM;QACJH,KAAK,CAACW,mBAAmB,CAAC,MAAM;UAC9B;UACA,OAAO,EAAE;QACX,CAAC,CAAC;MACJ,CACF,CAAC;IACH,CAAC,MAAM;MACLX,KAAK,CAACS,WAAW,CACf,kFAAkF,EAClF;QACEC,IAAI,EAAEP;MACR,CAAC,EACD,MAAM;QACJH,KAAK,CAACW,mBAAmB,CAAC,CAACC,IAAI,EAAEC,UAAU,KAAK;UAC9C,OAAO;UACL;UACA;YACEC,MAAM,
|
|
1
|
+
{"version":3,"file":"noBlankBlockDescriptions.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","anyWhitespaceLines","atLeastTwoLinesWhitespace","_default","iterateJsdoc","jsdoc","utils","description","descriptions","lastDescriptionLine","getDescription","regex","tags","length","test","reportJSDoc","line","setBlockDescription","info","seedTokens","number","source","tokens","iterateAllJsdocs","meta","docs","url","fixable","schema","type","exports","module"],"sources":["../../src/rules/noBlankBlockDescriptions.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst anyWhitespaceLines = /^\\s*$/u;\nconst atLeastTwoLinesWhitespace = /^[ \\t]*\\n[ \\t]*\\n\\s*$/u;\n\nexport default iterateJsdoc(({\n jsdoc,\n utils,\n}) => {\n const {\n description,\n descriptions,\n lastDescriptionLine,\n } = utils.getDescription();\n\n const regex = jsdoc.tags.length ?\n anyWhitespaceLines :\n atLeastTwoLinesWhitespace;\n\n if (descriptions.length && regex.test(description)) {\n if (jsdoc.tags.length) {\n utils.reportJSDoc(\n 'There should be no blank lines in block descriptions followed by tags.',\n {\n line: lastDescriptionLine,\n },\n () => {\n utils.setBlockDescription(() => {\n // Remove all lines\n return [];\n });\n },\n );\n } else {\n utils.reportJSDoc(\n 'There should be no extra blank lines in block descriptions not followed by tags.',\n {\n line: lastDescriptionLine,\n },\n () => {\n utils.setBlockDescription((info, seedTokens) => {\n return [\n // Keep the starting line\n {\n number: 0,\n source: '',\n tokens: seedTokens({\n ...info,\n description: '',\n }),\n },\n ];\n });\n },\n );\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Detects and removes extra lines of a blank block description',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-blank-block-descriptions',\n },\n fixable: 'whitespace',\n schema: [],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C,MAAMG,kBAAkB,GAAG,QAAQ;AACnC,MAAMC,yBAAyB,GAAG,wBAAwB;AAAC,IAAAC,QAAA,GAE5C,IAAAC,qBAAY,EAAC,CAAC;EAC3BC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAM;IAC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|
var _esquery = _interopRequireDefault(require("esquery"));
|
|
8
8
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{
|
|
12
|
+
* comment: string,
|
|
13
|
+
* context: string,
|
|
14
|
+
* message: string,
|
|
15
|
+
* minimum: import('../iterateJsdoc.js').Integer
|
|
16
|
+
* }} ContextObject
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {string|ContextObject} Context
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @param {import('../iterateJsdoc.js').StateObject} state
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
10
26
|
const setDefaults = state => {
|
|
11
27
|
if (!state.selectorMap) {
|
|
12
28
|
state.selectorMap = {};
|
|
13
29
|
}
|
|
14
30
|
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {import('../iterateJsdoc.js').StateObject} state
|
|
34
|
+
* @param {string} selector
|
|
35
|
+
* @param {string} comment
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
15
38
|
const incrementSelector = (state, selector, comment) => {
|
|
16
39
|
if (!state.selectorMap[selector]) {
|
|
17
40
|
state.selectorMap[selector] = {};
|
|
@@ -34,19 +57,27 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
34
57
|
// Handle error later
|
|
35
58
|
return;
|
|
36
59
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @type {Context[]}
|
|
63
|
+
*/
|
|
64
|
+
const contexts = context.options[0].contexts;
|
|
40
65
|
const foundContext = contexts.find(cntxt => {
|
|
41
|
-
return typeof cntxt === 'string' ? _esquery.default.matches(node, _esquery.default.parse(cntxt), null,
|
|
66
|
+
return typeof cntxt === 'string' ? _esquery.default.matches(node, _esquery.default.parse(cntxt), null,
|
|
67
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460
|
|
68
|
+
// @ts-expect-error
|
|
69
|
+
{
|
|
42
70
|
visitorKeys: sourceCode.visitorKeys
|
|
43
|
-
}) : (!cntxt.context || cntxt.context === 'any' ||
|
|
71
|
+
}) : (!cntxt.context || cntxt.context === 'any' ||
|
|
72
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460
|
|
73
|
+
// @ts-expect-error
|
|
74
|
+
_esquery.default.matches(node, _esquery.default.parse(cntxt.context), null, {
|
|
44
75
|
visitorKeys: sourceCode.visitorKeys
|
|
45
76
|
})) && comment === cntxt.comment;
|
|
46
77
|
});
|
|
47
|
-
const contextStr = typeof foundContext === 'object' ? foundContext.context ?? 'any' : foundContext;
|
|
78
|
+
const contextStr = typeof foundContext === 'object' ? foundContext.context ?? 'any' : String(foundContext);
|
|
48
79
|
setDefaults(state);
|
|
49
|
-
incrementSelector(state, contextStr, comment);
|
|
80
|
+
incrementSelector(state, contextStr, String(comment));
|
|
50
81
|
}, {
|
|
51
82
|
contextSelected: true,
|
|
52
83
|
exit({
|
|
@@ -57,6 +88,10 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
57
88
|
if (!context.options.length && !settings.contexts) {
|
|
58
89
|
context.report({
|
|
59
90
|
loc: {
|
|
91
|
+
end: {
|
|
92
|
+
column: 1,
|
|
93
|
+
line: 1
|
|
94
|
+
},
|
|
60
95
|
start: {
|
|
61
96
|
column: 1,
|
|
62
97
|
line: 1
|
|
@@ -67,19 +102,25 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
67
102
|
return;
|
|
68
103
|
}
|
|
69
104
|
setDefaults(state);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @type {Context[]}
|
|
108
|
+
*/
|
|
109
|
+
const contexts = (context.options[0] ?? {}).contexts ?? (settings === null || settings === void 0 ? void 0 : settings.contexts);
|
|
73
110
|
|
|
74
111
|
// Report when MISSING
|
|
75
112
|
contexts.some(cntxt => {
|
|
76
113
|
const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;
|
|
77
|
-
const comment =
|
|
78
|
-
const contextKey = contextStr === 'any' ? undefined : contextStr;
|
|
79
|
-
if ((!state.selectorMap[contextKey] || !state.selectorMap[contextKey][comment] || state.selectorMap[contextKey][comment] < (
|
|
80
|
-
|
|
114
|
+
const comment = typeof cntxt === 'string' ? '' : cntxt === null || cntxt === void 0 ? void 0 : cntxt.comment;
|
|
115
|
+
const contextKey = contextStr === 'any' ? 'undefined' : contextStr;
|
|
116
|
+
if ((!state.selectorMap[contextKey] || !state.selectorMap[contextKey][comment] || state.selectorMap[contextKey][comment] < (
|
|
117
|
+
// @ts-expect-error comment would need an object, not string
|
|
118
|
+
(cntxt === null || cntxt === void 0 ? void 0 : cntxt.minimum) ?? 1)) && (contextStr !== 'any' || Object.values(state.selectorMap).every(cmmnt => {
|
|
119
|
+
return !cmmnt[comment] || cmmnt[comment] < (
|
|
120
|
+
// @ts-expect-error comment would need an object, not string
|
|
121
|
+
(cntxt === null || cntxt === void 0 ? void 0 : cntxt.minimum) ?? 1);
|
|
81
122
|
}))) {
|
|
82
|
-
const message = (cntxt === null || cntxt === void 0 ? void 0 : cntxt.message) ?? 'Syntax is required: {{context}}' + (comment ? ' with {{comment}}' : '');
|
|
123
|
+
const message = typeof cntxt === 'string' ? 'Syntax is required: {{context}}' : (cntxt === null || cntxt === void 0 ? void 0 : cntxt.message) ?? 'Syntax is required: {{context}}' + (comment ? ' with {{comment}}' : '');
|
|
83
124
|
context.report({
|
|
84
125
|
data: {
|
|
85
126
|
comment,
|
|
@@ -87,9 +128,11 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
87
128
|
},
|
|
88
129
|
loc: {
|
|
89
130
|
end: {
|
|
131
|
+
column: 1,
|
|
90
132
|
line: 1
|
|
91
133
|
},
|
|
92
134
|
start: {
|
|
135
|
+
column: 1,
|
|
93
136
|
line: 1
|
|
94
137
|
}
|
|
95
138
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noMissingSyntax.js","names":["_esquery","_interopRequireDefault","require","_iterateJsdoc","obj","__esModule","default","setDefaults","state","selectorMap","incrementSelector","selector","comment","_default","iterateJsdoc","context","node","info","sourceCode","options","contexts","foundContext","find","cntxt","esquery","matches","parse","visitorKeys","contextStr","contextSelected","exit","settings","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","exports","module"],"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 settings,\n state,\n }) {\n if (!context.options.length && !settings.contexts) {\n context.report({\n loc: {\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `contexts` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n const {\n contexts = settings?.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,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA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,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVrC,QAAQ,EAAE;UACRsC,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEC,IAAI,EAAE;YACR,CAAC,EACD;cACEJ,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACV7C,OAAO,EAAE;kBACPgD,IAAI,EAAE;gBACR,CAAC;gBACD7C,OAAO,EAAE;kBACP6C,IAAI,EAAE;gBACR,CAAC;gBACDtB,OAAO,EAAE;kBACPsB,IAAI,EAAE;gBACR,CAAC;gBACDlB,OAAO,EAAE;kBACPkB,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,OAAA,CAAAvD,OAAA,GAAAO,QAAA;AAAAiD,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAvD,OAAA"}
|
|
1
|
+
{"version":3,"file":"noMissingSyntax.js","names":["_esquery","_interopRequireDefault","require","_iterateJsdoc","obj","__esModule","default","setDefaults","state","selectorMap","incrementSelector","selector","comment","_default","iterateJsdoc","context","node","info","sourceCode","options","contexts","foundContext","find","cntxt","esquery","matches","parse","visitorKeys","contextStr","String","contextSelected","exit","settings","length","report","loc","end","column","line","start","message","some","contextKey","minimum","Object","values","every","cmmnt","data","matchContext","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","exports","module"],"sources":["../../src/rules/noMissingSyntax.js"],"sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\n/**\n * @typedef {{\n * comment: string,\n * context: string,\n * message: string,\n * minimum: import('../iterateJsdoc.js').Integer\n * }} ContextObject\n */\n\n/**\n * @typedef {string|ContextObject} Context\n */\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @returns {void}\n */\nconst setDefaults = (state) => {\n if (!state.selectorMap) {\n state.selectorMap = {};\n }\n};\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @param {string} selector\n * @param {string} comment\n * @returns {void}\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 /**\n * @type {Context[]}\n */\n const contexts = context.options[0].contexts;\n\n const foundContext = contexts.find((cntxt) => {\n return typeof cntxt === 'string' ?\n esquery.matches(\n node,\n esquery.parse(cntxt),\n null,\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460\n // @ts-expect-error\n {\n visitorKeys: sourceCode.visitorKeys,\n },\n ) :\n (!cntxt.context || cntxt.context === 'any' ||\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460\n // @ts-expect-error\n 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 String(foundContext);\n\n setDefaults(state);\n\n incrementSelector(state, contextStr, String(comment));\n}, {\n contextSelected: true,\n exit ({\n context,\n settings,\n state,\n }) {\n if (!context.options.length && !settings.contexts) {\n context.report({\n loc: {\n end: {\n column: 1,\n line: 1,\n },\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `contexts` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n\n /**\n * @type {Context[]}\n */\n const contexts = (context.options[0] ?? {}).contexts ?? settings?.contexts;\n\n // Report when MISSING\n contexts.some((cntxt) => {\n const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n const comment = typeof cntxt === 'string' ? '' : 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] < (\n // @ts-expect-error comment would need an object, not string\n cntxt?.minimum ?? 1\n )) &&\n (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n return !cmmnt[comment] || cmmnt[comment] < (\n // @ts-expect-error comment would need an object, not string\n cntxt?.minimum ?? 1\n );\n }))\n ) {\n const message = typeof cntxt === 'string' ?\n 'Syntax is required: {{context}}' :\n 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 column: 1,\n line: 1,\n },\n start: {\n column: 1,\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,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA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AAEa;UACX,CAAC;UACDO,GAAG,EAAE;YACHC,GAAG,EAAE;cACHC,MAAM,EAAE,CAAC;cACTC,IAAI,EAAE;YACR,CAAC;YACDC,KAAK,EAAE;cACLF,MAAM,EAAE,CAAC;cACTC,IAAI,EAAE;YACR;UACF,CAAC;UACDE;QACF,CAAC,CAAC;QAEF,OAAO,IAAI;MACb;MAEA,OAAO,KAAK;IACd,CAAC,CAAC;EACJ,CAAC;EACDS,YAAY,EAAE,IAAI;EAClBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,8DAA8D;MAC3EC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVrC,QAAQ,EAAE;UACRsC,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEC,IAAI,EAAE;YACR,CAAC,EACD;cACEJ,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACV7C,OAAO,EAAE;kBACPgD,IAAI,EAAE;gBACR,CAAC;gBACD7C,OAAO,EAAE;kBACP6C,IAAI,EAAE;gBACR,CAAC;gBACDpB,OAAO,EAAE;kBACPoB,IAAI,EAAE;gBACR,CAAC;gBACDjB,OAAO,EAAE;kBACPiB,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,OAAA,CAAAvD,OAAA,GAAAO,QAAA;AAAAiD,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAvD,OAAA"}
|
|
@@ -53,12 +53,7 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
53
53
|
}
|
|
54
54
|
const isSingleLineBlock = delimiter === '/**';
|
|
55
55
|
const delim = isSingleLineBlock ? '*' : delimiter;
|
|
56
|
-
|
|
57
|
-
if (allowWhitespace) {
|
|
58
|
-
endAsterisks = isSingleLineBlock ? endAsterisksSingleLineNoBlockWS : endAsterisksMultipleLineNoBlockWS;
|
|
59
|
-
} else {
|
|
60
|
-
endAsterisks = isSingleLineBlock ? endAsterisksSingleLineBlockWS : endAsterisksMultipleLineBlockWS;
|
|
61
|
-
}
|
|
56
|
+
const endAsterisks = allowWhitespace ? isSingleLineBlock ? endAsterisksSingleLineNoBlockWS : endAsterisksMultipleLineNoBlockWS : isSingleLineBlock ? endAsterisksSingleLineBlockWS : endAsterisksMultipleLineBlockWS;
|
|
62
57
|
const endingAsterisksAndSpaces = (allowWhitespace ? postDelimiter + description + delim : description + delim).match(endAsterisks);
|
|
63
58
|
if (!endingAsterisksAndSpaces || !isSingleLineBlock && endingAsterisksAndSpaces[1] && !endingAsterisksAndSpaces[1].trim()) {
|
|
64
59
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noMultiAsterisks.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","middleAsterisksBlockWS","middleAsterisksNoBlockWS","endAsterisksSingleLineBlockWS","endAsterisksMultipleLineBlockWS","endAsterisksSingleLineNoBlockWS","endAsterisksMultipleLineNoBlockWS","_default","iterateJsdoc","context","jsdoc","utils","allowWhitespace","preventAtEnd","preventAtMiddleLines","options","middleAsterisks","source","some","tokens","number","delimiter","tag","name","type","description","end","postDelimiter","test","fix","replace","reportJSDoc","line","isSingleLineBlock","delim","endAsterisks","endingAsterisksAndSpaces","match","trim","endFix","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","exports","module"],"sources":["../../src/rules/noMultiAsterisks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst middleAsterisksBlockWS = /^([\\t ]|\\*(?!\\*))+/u;\nconst middleAsterisksNoBlockWS = /^\\*+/u;\n\nconst endAsterisksSingleLineBlockWS = /\\*((?:\\*|(?: |\\t))*)\\*$/u;\nconst endAsterisksMultipleLineBlockWS = /((?:\\*|(?: |\\t))*)\\*$/u;\n\nconst endAsterisksSingleLineNoBlockWS = /\\*(\\**)\\*$/u;\nconst endAsterisksMultipleLineNoBlockWS = /(\\**)\\*$/u;\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const {\n allowWhitespace = false,\n preventAtEnd = true,\n preventAtMiddleLines = true,\n } = context.options[0] || {};\n\n const middleAsterisks = allowWhitespace ? middleAsterisksNoBlockWS : middleAsterisksBlockWS;\n\n // eslint-disable-next-line complexity -- Todo\n jsdoc.source.some(({\n tokens,\n number,\n }) => {\n const {\n delimiter,\n tag,\n name,\n type,\n description,\n end,\n postDelimiter,\n } = tokens;\n\n if (\n preventAtMiddleLines &&\n !end && !tag && !type && !name &&\n (\n !allowWhitespace && middleAsterisks.test(description) ||\n allowWhitespace && middleAsterisks.test(postDelimiter + description)\n )\n ) {\n // console.log('description', JSON.stringify(description));\n const fix = () => {\n tokens.description = description.replace(middleAsterisks, '');\n };\n\n utils.reportJSDoc(\n 'Should be no multiple asterisks on middle lines.',\n {\n line: number,\n },\n fix,\n true,\n );\n\n return true;\n }\n\n if (!preventAtEnd || !end) {\n return false;\n }\n\n const isSingleLineBlock = delimiter === '/**';\n const delim = isSingleLineBlock ? '*' : delimiter;\n
|
|
1
|
+
{"version":3,"file":"noMultiAsterisks.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","middleAsterisksBlockWS","middleAsterisksNoBlockWS","endAsterisksSingleLineBlockWS","endAsterisksMultipleLineBlockWS","endAsterisksSingleLineNoBlockWS","endAsterisksMultipleLineNoBlockWS","_default","iterateJsdoc","context","jsdoc","utils","allowWhitespace","preventAtEnd","preventAtMiddleLines","options","middleAsterisks","source","some","tokens","number","delimiter","tag","name","type","description","end","postDelimiter","test","fix","replace","reportJSDoc","line","isSingleLineBlock","delim","endAsterisks","endingAsterisksAndSpaces","match","trim","endFix","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","exports","module"],"sources":["../../src/rules/noMultiAsterisks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst middleAsterisksBlockWS = /^([\\t ]|\\*(?!\\*))+/u;\nconst middleAsterisksNoBlockWS = /^\\*+/u;\n\nconst endAsterisksSingleLineBlockWS = /\\*((?:\\*|(?: |\\t))*)\\*$/u;\nconst endAsterisksMultipleLineBlockWS = /((?:\\*|(?: |\\t))*)\\*$/u;\n\nconst endAsterisksSingleLineNoBlockWS = /\\*(\\**)\\*$/u;\nconst endAsterisksMultipleLineNoBlockWS = /(\\**)\\*$/u;\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const {\n allowWhitespace = false,\n preventAtEnd = true,\n preventAtMiddleLines = true,\n } = context.options[0] || {};\n\n const middleAsterisks = allowWhitespace ? middleAsterisksNoBlockWS : middleAsterisksBlockWS;\n\n // eslint-disable-next-line complexity -- Todo\n jsdoc.source.some(({\n tokens,\n number,\n }) => {\n const {\n delimiter,\n tag,\n name,\n type,\n description,\n end,\n postDelimiter,\n } = tokens;\n\n if (\n preventAtMiddleLines &&\n !end && !tag && !type && !name &&\n (\n !allowWhitespace && middleAsterisks.test(description) ||\n allowWhitespace && middleAsterisks.test(postDelimiter + description)\n )\n ) {\n // console.log('description', JSON.stringify(description));\n const fix = () => {\n tokens.description = description.replace(middleAsterisks, '');\n };\n\n utils.reportJSDoc(\n 'Should be no multiple asterisks on middle lines.',\n {\n line: number,\n },\n fix,\n true,\n );\n\n return true;\n }\n\n if (!preventAtEnd || !end) {\n return false;\n }\n\n const isSingleLineBlock = delimiter === '/**';\n const delim = isSingleLineBlock ? '*' : delimiter;\n const endAsterisks = allowWhitespace ?\n (isSingleLineBlock ? endAsterisksSingleLineNoBlockWS : endAsterisksMultipleLineNoBlockWS) :\n (isSingleLineBlock ? endAsterisksSingleLineBlockWS : endAsterisksMultipleLineBlockWS);\n\n const endingAsterisksAndSpaces = (\n allowWhitespace ? postDelimiter + description + delim : description + delim\n ).match(\n endAsterisks,\n );\n\n if (\n !endingAsterisksAndSpaces ||\n !isSingleLineBlock && endingAsterisksAndSpaces[1] && !endingAsterisksAndSpaces[1].trim()\n ) {\n return false;\n }\n\n const endFix = () => {\n if (!isSingleLineBlock) {\n tokens.delimiter = '';\n }\n\n tokens.description = (description + delim).replace(endAsterisks, '');\n };\n\n utils.reportJSDoc(\n 'Should be no multiple asterisks on end lines.',\n {\n line: number,\n },\n endFix,\n true,\n );\n\n return true;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: '',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-multi-asterisks',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowWhitespace: {\n type: 'boolean',\n },\n preventAtEnd: {\n type: 'boolean',\n },\n preventAtMiddleLines: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C,MAAMG,sBAAsB,GAAG,qBAAqB;AACpD,MAAMC,wBAAwB,GAAG,OAAO;AAExC,MAAMC,6BAA6B,GAAG,0BAA0B;AAChE,MAAMC,+BAA+B,GAAG,wBAAwB;AAEhE,MAAMC,+BAA+B,GAAG,aAAa;AACrD,MAAMC,iCAAiC,GAAG,WAAW;AAAC,IAAAC,QAAA,GAEvC,IAAAC,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,eAAe,GAAG,KAAK;IACvBC,YAAY,GAAG,IAAI;IACnBC,oBAAoB,GAAG;EACzB,CAAC,GAAGL,OAAO,CAACM,OAA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AK,EAC3EG,KAAK,CACLF,YACF,CAAC;IAED,IACE,CAACC,wBAAwB,IACzB,CAACH,iBAAiB,IAAIG,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAACA,wBAAwB,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,CAAC,EACxF;MACA,OAAO,KAAK;IACd;IAEA,MAAMC,MAAM,GAAGA,CAAA,KAAM;MACnB,IAAI,CAACN,iBAAiB,EAAE;QACtBd,MAAM,CAACE,SAAS,GAAG,EAAE;MACvB;MAEAF,MAAM,CAACM,WAAW,GAAG,CAACA,WAAW,GAAGS,KAAK,EAAEJ,OAAO,CAACK,YAAY,EAAE,EAAE,CAAC;IACtE,CAAC;IAEDxB,KAAK,CAACoB,WAAW,CACf,+CAA+C,EAC/C;MACEC,IAAI,EAAEZ;IACR,CAAC,EACDmB,MAAM,EACN,IACF,CAAC;IAED,OAAO,IAAI;EACb,CAAC,CAAC;AACJ,CAAC,EAAE;EACDC,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJjB,WAAW,EAAE,EAAE;MACfkB,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVnC,eAAe,EAAE;UACfY,IAAI,EAAE;QACR,CAAC;QACDX,YAAY,EAAE;UACZW,IAAI,EAAE;QACR,CAAC;QACDV,oBAAoB,EAAE;UACpBU,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAwB,OAAA,CAAAhD,OAAA,GAAAO,QAAA;AAAA0C,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAhD,OAAA"}
|
|
@@ -23,10 +23,21 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
23
23
|
const {
|
|
24
24
|
contexts
|
|
25
25
|
} = context.options[0];
|
|
26
|
-
const foundContext = contexts.find(
|
|
27
|
-
|
|
26
|
+
const foundContext = contexts.find(
|
|
27
|
+
/**
|
|
28
|
+
* @param {string|{context: string, comment: string}} cntxt
|
|
29
|
+
* @returns {boolean}
|
|
30
|
+
*/
|
|
31
|
+
cntxt => {
|
|
32
|
+
return typeof cntxt === 'string' ? _esquery.default.matches(node, _esquery.default.parse(cntxt), null,
|
|
33
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460
|
|
34
|
+
// @ts-expect-error
|
|
35
|
+
{
|
|
28
36
|
visitorKeys: sourceCode.visitorKeys
|
|
29
|
-
}) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches(node, _esquery.default.parse(cntxt.context), null,
|
|
37
|
+
}) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches(node, _esquery.default.parse(cntxt.context), null,
|
|
38
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
{
|
|
30
41
|
visitorKeys: sourceCode.visitorKeys
|
|
31
42
|
})) && comment === cntxt.comment;
|
|
32
43
|
});
|
|
@@ -38,9 +49,11 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
38
49
|
}
|
|
39
50
|
const contextStr = typeof foundContext === 'object' ? foundContext.context ?? 'any' : foundContext;
|
|
40
51
|
const message = (foundContext === null || foundContext === void 0 ? void 0 : foundContext.message) ?? 'Syntax is restricted: {{context}}' + (comment ? ' with {{comment}}' : '');
|
|
41
|
-
report(message, null, null, {
|
|
52
|
+
report(message, null, null, comment ? {
|
|
42
53
|
comment,
|
|
43
54
|
context: contextStr
|
|
55
|
+
} : {
|
|
56
|
+
context: contextStr
|
|
44
57
|
});
|
|
45
58
|
}, {
|
|
46
59
|
contextSelected: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noRestrictedSyntax.js","names":["_esquery","_interopRequireDefault","require","_iterateJsdoc","obj","__esModule","default","_default","iterateJsdoc","node","context","info","comment","sourceCode","report","options","length","contexts","foundContext","find","cntxt","esquery","matches","parse","visitorKeys","contextStr","message","contextSelected","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","required","nonGlobalSettings","exports","module"],"sources":["../../src/rules/noRestrictedSyntax.js"],"sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n node,\n context,\n info: {\n comment,\n },\n sourceCode,\n report,\n}) => {\n if (!context.options.length) {\n report('Rule `no-restricted-syntax` is missing a `contexts` option.');\n\n return;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n const foundContext = contexts.find((cntxt) => {\n
|
|
1
|
+
{"version":3,"file":"noRestrictedSyntax.js","names":["_esquery","_interopRequireDefault","require","_iterateJsdoc","obj","__esModule","default","_default","iterateJsdoc","node","context","info","comment","sourceCode","report","options","length","contexts","foundContext","find","cntxt","esquery","matches","parse","visitorKeys","contextStr","message","contextSelected","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","required","nonGlobalSettings","exports","module"],"sources":["../../src/rules/noRestrictedSyntax.js"],"sourcesContent":["import esquery from 'esquery';\nimport iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n node,\n context,\n info: {\n comment,\n },\n sourceCode,\n report,\n}) => {\n if (!context.options.length) {\n report('Rule `no-restricted-syntax` is missing a `contexts` option.');\n\n return;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n const foundContext = contexts.find(\n /**\n * @param {string|{context: string, comment: string}} cntxt\n * @returns {boolean}\n */\n (cntxt) => {\n return typeof cntxt === 'string' ?\n esquery.matches(\n node,\n esquery.parse(cntxt),\n null,\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460\n // @ts-expect-error\n {\n visitorKeys: sourceCode.visitorKeys,\n },\n ) :\n (!cntxt.context || cntxt.context === 'any' ||\n esquery.matches(\n node,\n esquery.parse(cntxt.context),\n null,\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65460\n // @ts-expect-error\n {\n visitorKeys: sourceCode.visitorKeys,\n },\n )) &&\n comment === cntxt.comment;\n },\n );\n\n // We are not on the *particular* matching context/comment, so don't assume\n // we need reporting\n if (!foundContext) {\n return;\n }\n\n const contextStr = typeof foundContext === 'object' ?\n foundContext.context ?? 'any' :\n foundContext;\n const message = foundContext?.message ??\n 'Syntax is restricted: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n\n report(message, null, null, comment ? {\n comment,\n context: contextStr,\n } : {\n context: contextStr,\n });\n}, {\n contextSelected: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are present.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-restricted-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 },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n required: [\n 'contexts',\n ],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n nonGlobalSettings: true,\n});\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAE5B,IAAAC,qBAAY,EAAC,CAAC;EAC3BC,IAAI;EACJC,OAAO;EACPC,IAAI,EAAE;IACJC;EACF,CAAC;EACDC,UAAU;EACVC;AACF,CAAC,KAAK;EACJ,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACC,MAAM,EAAE;IAC3BF,MAAM,CAAC,6DAA6D,CAAC;IAErE;EACF;EAEA,M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CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVlB,QAAQ,EAAE;UACRmB,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEC,IAAI,EAAE;YACR,CAAC,EACD;cACEJ,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVvB,OAAO,EAAE;kBACP0B,IAAI,EAAE;gBACR,CAAC;gBACD5B,OAAO,EAAE;kBACP4B,IAAI,EAAE;gBACR,CAAC;gBACDZ,OAAO,EAAE;kBACPY,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDC,QAAQ,EAAE,CACR,UAAU,CACX;MACDD,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR,CAAC;EACDE,iBAAiB,EAAE;AACrB,CAAC,CAAC;AAAAC,OAAA,CAAAnC,OAAA,GAAAC,QAAA;AAAAmC,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAnC,OAAA"}
|
package/dist/rules/noTypes.js
CHANGED
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('comment-parser').Line} line
|
|
11
|
+
*/
|
|
9
12
|
const removeType = ({
|
|
10
13
|
tokens
|
|
11
14
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noTypes.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","removeType","tokens","postTag","type","_default","iterateJsdoc","utils","isIteratingFunction","isVirtualFunction","tags","getPresentTags","tag","reportJSDoc","source","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exports","module"],"sources":["../../src/rules/noTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst removeType = ({\n tokens,\n}) => {\n tokens.postTag = '';\n tokens.type = '';\n};\n\nexport default iterateJsdoc(({\n utils,\n}) => {\n if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) {\n return;\n }\n\n const tags = utils.getPresentTags([\n 'param', 'arg', 'argument', 'returns', 'return',\n ]);\n\n for (const tag of tags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'This rule reports types being used on `@param` or `@returns`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-types',\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 },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C,MAAMG,UAAU,GAAGA,CAAC;EAClBC;AACF,CAAC,KAAK;EACJA,MAAM,CAACC,OAAO,GAAG,EAAE;EACnBD,MAAM,CAACE,IAAI,GAAG,EAAE;AAClB,CAAC;AAAC,IAAAC,QAAA,GAEa,IAAAC,qBAAY,EAAC,CAAC;EAC3BC;AACF,CAAC,KAAK;EACJ,IAAI,CAACA,KAAK,CAACC,mBAAmB,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+
{"version":3,"file":"noTypes.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","removeType","tokens","postTag","type","_default","iterateJsdoc","utils","isIteratingFunction","isVirtualFunction","tags","getPresentTags","tag","reportJSDoc","source","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exports","module"],"sources":["../../src/rules/noTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n/**\n * @param {import('comment-parser').Line} line\n */\nconst removeType = ({\n tokens,\n}) => {\n tokens.postTag = '';\n tokens.type = '';\n};\n\nexport default iterateJsdoc(({\n utils,\n}) => {\n if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) {\n return;\n }\n\n const tags = utils.getPresentTags([\n 'param', 'arg', 'argument', 'returns', 'return',\n ]);\n\n for (const tag of tags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'This rule reports types being used on `@param` or `@returns`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-types',\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 },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE3C;AACA;AACA;AACA,MAAMG,UAAU,GAAGA,CAAC;EAClBC;AACF,CAAC,KAAK;EACJA,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