eslint-plugin-jsdoc 61.3.0 → 61.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"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","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 'link', 'linkcode', 'linkplain', 'tutorial',\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 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 if (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'\\``,\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,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD;AAC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,KAAK;MAC3BC,UAAU,EAAE;QACVvE,WAAW,EAAE;UACXuC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;UACKiC,KAAK,EAAE;YACLhD,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDvB,WAAW,EAAE;UACXsC,WAAW,EAAE,uGAAuG;UACpHf,IAAI,EAAE;QACR,CAAC;QACDtB,UAAU,EAAE;UACVqC,WAAW,EAAE;AACzB;AACA,qEAAqE;UACzDiC,KAAK,EAAE;YACLhD,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDrB,OAAO,EAAE;UACPoC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kHAAkH;UACtGf,IAAI,EAAE;QACR,CAAC;QACDpB,KAAK,EAAE;UACLmC,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;UACKf,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAiD,MAAA,CAAAnF,OAAA,GAAAA,OAAA,CAAAP,OAAA","ignoreList":[]}
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 'link', 'linkcode', 'linkplain', 'tutorial',\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 -- Support old ESLint */\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 -- Support old ESLint */\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'\\``,\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,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD;AACA,MAAMG,WAAW,GAAG,IAAIC,GAAG,CAAC,CAC1B,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,YAAY,CACb,CAAC;AAEF,MAAMC,0BAA0B,GAAG,IAAID,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,CAA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GAAuG;UACpHhB,IAAI,EAAE;QACR,CAAC;QACDtB,UAAU,EAAE;UACVsC,WAAW,EAAE;AACzB;AACA,qEAAqE;UACzDiC,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":[]}
@@ -0,0 +1,226 @@
1
+ "use strict";
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
+ /**
10
+ * Checks if a node or its children contain Promise rejection patterns
11
+ * @param {import('eslint').Rule.Node} node
12
+ * @param {boolean} [innerFunction]
13
+ * @param {boolean} [isAsync]
14
+ * @returns {boolean}
15
+ */
16
+ // eslint-disable-next-line complexity -- Temporary
17
+ const hasRejectValue = (node, innerFunction, isAsync) => {
18
+ if (!node) {
19
+ return false;
20
+ }
21
+ switch (node.type) {
22
+ case 'ArrowFunctionExpression':
23
+ case 'FunctionDeclaration':
24
+ case 'FunctionExpression':
25
+ {
26
+ // For inner functions in async contexts, check if they throw
27
+ // (they could be called and cause rejection)
28
+ if (innerFunction) {
29
+ // Check inner functions for throws - if called from async context, throws become rejections
30
+ const innerIsAsync = node.async;
31
+ // Pass isAsync=true if the inner function is async OR if we're already in an async context
32
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.body, false, innerIsAsync || isAsync);
33
+ }
34
+
35
+ // This is the top-level function we're checking
36
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.body, true, node.async);
37
+ }
38
+ case 'BlockStatement':
39
+ {
40
+ return node.body.some(bodyNode => {
41
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */bodyNode, innerFunction, isAsync);
42
+ });
43
+ }
44
+ case 'CallExpression':
45
+ {
46
+ // Check for Promise.reject()
47
+ if (node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && node.callee.object.name === 'Promise' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'reject') {
48
+ return true;
49
+ }
50
+
51
+ // Check for reject() call (in Promise executor context)
52
+ if (node.callee.type === 'Identifier' && node.callee.name === 'reject') {
53
+ return true;
54
+ }
55
+
56
+ // Check if this is calling an inner function that might reject
57
+ if (innerFunction && node.callee.type === 'Identifier') {
58
+ // We found a function call inside - check if it could be calling a function that rejects
59
+ // We'll handle this in function body traversal
60
+ return false;
61
+ }
62
+ return false;
63
+ }
64
+ case 'DoWhileStatement':
65
+ case 'ForInStatement':
66
+ case 'ForOfStatement':
67
+ case 'ForStatement':
68
+ case 'LabeledStatement':
69
+ case 'WhileStatement':
70
+ case 'WithStatement':
71
+ {
72
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.body, innerFunction, isAsync);
73
+ }
74
+ case 'ExpressionStatement':
75
+ {
76
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.expression, innerFunction, isAsync);
77
+ }
78
+ case 'IfStatement':
79
+ {
80
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.consequent, innerFunction, isAsync) || hasRejectValue(/** @type {import('eslint').Rule.Node} */node.alternate, innerFunction, isAsync);
81
+ }
82
+ case 'NewExpression':
83
+ {
84
+ // Check for new Promise((resolve, reject) => { reject(...) })
85
+ if (node.callee.type === 'Identifier' && node.callee.name === 'Promise' && node.arguments.length > 0) {
86
+ const executor = node.arguments[0];
87
+ if (executor.type === 'ArrowFunctionExpression' || executor.type === 'FunctionExpression') {
88
+ // Check if the executor has reject() calls
89
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */executor.body, false, false);
90
+ }
91
+ }
92
+ return false;
93
+ }
94
+ case 'ReturnStatement':
95
+ {
96
+ if (node.argument) {
97
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.argument, innerFunction, isAsync);
98
+ }
99
+ return false;
100
+ }
101
+ case 'SwitchStatement':
102
+ {
103
+ return node.cases.some(someCase => {
104
+ return someCase.consequent.some(nde => {
105
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */nde, innerFunction, isAsync);
106
+ });
107
+ });
108
+ }
109
+
110
+ // Throw statements in async functions become rejections
111
+ case 'ThrowStatement':
112
+ {
113
+ return isAsync === true;
114
+ }
115
+ case 'TryStatement':
116
+ {
117
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node.handler && node.handler.body, innerFunction, isAsync) || hasRejectValue(/** @type {import('eslint').Rule.Node} */node.finalizer, innerFunction, isAsync);
118
+ }
119
+ default:
120
+ {
121
+ return false;
122
+ }
123
+ }
124
+ };
125
+
126
+ /**
127
+ * We can skip checking for a rejects value, in case the documentation is inherited
128
+ * or the method is abstract.
129
+ * @param {import('../iterateJsdoc.js').Utils} utils
130
+ * @returns {boolean}
131
+ */
132
+ const canSkip = utils => {
133
+ return utils.hasATag(['abstract', 'virtual', 'type']) || utils.avoidDocs();
134
+ };
135
+ var _default = exports.default = (0, _iterateJsdoc.default)(({
136
+ node,
137
+ report,
138
+ utils
139
+ }) => {
140
+ if (canSkip(utils)) {
141
+ return;
142
+ }
143
+ const tagName = /** @type {string} */utils.getPreferredTagName({
144
+ tagName: 'rejects'
145
+ });
146
+ if (!tagName) {
147
+ return;
148
+ }
149
+ const tags = utils.getTags(tagName);
150
+ const iteratingFunction = utils.isIteratingFunction();
151
+ const [tag] = tags;
152
+ const missingRejectsTag = typeof tag === 'undefined' || tag === null;
153
+ const shouldReport = () => {
154
+ if (!missingRejectsTag) {
155
+ return false;
156
+ }
157
+
158
+ // Check if this is an async function or returns a Promise
159
+ const isAsync = utils.isAsync();
160
+ if (!isAsync && !iteratingFunction) {
161
+ return false;
162
+ }
163
+
164
+ // For async functions, check for throw statements
165
+ // For regular functions, check for Promise.reject or reject calls
166
+ return hasRejectValue(/** @type {import('eslint').Rule.Node} */node);
167
+ };
168
+ if (shouldReport()) {
169
+ report('Promise-rejecting function requires `@reject` tag');
170
+ }
171
+ }, {
172
+ contextDefaults: true,
173
+ meta: {
174
+ docs: {
175
+ description: 'Requires that Promise rejections are documented with `@rejects` tags.',
176
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-rejects.md#repos-sticky-header'
177
+ },
178
+ schema: [{
179
+ additionalProperties: false,
180
+ properties: {
181
+ contexts: {
182
+ description: `Set this to an array of strings representing the AST context
183
+ (or objects with optional \`context\` and \`comment\` properties) where you wish
184
+ the rule to be applied.
185
+
186
+ \`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
187
+
188
+ Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
189
+ \`FunctionExpression\`).`,
190
+ items: {
191
+ anyOf: [{
192
+ type: 'string'
193
+ }, {
194
+ additionalProperties: false,
195
+ properties: {
196
+ comment: {
197
+ type: 'string'
198
+ },
199
+ context: {
200
+ type: 'string'
201
+ }
202
+ },
203
+ type: 'object'
204
+ }]
205
+ },
206
+ type: 'array'
207
+ },
208
+ exemptedBy: {
209
+ description: `Array of tags (e.g., \`['type']\`) whose presence on the
210
+ document block avoids the need for a \`@rejects\`. Defaults to an array
211
+ with \`abstract\`, \`virtual\`, and \`type\`. If you set this array, it will overwrite the default,
212
+ so be sure to add back those tags if you wish their presence to cause
213
+ exemption of the rule.`,
214
+ items: {
215
+ type: 'string'
216
+ },
217
+ type: 'array'
218
+ }
219
+ },
220
+ type: 'object'
221
+ }],
222
+ type: 'suggestion'
223
+ }
224
+ });
225
+ module.exports = exports.default;
226
+ //# sourceMappingURL=requireRejects.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireRejects.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","hasRejectValue","node","innerFunction","isAsync","type","innerIsAsync","async","body","some","bodyNode","callee","object","name","property","expression","consequent","alternate","arguments","length","executor","argument","cases","someCase","nde","handler","finalizer","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingRejectsTag","shouldReport","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exemptedBy","module"],"sources":["../../src/rules/requireRejects.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * Checks if a node or its children contain Promise rejection patterns\n * @param {import('eslint').Rule.Node} node\n * @param {boolean} [innerFunction]\n * @param {boolean} [isAsync]\n * @returns {boolean}\n */\n// eslint-disable-next-line complexity -- Temporary\nconst hasRejectValue = (node, innerFunction, isAsync) => {\n if (!node) {\n return false;\n }\n\n switch (node.type) {\n case 'ArrowFunctionExpression':\n case 'FunctionDeclaration':\n case 'FunctionExpression': {\n // For inner functions in async contexts, check if they throw\n // (they could be called and cause rejection)\n if (innerFunction) {\n // Check inner functions for throws - if called from async context, throws become rejections\n const innerIsAsync = node.async;\n // Pass isAsync=true if the inner function is async OR if we're already in an async context\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), false, innerIsAsync || isAsync);\n }\n\n // This is the top-level function we're checking\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), true, node.async);\n }\n\n case 'BlockStatement': {\n return node.body.some((bodyNode) => {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (bodyNode), innerFunction, isAsync);\n });\n }\n\n case 'CallExpression': {\n // Check for Promise.reject()\n if (node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'Promise' &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'reject') {\n return true;\n }\n\n // Check for reject() call (in Promise executor context)\n if (node.callee.type === 'Identifier' && node.callee.name === 'reject') {\n return true;\n }\n\n // Check if this is calling an inner function that might reject\n if (innerFunction && node.callee.type === 'Identifier') {\n // We found a function call inside - check if it could be calling a function that rejects\n // We'll handle this in function body traversal\n return false;\n }\n\n return false;\n }\n\n case 'DoWhileStatement':\n case 'ForInStatement':\n case 'ForOfStatement':\n case 'ForStatement':\n case 'LabeledStatement':\n case 'WhileStatement':\n\n case 'WithStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), innerFunction, isAsync);\n }\n\n case 'ExpressionStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.expression), innerFunction, isAsync);\n }\n\n case 'IfStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.consequent), innerFunction, isAsync) || hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.alternate), innerFunction, isAsync);\n }\n\n case 'NewExpression': {\n // Check for new Promise((resolve, reject) => { reject(...) })\n if (node.callee.type === 'Identifier' && node.callee.name === 'Promise' && node.arguments.length > 0) {\n const executor = node.arguments[0];\n if (executor.type === 'ArrowFunctionExpression' || executor.type === 'FunctionExpression') {\n // Check if the executor has reject() calls\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (executor.body), false, false);\n }\n }\n\n return false;\n }\n\n case 'ReturnStatement': {\n if (node.argument) {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.argument), innerFunction, isAsync);\n }\n\n return false;\n }\n\n case 'SwitchStatement': {\n return node.cases.some(\n (someCase) => {\n return someCase.consequent.some((nde) => {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (nde), innerFunction, isAsync);\n });\n },\n );\n }\n\n // Throw statements in async functions become rejections\n case 'ThrowStatement': {\n return isAsync === true;\n }\n\n case 'TryStatement': {\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.handler && node.handler.body), innerFunction, isAsync) ||\n hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.finalizer), innerFunction, isAsync);\n }\n\n default: {\n return false;\n }\n }\n};\n\n/**\n * We can skip checking for a rejects value, in case the documentation is inherited\n * or the method is abstract.\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @returns {boolean}\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n 'abstract',\n 'virtual',\n 'type',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n node,\n report,\n utils,\n}) => {\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'rejects',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n const [\n tag,\n ] = tags;\n const missingRejectsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingRejectsTag) {\n return false;\n }\n\n // Check if this is an async function or returns a Promise\n const isAsync = utils.isAsync();\n if (!isAsync && !iteratingFunction) {\n return false;\n }\n\n // For async functions, check for throw statements\n // For regular functions, check for Promise.reject or reject calls\n return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node));\n };\n\n if (shouldReport()) {\n report('Promise-rejecting function requires `@reject` tag');\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that Promise rejections are documented with `@rejects` tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-rejects.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`).`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@rejects\\`. Defaults to an array\nwith \\`abstract\\`, \\`virtual\\`, and \\`type\\`. If you set this array, it will overwrite the default,\nso be sure to add back those tags if you wish their presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,cAAc,GAAGA,CAACC,IAAI,EAAEC,aAAa,EAAEC,OAAO,KAAK;EACvD,IAAI,CAACF,IAAI,EAAE;IACT,OAAO,KAAK;EACd;EAEA,QAAQA,IAAI,CAACG,IAAI;IACf,KAAK,yBAAyB;IAC9B,KAAK,qBAAqB;IAC1B,KAAK,oBAAoB;MAAE;QACzB;QACA;QACA,IAAIF,aAAa,EAAE;UACjB;UACA,MAAMG,YAAY,GAAGJ,IAAI,CAACK,KAAK;UAC/B;UACA,OAAON,cAAc,CAAC,yCAA2CC,IAAI,CAACM,IAAI,EAAG,KAAK,EAAEF,YAAY,IA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OAAO,GAAGwB,KAAK,CAACxB,OAAO,CAAC,CAAC;IAC/B,IAAI,CAACA,OAAO,IAAI,CAACmC,iBAAiB,EAAE;MAClC,OAAO,KAAK;IACd;;IAEA;IACA;IACA,OAAOtC,cAAc,CAAC,yCAA2CC,IAAK,CAAC;EACzE,CAAC;EAED,IAAIyC,YAAY,CAAC,CAAC,EAAE;IAClBT,MAAM,CAAC,mDAAmD,CAAC;EAC7D;AACF,CAAC,EAAE;EACDU,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,uEAAuE;MACpFC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRL,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;UACbM,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEjD,IAAI,EAAE;YACR,CAAC,EACD;cACE6C,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACPlD,IAAI,EAAE;gBACR,CAAC;gBACDmD,OAAO,EAAE;kBACPnD,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDoD,UAAU,EAAE;UACVV,WAAW,EAAE;AACzB;AACA;AACA;AACA,uBAAuB;UACXM,KAAK,EAAE;YACLhD,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAqD,MAAA,CAAA1B,OAAA,GAAAA,OAAA,CAAAhC,OAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("eslint").Rule.RuleModule;
2
+ export default _default;
3
+ //# sourceMappingURL=requireRejects.d.ts.map
package/dist/rules.d.ts CHANGED
@@ -2196,6 +2196,39 @@ export interface Rules {
2196
2196
  /** Requires that each `@property` tag has a type value (in curly brackets). */
2197
2197
  "jsdoc/require-property-type": [];
2198
2198
 
2199
+ /** Requires that Promise rejections are documented with `@rejects` tags. */
2200
+ "jsdoc/require-rejects":
2201
+ | []
2202
+ | [
2203
+ {
2204
+ /**
2205
+ * Set this to an array of strings representing the AST context
2206
+ * (or objects with optional `context` and `comment` properties) where you wish
2207
+ * the rule to be applied.
2208
+ *
2209
+ * `context` defaults to `any` and `comment` defaults to no specific comment context.
2210
+ *
2211
+ * Overrides the default contexts (`ArrowFunctionExpression`, `FunctionDeclaration`,
2212
+ * `FunctionExpression`).
2213
+ */
2214
+ contexts?: (
2215
+ | string
2216
+ | {
2217
+ comment?: string;
2218
+ context?: string;
2219
+ }
2220
+ )[];
2221
+ /**
2222
+ * Array of tags (e.g., `['type']`) whose presence on the
2223
+ * document block avoids the need for a `@rejects`. Defaults to an array
2224
+ * with `abstract`, `virtual`, and `type`. If you set this array, it will overwrite the default,
2225
+ * so be sure to add back those tags if you wish their presence to cause
2226
+ * exemption of the rule.
2227
+ */
2228
+ exemptedBy?: string[];
2229
+ }
2230
+ ];
2231
+
2199
2232
  /** Requires that returns are documented with `@returns`. */
2200
2233
  "jsdoc/require-returns":
2201
2234
  | []
package/package.json CHANGED
@@ -192,5 +192,5 @@
192
192
  "test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
193
193
  "test-index": "pnpm run test-no-cov test/rules/index.js"
194
194
  },
195
- "version": "61.3.0"
195
+ "version": "61.4.1"
196
196
  }
@@ -9,6 +9,27 @@ import {
9
9
  util,
10
10
  } from 'comment-parser';
11
11
 
12
+ /**
13
+ * Detects if a line starts with a markdown list marker
14
+ * Supports: -, *, numbered lists (1., 2., etc.)
15
+ * This explicitly excludes hyphens that are part of JSDoc tag syntax
16
+ * @param {string} text - The text to check
17
+ * @param {boolean} isFirstLineOfTag - True if this is the first line (tag line)
18
+ * @returns {boolean} - True if the text starts with a list marker
19
+ */
20
+ const startsWithListMarker = (text, isFirstLineOfTag = false) => {
21
+ // On the first line of a tag, the hyphen is typically the JSDoc separator,
22
+ // not a list marker
23
+ if (isFirstLineOfTag) {
24
+ return false;
25
+ }
26
+
27
+ // Match lines that start with optional whitespace, then a list marker
28
+ // - or * followed by a space
29
+ // or a number followed by . or ) and a space
30
+ return /^\s*(?:[\-*]|\d+(?:\.|\)))\s+/v.test(text);
31
+ };
32
+
12
33
  /**
13
34
  * @typedef {{
14
35
  * hasNoTypes: boolean,
@@ -144,6 +165,59 @@ const space = (len) => {
144
165
  return ''.padStart(len, ' ');
145
166
  };
146
167
 
168
+ /**
169
+ * Check if a tag or any of its lines contain list markers
170
+ * @param {import('./iterateJsdoc.js').Integer} index - Current line index
171
+ * @param {import('comment-parser').Line[]} source - All source lines
172
+ * @returns {{hasListMarker: boolean, tagStartIndex: import('./iterateJsdoc.js').Integer}}
173
+ */
174
+ const checkForListMarkers = (index, source) => {
175
+ let hasListMarker = false;
176
+ let tagStartIndex = index;
177
+ while (tagStartIndex > 0 && source[tagStartIndex].tokens.tag === '') {
178
+ tagStartIndex--;
179
+ }
180
+
181
+ for (let idx = tagStartIndex; idx <= index; idx++) {
182
+ const isFirstLine = (idx === tagStartIndex);
183
+ if (source[idx]?.tokens?.description && startsWithListMarker(source[idx].tokens.description, isFirstLine)) {
184
+ hasListMarker = true;
185
+ break;
186
+ }
187
+ }
188
+
189
+ return {
190
+ hasListMarker,
191
+ tagStartIndex,
192
+ };
193
+ };
194
+
195
+ /**
196
+ * Calculate extra indentation for list items relative to the first continuation line
197
+ * @param {import('./iterateJsdoc.js').Integer} index - Current line index
198
+ * @param {import('./iterateJsdoc.js').Integer} tagStartIndex - Index of the tag line
199
+ * @param {import('comment-parser').Line[]} source - All source lines
200
+ * @returns {string} - Extra indentation spaces
201
+ */
202
+ const calculateListExtraIndent = (index, tagStartIndex, source) => {
203
+ // Find the first continuation line to use as baseline
204
+ let firstContinuationIndent = null;
205
+ for (let idx = tagStartIndex + 1; idx < source.length; idx++) {
206
+ if (source[idx].tokens.description && !source[idx].tokens.tag) {
207
+ firstContinuationIndent = source[idx].tokens.postDelimiter.length;
208
+ break;
209
+ }
210
+ }
211
+
212
+ // Calculate the extra indentation of current line relative to the first continuation line
213
+ const currentOriginalIndent = source[index].tokens.postDelimiter.length;
214
+ const extraIndent = firstContinuationIndent !== null && currentOriginalIndent > firstContinuationIndent ?
215
+ ' '.repeat(currentOriginalIndent - firstContinuationIndent) :
216
+ '';
217
+
218
+ return extraIndent;
219
+ };
220
+
147
221
  /**
148
222
  * @param {{
149
223
  * customSpacings: import('../src/rules/checkLineAlignment.js').CustomSpacings,
@@ -316,8 +390,20 @@ const alignTransform = ({
316
390
  // Not align.
317
391
  if (shouldAlign(tags, index, source)) {
318
392
  alignTokens(tokens, typelessInfo);
393
+
319
394
  if (!disableWrapIndent && indentTag) {
320
- tokens.postDelimiter += wrapIndent;
395
+ const {
396
+ hasListMarker,
397
+ tagStartIndex,
398
+ } = checkForListMarkers(index, source);
399
+
400
+ if (hasListMarker && index > tagStartIndex) {
401
+ const extraIndent = calculateListExtraIndent(index, tagStartIndex, source);
402
+ tokens.postDelimiter += wrapIndent + extraIndent;
403
+ } else {
404
+ // Normal case: add wrapIndent after the aligned delimiter
405
+ tokens.postDelimiter += wrapIndent;
406
+ }
321
407
  }
322
408
  }
323
409
 
package/src/index-cjs.js CHANGED
@@ -54,6 +54,7 @@ import requireProperty from './rules/requireProperty.js';
54
54
  import requirePropertyDescription from './rules/requirePropertyDescription.js';
55
55
  import requirePropertyName from './rules/requirePropertyName.js';
56
56
  import requirePropertyType from './rules/requirePropertyType.js';
57
+ import requireRejects from './rules/requireRejects.js';
57
58
  import requireReturns from './rules/requireReturns.js';
58
59
  import requireReturnsCheck from './rules/requireReturnsCheck.js';
59
60
  import requireReturnsDescription from './rules/requireReturnsDescription.js';
@@ -188,6 +189,7 @@ index.rules = {
188
189
  'require-property-description': requirePropertyDescription,
189
190
  'require-property-name': requirePropertyName,
190
191
  'require-property-type': requirePropertyType,
192
+ 'require-rejects': requireRejects,
191
193
  'require-returns': requireReturns,
192
194
  'require-returns-check': requireReturnsCheck,
193
195
  'require-returns-description': requireReturnsDescription,
@@ -332,6 +334,7 @@ const createRecommendedRuleset = (warnOrError, flatName) => {
332
334
  'jsdoc/require-property-description': warnOrError,
333
335
  'jsdoc/require-property-name': warnOrError,
334
336
  'jsdoc/require-property-type': warnOrError,
337
+ 'jsdoc/require-rejects': 'off',
335
338
  'jsdoc/require-returns': warnOrError,
336
339
  'jsdoc/require-returns-check': warnOrError,
337
340
  'jsdoc/require-returns-description': warnOrError,
package/src/index-esm.js CHANGED
@@ -177,6 +177,11 @@ export const jsdoc = function (cfg) {
177
177
  'type',
178
178
  ],
179
179
  },
180
+ rejects: {
181
+ required: [
182
+ 'type',
183
+ ],
184
+ },
180
185
  },
181
186
  } :
182
187
  {},
package/src/index.js CHANGED
@@ -60,6 +60,7 @@ import requireProperty from './rules/requireProperty.js';
60
60
  import requirePropertyDescription from './rules/requirePropertyDescription.js';
61
61
  import requirePropertyName from './rules/requirePropertyName.js';
62
62
  import requirePropertyType from './rules/requirePropertyType.js';
63
+ import requireRejects from './rules/requireRejects.js';
63
64
  import requireReturns from './rules/requireReturns.js';
64
65
  import requireReturnsCheck from './rules/requireReturnsCheck.js';
65
66
  import requireReturnsDescription from './rules/requireReturnsDescription.js';
@@ -194,6 +195,7 @@ index.rules = {
194
195
  'require-property-description': requirePropertyDescription,
195
196
  'require-property-name': requirePropertyName,
196
197
  'require-property-type': requirePropertyType,
198
+ 'require-rejects': requireRejects,
197
199
  'require-returns': requireReturns,
198
200
  'require-returns-check': requireReturnsCheck,
199
201
  'require-returns-description': requireReturnsDescription,
@@ -338,6 +340,7 @@ const createRecommendedRuleset = (warnOrError, flatName) => {
338
340
  'jsdoc/require-property-description': warnOrError,
339
341
  'jsdoc/require-property-name': warnOrError,
340
342
  'jsdoc/require-property-type': warnOrError,
343
+ 'jsdoc/require-rejects': 'off',
341
344
  'jsdoc/require-returns': warnOrError,
342
345
  'jsdoc/require-returns-check': warnOrError,
343
346
  'jsdoc/require-returns-description': warnOrError,
@@ -883,6 +886,11 @@ export const jsdoc = function (cfg) {
883
886
  'type',
884
887
  ],
885
888
  },
889
+ rejects: {
890
+ required: [
891
+ 'type',
892
+ ],
893
+ },
886
894
  },
887
895
  } :
888
896
  {},