eslint-plugin-jsdoc 63.0.9 → 63.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WarnSettings.cjs +1 -8
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/alignTransform.cjs +6 -10
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/buildForbidRuleDefinition.cjs +3 -10
- package/dist/buildForbidRuleDefinition.cjs.map +1 -1
- package/dist/buildRejectOrPreferRuleDefinition.cjs +7 -14
- package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -1
- package/dist/defaultTagOrder.cjs +1 -8
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/exportParser.cjs +6 -14
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateDocs.cjs +36 -44
- package/dist/generateDocs.cjs.map +1 -1
- package/dist/generateOptions.cjs +15 -18
- package/dist/generateOptions.cjs.map +1 -1
- package/dist/generateRule.cjs +24 -24
- package/dist/generateRule.cjs.map +1 -1
- package/dist/generateRuleTypes.cjs +6 -9
- package/dist/generateRuleTypes.cjs.map +1 -1
- package/dist/getDefaultTagStructureForMode.cjs +1 -8
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +20 -28
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/index-cjs.cjs +152 -159
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index-esm.cjs +16 -27
- package/dist/index-esm.cjs.map +1 -1
- package/dist/index.cjs +159 -172
- package/dist/index.cjs.map +1 -1
- package/dist/iterateJsdoc.cjs +22 -32
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/jsdocUtils.cjs +18 -86
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkAccess.cjs +2 -10
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +2 -10
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +6 -15
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +2 -9
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +6 -14
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +2 -9
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +2 -9
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkSyntax.cjs +2 -10
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +4 -11
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +12 -21
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +4 -10
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +9 -17
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +13 -19
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +2 -10
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/escapeInlineTags.cjs +96 -42
- package/dist/rules/escapeInlineTags.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.cjs +2 -10
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.cjs +12 -20
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +4 -12
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +2 -9
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +2 -9
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +2 -10
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +2 -9
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +4 -11
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +2 -10
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.cjs +2 -10
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noDefaults.cjs +2 -10
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +2 -9
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +2 -10
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +2 -9
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +2 -9
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +13 -21
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/preferImportTag.cjs +21 -28
- package/dist/rules/preferImportTag.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +2 -10
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +2 -9
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +7 -15
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireExample.cjs +2 -10
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +2 -10
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +2 -10
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +17 -25
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +2 -9
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamDescription.cjs +2 -10
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +2 -10
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamType.cjs +2 -10
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireProperty.cjs +2 -10
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.cjs +2 -10
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyName.cjs +2 -10
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyType.cjs +2 -10
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requireRejects.cjs +2 -9
- package/dist/rules/requireRejects.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +4 -11
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +8 -15
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +2 -10
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsType.cjs +2 -10
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireTags.cjs +2 -9
- package/dist/rules/requireTags.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +5 -13
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireThrows.cjs +2 -9
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +2 -9
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +2 -9
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +4 -12
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +2 -9
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +2 -9
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/tsMethodSignatureStyle.cjs +10 -18
- package/dist/rules/tsMethodSignatureStyle.cjs.map +1 -1
- package/dist/rules/tsNoEmptyObjectType.cjs +5 -13
- package/dist/rules/tsNoEmptyObjectType.cjs.map +1 -1
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +8 -16
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +1 -1
- package/dist/rules/tsPreferFunctionType.cjs +8 -16
- package/dist/rules/tsPreferFunctionType.cjs.map +1 -1
- package/dist/rules/typeFormatting.cjs +9 -17
- package/dist/rules/typeFormatting.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +10 -18
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/tagNames.cjs +4 -9
- package/dist/tagNames.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +1 -8
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/package.json +21 -21
- package/src/rules/checkTemplateNames.js +0 -1
- package/src/rules/escapeInlineTags.js +142 -45
- package/src/rules/requireJsdoc.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkParamNames.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","validateParameterNames","targetTagName","allowExtraTrailingParamDocs","checkDestructured","checkRestProperty","checkTypesRegex","disableExtraPropertyReporting","disableMissingParamChecks","enableFixer","functionParameterNames","jsdoc","utils","report","paramTags","Object","entries","tags","filter","tag","paramTagsNonNested","name","includes","dotted","thisOffset","some","index","tagsIndex","dupeTagInfo","find","tgsIndex","tg","idx","Number","reportJSDoc","removeTag","functionParameterName","trim","Array","isArray","actualName","expectedName","type","search","parameterName","annotationParamName","hasPropertyRest","names","properties","rests","undefined","tagName","expectedNames","map","actualNames","paramTag","actualTypes","missingProperties","notCheckingNames","notCheckingName","startsWith","actualNameIdx","findIndex","comparePaths","missingIndex","pathDoesNotBeginWith","line","source","number","length","push","tagPlacement","hasMissing","missingProperty","extraProperties","match","prop","split","extraProperty","funcParamName","item","usedExpectedNames","a","toString","usedInOrder","every","restElement","join","validateParameterNamesDeep","_allowExtraTrailingParamDocs","jsdocParameterNames","lastRealParameter","jsdocParameterName","isPropertyPath","pathRootNodeName","slice","indexOf","endsWith","allowedNodes","_default","exports","iterateJsdoc","context","node","checkTypesPattern","useDefaultObjectProperties","options","nde","typeAnnotation","getRegexFromString","jsdocParameterNamesDeep","getJsdocTagsDeep","getFunctionParameterNames","getPreferredTagName","isError","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","module"],"sources":["../../src/rules/checkParamNames.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {string} targetTagName\n * @param {boolean} allowExtraTrailingParamDocs\n * @param {boolean} checkDestructured\n * @param {boolean} checkRestProperty\n * @param {RegExp} checkTypesRegex\n * @param {boolean} disableExtraPropertyReporting\n * @param {boolean} disableMissingParamChecks\n * @param {boolean} enableFixer\n * @param {import('../jsdocUtils.js').ParamNameInfo[]} functionParameterNames\n * @param {import('comment-parser').Block} jsdoc\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Report} report\n * @returns {boolean}\n */\nconst validateParameterNames = (\n targetTagName,\n allowExtraTrailingParamDocs,\n checkDestructured,\n checkRestProperty,\n checkTypesRegex,\n disableExtraPropertyReporting,\n disableMissingParamChecks,\n enableFixer,\n functionParameterNames, jsdoc, utils, report,\n) => {\n const paramTags = Object.entries(jsdoc.tags).filter(([\n , tag,\n ]) => {\n return tag.tag === targetTagName;\n });\n const paramTagsNonNested = paramTags.filter(([\n , tag,\n ]) => {\n return !tag.name.includes('.');\n });\n\n let dotted = 0;\n let thisOffset = 0;\n\n return paramTags.some(([\n , tag,\n // eslint-disable-next-line complexity\n ], index) => {\n /** @type {import('../iterateJsdoc.js').Integer} */\n let tagsIndex;\n const dupeTagInfo = paramTags.find(([\n tgsIndex,\n tg,\n ], idx) => {\n tagsIndex = Number(tgsIndex);\n\n return tg.name === tag.name && idx !== index;\n });\n if (dupeTagInfo) {\n utils.reportJSDoc(`Duplicate @${targetTagName} \"${tag.name}\"`, dupeTagInfo[1], enableFixer ? () => {\n utils.removeTag(tagsIndex);\n } : null);\n\n return true;\n }\n\n if (tag.name.includes('.')) {\n dotted++;\n\n return false;\n }\n\n let functionParameterName = functionParameterNames[index - dotted + thisOffset];\n if (functionParameterName === 'this' && tag.name.trim() !== 'this') {\n ++thisOffset;\n functionParameterName = functionParameterNames[index - dotted + thisOffset];\n }\n\n if (!functionParameterName) {\n if (allowExtraTrailingParamDocs) {\n return false;\n }\n\n report(\n `@${targetTagName} \"${tag.name}\" does not match an existing function parameter.`,\n null,\n tag,\n );\n\n return true;\n }\n\n if (\n typeof functionParameterName === 'object' &&\n 'name' in functionParameterName &&\n Array.isArray(functionParameterName.name)\n ) {\n const actualName = tag.name.trim();\n const expectedName = functionParameterName.name[index];\n if (actualName === expectedName) {\n thisOffset--;\n return false;\n }\n\n report(\n `Expected @${targetTagName} name to be \"${expectedName}\". Got \"${actualName}\".`,\n null,\n tag,\n );\n return true;\n }\n\n if (Array.isArray(functionParameterName)) {\n if (!checkDestructured) {\n return false;\n }\n\n if (tag.type && tag.type.search(checkTypesRegex) === -1) {\n return false;\n }\n\n const [\n parameterName,\n {\n annotationParamName,\n hasPropertyRest,\n names: properties,\n rests,\n },\n ] =\n /**\n * @type {[string | undefined, import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string | undefined;\n }]} */ (functionParameterName);\n if (annotationParamName !== undefined) {\n const name = tag.name.trim();\n if (name !== annotationParamName) {\n report(`@${targetTagName} \"${name}\" does not match parameter name \"${annotationParamName}\"`, null, tag);\n }\n }\n\n const tagName = parameterName === undefined ? tag.name.trim() : parameterName;\n const expectedNames = properties.map((name) => {\n return `${tagName}.${name}`;\n });\n const actualNames = paramTags.map(([\n , paramTag,\n ]) => {\n return paramTag.name.trim();\n });\n const actualTypes = paramTags.map(([\n , paramTag,\n ]) => {\n return paramTag.type;\n });\n\n const missingProperties = [];\n\n /** @type {string[]} */\n const notCheckingNames = [];\n\n for (const [\n idx,\n name,\n ] of expectedNames.entries()) {\n if (notCheckingNames.some((notCheckingName) => {\n return name.startsWith(notCheckingName);\n })) {\n continue;\n }\n\n const actualNameIdx = actualNames.findIndex((actualName) => {\n return utils.comparePaths(name)(actualName);\n });\n if (actualNameIdx === -1) {\n if (!checkRestProperty && rests[idx]) {\n continue;\n }\n\n const missingIndex = actualNames.findIndex((actualName) => {\n return utils.pathDoesNotBeginWith(name, actualName);\n });\n const line = tag.source[0].number - 1 + (missingIndex > -1 ? missingIndex : actualNames.length);\n missingProperties.push({\n name,\n tagPlacement: {\n line: line === 0 ? 1 : line,\n },\n });\n } else if (actualTypes[actualNameIdx].search(checkTypesRegex) === -1 && actualTypes[actualNameIdx] !== '') {\n notCheckingNames.push(name);\n }\n }\n\n const hasMissing = missingProperties.length;\n if (hasMissing) {\n for (const {\n name: missingProperty,\n tagPlacement,\n } of missingProperties) {\n report(`Missing @${targetTagName} \"${missingProperty}\"`, null, tagPlacement);\n }\n }\n\n if (!hasPropertyRest || checkRestProperty) {\n /** @type {[string, import('comment-parser').Spec][]} */\n const extraProperties = [];\n for (const [\n idx,\n name,\n ] of actualNames.entries()) {\n const match = name.startsWith(tag.name.trim() + '.');\n if (\n match && !expectedNames.some(\n utils.comparePaths(name),\n ) && !utils.comparePaths(name)(tag.name) &&\n (!disableExtraPropertyReporting || properties.some((prop) => {\n return prop.split('.').length >= name.split('.').length - 1;\n }))\n ) {\n extraProperties.push([\n name, paramTags[idx][1],\n ]);\n }\n }\n\n if (extraProperties.length) {\n for (const [\n extraProperty,\n tg,\n ] of extraProperties) {\n report(`@${targetTagName} \"${extraProperty}\" does not exist on ${tag.name}`, null, tg);\n }\n\n return true;\n }\n }\n\n return hasMissing;\n }\n\n let funcParamName;\n if (typeof functionParameterName === 'object') {\n const {\n name,\n } = functionParameterName;\n funcParamName = name;\n } else {\n funcParamName = functionParameterName;\n }\n\n if (funcParamName !== tag.name.trim()) {\n // Todo: Improve for array or object child items\n const actualNames = paramTagsNonNested.map(([\n , {\n name,\n },\n ]) => {\n return name.trim();\n });\n\n const expectedNames = functionParameterNames.map((item, idx) => {\n if (/**\n * @type {[string|undefined, (import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string,\n })]} */ (item)?.[1]?.names) {\n return actualNames[idx];\n }\n\n return item;\n }).filter((item) => {\n return item !== 'this';\n });\n\n // When disableMissingParamChecks is true tag names can be omitted.\n // Report when the tag names do not match the expected names or they are used out of order.\n if (disableMissingParamChecks) {\n const usedExpectedNames = expectedNames.map((a) => {\n return a?.toString();\n }).filter((expectedName) => {\n return expectedName && actualNames.includes(expectedName);\n });\n const usedInOrder = actualNames.every((actualName, idx) => {\n return actualName === usedExpectedNames[idx];\n });\n if (usedInOrder) {\n return false;\n }\n }\n\n report(\n `Expected @${targetTagName} names to be \"${\n expectedNames.map((expectedName) => {\n return typeof expectedName === 'object' &&\n 'name' in expectedName &&\n expectedName.restElement ?\n '...' + expectedName.name :\n expectedName;\n }).join(', ')\n }\". Got \"${actualNames.join(', ')}\".`,\n null,\n tag,\n );\n\n return true;\n }\n\n return false;\n });\n};\n\n/**\n * @param {string} targetTagName\n * @param {boolean} _allowExtraTrailingParamDocs\n * @param {{\n * name: string,\n * idx: import('../iterateJsdoc.js').Integer\n * }[]} jsdocParameterNames\n * @param {import('comment-parser').Block} jsdoc\n * @param {import('../iterateJsdoc.js').Report} report\n * @returns {boolean}\n */\nconst validateParameterNamesDeep = (\n targetTagName, _allowExtraTrailingParamDocs,\n jsdocParameterNames, jsdoc, report,\n) => {\n /** @type {string} */\n let lastRealParameter;\n\n return jsdocParameterNames.some(({\n idx,\n name: jsdocParameterName,\n }) => {\n const isPropertyPath = jsdocParameterName.includes('.');\n\n if (isPropertyPath) {\n if (!lastRealParameter) {\n report(`@${targetTagName} path declaration (\"${jsdocParameterName}\") appears before any real parameter.`, null, jsdoc.tags[idx]);\n\n return true;\n }\n\n let pathRootNodeName = jsdocParameterName.slice(0, jsdocParameterName.indexOf('.'));\n\n if (pathRootNodeName.endsWith('[]')) {\n pathRootNodeName = pathRootNodeName.slice(0, -2);\n }\n\n if (pathRootNodeName !== lastRealParameter) {\n report(\n `@${targetTagName} path declaration (\"${jsdocParameterName}\") root node name (\"${pathRootNodeName}\") ` +\n `does not match previous real parameter name (\"${lastRealParameter}\").`,\n null,\n jsdoc.tags[idx],\n );\n\n return true;\n }\n } else {\n lastRealParameter = jsdocParameterName;\n }\n\n return false;\n });\n};\n\nconst allowedNodes = [\n 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',\n // Add this to above defaults\n 'TSMethodSignature', 'TSPropertySignature',\n];\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n node,\n report,\n utils,\n}) => {\n const {\n allowExtraTrailingParamDocs,\n checkDestructured = true,\n checkRestProperty = false,\n checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/',\n disableExtraPropertyReporting = false,\n disableMissingParamChecks = false,\n enableFixer = false,\n useDefaultObjectProperties = false,\n } = context.options[0] || {};\n\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (node);\n\n // Although we might just remove global settings contexts from applying to\n // this rule (as they can cause problems with `getFunctionParameterNames`\n // checks if they are not functions but say variables), the user may\n // instead wish to narrow contexts in those settings, so this check\n // is still useful\n if (!allowedNodes.includes(nde.type) ||\n nde.type === 'TSPropertySignature' &&\n (/** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ (\n nde\n )?.typeAnnotation?.typeAnnotation?.type !== 'TSFunctionType')) {\n return;\n }\n\n const checkTypesRegex = utils.getRegexFromString(checkTypesPattern);\n\n const jsdocParameterNamesDeep = utils.getJsdocTagsDeep('param');\n if (!jsdocParameterNamesDeep || !jsdocParameterNamesDeep.length) {\n return;\n }\n\n const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties);\n\n const targetTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'param',\n }));\n const isError = validateParameterNames(\n targetTagName,\n allowExtraTrailingParamDocs,\n checkDestructured,\n checkRestProperty,\n checkTypesRegex,\n disableExtraPropertyReporting,\n disableMissingParamChecks,\n enableFixer,\n functionParameterNames,\n jsdoc,\n utils,\n report,\n );\n\n if (isError || !checkDestructured) {\n return;\n }\n\n validateParameterNamesDeep(\n targetTagName, allowExtraTrailingParamDocs, jsdocParameterNamesDeep, jsdoc, report,\n );\n}, {\n contextDefaults: allowedNodes,\n meta: {\n docs: {\n description: 'Checks for dupe `@param` names, that nested param names have roots, and that parameter names in function declarations match JSDoc param names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-param-names.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowExtraTrailingParamDocs: {\n description: `If set to \\`true\\`, this option will allow extra \\`@param\\` definitions (e.g.,\nrepresenting future expected or virtual params) to be present without needing\ntheir presence within the function signature. Other inconsistencies between\n\\`@param\\`'s and present function parameters will still be reported.`,\n type: 'boolean',\n },\n checkDestructured: {\n description: 'Whether to check destructured properties. Defaults to `true`.',\n type: 'boolean',\n },\n checkRestProperty: {\n description: `If set to \\`true\\`, will require that rest properties are documented and\nthat any extraneous properties (which may have been within the rest property)\nare documented. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n checkTypesPattern: {\n description: `Defines a regular expression pattern to indicate which types should be\nchecked for destructured content (and that those not matched should not\nbe checked).\n\nWhen one specifies a type, unless it is of a generic type, like \\`object\\`\nor \\`array\\`, it may be considered unnecessary to have that object's\ndestructured components required, especially where generated docs will\nlink back to the specified type. For example:\n\n\\`\\`\\`js\n/**\n * @param {SVGRect} bbox - a SVGRect\n */\nexport const bboxToObj = function ({x, y, width, height}) {\n return {x, y, width, height};\n};\n\\`\\`\\`\n\nBy default \\`checkTypesPattern\\` is set to\n\\`/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/v\\`,\nmeaning that destructuring will be required only if the type of the \\`@param\\`\n(the text between curly brackets) is a match for \"Object\" or \"Array\" (with or\nwithout initial caps), \"PlainObject\", or \"GenericObject\", \"GenericArray\" (or\nif no type is present). So in the above example, the lack of a match will\nmean that no complaint will be given about the undocumented destructured\nparameters.\n\nNote that the \\`/\\` delimiters are optional, but necessary to add flags.\n\nDefaults to using (only) the \\`v\\` flag, so to add your own flags, encapsulate\nyour expression as a string, but like a literal, e.g., \\`/^object$/vi\\`.\n\nYou could set this regular expression to a more expansive list, or you\ncould restrict it such that even types matching those strings would not\nneed destructuring.`,\n type: 'string',\n },\n disableExtraPropertyReporting: {\n description: `Whether to check for extra destructured properties. Defaults to \\`false\\`. Change\nto \\`true\\` if you want to be able to document properties which are not actually\ndestructured. Keep as \\`false\\` if you expect properties to be documented in\ntheir own types. Note that extra properties will always be reported if another\nitem at the same level is destructured as destructuring will prevent other\naccess and this option is only intended to permit documenting extra properties\nthat are available and actually used in the function.`,\n type: 'boolean',\n },\n disableMissingParamChecks: {\n description: 'Whether to avoid checks for missing `@param` definitions. Defaults to `false`. Change to `true` if you want to be able to omit properties.',\n type: 'boolean',\n },\n enableFixer: {\n description: `Set to \\`true\\` to auto-remove \\`@param\\` duplicates (based on identical\nnames).\n\nNote that this option will remove duplicates of the same name even if\nthe definitions do not match in other ways (e.g., the second param will\nbe removed even if it has a different type or description).`,\n type: 'boolean',\n },\n useDefaultObjectProperties: {\n description: `Set to \\`true\\` if you wish to avoid reporting of child property documentation\nwhere instead of destructuring, a whole plain object is supplied as default\nvalue but you wish its keys to be considered as signalling that the properties\nare present and can therefore be documented. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAA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EAAE;QACV7C,2BAA2B,EAAE;UAC3BmH,WAAW,EAAE;AACzB;AACA;AACA,qEAAqE;UACzD5E,IAAI,EAAE;QACR,CAAC;QACDtC,iBAAiB,EAAE;UACjBkH,WAAW,EAAE,+DAA+D;UAC5E5E,IAAI,EAAE;QACR,CAAC;QACDrC,iBAAiB,EAAE;UACjBiH,WAAW,EAAE;AACzB;AACA,uCAAuC;UAC3B5E,IAAI,EAAE;QACR,CAAC;QACD8D,iBAAiB,EAAE;UACjBc,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;UACR5E,IAAI,EAAE;QACR,CAAC;QACDnC,6BAA6B,EAAE;UAC7B+G,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA,sDAAsD;UAC1C5E,IAAI,EAAE;QACR,CAAC;QACDlC,yBAAyB,EAAE;UACzB8G,WAAW,EAAE,4IAA4I;UACzJ5E,IAAI,EAAE;QACR,CAAC;QACDjC,WAAW,EAAE;UACX6G,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA,4DAA4D;UAChD5E,IAAI,EAAE;QACR,CAAC;QACD+D,0BAA0B,EAAE;UAC1Ba,WAAW,EAAE;AACzB;AACA;AACA,oEAAoE;UACxD5E,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAiF,MAAA,CAAAvB,OAAA,GAAAA,OAAA,CAAApG,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"checkParamNames.cjs","names":[],"sources":["../../src/rules/checkParamNames.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {string} targetTagName\n * @param {boolean} allowExtraTrailingParamDocs\n * @param {boolean} checkDestructured\n * @param {boolean} checkRestProperty\n * @param {RegExp} checkTypesRegex\n * @param {boolean} disableExtraPropertyReporting\n * @param {boolean} disableMissingParamChecks\n * @param {boolean} enableFixer\n * @param {import('../jsdocUtils.js').ParamNameInfo[]} functionParameterNames\n * @param {import('comment-parser').Block} jsdoc\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Report} report\n * @returns {boolean}\n */\nconst validateParameterNames = (\n targetTagName,\n allowExtraTrailingParamDocs,\n checkDestructured,\n checkRestProperty,\n checkTypesRegex,\n disableExtraPropertyReporting,\n disableMissingParamChecks,\n enableFixer,\n functionParameterNames, jsdoc, utils, report,\n) => {\n const paramTags = Object.entries(jsdoc.tags).filter(([\n , tag,\n ]) => {\n return tag.tag === targetTagName;\n });\n const paramTagsNonNested = paramTags.filter(([\n , tag,\n ]) => {\n return !tag.name.includes('.');\n });\n\n let dotted = 0;\n let thisOffset = 0;\n\n return paramTags.some(([\n , tag,\n // eslint-disable-next-line complexity\n ], index) => {\n /** @type {import('../iterateJsdoc.js').Integer} */\n let tagsIndex;\n const dupeTagInfo = paramTags.find(([\n tgsIndex,\n tg,\n ], idx) => {\n tagsIndex = Number(tgsIndex);\n\n return tg.name === tag.name && idx !== index;\n });\n if (dupeTagInfo) {\n utils.reportJSDoc(`Duplicate @${targetTagName} \"${tag.name}\"`, dupeTagInfo[1], enableFixer ? () => {\n utils.removeTag(tagsIndex);\n } : null);\n\n return true;\n }\n\n if (tag.name.includes('.')) {\n dotted++;\n\n return false;\n }\n\n let functionParameterName = functionParameterNames[index - dotted + thisOffset];\n if (functionParameterName === 'this' && tag.name.trim() !== 'this') {\n ++thisOffset;\n functionParameterName = functionParameterNames[index - dotted + thisOffset];\n }\n\n if (!functionParameterName) {\n if (allowExtraTrailingParamDocs) {\n return false;\n }\n\n report(\n `@${targetTagName} \"${tag.name}\" does not match an existing function parameter.`,\n null,\n tag,\n );\n\n return true;\n }\n\n if (\n typeof functionParameterName === 'object' &&\n 'name' in functionParameterName &&\n Array.isArray(functionParameterName.name)\n ) {\n const actualName = tag.name.trim();\n const expectedName = functionParameterName.name[index];\n if (actualName === expectedName) {\n thisOffset--;\n return false;\n }\n\n report(\n `Expected @${targetTagName} name to be \"${expectedName}\". Got \"${actualName}\".`,\n null,\n tag,\n );\n return true;\n }\n\n if (Array.isArray(functionParameterName)) {\n if (!checkDestructured) {\n return false;\n }\n\n if (tag.type && tag.type.search(checkTypesRegex) === -1) {\n return false;\n }\n\n const [\n parameterName,\n {\n annotationParamName,\n hasPropertyRest,\n names: properties,\n rests,\n },\n ] =\n /**\n * @type {[string | undefined, import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string | undefined;\n }]} */ (functionParameterName);\n if (annotationParamName !== undefined) {\n const name = tag.name.trim();\n if (name !== annotationParamName) {\n report(`@${targetTagName} \"${name}\" does not match parameter name \"${annotationParamName}\"`, null, tag);\n }\n }\n\n const tagName = parameterName === undefined ? tag.name.trim() : parameterName;\n const expectedNames = properties.map((name) => {\n return `${tagName}.${name}`;\n });\n const actualNames = paramTags.map(([\n , paramTag,\n ]) => {\n return paramTag.name.trim();\n });\n const actualTypes = paramTags.map(([\n , paramTag,\n ]) => {\n return paramTag.type;\n });\n\n const missingProperties = [];\n\n /** @type {string[]} */\n const notCheckingNames = [];\n\n for (const [\n idx,\n name,\n ] of expectedNames.entries()) {\n if (notCheckingNames.some((notCheckingName) => {\n return name.startsWith(notCheckingName);\n })) {\n continue;\n }\n\n const actualNameIdx = actualNames.findIndex((actualName) => {\n return utils.comparePaths(name)(actualName);\n });\n if (actualNameIdx === -1) {\n if (!checkRestProperty && rests[idx]) {\n continue;\n }\n\n const missingIndex = actualNames.findIndex((actualName) => {\n return utils.pathDoesNotBeginWith(name, actualName);\n });\n const line = tag.source[0].number - 1 + (missingIndex > -1 ? missingIndex : actualNames.length);\n missingProperties.push({\n name,\n tagPlacement: {\n line: line === 0 ? 1 : line,\n },\n });\n } else if (actualTypes[actualNameIdx].search(checkTypesRegex) === -1 && actualTypes[actualNameIdx] !== '') {\n notCheckingNames.push(name);\n }\n }\n\n const hasMissing = missingProperties.length;\n if (hasMissing) {\n for (const {\n name: missingProperty,\n tagPlacement,\n } of missingProperties) {\n report(`Missing @${targetTagName} \"${missingProperty}\"`, null, tagPlacement);\n }\n }\n\n if (!hasPropertyRest || checkRestProperty) {\n /** @type {[string, import('comment-parser').Spec][]} */\n const extraProperties = [];\n for (const [\n idx,\n name,\n ] of actualNames.entries()) {\n const match = name.startsWith(tag.name.trim() + '.');\n if (\n match && !expectedNames.some(\n utils.comparePaths(name),\n ) && !utils.comparePaths(name)(tag.name) &&\n (!disableExtraPropertyReporting || properties.some((prop) => {\n return prop.split('.').length >= name.split('.').length - 1;\n }))\n ) {\n extraProperties.push([\n name, paramTags[idx][1],\n ]);\n }\n }\n\n if (extraProperties.length) {\n for (const [\n extraProperty,\n tg,\n ] of extraProperties) {\n report(`@${targetTagName} \"${extraProperty}\" does not exist on ${tag.name}`, null, tg);\n }\n\n return true;\n }\n }\n\n return hasMissing;\n }\n\n let funcParamName;\n if (typeof functionParameterName === 'object') {\n const {\n name,\n } = functionParameterName;\n funcParamName = name;\n } else {\n funcParamName = functionParameterName;\n }\n\n if (funcParamName !== tag.name.trim()) {\n // Todo: Improve for array or object child items\n const actualNames = paramTagsNonNested.map(([\n , {\n name,\n },\n ]) => {\n return name.trim();\n });\n\n const expectedNames = functionParameterNames.map((item, idx) => {\n if (/**\n * @type {[string|undefined, (import('../jsdocUtils.js').FlattendRootInfo & {\n * annotationParamName?: string,\n })]} */ (item)?.[1]?.names) {\n return actualNames[idx];\n }\n\n return item;\n }).filter((item) => {\n return item !== 'this';\n });\n\n // When disableMissingParamChecks is true tag names can be omitted.\n // Report when the tag names do not match the expected names or they are used out of order.\n if (disableMissingParamChecks) {\n const usedExpectedNames = expectedNames.map((a) => {\n return a?.toString();\n }).filter((expectedName) => {\n return expectedName && actualNames.includes(expectedName);\n });\n const usedInOrder = actualNames.every((actualName, idx) => {\n return actualName === usedExpectedNames[idx];\n });\n if (usedInOrder) {\n return false;\n }\n }\n\n report(\n `Expected @${targetTagName} names to be \"${\n expectedNames.map((expectedName) => {\n return typeof expectedName === 'object' &&\n 'name' in expectedName &&\n expectedName.restElement ?\n '...' + expectedName.name :\n expectedName;\n }).join(', ')\n }\". Got \"${actualNames.join(', ')}\".`,\n null,\n tag,\n );\n\n return true;\n }\n\n return false;\n });\n};\n\n/**\n * @param {string} targetTagName\n * @param {boolean} _allowExtraTrailingParamDocs\n * @param {{\n * name: string,\n * idx: import('../iterateJsdoc.js').Integer\n * }[]} jsdocParameterNames\n * @param {import('comment-parser').Block} jsdoc\n * @param {import('../iterateJsdoc.js').Report} report\n * @returns {boolean}\n */\nconst validateParameterNamesDeep = (\n targetTagName, _allowExtraTrailingParamDocs,\n jsdocParameterNames, jsdoc, report,\n) => {\n /** @type {string} */\n let lastRealParameter;\n\n return jsdocParameterNames.some(({\n idx,\n name: jsdocParameterName,\n }) => {\n const isPropertyPath = jsdocParameterName.includes('.');\n\n if (isPropertyPath) {\n if (!lastRealParameter) {\n report(`@${targetTagName} path declaration (\"${jsdocParameterName}\") appears before any real parameter.`, null, jsdoc.tags[idx]);\n\n return true;\n }\n\n let pathRootNodeName = jsdocParameterName.slice(0, jsdocParameterName.indexOf('.'));\n\n if (pathRootNodeName.endsWith('[]')) {\n pathRootNodeName = pathRootNodeName.slice(0, -2);\n }\n\n if (pathRootNodeName !== lastRealParameter) {\n report(\n `@${targetTagName} path declaration (\"${jsdocParameterName}\") root node name (\"${pathRootNodeName}\") ` +\n `does not match previous real parameter name (\"${lastRealParameter}\").`,\n null,\n jsdoc.tags[idx],\n );\n\n return true;\n }\n } else {\n lastRealParameter = jsdocParameterName;\n }\n\n return false;\n });\n};\n\nconst allowedNodes = [\n 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',\n // Add this to above defaults\n 'TSMethodSignature', 'TSPropertySignature',\n];\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n node,\n report,\n utils,\n}) => {\n const {\n allowExtraTrailingParamDocs,\n checkDestructured = true,\n checkRestProperty = false,\n checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/',\n disableExtraPropertyReporting = false,\n disableMissingParamChecks = false,\n enableFixer = false,\n useDefaultObjectProperties = false,\n } = context.options[0] || {};\n\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (node);\n\n // Although we might just remove global settings contexts from applying to\n // this rule (as they can cause problems with `getFunctionParameterNames`\n // checks if they are not functions but say variables), the user may\n // instead wish to narrow contexts in those settings, so this check\n // is still useful\n if (!allowedNodes.includes(nde.type) ||\n nde.type === 'TSPropertySignature' &&\n (/** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ (\n nde\n )?.typeAnnotation?.typeAnnotation?.type !== 'TSFunctionType')) {\n return;\n }\n\n const checkTypesRegex = utils.getRegexFromString(checkTypesPattern);\n\n const jsdocParameterNamesDeep = utils.getJsdocTagsDeep('param');\n if (!jsdocParameterNamesDeep || !jsdocParameterNamesDeep.length) {\n return;\n }\n\n const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties);\n\n const targetTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'param',\n }));\n const isError = validateParameterNames(\n targetTagName,\n allowExtraTrailingParamDocs,\n checkDestructured,\n checkRestProperty,\n checkTypesRegex,\n disableExtraPropertyReporting,\n disableMissingParamChecks,\n enableFixer,\n functionParameterNames,\n jsdoc,\n utils,\n report,\n );\n\n if (isError || !checkDestructured) {\n return;\n }\n\n validateParameterNamesDeep(\n targetTagName, allowExtraTrailingParamDocs, jsdocParameterNamesDeep, jsdoc, report,\n );\n}, {\n contextDefaults: allowedNodes,\n meta: {\n docs: {\n description: 'Checks for dupe `@param` names, that nested param names have roots, and that parameter names in function declarations match JSDoc param names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-param-names.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowExtraTrailingParamDocs: {\n description: `If set to \\`true\\`, this option will allow extra \\`@param\\` definitions (e.g.,\nrepresenting future expected or virtual params) to be present without needing\ntheir presence within the function signature. Other inconsistencies between\n\\`@param\\`'s and present function parameters will still be reported.`,\n type: 'boolean',\n },\n checkDestructured: {\n description: 'Whether to check destructured properties. Defaults to `true`.',\n type: 'boolean',\n },\n checkRestProperty: {\n description: `If set to \\`true\\`, will require that rest properties are documented and\nthat any extraneous properties (which may have been within the rest property)\nare documented. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n checkTypesPattern: {\n description: `Defines a regular expression pattern to indicate which types should be\nchecked for destructured content (and that those not matched should not\nbe checked).\n\nWhen one specifies a type, unless it is of a generic type, like \\`object\\`\nor \\`array\\`, it may be considered unnecessary to have that object's\ndestructured components required, especially where generated docs will\nlink back to the specified type. For example:\n\n\\`\\`\\`js\n/**\n * @param {SVGRect} bbox - a SVGRect\n */\nexport const bboxToObj = function ({x, y, width, height}) {\n return {x, y, width, height};\n};\n\\`\\`\\`\n\nBy default \\`checkTypesPattern\\` is set to\n\\`/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/v\\`,\nmeaning that destructuring will be required only if the type of the \\`@param\\`\n(the text between curly brackets) is a match for \"Object\" or \"Array\" (with or\nwithout initial caps), \"PlainObject\", or \"GenericObject\", \"GenericArray\" (or\nif no type is present). So in the above example, the lack of a match will\nmean that no complaint will be given about the undocumented destructured\nparameters.\n\nNote that the \\`/\\` delimiters are optional, but necessary to add flags.\n\nDefaults to using (only) the \\`v\\` flag, so to add your own flags, encapsulate\nyour expression as a string, but like a literal, e.g., \\`/^object$/vi\\`.\n\nYou could set this regular expression to a more expansive list, or you\ncould restrict it such that even types matching those strings would not\nneed destructuring.`,\n type: 'string',\n },\n disableExtraPropertyReporting: {\n description: `Whether to check for extra destructured properties. Defaults to \\`false\\`. Change\nto \\`true\\` if you want to be able to document properties which are not actually\ndestructured. Keep as \\`false\\` if you expect properties to be documented in\ntheir own types. Note that extra properties will always be reported if another\nitem at the same level is destructured as destructuring will prevent other\naccess and this option is only intended to permit documenting extra properties\nthat are available and actually used in the function.`,\n type: 'boolean',\n },\n disableMissingParamChecks: {\n description: 'Whether to avoid checks for missing `@param` definitions. Defaults to `false`. Change to `true` if you want to be able to omit properties.',\n type: 'boolean',\n },\n enableFixer: {\n description: `Set to \\`true\\` to auto-remove \\`@param\\` duplicates (based on identical\nnames).\n\nNote that this option will remove duplicates of the same name even if\nthe definitions do not match in other ways (e.g., the second param will\nbe removed even if it has a different type or description).`,\n type: 'boolean',\n },\n useDefaultObjectProperties: {\n description: `Set to \\`true\\` if you wish to avoid reporting of child property documentation\nwhere instead of destructuring, a whole plain object is supplied as default\nvalue but you wish its keys to be considered as signalling that the properties\nare present and can therefore be documented. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,sBAAsB,GAAG,CAC7B,aAAa,EACb,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,6BAA6B,EAC7B,yBAAyB,EACzB,WAAW,EACX,sBAAsB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KACzC;EACH,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GACjD,GAAG,CACN,KAAK;IACJ,OAAO,GAAG,CAAC,GAAG,KAAK,aAAa;EAClC,CAAC,CAAC;EACF,MAAM,kBAAkB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GACzC,GAAG,CACN,KAAK;IACJ,OAAO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ACjB,WAAW,EAAE,+DAA+D;UAC5E,IAAI,EAAE;QACR,CAAC;QACD,iBAAiB,EAAE;UACjB,WAAW,EAAE;AACzB;AACA,uCAAuC;UAC3B,IAAI,EAAE;QACR,CAAC;QACD,iBAAiB,EAAE;UACjB,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;UACR,IAAI,EAAE;QACR,CAAC;QACD,6BAA6B,EAAE;UAC7B,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA,sDAAsD;UAC1C,IAAI,EAAE;QACR,CAAC;QACD,yBAAyB,EAAE;UACzB,WAAW,EAAE,4IAA4I;UACzJ,IAAI,EAAE;QACR,CAAC;QACD,WAAW,EAAE;UACX,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA,4DAA4D;UAChD,IAAI,EAAE;QACR,CAAC;QACD,0BAA0B,EAAE;UAC1B,WAAW,EAAE;AACzB;AACA;AACA,oEAAoE;UACxD,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
3
|
/**
|
|
10
4
|
* @param {string} targetTagName
|
|
11
5
|
* @param {boolean} enableFixer
|
|
@@ -84,7 +78,7 @@ const validatePropertyNamesDeep = (targetTagName, jsdocPropertyNames, jsdoc, rep
|
|
|
84
78
|
return false;
|
|
85
79
|
});
|
|
86
80
|
};
|
|
87
|
-
|
|
81
|
+
export default iterateJsdoc(({
|
|
88
82
|
context,
|
|
89
83
|
jsdoc,
|
|
90
84
|
report,
|
|
@@ -131,5 +125,4 @@ be removed even if it has a different type or description).`,
|
|
|
131
125
|
type: 'suggestion'
|
|
132
126
|
}
|
|
133
127
|
});
|
|
134
|
-
module.exports = exports.default;
|
|
135
128
|
//# sourceMappingURL=checkPropertyNames.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkPropertyNames.cjs","names":[
|
|
1
|
+
{"version":3,"file":"checkPropertyNames.cjs","names":[],"sources":["../../src/rules/checkPropertyNames.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {string} targetTagName\n * @param {boolean} enableFixer\n * @param {import('comment-parser').Block} jsdoc\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @returns {boolean}\n */\nconst validatePropertyNames = (\n targetTagName,\n enableFixer,\n jsdoc, utils,\n) => {\n const jsdocTypedefs = utils.getJsdocTagsDeep('typedef');\n let propertyTagGroups;\n if (jsdocTypedefs && jsdocTypedefs.length > 1) {\n propertyTagGroups = jsdocTypedefs.map(({\n idx,\n }, index) => {\n return Object.entries(jsdoc.tags).slice(idx, jsdocTypedefs[index + 1]?.idx);\n });\n } else {\n propertyTagGroups = [\n Object.entries(jsdoc.tags),\n ];\n }\n\n return propertyTagGroups.some((propertyTagGroup) => {\n const propertyTags = propertyTagGroup.filter(([\n , tag,\n ]) => {\n return tag.tag === targetTagName;\n });\n\n return propertyTags.some(([\n , tag,\n ], index) => {\n /** @type {import('../iterateJsdoc.js').Integer} */\n let tagsIndex;\n const dupeTagInfo = propertyTags.find(([\n tgsIndex,\n tg,\n ], idx) => {\n tagsIndex = Number(tgsIndex);\n\n return tg.name === tag.name && idx !== index;\n });\n if (dupeTagInfo) {\n utils.reportJSDoc(`Duplicate @${targetTagName} \"${tag.name}\"`, dupeTagInfo[1], enableFixer ? () => {\n utils.removeTag(tagsIndex);\n } : null);\n\n return true;\n }\n\n return false;\n });\n });\n};\n\n/**\n * @param {string} targetTagName\n * @param {{\n * idx: number;\n * name: string;\n * type: string;\n * }[]} jsdocPropertyNames\n * @param {import('comment-parser').Block} jsdoc\n * @param {import('../iterateJsdoc.js').Report} report\n */\nconst validatePropertyNamesDeep = (\n targetTagName,\n jsdocPropertyNames, jsdoc, report,\n) => {\n /** @type {string} */\n let lastRealProperty;\n\n return jsdocPropertyNames.some(({\n idx,\n name: jsdocPropertyName,\n }) => {\n const isPropertyPath = jsdocPropertyName.includes('.');\n\n if (isPropertyPath) {\n if (!lastRealProperty) {\n report(`@${targetTagName} path declaration (\"${jsdocPropertyName}\") appears before any real property.`, null, jsdoc.tags[idx]);\n\n return true;\n }\n\n let pathRootNodeName = jsdocPropertyName.slice(0, jsdocPropertyName.indexOf('.'));\n\n if (pathRootNodeName.endsWith('[]')) {\n pathRootNodeName = pathRootNodeName.slice(0, -2);\n }\n\n if (pathRootNodeName !== lastRealProperty) {\n report(\n `@${targetTagName} path declaration (\"${jsdocPropertyName}\") root node name (\"${pathRootNodeName}\") ` +\n `does not match previous real property name (\"${lastRealProperty}\").`,\n null,\n jsdoc.tags[idx],\n );\n\n return true;\n }\n } else {\n lastRealProperty = jsdocPropertyName;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n report,\n utils,\n}) => {\n const {\n enableFixer = false,\n } = context.options[0] || {};\n const jsdocPropertyNamesDeep = utils.getJsdocTagsDeep('property');\n if (!jsdocPropertyNamesDeep || !jsdocPropertyNamesDeep.length) {\n return;\n }\n\n const targetTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'property',\n }));\n const isError = validatePropertyNames(\n targetTagName,\n enableFixer,\n jsdoc,\n utils,\n );\n\n if (isError) {\n return;\n }\n\n validatePropertyNamesDeep(\n targetTagName, jsdocPropertyNamesDeep, jsdoc, report,\n );\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Ensures that property names in JSDoc are not duplicated on the same block and that nested properties have defined roots.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-property-names.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n enableFixer: {\n description: `Set to \\`true\\` to auto-remove \\`@property\\` duplicates (based on\nidentical names).\n\nNote that this option will remove duplicates of the same name even if\nthe definitions do not match in other ways (e.g., the second property will\nbe removed even if it has a different type or description).`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,CAC5B,aAAa,EACb,WAAW,EACX,KAAK,EAAE,KAAK,KACT;EACH,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC;EACvD,IAAI,iBAAiB;EACrB,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;IAC7C,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;MACrC;IACF,CAAC,EAAE,KAAK,KAAK;MACX,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7E,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,iBAAiB,GAAG,CAClB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAC3B;EACH;EAEA,OAAO,iBAAiB,CAAC,IAAI,CAAE,gBAAgB,IAAK;IAClD,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAC1C,GAAG,CACN,KA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,IAAI,EAAE;MACJ,WAAW,EAAE,0HAA0H;MACvI,GAAG,EAAE;IACP,CAAC;IACD,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,CACN;MACE,oBAAoB,EAAE,KAAK;MAC3B,UAAU,EAAE;QACV,WAAW,EAAE;UACX,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA,4DAA4D;UAChD,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
|
+
export default iterateJsdoc(({
|
|
10
3
|
jsdoc,
|
|
11
4
|
report,
|
|
12
5
|
settings
|
|
@@ -34,5 +27,4 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
34
27
|
type: 'suggestion'
|
|
35
28
|
}
|
|
36
29
|
});
|
|
37
|
-
module.exports = exports.default;
|
|
38
30
|
//# sourceMappingURL=checkSyntax.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkSyntax.cjs","names":[
|
|
1
|
+
{"version":3,"file":"checkSyntax.cjs","names":[],"sources":["../../src/rules/checkSyntax.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n settings,\n}) => {\n const {\n mode,\n } = settings;\n\n // Don't check for \"permissive\" and \"closure\"\n if (mode === 'jsdoc' || mode === 'typescript') {\n for (const tag of jsdoc.tags) {\n if (tag.type.slice(-1) === '=') {\n report('Syntax should not be Google Closure Compiler style.', null, tag);\n break;\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports against syntax not valid for the mode (e.g., Google Closure Compiler in non-Closure mode).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-syntax.md#repos-sticky-header',\n },\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;AAE7C,eAAe,YAAY,CAAC,CAAC;EAC3B,KAAK;EACL,MAAM;EACN;AACF,CAAC,KAAK;EACJ,MAAM;IACJ;EACF,CAAC,GAAG,QAAQ;;EAEZ;EACA,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,YAAY,EAAE;IAC7C,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE;MAC5B,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QAC9B,MAAM,CAAC,qDAAqD,EAAE,IAAI,EAAE,GAAG,CAAC;QACxE;MACF;IACF;EACF;AACF,CAAC,EAAE;EACD,gBAAgB,EAAE,IAAI;EACtB,IAAI,EAAE;IACJ,IAAI,EAAE;MACJ,WAAW,EAAE,oGAAoG;MACjH,GAAG,EAAE;IACP,CAAC;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
|
+
import escapeStringRegexp from 'escape-string-regexp';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
8
|
-
var _escapeStringRegexp = _interopRequireDefault(require("escape-string-regexp"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
4
|
// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/
|
|
11
5
|
const jsxTagNames = new Set(['jsx', 'jsxFrag', 'jsxImportSource', 'jsxRuntime']);
|
|
12
6
|
const typedTagsAlwaysUnnecessary = new Set(['augments', 'callback', 'class', 'enum', 'implements', 'private', 'property', 'protected', 'public', 'readonly', 'this', 'type', 'typedef']);
|
|
13
7
|
const typedTagsNeedingName = new Set(['template']);
|
|
14
8
|
const typedTagsUnnecessaryOutsideDeclare = new Set(['abstract', 'access', 'class', 'constant', 'constructs', 'default', 'enum', 'export', 'exports', 'function', 'global', 'inherits', 'instance', 'interface', 'member', 'memberof', 'memberOf', 'method', 'mixes', 'mixin', 'module', 'name', 'namespace', 'override', 'property', 'requires', 'static', 'this']);
|
|
15
|
-
|
|
9
|
+
export default iterateJsdoc(({
|
|
16
10
|
context,
|
|
17
11
|
jsdoc,
|
|
18
12
|
jsdocNode,
|
|
@@ -183,7 +177,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
183
177
|
}
|
|
184
178
|
if (preferredTagName !== tagName) {
|
|
185
179
|
report(message, fixer => {
|
|
186
|
-
const replacement = sourceCode.getText(jsdocNode).replace(new RegExp(`@${(
|
|
180
|
+
const replacement = sourceCode.getText(jsdocNode).replace(new RegExp(`@${escapeStringRegexp(tagName)}\\b`, 'v'), `@${preferredTagName}`);
|
|
187
181
|
return fixer.replaceText(jsdocNode, replacement);
|
|
188
182
|
}, jsdocTag);
|
|
189
183
|
}
|
|
@@ -308,5 +302,4 @@ this
|
|
|
308
302
|
type: 'suggestion'
|
|
309
303
|
}
|
|
310
304
|
});
|
|
311
|
-
module.exports = exports.default;
|
|
312
305
|
//# sourceMappingURL=checkTagNames.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkTagNames.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_escapeStringRegexp","e","__esModule","default","jsxTagNames","Set","typedTagsAlwaysUnnecessary","typedTagsNeedingName","typedTagsUnnecessaryOutsideDeclare","_default","exports","iterateJsdoc","context","jsdoc","jsdocNode","node","report","settings","sourceCode","utils","definedTags","enableFixer","inlineTags","jsxTags","typed","options","definedPreferredTags","structuredTags","tagNamePreference","definedStructuredTags","Object","keys","definedNonPreferredTags","length","values","map","preferredTag","undefined","reportSettings","replacement","filter","Boolean","isInAmbientContext","subNode","type","filename","getFilename","endsWith","declare","parent","tagIsRedundantWhenTyped","jsdocTag","has","tag","includes","reportWithTagRemovalFixer","message","tagIndex","additionalTagChanges","reportJSDoc","description","trim","changeTag","postType","removeTag","removeEmptyBlock","checkTagForTypedValidity","postTag","name","tags","tagName","validTags","isValidTag","preferredTagName","getPreferredTagName","allowObjectReturn","defaultMessage","fixer","getText","replace","RegExp","escapeStringRegexp","replaceText","inlineTag","getInlineTags","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/checkTagNames.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport escapeStringRegexp from 'escape-string-regexp';\n\n// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/\nconst jsxTagNames = new Set([\n 'jsx',\n 'jsxFrag',\n 'jsxImportSource',\n 'jsxRuntime',\n]);\n\nconst typedTagsAlwaysUnnecessary = new Set([\n 'augments',\n 'callback',\n 'class',\n 'enum',\n 'implements',\n 'private',\n 'property',\n 'protected',\n 'public',\n 'readonly',\n 'this',\n 'type',\n 'typedef',\n]);\n\nconst typedTagsNeedingName = new Set([\n 'template',\n]);\n\nconst typedTagsUnnecessaryOutsideDeclare = new Set([\n 'abstract',\n 'access',\n 'class',\n 'constant',\n 'constructs',\n 'default',\n 'enum',\n 'export',\n 'exports',\n 'function',\n 'global',\n 'inherits',\n 'instance',\n 'interface',\n 'member',\n 'memberof',\n 'memberOf',\n 'method',\n 'mixes',\n 'mixin',\n 'module',\n 'name',\n 'namespace',\n 'override',\n 'property',\n 'requires',\n 'static',\n 'this',\n]);\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n jsdocNode,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const\n /**\n * @type {{\n * definedTags: string[],\n * enableFixer: boolean,\n * inlineTags: string[],\n * jsxTags: boolean,\n * typed: boolean\n }} */ {\n definedTags = [],\n enableFixer = true,\n inlineTags = [\n // jsdoc\n 'link', 'linkcode', 'linkplain', 'tutorial',\n // https://tsdoc.org/pages/spec/tag_kinds/#inline-tags\n 'inheritDoc',\n 'label',\n // https://typedoc.org/documents/Tags.html#inline-tags\n 'include', 'includeCode',\n ],\n jsxTags,\n typed,\n } = context.options[0] || {};\n\n /** @type {(string|undefined)[]} */\n let definedPreferredTags = [];\n const {\n structuredTags,\n tagNamePreference,\n } = settings;\n const definedStructuredTags = Object.keys(structuredTags);\n const definedNonPreferredTags = Object.keys(tagNamePreference);\n if (definedNonPreferredTags.length) {\n definedPreferredTags = Object.values(tagNamePreference).map((preferredTag) => {\n if (typeof preferredTag === 'string') {\n // May become an empty string but will be filtered out below\n return preferredTag;\n }\n\n if (!preferredTag) {\n return undefined;\n }\n\n if (typeof preferredTag !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.',\n );\n }\n\n return preferredTag.replacement;\n })\n .filter(Boolean);\n }\n\n /**\n * @param {import('eslint').Rule.Node} subNode\n * @returns {boolean}\n */\n const isInAmbientContext = (subNode) => {\n return subNode.type === 'Program' ?\n /* c8 ignore next 2 -- Support old ESLint */\n // @ts-expect-error ESLint < 10\n (context.filename ?? context.getFilename()).endsWith('.d.ts') :\n Boolean(\n /** @type {import('@typescript-eslint/types').TSESTree.VariableDeclaration} */ (\n subNode\n ).declare,\n ) || isInAmbientContext(subNode.parent);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @returns {boolean}\n */\n const tagIsRedundantWhenTyped = (jsdocTag) => {\n if (!typedTagsUnnecessaryOutsideDeclare.has(jsdocTag.tag)) {\n return false;\n }\n\n if (jsdocTag.tag === 'default') {\n return false;\n }\n\n if (node === null) {\n return false;\n }\n\n /* c8 ignore next 2 -- Support old ESLint */\n // @ts-expect-error ESLint < 10\n if ((context.filename ?? context.getFilename()).endsWith('.d.ts') && [\n null, 'Program', undefined,\n ].includes(node?.parent?.type)) {\n return false;\n }\n\n if (isInAmbientContext(/** @type {import('eslint').Rule.Node} */ (node))) {\n return false;\n }\n\n return true;\n };\n\n /**\n * @param {string} message\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @param {Partial<import('comment-parser').Tokens>} [additionalTagChanges]\n * @returns {void}\n */\n const reportWithTagRemovalFixer = (message, jsdocTag, tagIndex, additionalTagChanges) => {\n utils.reportJSDoc(message, jsdocTag, enableFixer ? () => {\n if (jsdocTag.description.trim()) {\n utils.changeTag(jsdocTag, {\n postType: '',\n type: '',\n ...additionalTagChanges,\n });\n } else {\n utils.removeTag(tagIndex, {\n removeEmptyBlock: true,\n });\n }\n } : null, true);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @returns {boolean}\n */\n const checkTagForTypedValidity = (jsdocTag, tagIndex) => {\n if (typedTagsAlwaysUnnecessary.has(jsdocTag.tag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n {\n postTag: '',\n tag: '',\n },\n );\n return true;\n }\n\n if (tagIsRedundantWhenTyped(jsdocTag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant outside of ambient (\\`declare\\`/\\`.d.ts\\`) contexts when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n if (typedTagsNeedingName.has(jsdocTag.tag) && !jsdocTag.name) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' without a name is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n return false;\n };\n\n for (let tagIndex = 0; tagIndex < jsdoc.tags.length; tagIndex += 1) {\n const jsdocTag = jsdoc.tags[tagIndex];\n const tagName = jsdocTag.tag;\n if (jsxTags && jsxTagNames.has(tagName)) {\n continue;\n }\n\n if (typed && checkTagForTypedValidity(jsdocTag, tagIndex)) {\n continue;\n }\n\n const validTags = [\n ...definedTags,\n ...(/** @type {string[]} */ (definedPreferredTags)),\n ...definedNonPreferredTags,\n ...definedStructuredTags,\n ...typed ? typedTagsNeedingName : [],\n ];\n\n if (utils.isValidTag(tagName, validTags)) {\n let preferredTagName = utils.getPreferredTagName({\n allowObjectReturn: true,\n defaultMessage: `Blacklisted tag found (\\`@${tagName}\\`)`,\n tagName,\n });\n if (!preferredTagName) {\n continue;\n }\n\n let message;\n if (typeof preferredTagName === 'object') {\n ({\n message,\n replacement: preferredTagName,\n } = /** @type {{message: string; replacement?: string | undefined;}} */ (\n preferredTagName\n ));\n }\n\n if (!message) {\n message = `Invalid JSDoc tag (preference). Replace \"${tagName}\" JSDoc tag with \"${preferredTagName}\".`;\n }\n\n if (preferredTagName !== tagName) {\n report(message, (fixer) => {\n const replacement = sourceCode.getText(jsdocNode).replace(\n new RegExp(`@${escapeStringRegexp(tagName)}\\\\b`, 'v'),\n `@${preferredTagName}`,\n );\n\n return fixer.replaceText(jsdocNode, replacement);\n }, jsdocTag);\n }\n } else {\n report(`Invalid JSDoc tag name \"${tagName}\".`, null, jsdocTag);\n }\n }\n\n for (const inlineTag of utils.getInlineTags()) {\n if (!inlineTags.includes(inlineTag.tag)) {\n report(`Invalid JSDoc inline tag name \"${inlineTag.tag}\"`, null, inlineTag);\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid block tag names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n definedTags: {\n description: `Use an array of \\`definedTags\\` strings to configure additional, allowed tags.\nThe format is as follows:\n\n\\`\\`\\`json\n{\n \"definedTags\": [\"note\", \"record\"]\n}\n\\`\\`\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n enableFixer: {\n description: 'Set to `false` to disable auto-removal of types that are redundant with the [`typed` option](#typed).',\n type: 'boolean',\n },\n inlineTags: {\n description: `List of tags to allow inline.\n\nDefaults to array of \\`'link', 'linkcode', 'linkplain', 'tutorial', 'inheritDoc', 'label', 'include', and 'includeCode'\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n jsxTags: {\n description: `If this is set to \\`true\\`, all of the following tags used to control JSX output are allowed:\n\n\\`\\`\\`\njsx\njsxFrag\njsxImportSource\njsxRuntime\n\\`\\`\\`\n\nFor more information, see the [babel documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx).`,\n type: 'boolean',\n },\n typed: {\n description: `If this is set to \\`true\\`, additionally checks for tag names that are redundant when using a type checker such as TypeScript.\n\nThese tags are always unnecessary when using TypeScript or similar:\n\n\\`\\`\\`\naugments\ncallback\nclass\nenum\nimplements\nprivate\nproperty\nprotected\npublic\nreadonly\nthis\ntype\ntypedef\n\\`\\`\\`\n\nThese tags are unnecessary except when inside a TypeScript \\`declare\\` context:\n\n\\`\\`\\`\nabstract\naccess\nclass\nconstant\nconstructs\ndefault\nenum\nexport\nexports\nfunction\nglobal\ninherits\ninstance\ninterface\nmember\nmemberof\nmemberOf\nmethod\nmixes\nmixin\nmodule\nname\nnamespace\noverride\nproperty\nrequires\nstatic\nthis\n\\`\\`\\``,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAA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AI,EAAE8B,SAAS,CAAC;IAC7E;EACF;AACF,CAAC,EAAE;EACDE,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJ3B,WAAW,EAAE,kCAAkC;MAC/C4B,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVxE,WAAW,EAAE;UACXwC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACKiC,KAAK,EAAE;YACLjD,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDvB,WAAW,EAAE;UACXuC,WAAW,EAAE,uGAAuG;UACpHhB,IAAI,EAAE;QACR,CAAC;QACDtB,UAAU,EAAE;UACVsC,WAAW,EAAE;AACzB;AACA,0HAA0H;UAC9GiC,KAAK,EAAE;YACLjD,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDrB,OAAO,EAAE;UACPqC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kHAAkH;UACtGhB,IAAI,EAAE;QACR,CAAC;QACDpB,KAAK,EAAE;UACLoC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACKhB,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAkD,MAAA,CAAApF,OAAA,GAAAA,OAAA,CAAAP,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"checkTagNames.cjs","names":[],"sources":["../../src/rules/checkTagNames.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport escapeStringRegexp from 'escape-string-regexp';\n\n// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/\nconst jsxTagNames = new Set([\n 'jsx',\n 'jsxFrag',\n 'jsxImportSource',\n 'jsxRuntime',\n]);\n\nconst typedTagsAlwaysUnnecessary = new Set([\n 'augments',\n 'callback',\n 'class',\n 'enum',\n 'implements',\n 'private',\n 'property',\n 'protected',\n 'public',\n 'readonly',\n 'this',\n 'type',\n 'typedef',\n]);\n\nconst typedTagsNeedingName = new Set([\n 'template',\n]);\n\nconst typedTagsUnnecessaryOutsideDeclare = new Set([\n 'abstract',\n 'access',\n 'class',\n 'constant',\n 'constructs',\n 'default',\n 'enum',\n 'export',\n 'exports',\n 'function',\n 'global',\n 'inherits',\n 'instance',\n 'interface',\n 'member',\n 'memberof',\n 'memberOf',\n 'method',\n 'mixes',\n 'mixin',\n 'module',\n 'name',\n 'namespace',\n 'override',\n 'property',\n 'requires',\n 'static',\n 'this',\n]);\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n jsdocNode,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const\n /**\n * @type {{\n * definedTags: string[],\n * enableFixer: boolean,\n * inlineTags: string[],\n * jsxTags: boolean,\n * typed: boolean\n }} */ {\n definedTags = [],\n enableFixer = true,\n inlineTags = [\n // jsdoc\n 'link', 'linkcode', 'linkplain', 'tutorial',\n // https://tsdoc.org/pages/spec/tag_kinds/#inline-tags\n 'inheritDoc',\n 'label',\n // https://typedoc.org/documents/Tags.html#inline-tags\n 'include', 'includeCode',\n ],\n jsxTags,\n typed,\n } = context.options[0] || {};\n\n /** @type {(string|undefined)[]} */\n let definedPreferredTags = [];\n const {\n structuredTags,\n tagNamePreference,\n } = settings;\n const definedStructuredTags = Object.keys(structuredTags);\n const definedNonPreferredTags = Object.keys(tagNamePreference);\n if (definedNonPreferredTags.length) {\n definedPreferredTags = Object.values(tagNamePreference).map((preferredTag) => {\n if (typeof preferredTag === 'string') {\n // May become an empty string but will be filtered out below\n return preferredTag;\n }\n\n if (!preferredTag) {\n return undefined;\n }\n\n if (typeof preferredTag !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.',\n );\n }\n\n return preferredTag.replacement;\n })\n .filter(Boolean);\n }\n\n /**\n * @param {import('eslint').Rule.Node} subNode\n * @returns {boolean}\n */\n const isInAmbientContext = (subNode) => {\n return subNode.type === 'Program' ?\n /* c8 ignore next 2 -- Support old ESLint */\n // @ts-expect-error ESLint < 10\n (context.filename ?? context.getFilename()).endsWith('.d.ts') :\n Boolean(\n /** @type {import('@typescript-eslint/types').TSESTree.VariableDeclaration} */ (\n subNode\n ).declare,\n ) || isInAmbientContext(subNode.parent);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @returns {boolean}\n */\n const tagIsRedundantWhenTyped = (jsdocTag) => {\n if (!typedTagsUnnecessaryOutsideDeclare.has(jsdocTag.tag)) {\n return false;\n }\n\n if (jsdocTag.tag === 'default') {\n return false;\n }\n\n if (node === null) {\n return false;\n }\n\n /* c8 ignore next 2 -- Support old ESLint */\n // @ts-expect-error ESLint < 10\n if ((context.filename ?? context.getFilename()).endsWith('.d.ts') && [\n null, 'Program', undefined,\n ].includes(node?.parent?.type)) {\n return false;\n }\n\n if (isInAmbientContext(/** @type {import('eslint').Rule.Node} */ (node))) {\n return false;\n }\n\n return true;\n };\n\n /**\n * @param {string} message\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @param {Partial<import('comment-parser').Tokens>} [additionalTagChanges]\n * @returns {void}\n */\n const reportWithTagRemovalFixer = (message, jsdocTag, tagIndex, additionalTagChanges) => {\n utils.reportJSDoc(message, jsdocTag, enableFixer ? () => {\n if (jsdocTag.description.trim()) {\n utils.changeTag(jsdocTag, {\n postType: '',\n type: '',\n ...additionalTagChanges,\n });\n } else {\n utils.removeTag(tagIndex, {\n removeEmptyBlock: true,\n });\n }\n } : null, true);\n };\n\n /**\n * @param {import('comment-parser').Spec} jsdocTag\n * @param {import('../iterateJsdoc.js').Integer} tagIndex\n * @returns {boolean}\n */\n const checkTagForTypedValidity = (jsdocTag, tagIndex) => {\n if (typedTagsAlwaysUnnecessary.has(jsdocTag.tag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n {\n postTag: '',\n tag: '',\n },\n );\n return true;\n }\n\n if (tagIsRedundantWhenTyped(jsdocTag)) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' is redundant outside of ambient (\\`declare\\`/\\`.d.ts\\`) contexts when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n if (typedTagsNeedingName.has(jsdocTag.tag) && !jsdocTag.name) {\n reportWithTagRemovalFixer(\n `'@${jsdocTag.tag}' without a name is redundant when using a type system.`,\n jsdocTag,\n tagIndex,\n );\n return true;\n }\n\n return false;\n };\n\n for (let tagIndex = 0; tagIndex < jsdoc.tags.length; tagIndex += 1) {\n const jsdocTag = jsdoc.tags[tagIndex];\n const tagName = jsdocTag.tag;\n if (jsxTags && jsxTagNames.has(tagName)) {\n continue;\n }\n\n if (typed && checkTagForTypedValidity(jsdocTag, tagIndex)) {\n continue;\n }\n\n const validTags = [\n ...definedTags,\n ...(/** @type {string[]} */ (definedPreferredTags)),\n ...definedNonPreferredTags,\n ...definedStructuredTags,\n ...typed ? typedTagsNeedingName : [],\n ];\n\n if (utils.isValidTag(tagName, validTags)) {\n let preferredTagName = utils.getPreferredTagName({\n allowObjectReturn: true,\n defaultMessage: `Blacklisted tag found (\\`@${tagName}\\`)`,\n tagName,\n });\n if (!preferredTagName) {\n continue;\n }\n\n let message;\n if (typeof preferredTagName === 'object') {\n ({\n message,\n replacement: preferredTagName,\n } = /** @type {{message: string; replacement?: string | undefined;}} */ (\n preferredTagName\n ));\n }\n\n if (!message) {\n message = `Invalid JSDoc tag (preference). Replace \"${tagName}\" JSDoc tag with \"${preferredTagName}\".`;\n }\n\n if (preferredTagName !== tagName) {\n report(message, (fixer) => {\n const replacement = sourceCode.getText(jsdocNode).replace(\n new RegExp(`@${escapeStringRegexp(tagName)}\\\\b`, 'v'),\n `@${preferredTagName}`,\n );\n\n return fixer.replaceText(jsdocNode, replacement);\n }, jsdocTag);\n }\n } else {\n report(`Invalid JSDoc tag name \"${tagName}\".`, null, jsdocTag);\n }\n }\n\n for (const inlineTag of utils.getInlineTags()) {\n if (!inlineTags.includes(inlineTag.tag)) {\n report(`Invalid JSDoc inline tag name \"${inlineTag.tag}\"`, null, inlineTag);\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid block tag names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n definedTags: {\n description: `Use an array of \\`definedTags\\` strings to configure additional, allowed tags.\nThe format is as follows:\n\n\\`\\`\\`json\n{\n \"definedTags\": [\"note\", \"record\"]\n}\n\\`\\`\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n enableFixer: {\n description: 'Set to `false` to disable auto-removal of types that are redundant with the [`typed` option](#typed).',\n type: 'boolean',\n },\n inlineTags: {\n description: `List of tags to allow inline.\n\nDefaults to array of \\`'link', 'linkcode', 'linkplain', 'tutorial', 'inheritDoc', 'label', 'include', and 'includeCode'\\``,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n jsxTags: {\n description: `If this is set to \\`true\\`, all of the following tags used to control JSX output are allowed:\n\n\\`\\`\\`\njsx\njsxFrag\njsxImportSource\njsxRuntime\n\\`\\`\\`\n\nFor more information, see the [babel documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx).`,\n type: 'boolean',\n },\n typed: {\n description: `If this is set to \\`true\\`, additionally checks for tag names that are redundant when using a type checker such as TypeScript.\n\nThese tags are always unnecessary when using TypeScript or similar:\n\n\\`\\`\\`\naugments\ncallback\nclass\nenum\nimplements\nprivate\nproperty\nprotected\npublic\nreadonly\nthis\ntype\ntypedef\n\\`\\`\\`\n\nThese tags are unnecessary except when inside a TypeScript \\`declare\\` context:\n\n\\`\\`\\`\nabstract\naccess\nclass\nconstant\nconstructs\ndefault\nenum\nexport\nexports\nfunction\nglobal\ninherits\ninstance\ninterface\nmember\nmemberof\nmemberOf\nmethod\nmixes\nmixin\nmodule\nname\nnamespace\noverride\nproperty\nrequires\nstatic\nthis\n\\`\\`\\``,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;AAC7C,OAAO,kBAAkB,MAAM,sBAAsB;;AAErD;AACA,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAC1B,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,YAAY,CACb,CAAC;AAEF,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CACzC,UAAU,EACV,UAAU,EACV,OAAO,EACP,MAAM,EACN,YAAY,EACZ,SAAS,EACT,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,MAAM,EACN,MAAM,EACN,SAAS,CACV,CAAC;AAEF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CACnC,UAAU,CACX,CAAC;AAEF,MAAM,kCAAkC,GAAG,IAAI,GAAG,CAAC,CACjD,UAAU,EACV,QAAQ,EACR,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,QAAQ,EACR,OAAO,EACP,OAAO,EAC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,CAAC,CAAC,EAAE;IAC7C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;MACvC,MAAM,CAAC,kCAAkC,SAAS,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC;IAC7E;EACF;AACF,CAAC,EAAE;EACD,gBAAgB,EAAE,IAAI;EACtB,IAAI,EAAE;IACJ,IAAI,EAAE;MACJ,WAAW,EAAE,kCAAkC;MAC/C,GAAG,EAAE;IACP,CAAC;IACD,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,CACN;MACE,oBAAoB,EAAE,KAAK;MAC3B,UAAU,EAAE;QACV,WAAW,EAAE;UACX,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACK,KAAK,EAAE;YACL,IAAI,EAAE;UACR,CAAC;UACD,IAAI,EAAE;QACR,CAAC;QACD,WAAW,EAAE;UACX,WAAW,EAAE,uGAAuG;UACpH,IAAI,EAAE;QACR,CAAC;QACD,UAAU,EAAE;UACV,WAAW,EAAE;AACzB;AACA,0HAA0H;UAC9G,KAAK,EAAE;YACL,IAAI,EAAE;UACR,CAAC;UACD,IAAI,EAAE;QACR,CAAC;QACD,OAAO,EAAE;UACP,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kHAAkH;UACtG,IAAI,EAAE;QACR,CAAC;QACD,KAAK,EAAE;UACL,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACK,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _iterateJsdoc = _interopRequireWildcard(require("../iterateJsdoc.cjs"));
|
|
8
|
-
var _jsdocUtils = require("../jsdocUtils.cjs");
|
|
9
|
-
var _jsdoccomment = require("@es-joy/jsdoccomment");
|
|
10
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
-
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
1
|
+
import iterateJsdoc, { parseComment } from '../iterateJsdoc.js';
|
|
2
|
+
import { getTags } from '../jsdocUtils.js';
|
|
3
|
+
import { getJSDocComment, parse as parseType, traverse, tryParse as tryParseType } from '@es-joy/jsdoccomment';
|
|
4
|
+
export default iterateJsdoc(({
|
|
12
5
|
jsdoc,
|
|
13
6
|
node,
|
|
14
7
|
report,
|
|
@@ -33,11 +26,11 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
33
26
|
const checkForUsedTypes = potentialType => {
|
|
34
27
|
let parsedType;
|
|
35
28
|
try {
|
|
36
|
-
parsedType = mode === 'permissive' ? (
|
|
29
|
+
parsedType = mode === 'permissive' ? tryParseType(/** @type {string} */potentialType) : parseType(/** @type {string} */potentialType, mode);
|
|
37
30
|
} catch {
|
|
38
31
|
return;
|
|
39
32
|
}
|
|
40
|
-
|
|
33
|
+
traverse(parsedType, nde => {
|
|
41
34
|
const {
|
|
42
35
|
type,
|
|
43
36
|
value
|
|
@@ -51,14 +44,14 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
51
44
|
const paramName = /** @type {string} */utils.getPreferredTagName({
|
|
52
45
|
tagName: 'param'
|
|
53
46
|
});
|
|
54
|
-
const paramTags =
|
|
47
|
+
const paramTags = getTags(jsdc, paramName);
|
|
55
48
|
for (const paramTag of paramTags) {
|
|
56
49
|
checkForUsedTypes(paramTag.type);
|
|
57
50
|
}
|
|
58
51
|
const returnsName = /** @type {string} */utils.getPreferredTagName({
|
|
59
52
|
tagName: 'returns'
|
|
60
53
|
});
|
|
61
|
-
const returnsTags =
|
|
54
|
+
const returnsTags = getTags(jsdc, returnsName);
|
|
62
55
|
for (const returnsTag of returnsTags) {
|
|
63
56
|
checkForUsedTypes(returnsTag.type);
|
|
64
57
|
}
|
|
@@ -100,17 +93,16 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
100
93
|
} else if (aliasDeclaration.type === 'ClassDeclaration') {
|
|
101
94
|
/* c8 ignore next -- TS */
|
|
102
95
|
for (const nde of aliasDeclaration?.body?.body ?? []) {
|
|
103
|
-
|
|
104
|
-
const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, nde, settings);
|
|
96
|
+
const commentNode = getJSDocComment(sourceCode, nde, settings);
|
|
105
97
|
if (!commentNode) {
|
|
106
98
|
continue;
|
|
107
99
|
}
|
|
108
|
-
const innerJsdoc =
|
|
100
|
+
const innerJsdoc = parseComment(commentNode, '');
|
|
109
101
|
checkParamsAndReturnsTags(innerJsdoc);
|
|
110
102
|
const typeName = /** @type {string} */utils.getPreferredTagName({
|
|
111
103
|
tagName: 'type'
|
|
112
104
|
});
|
|
113
|
-
const typeTags =
|
|
105
|
+
const typeTags = getTags(innerJsdoc, typeName);
|
|
114
106
|
for (const typeTag of typeTags) {
|
|
115
107
|
checkForUsedTypes(typeTag.type);
|
|
116
108
|
}
|
|
@@ -120,7 +112,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
120
112
|
// Template names may be used only within the heritage clause types of a
|
|
121
113
|
// class/interface, e.g. `@template T` used in `@augments {Base<T>}`.
|
|
122
114
|
for (const heritageTagName of ['augments', 'extends', 'implements']) {
|
|
123
|
-
for (const heritageTag of
|
|
115
|
+
for (const heritageTag of getTags(jsdoc, heritageTagName)) {
|
|
124
116
|
checkForUsedTypes(heritageTag.type);
|
|
125
117
|
}
|
|
126
118
|
}
|
|
@@ -189,5 +181,4 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
189
181
|
type: 'suggestion'
|
|
190
182
|
}
|
|
191
183
|
});
|
|
192
|
-
module.exports = exports.default;
|
|
193
184
|
//# sourceMappingURL=checkTemplateNames.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkTemplateNames.cjs","names":["_iterateJsdoc","_interopRequireWildcard","require","_jsdocUtils","_jsdoccomment","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_default","exports","iterateJsdoc","jsdoc","node","report","settings","sourceCode","utils","mode","tgName","getPreferredTagName","tagName","templateTags","getTags","usedNames","Set","checkForUsedTypes","potentialType","parsedType","tryParseType","parseType","traverse","nde","type","value","add","checkParamsAndReturnsTags","jsdc","paramName","paramTags","paramTag","returnsName","returnsTags","returnsTag","checkTemplateTags","tag","names","parseClosureTemplateTag","nme","checkParameters","aliasDeclaration","checkParamsAndReturns","params","typeParameters","name","body","commentNode","getJSDocComment","innerJsdoc","parseComment","typeName","typeTags","typeTag","heritageTagName","heritageTag","handleTypeAliases","declaration","callbackTags","functionTags","length","typedefTags","potentialTypedefType","propertyName","propertyTags","propertyTag","iterateAllJsdocs","meta","docs","description","url","schema","module"],"sources":["../../src/rules/checkTemplateNames.js"],"sourcesContent":["import iterateJsdoc, {\n parseComment,\n} from '../iterateJsdoc.js';\nimport {\n getTags,\n} from '../jsdocUtils.js';\nimport {\n getJSDocComment,\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\nexport default iterateJsdoc(({\n jsdoc,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n mode,\n } = settings;\n\n const tgName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'template',\n }));\n if (!tgName) {\n return;\n }\n\n const templateTags = utils.getTags(tgName);\n\n const usedNames = new Set();\n /**\n * @param {string} potentialType\n */\n const checkForUsedTypes = (potentialType) => {\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode);\n } catch {\n return;\n }\n\n traverse(parsedType, (nde) => {\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n if (type === 'JsdocTypeName') {\n usedNames.add(value);\n }\n });\n };\n\n const checkParamsAndReturnsTags = (jsdc = jsdoc) => {\n const paramName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'param',\n }));\n const paramTags = getTags(jsdc, paramName);\n for (const paramTag of paramTags) {\n checkForUsedTypes(paramTag.type);\n }\n\n const returnsName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n const returnsTags = getTags(jsdc, returnsName);\n for (const returnsTag of returnsTags) {\n checkForUsedTypes(returnsTag.type);\n }\n };\n\n const checkTemplateTags = () => {\n for (const tag of templateTags) {\n const names = utils.parseClosureTemplateTag(tag);\n for (const nme of names) {\n if (!usedNames.has(nme)) {\n report(`@${tgName} ${nme} not in use`, null, tag);\n }\n }\n }\n };\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|\n * import('@typescript-eslint/types').TSESTree.ClassDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n * @param {boolean} [checkParamsAndReturns]\n */\n const checkParameters = (aliasDeclaration, checkParamsAndReturns) => {\n /* c8 ignore next -- Guard */\n const {\n params,\n } = aliasDeclaration.typeParameters ?? {\n params: [],\n };\n for (const {\n name: {\n name,\n },\n } of params) {\n usedNames.add(name);\n }\n\n if (checkParamsAndReturns) {\n checkParamsAndReturnsTags();\n } else if (aliasDeclaration.type === 'ClassDeclaration') {\n /* c8 ignore next -- TS */\n for (const nde of aliasDeclaration?.body?.body ?? []) {\n // @ts-expect-error Should be ok\n const commentNode = getJSDocComment(sourceCode, nde, settings);\n if (!commentNode) {\n continue;\n }\n\n const innerJsdoc = parseComment(commentNode, '');\n checkParamsAndReturnsTags(innerJsdoc);\n\n const typeName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'type',\n }));\n const typeTags = getTags(innerJsdoc, typeName);\n for (const typeTag of typeTags) {\n checkForUsedTypes(typeTag.type);\n }\n }\n }\n\n // Template names may be used only within the heritage clause types of a\n // class/interface, e.g. `@template T` used in `@augments {Base<T>}`.\n for (const heritageTagName of [\n 'augments', 'extends', 'implements',\n ]) {\n for (const heritageTag of getTags(jsdoc, heritageTagName)) {\n checkForUsedTypes(heritageTag.type);\n }\n }\n\n checkTemplateTags();\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n\n switch (nde.type) {\n case 'ClassDeclaration':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n case 'ExportDefaultDeclaration':\n case 'ExportNamedDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkParameters(nde.declaration);\n break;\n case 'FunctionDeclaration':\n checkParameters(nde.declaration, true);\n break;\n }\n\n break;\n case 'FunctionDeclaration':\n checkParameters(nde, true);\n break;\n }\n };\n\n const callbackTags = utils.getTags('callback');\n const functionTags = utils.getTags('function');\n if (callbackTags.length || functionTags.length) {\n checkParamsAndReturnsTags();\n checkTemplateTags();\n return;\n }\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n const potentialTypedefType = typedefTags[0].type;\n checkForUsedTypes(potentialTypedefType);\n\n const propertyName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'property',\n }));\n const propertyTags = utils.getTags(propertyName);\n for (const propertyTag of propertyTags) {\n checkForUsedTypes(propertyTag.type);\n }\n\n checkTemplateTags();\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that any `@template` names are actually used in the connected `@typedef` or type alias.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-template-names.md#repos-sticky-header',\n },\n schema: [],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAGA,IAAAE,aAAA,GAAAF,OAAA;AAK8B,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAA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C,YAAY,GAAG,qBAAuBvD,KAAK,CAACG,mBAAmB,CAAC;IACpEC,OAAO,EAAE;EACX,CAAC,CAAE;EACH,MAAMoD,YAAY,GAAGxD,KAAK,CAACM,OAAO,CAACiD,YAAY,CAAC;EAChD,KAAK,MAAME,WAAW,IAAID,YAAY,EAAE;IACtC/C,iBAAiB,CAACgD,WAAW,CAACzC,IAAI,CAAC;EACrC;EAEAW,iBAAiB,CAAC,CAAC;AACrB,CAAC,EAAE;EACD+B,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,gGAAgG;MAC7GC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,EAAE;IACV/C,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAgD,MAAA,CAAAvE,OAAA,GAAAA,OAAA,CAAAV,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"checkTemplateNames.cjs","names":[],"sources":["../../src/rules/checkTemplateNames.js"],"sourcesContent":["import iterateJsdoc, {\n parseComment,\n} from '../iterateJsdoc.js';\nimport {\n getTags,\n} from '../jsdocUtils.js';\nimport {\n getJSDocComment,\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\nexport default iterateJsdoc(({\n jsdoc,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n mode,\n } = settings;\n\n const tgName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'template',\n }));\n if (!tgName) {\n return;\n }\n\n const templateTags = utils.getTags(tgName);\n\n const usedNames = new Set();\n /**\n * @param {string} potentialType\n */\n const checkForUsedTypes = (potentialType) => {\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode);\n } catch {\n return;\n }\n\n traverse(parsedType, (nde) => {\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n if (type === 'JsdocTypeName') {\n usedNames.add(value);\n }\n });\n };\n\n const checkParamsAndReturnsTags = (jsdc = jsdoc) => {\n const paramName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'param',\n }));\n const paramTags = getTags(jsdc, paramName);\n for (const paramTag of paramTags) {\n checkForUsedTypes(paramTag.type);\n }\n\n const returnsName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n const returnsTags = getTags(jsdc, returnsName);\n for (const returnsTag of returnsTags) {\n checkForUsedTypes(returnsTag.type);\n }\n };\n\n const checkTemplateTags = () => {\n for (const tag of templateTags) {\n const names = utils.parseClosureTemplateTag(tag);\n for (const nme of names) {\n if (!usedNames.has(nme)) {\n report(`@${tgName} ${nme} not in use`, null, tag);\n }\n }\n }\n };\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|\n * import('@typescript-eslint/types').TSESTree.ClassDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n * @param {boolean} [checkParamsAndReturns]\n */\n const checkParameters = (aliasDeclaration, checkParamsAndReturns) => {\n /* c8 ignore next -- Guard */\n const {\n params,\n } = aliasDeclaration.typeParameters ?? {\n params: [],\n };\n for (const {\n name: {\n name,\n },\n } of params) {\n usedNames.add(name);\n }\n\n if (checkParamsAndReturns) {\n checkParamsAndReturnsTags();\n } else if (aliasDeclaration.type === 'ClassDeclaration') {\n /* c8 ignore next -- TS */\n for (const nde of aliasDeclaration?.body?.body ?? []) {\n const commentNode = getJSDocComment(sourceCode, nde, settings);\n if (!commentNode) {\n continue;\n }\n\n const innerJsdoc = parseComment(commentNode, '');\n checkParamsAndReturnsTags(innerJsdoc);\n\n const typeName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'type',\n }));\n const typeTags = getTags(innerJsdoc, typeName);\n for (const typeTag of typeTags) {\n checkForUsedTypes(typeTag.type);\n }\n }\n }\n\n // Template names may be used only within the heritage clause types of a\n // class/interface, e.g. `@template T` used in `@augments {Base<T>}`.\n for (const heritageTagName of [\n 'augments', 'extends', 'implements',\n ]) {\n for (const heritageTag of getTags(jsdoc, heritageTagName)) {\n checkForUsedTypes(heritageTag.type);\n }\n }\n\n checkTemplateTags();\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n\n switch (nde.type) {\n case 'ClassDeclaration':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n case 'ExportDefaultDeclaration':\n case 'ExportNamedDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkParameters(nde.declaration);\n break;\n case 'FunctionDeclaration':\n checkParameters(nde.declaration, true);\n break;\n }\n\n break;\n case 'FunctionDeclaration':\n checkParameters(nde, true);\n break;\n }\n };\n\n const callbackTags = utils.getTags('callback');\n const functionTags = utils.getTags('function');\n if (callbackTags.length || functionTags.length) {\n checkParamsAndReturnsTags();\n checkTemplateTags();\n return;\n }\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n const potentialTypedefType = typedefTags[0].type;\n checkForUsedTypes(potentialTypedefType);\n\n const propertyName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'property',\n }));\n const propertyTags = utils.getTags(propertyName);\n for (const propertyTag of propertyTags) {\n checkForUsedTypes(propertyTag.type);\n }\n\n checkTemplateTags();\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that any `@template` names are actually used in the connected `@typedef` or type alias.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-template-names.md#repos-sticky-header',\n },\n schema: [],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,IAC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QACxB,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC;QAC1B;IACJ;EACF,CAAC;EAED,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;EAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;EAC9C,IAAI,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE;IAC9C,yBAAyB,CAAC,CAAC;IAC3B,iBAAiB,CAAC,CAAC;IACnB;EACF;EAEA,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;EAC5C,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE;IAClD,iBAAiB,CAAC,CAAC;IACnB;EACF;EAEA,MAAM,oBAAoB,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI;EAChD,iBAAiB,CAAC,oBAAoB,CAAC;EAEvC,MAAM,YAAY,GAAG,qBAAuB,KAAK,CAAC,mBAAmB,CAAC;IACpE,OAAO,EAAE;EACX,CAAC,CAAE;EACH,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;EAChD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;IACtC,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;EACrC;EAEA,iBAAiB,CAAC,CAAC;AACrB,CAAC,EAAE;EACD,gBAAgB,EAAE,IAAI;EACtB,IAAI,EAAE;IACJ,IAAI,EAAE;MACJ,WAAW,EAAE,gGAAgG;MAC7G,GAAG,EAAE;IACP,CAAC;IACD,MAAM,EAAE,EAAE;IACV,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { buildRejectOrPreferRuleDefinition } from '../buildRejectOrPreferRuleDefinition.js';
|
|
2
|
+
import { strictNativeTypes } from '../jsdocUtils.js';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _buildRejectOrPreferRuleDefinition = require("../buildRejectOrPreferRuleDefinition.cjs");
|
|
8
|
-
var _jsdocUtils = require("../jsdocUtils.cjs");
|
|
9
4
|
/**
|
|
10
5
|
* @callback CheckNativeTypes
|
|
11
6
|
* Iterates strict types to see if any should be added to `invalidTypes` (and
|
|
@@ -21,7 +16,7 @@ var _jsdocUtils = require("../jsdocUtils.cjs");
|
|
|
21
16
|
/** @type {CheckNativeTypes} */
|
|
22
17
|
const checkNativeTypes = (preferredTypes, typeNodeName, preferred, parentNode, invalidTypes) => {
|
|
23
18
|
let changedPreferred = preferred;
|
|
24
|
-
for (const strictNativeType of
|
|
19
|
+
for (const strictNativeType of strictNativeTypes) {
|
|
25
20
|
if (strictNativeType === 'object' && (
|
|
26
21
|
// This is not set to remap with exact type match (e.g.,
|
|
27
22
|
// `object: 'Object'`), so can ignore (including if circular)
|
|
@@ -54,7 +49,7 @@ const checkNativeTypes = (preferredTypes, typeNodeName, preferred, parentNode, i
|
|
|
54
49
|
}
|
|
55
50
|
return changedPreferred;
|
|
56
51
|
};
|
|
57
|
-
|
|
52
|
+
export default buildRejectOrPreferRuleDefinition({
|
|
58
53
|
checkNativeTypes,
|
|
59
54
|
schema: [{
|
|
60
55
|
additionalProperties: false,
|
|
@@ -107,5 +102,4 @@ If this option is \`true\`, will currently override \`unifyParentAndChildTypeChe
|
|
|
107
102
|
type: 'object'
|
|
108
103
|
}]
|
|
109
104
|
});
|
|
110
|
-
module.exports = exports.default;
|
|
111
105
|
//# sourceMappingURL=checkTypes.cjs.map
|