eslint-plugin-jsdoc 48.5.1 → 48.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"requireParam.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","rootNamer","desiredRoots","currentIndex","name","idx","incremented","length","base","suffix","shift","_default","exports","iterateJsdoc","jsdoc","utils","context","avoidDocs","hasTag","autoIncrementBase","checkRestProperty","checkDestructured","checkDestructuredRoots","checkTypesPattern","enableFixer","enableRootFixer","enableRestElementFixer","unnamedRootBase","useDefaultObjectProperties","options","preferredTagName","getPreferredTagName","tagName","functionParameterNames","getFunctionParameterNames","jsdocParameterNames","getJsdocTagsDeep","shallowJsdocParameterNames","filter","tag","includes","map","checkTypesRegex","getRegexFromString","missingTags","flattenedRoots","flattenRoots","names","paramIndex","hasParamIndex","cur","dropPathSegmentQuotes","String","getParamIndex","setParamIndex","entries","findExpectedIndex","jsdocTags","indexAtFunctionParams","remainingRoots","slice","foundIndex","findIndex","newAdd","some","remainingRoot","Array","isArray","tags","tagLineCount","source","tokens","end","nextRootName","namer","thisOffset","functionParameterIdx","functionParameterName","inc","matchedJsdoc","rootName","type","search","hasRestElement","hasPropertyRest","rests","notCheckingNames","paramName","find","fpn","emptyParamIdx","push","remove","fullParamName","notCheckingName","paramType","comparePaths","undefined","startsWith","funcParamName","restElement","fix","createTokens","tagIndex","sourceIndex","spliceCount","number","delimiter","description","lineEnd","postDelimiter","postName","postTag","postType","start","splice","inlineTags","optional","problems","firstNumber","src","offset","expectedIdx","fixer","missingTag","makeMultiline","reportJSDoc","contextDefaults","meta","docs","url","fixable","schema","additionalProperties","properties","checkConstructors","checkGetters","checkSetters","contexts","items","anyOf","comment","exemptedBy","noTracking","module"],"sources":["../../src/rules/requireParam.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @typedef {[string, boolean, () => RootNamerReturn]} RootNamerReturn\n */\n\n/**\n * @param {string[]} desiredRoots\n * @param {number} currentIndex\n * @returns {RootNamerReturn}\n */\nconst rootNamer = (desiredRoots, currentIndex) => {\n /** @type {string} */\n let name;\n let idx = currentIndex;\n const incremented = desiredRoots.length <= 1;\n if (incremented) {\n const base = desiredRoots[0];\n const suffix = idx++;\n name = `${base}${suffix}`;\n } else {\n name = /** @type {string} */ (desiredRoots.shift());\n }\n\n return [\n name,\n incremented,\n () => {\n return rootNamer(desiredRoots, idx);\n },\n ];\n};\n\n/* eslint-disable complexity -- Temporary */\nexport default iterateJsdoc(({\n jsdoc,\n utils,\n context,\n}) => {\n /* eslint-enable complexity -- Temporary */\n if (utils.avoidDocs()) {\n return;\n }\n\n // Param type is specified by type in @type\n if (utils.hasTag('type')) {\n return;\n }\n\n const {\n autoIncrementBase = 0,\n checkRestProperty = false,\n checkDestructured = true,\n checkDestructuredRoots = true,\n checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/',\n enableFixer = true,\n enableRootFixer = true,\n enableRestElementFixer = true,\n unnamedRootBase = [\n 'root',\n ],\n useDefaultObjectProperties = false,\n } = context.options[0] || {};\n\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'param',\n }));\n if (!preferredTagName) {\n return;\n }\n\n const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties);\n if (!functionParameterNames.length) {\n return;\n }\n\n const jsdocParameterNames =\n /**\n * @type {{\n * idx: import('../iterateJsdoc.js').Integer;\n * name: string;\n * type: string;\n * }[]}\n */ (utils.getJsdocTagsDeep(preferredTagName));\n\n const shallowJsdocParameterNames = jsdocParameterNames.filter((tag) => {\n return !tag.name.includes('.');\n }).map((tag, idx) => {\n return {\n ...tag,\n idx,\n };\n });\n\n const checkTypesRegex = utils.getRegexFromString(checkTypesPattern);\n\n /**\n * @type {{\n * functionParameterIdx: import('../iterateJsdoc.js').Integer,\n * functionParameterName: string,\n * inc: boolean|undefined,\n * remove?: true,\n * type?: string|undefined\n * }[]}\n */\n const missingTags = [];\n const flattenedRoots = utils.flattenRoots(functionParameterNames).names;\n\n /**\n * @type {{\n * [key: string]: import('../iterateJsdoc.js').Integer\n * }}\n */\n const paramIndex = {};\n\n /**\n * @param {string} cur\n * @returns {boolean}\n */\n const hasParamIndex = (cur) => {\n return utils.dropPathSegmentQuotes(String(cur)) in paramIndex;\n };\n\n /**\n *\n * @param {string|number|undefined} cur\n * @returns {import('../iterateJsdoc.js').Integer}\n */\n const getParamIndex = (cur) => {\n return paramIndex[utils.dropPathSegmentQuotes(String(cur))];\n };\n\n /**\n *\n * @param {string} cur\n * @param {import('../iterateJsdoc.js').Integer} idx\n * @returns {void}\n */\n const setParamIndex = (cur, idx) => {\n paramIndex[utils.dropPathSegmentQuotes(String(cur))] = idx;\n };\n\n for (const [\n idx,\n cur,\n ] of flattenedRoots.entries()) {\n setParamIndex(cur, idx);\n }\n\n /**\n *\n * @param {(import('@es-joy/jsdoccomment').JsdocTagWithInline & {\n * newAdd?: boolean\n * })[]} jsdocTags\n * @param {import('../iterateJsdoc.js').Integer} indexAtFunctionParams\n * @returns {import('../iterateJsdoc.js').Integer}\n */\n const findExpectedIndex = (jsdocTags, indexAtFunctionParams) => {\n const remainingRoots = functionParameterNames.slice(indexAtFunctionParams || 0);\n const foundIndex = jsdocTags.findIndex(({\n name,\n newAdd,\n }) => {\n return !newAdd && remainingRoots.some((remainingRoot) => {\n if (Array.isArray(remainingRoot)) {\n return (\n /**\n * @type {import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string|undefined;\n * }}\n */ (remainingRoot[1]).names.includes(name)\n );\n }\n\n if (typeof remainingRoot === 'object') {\n return name === remainingRoot.name;\n }\n\n return name === remainingRoot;\n });\n });\n\n const tags = foundIndex > -1 ?\n jsdocTags.slice(0, foundIndex) :\n jsdocTags.filter(({\n tag,\n }) => {\n return tag === preferredTagName;\n });\n\n let tagLineCount = 0;\n for (const {\n source,\n } of tags) {\n for (const {\n tokens: {\n end,\n },\n } of source) {\n if (!end) {\n tagLineCount++;\n }\n }\n }\n\n return tagLineCount;\n };\n\n let [\n nextRootName,\n incremented,\n namer,\n ] = rootNamer([\n ...unnamedRootBase,\n ], autoIncrementBase);\n\n const thisOffset = functionParameterNames[0] === 'this' ? 1 : 0;\n\n for (const [\n functionParameterIdx,\n functionParameterName,\n ] of functionParameterNames.entries()) {\n let inc;\n if (Array.isArray(functionParameterName)) {\n const matchedJsdoc = shallowJsdocParameterNames[functionParameterIdx - thisOffset] ||\n jsdocParameterNames[functionParameterIdx - thisOffset];\n\n /** @type {string} */\n let rootName;\n if (functionParameterName[0]) {\n rootName = functionParameterName[0];\n } else if (matchedJsdoc && matchedJsdoc.name) {\n rootName = matchedJsdoc.name;\n if (matchedJsdoc.type && matchedJsdoc.type.search(checkTypesRegex) === -1) {\n continue;\n }\n } else {\n rootName = nextRootName;\n inc = incremented;\n [\n nextRootName,\n incremented,\n namer,\n ] = namer();\n }\n\n const {\n hasRestElement,\n hasPropertyRest,\n rests,\n names,\n } = /**\n * @type {import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string | undefined;\n * }}\n */ (functionParameterName[1]);\n const notCheckingNames = [];\n if (!enableRestElementFixer && hasRestElement) {\n continue;\n }\n\n if (!checkDestructuredRoots) {\n continue;\n }\n\n for (const [\n idx,\n paramName,\n ] of names.entries()) {\n // Add root if the root name is not in the docs (and is not already\n // in the tags to be fixed)\n if (!jsdocParameterNames.find(({\n name,\n }) => {\n return name === rootName;\n }) && !missingTags.find(({\n functionParameterName: fpn,\n }) => {\n return fpn === rootName;\n })) {\n const emptyParamIdx = jsdocParameterNames.findIndex(({\n name,\n }) => {\n return !name;\n });\n\n if (emptyParamIdx > -1) {\n missingTags.push({\n functionParameterIdx: emptyParamIdx,\n functionParameterName: rootName,\n inc,\n remove: true,\n });\n } else {\n missingTags.push({\n functionParameterIdx: hasParamIndex(rootName) ?\n getParamIndex(rootName) :\n getParamIndex(paramName),\n functionParameterName: rootName,\n inc,\n });\n }\n }\n\n if (!checkDestructured) {\n continue;\n }\n\n if (!checkRestProperty && rests[idx]) {\n continue;\n }\n\n const fullParamName = `${rootName}.${paramName}`;\n\n const notCheckingName = jsdocParameterNames.find(({\n name,\n type: paramType,\n }) => {\n return utils.comparePaths(name)(fullParamName) && paramType.search(checkTypesRegex) === -1 && paramType !== '';\n });\n\n if (notCheckingName !== undefined) {\n notCheckingNames.push(notCheckingName.name);\n }\n\n if (notCheckingNames.find((name) => {\n return fullParamName.startsWith(name);\n })) {\n continue;\n }\n\n if (jsdocParameterNames && !jsdocParameterNames.find(({\n name,\n }) => {\n return utils.comparePaths(name)(fullParamName);\n })) {\n missingTags.push({\n functionParameterIdx: getParamIndex(\n functionParameterName[0] ? fullParamName : paramName,\n ),\n functionParameterName: fullParamName,\n inc,\n type: hasRestElement && !hasPropertyRest ? '{...any}' : undefined,\n });\n }\n }\n\n continue;\n }\n\n /** @type {string} */\n let funcParamName;\n let type;\n if (typeof functionParameterName === 'object') {\n if (!enableRestElementFixer && functionParameterName.restElement) {\n continue;\n }\n\n funcParamName = /** @type {string} */ (functionParameterName.name);\n type = '{...any}';\n } else {\n funcParamName = /** @type {string} */ (functionParameterName);\n }\n\n if (jsdocParameterNames && !jsdocParameterNames.find(({\n name,\n }) => {\n return name === funcParamName;\n }) && funcParamName !== 'this') {\n missingTags.push({\n functionParameterIdx: getParamIndex(funcParamName),\n functionParameterName: funcParamName,\n inc,\n type,\n });\n }\n }\n\n /**\n *\n * @param {{\n * functionParameterIdx: import('../iterateJsdoc.js').Integer,\n * functionParameterName: string,\n * remove?: true,\n * inc?: boolean,\n * type?: string\n * }} cfg\n */\n const fix = ({\n functionParameterIdx,\n functionParameterName,\n remove,\n inc,\n type,\n }) => {\n if (inc && !enableRootFixer) {\n return;\n }\n\n /**\n *\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @param {import('../iterateJsdoc.js').Integer} sourceIndex\n * @param {import('../iterateJsdoc.js').Integer} spliceCount\n * @returns {void}\n */\n const createTokens = (tagIndex, sourceIndex, spliceCount) => {\n // console.log(sourceIndex, tagIndex, jsdoc.tags, jsdoc.source);\n const tokens = {\n number: sourceIndex + 1,\n source: '',\n tokens: {\n delimiter: '*',\n description: '',\n end: '',\n lineEnd: '',\n name: functionParameterName,\n newAdd: true,\n postDelimiter: ' ',\n postName: '',\n postTag: ' ',\n postType: type ? ' ' : '',\n start: jsdoc.source[sourceIndex].tokens.start,\n tag: `@${preferredTagName}`,\n type: type ?? '',\n },\n };\n\n /**\n * @type {(import('@es-joy/jsdoccomment').JsdocTagWithInline & {\n * newAdd?: true\n * })[]}\n */ (jsdoc.tags).splice(tagIndex, spliceCount, {\n description: '',\n inlineTags: [],\n name: functionParameterName,\n newAdd: true,\n optional: false,\n problems: [],\n source: [\n tokens,\n ],\n tag: preferredTagName,\n type: type ?? '',\n });\n const firstNumber = jsdoc.source[0].number;\n jsdoc.source.splice(sourceIndex, spliceCount, tokens);\n for (const [\n idx,\n src,\n ] of jsdoc.source.slice(sourceIndex).entries()) {\n src.number = firstNumber + sourceIndex + idx;\n }\n };\n\n const offset = jsdoc.source.findIndex(({\n tokens: {\n tag,\n end,\n },\n }) => {\n return tag || end;\n });\n if (remove) {\n createTokens(functionParameterIdx, offset + functionParameterIdx, 1);\n } else {\n const expectedIdx = findExpectedIndex(jsdoc.tags, functionParameterIdx);\n createTokens(expectedIdx, offset + expectedIdx, 0);\n }\n };\n\n /**\n * @returns {void}\n */\n const fixer = () => {\n for (const missingTag of missingTags) {\n fix(missingTag);\n }\n };\n\n if (missingTags.length && jsdoc.source.length === 1) {\n utils.makeMultiline();\n }\n\n for (const {\n functionParameterName,\n } of missingTags) {\n utils.reportJSDoc(\n `Missing JSDoc @${preferredTagName} \"${functionParameterName}\" declaration.`,\n null,\n enableFixer ? fixer : null,\n );\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that all function parameters are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n autoIncrementBase: {\n default: 0,\n type: 'integer',\n },\n checkConstructors: {\n default: true,\n type: 'boolean',\n },\n checkDestructured: {\n default: true,\n type: 'boolean',\n },\n checkDestructuredRoots: {\n default: true,\n type: 'boolean',\n },\n checkGetters: {\n default: false,\n type: 'boolean',\n },\n checkRestProperty: {\n default: false,\n type: 'boolean',\n },\n checkSetters: {\n default: false,\n type: 'boolean',\n },\n checkTypesPattern: {\n type: 'string',\n },\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 enableFixer: {\n type: 'boolean',\n },\n enableRestElementFixer: {\n type: 'boolean',\n },\n enableRootFixer: {\n type: 'boolean',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n unnamedRootBase: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n useDefaultObjectProperties: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n\n // We cannot cache comment nodes as the contexts may recur with the\n // same comment node but a different JS node, and we may need the different\n // JS node to ensure we iterate its context\n noTracking: true,\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;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMG,SAAS,GAAGA,CAACC,YAAY,EAAEC,YAAY,KAAK;EAChD;EACA,IAAIC,IAAI;EACR,IAAIC,GAAG,GAAGF,YAAY;EACtB,MAAMG,WAAW,GAAGJ,YAAY,CAACK,MAAM,IA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QACR,CAAC;QACDuD,YAAY,EAAE;UACZxI,OAAO,EAAE,KAAK;UACdiF,IAAI,EAAE;QACR,CAAC;QACD7D,iBAAiB,EAAE;UACjBpB,OAAO,EAAE,KAAK;UACdiF,IAAI,EAAE;QACR,CAAC;QACDwD,YAAY,EAAE;UACZzI,OAAO,EAAE,KAAK;UACdiF,IAAI,EAAE;QACR,CAAC;QACD1D,iBAAiB,EAAE;UACjB0D,IAAI,EAAE;QACR,CAAC;QACDyD,QAAQ,EAAE;UACRC,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACE3D,IAAI,EAAE;YACR,CAAC,EACD;cACEoD,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVO,OAAO,EAAE;kBACP5D,IAAI,EAAE;gBACR,CAAC;gBACDjE,OAAO,EAAE;kBACPiE,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDzD,WAAW,EAAE;UACXyD,IAAI,EAAE;QACR,CAAC;QACDvD,sBAAsB,EAAE;UACtBuD,IAAI,EAAE;QACR,CAAC;QACDxD,eAAe,EAAE;UACfwD,IAAI,EAAE;QACR,CAAC;QACD6D,UAAU,EAAE;UACVH,KAAK,EAAE;YACL1D,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDtD,eAAe,EAAE;UACfgH,KAAK,EAAE;YACL1D,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDrD,0BAA0B,EAAE;UAC1BqD,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR,CAAC;EAED;EACA;EACA;EACA8D,UAAU,EAAE;AACd,CAAC,CAAC;AAAAC,MAAA,CAAApI,OAAA,GAAAA,OAAA,CAAAZ,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireParam.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","rootNamer","desiredRoots","currentIndex","name","idx","incremented","length","base","suffix","shift","_default","exports","iterateJsdoc","jsdoc","utils","context","avoidDocs","hasTag","autoIncrementBase","checkRestProperty","checkDestructured","checkDestructuredRoots","checkTypesPattern","enableFixer","enableRootFixer","enableRestElementFixer","unnamedRootBase","useDefaultObjectProperties","options","preferredTagName","getPreferredTagName","tagName","functionParameterNames","getFunctionParameterNames","jsdocParameterNames","getJsdocTagsDeep","shallowJsdocParameterNames","filter","tag","includes","map","checkTypesRegex","getRegexFromString","missingTags","flattenedRoots","flattenRoots","names","paramIndex","hasParamIndex","cur","dropPathSegmentQuotes","String","getParamIndex","setParamIndex","entries","findExpectedIndex","jsdocTags","indexAtFunctionParams","remainingRoots","slice","foundIndex","findIndex","newAdd","some","remainingRoot","Array","isArray","tags","tagLineCount","source","tokens","end","nextRootName","namer","thisOffset","functionParameterIdx","functionParameterName","inc","matchedJsdoc","rootName","type","search","hasRestElement","hasPropertyRest","rests","notCheckingNames","paramName","find","fpn","emptyParamIdx","push","remove","fullParamName","notCheckingName","paramType","comparePaths","undefined","startsWith","funcParamName","restElement","fix","createTokens","tagIndex","sourceIndex","spliceCount","number","delimiter","description","lineEnd","postDelimiter","postName","postTag","postType","start","splice","inlineTags","optional","problems","firstNumber","src","offset","expectedIdx","fixer","missingTag","makeMultiline","reportJSDoc","contextDefaults","meta","docs","url","fixable","schema","additionalProperties","properties","checkConstructors","checkGetters","checkSetters","contexts","items","anyOf","comment","exemptedBy","noTracking","module"],"sources":["../../src/rules/requireParam.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @typedef {[string, boolean, () => RootNamerReturn]} RootNamerReturn\n */\n\n/**\n * @param {string[]} desiredRoots\n * @param {number} currentIndex\n * @returns {RootNamerReturn}\n */\nconst rootNamer = (desiredRoots, currentIndex) => {\n /** @type {string} */\n let name;\n let idx = currentIndex;\n const incremented = desiredRoots.length <= 1;\n if (incremented) {\n const base = desiredRoots[0];\n const suffix = idx++;\n name = `${base}${suffix}`;\n } else {\n name = /** @type {string} */ (desiredRoots.shift());\n }\n\n return [\n name,\n incremented,\n () => {\n return rootNamer(desiredRoots, idx);\n },\n ];\n};\n\n/* eslint-disable complexity -- Temporary */\nexport default iterateJsdoc(({\n jsdoc,\n utils,\n context,\n}) => {\n /* eslint-enable complexity -- Temporary */\n if (utils.avoidDocs()) {\n return;\n }\n\n // Param type is specified by type in @type\n if (utils.hasTag('type')) {\n return;\n }\n\n const {\n autoIncrementBase = 0,\n checkRestProperty = false,\n checkDestructured = true,\n checkDestructuredRoots = true,\n checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/',\n enableFixer = true,\n enableRootFixer = true,\n enableRestElementFixer = true,\n unnamedRootBase = [\n 'root',\n ],\n useDefaultObjectProperties = false,\n } = context.options[0] || {};\n\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'param',\n }));\n if (!preferredTagName) {\n return;\n }\n\n const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties);\n if (!functionParameterNames.length) {\n return;\n }\n\n const jsdocParameterNames =\n /**\n * @type {{\n * idx: import('../iterateJsdoc.js').Integer;\n * name: string;\n * type: string;\n * }[]}\n */ (utils.getJsdocTagsDeep(preferredTagName));\n\n const shallowJsdocParameterNames = jsdocParameterNames.filter((tag) => {\n return !tag.name.includes('.');\n }).map((tag, idx) => {\n return {\n ...tag,\n idx,\n };\n });\n\n const checkTypesRegex = utils.getRegexFromString(checkTypesPattern);\n\n /**\n * @type {{\n * functionParameterIdx: import('../iterateJsdoc.js').Integer,\n * functionParameterName: string,\n * inc: boolean|undefined,\n * remove?: true,\n * type?: string|undefined\n * }[]}\n */\n const missingTags = [];\n const flattenedRoots = utils.flattenRoots(functionParameterNames).names;\n\n /**\n * @type {{\n * [key: string]: import('../iterateJsdoc.js').Integer\n * }}\n */\n const paramIndex = {};\n\n /**\n * @param {string} cur\n * @returns {boolean}\n */\n const hasParamIndex = (cur) => {\n return utils.dropPathSegmentQuotes(String(cur)) in paramIndex;\n };\n\n /**\n *\n * @param {string|number|undefined} cur\n * @returns {import('../iterateJsdoc.js').Integer}\n */\n const getParamIndex = (cur) => {\n return paramIndex[utils.dropPathSegmentQuotes(String(cur))];\n };\n\n /**\n *\n * @param {string} cur\n * @param {import('../iterateJsdoc.js').Integer} idx\n * @returns {void}\n */\n const setParamIndex = (cur, idx) => {\n paramIndex[utils.dropPathSegmentQuotes(String(cur))] = idx;\n };\n\n for (const [\n idx,\n cur,\n ] of flattenedRoots.entries()) {\n setParamIndex(cur, idx);\n }\n\n /**\n *\n * @param {(import('@es-joy/jsdoccomment').JsdocTagWithInline & {\n * newAdd?: boolean\n * })[]} jsdocTags\n * @param {import('../iterateJsdoc.js').Integer} indexAtFunctionParams\n * @returns {import('../iterateJsdoc.js').Integer}\n */\n const findExpectedIndex = (jsdocTags, indexAtFunctionParams) => {\n const remainingRoots = functionParameterNames.slice(indexAtFunctionParams || 0);\n const foundIndex = jsdocTags.findIndex(({\n name,\n newAdd,\n }) => {\n return !newAdd && remainingRoots.some((remainingRoot) => {\n if (Array.isArray(remainingRoot)) {\n return (\n /**\n * @type {import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string|undefined;\n * }}\n */ (remainingRoot[1]).names.includes(name)\n );\n }\n\n if (typeof remainingRoot === 'object') {\n return name === remainingRoot.name;\n }\n\n return name === remainingRoot;\n });\n });\n\n const tags = foundIndex > -1 ?\n jsdocTags.slice(0, foundIndex) :\n jsdocTags.filter(({\n tag,\n }) => {\n return tag === preferredTagName;\n });\n\n let tagLineCount = 0;\n for (const {\n source,\n } of tags) {\n for (const {\n tokens: {\n end,\n },\n } of source) {\n if (!end) {\n tagLineCount++;\n }\n }\n }\n\n return tagLineCount;\n };\n\n let [\n nextRootName,\n incremented,\n namer,\n ] = rootNamer([\n ...unnamedRootBase,\n ], autoIncrementBase);\n\n const thisOffset = functionParameterNames[0] === 'this' ? 1 : 0;\n\n for (const [\n functionParameterIdx,\n functionParameterName,\n ] of functionParameterNames.entries()) {\n\n let inc;\n if (Array.isArray(functionParameterName)) {\n const matchedJsdoc = shallowJsdocParameterNames[functionParameterIdx - thisOffset];\n\n /** @type {string} */\n let rootName;\n if (functionParameterName[0]) {\n rootName = functionParameterName[0];\n } else if (matchedJsdoc && matchedJsdoc.name) {\n rootName = matchedJsdoc.name;\n if (matchedJsdoc.type && matchedJsdoc.type.search(checkTypesRegex) === -1) {\n continue;\n }\n } else {\n rootName = nextRootName;\n inc = incremented;\n }\n [\n nextRootName,\n incremented,\n namer,\n ] = namer();\n\n const {\n hasRestElement,\n hasPropertyRest,\n rests,\n names,\n } = /**\n * @type {import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string | undefined;\n * }}\n */ (functionParameterName[1]);\n const notCheckingNames = [];\n if (!enableRestElementFixer && hasRestElement) {\n continue;\n }\n\n if (!checkDestructuredRoots) {\n continue;\n }\n\n for (const [\n idx,\n paramName,\n ] of names.entries()) {\n // Add root if the root name is not in the docs (and is not already\n // in the tags to be fixed)\n if (!jsdocParameterNames.find(({\n name,\n }) => {\n return name === rootName;\n }) && !missingTags.find(({\n functionParameterName: fpn,\n }) => {\n return fpn === rootName;\n })) {\n const emptyParamIdx = jsdocParameterNames.findIndex(({\n name,\n }) => {\n return !name;\n });\n\n if (emptyParamIdx > -1) {\n missingTags.push({\n functionParameterIdx: emptyParamIdx,\n functionParameterName: rootName,\n inc,\n remove: true,\n });\n } else {\n missingTags.push({\n functionParameterIdx: hasParamIndex(rootName) ?\n getParamIndex(rootName) :\n getParamIndex(paramName),\n functionParameterName: rootName,\n inc,\n });\n }\n }\n\n if (!checkDestructured) {\n continue;\n }\n\n if (!checkRestProperty && rests[idx]) {\n continue;\n }\n\n const fullParamName = `${rootName}.${paramName}`;\n\n const notCheckingName = jsdocParameterNames.find(({\n name,\n type: paramType,\n }) => {\n return utils.comparePaths(name)(fullParamName) && paramType.search(checkTypesRegex) === -1 && paramType !== '';\n });\n\n if (notCheckingName !== undefined) {\n notCheckingNames.push(notCheckingName.name);\n }\n\n if (notCheckingNames.find((name) => {\n return fullParamName.startsWith(name);\n })) {\n continue;\n }\n\n if (jsdocParameterNames && !jsdocParameterNames.find(({\n name,\n }) => {\n return utils.comparePaths(name)(fullParamName);\n })) {\n missingTags.push({\n functionParameterIdx: getParamIndex(\n functionParameterName[0] ? fullParamName : paramName,\n ),\n functionParameterName: fullParamName,\n inc,\n type: hasRestElement && !hasPropertyRest ? '{...any}' : undefined,\n });\n }\n }\n\n continue;\n }\n\n /** @type {string} */\n let funcParamName;\n let type;\n if (typeof functionParameterName === 'object') {\n if (!enableRestElementFixer && functionParameterName.restElement) {\n continue;\n }\n\n funcParamName = /** @type {string} */ (functionParameterName.name);\n type = '{...any}';\n } else {\n funcParamName = /** @type {string} */ (functionParameterName);\n }\n\n if (jsdocParameterNames && !jsdocParameterNames.find(({\n name,\n }) => {\n return name === funcParamName;\n }) && funcParamName !== 'this') {\n missingTags.push({\n functionParameterIdx: getParamIndex(funcParamName),\n functionParameterName: funcParamName,\n inc,\n type,\n });\n }\n }\n\n /**\n *\n * @param {{\n * functionParameterIdx: import('../iterateJsdoc.js').Integer,\n * functionParameterName: string,\n * remove?: true,\n * inc?: boolean,\n * type?: string\n * }} cfg\n */\n const fix = ({\n functionParameterIdx,\n functionParameterName,\n remove,\n inc,\n type,\n }) => {\n if (inc && !enableRootFixer) {\n return;\n }\n\n /**\n *\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @param {import('../iterateJsdoc.js').Integer} sourceIndex\n * @param {import('../iterateJsdoc.js').Integer} spliceCount\n * @returns {void}\n */\n const createTokens = (tagIndex, sourceIndex, spliceCount) => {\n // console.log(sourceIndex, tagIndex, jsdoc.tags, jsdoc.source);\n const tokens = {\n number: sourceIndex + 1,\n source: '',\n tokens: {\n delimiter: '*',\n description: '',\n end: '',\n lineEnd: '',\n name: functionParameterName,\n newAdd: true,\n postDelimiter: ' ',\n postName: '',\n postTag: ' ',\n postType: type ? ' ' : '',\n start: jsdoc.source[sourceIndex].tokens.start,\n tag: `@${preferredTagName}`,\n type: type ?? '',\n },\n };\n\n /**\n * @type {(import('@es-joy/jsdoccomment').JsdocTagWithInline & {\n * newAdd?: true\n * })[]}\n */ (jsdoc.tags).splice(tagIndex, spliceCount, {\n description: '',\n inlineTags: [],\n name: functionParameterName,\n newAdd: true,\n optional: false,\n problems: [],\n source: [\n tokens,\n ],\n tag: preferredTagName,\n type: type ?? '',\n });\n const firstNumber = jsdoc.source[0].number;\n jsdoc.source.splice(sourceIndex, spliceCount, tokens);\n for (const [\n idx,\n src,\n ] of jsdoc.source.slice(sourceIndex).entries()) {\n src.number = firstNumber + sourceIndex + idx;\n }\n };\n\n const offset = jsdoc.source.findIndex(({\n tokens: {\n tag,\n end,\n },\n }) => {\n return tag || end;\n });\n if (remove) {\n createTokens(functionParameterIdx, offset + functionParameterIdx, 1);\n } else {\n const expectedIdx = findExpectedIndex(jsdoc.tags, functionParameterIdx);\n createTokens(expectedIdx, offset + expectedIdx, 0);\n }\n };\n\n /**\n * @returns {void}\n */\n const fixer = () => {\n for (const missingTag of missingTags) {\n fix(missingTag);\n }\n };\n\n if (missingTags.length && jsdoc.source.length === 1) {\n utils.makeMultiline();\n }\n\n for (const {\n functionParameterName,\n } of missingTags) {\n utils.reportJSDoc(\n `Missing JSDoc @${preferredTagName} \"${functionParameterName}\" declaration.`,\n null,\n enableFixer ? fixer : null,\n );\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that all function parameters are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n autoIncrementBase: {\n default: 0,\n type: 'integer',\n },\n checkConstructors: {\n default: true,\n type: 'boolean',\n },\n checkDestructured: {\n default: true,\n type: 'boolean',\n },\n checkDestructuredRoots: {\n default: true,\n type: 'boolean',\n },\n checkGetters: {\n default: false,\n type: 'boolean',\n },\n checkRestProperty: {\n default: false,\n type: 'boolean',\n },\n checkSetters: {\n default: false,\n type: 'boolean',\n },\n checkTypesPattern: {\n type: 'string',\n },\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 enableFixer: {\n type: 'boolean',\n },\n enableRestElementFixer: {\n type: 'boolean',\n },\n enableRootFixer: {\n type: 'boolean',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n unnamedRootBase: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n useDefaultObjectProperties: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n\n // We cannot cache comment nodes as the contexts may recur with the\n // same comment node but a different JS node, and we may need the different\n // JS node to ensure we iterate its context\n noTracking: true,\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;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMG,SAAS,GAAGA,CAACC,YAAY,EAAEC,YAAY,KAAK;EAChD;EACA,IAAIC,IAAI;EACR,IAAIC,GAAG,GAAGF,YAAY;EACtB,MAAMG,WAAW,GAAGJ,YAAY,CAACK,MAAM,IAAI,CAAC;EAC5C,IAAID,WAAW,EAAE;IACf,MAAME,IAAI,GAAGN,YAAY,CAAC,CAAC,CAAC;IAC5B,MAAMO,MAAM,GAAGJ,GAAG,EAAE;IACpBD,IAAI,GAAG,GAAGI,IAAI,GAAGC,MAAM,EAAE;EAC3B,CAAC,MAAM;I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AAiB,EAAE;UACjB0D,IAAI,EAAE;QACR,CAAC;QACDyD,QAAQ,EAAE;UACRC,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACE3D,IAAI,EAAE;YACR,CAAC,EACD;cACEoD,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVO,OAAO,EAAE;kBACP5D,IAAI,EAAE;gBACR,CAAC;gBACDjE,OAAO,EAAE;kBACPiE,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDzD,WAAW,EAAE;UACXyD,IAAI,EAAE;QACR,CAAC;QACDvD,sBAAsB,EAAE;UACtBuD,IAAI,EAAE;QACR,CAAC;QACDxD,eAAe,EAAE;UACfwD,IAAI,EAAE;QACR,CAAC;QACD6D,UAAU,EAAE;UACVH,KAAK,EAAE;YACL1D,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDtD,eAAe,EAAE;UACfgH,KAAK,EAAE;YACL1D,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDrD,0BAA0B,EAAE;UAC1BqD,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR,CAAC;EAED;EACA;EACA;EACA8D,UAAU,EAAE;AACd,CAAC,CAAC;AAAAC,MAAA,CAAApI,OAAA,GAAAA,OAAA,CAAAZ,OAAA","ignoreList":[]}
package/package.json CHANGED
@@ -5,13 +5,13 @@
5
5
  "url": "http://gajus.com"
6
6
  },
7
7
  "dependencies": {
8
- "@es-joy/jsdoccomment": "~0.43.1",
8
+ "@es-joy/jsdoccomment": "~0.45.0",
9
9
  "are-docs-informative": "^0.0.2",
10
10
  "comment-parser": "1.4.1",
11
11
  "debug": "^4.3.5",
12
12
  "escape-string-regexp": "^4.0.0",
13
- "esquery": "^1.5.0",
14
- "parse-imports": "^2.1.0",
13
+ "esquery": "^1.6.0",
14
+ "parse-imports": "^2.1.1",
15
15
  "semver": "^7.6.2",
16
16
  "spdx-expression-parse": "^4.0.0",
17
17
  "synckit": "^0.9.0"
@@ -29,7 +29,7 @@
29
29
  "@es-joy/jsdoc-eslint-parser": "^0.21.1",
30
30
  "@hkdobrev/run-if-changed": "^0.3.1",
31
31
  "@semantic-release/commit-analyzer": "^13.0.0",
32
- "@semantic-release/github": "^10.0.6",
32
+ "@semantic-release/github": "^10.1.0",
33
33
  "@semantic-release/npm": "^12.0.1",
34
34
  "@types/chai": "^4.3.16",
35
35
  "@types/debug": "^4.1.12",
@@ -39,35 +39,35 @@
39
39
  "@types/json-schema": "^7.0.15",
40
40
  "@types/lodash.defaultsdeep": "^4.6.9",
41
41
  "@types/mocha": "^10.0.7",
42
- "@types/node": "^20.14.9",
42
+ "@types/node": "^20.14.10",
43
43
  "@types/semver": "^7.5.8",
44
44
  "@types/spdx-expression-parse": "^3.0.5",
45
- "@typescript-eslint/types": "^7.14.1",
45
+ "@typescript-eslint/types": "^7.16.0",
46
46
  "babel-plugin-add-module-exports": "^1.0.4",
47
- "babel-plugin-istanbul": "^6.1.1",
47
+ "babel-plugin-istanbul": "^7.0.0",
48
48
  "babel-plugin-transform-import-meta": "^2.2.1",
49
49
  "c8": "^10.1.2",
50
50
  "camelcase": "^6.3.0",
51
51
  "chai": "^4.3.10",
52
52
  "cross-env": "^7.0.3",
53
53
  "decamelize": "^5.0.1",
54
- "eslint": "9.5.0",
54
+ "eslint": "9.6.0",
55
55
  "eslint-config-canonical": "~43.0.13",
56
56
  "espree": "^10.1.0",
57
57
  "gitdown": "^3.1.5",
58
58
  "glob": "^10.4.2",
59
- "globals": "^15.6.0",
59
+ "globals": "^15.8.0",
60
60
  "husky": "^9.0.11",
61
61
  "jsdoc-type-pratt-parser": "^4.0.0",
62
62
  "json-schema": "^0.4.0",
63
63
  "lint-staged": "^15.2.7",
64
64
  "lodash.defaultsdeep": "^4.6.1",
65
- "mocha": "^10.5.2",
65
+ "mocha": "^10.6.0",
66
66
  "open-editor": "^3.0.0",
67
67
  "replace": "^1.2.2",
68
68
  "rimraf": "^5.0.7",
69
69
  "semantic-release": "^24.0.0",
70
- "typescript": "5.3.x",
70
+ "typescript": "5.5.x",
71
71
  "typescript-eslint": "^8.0.0-alpha.34"
72
72
  },
73
73
  "engines": {
@@ -144,5 +144,5 @@
144
144
  "test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov",
145
145
  "test-index": "npm run test-no-cov -- test/rules/index.js"
146
146
  },
147
- "version": "48.5.1"
147
+ "version": "48.6.0"
148
148
  }
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ import checkSyntax from './rules/checkSyntax.js';
9
9
  import checkTagNames from './rules/checkTagNames.js';
10
10
  import checkTypes from './rules/checkTypes.js';
11
11
  import checkValues from './rules/checkValues.js';
12
+ import convertToJsdocComments from './rules/convertToJsdocComments.js';
12
13
  import emptyTags from './rules/emptyTags.js';
13
14
  import implementsOnClasses from './rules/implementsOnClasses.js';
14
15
  import importsAsDependencies from './rules/importsAsDependencies.js';
@@ -81,6 +82,7 @@ const index = {
81
82
  'check-tag-names': checkTagNames,
82
83
  'check-types': checkTypes,
83
84
  'check-values': checkValues,
85
+ 'convert-to-jsdoc-comments': convertToJsdocComments,
84
86
  'empty-tags': emptyTags,
85
87
  'implements-on-classes': implementsOnClasses,
86
88
  'imports-as-dependencies': importsAsDependencies,
@@ -153,6 +155,7 @@ const createRecommendedRuleset = (warnOrError, flatName) => {
153
155
  'jsdoc/check-tag-names': warnOrError,
154
156
  'jsdoc/check-types': warnOrError,
155
157
  'jsdoc/check-values': warnOrError,
158
+ 'jsdoc/convert-to-jsdoc-comments': 'off',
156
159
  'jsdoc/empty-tags': warnOrError,
157
160
  'jsdoc/implements-on-classes': warnOrError,
158
161
  'jsdoc/imports-as-dependencies': 'off',
package/src/jsdocUtils.js CHANGED
@@ -1321,7 +1321,7 @@ const parseClosureTemplateTag = (tag) => {
1321
1321
  * @param {{
1322
1322
  * contexts?: import('./iterateJsdoc.js').Context[]
1323
1323
  * }} settings
1324
- * @returns {string[]}
1324
+ * @returns {(string|import('./iterateJsdoc.js').ContextObject)[]}
1325
1325
  */
1326
1326
  const enforcedContexts = (context, defaultContexts, settings) => {
1327
1327
  const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? [
@@ -0,0 +1,384 @@
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
+ import {
3
+ getSettings,
4
+ } from '../iterateJsdoc.js';
5
+ import jsdocUtils from '../jsdocUtils.js';
6
+ import {
7
+ getNonJsdocComment,
8
+ getDecorator,
9
+ getReducedASTNode,
10
+ getFollowingComment,
11
+ } from '@es-joy/jsdoccomment';
12
+
13
+ /** @type {import('eslint').Rule.RuleModule} */
14
+ export default {
15
+ create (context) {
16
+ /**
17
+ * @typedef {import('eslint').AST.Token | import('estree').Comment | {
18
+ * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
19
+ * range: [number, number],
20
+ * value: string
21
+ * }} Token
22
+ */
23
+
24
+ /**
25
+ * @callback AddComment
26
+ * @param {boolean|undefined} inlineCommentBlock
27
+ * @param {Token} comment
28
+ * @param {string} indent
29
+ * @param {number} lines
30
+ * @param {import('eslint').Rule.RuleFixer} fixer
31
+ */
32
+
33
+ /* c8 ignore next -- Fallback to deprecated method */
34
+ const {
35
+ sourceCode = context.getSourceCode(),
36
+ } = context;
37
+ const settings = getSettings(context);
38
+ if (!settings) {
39
+ return {};
40
+ }
41
+
42
+ const {
43
+ contexts = settings.contexts || [],
44
+ contextsAfter = /** @type {string[]} */ ([]),
45
+ contextsBeforeAndAfter = [
46
+ 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition'
47
+ ],
48
+ enableFixer = true,
49
+ enforceJsdocLineStyle = 'multi',
50
+ lineOrBlockStyle = 'both',
51
+ allowedPrefixes = ['@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-']
52
+ } = context.options[0] ?? {};
53
+
54
+ let reportingNonJsdoc = false;
55
+
56
+ /**
57
+ * @param {string} messageId
58
+ * @param {import('estree').Comment|Token} comment
59
+ * @param {import('eslint').Rule.Node} node
60
+ * @param {import('eslint').Rule.ReportFixer} fixer
61
+ */
62
+ const report = (messageId, comment, node, fixer) => {
63
+ const loc = {
64
+ end: {
65
+ column: 0,
66
+ /* c8 ignore next 2 -- Guard */
67
+ // @ts-expect-error Ok
68
+ line: (comment.loc?.start?.line ?? 1),
69
+ },
70
+ start: {
71
+ column: 0,
72
+ /* c8 ignore next 2 -- Guard */
73
+ // @ts-expect-error Ok
74
+ line: (comment.loc?.start?.line ?? 1)
75
+ },
76
+ };
77
+
78
+ context.report({
79
+ fix: enableFixer ? fixer : null,
80
+ loc,
81
+ messageId,
82
+ node,
83
+ });
84
+ };
85
+
86
+ /**
87
+ * @param {import('eslint').Rule.Node} node
88
+ * @param {import('eslint').AST.Token | import('estree').Comment | {
89
+ * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
90
+ * range: [number, number],
91
+ * value: string
92
+ * }} comment
93
+ * @param {AddComment} addComment
94
+ * @param {import('../iterateJsdoc.js').Context[]} ctxts
95
+ */
96
+ const getFixer = (node, comment, addComment, ctxts) => {
97
+ return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
98
+ // Default to one line break if the `minLines`/`maxLines` settings allow
99
+ const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
100
+ let baseNode =
101
+ /**
102
+ * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node}
103
+ */ (
104
+ getReducedASTNode(node, sourceCode)
105
+ );
106
+
107
+ const decorator = getDecorator(
108
+ /** @type {import('eslint').Rule.Node} */
109
+ (baseNode)
110
+ );
111
+ if (decorator) {
112
+ baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (
113
+ decorator
114
+ );
115
+ }
116
+
117
+ const indent = jsdocUtils.getIndent({
118
+ text: sourceCode.getText(
119
+ /** @type {import('eslint').Rule.Node} */ (baseNode),
120
+ /** @type {import('eslint').AST.SourceLocation} */
121
+ (
122
+ /** @type {import('eslint').Rule.Node} */ (baseNode).loc
123
+ ).start.column,
124
+ ),
125
+ });
126
+
127
+ const {
128
+ inlineCommentBlock,
129
+ } =
130
+ /**
131
+ * @type {{
132
+ * context: string,
133
+ * inlineCommentBlock: boolean,
134
+ * minLineCount: import('../iterateJsdoc.js').Integer
135
+ * }[]}
136
+ */ (ctxts).find((contxt) => {
137
+ if (typeof contxt === 'string') {
138
+ return false;
139
+ }
140
+
141
+ const {
142
+ context: ctxt,
143
+ } = contxt;
144
+ return ctxt === node.type;
145
+ }) || {};
146
+
147
+ return addComment(inlineCommentBlock, comment, indent, lines, fixer);
148
+ };
149
+ };
150
+
151
+ /**
152
+ * @param {import('eslint').AST.Token | import('estree').Comment | {
153
+ * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
154
+ * range: [number, number],
155
+ * value: string
156
+ * }} comment
157
+ * @param {import('eslint').Rule.Node} node
158
+ * @param {AddComment} addComment
159
+ * @param {import('../iterateJsdoc.js').Context[]} ctxts
160
+ */
161
+ const reportings = (comment, node, addComment, ctxts) => {
162
+ const fixer = getFixer(node, comment, addComment, ctxts);
163
+
164
+ if (comment.type === 'Block') {
165
+ if (lineOrBlockStyle === 'line') {
166
+ return;
167
+ }
168
+ report('blockCommentsJsdocStyle', comment, node, fixer);
169
+ return;
170
+ }
171
+
172
+ if (comment.type === 'Line') {
173
+ if (lineOrBlockStyle === 'block') {
174
+ return;
175
+ }
176
+ report('lineCommentsJsdocStyle', comment, node, fixer);
177
+ }
178
+ };
179
+
180
+ /**
181
+ * @type {import('../iterateJsdoc.js').CheckJsdoc}
182
+ */
183
+ const checkNonJsdoc = (_info, _handler, node) => {
184
+ const comment = getNonJsdocComment(sourceCode, node, settings);
185
+
186
+ if (
187
+ !comment ||
188
+ /** @type {string[]} */
189
+ (allowedPrefixes).some((prefix) => {
190
+ return comment.value.trimStart().startsWith(prefix);
191
+ })
192
+ ) {
193
+ return;
194
+ }
195
+
196
+ reportingNonJsdoc = true;
197
+
198
+ /** @type {AddComment} */
199
+ const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => {
200
+ const insertion = (
201
+ inlineCommentBlock || enforceJsdocLineStyle === 'single'
202
+ ? `/** ${comment.value.trim()} `
203
+ : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}`
204
+ ) +
205
+ `*/${'\n'.repeat((lines || 1) - 1)}`;
206
+
207
+ return fixer.replaceText(
208
+ /** @type {import('eslint').AST.Token} */
209
+ (comment),
210
+ insertion,
211
+ );
212
+ };
213
+
214
+ reportings(comment, node, addComment, contexts);
215
+ };
216
+
217
+ /**
218
+ * @param {import('eslint').Rule.Node} node
219
+ * @param {import('../iterateJsdoc.js').Context[]} ctxts
220
+ */
221
+ const checkNonJsdocAfter = (node, ctxts) => {
222
+ const comment = getFollowingComment(sourceCode, node);
223
+
224
+ if (
225
+ !comment ||
226
+ comment.value.startsWith('*') ||
227
+ /** @type {string[]} */
228
+ (allowedPrefixes).some((prefix) => {
229
+ return comment.value.trimStart().startsWith(prefix);
230
+ })
231
+ ) {
232
+ return;
233
+ }
234
+
235
+ /** @type {AddComment} */
236
+ const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => {
237
+ const insertion = (
238
+ inlineCommentBlock || enforceJsdocLineStyle === 'single'
239
+ ? `/** ${comment.value.trim()} `
240
+ : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}`
241
+ ) +
242
+ `*/${'\n'.repeat((lines || 1) - 1)}${lines ? `\n${indent.slice(1)}` : ' '}`;
243
+
244
+ return [fixer.remove(
245
+ /** @type {import('eslint').AST.Token} */
246
+ (comment)
247
+ ), fixer.insertTextBefore(
248
+ node.type === 'VariableDeclarator' ? node.parent : node,
249
+ insertion,
250
+ )];
251
+ };
252
+
253
+ reportings(comment, node, addComment, ctxts);
254
+ };
255
+
256
+ // Todo: add contexts to check after (and handle if want both before and after)
257
+ return {
258
+ ...jsdocUtils.getContextObject(
259
+ jsdocUtils.enforcedContexts(context, true, settings),
260
+ checkNonJsdoc,
261
+ ),
262
+ ...jsdocUtils.getContextObject(
263
+ contextsAfter,
264
+ (_info, _handler, node) => {
265
+ checkNonJsdocAfter(node, contextsAfter);
266
+ },
267
+ ),
268
+ ...jsdocUtils.getContextObject(
269
+ contextsBeforeAndAfter,
270
+ (_info, _handler, node) => {
271
+ checkNonJsdoc({}, null, node);
272
+ if (!reportingNonJsdoc) {
273
+ checkNonJsdocAfter(node, contextsBeforeAndAfter);
274
+ }
275
+ }
276
+ )
277
+ };
278
+ },
279
+ meta: {
280
+ fixable: 'code',
281
+
282
+ messages: {
283
+ blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',
284
+ lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',
285
+ },
286
+
287
+ docs: {
288
+ description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',
289
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',
290
+ },
291
+ schema: [
292
+ {
293
+ additionalProperties: false,
294
+ properties: {
295
+ allowedPrefixes: {
296
+ type: 'array',
297
+ items: {
298
+ type: 'string'
299
+ }
300
+ },
301
+ contexts: {
302
+ items: {
303
+ anyOf: [
304
+ {
305
+ type: 'string',
306
+ },
307
+ {
308
+ additionalProperties: false,
309
+ properties: {
310
+ context: {
311
+ type: 'string',
312
+ },
313
+ inlineCommentBlock: {
314
+ type: 'boolean',
315
+ },
316
+ },
317
+ type: 'object',
318
+ },
319
+ ],
320
+ },
321
+ type: 'array',
322
+ },
323
+ contextsAfter: {
324
+ items: {
325
+ anyOf: [
326
+ {
327
+ type: 'string',
328
+ },
329
+ {
330
+ additionalProperties: false,
331
+ properties: {
332
+ context: {
333
+ type: 'string',
334
+ },
335
+ inlineCommentBlock: {
336
+ type: 'boolean',
337
+ },
338
+ },
339
+ type: 'object',
340
+ },
341
+ ],
342
+ },
343
+ type: 'array',
344
+ },
345
+ contextsBeforeAndAfter: {
346
+ items: {
347
+ anyOf: [
348
+ {
349
+ type: 'string',
350
+ },
351
+ {
352
+ additionalProperties: false,
353
+ properties: {
354
+ context: {
355
+ type: 'string',
356
+ },
357
+ inlineCommentBlock: {
358
+ type: 'boolean',
359
+ },
360
+ },
361
+ type: 'object',
362
+ },
363
+ ],
364
+ },
365
+ type: 'array',
366
+ },
367
+ enableFixer: {
368
+ type: 'boolean'
369
+ },
370
+ enforceJsdocLineStyle: {
371
+ type: 'string',
372
+ enum: ['multi', 'single']
373
+ },
374
+ lineOrBlockStyle: {
375
+ type: 'string',
376
+ enum: ['block', 'line', 'both']
377
+ },
378
+ },
379
+ type: 'object',
380
+ },
381
+ ],
382
+ type: 'suggestion',
383
+ },
384
+ };
@@ -18,6 +18,11 @@ import {
18
18
  * }} RequireJsdocOpts
19
19
  */
20
20
 
21
+ /**
22
+ * @typedef {import('eslint').Rule.Node|
23
+ * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
24
+ */
25
+
21
26
  /** @type {import('json-schema').JSONSchema4} */
22
27
  const OPTIONS_SCHEMA = {
23
28
  additionalProperties: false,
@@ -411,10 +416,13 @@ export default {
411
416
  const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
412
417
  // Default to one line break if the `minLines`/`maxLines` settings allow
413
418
  const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
414
- /** @type {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Decorator} */
419
+ /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
415
420
  let baseNode = getReducedASTNode(node, sourceCode);
416
421
 
417
- const decorator = getDecorator(baseNode);
422
+ const decorator = getDecorator(
423
+ /** @type {import('eslint').Rule.Node} */
424
+ (baseNode)
425
+ );
418
426
  if (decorator) {
419
427
  baseNode = decorator;
420
428
  }