eslint-plugin-jsdoc 46.2.6 → 46.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/getDefaultTagStructureForMode.js +1 -1
- package/dist/getDefaultTagStructureForMode.js.map +1 -1
- package/dist/iterateJsdoc.js +1 -1
- package/dist/iterateJsdoc.js.map +1 -1
- package/dist/jsdocUtils.js +3 -5
- package/dist/jsdocUtils.js.map +1 -1
- package/dist/rules/matchDescription.js +32 -8
- package/dist/rules/matchDescription.js.map +1 -1
- package/dist/rules/validTypes.js +11 -0
- package/dist/rules/validTypes.js.map +1 -1
- package/docs/rules/match-description.md +42 -11
- package/docs/rules/match-name.md +6 -0
- package/docs/rules/no-restricted-syntax.md +6 -0
- package/docs/rules/require-description.md +2 -1
- package/docs/rules/valid-types.md +27 -0
- package/package.json +1 -1
- package/tsconfig.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validTypes.js","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdoccomment","obj","__esModule","default","asExpression","suppressTypes","Set","tryParsePathIgnoreError","path","tryParse","_default","iterateJsdoc","jsdoc","report","utils","context","settings","allowEmptyNamepaths","options","mode","tag","tags","validNamepathParsing","namepath","tagName","handled","startsWith","endChar","slice","includes","startChar","charAt","validTypeParsing","type","parsedTypes","parse","traverse","node","_node$right","_node$right2","_node$right2$meta","typ","right","meta","position","problems","length","msg","reduce","str","message","thisNamepath","getTagDescription","replace","trim","test","thatNamepath","name","value","undefined","has","otherModeMaps","filter","mde","map","getTagStructureForMode","tagMightHaveNamePosition","modeInfo","mightHaveTypePosition","tagMightHaveTypePosition","tagMustHaveNamePosition","mustHaveTypePosition","tagMustHaveTypePosition","tagMissingRequiredTypeOrNamepath","hasTypePosition","Boolean","hasNameOrNamepathPosition","tagMightHaveNamepath","parseClosureTemplateTag","iterateAllJsdocs","docs","description","url","schema","additionalProperties","properties","exports","module"],"sources":["../../src/rules/validTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\nimport {\n parse,\n traverse,\n tryParse,\n} from '@es-joy/jsdoccomment';\n\nconst asExpression = /as\\s+/u;\n\nconst suppressTypes = new Set([\n // https://github.com/google/closure-compiler/wiki/@suppress-annotations\n // https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L154\n 'accessControls',\n 'checkDebuggerStatement',\n 'checkPrototypalTypes',\n 'checkRegExp',\n 'checkTypes',\n 'checkVars',\n 'closureDepMethodUsageChecks',\n 'const',\n 'constantProperty',\n 'deprecated',\n 'duplicate',\n 'es5Strict',\n 'externsValidation',\n 'extraProvide',\n 'extraRequire',\n 'globalThis',\n 'invalidCasts',\n 'lateProvide',\n 'legacyGoogScopeRequire',\n 'lintChecks',\n 'messageConventions',\n 'misplacedTypeAnnotation',\n 'missingOverride',\n 'missingPolyfill',\n 'missingProperties',\n 'missingProvide',\n 'missingRequire',\n 'missingSourcesWarnings',\n 'moduleLoad',\n 'nonStandardJsDocs',\n 'partialAlias',\n 'polymer',\n 'reportUnknownTypes',\n 'strictMissingProperties',\n 'strictModuleDepCheck',\n 'strictPrimitiveOperators',\n 'suspiciousCode',\n\n // Not documented in enum\n 'switch',\n 'transitionalSuspiciousCodeWarnings',\n 'undefinedNames',\n 'undefinedVars',\n 'underscore',\n 'unknownDefines',\n 'untranspilableFeatures',\n 'unusedLocalVariables',\n 'unusedPrivateMembers',\n 'useOfGoogProvide',\n 'uselessCode',\n 'visibility',\n 'with',\n]);\n\n/**\n * @param {string} path\n * @returns {boolean}\n */\nconst tryParsePathIgnoreError = (path) => {\n try {\n tryParse(path);\n\n return true;\n } catch {\n // Keep the original error for including the whole type\n }\n\n return false;\n};\n\n// eslint-disable-next-line complexity\nexport default iterateJsdoc(({\n jsdoc,\n report,\n utils,\n context,\n settings,\n}) => {\n const {\n allowEmptyNamepaths = false,\n } = context.options[0] || {};\n const {\n mode,\n } = settings;\n\n for (const tag of jsdoc.tags) {\n /**\n * @param {string} namepath\n * @param {string} [tagName]\n * @returns {boolean}\n */\n const validNamepathParsing = function (namepath, tagName) {\n if (tryParsePathIgnoreError(namepath)) {\n return true;\n }\n\n let handled = false;\n\n if (tagName) {\n // eslint-disable-next-line default-case\n switch (tagName) {\n case 'requires':\n case 'module': {\n if (!namepath.startsWith('module:')) {\n handled = tryParsePathIgnoreError(`module:${namepath}`);\n }\n\n break;\n }\n\n case 'memberof': case 'memberof!': {\n const endChar = namepath.slice(-1);\n if ([\n '#', '.', '~',\n ].includes(endChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(0, -1));\n }\n\n break;\n }\n\n case 'borrows': {\n const startChar = namepath.charAt(0);\n if ([\n '#', '.', '~',\n ].includes(startChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(1));\n }\n }\n }\n }\n\n if (!handled) {\n report(`Syntax error in namepath: ${namepath}`, null, tag);\n\n return false;\n }\n\n return true;\n };\n\n /**\n * @param {string} type\n * @returns {boolean}\n */\n const validTypeParsing = function (type) {\n let parsedTypes;\n try {\n if (mode === 'permissive') {\n parsedTypes = tryParse(type);\n } else {\n parsedTypes = parse(type, mode);\n }\n } catch {\n report(`Syntax error in type: ${type}`, null, tag);\n\n return false;\n }\n\n if (mode === 'closure' || mode === 'typescript') {\n traverse(parsedTypes, (node) => {\n const {\n type: typ,\n } = node;\n\n if (\n (typ === 'JsdocTypeObjectField' || typ === 'JsdocTypeKeyValue') &&\n node.right?.type === 'JsdocTypeNullable' &&\n node.right?.meta?.position === 'suffix'\n ) {\n report(`Syntax error in type: ${node.right.type}`, null, tag);\n }\n });\n }\n\n return true;\n };\n\n if (tag.problems.length) {\n const msg = tag.problems.reduce((str, {\n message,\n }) => {\n return str + '; ' + message;\n }, '').slice(2);\n report(`Invalid name: ${msg}`, null, tag);\n continue;\n }\n\n if (tag.tag === 'borrows') {\n const thisNamepath = /** @type {string} */ (\n utils.getTagDescription(tag)\n ).replace(asExpression, '')\n .trim();\n\n if (!asExpression.test(/** @type {string} */ (\n utils.getTagDescription(tag)\n )) || !thisNamepath) {\n report(`@borrows must have an \"as\" expression. Found \"${utils.getTagDescription(tag)}\"`, null, tag);\n\n continue;\n }\n\n if (validNamepathParsing(thisNamepath, 'borrows')) {\n const thatNamepath = tag.name;\n\n validNamepathParsing(thatNamepath);\n }\n\n continue;\n }\n\n if (tag.tag === 'suppress' && mode === 'closure') {\n let parsedTypes;\n\n try {\n parsedTypes = tryParse(tag.type);\n } catch {\n // Ignore\n }\n\n if (parsedTypes) {\n traverse(parsedTypes, (node) => {\n let type;\n if ('value' in node && typeof node.value === 'string') {\n type = node.value;\n }\n\n if (type !== undefined && !suppressTypes.has(type)) {\n report(`Syntax error in suppress type: ${type}`, null, tag);\n }\n });\n }\n }\n\n const otherModeMaps = /** @type {import('../jsdocUtils.js').ParserMode[]} */ ([\n 'jsdoc', 'typescript', 'closure', 'permissive',\n ]).filter(\n (mde) => {\n return mde !== mode;\n },\n ).map((mde) => {\n return utils.getTagStructureForMode(mde);\n });\n\n const tagMightHaveNamePosition = utils.tagMightHaveNamePosition(tag.tag, otherModeMaps);\n if (tagMightHaveNamePosition !== true && tag.name) {\n const modeInfo = tagMightHaveNamePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a name${modeInfo}.`, null, tag);\n\n continue;\n }\n\n const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag, otherModeMaps);\n if (mightHaveTypePosition !== true && tag.type) {\n const modeInfo = mightHaveTypePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a bracketed type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED NAME\n const tagMustHaveNamePosition = utils.tagMustHaveNamePosition(tag.tag, otherModeMaps);\n\n // Don't handle `@param` here though it does require name as handled by\n // `require-param-name` (`@property` would similarly seem to require one,\n // but is handled by `require-property-name`)\n if (tagMustHaveNamePosition !== false && !tag.name && !allowEmptyNamepaths && ![\n 'param', 'arg', 'argument',\n 'property', 'prop',\n ].includes(tag.tag) &&\n (tag.tag !== 'see' || !utils.getTagDescription(tag).includes('{@link'))\n ) {\n const modeInfo = tagMustHaveNamePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a name/namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE\n const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps);\n if (mustHaveTypePosition !== false && !tag.type) {\n const modeInfo = mustHaveTypePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE OR NAME/NAMEPATH\n const tagMissingRequiredTypeOrNamepath = utils.tagMissingRequiredTypeOrNamepath(tag, otherModeMaps);\n if (tagMissingRequiredTypeOrNamepath !== false && !allowEmptyNamepaths) {\n const modeInfo = tagMissingRequiredTypeOrNamepath === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have either a type or namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // VALID TYPE\n const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);\n if (hasTypePosition) {\n validTypeParsing(tag.type);\n }\n\n // VALID NAME/NAMEPATH\n const hasNameOrNamepathPosition = (\n tagMustHaveNamePosition !== false ||\n utils.tagMightHaveNamepath(tag.tag)\n ) && Boolean(tag.name);\n\n if (hasNameOrNamepathPosition) {\n if (mode !== 'jsdoc' && tag.tag === 'template') {\n for (const namepath of utils.parseClosureTemplateTag(tag)) {\n validNamepathParsing(namepath);\n }\n } else {\n validNamepathParsing(tag.name, tag.tag);\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires all types to be valid JSDoc or Closure compiler types without syntax errors.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/valid-types.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowEmptyNamepaths: {\n default: 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,aAAA,GAAAD,OAAA;AAI8B,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE9B,MAAMG,YAAY,GAAG,QAAQ;AAE7B,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAC;AAC5B;AACA;AACA,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,6BAA6B,EAC7B,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB;AAEhB;AACA,QAAQ,EACR,oCAAoC,EACpC,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,MAAM,CACP,CAAC;;AAEF;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,GAAIC,IAAI,IAAK;EACxC,IAAI;IACF,IAAAC,sBAAQ,EAACD,IAAI,CAAC;IAEd,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,KAAK;AACd,CAAC;;AA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AI,EAAE;MACJC,WAAW,EAAE,uFAAuF;MACpGC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVpE,mBAAmB,EAAE;UACnBd,OAAO,EAAE,KAAK;UACd8B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAqD,OAAA,CAAAnF,OAAA,GAAAO,QAAA;AAAA6E,MAAA,CAAAD,OAAA,GAAAA,OAAA,CAAAnF,OAAA"}
|
|
1
|
+
{"version":3,"file":"validTypes.js","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdoccomment","obj","__esModule","default","inlineTags","Set","asExpression","suppressTypes","tryParsePathIgnoreError","path","tryParse","_default","iterateJsdoc","jsdoc","report","utils","context","settings","allowEmptyNamepaths","options","mode","tag","tags","validNamepathParsing","namepath","tagName","handled","startsWith","endChar","slice","includes","startChar","charAt","validTypeParsing","type","parsedTypes","parse","traverse","node","_node$right","_node$right2","_node$right2$meta","typ","right","meta","position","problems","length","msg","reduce","str","message","thisNamepath","getTagDescription","replace","trim","test","thatNamepath","name","value","undefined","has","otherModeMaps","filter","mde","map","getTagStructureForMode","tagMightHaveNamePosition","modeInfo","mightHaveTypePosition","tagMightHaveTypePosition","tagMustHaveNamePosition","mustHaveTypePosition","tagMustHaveTypePosition","tagMissingRequiredTypeOrNamepath","hasTypePosition","Boolean","hasNameOrNamepathPosition","tagMightHaveNamepath","parseClosureTemplateTag","inlineTag","text","namepathOrURL","iterateAllJsdocs","docs","description","url","schema","additionalProperties","properties","exports","module"],"sources":["../../src/rules/validTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\nimport {\n parse,\n traverse,\n tryParse,\n} from '@es-joy/jsdoccomment';\n\nconst inlineTags = new Set([\n 'link', 'linkcode', 'linkplain',\n 'tutorial',\n]);\n\nconst asExpression = /as\\s+/u;\n\nconst suppressTypes = new Set([\n // https://github.com/google/closure-compiler/wiki/@suppress-annotations\n // https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L154\n 'accessControls',\n 'checkDebuggerStatement',\n 'checkPrototypalTypes',\n 'checkRegExp',\n 'checkTypes',\n 'checkVars',\n 'closureDepMethodUsageChecks',\n 'const',\n 'constantProperty',\n 'deprecated',\n 'duplicate',\n 'es5Strict',\n 'externsValidation',\n 'extraProvide',\n 'extraRequire',\n 'globalThis',\n 'invalidCasts',\n 'lateProvide',\n 'legacyGoogScopeRequire',\n 'lintChecks',\n 'messageConventions',\n 'misplacedTypeAnnotation',\n 'missingOverride',\n 'missingPolyfill',\n 'missingProperties',\n 'missingProvide',\n 'missingRequire',\n 'missingSourcesWarnings',\n 'moduleLoad',\n 'nonStandardJsDocs',\n 'partialAlias',\n 'polymer',\n 'reportUnknownTypes',\n 'strictMissingProperties',\n 'strictModuleDepCheck',\n 'strictPrimitiveOperators',\n 'suspiciousCode',\n\n // Not documented in enum\n 'switch',\n 'transitionalSuspiciousCodeWarnings',\n 'undefinedNames',\n 'undefinedVars',\n 'underscore',\n 'unknownDefines',\n 'untranspilableFeatures',\n 'unusedLocalVariables',\n 'unusedPrivateMembers',\n 'useOfGoogProvide',\n 'uselessCode',\n 'visibility',\n 'with',\n]);\n\n/**\n * @param {string} path\n * @returns {boolean}\n */\nconst tryParsePathIgnoreError = (path) => {\n try {\n tryParse(path);\n\n return true;\n } catch {\n // Keep the original error for including the whole type\n }\n\n return false;\n};\n\n// eslint-disable-next-line complexity\nexport default iterateJsdoc(({\n jsdoc,\n report,\n utils,\n context,\n settings,\n}) => {\n const {\n allowEmptyNamepaths = false,\n } = context.options[0] || {};\n const {\n mode,\n } = settings;\n\n for (const tag of jsdoc.tags) {\n /**\n * @param {string} namepath\n * @param {string} [tagName]\n * @returns {boolean}\n */\n const validNamepathParsing = function (namepath, tagName) {\n if (tryParsePathIgnoreError(namepath)) {\n return true;\n }\n\n let handled = false;\n\n if (tagName) {\n // eslint-disable-next-line default-case\n switch (tagName) {\n case 'requires':\n case 'module': {\n if (!namepath.startsWith('module:')) {\n handled = tryParsePathIgnoreError(`module:${namepath}`);\n }\n\n break;\n }\n\n case 'memberof': case 'memberof!': {\n const endChar = namepath.slice(-1);\n if ([\n '#', '.', '~',\n ].includes(endChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(0, -1));\n }\n\n break;\n }\n\n case 'borrows': {\n const startChar = namepath.charAt(0);\n if ([\n '#', '.', '~',\n ].includes(startChar)) {\n handled = tryParsePathIgnoreError(namepath.slice(1));\n }\n }\n }\n }\n\n if (!handled) {\n report(`Syntax error in namepath: ${namepath}`, null, tag);\n\n return false;\n }\n\n return true;\n };\n\n /**\n * @param {string} type\n * @returns {boolean}\n */\n const validTypeParsing = function (type) {\n let parsedTypes;\n try {\n if (mode === 'permissive') {\n parsedTypes = tryParse(type);\n } else {\n parsedTypes = parse(type, mode);\n }\n } catch {\n report(`Syntax error in type: ${type}`, null, tag);\n\n return false;\n }\n\n if (mode === 'closure' || mode === 'typescript') {\n traverse(parsedTypes, (node) => {\n const {\n type: typ,\n } = node;\n\n if (\n (typ === 'JsdocTypeObjectField' || typ === 'JsdocTypeKeyValue') &&\n node.right?.type === 'JsdocTypeNullable' &&\n node.right?.meta?.position === 'suffix'\n ) {\n report(`Syntax error in type: ${node.right.type}`, null, tag);\n }\n });\n }\n\n return true;\n };\n\n if (tag.problems.length) {\n const msg = tag.problems.reduce((str, {\n message,\n }) => {\n return str + '; ' + message;\n }, '').slice(2);\n report(`Invalid name: ${msg}`, null, tag);\n continue;\n }\n\n if (tag.tag === 'borrows') {\n const thisNamepath = /** @type {string} */ (\n utils.getTagDescription(tag)\n ).replace(asExpression, '')\n .trim();\n\n if (!asExpression.test(/** @type {string} */ (\n utils.getTagDescription(tag)\n )) || !thisNamepath) {\n report(`@borrows must have an \"as\" expression. Found \"${utils.getTagDescription(tag)}\"`, null, tag);\n\n continue;\n }\n\n if (validNamepathParsing(thisNamepath, 'borrows')) {\n const thatNamepath = tag.name;\n\n validNamepathParsing(thatNamepath);\n }\n\n continue;\n }\n\n if (tag.tag === 'suppress' && mode === 'closure') {\n let parsedTypes;\n\n try {\n parsedTypes = tryParse(tag.type);\n } catch {\n // Ignore\n }\n\n if (parsedTypes) {\n traverse(parsedTypes, (node) => {\n let type;\n if ('value' in node && typeof node.value === 'string') {\n type = node.value;\n }\n\n if (type !== undefined && !suppressTypes.has(type)) {\n report(`Syntax error in suppress type: ${type}`, null, tag);\n }\n });\n }\n }\n\n const otherModeMaps = /** @type {import('../jsdocUtils.js').ParserMode[]} */ ([\n 'jsdoc', 'typescript', 'closure', 'permissive',\n ]).filter(\n (mde) => {\n return mde !== mode;\n },\n ).map((mde) => {\n return utils.getTagStructureForMode(mde);\n });\n\n const tagMightHaveNamePosition = utils.tagMightHaveNamePosition(tag.tag, otherModeMaps);\n if (tagMightHaveNamePosition !== true && tag.name) {\n const modeInfo = tagMightHaveNamePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a name${modeInfo}.`, null, tag);\n\n continue;\n }\n\n const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag, otherModeMaps);\n if (mightHaveTypePosition !== true && tag.type) {\n const modeInfo = mightHaveTypePosition === false ? '' : ` in \"${mode}\" mode`;\n report(`@${tag.tag} should not have a bracketed type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED NAME\n const tagMustHaveNamePosition = utils.tagMustHaveNamePosition(tag.tag, otherModeMaps);\n\n // Don't handle `@param` here though it does require name as handled by\n // `require-param-name` (`@property` would similarly seem to require one,\n // but is handled by `require-property-name`)\n if (tagMustHaveNamePosition !== false && !tag.name && !allowEmptyNamepaths && ![\n 'param', 'arg', 'argument',\n 'property', 'prop',\n ].includes(tag.tag) &&\n (tag.tag !== 'see' || !utils.getTagDescription(tag).includes('{@link'))\n ) {\n const modeInfo = tagMustHaveNamePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a name/namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE\n const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps);\n if (mustHaveTypePosition !== false && !tag.type) {\n const modeInfo = mustHaveTypePosition === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // REQUIRED TYPE OR NAME/NAMEPATH\n const tagMissingRequiredTypeOrNamepath = utils.tagMissingRequiredTypeOrNamepath(tag, otherModeMaps);\n if (tagMissingRequiredTypeOrNamepath !== false && !allowEmptyNamepaths) {\n const modeInfo = tagMissingRequiredTypeOrNamepath === true ? '' : ` in \"${mode}\" mode`;\n report(`Tag @${tag.tag} must have either a type or namepath${modeInfo}.`, null, tag);\n\n continue;\n }\n\n // VALID TYPE\n const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);\n if (hasTypePosition) {\n validTypeParsing(tag.type);\n }\n\n // VALID NAME/NAMEPATH\n const hasNameOrNamepathPosition = (\n tagMustHaveNamePosition !== false ||\n utils.tagMightHaveNamepath(tag.tag)\n ) && Boolean(tag.name);\n\n if (hasNameOrNamepathPosition) {\n if (mode !== 'jsdoc' && tag.tag === 'template') {\n for (const namepath of utils.parseClosureTemplateTag(tag)) {\n validNamepathParsing(namepath);\n }\n } else {\n validNamepathParsing(tag.name, tag.tag);\n }\n }\n\n for (const inlineTag of tag.inlineTags) {\n if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) {\n report(`Inline tag \"${inlineTag.tag}\" missing content`, null, tag);\n }\n }\n }\n\n for (const inlineTag of jsdoc.inlineTags) {\n if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) {\n report(`Inline tag \"${inlineTag.tag}\" missing content`);\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires all types to be valid JSDoc or Closure compiler types without syntax errors.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/valid-types.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowEmptyNamepaths: {\n default: 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,aAAA,GAAAD,OAAA;AAI8B,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE9B,MAAMG,UAAU,GAAG,IAAIC,GAAG,CAAC,CACzB,MAAM,EAAE,UAAU,EAAE,WAAW,EAC/B,UAAU,CACX,CAAC;AAEF,MAAMC,YAAY,GAAG,QAAQ;AAE7B,MAAMC,aAAa,GAAG,IAAIF,GAAG,CAAC;AAC5B;AACA;AACA,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,6BAA6B,EAC7B,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB;AAEhB;AACA,QAAQ,EACR,oCAAoC,EACpC,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,sBA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 @@
|
|
|
5
5
|
* [Options](#user-content-match-description-options)
|
|
6
6
|
* [`matchDescription`](#user-content-match-description-options-matchdescription)
|
|
7
7
|
* [`message`](#user-content-match-description-options-message)
|
|
8
|
+
* [`nonemptyTags`](#user-content-match-description-options-nonemptytags)
|
|
8
9
|
* [`tags`](#user-content-match-description-options-tags)
|
|
9
10
|
* [`mainDescription`](#user-content-match-description-options-maindescription)
|
|
10
11
|
* [`contexts`](#user-content-match-description-options-contexts)
|
|
@@ -21,8 +22,14 @@ by our supported Node versions):
|
|
|
21
22
|
|
|
22
23
|
``^\n?([A-Z`\\d_][\\s\\S]*[.?!`]\\s*)?$``
|
|
23
24
|
|
|
24
|
-
Applies to the jsdoc block description and
|
|
25
|
-
|
|
25
|
+
Applies by default to the jsdoc block description and to the following tags:
|
|
26
|
+
|
|
27
|
+
- `@description`/`@desc`
|
|
28
|
+
- `@summary`
|
|
29
|
+
- `@file`/`@fileoverview`/`@overview`
|
|
30
|
+
- `@classdesc`
|
|
31
|
+
|
|
32
|
+
In addition, the `tags` option (see below) may be used to match other tags.
|
|
26
33
|
|
|
27
34
|
The default (and all regex options) defaults to using (only) the `u` flag, so
|
|
28
35
|
to add your own flags, encapsulate your expression as a string, but like a
|
|
@@ -71,6 +78,23 @@ You may provide a custom default message by using the following format:
|
|
|
71
78
|
This can be overridden per tag or for the main block description by setting
|
|
72
79
|
`message` within `tags` or `mainDescription`, respectively.
|
|
73
80
|
|
|
81
|
+
<a name="user-content-match-description-options-nonemptytags"></a>
|
|
82
|
+
<a name="match-description-options-nonemptytags"></a>
|
|
83
|
+
### <code>nonemptyTags</code>
|
|
84
|
+
|
|
85
|
+
If not set to `false`, will enforce that the following tags have at least
|
|
86
|
+
some content:
|
|
87
|
+
|
|
88
|
+
- `@copyright`
|
|
89
|
+
- `@example`
|
|
90
|
+
- `@see`
|
|
91
|
+
- `@todo`
|
|
92
|
+
- `@throws`/`@exception`
|
|
93
|
+
- `@yields`/`@yield`
|
|
94
|
+
|
|
95
|
+
If you supply your own tag description for any of the above tags in `tags`,
|
|
96
|
+
your description will take precedence.
|
|
97
|
+
|
|
74
98
|
<a name="user-content-match-description-options-tags"></a>
|
|
75
99
|
<a name="match-description-options-tags"></a>
|
|
76
100
|
### <code>tags</code>
|
|
@@ -186,7 +210,7 @@ section of our README for more on the expected format.
|
|
|
186
210
|
|Aliases|`@desc`|
|
|
187
211
|
|Recommended|false|
|
|
188
212
|
|Settings||
|
|
189
|
-
|Options|`contexts`, `mainDescription`, `matchDescription`, `message`, `tags`|
|
|
213
|
+
|Options|`contexts`, `mainDescription`, `matchDescription`, `message`, `nonemptyTags`, `tags`|
|
|
190
214
|
|
|
191
215
|
<a name="user-content-match-description-failing-examples"></a>
|
|
192
216
|
<a name="match-description-failing-examples"></a>
|
|
@@ -335,7 +359,6 @@ function quux (foo) {
|
|
|
335
359
|
function quux () {
|
|
336
360
|
|
|
337
361
|
}
|
|
338
|
-
// "jsdoc/match-description": ["error"|"warn", {"tags":{"summary":true}}]
|
|
339
362
|
// Message: JSDoc description does not satisfy the regex pattern.
|
|
340
363
|
|
|
341
364
|
/**
|
|
@@ -368,7 +391,6 @@ function quux () {
|
|
|
368
391
|
function quux (foo) {
|
|
369
392
|
|
|
370
393
|
}
|
|
371
|
-
// "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
|
|
372
394
|
// Message: JSDoc description does not satisfy the regex pattern.
|
|
373
395
|
|
|
374
396
|
/**
|
|
@@ -602,6 +624,13 @@ function quux () {
|
|
|
602
624
|
function foo(): string;
|
|
603
625
|
// "jsdoc/match-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine=0]"}],"matchDescription":"^\\S[\\s\\S]*\\S$"}]
|
|
604
626
|
// Message: JSDoc description does not satisfy the regex pattern.
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* @copyright
|
|
630
|
+
*/
|
|
631
|
+
function quux () {
|
|
632
|
+
}
|
|
633
|
+
// Message: JSDoc description must not be empty.
|
|
605
634
|
````
|
|
606
635
|
|
|
607
636
|
|
|
@@ -722,7 +751,6 @@ function quux () {
|
|
|
722
751
|
function quux () {
|
|
723
752
|
|
|
724
753
|
}
|
|
725
|
-
// "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
|
|
726
754
|
|
|
727
755
|
/**
|
|
728
756
|
* @description Foo
|
|
@@ -732,13 +760,11 @@ function quux () {
|
|
|
732
760
|
function quux () {
|
|
733
761
|
|
|
734
762
|
}
|
|
735
|
-
// "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
|
|
736
763
|
|
|
737
764
|
/** @description Foo bar. */
|
|
738
765
|
function quux () {
|
|
739
766
|
|
|
740
767
|
}
|
|
741
|
-
// "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
|
|
742
768
|
|
|
743
769
|
/**
|
|
744
770
|
* @description Foo
|
|
@@ -747,7 +773,6 @@ function quux () {
|
|
|
747
773
|
function quux () {
|
|
748
774
|
|
|
749
775
|
}
|
|
750
|
-
// "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
|
|
751
776
|
|
|
752
777
|
/**
|
|
753
778
|
* Foo. {@see Math.sin}.
|
|
@@ -872,7 +897,7 @@ const q = {
|
|
|
872
897
|
// "jsdoc/match-description": ["error"|"warn", {"contexts":[]}]
|
|
873
898
|
|
|
874
899
|
/**
|
|
875
|
-
* @
|
|
900
|
+
* @deprecated foo.
|
|
876
901
|
*/
|
|
877
902
|
function quux () {
|
|
878
903
|
|
|
@@ -887,7 +912,6 @@ function quux () {
|
|
|
887
912
|
function quux () {
|
|
888
913
|
|
|
889
914
|
}
|
|
890
|
-
// "jsdoc/match-description": ["error"|"warn", {"tags":{"summary":true}}]
|
|
891
915
|
|
|
892
916
|
/**
|
|
893
917
|
* Foo.
|
|
@@ -975,5 +999,12 @@ function foo(): string;
|
|
|
975
999
|
*/
|
|
976
1000
|
function foo(): void;
|
|
977
1001
|
// "jsdoc/match-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine!=0]:not(:has(JsdocTag))"}],"matchDescription":"^\\S[\\s\\S]*\\S$"}]
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* @copyright
|
|
1005
|
+
*/
|
|
1006
|
+
function quux () {
|
|
1007
|
+
}
|
|
1008
|
+
// "jsdoc/match-description": ["error"|"warn", {"nonemptyTags":false}]
|
|
978
1009
|
````
|
|
979
1010
|
|
package/docs/rules/match-name.md
CHANGED
|
@@ -178,6 +178,12 @@ function quux () {}
|
|
|
178
178
|
*/
|
|
179
179
|
// "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","replacement":""}]}]
|
|
180
180
|
// Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @template
|
|
184
|
+
*/
|
|
185
|
+
// "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^$/","tags":["template"]}]}]
|
|
186
|
+
// Message: Only allowing names not matching `/^$/u` but found "".
|
|
181
187
|
````
|
|
182
188
|
|
|
183
189
|
|
|
@@ -373,5 +373,11 @@ class Test {
|
|
|
373
373
|
abstract Test(): void;
|
|
374
374
|
}
|
|
375
375
|
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"TSEmptyBodyFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"methods with non-void return types must have a @returns tag"}]}]
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* @private
|
|
379
|
+
*/
|
|
380
|
+
function quux () {}
|
|
381
|
+
// "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(JsdocBlock:has(JsdocTag[tag=/private|protected|public/]))","context":"any","message":"Access modifier tags must be present"}]}]
|
|
376
382
|
````
|
|
377
383
|
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* [Passing examples](#user-content-require-description-passing-examples)
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
Requires that all functions
|
|
11
|
+
Requires that all functions (or optionally other structures) with a JSDoc block
|
|
12
|
+
have a description.
|
|
12
13
|
|
|
13
14
|
* All functions must have an implicit description (e.g., text above tags) or
|
|
14
15
|
have the option `descriptionStyle` set to `tag` (requiring `@description`
|
|
@@ -487,6 +487,21 @@ function quux (items) {
|
|
|
487
487
|
}
|
|
488
488
|
// Settings: {"jsdoc":{"mode":"typescript"}}
|
|
489
489
|
// Message: Syntax error in type: JsdocTypeNullable
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* An inline {@link} tag without content.
|
|
493
|
+
*/
|
|
494
|
+
// Message: Inline tag "link" missing content
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* An inline {@tutorial} tag without content.
|
|
498
|
+
*/
|
|
499
|
+
// Message: Inline tag "tutorial" missing content
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* @param {SomeType} aName An inline {@link} tag without content.
|
|
503
|
+
*/
|
|
504
|
+
// Message: Inline tag "link" missing content
|
|
490
505
|
````
|
|
491
506
|
|
|
492
507
|
|
|
@@ -850,5 +865,17 @@ function quux() {
|
|
|
850
865
|
/**
|
|
851
866
|
* @returns {Promise<{publicKey, privateKey}>} - The public and private key
|
|
852
867
|
*/
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Some other {@inline} tag.
|
|
871
|
+
*/
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* @param {SomeType} aName An inline {@link text} tag with content.
|
|
875
|
+
*/
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* An inline {@link text} tag with content.
|
|
879
|
+
*/
|
|
853
880
|
````
|
|
854
881
|
|
package/package.json
CHANGED