eslint-plugin-jsdoc 57.2.1 → 58.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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","context","jsdoc","utils","avoidDocs","hasTag","autoIncrementBase","checkDestructured","checkDestructuredRoots","checkRestProperty","checkTypesPattern","enableFixer","enableRestElementFixer","enableRootFixer","ignoreWhenAllParamsMissing","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","hasPropertyRest","hasRestElement","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 context,\n jsdoc,\n utils,\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 checkDestructured = true,\n checkDestructuredRoots = true,\n checkRestProperty = false,\n checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/',\n enableFixer = true,\n enableRestElementFixer = true,\n enableRootFixer = true,\n ignoreWhenAllParamsMissing = false,\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 if (ignoreWhenAllParamsMissing && !jsdocParameterNames.length) {\n return;\n }\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\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 [\n nextRootName,\n incremented,\n namer,\n ] = namer();\n\n const {\n hasPropertyRest,\n hasRestElement,\n names,\n rests,\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 inc,\n remove,\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 end,\n tag,\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 ignoreWhenAllParamsMissing: {\n type: 'boolean',\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;EA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A,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR,CAAC;EAED;EACA;EACA;EACA8D,UAAU,EAAE;AACd,CAAC,CAAC;AAAAC,MAAA,CAAArI,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","context","jsdoc","node","utils","avoidDocs","hasTag","autoIncrementBase","checkDestructured","checkDestructuredRoots","checkRestProperty","checkTypesPattern","enableFixer","enableRestElementFixer","enableRootFixer","ignoreWhenAllParamsMissing","interfaceExemptsParamsCheck","unnamedRootBase","useDefaultObjectProperties","options","params","type","typeAnnotation","parent","id","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","search","hasPropertyRest","hasRestElement","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 context,\n jsdoc,\n node,\n utils,\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 checkDestructured = true,\n checkDestructuredRoots = true,\n checkRestProperty = false,\n checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/',\n enableFixer = true,\n enableRestElementFixer = true,\n enableRootFixer = true,\n ignoreWhenAllParamsMissing = false,\n interfaceExemptsParamsCheck = false,\n unnamedRootBase = [\n 'root',\n ],\n useDefaultObjectProperties = false,\n } = context.options[0] || {};\n\n if (interfaceExemptsParamsCheck) {\n if (node && 'params' in node && node.params.length === 1 &&\n node.params?.[0] && typeof node.params[0] === 'object' &&\n node.params[0].type === 'ObjectPattern' &&\n 'typeAnnotation' in node.params[0] && node.params[0].typeAnnotation\n ) {\n return;\n }\n\n if (node && node.parent.type === 'VariableDeclarator' &&\n 'typeAnnotation' in node.parent.id && node.parent.id.typeAnnotation) {\n return;\n }\n }\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 if (ignoreWhenAllParamsMissing && !jsdocParameterNames.length) {\n return;\n }\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\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 [\n nextRootName,\n incremented,\n namer,\n ] = namer();\n\n const {\n hasPropertyRest,\n hasRestElement,\n names,\n rests,\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 inc,\n remove,\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 end,\n tag,\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 ignoreWhenAllParamsMissing: {\n type: 'boolean',\n },\n interfaceExemptsParamsCheck: {\n type: 'boolean',\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;IACLL,IAAI,GAAG,qBAAuBF,YAAY,CAACQ,KAAK,CAAC,CAAE;EACrD;EAEA,OAAO,CACLN,IAAI,EACJE,WAAW,EACX,MAAM;IACJ,OAAOL,SAAS,CAACC,YAAY,EAAEG,GAAG,CAAC;EACrC,CAAC,CACF;AACH,CAAC;;AAED;AAAA,IAAAM,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GACe,IAAAa,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC,IAAI;EACJC;AACF,CAAC,KAAK;EACJ;EACA,IAAIA,KAAK,CAACC,SAAS,CAAC,CAAC,EAAE;IACrB;EACF;;EAEA;EACA,IAAID,KAAK,CAACE,MAAM,CAAC,MAAM,CAAC,EAAE;IACxB;EACF;EAEA,MAAM;IACJC,iBAAiB,GAAG,CAAC;IACrBC,iBAAiB,GAA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AAU,EAAE;AACd,CAAC,CAAC;AAAAC,MAAA,CAAA3I,OAAA,GAAAA,OAAA,CAAAZ,OAAA","ignoreList":[]}
package/dist/rules.d.ts CHANGED
@@ -410,6 +410,12 @@ export interface Rules {
410
410
  }
411
411
  ];
412
412
 
413
+ /** Reports use of `any` or `*` type */
414
+ "jsdoc/reject-any-type": [];
415
+
416
+ /** Reports use of `Function` type */
417
+ "jsdoc/reject-function-type": [];
418
+
413
419
  /** Requires that each JSDoc line starts with an `*`. */
414
420
  "jsdoc/require-asterisk-prefix":
415
421
  | []
@@ -557,7 +563,7 @@ export interface Rules {
557
563
  }
558
564
  ];
559
565
 
560
- /** Requires a type for @next tags */
566
+ /** Requires a type for `@next` tags */
561
567
  "jsdoc/require-next-type": [];
562
568
 
563
569
  /** Requires that all function parameters are documented. */
@@ -585,6 +591,7 @@ export interface Rules {
585
591
  enableRootFixer?: boolean;
586
592
  exemptedBy?: string[];
587
593
  ignoreWhenAllParamsMissing?: boolean;
594
+ interfaceExemptsParamsCheck?: boolean;
588
595
  unnamedRootBase?: string[];
589
596
  useDefaultObjectProperties?: boolean;
590
597
  }
@@ -748,7 +755,7 @@ export interface Rules {
748
755
  }
749
756
  ];
750
757
 
751
- /** Requires a type for @throws tags */
758
+ /** Requires a type for `@throws` tags */
752
759
  "jsdoc/require-throws-type": [];
753
760
 
754
761
  /** Requires yields are documented. */
@@ -790,7 +797,7 @@ export interface Rules {
790
797
  }
791
798
  ];
792
799
 
793
- /** Requires a type for @yields tags */
800
+ /** Requires a type for `@yields` tags */
794
801
  "jsdoc/require-yields-type": [];
795
802
 
796
803
  /** Sorts tags by a specified sequence according to tag name. */
package/package.json CHANGED
@@ -172,5 +172,5 @@
172
172
  "test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
173
173
  "test-index": "pnpm run test-no-cov test/rules/index.js"
174
174
  },
175
- "version": "57.2.1"
175
+ "version": "58.1.0"
176
176
  }
@@ -0,0 +1,472 @@
1
+ import iterateJsdoc from './iterateJsdoc.js';
2
+ import {
3
+ parse,
4
+ stringify,
5
+ traverse,
6
+ tryParse,
7
+ } from '@es-joy/jsdoccomment';
8
+
9
+ /**
10
+ * Adjusts the parent type node `meta` for generic matches (or type node
11
+ * `type` for `JsdocTypeAny`) and sets the type node `value`.
12
+ * @param {string} type The actual type
13
+ * @param {string} preferred The preferred type
14
+ * @param {boolean} isGenericMatch
15
+ * @param {string} typeNodeName
16
+ * @param {import('jsdoc-type-pratt-parser').NonRootResult} node
17
+ * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode
18
+ * @returns {void}
19
+ */
20
+ const adjustNames = (type, preferred, isGenericMatch, typeNodeName, node, parentNode) => {
21
+ let ret = preferred;
22
+ if (isGenericMatch) {
23
+ const parentMeta = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (
24
+ parentNode
25
+ ).meta;
26
+ if (preferred === '[]') {
27
+ parentMeta.brackets = 'square';
28
+ parentMeta.dot = false;
29
+ ret = 'Array';
30
+ } else {
31
+ const dotBracketEnd = preferred.match(/\.(?:<>)?$/v);
32
+ if (dotBracketEnd) {
33
+ parentMeta.brackets = 'angle';
34
+ parentMeta.dot = true;
35
+ ret = preferred.slice(0, -dotBracketEnd[0].length);
36
+ } else {
37
+ const bracketEnd = preferred.endsWith('<>');
38
+ if (bracketEnd) {
39
+ parentMeta.brackets = 'angle';
40
+ parentMeta.dot = false;
41
+ ret = preferred.slice(0, -2);
42
+ } else if (
43
+ parentMeta?.brackets === 'square' &&
44
+ (typeNodeName === '[]' || typeNodeName === 'Array')
45
+ ) {
46
+ parentMeta.brackets = 'angle';
47
+ parentMeta.dot = false;
48
+ }
49
+ }
50
+ }
51
+ } else if (type === 'JsdocTypeAny') {
52
+ node.type = 'JsdocTypeName';
53
+ }
54
+
55
+ /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (
56
+ node
57
+ ).value = ret.replace(/(?:\.|<>|\.<>|\[\])$/v, '');
58
+
59
+ // For bare pseudo-types like `<>`
60
+ if (!ret) {
61
+ /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (
62
+ node
63
+ ).value = typeNodeName;
64
+ }
65
+ };
66
+
67
+ /**
68
+ * @param {boolean} [upperCase]
69
+ * @returns {string}
70
+ */
71
+ const getMessage = (upperCase) => {
72
+ return 'Use object shorthand or index signatures instead of ' +
73
+ '`' + (upperCase ? 'O' : 'o') + 'bject`, e.g., `{[key: string]: string}`';
74
+ };
75
+
76
+ /**
77
+ * @type {{
78
+ * message: string,
79
+ * replacement: false
80
+ * }}
81
+ */
82
+ const info = {
83
+ message: getMessage(),
84
+ replacement: false,
85
+ };
86
+
87
+ /**
88
+ * @type {{
89
+ * message: string,
90
+ * replacement: false
91
+ * }}
92
+ */
93
+ const infoUC = {
94
+ message: getMessage(true),
95
+ replacement: false,
96
+ };
97
+
98
+ /**
99
+ * @param {{
100
+ * checkNativeTypes?: import('./rules/checkTypes.js').CheckNativeTypes|null
101
+ * overrideSettings?: import('./iterateJsdoc.js').Settings['preferredTypes']|null,
102
+ * description?: string,
103
+ * schema?: import('eslint').Rule.RuleMetaData['schema'],
104
+ * typeName?: string,
105
+ * url?: string,
106
+ * }} cfg
107
+ * @returns {import('@eslint/core').RuleDefinition<
108
+ * import('@eslint/core').RuleDefinitionTypeOptions
109
+ * >}
110
+ */
111
+ export const buildRejectOrPreferRuleDefinition = ({
112
+ checkNativeTypes = null,
113
+ typeName,
114
+ description = typeName ?? 'Reports invalid types.',
115
+ overrideSettings = null,
116
+ schema = [],
117
+ url = 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-types.md#repos-sticky-header',
118
+ }) => {
119
+ return iterateJsdoc(
120
+ ({
121
+ context,
122
+ jsdocNode,
123
+ report,
124
+ settings,
125
+ sourceCode,
126
+ utils,
127
+ }) => {
128
+ const jsdocTagsWithPossibleType = utils.filterTags((tag) => {
129
+ return Boolean(utils.tagMightHaveTypePosition(tag.tag));
130
+ });
131
+
132
+ const
133
+ /**
134
+ * @type {{
135
+ * preferredTypes: import('./iterateJsdoc.js').PreferredTypes,
136
+ * structuredTags: import('./iterateJsdoc.js').StructuredTags,
137
+ * mode: import('./jsdocUtils.js').ParserMode
138
+ * }}
139
+ */
140
+ {
141
+ mode,
142
+ preferredTypes: preferredTypesOriginal,
143
+ structuredTags,
144
+ } = overrideSettings ? {
145
+ mode: settings.mode,
146
+ preferredTypes: overrideSettings,
147
+ structuredTags: {},
148
+ } : settings;
149
+
150
+ const injectObjectPreferredTypes = !('Object' in preferredTypesOriginal ||
151
+ 'object' in preferredTypesOriginal ||
152
+ 'object.<>' in preferredTypesOriginal ||
153
+ 'Object.<>' in preferredTypesOriginal ||
154
+ 'object<>' in preferredTypesOriginal);
155
+
156
+ /** @type {import('./iterateJsdoc.js').PreferredTypes} */
157
+ const typeToInject = mode === 'typescript' ?
158
+ {
159
+ Object: 'object',
160
+ 'object.<>': info,
161
+ 'Object.<>': infoUC,
162
+ 'object<>': info,
163
+ 'Object<>': infoUC,
164
+ } :
165
+ {
166
+ Object: 'object',
167
+ 'object.<>': 'Object<>',
168
+ 'Object.<>': 'Object<>',
169
+ 'object<>': 'Object<>',
170
+ };
171
+
172
+ /** @type {import('./iterateJsdoc.js').PreferredTypes} */
173
+ const preferredTypes = {
174
+ ...injectObjectPreferredTypes ?
175
+ typeToInject :
176
+ {},
177
+ ...preferredTypesOriginal,
178
+ };
179
+
180
+ const
181
+ /**
182
+ * @type {{
183
+ * noDefaults: boolean,
184
+ * unifyParentAndChildTypeChecks: boolean,
185
+ * exemptTagContexts: ({
186
+ * tag: string,
187
+ * types: true|string[]
188
+ * })[]
189
+ * }}
190
+ */ {
191
+ exemptTagContexts = [],
192
+ noDefaults,
193
+ unifyParentAndChildTypeChecks,
194
+ } = context.options[0] || {};
195
+
196
+ /**
197
+ * Gets information about the preferred type: whether there is a matching
198
+ * preferred type, what the type is, and whether it is a match to a generic.
199
+ * @param {string} _type Not currently in use
200
+ * @param {string} typeNodeName
201
+ * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode
202
+ * @param {string|undefined} property
203
+ * @returns {[hasMatchingPreferredType: boolean, typeName: string, isGenericMatch: boolean]}
204
+ */
205
+ const getPreferredTypeInfo = (_type, typeNodeName, parentNode, property) => {
206
+ let hasMatchingPreferredType = false;
207
+ let isGenericMatch = false;
208
+ let typName = typeNodeName;
209
+
210
+ const isNameOfGeneric = parentNode !== undefined && parentNode.type === 'JsdocTypeGeneric' && property === 'left';
211
+
212
+ const brackets = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (
213
+ parentNode
214
+ )?.meta?.brackets;
215
+ const dot = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (
216
+ parentNode
217
+ )?.meta?.dot;
218
+
219
+ if (brackets === 'angle') {
220
+ const checkPostFixes = dot ? [
221
+ '.', '.<>',
222
+ ] : [
223
+ '<>',
224
+ ];
225
+ isGenericMatch = checkPostFixes.some((checkPostFix) => {
226
+ const preferredType = preferredTypes?.[typeNodeName + checkPostFix];
227
+
228
+ // Does `unifyParentAndChildTypeChecks` need to be checked here?
229
+ if (
230
+ (unifyParentAndChildTypeChecks || isNameOfGeneric ||
231
+ /* c8 ignore next 2 -- If checking `unifyParentAndChildTypeChecks` */
232
+ (typeof preferredType === 'object' &&
233
+ preferredType?.unifyParentAndChildTypeChecks)
234
+ ) &&
235
+ preferredType !== undefined
236
+ ) {
237
+ typName += checkPostFix;
238
+
239
+ return true;
240
+ }
241
+
242
+ return false;
243
+ });
244
+ }
245
+
246
+ if (
247
+ !isGenericMatch && property &&
248
+ /** @type {import('jsdoc-type-pratt-parser').NonRootResult} */ (
249
+ parentNode
250
+ ).type === 'JsdocTypeGeneric'
251
+ ) {
252
+ const checkPostFixes = dot ? [
253
+ '.', '.<>',
254
+ ] : [
255
+ brackets === 'angle' ? '<>' : '[]',
256
+ ];
257
+
258
+ isGenericMatch = checkPostFixes.some((checkPostFix) => {
259
+ const preferredType = preferredTypes?.[checkPostFix];
260
+ if (
261
+ // Does `unifyParentAndChildTypeChecks` need to be checked here?
262
+ (unifyParentAndChildTypeChecks || isNameOfGeneric ||
263
+ /* c8 ignore next 2 -- If checking `unifyParentAndChildTypeChecks` */
264
+ (typeof preferredType === 'object' &&
265
+ preferredType?.unifyParentAndChildTypeChecks)) &&
266
+ preferredType !== undefined
267
+ ) {
268
+ typName = checkPostFix;
269
+
270
+ return true;
271
+ }
272
+
273
+ return false;
274
+ });
275
+ }
276
+
277
+ const prefType = preferredTypes?.[typeNodeName];
278
+ const directNameMatch = prefType !== undefined &&
279
+ !Object.values(preferredTypes).includes(typeNodeName);
280
+ const specificUnify = typeof prefType === 'object' &&
281
+ prefType?.unifyParentAndChildTypeChecks;
282
+ const unifiedSyntaxParentMatch = property && directNameMatch && (unifyParentAndChildTypeChecks || specificUnify);
283
+ isGenericMatch = isGenericMatch || Boolean(unifiedSyntaxParentMatch);
284
+
285
+ hasMatchingPreferredType = isGenericMatch ||
286
+ directNameMatch && !property;
287
+
288
+ return [
289
+ hasMatchingPreferredType, typName, isGenericMatch,
290
+ ];
291
+ };
292
+
293
+ /**
294
+ * Collect invalid type info.
295
+ * @param {string} type
296
+ * @param {string} value
297
+ * @param {string} tagName
298
+ * @param {string} nameInTag
299
+ * @param {number} idx
300
+ * @param {string|undefined} property
301
+ * @param {import('jsdoc-type-pratt-parser').NonRootResult} node
302
+ * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode
303
+ * @param {(string|false|undefined)[][]} invalidTypes
304
+ * @returns {void}
305
+ */
306
+ const getInvalidTypes = (type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes) => {
307
+ let typeNodeName = type === 'JsdocTypeAny' ? '*' : value;
308
+
309
+ const [
310
+ hasMatchingPreferredType,
311
+ typName,
312
+ isGenericMatch,
313
+ ] = getPreferredTypeInfo(type, typeNodeName, parentNode, property);
314
+
315
+ let preferred;
316
+ let types;
317
+ if (hasMatchingPreferredType) {
318
+ const preferredSetting = preferredTypes[typName];
319
+ typeNodeName = typName === '[]' ? typName : typeNodeName;
320
+
321
+ if (!preferredSetting) {
322
+ invalidTypes.push([
323
+ typeNodeName,
324
+ ]);
325
+ } else if (typeof preferredSetting === 'string') {
326
+ preferred = preferredSetting;
327
+ invalidTypes.push([
328
+ typeNodeName, preferred,
329
+ ]);
330
+ } else if (preferredSetting && typeof preferredSetting === 'object') {
331
+ const nextItem = preferredSetting.skipRootChecking && jsdocTagsWithPossibleType[idx + 1];
332
+
333
+ if (!nextItem || !nextItem.name.startsWith(`${nameInTag}.`)) {
334
+ preferred = preferredSetting.replacement;
335
+ invalidTypes.push([
336
+ typeNodeName,
337
+ preferred,
338
+ preferredSetting.message,
339
+ ]);
340
+ }
341
+ } else {
342
+ utils.reportSettings(
343
+ 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.',
344
+ );
345
+
346
+ return;
347
+ }
348
+ } else if (Object.entries(structuredTags).some(([
349
+ tag,
350
+ {
351
+ type: typs,
352
+ },
353
+ ]) => {
354
+ types = typs;
355
+
356
+ return tag === tagName &&
357
+ Array.isArray(types) &&
358
+ !types.includes(typeNodeName);
359
+ })) {
360
+ invalidTypes.push([
361
+ typeNodeName, types,
362
+ ]);
363
+ } else if (checkNativeTypes && !noDefaults && type === 'JsdocTypeName') {
364
+ preferred = checkNativeTypes(
365
+ preferredTypes, typeNodeName, preferred, parentNode, invalidTypes,
366
+ );
367
+ }
368
+
369
+ // For fixer
370
+ if (preferred) {
371
+ adjustNames(type, preferred, isGenericMatch, typeNodeName, node, parentNode);
372
+ }
373
+ };
374
+
375
+ for (const [
376
+ idx,
377
+ jsdocTag,
378
+ ] of jsdocTagsWithPossibleType.entries()) {
379
+ /** @type {(string|false|undefined)[][]} */
380
+ const invalidTypes = [];
381
+ let typeAst;
382
+
383
+ try {
384
+ typeAst = mode === 'permissive' ? tryParse(jsdocTag.type) : parse(jsdocTag.type, mode);
385
+ } catch {
386
+ continue;
387
+ }
388
+
389
+ const {
390
+ name: nameInTag,
391
+ tag: tagName,
392
+ } = jsdocTag;
393
+
394
+ traverse(typeAst, (node, parentNode, property) => {
395
+ const {
396
+ type,
397
+ value,
398
+ } =
399
+ /**
400
+ * @type {import('jsdoc-type-pratt-parser').NameResult}
401
+ */ (node);
402
+ if (![
403
+ 'JsdocTypeAny', 'JsdocTypeName',
404
+ ].includes(type)) {
405
+ return;
406
+ }
407
+
408
+ getInvalidTypes(type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes);
409
+ });
410
+
411
+ if (invalidTypes.length) {
412
+ const fixedType = stringify(typeAst);
413
+
414
+ /**
415
+ * @type {import('eslint').Rule.ReportFixer}
416
+ */
417
+ const fix = (fixer) => {
418
+ return fixer.replaceText(
419
+ jsdocNode,
420
+ sourceCode.getText(jsdocNode).replace(
421
+ `{${jsdocTag.type}}`,
422
+ `{${fixedType}}`,
423
+ ),
424
+ );
425
+ };
426
+
427
+ for (const [
428
+ badType,
429
+ preferredType = '',
430
+ msg,
431
+ ] of invalidTypes) {
432
+ const tagValue = jsdocTag.name ? ` "${jsdocTag.name}"` : '';
433
+ if (exemptTagContexts.some(({
434
+ tag,
435
+ types,
436
+ }) => {
437
+ return tag === tagName &&
438
+ (types === true || types.includes(jsdocTag.type));
439
+ })) {
440
+ continue;
441
+ }
442
+
443
+ report(
444
+ msg ||
445
+ `Invalid JSDoc @${tagName}${tagValue} type "${badType}"` +
446
+ (preferredType ? '; ' : '.') +
447
+ (preferredType ? `prefer: ${JSON.stringify(preferredType)}.` : ''),
448
+ preferredType ? fix : null,
449
+ jsdocTag,
450
+ msg ? {
451
+ tagName,
452
+ tagValue,
453
+ } : undefined,
454
+ );
455
+ }
456
+ }
457
+ }
458
+ },
459
+ {
460
+ iterateAllJsdocs: true,
461
+ meta: {
462
+ docs: {
463
+ description,
464
+ url,
465
+ },
466
+ fixable: 'code',
467
+ schema,
468
+ type: 'suggestion',
469
+ },
470
+ },
471
+ );
472
+ };