eslint-plugin-jsdoc 63.0.1 → 63.0.2
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/cjs/jsdocUtils.d.ts +10 -0
- package/dist/jsdocUtils.cjs +30 -2
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/jsdocUtils.d.ts +10 -0
- package/dist/rules/noUndefinedTypes.cjs +3 -12
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +86 -1
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/package.json +9 -9
- package/src/jsdocUtils.js +38 -0
- package/src/rules/noUndefinedTypes.js +6 -21
- package/src/rules/requireReturnsCheck.js +110 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noUndefinedTypes.cjs","names":["_iterateJsdoc","_interopRequireWildcard","require","_jsdoccomment","_parseImportsExports","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","extraTypes","globalTypes","typescriptGlobals","stripPseudoTypes","str","replace","_default","exports","iterateJsdoc","context","node","report","settings","sourceCode","state","utils","foundTypedefValues","scopeManager","globalScope","checkUsedTypedefs","definedTypes","disableReporting","markVariablesAsUsed","options","definedPreferredTypes","mode","preferredTypes","structuredTags","keys","length","values","map","preferredType","undefined","reportSettings","replacement","filter","Boolean","allComments","getAllComments","comments","comment","test","value","commentNode","parseComment","globals","flatMap","trim","split","concat","languageOptions","typedefs","doc","tags","tag","isNameOrNamepathDefiningTag","includes","typedefDeclarations","name","importTags","description","type","typePart","imprt","importsExports","parseImportsExports","types","namedImports","push","names","namespaceImports","namespace","ancestorNodes","currentNode","parent","getTemplateTags","ancestorNode","getJSDocComment","jsdc","templateTags","closureGenericTypes","parseClosureTemplateTag","cjsOrESMScope","childScopes","block","getValidRuntimeIdentifiers","scope","result","Set","scp","variables","add","upper","getNamespaceTypes","prefix","moduleDeclaration","body","item","declaration","id","prop","key","propName","nestedName","imports","closedTypes","allDefinedTypes","identifiers","globalItem","property","init","callee","methodOrProp","programBody","ast","statement","expression","left","object","getScope","tagToParsedType","propertyName","potentialType","parsedType","tryParseType","parseType","typeTags","filterTags","tagMightHaveTypePosition","namepathReferencingTags","isNamepathReferencingTag","namepathOrUrlReferencingTags","filterAllTags","isNamepathOrUrlReferencingTag","definedNamesAndNamepaths","tagsWithTypes","traverse","nde","parentNode","_parent","val","currNode","right","structuredTypes","rootNamespace","isNamespaceValid","Array","isArray","typeParameters","some","typeParam","element","markVariableAsUsed","exit","loc","typedef","message","iterateAllJsdocs","meta","docs","url","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/noUndefinedTypes.js"],"sourcesContent":["import iterateJsdoc, {\n parseComment,\n} from '../iterateJsdoc.js';\nimport {\n getJSDocComment,\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport {\n parseImportsExports,\n} from 'parse-imports-exports';\n\nconst extraTypes = [\n 'null', 'undefined', 'void', 'string', 'boolean', 'object',\n 'function', 'symbol',\n 'number', 'bigint', 'NaN', 'Infinity',\n 'any', '*', 'never', 'unknown', 'const',\n 'this', 'true', 'false',\n 'Array', 'Object', 'RegExp', 'Date', 'Function', 'Intl',\n];\n\nconst globalTypes = [\n 'globalThis', 'global', 'window', 'self',\n];\n\nconst typescriptGlobals = [\n // https://www.typescriptlang.org/docs/handbook/utility-types.html\n 'Awaited',\n 'Partial',\n 'Required',\n 'Readonly',\n 'Record',\n 'Pick',\n 'Omit',\n 'Exclude',\n 'Extract',\n 'NonNullable',\n 'Parameters',\n 'ConstructorParameters',\n 'ReturnType',\n 'InstanceType',\n 'ThisParameterType',\n 'OmitThisParameter',\n 'ThisType',\n 'Uppercase',\n 'Lowercase',\n 'Capitalize',\n 'Uncapitalize',\n];\n\n/**\n * @param {string|false|undefined} [str]\n * @returns {undefined|string|false}\n */\nconst stripPseudoTypes = (str) => {\n return str && str.replace(/(?:\\.|<>|\\.<>|\\[\\])$/v, '');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n sourceCode,\n state,\n utils,\n}) => {\n /** @type {string[]} */\n const foundTypedefValues = [];\n\n const {\n scopeManager,\n } = sourceCode;\n\n // When is this ever `null`?\n const globalScope = /** @type {import('eslint').Scope.Scope} */ (\n scopeManager.globalScope\n );\n\n const\n /**\n * @type {{\n * checkUsedTypedefs: boolean\n * definedTypes: string[],\n * disableReporting: boolean,\n * markVariablesAsUsed: boolean,\n * }}\n */ {\n checkUsedTypedefs = false,\n definedTypes = [],\n disableReporting = false,\n markVariablesAsUsed = true,\n } = context.options[0] || {};\n\n /** @type {(string|undefined)[]} */\n let definedPreferredTypes = [];\n const {\n mode,\n preferredTypes,\n structuredTags,\n } = settings;\n if (Object.keys(preferredTypes).length) {\n definedPreferredTypes = /** @type {string[]} */ (Object.values(preferredTypes).map((preferredType) => {\n if (typeof preferredType === 'string') {\n // May become an empty string but will be filtered out below\n return stripPseudoTypes(preferredType);\n }\n\n if (!preferredType) {\n return undefined;\n }\n\n if (typeof preferredType !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.',\n );\n }\n\n return stripPseudoTypes(preferredType.replacement);\n })\n .filter(Boolean));\n }\n\n const allComments = sourceCode.getAllComments();\n const comments = allComments\n .filter((comment) => {\n return (/^\\*(?!\\*)/v).test(comment.value);\n })\n .map((commentNode) => {\n return parseComment(commentNode, '');\n });\n\n const globals = allComments\n .filter((comment) => {\n return (/^\\s*globals/v).test(comment.value);\n }).flatMap((commentNode) => {\n return commentNode.value.replace(/^\\s*globals/v, '').trim().split(/,\\s*/v);\n }).concat(Object.keys(context.languageOptions.globals ?? []));\n\n const typedefs = comments\n .flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return utils.isNameOrNamepathDefiningTag(tag) && ![\n 'arg',\n 'argument',\n 'param',\n 'prop',\n 'property',\n ].includes(tag);\n });\n });\n\n const typedefDeclarations = typedefs\n .map((tag) => {\n return tag.name;\n });\n\n const importTags = settings.mode === 'typescript' ? /** @type {string[]} */ (comments.flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return tag === 'import';\n });\n }).flatMap((tag) => {\n const {\n description,\n name,\n type,\n } = tag;\n const typePart = type ? `{${type}} ` : '';\n const imprt = 'import ' + (description ?\n `${typePart}${name} ${description}` :\n `${typePart}${name}`);\n\n const importsExports = parseImportsExports(imprt.trim());\n\n const types = [];\n const namedImports = Object.values(importsExports.namedImports || {})[0]?.[0];\n if (namedImports) {\n if (namedImports.default) {\n types.push(namedImports.default);\n }\n\n if (namedImports.names) {\n types.push(...Object.keys(namedImports.names));\n }\n }\n\n const namespaceImports = Object.values(importsExports.namespaceImports || {})[0]?.[0];\n if (namespaceImports) {\n if (namespaceImports.namespace) {\n types.push(namespaceImports.namespace);\n }\n\n if (namespaceImports.default) {\n types.push(namespaceImports.default);\n }\n }\n\n return types;\n }).filter(Boolean)) : [];\n\n const ancestorNodes = [];\n\n let currentNode = node;\n // No need for Program node?\n while (currentNode?.parent) {\n ancestorNodes.push(currentNode);\n currentNode = currentNode.parent;\n }\n\n /**\n * @param {import('eslint').Rule.Node} ancestorNode\n * @returns {import('comment-parser').Spec[]}\n */\n const getTemplateTags = function (ancestorNode) {\n const commentNode = getJSDocComment(sourceCode, ancestorNode, settings);\n if (!commentNode) {\n return [];\n }\n\n const jsdc = parseComment(commentNode, '');\n\n return jsdc.tags.filter((tag) => {\n return tag.tag === 'template';\n });\n };\n\n // `currentScope` may be `null` or `Program`, so in such a case,\n // we look to present tags instead\n const templateTags = ancestorNodes.length ?\n ancestorNodes.flatMap((ancestorNode) => {\n return getTemplateTags(ancestorNode);\n }) :\n // We err on the side of being too aggressive; checking only\n // present tags is not sufficient\n comments.flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return tag === 'template';\n });\n });\n\n const closureGenericTypes = templateTags.flatMap((tag) => {\n return utils.parseClosureTemplateTag(tag);\n });\n\n // In modules, including Node, there is a global scope at top with the\n // Program scope inside\n const cjsOrESMScope = globalScope.childScopes[0]?.block?.type === 'Program';\n\n /**\n * @param {import(\"eslint\").Scope.Scope | null} scope\n * @returns {Set<string>}\n */\n const getValidRuntimeIdentifiers = (scope) => {\n const result = new Set();\n\n let scp = scope;\n while (scp) {\n for (const {\n name,\n } of scp.variables) {\n result.add(name);\n }\n\n scp = scp.upper;\n }\n\n return result;\n };\n\n /**\n * Recursively extracts types from a namespace declaration.\n * @param {string} prefix - The namespace prefix (e.g., \"MyNamespace\" or \"Outer.Inner\").\n * @param {import('@typescript-eslint/types').TSESTree.TSModuleDeclaration} moduleDeclaration - The module declaration node.\n * @returns {string[]} Array of fully qualified type names.\n */\n const getNamespaceTypes = (prefix, moduleDeclaration) => {\n /* c8 ignore next 3 -- Guard for ambient modules without body. */\n if (!moduleDeclaration.body || moduleDeclaration.body.type !== 'TSModuleBlock') {\n return [];\n }\n\n return moduleDeclaration.body.body.flatMap((item) => {\n /** @type {import('@typescript-eslint/types').TSESTree.ProgramStatement | import('@typescript-eslint/types').TSESTree.NamedExportDeclarations | null} */\n let declaration = item;\n\n if (item.type === 'ExportNamedDeclaration' && item.declaration) {\n declaration = item.declaration;\n }\n\n if (declaration.type === 'TSTypeAliasDeclaration' || declaration.type === 'ClassDeclaration') {\n /* c8 ignore next 4 -- Guard for anonymous class declarations. */\n if (!declaration.id) {\n return [];\n }\n\n return [\n `${prefix}.${declaration.id.name}`,\n ];\n }\n\n if (declaration.type === 'TSInterfaceDeclaration') {\n return [\n `${prefix}.${declaration.id.name}`,\n ...declaration.body.body.map((prop) => {\n // Only `TSPropertySignature` and `TSMethodSignature` have 'key'.\n if (prop.type !== 'TSPropertySignature' && prop.type !== 'TSMethodSignature') {\n return '';\n }\n\n // Key can be computed or a literal, only handle Identifier.\n if (prop.key.type !== 'Identifier') {\n return '';\n }\n\n const propName = prop.key.name;\n /* c8 ignore next -- `propName` is always truthy for Identifiers. */\n return propName ? `${prefix}.${declaration.id.name}.${propName}` : '';\n }).filter(Boolean),\n ];\n }\n\n // Handle nested namespaces.\n if (declaration.type === 'TSModuleDeclaration') {\n /* c8 ignore next -- Nested string-literal modules aren't valid TS syntax. */\n const nestedName = declaration.id?.type === 'Identifier' ? declaration.id.name : '';\n /* c8 ignore next 3 -- Guard. */\n if (!nestedName) {\n return [];\n }\n\n return [\n `${prefix}.${nestedName}`,\n ...getNamespaceTypes(`${prefix}.${nestedName}`, declaration),\n ];\n }\n\n // Fallback for unhandled declaration types (e.g., TSEnumDeclaration, FunctionDeclaration, etc.).\n return [];\n });\n };\n\n /**\n * We treat imports differently as we can't introspect their children.\n * @type {string[]}\n */\n const imports = [];\n\n /** @type {Set<string>} */\n const closedTypes = new Set();\n\n const allDefinedTypes = new Set(globalScope.variables.map(({\n name,\n }) => {\n return name;\n })\n\n // If the file is a module, concat the variables from the module scope.\n .concat(\n cjsOrESMScope ?\n globalScope.childScopes.flatMap(({\n variables,\n }) => {\n return variables;\n }).flatMap(({\n identifiers,\n name,\n }) => {\n const globalItem = /** @type {import('estree').Identifier & {parent: import('@typescript-eslint/types').TSESTree.Node}} */ (\n identifiers?.[0]\n )?.parent;\n switch (globalItem?.type) {\n case 'ClassDeclaration':\n closedTypes.add(name);\n return [\n name,\n ...globalItem.body.body.map((item) => {\n const property = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n /** @type {import('@typescript-eslint/types').TSESTree.PropertyDefinition} */ (\n item)?.key)?.name;\n /* c8 ignore next 3 -- Guard */\n if (!property) {\n return '';\n }\n\n return `${name}.${property}`;\n }).filter(Boolean),\n ];\n case 'ImportDefaultSpecifier':\n case 'ImportNamespaceSpecifier':\n case 'ImportSpecifier':\n imports.push(name);\n break;\n case 'TSInterfaceDeclaration':\n return [\n name,\n ...globalItem.body.body.map((item) => {\n const property = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ (\n item)?.key)?.name;\n /* c8 ignore next 3 -- Guard */\n if (!property) {\n return '';\n }\n\n return `${name}.${property}`;\n }).filter(Boolean),\n ];\n case 'TSModuleDeclaration':\n closedTypes.add(name);\n return [\n name,\n ...getNamespaceTypes(name, globalItem),\n ];\n case 'VariableDeclarator':\n if (/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n /** @type {import('@typescript-eslint/types').TSESTree.CallExpression} */ (\n globalItem?.init\n )?.callee)?.name === 'require'\n ) {\n imports.push(/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n globalItem.id\n ).name);\n break;\n }\n\n // Module scope names are also defined\n return [\n name,\n ];\n }\n\n return [\n name,\n ];\n /* c8 ignore next */\n }) : [],\n )\n .concat(extraTypes)\n .concat(typedefDeclarations)\n .concat(importTags)\n .concat(definedTypes)\n .concat(/** @type {string[]} */ (definedPreferredTypes))\n .concat((() => {\n // Other methods are not in scope, but we need them, and we grab them here\n if (node?.type === 'MethodDefinition') {\n return /** @type {import('estree').ClassBody} */ (node.parent).body.flatMap((methodOrProp) => {\n if (methodOrProp.type === 'MethodDefinition') {\n // eslint-disable-next-line unicorn/no-lonely-if -- Pattern\n if (methodOrProp.key.type === 'Identifier') {\n return [\n methodOrProp.key.name,\n `${/** @type {import('estree').ClassDeclaration} */ (\n node.parent?.parent\n )?.id?.name}.${methodOrProp.key.name}`,\n ];\n }\n }\n\n if (methodOrProp.type === 'PropertyDefinition') {\n // eslint-disable-next-line unicorn/no-lonely-if -- Pattern\n if (methodOrProp.key.type === 'Identifier') {\n return [\n methodOrProp.key.name,\n `${/** @type {import('estree').ClassDeclaration} */ (\n node.parent?.parent\n )?.id?.name}.${methodOrProp.key.name}`,\n ];\n }\n }\n /* c8 ignore next 2 -- Not yet built */\n\n return '';\n }).filter(Boolean);\n }\n\n return [];\n })())\n .concat((() => {\n // Detect static property assignments like `MyClass.Prop = ...`\n const programBody = /** @type {import('@typescript-eslint/types').TSESTree.Program} */ (\n sourceCode.ast\n ).body;\n\n return programBody.flatMap((statement) => {\n if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'AssignmentExpression' &&\n statement.expression.left.type === 'MemberExpression' &&\n statement.expression.left.object.type === 'Identifier' &&\n statement.expression.left.property.type === 'Identifier' &&\n closedTypes.has(statement.expression.left.object.name)\n ) {\n return [\n `${statement.expression.left.object.name}.${statement.expression.left.property.name}`,\n ];\n }\n\n return [];\n });\n })())\n .concat(...getValidRuntimeIdentifiers(node && (\n (sourceCode.getScope &&\n /* c8 ignore next 3 */\n sourceCode.getScope(node)) ||\n // @ts-expect-error ESLint 8\n context.getScope()\n )))\n .concat(\n settings.mode === 'jsdoc' ?\n [] :\n [\n ...settings.mode === 'typescript' ? typescriptGlobals : [],\n ...closureGenericTypes,\n ],\n ));\n\n /**\n * @typedef {{\n * parsedType: import('jsdoc-type-pratt-parser').RootResult;\n * tag: import('comment-parser').Spec|import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {\n * line?: import('../iterateJsdoc.js').Integer\n * }\n * }} TypeAndTagInfo\n */\n\n /**\n * @param {string} propertyName\n * @returns {(tag: (import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {\n * name?: string,\n * type?: string,\n * line?: import('../iterateJsdoc.js').Integer\n * })|import('comment-parser').Spec & {\n * namepathOrURL?: string\n * }\n * ) => undefined|TypeAndTagInfo}\n */\n const tagToParsedType = (propertyName) => {\n return (tag) => {\n try {\n const potentialType = tag[\n /** @type {\"type\"|\"name\"|\"namepathOrURL\"} */ (propertyName)\n ];\n return {\n parsedType: mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode),\n tag,\n };\n } catch {\n return undefined;\n }\n };\n };\n\n const typeTags = utils.filterTags(({\n tag,\n }) => {\n return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');\n }).map(tagToParsedType('type'));\n\n const namepathReferencingTags = utils.filterTags(({\n tag,\n }) => {\n return utils.isNamepathReferencingTag(tag);\n }).map(tagToParsedType('name'));\n\n const namepathOrUrlReferencingTags = utils.filterAllTags(({\n tag,\n }) => {\n return utils.isNamepathOrUrlReferencingTag(tag);\n }).map(tagToParsedType('namepathOrURL'));\n\n const definedNamesAndNamepaths = new Set(utils.filterTags(({\n tag,\n }) => {\n return utils.isNameOrNamepathDefiningTag(tag);\n }).map(({\n name,\n }) => {\n return name;\n }));\n\n const tagsWithTypes = /** @type {TypeAndTagInfo[]} */ ([\n ...typeTags,\n ...namepathReferencingTags,\n ...namepathOrUrlReferencingTags,\n // Remove types which failed to parse\n ].filter(Boolean));\n\n for (const {\n parsedType,\n tag,\n } of tagsWithTypes) {\n // eslint-disable-next-line complexity -- Refactor\n traverse(parsedType, (nde, parentNode) => {\n /**\n * @type {import('jsdoc-type-pratt-parser').NameResult & {\n * _parent?: import('jsdoc-type-pratt-parser').NonRootResult\n * }}\n */\n // eslint-disable-next-line canonical/id-match -- Avoid clashes\n (nde)._parent = parentNode;\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n\n let val = value;\n\n /** @type {import('jsdoc-type-pratt-parser').NonRootResult|undefined} */\n let currNode = nde;\n do {\n currNode =\n /**\n * @type {import('jsdoc-type-pratt-parser').NameResult & {\n * _parent?: import('jsdoc-type-pratt-parser').NonRootResult\n * }}\n */ (currNode)._parent;\n if (\n // Avoid appending for imports and globals since we don't want to\n // check their properties which may or may not exist\n !imports.includes(val) && !globals.includes(val) &&\n !importTags.includes(val) &&\n !extraTypes.includes(val) &&\n !typedefDeclarations.includes(val) &&\n !globalTypes.includes(val) &&\n currNode && 'right' in currNode &&\n currNode.right?.type === 'JsdocTypeProperty'\n ) {\n val = val + '.' + currNode.right.value;\n }\n } while (currNode?.type === 'JsdocTypeNamePath');\n\n if (type === 'JsdocTypeName') {\n const structuredTypes = structuredTags[tag.tag]?.type;\n const rootNamespace = val.split('.')[0];\n const isNamespaceValid = (definedTypes.includes(rootNamespace) || allDefinedTypes.has(rootNamespace)) &&\n !closedTypes.has(rootNamespace);\n\n if (!allDefinedTypes.has(val) &&\n !definedNamesAndNamepaths.has(val) &&\n (!Array.isArray(structuredTypes) || !structuredTypes.includes(val)) && !isNamespaceValid\n ) {\n const parent =\n /**\n * @type {import('jsdoc-type-pratt-parser').RootResult & {\n * _parent?: import('jsdoc-type-pratt-parser').NonRootResult\n * }}\n */ (nde)._parent;\n if (parent?.type === 'JsdocTypeTypeParameter') {\n return;\n }\n\n if (parent?.type === 'JsdocTypeFunction' &&\n /** @type {import('jsdoc-type-pratt-parser').FunctionResult} */\n (parent)?.typeParameters?.some((typeParam) => {\n return value === typeParam.name.value;\n })\n ) {\n return;\n }\n\n if (parent?.type === 'JsdocTypeInfer' && value === parent.element.value) {\n allDefinedTypes.add(value);\n return;\n }\n\n if (!disableReporting) {\n report(`The type '${val}' is undefined.`, null, tag);\n }\n } else if (markVariablesAsUsed && !extraTypes.includes(val)) {\n if (sourceCode.markVariableAsUsed) {\n sourceCode.markVariableAsUsed(val);\n /* c8 ignore next 4 */\n } else {\n // @ts-expect-error ESLint 8\n context.markVariableAsUsed(val);\n }\n }\n\n if (checkUsedTypedefs && typedefDeclarations.includes(val)) {\n foundTypedefValues.push(val);\n }\n }\n });\n }\n\n state.foundTypedefValues = foundTypedefValues;\n}, {\n // We use this method rather than checking at end of handler above because\n // in that case, it is invoked too many times and would thus report errors\n // too many times.\n exit ({\n context,\n state,\n utils,\n }) {\n const {\n checkUsedTypedefs = false,\n } = context.options[0] || {};\n\n if (!checkUsedTypedefs) {\n return;\n }\n\n const allComments = context.sourceCode.getAllComments();\n const comments = allComments\n .filter((comment) => {\n return (/^\\*(?!\\*)/v).test(comment.value);\n })\n .map((commentNode) => {\n return {\n doc: parseComment(commentNode, ''),\n loc: commentNode.loc,\n };\n });\n const typedefs = comments\n .flatMap(({\n doc,\n loc,\n }) => {\n const tags = doc.tags.filter(({\n tag,\n }) => {\n return utils.isNameOrNamepathDefiningTag(tag);\n });\n if (!tags.length) {\n return [];\n }\n\n return {\n loc,\n tags,\n };\n });\n\n for (const typedef of typedefs) {\n if (\n !state.foundTypedefValues.includes(typedef.tags[0].name)\n ) {\n context.report({\n loc: /** @type {import('@eslint/core').SourceLocation} */ (typedef.loc),\n message: 'This typedef was not used within the file',\n });\n }\n }\n },\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Besides some expected built-in types, prohibits any types not specified as globals or within `@typedef`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkUsedTypedefs: {\n description: 'Whether to check typedefs for use within the file',\n type: 'boolean',\n },\n definedTypes: {\n description: `This array can be populated to indicate other types which\nare automatically considered as defined (in addition to globals, etc.).\nDefaults to an empty array.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n disableReporting: {\n description: `Whether to disable reporting of errors. Defaults to\n\\`false\\`. This may be set to \\`true\\` in order to take advantage of only\nmarking defined variables as used or checking used typedefs.`,\n type: 'boolean',\n },\n markVariablesAsUsed: {\n description: `Whether to mark variables as used for the purposes\nof the \\`no-unused-vars\\` rule when they are not found to be undefined.\nDefaults to \\`true\\`. May be set to \\`false\\` to enforce a practice of not\nimporting types unless used in code.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,aAAA,GAAAD,OAAA;AAMA,IAAAE,oBAAA,GAAAF,OAAA;AAE+B,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,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ACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAwG,MAAA,CAAA/J,OAAA,GAAAA,OAAA,CAAAhB,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"noUndefinedTypes.cjs","names":["_iterateJsdoc","_interopRequireWildcard","require","_jsdocUtils","_jsdoccomment","_parseImportsExports","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","extraTypes","globalTypes","typescriptGlobals","stripPseudoTypes","str","replace","_default","exports","iterateJsdoc","context","node","report","settings","sourceCode","state","utils","foundTypedefValues","scopeManager","globalScope","checkUsedTypedefs","definedTypes","disableReporting","markVariablesAsUsed","options","definedPreferredTypes","mode","preferredTypes","structuredTags","keys","length","values","map","preferredType","undefined","reportSettings","replacement","filter","Boolean","allComments","getAllComments","comments","getJSDocCommentBlocks","globals","comment","test","value","flatMap","commentNode","trim","split","concat","languageOptions","typedefs","getDocumentNamepathDefiningTags","typedefDeclarations","tag","name","importTags","doc","tags","description","type","typePart","imprt","importsExports","parseImportsExports","types","namedImports","push","names","namespaceImports","namespace","ancestorNodes","currentNode","parent","getTemplateTags","ancestorNode","getJSDocComment","jsdc","parseComment","templateTags","closureGenericTypes","parseClosureTemplateTag","cjsOrESMScope","childScopes","block","getValidRuntimeIdentifiers","scope","result","Set","scp","variables","add","upper","getNamespaceTypes","prefix","moduleDeclaration","body","item","declaration","id","prop","key","propName","nestedName","imports","closedTypes","allDefinedTypes","identifiers","globalItem","property","init","callee","methodOrProp","programBody","ast","statement","expression","left","object","getScope","tagToParsedType","propertyName","potentialType","parsedType","tryParseType","parseType","typeTags","filterTags","tagMightHaveTypePosition","namepathReferencingTags","isNamepathReferencingTag","namepathOrUrlReferencingTags","filterAllTags","isNamepathOrUrlReferencingTag","definedNamesAndNamepaths","isNameOrNamepathDefiningTag","tagsWithTypes","traverse","nde","parentNode","_parent","val","currNode","includes","right","structuredTypes","rootNamespace","isNamespaceValid","Array","isArray","typeParameters","some","typeParam","element","markVariableAsUsed","exit","loc","typedef","message","iterateAllJsdocs","meta","docs","url","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/noUndefinedTypes.js"],"sourcesContent":["import iterateJsdoc, {\n parseComment,\n} from '../iterateJsdoc.js';\nimport {\n getDocumentNamepathDefiningTags,\n getJSDocCommentBlocks,\n} from '../jsdocUtils.js';\nimport {\n getJSDocComment,\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport {\n parseImportsExports,\n} from 'parse-imports-exports';\n\nconst extraTypes = [\n 'null', 'undefined', 'void', 'string', 'boolean', 'object',\n 'function', 'symbol',\n 'number', 'bigint', 'NaN', 'Infinity',\n 'any', '*', 'never', 'unknown', 'const',\n 'this', 'true', 'false',\n 'Array', 'Object', 'RegExp', 'Date', 'Function', 'Intl',\n];\n\nconst globalTypes = [\n 'globalThis', 'global', 'window', 'self',\n];\n\nconst typescriptGlobals = [\n // https://www.typescriptlang.org/docs/handbook/utility-types.html\n 'Awaited',\n 'Partial',\n 'Required',\n 'Readonly',\n 'Record',\n 'Pick',\n 'Omit',\n 'Exclude',\n 'Extract',\n 'NonNullable',\n 'Parameters',\n 'ConstructorParameters',\n 'ReturnType',\n 'InstanceType',\n 'ThisParameterType',\n 'OmitThisParameter',\n 'ThisType',\n 'Uppercase',\n 'Lowercase',\n 'Capitalize',\n 'Uncapitalize',\n];\n\n/**\n * @param {string|false|undefined} [str]\n * @returns {undefined|string|false}\n */\nconst stripPseudoTypes = (str) => {\n return str && str.replace(/(?:\\.|<>|\\.<>|\\[\\])$/v, '');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n sourceCode,\n state,\n utils,\n}) => {\n /** @type {string[]} */\n const foundTypedefValues = [];\n\n const {\n scopeManager,\n } = sourceCode;\n\n // When is this ever `null`?\n const globalScope = /** @type {import('eslint').Scope.Scope} */ (\n scopeManager.globalScope\n );\n\n const\n /**\n * @type {{\n * checkUsedTypedefs: boolean\n * definedTypes: string[],\n * disableReporting: boolean,\n * markVariablesAsUsed: boolean,\n * }}\n */ {\n checkUsedTypedefs = false,\n definedTypes = [],\n disableReporting = false,\n markVariablesAsUsed = true,\n } = context.options[0] || {};\n\n /** @type {(string|undefined)[]} */\n let definedPreferredTypes = [];\n const {\n mode,\n preferredTypes,\n structuredTags,\n } = settings;\n if (Object.keys(preferredTypes).length) {\n definedPreferredTypes = /** @type {string[]} */ (Object.values(preferredTypes).map((preferredType) => {\n if (typeof preferredType === 'string') {\n // May become an empty string but will be filtered out below\n return stripPseudoTypes(preferredType);\n }\n\n if (!preferredType) {\n return undefined;\n }\n\n if (typeof preferredType !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.',\n );\n }\n\n return stripPseudoTypes(preferredType.replacement);\n })\n .filter(Boolean));\n }\n\n const allComments = sourceCode.getAllComments();\n const comments = getJSDocCommentBlocks(sourceCode);\n\n const globals = allComments\n .filter((comment) => {\n return (/^\\s*globals/v).test(comment.value);\n }).flatMap((commentNode) => {\n return commentNode.value.replace(/^\\s*globals/v, '').trim().split(/,\\s*/v);\n }).concat(Object.keys(context.languageOptions.globals ?? []));\n\n const typedefs = getDocumentNamepathDefiningTags(sourceCode);\n\n const typedefDeclarations = typedefs\n .map((tag) => {\n return tag.name;\n });\n\n const importTags = settings.mode === 'typescript' ? /** @type {string[]} */ (comments.flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return tag === 'import';\n });\n }).flatMap((tag) => {\n const {\n description,\n name,\n type,\n } = tag;\n const typePart = type ? `{${type}} ` : '';\n const imprt = 'import ' + (description ?\n `${typePart}${name} ${description}` :\n `${typePart}${name}`);\n\n const importsExports = parseImportsExports(imprt.trim());\n\n const types = [];\n const namedImports = Object.values(importsExports.namedImports || {})[0]?.[0];\n if (namedImports) {\n if (namedImports.default) {\n types.push(namedImports.default);\n }\n\n if (namedImports.names) {\n types.push(...Object.keys(namedImports.names));\n }\n }\n\n const namespaceImports = Object.values(importsExports.namespaceImports || {})[0]?.[0];\n if (namespaceImports) {\n if (namespaceImports.namespace) {\n types.push(namespaceImports.namespace);\n }\n\n if (namespaceImports.default) {\n types.push(namespaceImports.default);\n }\n }\n\n return types;\n }).filter(Boolean)) : [];\n\n const ancestorNodes = [];\n\n let currentNode = node;\n // No need for Program node?\n while (currentNode?.parent) {\n ancestorNodes.push(currentNode);\n currentNode = currentNode.parent;\n }\n\n /**\n * @param {import('eslint').Rule.Node} ancestorNode\n * @returns {import('comment-parser').Spec[]}\n */\n const getTemplateTags = function (ancestorNode) {\n const commentNode = getJSDocComment(sourceCode, ancestorNode, settings);\n if (!commentNode) {\n return [];\n }\n\n const jsdc = parseComment(commentNode, '');\n\n return jsdc.tags.filter((tag) => {\n return tag.tag === 'template';\n });\n };\n\n // `currentScope` may be `null` or `Program`, so in such a case,\n // we look to present tags instead\n const templateTags = ancestorNodes.length ?\n ancestorNodes.flatMap((ancestorNode) => {\n return getTemplateTags(ancestorNode);\n }) :\n // We err on the side of being too aggressive; checking only\n // present tags is not sufficient\n comments.flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return tag === 'template';\n });\n });\n\n const closureGenericTypes = templateTags.flatMap((tag) => {\n return utils.parseClosureTemplateTag(tag);\n });\n\n // In modules, including Node, there is a global scope at top with the\n // Program scope inside\n const cjsOrESMScope = globalScope.childScopes[0]?.block?.type === 'Program';\n\n /**\n * @param {import(\"eslint\").Scope.Scope | null} scope\n * @returns {Set<string>}\n */\n const getValidRuntimeIdentifiers = (scope) => {\n const result = new Set();\n\n let scp = scope;\n while (scp) {\n for (const {\n name,\n } of scp.variables) {\n result.add(name);\n }\n\n scp = scp.upper;\n }\n\n return result;\n };\n\n /**\n * Recursively extracts types from a namespace declaration.\n * @param {string} prefix - The namespace prefix (e.g., \"MyNamespace\" or \"Outer.Inner\").\n * @param {import('@typescript-eslint/types').TSESTree.TSModuleDeclaration} moduleDeclaration - The module declaration node.\n * @returns {string[]} Array of fully qualified type names.\n */\n const getNamespaceTypes = (prefix, moduleDeclaration) => {\n /* c8 ignore next 3 -- Guard for ambient modules without body. */\n if (!moduleDeclaration.body || moduleDeclaration.body.type !== 'TSModuleBlock') {\n return [];\n }\n\n return moduleDeclaration.body.body.flatMap((item) => {\n /** @type {import('@typescript-eslint/types').TSESTree.ProgramStatement | import('@typescript-eslint/types').TSESTree.NamedExportDeclarations | null} */\n let declaration = item;\n\n if (item.type === 'ExportNamedDeclaration' && item.declaration) {\n declaration = item.declaration;\n }\n\n if (declaration.type === 'TSTypeAliasDeclaration' || declaration.type === 'ClassDeclaration') {\n /* c8 ignore next 4 -- Guard for anonymous class declarations. */\n if (!declaration.id) {\n return [];\n }\n\n return [\n `${prefix}.${declaration.id.name}`,\n ];\n }\n\n if (declaration.type === 'TSInterfaceDeclaration') {\n return [\n `${prefix}.${declaration.id.name}`,\n ...declaration.body.body.map((prop) => {\n // Only `TSPropertySignature` and `TSMethodSignature` have 'key'.\n if (prop.type !== 'TSPropertySignature' && prop.type !== 'TSMethodSignature') {\n return '';\n }\n\n // Key can be computed or a literal, only handle Identifier.\n if (prop.key.type !== 'Identifier') {\n return '';\n }\n\n const propName = prop.key.name;\n /* c8 ignore next -- `propName` is always truthy for Identifiers. */\n return propName ? `${prefix}.${declaration.id.name}.${propName}` : '';\n }).filter(Boolean),\n ];\n }\n\n // Handle nested namespaces.\n if (declaration.type === 'TSModuleDeclaration') {\n /* c8 ignore next -- Nested string-literal modules aren't valid TS syntax. */\n const nestedName = declaration.id?.type === 'Identifier' ? declaration.id.name : '';\n /* c8 ignore next 3 -- Guard. */\n if (!nestedName) {\n return [];\n }\n\n return [\n `${prefix}.${nestedName}`,\n ...getNamespaceTypes(`${prefix}.${nestedName}`, declaration),\n ];\n }\n\n // Fallback for unhandled declaration types (e.g., TSEnumDeclaration, FunctionDeclaration, etc.).\n return [];\n });\n };\n\n /**\n * We treat imports differently as we can't introspect their children.\n * @type {string[]}\n */\n const imports = [];\n\n /** @type {Set<string>} */\n const closedTypes = new Set();\n\n const allDefinedTypes = new Set(globalScope.variables.map(({\n name,\n }) => {\n return name;\n })\n\n // If the file is a module, concat the variables from the module scope.\n .concat(\n cjsOrESMScope ?\n globalScope.childScopes.flatMap(({\n variables,\n }) => {\n return variables;\n }).flatMap(({\n identifiers,\n name,\n }) => {\n const globalItem = /** @type {import('estree').Identifier & {parent: import('@typescript-eslint/types').TSESTree.Node}} */ (\n identifiers?.[0]\n )?.parent;\n switch (globalItem?.type) {\n case 'ClassDeclaration':\n closedTypes.add(name);\n return [\n name,\n ...globalItem.body.body.map((item) => {\n const property = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n /** @type {import('@typescript-eslint/types').TSESTree.PropertyDefinition} */ (\n item)?.key)?.name;\n /* c8 ignore next 3 -- Guard */\n if (!property) {\n return '';\n }\n\n return `${name}.${property}`;\n }).filter(Boolean),\n ];\n case 'ImportDefaultSpecifier':\n case 'ImportNamespaceSpecifier':\n case 'ImportSpecifier':\n imports.push(name);\n break;\n case 'TSInterfaceDeclaration':\n return [\n name,\n ...globalItem.body.body.map((item) => {\n const property = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ (\n item)?.key)?.name;\n /* c8 ignore next 3 -- Guard */\n if (!property) {\n return '';\n }\n\n return `${name}.${property}`;\n }).filter(Boolean),\n ];\n case 'TSModuleDeclaration':\n closedTypes.add(name);\n return [\n name,\n ...getNamespaceTypes(name, globalItem),\n ];\n case 'VariableDeclarator':\n if (/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n /** @type {import('@typescript-eslint/types').TSESTree.CallExpression} */ (\n globalItem?.init\n )?.callee)?.name === 'require'\n ) {\n imports.push(/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (\n globalItem.id\n ).name);\n break;\n }\n\n // Module scope names are also defined\n return [\n name,\n ];\n }\n\n return [\n name,\n ];\n /* c8 ignore next */\n }) : [],\n )\n .concat(extraTypes)\n .concat(typedefDeclarations)\n .concat(importTags)\n .concat(definedTypes)\n .concat(/** @type {string[]} */ (definedPreferredTypes))\n .concat((() => {\n // Other methods are not in scope, but we need them, and we grab them here\n if (node?.type === 'MethodDefinition') {\n return /** @type {import('estree').ClassBody} */ (node.parent).body.flatMap((methodOrProp) => {\n if (methodOrProp.type === 'MethodDefinition') {\n // eslint-disable-next-line unicorn/no-lonely-if -- Pattern\n if (methodOrProp.key.type === 'Identifier') {\n return [\n methodOrProp.key.name,\n `${/** @type {import('estree').ClassDeclaration} */ (\n node.parent?.parent\n )?.id?.name}.${methodOrProp.key.name}`,\n ];\n }\n }\n\n if (methodOrProp.type === 'PropertyDefinition') {\n // eslint-disable-next-line unicorn/no-lonely-if -- Pattern\n if (methodOrProp.key.type === 'Identifier') {\n return [\n methodOrProp.key.name,\n `${/** @type {import('estree').ClassDeclaration} */ (\n node.parent?.parent\n )?.id?.name}.${methodOrProp.key.name}`,\n ];\n }\n }\n /* c8 ignore next 2 -- Not yet built */\n\n return '';\n }).filter(Boolean);\n }\n\n return [];\n })())\n .concat((() => {\n // Detect static property assignments like `MyClass.Prop = ...`\n const programBody = /** @type {import('@typescript-eslint/types').TSESTree.Program} */ (\n sourceCode.ast\n ).body;\n\n return programBody.flatMap((statement) => {\n if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'AssignmentExpression' &&\n statement.expression.left.type === 'MemberExpression' &&\n statement.expression.left.object.type === 'Identifier' &&\n statement.expression.left.property.type === 'Identifier' &&\n closedTypes.has(statement.expression.left.object.name)\n ) {\n return [\n `${statement.expression.left.object.name}.${statement.expression.left.property.name}`,\n ];\n }\n\n return [];\n });\n })())\n .concat(...getValidRuntimeIdentifiers(node && (\n (sourceCode.getScope &&\n /* c8 ignore next 3 */\n sourceCode.getScope(node)) ||\n // @ts-expect-error ESLint 8\n context.getScope()\n )))\n .concat(\n settings.mode === 'jsdoc' ?\n [] :\n [\n ...settings.mode === 'typescript' ? typescriptGlobals : [],\n ...closureGenericTypes,\n ],\n ));\n\n /**\n * @typedef {{\n * parsedType: import('jsdoc-type-pratt-parser').RootResult;\n * tag: import('comment-parser').Spec|import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {\n * line?: import('../iterateJsdoc.js').Integer\n * }\n * }} TypeAndTagInfo\n */\n\n /**\n * @param {string} propertyName\n * @returns {(tag: (import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {\n * name?: string,\n * type?: string,\n * line?: import('../iterateJsdoc.js').Integer\n * })|import('comment-parser').Spec & {\n * namepathOrURL?: string\n * }\n * ) => undefined|TypeAndTagInfo}\n */\n const tagToParsedType = (propertyName) => {\n return (tag) => {\n try {\n const potentialType = tag[\n /** @type {\"type\"|\"name\"|\"namepathOrURL\"} */ (propertyName)\n ];\n return {\n parsedType: mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode),\n tag,\n };\n } catch {\n return undefined;\n }\n };\n };\n\n const typeTags = utils.filterTags(({\n tag,\n }) => {\n return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');\n }).map(tagToParsedType('type'));\n\n const namepathReferencingTags = utils.filterTags(({\n tag,\n }) => {\n return utils.isNamepathReferencingTag(tag);\n }).map(tagToParsedType('name'));\n\n const namepathOrUrlReferencingTags = utils.filterAllTags(({\n tag,\n }) => {\n return utils.isNamepathOrUrlReferencingTag(tag);\n }).map(tagToParsedType('namepathOrURL'));\n\n const definedNamesAndNamepaths = new Set(utils.filterTags(({\n tag,\n }) => {\n return utils.isNameOrNamepathDefiningTag(tag);\n }).map(({\n name,\n }) => {\n return name;\n }));\n\n const tagsWithTypes = /** @type {TypeAndTagInfo[]} */ ([\n ...typeTags,\n ...namepathReferencingTags,\n ...namepathOrUrlReferencingTags,\n // Remove types which failed to parse\n ].filter(Boolean));\n\n for (const {\n parsedType,\n tag,\n } of tagsWithTypes) {\n // eslint-disable-next-line complexity -- Refactor\n traverse(parsedType, (nde, parentNode) => {\n /**\n * @type {import('jsdoc-type-pratt-parser').NameResult & {\n * _parent?: import('jsdoc-type-pratt-parser').NonRootResult\n * }}\n */\n // eslint-disable-next-line canonical/id-match -- Avoid clashes\n (nde)._parent = parentNode;\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n\n let val = value;\n\n /** @type {import('jsdoc-type-pratt-parser').NonRootResult|undefined} */\n let currNode = nde;\n do {\n currNode =\n /**\n * @type {import('jsdoc-type-pratt-parser').NameResult & {\n * _parent?: import('jsdoc-type-pratt-parser').NonRootResult\n * }}\n */ (currNode)._parent;\n if (\n // Avoid appending for imports and globals since we don't want to\n // check their properties which may or may not exist\n !imports.includes(val) && !globals.includes(val) &&\n !importTags.includes(val) &&\n !extraTypes.includes(val) &&\n !typedefDeclarations.includes(val) &&\n !globalTypes.includes(val) &&\n currNode && 'right' in currNode &&\n currNode.right?.type === 'JsdocTypeProperty'\n ) {\n val = val + '.' + currNode.right.value;\n }\n } while (currNode?.type === 'JsdocTypeNamePath');\n\n if (type === 'JsdocTypeName') {\n const structuredTypes = structuredTags[tag.tag]?.type;\n const rootNamespace = val.split('.')[0];\n const isNamespaceValid = (definedTypes.includes(rootNamespace) || allDefinedTypes.has(rootNamespace)) &&\n !closedTypes.has(rootNamespace);\n\n if (!allDefinedTypes.has(val) &&\n !definedNamesAndNamepaths.has(val) &&\n (!Array.isArray(structuredTypes) || !structuredTypes.includes(val)) && !isNamespaceValid\n ) {\n const parent =\n /**\n * @type {import('jsdoc-type-pratt-parser').RootResult & {\n * _parent?: import('jsdoc-type-pratt-parser').NonRootResult\n * }}\n */ (nde)._parent;\n if (parent?.type === 'JsdocTypeTypeParameter') {\n return;\n }\n\n if (parent?.type === 'JsdocTypeFunction' &&\n /** @type {import('jsdoc-type-pratt-parser').FunctionResult} */\n (parent)?.typeParameters?.some((typeParam) => {\n return value === typeParam.name.value;\n })\n ) {\n return;\n }\n\n if (parent?.type === 'JsdocTypeInfer' && value === parent.element.value) {\n allDefinedTypes.add(value);\n return;\n }\n\n if (!disableReporting) {\n report(`The type '${val}' is undefined.`, null, tag);\n }\n } else if (markVariablesAsUsed && !extraTypes.includes(val)) {\n if (sourceCode.markVariableAsUsed) {\n sourceCode.markVariableAsUsed(val);\n /* c8 ignore next 4 */\n } else {\n // @ts-expect-error ESLint 8\n context.markVariableAsUsed(val);\n }\n }\n\n if (checkUsedTypedefs && typedefDeclarations.includes(val)) {\n foundTypedefValues.push(val);\n }\n }\n });\n }\n\n state.foundTypedefValues = foundTypedefValues;\n}, {\n // We use this method rather than checking at end of handler above because\n // in that case, it is invoked too many times and would thus report errors\n // too many times.\n exit ({\n context,\n state,\n utils,\n }) {\n const {\n checkUsedTypedefs = false,\n } = context.options[0] || {};\n\n if (!checkUsedTypedefs) {\n return;\n }\n\n const allComments = context.sourceCode.getAllComments();\n const comments = allComments\n .filter((comment) => {\n return (/^\\*(?!\\*)/v).test(comment.value);\n })\n .map((commentNode) => {\n return {\n doc: parseComment(commentNode, ''),\n loc: commentNode.loc,\n };\n });\n const typedefs = comments\n .flatMap(({\n doc,\n loc,\n }) => {\n const tags = doc.tags.filter(({\n tag,\n }) => {\n return utils.isNameOrNamepathDefiningTag(tag);\n });\n if (!tags.length) {\n return [];\n }\n\n return {\n loc,\n tags,\n };\n });\n\n for (const typedef of typedefs) {\n if (\n !state.foundTypedefValues.includes(typedef.tags[0].name)\n ) {\n context.report({\n loc: /** @type {import('@eslint/core').SourceLocation} */ (typedef.loc),\n message: 'This typedef was not used within the file',\n });\n }\n }\n },\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Besides some expected built-in types, prohibits any types not specified as globals or within `@typedef`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkUsedTypedefs: {\n description: 'Whether to check typedefs for use within the file',\n type: 'boolean',\n },\n definedTypes: {\n description: `This array can be populated to indicate other types which\nare automatically considered as defined (in addition to globals, etc.).\nDefaults to an empty array.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n disableReporting: {\n description: `Whether to disable reporting of errors. Defaults to\n\\`false\\`. This may be set to \\`true\\` in order to take advantage of only\nmarking defined variables as used or checking used typedefs.`,\n type: 'boolean',\n },\n markVariablesAsUsed: {\n description: `Whether to mark variables as used for the purposes\nof the \\`no-unused-vars\\` rule when they are not found to be undefined.\nDefaults to \\`true\\`. May be set to \\`false\\` to enforce a practice of not\nimporting types unless used in code.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAAE,aAAA,GAAAF,OAAA;AAMA,IAAAG,oBAAA,GAAAH,OAAA;AAE+B,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,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,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cA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WAAW,EAAE;AACzB;AACA,4BAA4B;UAChB2G,KAAK,EAAE;YACL1G,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDxC,gBAAgB,EAAE;UAChBuC,WAAW,EAAE;AACzB;AACA,6DAA6D;UACjDC,IAAI,EAAE;QACR,CAAC;QACDvC,mBAAmB,EAAE;UACnBsC,WAAW,EAAE;AACzB;AACA;AACA,qCAAqC;UACzBC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA2G,MAAA,CAAAjK,OAAA,GAAAA,OAAA,CAAAhB,OAAA","ignoreList":[]}
|
|
@@ -6,7 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
8
8
|
var _jsdocUtils = require("../jsdocUtils.cjs");
|
|
9
|
+
var _jsdoccomment = require("@es-joy/jsdoccomment");
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* @type {Partial<Record<import('../jsdocUtils.js').ParserMode, import('jsdoc-type-pratt-parser').ParseMode[]>>}
|
|
13
|
+
*/
|
|
14
|
+
const parseTypeModes = {
|
|
15
|
+
closure: ['closure'],
|
|
16
|
+
jsdoc: ['jsdoc'],
|
|
17
|
+
typescript: ['typescript']
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
/**
|
|
11
21
|
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
12
22
|
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
@@ -29,11 +39,32 @@ const canSkip = (utils, settings) => {
|
|
|
29
39
|
}
|
|
30
40
|
return utils.hasATag(voidingTags) || utils.isConstructor() || utils.classHasTag('interface') || settings.mode === 'closure' && utils.classHasTag('record');
|
|
31
41
|
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {import('jsdoc-type-pratt-parser').RootResult} parsedType
|
|
45
|
+
* @returns {import('jsdoc-type-pratt-parser').RootResult}
|
|
46
|
+
*/
|
|
47
|
+
const getReturnTypeLevelNode = parsedType => {
|
|
48
|
+
return parsedType.type === 'JsdocTypeParenthesis' ? parsedType.element : parsedType;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
53
|
+
* @param {import('../jsdocUtils.js').ParserMode} mode
|
|
54
|
+
* @returns {import('../jsdocUtils.js').ParserMode}
|
|
55
|
+
*/
|
|
56
|
+
const getParseMode = (context, mode) => {
|
|
57
|
+
const {
|
|
58
|
+
jsdoc
|
|
59
|
+
} = /** @type {{jsdoc?: {mode?: import('../jsdocUtils.js').ParserMode}}} */context.settings;
|
|
60
|
+
return jsdoc?.mode ?? mode;
|
|
61
|
+
};
|
|
32
62
|
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
33
63
|
context,
|
|
34
64
|
node,
|
|
35
65
|
report,
|
|
36
66
|
settings,
|
|
67
|
+
sourceCode,
|
|
37
68
|
utils
|
|
38
69
|
}) => {
|
|
39
70
|
const {
|
|
@@ -42,6 +73,10 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
42
73
|
noNativeTypes = true,
|
|
43
74
|
reportMissingReturnForUndefinedTypes = false
|
|
44
75
|
} = context.options[0] || {};
|
|
76
|
+
const {
|
|
77
|
+
mode
|
|
78
|
+
} = settings;
|
|
79
|
+
const parseMode = getParseMode(context, mode);
|
|
45
80
|
if (canSkip(utils, settings)) {
|
|
46
81
|
return;
|
|
47
82
|
}
|
|
@@ -71,6 +106,56 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
71
106
|
return;
|
|
72
107
|
}
|
|
73
108
|
const returnNever = type === 'never';
|
|
109
|
+
const typedefs = (0, _jsdocUtils.getDocumentNamepathDefiningTags)(sourceCode);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {import('comment-parser').Spec} returnTag
|
|
113
|
+
* @returns {boolean}
|
|
114
|
+
*/
|
|
115
|
+
const mayReturnUndefined = returnTag => {
|
|
116
|
+
if (utils.mayBeUndefinedTypeTag(returnTag)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const returnType = returnTag.type.trim();
|
|
120
|
+
let parsedType;
|
|
121
|
+
try {
|
|
122
|
+
parsedType = (0, _jsdoccomment.tryParse)(returnType, parseTypeModes[parseMode]);
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const returnTypeLevelNode = getReturnTypeLevelNode(parsedType);
|
|
127
|
+
let returnIsUndefined = false;
|
|
128
|
+
(0, _jsdoccomment.traverse)(returnTypeLevelNode, (nde, parentNode) => {
|
|
129
|
+
const isReturnLevelNode = !parentNode || returnTypeLevelNode.type === 'JsdocTypeUnion' && parentNode === returnTypeLevelNode;
|
|
130
|
+
if (!isReturnLevelNode) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const {
|
|
134
|
+
type: nodeType
|
|
135
|
+
} = /** @type {import('jsdoc-type-pratt-parser').RootResult} */nde;
|
|
136
|
+
if (nodeType === 'JsdocTypeUndefined') {
|
|
137
|
+
returnIsUndefined = true;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (nodeType !== 'JsdocTypeName') {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const {
|
|
144
|
+
value
|
|
145
|
+
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
146
|
+
if (value === 'void') {
|
|
147
|
+
returnIsUndefined = true;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const referencedTypedef = typedefs.find(typedefTag => {
|
|
151
|
+
return typedefTag.name === value;
|
|
152
|
+
});
|
|
153
|
+
if (referencedTypedef && utils.mayBeUndefinedTypeTag(referencedTypedef)) {
|
|
154
|
+
returnIsUndefined = true;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return returnIsUndefined;
|
|
158
|
+
};
|
|
74
159
|
if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {
|
|
75
160
|
report(`JSDoc @${tagName} declaration set with "never" but return expression is present in function.`);
|
|
76
161
|
return;
|
|
@@ -81,7 +166,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
81
166
|
}
|
|
82
167
|
|
|
83
168
|
// In case a return value is declared in JSDoc, we also expect one in the code.
|
|
84
|
-
if (!returnNever && (reportMissingReturnForUndefinedTypes || !
|
|
169
|
+
if (!returnNever && (reportMissingReturnForUndefinedTypes || !mayReturnUndefined(tag)) && (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync) || tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync, true)) && Boolean(!exemptGenerators || !node || !('generator' in (/** @type {import('../iterateJsdoc.js').Node} */node)) || !(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node).generator)) {
|
|
85
170
|
report(`JSDoc @${tagName} declaration present but return expression not available in function.`);
|
|
86
171
|
}
|
|
87
172
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireReturnsCheck.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdocUtils","e","__esModule","default","canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","_default","exports","iterateJsdoc","context","node","report","exemptAsync","exemptGenerators","noNativeTypes","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","type","trim","test","returnNever","hasValueOrExecutorHasNonEmptyResolveValue","strictNativeTypes","includes","mayBeUndefinedTypeTag","Boolean","generator","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n strictNativeTypes,\n} from '../jsdocUtils.js';\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Settings} settings\n * @returns {boolean}\n */\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n noNativeTypes = true,\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n const isAsync = utils.isAsync();\n if (exemptAsync && isAsync) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [\n tag,\n ] = tags;\n\n const type = tag.type.trim();\n\n // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions\n if (/asserts\\s/v.test(type)) {\n return;\n }\n\n const returnNever = type === 'never';\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n if (noNativeTypes && isAsync && strictNativeTypes.includes(type)) {\n report('Function is async or otherwise returns a Promise but the return type is a native type.');\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !utils.mayBeUndefinedTypeTag(tag)\n ) &&\n (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) ||\n tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n true,\n )) &&\n Boolean(\n !exemptGenerators || !node ||\n !('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) ||\n !(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator,\n )\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in JSDoc comment(and reports if multiple `@returns` tags are present).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n description: `By default, functions which return a \\`Promise\\` that are not\ndetected as resolving with a non-\\`undefined\\` value and \\`async\\` functions\n(even ones that do not explicitly return a value, as these are returning a\n\\`Promise\\` implicitly) will be exempted from reporting by this rule.\nIf you wish to insist that only \\`Promise\\`'s which resolve to\nnon-\\`undefined\\` values or \\`async\\` functions with explicit \\`return\\`'s will\nbe exempted from reporting (i.e., that \\`async\\` functions can be reported\nif they lack an explicit (non-\\`undefined\\`) \\`return\\` when a \\`@returns\\` is\npresent), you can set \\`exemptAsync\\` to \\`false\\` on the options object.`,\n type: 'boolean',\n },\n exemptGenerators: {\n description: `Because a generator might be labeled as having a\n\\`IterableIterator\\` \\`@returns\\` value (along with an iterator type\ncorresponding to the type of any \\`yield\\` statements), projects might wish to\nleverage \\`@returns\\` in generators even without a \\`return\\` statement. This\noption is therefore \\`true\\` by default in \\`typescript\\` mode (in \"jsdoc\" mode,\none might be more likely to take advantage of \\`@yields\\`). Set it to \\`false\\`\nif you wish for a missing \\`return\\` to be flagged regardless.`,\n type: 'boolean',\n },\n noNativeTypes: {\n description: `Whether to check that async functions do not\nindicate they return non-native types. Defaults to \\`true\\`.`,\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n description: `If \\`true\\` and no return or\nresolve value is found, this setting will even insist that reporting occur\nwith \\`void\\` or \\`undefined\\` (including as an indicated \\`Promise\\` type).\nUnlike \\`require-returns\\`, with this option in the rule, one can\n*discourage* the labeling of \\`undefined\\` types. 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;AACA,IAAAC,WAAA,GAAAD,OAAA;AAE0B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1B;AACA;AACA;AACA;AACA;AACA,MAAMG,OAAO,GAAGA,CAACC,KAAK,EAAEC,QAAQ,KAAK;EACnC,MAAMC,WAAW,GAAG;EAClB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,aAAa,EACb,WAAW,CACZ;EAED,IAAID,QAAQ,CAACE,IAAI,KAAK,SAAS,EAAE;IAC/B;IACAD,WAAW,CAACE,IAAI,CAAC,QAAQ,CAAC;EAC5B;EAEA,OAAOJ,KAAK,CAACK,OAAO,CAACH,WAAW,CAAC,IAC/BF,KAAK,CAACM,aAAa,CAAC,CAAC,IACrBN,KAAK,CAACO,WAAW,CAAC,WAAW,CAAC,IAC9BN,QAAQ,CAACE,IAAI,KAAK,SAAS,IAAIH,KAAK,CAACO,WAAW,CAAC,QAAQ,CAAC;AAC9D,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA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E,KAAK;UACdwC,WAAW,EAAE;AACzB;AACA;AACA;AACA,yEAAyE;UAC7DZ,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAiB,MAAA,CAAAlC,OAAA,GAAAA,OAAA,CAAAX,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"requireReturnsCheck.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdocUtils","_jsdoccomment","e","__esModule","default","parseTypeModes","closure","jsdoc","typescript","canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","getReturnTypeLevelNode","parsedType","type","element","getParseMode","context","_default","exports","iterateJsdoc","node","report","sourceCode","exemptAsync","exemptGenerators","noNativeTypes","reportMissingReturnForUndefinedTypes","options","parseMode","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","trim","test","returnNever","typedefs","getDocumentNamepathDefiningTags","mayReturnUndefined","returnTag","mayBeUndefinedTypeTag","returnType","tryParseType","returnTypeLevelNode","returnIsUndefined","traverse","nde","parentNode","isReturnLevelNode","nodeType","value","referencedTypedef","find","typedefTag","name","hasValueOrExecutorHasNonEmptyResolveValue","strictNativeTypes","includes","Boolean","generator","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n getDocumentNamepathDefiningTags,\n strictNativeTypes,\n} from '../jsdocUtils.js';\nimport {\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\n/**\n * @type {Partial<Record<import('../jsdocUtils.js').ParserMode, import('jsdoc-type-pratt-parser').ParseMode[]>>}\n */\nconst parseTypeModes = {\n closure: [\n 'closure',\n ],\n jsdoc: [\n 'jsdoc',\n ],\n typescript: [\n 'typescript',\n ],\n};\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Settings} settings\n * @returns {boolean}\n */\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\n/**\n * @param {import('jsdoc-type-pratt-parser').RootResult} parsedType\n * @returns {import('jsdoc-type-pratt-parser').RootResult}\n */\nconst getReturnTypeLevelNode = (parsedType) => {\n return parsedType.type === 'JsdocTypeParenthesis' ?\n parsedType.element :\n parsedType;\n};\n\n/**\n * @param {import('eslint').Rule.RuleContext} context\n * @param {import('../jsdocUtils.js').ParserMode} mode\n * @returns {import('../jsdocUtils.js').ParserMode}\n */\nconst getParseMode = (context, mode) => {\n const {\n jsdoc,\n } = /** @type {{jsdoc?: {mode?: import('../jsdocUtils.js').ParserMode}}} */ (context.settings);\n\n return jsdoc?.mode ?? mode;\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n noNativeTypes = true,\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n const {\n mode,\n } = settings;\n const parseMode = getParseMode(context, mode);\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n const isAsync = utils.isAsync();\n if (exemptAsync && isAsync) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [\n tag,\n ] = tags;\n\n const type = tag.type.trim();\n\n // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions\n if (/asserts\\s/v.test(type)) {\n return;\n }\n\n const returnNever = type === 'never';\n const typedefs = getDocumentNamepathDefiningTags(sourceCode);\n\n /**\n * @param {import('comment-parser').Spec} returnTag\n * @returns {boolean}\n */\n const mayReturnUndefined = (returnTag) => {\n if (utils.mayBeUndefinedTypeTag(returnTag)) {\n return true;\n }\n\n const returnType = returnTag.type.trim();\n let parsedType;\n try {\n parsedType = tryParseType(returnType, parseTypeModes[parseMode]);\n } catch {\n return false;\n }\n\n const returnTypeLevelNode = getReturnTypeLevelNode(parsedType);\n let returnIsUndefined = false;\n traverse(returnTypeLevelNode, (nde, parentNode) => {\n const isReturnLevelNode = !parentNode ||\n returnTypeLevelNode.type === 'JsdocTypeUnion' && parentNode === returnTypeLevelNode;\n if (!isReturnLevelNode) {\n return;\n }\n\n const {\n type: nodeType,\n } = /** @type {import('jsdoc-type-pratt-parser').RootResult} */ (nde);\n\n if (nodeType === 'JsdocTypeUndefined') {\n returnIsUndefined = true;\n return;\n }\n\n if (nodeType !== 'JsdocTypeName') {\n return;\n }\n\n const {\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n\n if (value === 'void') {\n returnIsUndefined = true;\n return;\n }\n\n const referencedTypedef = typedefs.find((typedefTag) => {\n return typedefTag.name === value;\n });\n\n if (referencedTypedef && utils.mayBeUndefinedTypeTag(referencedTypedef)) {\n returnIsUndefined = true;\n }\n });\n\n return returnIsUndefined;\n };\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n if (noNativeTypes && isAsync && strictNativeTypes.includes(type)) {\n report('Function is async or otherwise returns a Promise but the return type is a native type.');\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !mayReturnUndefined(tag)\n ) &&\n (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) ||\n tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n true,\n )) &&\n Boolean(\n !exemptGenerators || !node ||\n !('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) ||\n !(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator,\n )\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in JSDoc comment(and reports if multiple `@returns` tags are present).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n description: `By default, functions which return a \\`Promise\\` that are not\ndetected as resolving with a non-\\`undefined\\` value and \\`async\\` functions\n(even ones that do not explicitly return a value, as these are returning a\n\\`Promise\\` implicitly) will be exempted from reporting by this rule.\nIf you wish to insist that only \\`Promise\\`'s which resolve to\nnon-\\`undefined\\` values or \\`async\\` functions with explicit \\`return\\`'s will\nbe exempted from reporting (i.e., that \\`async\\` functions can be reported\nif they lack an explicit (non-\\`undefined\\`) \\`return\\` when a \\`@returns\\` is\npresent), you can set \\`exemptAsync\\` to \\`false\\` on the options object.`,\n type: 'boolean',\n },\n exemptGenerators: {\n description: `Because a generator might be labeled as having a\n\\`IterableIterator\\` \\`@returns\\` value (along with an iterator type\ncorresponding to the type of any \\`yield\\` statements), projects might wish to\nleverage \\`@returns\\` in generators even without a \\`return\\` statement. This\noption is therefore \\`true\\` by default in \\`typescript\\` mode (in \"jsdoc\" mode,\none might be more likely to take advantage of \\`@yields\\`). Set it to \\`false\\`\nif you wish for a missing \\`return\\` to be flagged regardless.`,\n type: 'boolean',\n },\n noNativeTypes: {\n description: `Whether to check that async functions do not\nindicate they return non-native types. Defaults to \\`true\\`.`,\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n description: `If \\`true\\` and no return or\nresolve value is found, this setting will even insist that reporting occur\nwith \\`void\\` or \\`undefined\\` (including as an indicated \\`Promise\\` type).\nUnlike \\`require-returns\\`, with this option in the rule, one can\n*discourage* the labeling of \\`undefined\\` types. 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;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA,IAAAE,aAAA,GAAAF,OAAA;AAG8B,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9B;AACA;AACA;AACA,MAAMG,cAAc,GAAG;EACrBC,OAAO,EAAE,CACP,SAAS,CACV;EACDC,KAAK,EAAE,CACL,OAAO,CACR;EACDC,UAAU,EAAE,CACV,YAAY;AAEhB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,OAAO,GAAGA,CAACC,KAAK,EAAEC,QAAQ,KAAK;EACnC,MAAMC,WAAW,GAAG;EAClB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,aAAa,EACb,WAAW,CACZ;EAED,IAAID,QAAQ,CAACE,IAAI,KAAK,SAAS,EAAE;IAC/B;IACAD,WAAW,CAACE,IAAI,CAAC,QAAQ,CAAC;EAC5B;EAEA,OAAOJ,KAAK,CAACK,OAAO,CAACH,WAAW,CAAC,IAC/BF,KAAK,CAACM,aAAa,CAAC,CAAC,IACrBN,KAAK,CAACO,WAAW,CAAC,WAAW,CAAC,IAC9BN,Q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AAO,CACL,CAACrC,gBAAgB,IAAI,CAACJ,IAAI,IAC1B,EAAE,WAAW,KAAI,gDAAkDA,IAAI,CAAC,CAAC,IACzE,CAAC,CAAC,8EAAgFA,IAAI,EAAG0C,SAC3F,CAAC,EACD;IACAzC,MAAM,CAAC,UAAUS,OAAO,uEAAuE,CAAC;EAClG;AACF,CAAC,EAAE;EACDiC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,sJAAsJ;MACnKC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV9C,WAAW,EAAE;UACX1B,OAAO,EAAE,IAAI;UACboE,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E;UAC9DpD,IAAI,EAAE;QACR,CAAC;QACDW,gBAAgB,EAAE;UAChByC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA,+DAA+D;UACnDpD,IAAI,EAAE;QACR,CAAC;QACDY,aAAa,EAAE;UACbwC,WAAW,EAAE;AACzB,6DAA6D;UACjDpD,IAAI,EAAE;QACR,CAAC;QACDa,oCAAoC,EAAE;UACpC7B,OAAO,EAAE,KAAK;UACdoE,WAAW,EAAE;AACzB;AACA;AACA;AACA,yEAAyE;UAC7DpD,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAyD,MAAA,CAAApD,OAAA,GAAAA,OAAA,CAAArB,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"html-entities": "^2.6.0",
|
|
17
17
|
"object-deep-merge": "^2.0.1",
|
|
18
18
|
"parse-imports-exports": "^0.2.4",
|
|
19
|
-
"semver": "^7.8.
|
|
19
|
+
"semver": "^7.8.2",
|
|
20
20
|
"spdx-expression-parse": "^4.0.0",
|
|
21
21
|
"to-valid-identifier": "^1.0.0"
|
|
22
22
|
},
|
|
23
23
|
"description": "JSDoc linting rules for ESLint.",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@arethetypeswrong/cli": "^0.18.
|
|
25
|
+
"@arethetypeswrong/cli": "^0.18.3",
|
|
26
26
|
"@babel/cli": "8.0.0-rc.5",
|
|
27
27
|
"@babel/core": "8.0.0-rc.5",
|
|
28
28
|
"@babel/eslint-parser": "8.0.0-rc.5",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"@types/estree": "^1.0.9",
|
|
43
43
|
"@types/json-schema": "^7.0.15",
|
|
44
44
|
"@types/mocha": "^10.0.10",
|
|
45
|
-
"@types/node": "^25.9.
|
|
45
|
+
"@types/node": "^25.9.2",
|
|
46
46
|
"@types/semver": "^7.7.1",
|
|
47
47
|
"@types/spdx-expression-parse": "^4.0.0",
|
|
48
|
-
"@typescript-eslint/types": "8.
|
|
48
|
+
"@typescript-eslint/types": "8.60.1",
|
|
49
49
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
50
50
|
"babel-plugin-istanbul": "^8.0.0",
|
|
51
51
|
"babel-plugin-transform-import-meta": "^2.3.3",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"camelcase": "^9.0.0",
|
|
54
54
|
"chai": "^6.2.2",
|
|
55
55
|
"decamelize": "^6.0.1",
|
|
56
|
-
"eslint": "10.4.
|
|
56
|
+
"eslint": "10.4.1",
|
|
57
57
|
"eslint-config-canonical": "^47.4.2",
|
|
58
58
|
"gitdown": "^4.1.1",
|
|
59
59
|
"glob": "^13.0.6",
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
"jsdoc-type-pratt-parser": "^7.2.0",
|
|
63
63
|
"json-schema": "^0.4.0",
|
|
64
64
|
"json-schema-to-typescript": "^15.0.4",
|
|
65
|
-
"lint-staged": "^17.0.
|
|
65
|
+
"lint-staged": "^17.0.7",
|
|
66
66
|
"mocha": "^11.7.6",
|
|
67
67
|
"open-editor": "^6.0.0",
|
|
68
68
|
"playwright": "^1.60.0",
|
|
69
69
|
"replace": "^1.2.2",
|
|
70
70
|
"rimraf": "^6.1.3",
|
|
71
|
-
"rollup": "^4.
|
|
71
|
+
"rollup": "^4.61.1",
|
|
72
72
|
"semantic-release": "^25.0.3",
|
|
73
73
|
"sinon": "^22.0.0",
|
|
74
74
|
"ts-api-utils": "^2.5.0",
|
|
75
75
|
"typescript": "5.9.3",
|
|
76
|
-
"typescript-eslint": "8.
|
|
76
|
+
"typescript-eslint": "8.60.1"
|
|
77
77
|
},
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": "^22.13.0 || >=24"
|
|
@@ -179,5 +179,5 @@
|
|
|
179
179
|
"test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
|
|
180
180
|
"test-index": "pnpm run test-no-cov test/rules/index.js"
|
|
181
181
|
},
|
|
182
|
-
"version": "63.0.
|
|
182
|
+
"version": "63.0.2"
|
|
183
183
|
}
|
package/src/jsdocUtils.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from './tagNames.js';
|
|
7
7
|
import WarnSettings from './WarnSettings.js';
|
|
8
8
|
import {
|
|
9
|
+
parseComment,
|
|
9
10
|
stringify,
|
|
10
11
|
tryParse,
|
|
11
12
|
} from '@es-joy/jsdoccomment';
|
|
@@ -1084,6 +1085,41 @@ const isNameOrNamepathDefiningTag = (tag, tagMap = tagStructure) => {
|
|
|
1084
1085
|
tagStruct.get('namepathRole')));
|
|
1085
1086
|
};
|
|
1086
1087
|
|
|
1088
|
+
/**
|
|
1089
|
+
* @param {import('eslint').SourceCode} sourceCode
|
|
1090
|
+
* @returns {import('@es-joy/jsdoccomment').JsdocBlockWithInline[]}
|
|
1091
|
+
*/
|
|
1092
|
+
const getJSDocCommentBlocks = (sourceCode) => {
|
|
1093
|
+
return sourceCode.getAllComments()
|
|
1094
|
+
.filter((comment) => {
|
|
1095
|
+
return (/^\*(?!\*)/v).test(comment.value);
|
|
1096
|
+
})
|
|
1097
|
+
.map((commentNode) => {
|
|
1098
|
+
return parseComment(commentNode, '');
|
|
1099
|
+
});
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* @param {import('eslint').SourceCode} sourceCode
|
|
1104
|
+
* @returns {import('comment-parser').Spec[]}
|
|
1105
|
+
*/
|
|
1106
|
+
const getDocumentNamepathDefiningTags = (sourceCode) => {
|
|
1107
|
+
return getJSDocCommentBlocks(sourceCode)
|
|
1108
|
+
.flatMap((doc) => {
|
|
1109
|
+
return doc.tags.filter(({
|
|
1110
|
+
tag,
|
|
1111
|
+
}) => {
|
|
1112
|
+
return isNameOrNamepathDefiningTag(tag) && ![
|
|
1113
|
+
'arg',
|
|
1114
|
+
'argument',
|
|
1115
|
+
'param',
|
|
1116
|
+
'prop',
|
|
1117
|
+
'property',
|
|
1118
|
+
].includes(tag);
|
|
1119
|
+
});
|
|
1120
|
+
});
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1087
1123
|
/**
|
|
1088
1124
|
* @param {string} tag
|
|
1089
1125
|
* @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
|
|
@@ -2110,9 +2146,11 @@ export {
|
|
|
2110
2146
|
forEachPreferredTag,
|
|
2111
2147
|
getAllTags,
|
|
2112
2148
|
getContextObject,
|
|
2149
|
+
getDocumentNamepathDefiningTags,
|
|
2113
2150
|
getFunctionParameterNames,
|
|
2114
2151
|
getIndent,
|
|
2115
2152
|
getInlineTags,
|
|
2153
|
+
getJSDocCommentBlocks,
|
|
2116
2154
|
getJsdocTagsDeep,
|
|
2117
2155
|
getPreferredTagName,
|
|
2118
2156
|
getPreferredTagNameSimple,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import iterateJsdoc, {
|
|
2
2
|
parseComment,
|
|
3
3
|
} from '../iterateJsdoc.js';
|
|
4
|
+
import {
|
|
5
|
+
getDocumentNamepathDefiningTags,
|
|
6
|
+
getJSDocCommentBlocks,
|
|
7
|
+
} from '../jsdocUtils.js';
|
|
4
8
|
import {
|
|
5
9
|
getJSDocComment,
|
|
6
10
|
parse as parseType,
|
|
@@ -123,13 +127,7 @@ export default iterateJsdoc(({
|
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
const allComments = sourceCode.getAllComments();
|
|
126
|
-
const comments =
|
|
127
|
-
.filter((comment) => {
|
|
128
|
-
return (/^\*(?!\*)/v).test(comment.value);
|
|
129
|
-
})
|
|
130
|
-
.map((commentNode) => {
|
|
131
|
-
return parseComment(commentNode, '');
|
|
132
|
-
});
|
|
130
|
+
const comments = getJSDocCommentBlocks(sourceCode);
|
|
133
131
|
|
|
134
132
|
const globals = allComments
|
|
135
133
|
.filter((comment) => {
|
|
@@ -138,20 +136,7 @@ export default iterateJsdoc(({
|
|
|
138
136
|
return commentNode.value.replace(/^\s*globals/v, '').trim().split(/,\s*/v);
|
|
139
137
|
}).concat(Object.keys(context.languageOptions.globals ?? []));
|
|
140
138
|
|
|
141
|
-
const typedefs =
|
|
142
|
-
.flatMap((doc) => {
|
|
143
|
-
return doc.tags.filter(({
|
|
144
|
-
tag,
|
|
145
|
-
}) => {
|
|
146
|
-
return utils.isNameOrNamepathDefiningTag(tag) && ![
|
|
147
|
-
'arg',
|
|
148
|
-
'argument',
|
|
149
|
-
'param',
|
|
150
|
-
'prop',
|
|
151
|
-
'property',
|
|
152
|
-
].includes(tag);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
139
|
+
const typedefs = getDocumentNamepathDefiningTags(sourceCode);
|
|
155
140
|
|
|
156
141
|
const typedefDeclarations = typedefs
|
|
157
142
|
.map((tag) => {
|