eslint-plugin-jsdoc 60.4.1 → 60.6.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/README.md +4 -0
- package/dist/cjs/iterateJsdoc.d.ts +5 -0
- package/dist/cjs/jsdocUtils.d.ts +19 -2
- package/dist/cjs/rules/escapeInlineTags.d.ts +2 -0
- package/dist/generateDocs.cjs +5 -6
- package/dist/generateDocs.cjs.map +1 -1
- package/dist/index-cjs.cjs +14 -1
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index-esm.cjs +0 -2
- package/dist/index-esm.cjs.map +1 -1
- package/dist/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/iterateJsdoc.cjs +12 -0
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.ts +5 -0
- package/dist/jsdocUtils.cjs +21 -17
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/jsdocUtils.d.ts +19 -2
- package/dist/rules/checkLineAlignment.cjs +1 -2
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +16 -0
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +2 -4
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +1 -2
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/escapeInlineTags.cjs +149 -0
- package/dist/rules/escapeInlineTags.cjs.map +1 -0
- package/dist/rules/escapeInlineTags.d.ts +3 -0
- package/dist/rules/informativeDocs.cjs +3 -6
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +4 -8
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +2 -4
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +1 -2
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +3 -6
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +1 -2
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +1 -2
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +1 -1
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +1 -2
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +1 -2
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +1 -3
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +1 -2
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +3 -6
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +6 -12
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +1 -2
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +1 -2
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +1 -2
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +1 -2
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules.d.ts +34 -37
- package/package.json +11 -11
- package/src/index-cjs.js +16 -0
- package/src/index-esm.js +0 -2
- package/src/index.js +16 -2
- package/src/iterateJsdoc.js +13 -0
- package/src/jsdocUtils.js +22 -17
- package/src/rules/checkLineAlignment.js +1 -2
- package/src/rules/checkTagNames.js +19 -0
- package/src/rules/convertToJsdocComments.js +2 -4
- package/src/rules/emptyTags.js +1 -2
- package/src/rules/escapeInlineTags.js +189 -0
- package/src/rules/informativeDocs.js +3 -6
- package/src/rules/linesBeforeBlock.js +4 -8
- package/src/rules/matchDescription.js +2 -4
- package/src/rules/matchName.js +1 -2
- package/src/rules/multilineBlocks.js +3 -6
- package/src/rules/noBadBlocks.js +1 -2
- package/src/rules/noTypes.js +1 -2
- package/src/rules/noUndefinedTypes.js +7 -1
- package/src/rules/requireAsteriskPrefix.js +1 -2
- package/src/rules/requireDescriptionCompleteSentence.js +1 -2
- package/src/rules/requireFileOverview.js +1 -3
- package/src/rules/requireHyphenBeforeParamDescription.js +1 -2
- package/src/rules/requireJsdoc.js +3 -6
- package/src/rules/requireParam.js +6 -12
- package/src/rules/requireParamName.js +1 -2
- package/src/rules/requireReturns.js +1 -2
- package/src/rules/requireTemplate.js +1 -2
- package/src/rules/sortTags.js +1 -2
- package/src/rules.d.ts +34 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noTypes.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","removeType","tokens","postTag","type","_default","exports","iterateJsdoc","node","utils","isIteratingFunctionOrVariable","isVirtualFunction","tags","getPresentTags","tag","reportJSDoc","source","propertyTags","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"sources":["../../src/rules/noTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {import('comment-parser').Line} line\n */\nconst removeType = ({\n tokens,\n}) => {\n tokens.postTag = '';\n tokens.type = '';\n};\n\nexport default iterateJsdoc(({\n node,\n utils,\n}) => {\n if (!utils.isIteratingFunctionOrVariable() && !utils.isVirtualFunction()) {\n return;\n }\n\n const tags = utils.getPresentTags([\n 'param', 'arg', 'argument', 'returns', 'return',\n ]);\n\n for (const tag of tags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n\n if (node?.type === 'ClassDeclaration') {\n const propertyTags = utils.getPresentTags([\n 'prop', 'property',\n ]);\n for (const tag of propertyTags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag} in the supplied context.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n }\n}, {\n contextDefaults: [\n 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',\n // Add this to above defaults\n 'TSMethodSignature', 'ClassDeclaration',\n ],\n meta: {\n docs: {\n description: 'This rule reports types being used on `@param` or `@returns` (redundant with TypeScript).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-types.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the 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\\`, \\`TSDeclareFunction\\`, \\`TSMethodSignature\\`,\n\\`ClassDeclaration\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../#advanced-ast-and-selectors)\nsection of our Advanced docs for more on the expected format
|
|
1
|
+
{"version":3,"file":"noTypes.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","removeType","tokens","postTag","type","_default","exports","iterateJsdoc","node","utils","isIteratingFunctionOrVariable","isVirtualFunction","tags","getPresentTags","tag","reportJSDoc","source","propertyTags","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"sources":["../../src/rules/noTypes.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {import('comment-parser').Line} line\n */\nconst removeType = ({\n tokens,\n}) => {\n tokens.postTag = '';\n tokens.type = '';\n};\n\nexport default iterateJsdoc(({\n node,\n utils,\n}) => {\n if (!utils.isIteratingFunctionOrVariable() && !utils.isVirtualFunction()) {\n return;\n }\n\n const tags = utils.getPresentTags([\n 'param', 'arg', 'argument', 'returns', 'return',\n ]);\n\n for (const tag of tags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n\n if (node?.type === 'ClassDeclaration') {\n const propertyTags = utils.getPresentTags([\n 'prop', 'property',\n ]);\n for (const tag of propertyTags) {\n if (tag.type) {\n utils.reportJSDoc(`Types are not permitted on @${tag.tag} in the supplied context.`, tag, () => {\n for (const source of tag.source) {\n removeType(source);\n }\n });\n }\n }\n }\n}, {\n contextDefaults: [\n 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',\n // Add this to above defaults\n 'TSMethodSignature', 'ClassDeclaration',\n ],\n meta: {\n docs: {\n description: 'This rule reports types being used on `@param` or `@returns` (redundant with TypeScript).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-types.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the 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\\`, \\`TSDeclareFunction\\`, \\`TSMethodSignature\\`,\n\\`ClassDeclaration\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../#advanced-ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\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 },\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,MAAMG,UAAU,GAAGA,CAAC;EAClBC;AACF,CAAC,KAAK;EACJA,MAAM,CAACC,OAAO,GAAG,EAAE;EACnBD,MAAM,CAACE,IAAI,GAAG,EAAE;AAClB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAN,OAAA,GAEa,IAAAO,qBAAY,EAAC,CAAC;EAC3BC,IAAI;EACJC;AACF,CAAC,KAAK;EACJ,IAAI,CAACA,KAAK,CAACC,6BAA6B,CAAC,CAAC,IAAI,CAACD,KAAK,CAACE,iBAAiB,CAAC,CAAC,EAAE;IACxE;EACF;EAEA,MAAMC,IAAI,GAAGH,KAAK,CAACI,cAAc,CAAC,CAChC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,CAChD,CAAC;EAEF,KAAK,MAAMC,GAAG,IAAIF,IAAI,EAAE;IACtB,IAAIE,GAAG,CAACV,IAAI,EAAE;MACZK,KAAK,CAACM,WAAW,CAAC,+BAA+BD,GAAG,CAACA,GAAG,GAAG,EAAEA,GAAG,EAAE,MAAM;QACtE,KAAK,MAAME,MAAM,IAAIF,GAAG,CAACE,MAAM,EAAE;UAC/Bf,UAAU,CAAC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;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA4B,MAAA,CAAA1B,OAAA,GAAAA,OAAA,CAAAN,OAAA","ignoreList":[]}
|
|
@@ -91,7 +91,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
91
91
|
return doc.tags.filter(({
|
|
92
92
|
tag
|
|
93
93
|
}) => {
|
|
94
|
-
return utils.isNamepathDefiningTag(tag);
|
|
94
|
+
return utils.isNamepathDefiningTag(tag) && !['arg', 'argument', 'param', 'prop', 'property'].includes(tag);
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
const typedefDeclarations = typedefs.map(tag => {
|
|
@@ -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","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","isNamepathDefiningTag","typedefDeclarations","name","importTags","description","type","typePart","imprt","importsExports","parseImportsExports","types","namedImports","push","names","namespaceImports","namespace","ancestorNodes","currentNode","parent","getTemplateTags","ancestorNode","getJSDocComment","jsdc","templateTags","getPresentTags","closureGenericTypes","parseClosureTemplateTag","cjsOrESMScope","childScopes","block","getValidRuntimeIdentifiers","scope","result","Set","scp","variables","add","upper","imports","allDefinedTypes","identifiers","globalItem","body","item","property","key","init","callee","id","methodOrProp","getScope","tagToParsedType","propertyName","potentialType","parsedType","tryParseType","parseType","typeTags","filterTags","tagMightHaveTypePosition","namepathReferencingTags","isNamepathReferencingTag","namepathOrUrlReferencingTags","filterAllTags","isNamepathOrUrlReferencingTag","tagsWithTypes","traverse","nde","parentNode","_parent","val","currNode","includes","right","structuredTypes","Array","isArray","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 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.isNamepathDefiningTag(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 utils.getPresentTags([\n 'template',\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 * We treat imports differently as we can't introspect their children.\n * @type {string[]}\n */\n const imports = [];\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 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 '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 return [];\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(...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 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 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 currNode && 'right' in currNode &&\n currNode.right?.type === 'JsdocTypeProperty') {\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 if (!allDefinedTypes.has(val) &&\n (!Array.isArray(structuredTypes) || !structuredTypes.includes(val))\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.isNamepathDefiningTag(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,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,CA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ACzB;AACA;AACA,qCAAqC;UACzBC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAqF,MAAA,CAAA3I,OAAA,GAAAA,OAAA,CAAAf,OAAA","ignoreList":[]}
|
|
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","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","isNamepathDefiningTag","includes","typedefDeclarations","name","importTags","description","type","typePart","imprt","importsExports","parseImportsExports","types","namedImports","push","names","namespaceImports","namespace","ancestorNodes","currentNode","parent","getTemplateTags","ancestorNode","getJSDocComment","jsdc","templateTags","getPresentTags","closureGenericTypes","parseClosureTemplateTag","cjsOrESMScope","childScopes","block","getValidRuntimeIdentifiers","scope","result","Set","scp","variables","add","upper","imports","allDefinedTypes","identifiers","globalItem","body","item","property","key","init","callee","id","methodOrProp","getScope","tagToParsedType","propertyName","potentialType","parsedType","tryParseType","parseType","typeTags","filterTags","tagMightHaveTypePosition","namepathReferencingTags","isNamepathReferencingTag","namepathOrUrlReferencingTags","filterAllTags","isNamepathOrUrlReferencingTag","tagsWithTypes","traverse","nde","parentNode","_parent","val","currNode","right","structuredTypes","Array","isArray","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 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.isNamepathDefiningTag(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 utils.getPresentTags([\n 'template',\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 * We treat imports differently as we can't introspect their children.\n * @type {string[]}\n */\n const imports = [];\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 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 '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 return [];\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(...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 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 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 currNode && 'right' in currNode &&\n currNode.right?.type === 'JsdocTypeProperty') {\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 if (!allDefinedTypes.has(val) &&\n (!Array.isArray(structuredTypes) || !structuredTypes.includes(val))\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.isNamepathDefiningTag(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,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,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,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CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoF,MAAA,CAAA3I,OAAA,GAAAA,OAAA,CAAAf,OAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireAsteriskPrefix.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","indent","jsdoc","utils","defaultRequireValue","tags","tagMap","options","source","always","never","currentTag","some","number","tokens","delimiter","description","end","tag","neverFix","postDelimiter","checkNever","checkValue","includes","reportJSDoc","column","line","alwaysFix","start","checkAlways","slice","any","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type","additionalProperties","properties","items","module"],"sources":["../../src/rules/requireAsteriskPrefix.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n utils,\n}) => {\n const [\n defaultRequireValue = 'always',\n {\n tags: tagMap = {},\n } = {},\n ] = context.options;\n\n const {\n source,\n } = jsdoc;\n\n const always = defaultRequireValue === 'always';\n const never = defaultRequireValue === 'never';\n\n /** @type {string} */\n let currentTag;\n source.some(({\n number,\n tokens,\n }) => {\n const {\n delimiter,\n description,\n end,\n tag,\n } = tokens;\n\n /**\n * @returns {void}\n */\n const neverFix = () => {\n tokens.delimiter = '';\n tokens.postDelimiter = '';\n };\n\n /**\n * @param {string} checkValue\n * @returns {boolean}\n */\n const checkNever = (checkValue) => {\n if (delimiter && delimiter !== '/**' && (\n never && !tagMap.always?.includes(checkValue) ||\n tagMap.never?.includes(checkValue)\n )) {\n utils.reportJSDoc('Expected JSDoc line to have no prefix.', {\n column: 0,\n line: number,\n }, neverFix);\n\n return true;\n }\n\n return false;\n };\n\n /**\n * @returns {void}\n */\n const alwaysFix = () => {\n if (!tokens.start) {\n tokens.start = indent + ' ';\n }\n\n tokens.delimiter = '*';\n tokens.postDelimiter = tag || description ? ' ' : '';\n };\n\n /**\n * @param {string} checkValue\n * @returns {boolean}\n */\n const checkAlways = (checkValue) => {\n if (\n !delimiter && (\n always && !tagMap.never?.includes(checkValue) ||\n tagMap.always?.includes(checkValue)\n )\n ) {\n utils.reportJSDoc('Expected JSDoc line to have the prefix.', {\n column: 0,\n line: number,\n }, alwaysFix);\n\n return true;\n }\n\n return false;\n };\n\n if (tag) {\n // Remove at sign\n currentTag = tag.slice(1);\n }\n\n if (\n // If this is the end but has a tag, the delimiter will also be\n // populated and will be safely ignored later\n end && !tag\n ) {\n return false;\n }\n\n if (!currentTag) {\n if (tagMap.any?.includes('*description')) {\n return false;\n }\n\n if (checkNever('*description')) {\n return true;\n }\n\n if (checkAlways('*description')) {\n return true;\n }\n\n return false;\n }\n\n if (tagMap.any?.includes(currentTag)) {\n return false;\n }\n\n if (checkNever(currentTag)) {\n return true;\n }\n\n if (checkAlways(currentTag)) {\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description:\n 'Requires that each JSDoc line starts with an `*`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-asterisk-prefix.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n description: `If it is \\`\"always\"\\` then a problem is raised when there is no asterisk\nprefix on a given JSDoc line. If it is \\`\"never\"\\` then a problem is raised\nwhen there is an asterisk present.\n\nThe default value is \\`\"always\"\\`. You may also set the default to \\`\"any\"\\`\nand use the \\`tags\\` option to apply to specific tags only.`,\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n tags: {\n additionalProperties: false,\n description: `If you want different values to apply to specific tags, you may use\nthe \\`tags\\` option object. The keys are \\`always\\`, \\`never\\`, or \\`any\\` and\nthe values are arrays of tag names or the special value \\`*description\\`\nwhich applies to the main JSDoc block description.\n\n\\`\\`\\`js\n{\n 'jsdoc/require-asterisk-prefix': ['error', 'always', {\n tags: {\n always: ['*description'],\n any: ['example', 'license'],\n never: ['copyright']\n }\n }]\n}\n
|
|
1
|
+
{"version":3,"file":"requireAsteriskPrefix.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","indent","jsdoc","utils","defaultRequireValue","tags","tagMap","options","source","always","never","currentTag","some","number","tokens","delimiter","description","end","tag","neverFix","postDelimiter","checkNever","checkValue","includes","reportJSDoc","column","line","alwaysFix","start","checkAlways","slice","any","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type","additionalProperties","properties","items","module"],"sources":["../../src/rules/requireAsteriskPrefix.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n utils,\n}) => {\n const [\n defaultRequireValue = 'always',\n {\n tags: tagMap = {},\n } = {},\n ] = context.options;\n\n const {\n source,\n } = jsdoc;\n\n const always = defaultRequireValue === 'always';\n const never = defaultRequireValue === 'never';\n\n /** @type {string} */\n let currentTag;\n source.some(({\n number,\n tokens,\n }) => {\n const {\n delimiter,\n description,\n end,\n tag,\n } = tokens;\n\n /**\n * @returns {void}\n */\n const neverFix = () => {\n tokens.delimiter = '';\n tokens.postDelimiter = '';\n };\n\n /**\n * @param {string} checkValue\n * @returns {boolean}\n */\n const checkNever = (checkValue) => {\n if (delimiter && delimiter !== '/**' && (\n never && !tagMap.always?.includes(checkValue) ||\n tagMap.never?.includes(checkValue)\n )) {\n utils.reportJSDoc('Expected JSDoc line to have no prefix.', {\n column: 0,\n line: number,\n }, neverFix);\n\n return true;\n }\n\n return false;\n };\n\n /**\n * @returns {void}\n */\n const alwaysFix = () => {\n if (!tokens.start) {\n tokens.start = indent + ' ';\n }\n\n tokens.delimiter = '*';\n tokens.postDelimiter = tag || description ? ' ' : '';\n };\n\n /**\n * @param {string} checkValue\n * @returns {boolean}\n */\n const checkAlways = (checkValue) => {\n if (\n !delimiter && (\n always && !tagMap.never?.includes(checkValue) ||\n tagMap.always?.includes(checkValue)\n )\n ) {\n utils.reportJSDoc('Expected JSDoc line to have the prefix.', {\n column: 0,\n line: number,\n }, alwaysFix);\n\n return true;\n }\n\n return false;\n };\n\n if (tag) {\n // Remove at sign\n currentTag = tag.slice(1);\n }\n\n if (\n // If this is the end but has a tag, the delimiter will also be\n // populated and will be safely ignored later\n end && !tag\n ) {\n return false;\n }\n\n if (!currentTag) {\n if (tagMap.any?.includes('*description')) {\n return false;\n }\n\n if (checkNever('*description')) {\n return true;\n }\n\n if (checkAlways('*description')) {\n return true;\n }\n\n return false;\n }\n\n if (tagMap.any?.includes(currentTag)) {\n return false;\n }\n\n if (checkNever(currentTag)) {\n return true;\n }\n\n if (checkAlways(currentTag)) {\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description:\n 'Requires that each JSDoc line starts with an `*`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-asterisk-prefix.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n description: `If it is \\`\"always\"\\` then a problem is raised when there is no asterisk\nprefix on a given JSDoc line. If it is \\`\"never\"\\` then a problem is raised\nwhen there is an asterisk present.\n\nThe default value is \\`\"always\"\\`. You may also set the default to \\`\"any\"\\`\nand use the \\`tags\\` option to apply to specific tags only.`,\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n tags: {\n additionalProperties: false,\n description: `If you want different values to apply to specific tags, you may use\nthe \\`tags\\` option object. The keys are \\`always\\`, \\`never\\`, or \\`any\\` and\nthe values are arrays of tag names or the special value \\`*description\\`\nwhich applies to the main JSDoc block description.\n\n\\`\\`\\`js\n{\n 'jsdoc/require-asterisk-prefix': ['error', 'always', {\n tags: {\n always: ['*description'],\n any: ['example', 'license'],\n never: ['copyright']\n }\n }]\n}\n\\`\\`\\``,\n properties: {\n always: {\n description: `If it is \\`\"always\"\\` then a problem is raised when there is no asterisk\nprefix on a given JSDoc line.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n any: {\n description: 'No problem is raised regardless of asterisk presence or non-presence.',\n items: {\n type: 'string',\n },\n type: 'array',\n },\n never: {\n description: `If it is \\`\"never\"\\` then a problem is raised\nwhen there is an asterisk present.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\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;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,MAAM;EACNC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAM,CACJC,mBAAmB,GAAG,QAAQ,EAC9B;IACEC,IAAI,EAAEC,MAAM,GAAG,CAAC;EAClB,CAAC,GAAG,CAAC,CAAC,CACP,GAAGN,OAAO,CAACO,OAAO;EAEnB,MAAM;IACJC;EACF,CAAC,GAAGN,KAAK;EAET,MAAMO,MAAM,GAAGL,mBAAmB,KAAK,QAAQ;EAC/C,MAAMM,KAAK,GAAGN,mBAAmB,KAAK,OAAO;;EAE7C;EACA,IAAIO,UAAU;EACdH,MAAM,CAACI,IAAI,CAAC,CAAC;IACXC,MAAM;IACNC;EACF,CAAC,KAAK;IACJ,MAAM;MACJC,SAAS;MACTC,WAAW;MACXC,GAAG;MACHC;IACF,CAAC,GAAGJ,MAAM;;IAEV;AACJ;AACA;IACI,MAAMK,QAAQ,GAAGA,CAAA,KAAM;MACrBL,MAAM,CAACC,SAAS,GAAG,EAAE;MACrBD,MAAM,CAACM,aAAa,GAAG,EAAE;IAC3B,CAAC;;IAED;AACJ;AACA;AACA;IACI,MAAMC,UAAU,GAAIC,UAAU,IAAK;MACjC,IAAIP,SAAS,IAAI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uE;cACpF0B,KAAK,EAAE;gBACLH,IAAI,EAAE;cACR,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;YACD7B,KAAK,EAAE;cACLM,WAAW,EAAE;AAC7B,mCAAmC;cACnB0B,KAAK,EAAE;gBACLH,IAAI,EAAE;cACR,CAAC;cACDA,IAAI,EAAE;YACR;UACF,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAI,MAAA,CAAA7C,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -292,8 +292,7 @@ All other tags will treat the text following the tag name, a space, and
|
|
|
292
292
|
an optional curly-bracketed type expression (and another space) as part of
|
|
293
293
|
its "description" (e.g., for \`@returns {someType} some description\`, the
|
|
294
294
|
description is \`some description\` while for \`@some-tag xyz\`, the description
|
|
295
|
-
is \`xyz\`)
|
|
296
|
-
`,
|
|
295
|
+
is \`xyz\`).`,
|
|
297
296
|
items: {
|
|
298
297
|
type: 'string'
|
|
299
298
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireDescriptionCompleteSentence.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_escapeStringRegexp","e","__esModule","default","otherDescriptiveTags","Set","extractParagraphs","text","split","extractSentences","abbreviationsRegex","txt","replaceAll","replace","sentenceEndGrouping","puncts","matchAll","map","sentEnd","sentence","idx","test","isNewLinePrecededByAPeriod","lastLineEndsSentence","lines","some","line","isCapitalized","str","toUpperCase","isTable","charAt","capitalize","slice","validateDescription","description","reportOrig","jsdocNode","sourceCode","tag","newlineBeforeCapsAssumesBadSentenceEnd","descriptionNoHeadings","paragraphs","filter","Boolean","paragraph","parIdx","sentences","fix","fixer","getText","findLast","RegExp","escapeStringRegexp","sentence_","beginning","reg","_$0","$1","replaceText","report","msg","tagObj","source","number","column","paragraphNoAbbreviations","_default","exports","iterateJsdoc","context","jsdoc","utils","abbreviations","options","length","abbreviation","join","getDescription","indices","match","index","toReversed","forEachPreferredTag","matchingJsdocTag","desc","name","getTagDescription","trim","tagsWithNames","getTagsByType","tags","tagsWithoutNames","filterTags","tagName","has","hasOptionTag","trimEnd","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","type","module"],"sources":["../../src/rules/requireDescriptionCompleteSentence.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport escapeStringRegexp from 'escape-string-regexp';\n\nconst otherDescriptiveTags = new Set([\n 'classdesc', 'deprecated', 'exception', 'file', 'fileoverview', 'overview',\n // 'copyright' and 'see' might be good addition, but as the former may be\n // sensitive text, and the latter may have just a link, they are not\n // included by default\n 'summary', 'throws', 'todo', 'yield', 'yields',\n]);\n\n/**\n * @param {string} text\n * @returns {string[]}\n */\nconst extractParagraphs = (text) => {\n return text.split(/(?<![;:])\\n\\n+/v);\n};\n\n/**\n * @param {string} text\n * @param {string|RegExp} abbreviationsRegex\n * @returns {string[]}\n */\nconst extractSentences = (text, abbreviationsRegex) => {\n const txt = text\n // Remove all {} tags.\n .replaceAll(/(?<!^)\\{[\\s\\S]*?\\}\\s*/gv, '')\n\n // Remove custom abbreviations\n .replace(abbreviationsRegex, '');\n\n const sentenceEndGrouping = /([.?!])(?:\\s+|$)/gv;\n\n const puncts = [\n ...txt.matchAll(sentenceEndGrouping),\n ].map((sentEnd) => {\n return sentEnd[0];\n });\n\n return txt\n .split(/[.?!](?:\\s+|$)/v)\n\n // Re-add the dot.\n .map((sentence, idx) => {\n return !puncts[idx] && /^\\s*$/v.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;\n });\n};\n\n/**\n * @param {string} text\n * @returns {boolean}\n */\nconst isNewLinePrecededByAPeriod = (text) => {\n /** @type {boolean} */\n let lastLineEndsSentence;\n\n const lines = text.split('\\n');\n\n return !lines.some((line) => {\n if (lastLineEndsSentence === false && /^[A-Z][a-z]/v.test(line)) {\n return true;\n }\n\n lastLineEndsSentence = /[.:?!\\|]$/v.test(line);\n\n return false;\n });\n};\n\n/**\n * @param {string} str\n * @returns {boolean}\n */\nconst isCapitalized = (str) => {\n return str[0] === str[0].toUpperCase();\n};\n\n/**\n * @param {string} str\n * @returns {boolean}\n */\nconst isTable = (str) => {\n return str.charAt(0) === '|';\n};\n\n/**\n * @param {string} str\n * @returns {string}\n */\nconst capitalize = (str) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\n/**\n * @param {string} description\n * @param {import('../iterateJsdoc.js').Report} reportOrig\n * @param {import('eslint').Rule.Node} jsdocNode\n * @param {string|RegExp} abbreviationsRegex\n * @param {import('eslint').SourceCode} sourceCode\n * @param {import('comment-parser').Spec|{\n * line: import('../iterateJsdoc.js').Integer\n * }} tag\n * @param {boolean} newlineBeforeCapsAssumesBadSentenceEnd\n * @returns {boolean}\n */\nconst validateDescription = (\n description, reportOrig, jsdocNode, abbreviationsRegex,\n sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,\n) => {\n if (!description || (/^\\n+$/v).test(description)) {\n return false;\n }\n\n const descriptionNoHeadings = description.replaceAll(/^\\s*#[^\\n]*(\\n|$)/gmv, '');\n\n const paragraphs = extractParagraphs(descriptionNoHeadings).filter(Boolean);\n\n return paragraphs.some((paragraph, parIdx) => {\n const sentences = extractSentences(paragraph, abbreviationsRegex);\n\n const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n let text = sourceCode.getText(jsdocNode);\n\n if (!/[.:?!]$/v.test(paragraph)) {\n const line = paragraph.split('\\n').findLast(Boolean);\n text = text.replace(new RegExp(`${escapeStringRegexp(\n /** @type {string} */\n (line),\n )}$`, 'mv'), `${line}.`);\n }\n\n for (const sentence of sentences.filter((sentence_) => {\n return !(/^\\s*$/v).test(sentence_) && !isCapitalized(sentence_) &&\n !isTable(sentence_);\n })) {\n const beginning = sentence.split('\\n')[0];\n\n if ('tag' in tag && tag.tag) {\n const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'v');\n\n text = text.replace(reg, (_$0, $1) => {\n return $1 + capitalize(beginning);\n });\n } else {\n text = text.replace(new RegExp('((?:[.?!]|\\\\*|\\\\})\\\\s*)' + escapeStringRegexp(beginning), 'v'), '$1' + capitalize(beginning));\n }\n }\n\n return fixer.replaceText(jsdocNode, text);\n };\n\n /**\n * @param {string} msg\n * @param {import('eslint').Rule.ReportFixer | null | undefined} fixer\n * @param {{\n * line?: number | undefined;\n * column?: number | undefined;\n * } | (import('comment-parser').Spec & {\n * line?: number | undefined;\n * column?: number | undefined;\n * })} tagObj\n * @returns {void}\n */\n const report = (msg, fixer, tagObj) => {\n if ('line' in tagObj) {\n /**\n * @type {{\n * line: number;\n * }}\n */ (tagObj).line += parIdx * 2;\n } else {\n /** @type {import('comment-parser').Spec} */ (\n tagObj\n ).source[0].number += parIdx * 2;\n }\n\n // Avoid errors if old column doesn't exist here\n tagObj.column = 0;\n reportOrig(msg, fixer, tagObj);\n };\n\n if (sentences.some((sentence) => {\n return (/^[.?!]$/v).test(sentence);\n })) {\n report('Sentences must be more than punctuation.', null, tag);\n }\n\n if (sentences.some((sentence) => {\n return !(/^\\s*$/v).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);\n })) {\n report('Sentences should start with an uppercase character.', fix, tag);\n }\n\n const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');\n\n if (!/(?:[.?!\\|]|```)\\s*$/v.test(paragraphNoAbbreviations)) {\n report('Sentences must end with a period.', fix, tag);\n return true;\n }\n\n if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {\n report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag);\n\n return true;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n jsdocNode,\n report,\n sourceCode,\n utils,\n}) => {\n const /** @type {{abbreviations: string[], newlineBeforeCapsAssumesBadSentenceEnd: boolean}} */ {\n abbreviations = [],\n newlineBeforeCapsAssumesBadSentenceEnd = false,\n } = context.options[0] || {};\n\n const abbreviationsRegex = abbreviations.length ?\n new RegExp('\\\\b' + abbreviations.map((abbreviation) => {\n return escapeStringRegexp(abbreviation.replaceAll(/\\.$/gv, '') + '.');\n }).join('|') + '(?:$|\\\\s)', 'gv') :\n '';\n\n let {\n description,\n } = utils.getDescription();\n\n const indices = [\n ...description.matchAll(/```[\\s\\S]*```/gv),\n ].map((match) => {\n const {\n index,\n } = match;\n const [\n {\n length,\n },\n ] = match;\n return {\n index,\n length,\n };\n }).toReversed();\n\n for (const {\n index,\n length,\n } of indices) {\n description = description.slice(0, index) +\n description.slice(/** @type {import('../iterateJsdoc.js').Integer} */ (\n index\n ) + length);\n }\n\n if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {\n line: jsdoc.source[0].number + 1,\n }, newlineBeforeCapsAssumesBadSentenceEnd)) {\n return;\n }\n\n utils.forEachPreferredTag('description', (matchingJsdocTag) => {\n const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim();\n validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd);\n }, true);\n\n const {\n tagsWithNames,\n } = utils.getTagsByType(jsdoc.tags);\n const tagsWithoutNames = utils.filterTags(({\n tag: tagName,\n }) => {\n return otherDescriptiveTags.has(tagName) ||\n utils.hasOptionTag(tagName) && !tagsWithNames.some(({\n tag,\n }) => {\n // If user accidentally adds tags with names (or like `returns`\n // get parsed as having names), do not add to this list\n return tag === tagName;\n });\n });\n\n tagsWithNames.some((tag) => {\n const desc = /** @type {string} */ (\n utils.getTagDescription(tag)\n ).replace(/^- /v, '').trimEnd();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description-complete-sentence.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n abbreviations: {\n description: `You can provide an \\`abbreviations\\` options array to avoid such strings of text\nbeing treated as sentence endings when followed by dots. The \\`.\\` is not\nnecessary at the end of the array items.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n newlineBeforeCapsAssumesBadSentenceEnd: {\n description: `When \\`false\\` (the new default), we will not assume capital letters after\nnewlines are an incorrect way to end the sentence (they may be proper\nnouns, for example).`,\n type: 'boolean',\n },\n tags: {\n description: `If you want additional tags to be checked for their descriptions, you may\nadd them within this option.\n\n\\`\\`\\`js\n{\n 'jsdoc/require-description-complete-sentence': ['error', {\n tags: ['see', 'copyright']\n }]\n}\n\\`\\`\\`\n\nThe tags \\`@param\\`/\\`@arg\\`/\\`@argument\\` and \\`@property\\`/\\`@prop\\` will be properly\nparsed to ensure that the checked \"description\" text includes only the text\nafter the name.\n\nAll other tags will treat the text following the tag name, a space, and\nan optional curly-bracketed type expression (and another space) as part of\nits \"description\" (e.g., for \\`@returns {someType} some description\\`, the\ndescription is \\`some description\\` while for \\`@some-tag xyz\\`, the description\nis \\`xyz\\`).\n`,\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;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,U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AAE;QACVhC,aAAa,EAAE;UACbtC,WAAW,EAAE;AACzB;AACA,yCAAyC;UAC7BuE,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDnE,sCAAsC,EAAE;UACtCL,WAAW,EAAE;AACzB;AACA,qBAAqB;UACTwE,IAAI,EAAE;QACR,CAAC;QACDhB,IAAI,EAAE;UACJxD,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;UACWuE,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,MAAA,CAAAxC,OAAA,GAAAA,OAAA,CAAAjE,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"requireDescriptionCompleteSentence.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_escapeStringRegexp","e","__esModule","default","otherDescriptiveTags","Set","extractParagraphs","text","split","extractSentences","abbreviationsRegex","txt","replaceAll","replace","sentenceEndGrouping","puncts","matchAll","map","sentEnd","sentence","idx","test","isNewLinePrecededByAPeriod","lastLineEndsSentence","lines","some","line","isCapitalized","str","toUpperCase","isTable","charAt","capitalize","slice","validateDescription","description","reportOrig","jsdocNode","sourceCode","tag","newlineBeforeCapsAssumesBadSentenceEnd","descriptionNoHeadings","paragraphs","filter","Boolean","paragraph","parIdx","sentences","fix","fixer","getText","findLast","RegExp","escapeStringRegexp","sentence_","beginning","reg","_$0","$1","replaceText","report","msg","tagObj","source","number","column","paragraphNoAbbreviations","_default","exports","iterateJsdoc","context","jsdoc","utils","abbreviations","options","length","abbreviation","join","getDescription","indices","match","index","toReversed","forEachPreferredTag","matchingJsdocTag","desc","name","getTagDescription","trim","tagsWithNames","getTagsByType","tags","tagsWithoutNames","filterTags","tagName","has","hasOptionTag","trimEnd","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","type","module"],"sources":["../../src/rules/requireDescriptionCompleteSentence.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport escapeStringRegexp from 'escape-string-regexp';\n\nconst otherDescriptiveTags = new Set([\n 'classdesc', 'deprecated', 'exception', 'file', 'fileoverview', 'overview',\n // 'copyright' and 'see' might be good addition, but as the former may be\n // sensitive text, and the latter may have just a link, they are not\n // included by default\n 'summary', 'throws', 'todo', 'yield', 'yields',\n]);\n\n/**\n * @param {string} text\n * @returns {string[]}\n */\nconst extractParagraphs = (text) => {\n return text.split(/(?<![;:])\\n\\n+/v);\n};\n\n/**\n * @param {string} text\n * @param {string|RegExp} abbreviationsRegex\n * @returns {string[]}\n */\nconst extractSentences = (text, abbreviationsRegex) => {\n const txt = text\n // Remove all {} tags.\n .replaceAll(/(?<!^)\\{[\\s\\S]*?\\}\\s*/gv, '')\n\n // Remove custom abbreviations\n .replace(abbreviationsRegex, '');\n\n const sentenceEndGrouping = /([.?!])(?:\\s+|$)/gv;\n\n const puncts = [\n ...txt.matchAll(sentenceEndGrouping),\n ].map((sentEnd) => {\n return sentEnd[0];\n });\n\n return txt\n .split(/[.?!](?:\\s+|$)/v)\n\n // Re-add the dot.\n .map((sentence, idx) => {\n return !puncts[idx] && /^\\s*$/v.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;\n });\n};\n\n/**\n * @param {string} text\n * @returns {boolean}\n */\nconst isNewLinePrecededByAPeriod = (text) => {\n /** @type {boolean} */\n let lastLineEndsSentence;\n\n const lines = text.split('\\n');\n\n return !lines.some((line) => {\n if (lastLineEndsSentence === false && /^[A-Z][a-z]/v.test(line)) {\n return true;\n }\n\n lastLineEndsSentence = /[.:?!\\|]$/v.test(line);\n\n return false;\n });\n};\n\n/**\n * @param {string} str\n * @returns {boolean}\n */\nconst isCapitalized = (str) => {\n return str[0] === str[0].toUpperCase();\n};\n\n/**\n * @param {string} str\n * @returns {boolean}\n */\nconst isTable = (str) => {\n return str.charAt(0) === '|';\n};\n\n/**\n * @param {string} str\n * @returns {string}\n */\nconst capitalize = (str) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\n/**\n * @param {string} description\n * @param {import('../iterateJsdoc.js').Report} reportOrig\n * @param {import('eslint').Rule.Node} jsdocNode\n * @param {string|RegExp} abbreviationsRegex\n * @param {import('eslint').SourceCode} sourceCode\n * @param {import('comment-parser').Spec|{\n * line: import('../iterateJsdoc.js').Integer\n * }} tag\n * @param {boolean} newlineBeforeCapsAssumesBadSentenceEnd\n * @returns {boolean}\n */\nconst validateDescription = (\n description, reportOrig, jsdocNode, abbreviationsRegex,\n sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,\n) => {\n if (!description || (/^\\n+$/v).test(description)) {\n return false;\n }\n\n const descriptionNoHeadings = description.replaceAll(/^\\s*#[^\\n]*(\\n|$)/gmv, '');\n\n const paragraphs = extractParagraphs(descriptionNoHeadings).filter(Boolean);\n\n return paragraphs.some((paragraph, parIdx) => {\n const sentences = extractSentences(paragraph, abbreviationsRegex);\n\n const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n let text = sourceCode.getText(jsdocNode);\n\n if (!/[.:?!]$/v.test(paragraph)) {\n const line = paragraph.split('\\n').findLast(Boolean);\n text = text.replace(new RegExp(`${escapeStringRegexp(\n /** @type {string} */\n (line),\n )}$`, 'mv'), `${line}.`);\n }\n\n for (const sentence of sentences.filter((sentence_) => {\n return !(/^\\s*$/v).test(sentence_) && !isCapitalized(sentence_) &&\n !isTable(sentence_);\n })) {\n const beginning = sentence.split('\\n')[0];\n\n if ('tag' in tag && tag.tag) {\n const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'v');\n\n text = text.replace(reg, (_$0, $1) => {\n return $1 + capitalize(beginning);\n });\n } else {\n text = text.replace(new RegExp('((?:[.?!]|\\\\*|\\\\})\\\\s*)' + escapeStringRegexp(beginning), 'v'), '$1' + capitalize(beginning));\n }\n }\n\n return fixer.replaceText(jsdocNode, text);\n };\n\n /**\n * @param {string} msg\n * @param {import('eslint').Rule.ReportFixer | null | undefined} fixer\n * @param {{\n * line?: number | undefined;\n * column?: number | undefined;\n * } | (import('comment-parser').Spec & {\n * line?: number | undefined;\n * column?: number | undefined;\n * })} tagObj\n * @returns {void}\n */\n const report = (msg, fixer, tagObj) => {\n if ('line' in tagObj) {\n /**\n * @type {{\n * line: number;\n * }}\n */ (tagObj).line += parIdx * 2;\n } else {\n /** @type {import('comment-parser').Spec} */ (\n tagObj\n ).source[0].number += parIdx * 2;\n }\n\n // Avoid errors if old column doesn't exist here\n tagObj.column = 0;\n reportOrig(msg, fixer, tagObj);\n };\n\n if (sentences.some((sentence) => {\n return (/^[.?!]$/v).test(sentence);\n })) {\n report('Sentences must be more than punctuation.', null, tag);\n }\n\n if (sentences.some((sentence) => {\n return !(/^\\s*$/v).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);\n })) {\n report('Sentences should start with an uppercase character.', fix, tag);\n }\n\n const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');\n\n if (!/(?:[.?!\\|]|```)\\s*$/v.test(paragraphNoAbbreviations)) {\n report('Sentences must end with a period.', fix, tag);\n return true;\n }\n\n if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {\n report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag);\n\n return true;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n jsdocNode,\n report,\n sourceCode,\n utils,\n}) => {\n const /** @type {{abbreviations: string[], newlineBeforeCapsAssumesBadSentenceEnd: boolean}} */ {\n abbreviations = [],\n newlineBeforeCapsAssumesBadSentenceEnd = false,\n } = context.options[0] || {};\n\n const abbreviationsRegex = abbreviations.length ?\n new RegExp('\\\\b' + abbreviations.map((abbreviation) => {\n return escapeStringRegexp(abbreviation.replaceAll(/\\.$/gv, '') + '.');\n }).join('|') + '(?:$|\\\\s)', 'gv') :\n '';\n\n let {\n description,\n } = utils.getDescription();\n\n const indices = [\n ...description.matchAll(/```[\\s\\S]*```/gv),\n ].map((match) => {\n const {\n index,\n } = match;\n const [\n {\n length,\n },\n ] = match;\n return {\n index,\n length,\n };\n }).toReversed();\n\n for (const {\n index,\n length,\n } of indices) {\n description = description.slice(0, index) +\n description.slice(/** @type {import('../iterateJsdoc.js').Integer} */ (\n index\n ) + length);\n }\n\n if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {\n line: jsdoc.source[0].number + 1,\n }, newlineBeforeCapsAssumesBadSentenceEnd)) {\n return;\n }\n\n utils.forEachPreferredTag('description', (matchingJsdocTag) => {\n const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim();\n validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd);\n }, true);\n\n const {\n tagsWithNames,\n } = utils.getTagsByType(jsdoc.tags);\n const tagsWithoutNames = utils.filterTags(({\n tag: tagName,\n }) => {\n return otherDescriptiveTags.has(tagName) ||\n utils.hasOptionTag(tagName) && !tagsWithNames.some(({\n tag,\n }) => {\n // If user accidentally adds tags with names (or like `returns`\n // get parsed as having names), do not add to this list\n return tag === tagName;\n });\n });\n\n tagsWithNames.some((tag) => {\n const desc = /** @type {string} */ (\n utils.getTagDescription(tag)\n ).replace(/^- /v, '').trimEnd();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description-complete-sentence.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n abbreviations: {\n description: `You can provide an \\`abbreviations\\` options array to avoid such strings of text\nbeing treated as sentence endings when followed by dots. The \\`.\\` is not\nnecessary at the end of the array items.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n newlineBeforeCapsAssumesBadSentenceEnd: {\n description: `When \\`false\\` (the new default), we will not assume capital letters after\nnewlines are an incorrect way to end the sentence (they may be proper\nnouns, for example).`,\n type: 'boolean',\n },\n tags: {\n description: `If you want additional tags to be checked for their descriptions, you may\nadd them within this option.\n\n\\`\\`\\`js\n{\n 'jsdoc/require-description-complete-sentence': ['error', {\n tags: ['see', 'copyright']\n }]\n}\n\\`\\`\\`\n\nThe tags \\`@param\\`/\\`@arg\\`/\\`@argument\\` and \\`@property\\`/\\`@prop\\` will be properly\nparsed to ensure that the checked \"description\" text includes only the text\nafter the name.\n\nAll other tags will treat the text following the tag name, a space, and\nan optional curly-bracketed type expression (and another space) as part of\nits \"description\" (e.g., for \\`@returns {someType} some description\\`, the\ndescription is \\`some description\\` while for \\`@some-tag xyz\\`, the description\nis \\`xyz\\`).`,\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;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD,MAAMG,oBAAoB,GAAG,IAAIC,GAAG,CAAC,CACnC,WAAW,EAAE,YAA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ACDA,IAAI,EAAE;QACR,CAAC;QACDnE,sCAAsC,EAAE;UACtCL,WAAW,EAAE;AACzB;AACA,qBAAqB;UACTwE,IAAI,EAAE;QACR,CAAC;QACDhB,IAAI,EAAE;UACJxD,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;UACDuE,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,MAAA,CAAAxC,OAAA,GAAAA,OAAA,CAAAjE,OAAA","ignoreList":[]}
|
|
@@ -156,9 +156,7 @@ have a way to allow multiple licenses for the whole page by using the SPDX
|
|
|
156
156
|
Note that the tag names are the main JSDoc tag name, so you should use \`file\`
|
|
157
157
|
in this configuration object regardless of whether you have configured
|
|
158
158
|
\`fileoverview\` instead of \`file\` on \`tagNamePreference\` (i.e., \`fileoverview\`
|
|
159
|
-
will be checked, but you must use \`file\` on the configuration object)
|
|
160
|
-
|
|
161
|
-
`,
|
|
159
|
+
will be checked, but you must use \`file\` on the configuration object).`,
|
|
162
160
|
patternProperties: {
|
|
163
161
|
'.*': {
|
|
164
162
|
additionalProperties: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireFileOverview.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","defaultTags","file","initialCommentsOnly","mustExist","preventDuplicates","setDefaults","state","globalTags","hasDuplicates","hasTag","hasNonCommentBeforeTag","_default","exports","iterateJsdoc","context","jsdocNode","utils","tags","options","tagName","Object","keys","targetTagName","getPreferredTagName","Boolean","hasDuplicate","hasNonComment","range","exit","entries","obj","getPreferredTagNameObject","reportSettings","replacement","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","patternProperties","type","nonComment","node","module"],"sources":["../../src/rules/requireFileOverview.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nconst defaultTags = {\n file: {\n initialCommentsOnly: true,\n mustExist: true,\n preventDuplicates: true,\n },\n};\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @returns {void}\n */\nconst setDefaults = (state) => {\n // First iteration\n if (!state.globalTags) {\n state.globalTags = {};\n state.hasDuplicates = {};\n state.hasTag = {};\n state.hasNonCommentBeforeTag = {};\n }\n};\n\nexport default iterateJsdoc(({\n context,\n jsdocNode,\n state,\n utils,\n}) => {\n const {\n tags = defaultTags,\n } = context.options[0] || {};\n\n setDefaults(state);\n\n for (const tagName of Object.keys(tags)) {\n const targetTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n\n const hasTag = Boolean(targetTagName && utils.hasTag(targetTagName));\n\n state.hasTag[tagName] = hasTag || state.hasTag[tagName];\n\n const hasDuplicate = state.hasDuplicates[tagName];\n\n if (hasDuplicate === false) {\n // Was marked before, so if a tag now, is a dupe\n state.hasDuplicates[tagName] = hasTag;\n } else if (!hasDuplicate && hasTag) {\n // No dupes set before, but has first tag, so change state\n // from `undefined` to `false` so can detect next time\n state.hasDuplicates[tagName] = false;\n state.hasNonCommentBeforeTag[tagName] = state.hasNonComment &&\n state.hasNonComment < jsdocNode.range[0];\n }\n }\n}, {\n exit ({\n context,\n state,\n utils,\n }) {\n setDefaults(state);\n const {\n tags = defaultTags,\n } = context.options[0] || {};\n\n for (const [\n tagName,\n {\n initialCommentsOnly = false,\n mustExist = false,\n preventDuplicates = false,\n },\n ] of Object.entries(tags)) {\n const obj = utils.getPreferredTagNameObject({\n tagName,\n });\n if (obj && typeof obj === 'object' && 'blocked' in obj) {\n utils.reportSettings(\n `\\`settings.jsdoc.tagNamePreference\\` cannot block @${obj.tagName} ` +\n 'for the `require-file-overview` rule',\n );\n } else {\n const targetTagName = (\n obj && typeof obj === 'object' && obj.replacement\n ) || obj;\n if (mustExist && !state.hasTag[tagName]) {\n utils.reportSettings(`Missing @${targetTagName}`);\n }\n\n if (preventDuplicates && state.hasDuplicates[tagName]) {\n utils.reportSettings(\n `Duplicate @${targetTagName}`,\n );\n }\n\n if (initialCommentsOnly &&\n state.hasNonCommentBeforeTag[tagName]\n ) {\n utils.reportSettings(\n `@${targetTagName} should be at the beginning of the file`,\n );\n }\n }\n }\n },\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-file-overview.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n description: `The keys of this object are tag names, and the values are configuration\nobjects indicating what will be checked for these whole-file tags.\n\nEach configuration object has 3 potential boolean keys (which default\nto \\`false\\` when this option is supplied).\n\n1. \\`mustExist\\` - enforces that all files have a \\`@file\\`, \\`@fileoverview\\`, or \\`@overview\\` tag.\n2. \\`preventDuplicates\\` - enforces that duplicate file overview tags within a given file will be reported\n3. \\`initialCommentsOnly\\` - reports file overview tags which are not, as per\n [the docs](https://jsdoc.app/tags-file.html), \"at the beginning of\n the file\"–where beginning of the file is interpreted in this rule\n as being when the overview tag is not preceded by anything other than\n a comment.\n\nWhen no \\`tags\\` is present, the default is:\n\n\\`\\`\\`json\n{\n \"file\": {\n \"initialCommentsOnly\": true,\n \"mustExist\": true,\n \"preventDuplicates\": true,\n }\n}\n\\`\\`\\`\n\nYou can add additional tag names and/or override \\`file\\` if you supply this\noption, e.g., in place of or in addition to \\`file\\`, giving other potential\nfile global tags like \\`@license\\`, \\`@copyright\\`, \\`@author\\`, \\`@module\\` or\n\\`@exports\\`, optionally restricting them to a single use or preventing them\nfrom being preceded by anything besides comments.\n\nFor example:\n\n\\`\\`\\`js\n{\n \"license\": {\n \"mustExist\": true,\n \"preventDuplicates\": true,\n }\n}\n\\`\\`\\`\n\nThis would require one and only one \\`@license\\` in the file, though because\n\\`initialCommentsOnly\\` is absent and defaults to \\`false\\`, the \\`@license\\`\ncan be anywhere.\n\nIn the case of \\`@license\\`, you can use this rule along with the\n\\`check-values\\` rule (with its \\`allowedLicenses\\` or \\`licensePattern\\` options),\nto enforce a license whitelist be present on every JS file.\n\nNote that if you choose to use \\`preventDuplicates\\` with \\`license\\`, you still\nhave a way to allow multiple licenses for the whole page by using the SPDX\n\"AND\" expression, e.g., \\`@license (MIT AND GPL-3.0)\\`.\n\nNote that the tag names are the main JSDoc tag name, so you should use \\`file\\`\nin this configuration object regardless of whether you have configured\n\\`fileoverview\\` instead of \\`file\\` on \\`tagNamePreference\\` (i.e., \\`fileoverview\\`\nwill be checked, but you must use \\`file\\` on the configuration object).\n\n`,\n patternProperties: {\n '.*': {\n additionalProperties: false,\n properties: {\n initialCommentsOnly: {\n type: 'boolean',\n },\n mustExist: {\n type: 'boolean',\n },\n preventDuplicates: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n nonComment ({\n node,\n state,\n }) {\n if (!state.hasNonComment) {\n state.hasNonComment = node.range[0];\n }\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,MAAMG,WAAW,GAAG;EAClBC,IAAI,EAAE;IACJC,mBAAmB,EAAE,IAAI;IACzBC,SAAS,EAAE,IAAI;IACfC,iBAAiB,EAAE;EACrB;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAIC,KAAK,IAAK;EAC7B;EACA,IAAI,CAACA,KAAK,CAACC,UAAU,EAAE;IACrBD,KAAK,CAACC,UAAU,GAAG,CAAC,CAAC;IACrBD,KAAK,CAACE,aAAa,GAAG,CAAC,CAAC;IAC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GAA2G;MACxHC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVxB,IAAI,EAAE;UACJoB,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;UACWK,iBAAiB,EAAE;YACjB,IAAI,EAAE;cACJF,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVvC,mBAAmB,EAAE;kBACnByC,IAAI,EAAE;gBACR,CAAC;gBACDxC,SAAS,EAAE;kBACTwC,IAAI,EAAE;gBACR,CAAC;gBACDvC,iBAAiB,EAAE;kBACjBuC,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR;UACF,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR,CAAC;EACDC,UAAUA,CAAE;IACVC,IAAI;IACJvC;EACF,CAAC,EAAE;IACD,IAAI,CAACA,KAAK,CAACoB,aAAa,EAAE;MACxBpB,KAAK,CAACoB,aAAa,GAAGmB,IAAI,CAAClB,KAAK,CAAC,CAAC,CAAC;IACrC;EACF;AACF,CAAC,CAAC;AAAAmB,MAAA,CAAAlC,OAAA,GAAAA,OAAA,CAAAb,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"requireFileOverview.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","defaultTags","file","initialCommentsOnly","mustExist","preventDuplicates","setDefaults","state","globalTags","hasDuplicates","hasTag","hasNonCommentBeforeTag","_default","exports","iterateJsdoc","context","jsdocNode","utils","tags","options","tagName","Object","keys","targetTagName","getPreferredTagName","Boolean","hasDuplicate","hasNonComment","range","exit","entries","obj","getPreferredTagNameObject","reportSettings","replacement","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","patternProperties","type","nonComment","node","module"],"sources":["../../src/rules/requireFileOverview.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nconst defaultTags = {\n file: {\n initialCommentsOnly: true,\n mustExist: true,\n preventDuplicates: true,\n },\n};\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @returns {void}\n */\nconst setDefaults = (state) => {\n // First iteration\n if (!state.globalTags) {\n state.globalTags = {};\n state.hasDuplicates = {};\n state.hasTag = {};\n state.hasNonCommentBeforeTag = {};\n }\n};\n\nexport default iterateJsdoc(({\n context,\n jsdocNode,\n state,\n utils,\n}) => {\n const {\n tags = defaultTags,\n } = context.options[0] || {};\n\n setDefaults(state);\n\n for (const tagName of Object.keys(tags)) {\n const targetTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n\n const hasTag = Boolean(targetTagName && utils.hasTag(targetTagName));\n\n state.hasTag[tagName] = hasTag || state.hasTag[tagName];\n\n const hasDuplicate = state.hasDuplicates[tagName];\n\n if (hasDuplicate === false) {\n // Was marked before, so if a tag now, is a dupe\n state.hasDuplicates[tagName] = hasTag;\n } else if (!hasDuplicate && hasTag) {\n // No dupes set before, but has first tag, so change state\n // from `undefined` to `false` so can detect next time\n state.hasDuplicates[tagName] = false;\n state.hasNonCommentBeforeTag[tagName] = state.hasNonComment &&\n state.hasNonComment < jsdocNode.range[0];\n }\n }\n}, {\n exit ({\n context,\n state,\n utils,\n }) {\n setDefaults(state);\n const {\n tags = defaultTags,\n } = context.options[0] || {};\n\n for (const [\n tagName,\n {\n initialCommentsOnly = false,\n mustExist = false,\n preventDuplicates = false,\n },\n ] of Object.entries(tags)) {\n const obj = utils.getPreferredTagNameObject({\n tagName,\n });\n if (obj && typeof obj === 'object' && 'blocked' in obj) {\n utils.reportSettings(\n `\\`settings.jsdoc.tagNamePreference\\` cannot block @${obj.tagName} ` +\n 'for the `require-file-overview` rule',\n );\n } else {\n const targetTagName = (\n obj && typeof obj === 'object' && obj.replacement\n ) || obj;\n if (mustExist && !state.hasTag[tagName]) {\n utils.reportSettings(`Missing @${targetTagName}`);\n }\n\n if (preventDuplicates && state.hasDuplicates[tagName]) {\n utils.reportSettings(\n `Duplicate @${targetTagName}`,\n );\n }\n\n if (initialCommentsOnly &&\n state.hasNonCommentBeforeTag[tagName]\n ) {\n utils.reportSettings(\n `@${targetTagName} should be at the beginning of the file`,\n );\n }\n }\n }\n },\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-file-overview.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n description: `The keys of this object are tag names, and the values are configuration\nobjects indicating what will be checked for these whole-file tags.\n\nEach configuration object has 3 potential boolean keys (which default\nto \\`false\\` when this option is supplied).\n\n1. \\`mustExist\\` - enforces that all files have a \\`@file\\`, \\`@fileoverview\\`, or \\`@overview\\` tag.\n2. \\`preventDuplicates\\` - enforces that duplicate file overview tags within a given file will be reported\n3. \\`initialCommentsOnly\\` - reports file overview tags which are not, as per\n [the docs](https://jsdoc.app/tags-file.html), \"at the beginning of\n the file\"–where beginning of the file is interpreted in this rule\n as being when the overview tag is not preceded by anything other than\n a comment.\n\nWhen no \\`tags\\` is present, the default is:\n\n\\`\\`\\`json\n{\n \"file\": {\n \"initialCommentsOnly\": true,\n \"mustExist\": true,\n \"preventDuplicates\": true,\n }\n}\n\\`\\`\\`\n\nYou can add additional tag names and/or override \\`file\\` if you supply this\noption, e.g., in place of or in addition to \\`file\\`, giving other potential\nfile global tags like \\`@license\\`, \\`@copyright\\`, \\`@author\\`, \\`@module\\` or\n\\`@exports\\`, optionally restricting them to a single use or preventing them\nfrom being preceded by anything besides comments.\n\nFor example:\n\n\\`\\`\\`js\n{\n \"license\": {\n \"mustExist\": true,\n \"preventDuplicates\": true,\n }\n}\n\\`\\`\\`\n\nThis would require one and only one \\`@license\\` in the file, though because\n\\`initialCommentsOnly\\` is absent and defaults to \\`false\\`, the \\`@license\\`\ncan be anywhere.\n\nIn the case of \\`@license\\`, you can use this rule along with the\n\\`check-values\\` rule (with its \\`allowedLicenses\\` or \\`licensePattern\\` options),\nto enforce a license whitelist be present on every JS file.\n\nNote that if you choose to use \\`preventDuplicates\\` with \\`license\\`, you still\nhave a way to allow multiple licenses for the whole page by using the SPDX\n\"AND\" expression, e.g., \\`@license (MIT AND GPL-3.0)\\`.\n\nNote that the tag names are the main JSDoc tag name, so you should use \\`file\\`\nin this configuration object regardless of whether you have configured\n\\`fileoverview\\` instead of \\`file\\` on \\`tagNamePreference\\` (i.e., \\`fileoverview\\`\nwill be checked, but you must use \\`file\\` on the configuration object).`,\n patternProperties: {\n '.*': {\n additionalProperties: false,\n properties: {\n initialCommentsOnly: {\n type: 'boolean',\n },\n mustExist: {\n type: 'boolean',\n },\n preventDuplicates: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n nonComment ({\n node,\n state,\n }) {\n if (!state.hasNonComment) {\n state.hasNonComment = node.range[0];\n }\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,MAAMG,WAAW,GAAG;EAClBC,IAAI,EAAE;IACJC,mBAAmB,EAAE,IAAI;IACzBC,SAAS,EAAE,IAAI;IACfC,iBAAiB,EA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nBI,KAAK,CAACI,sBAAsB,CAACS,OAAO,CAAC,EACvC;UACAH,KAAK,CAACgB,cAAc,CAClB,IAAIV,aAAa,yCACnB,CAAC;QACH;MACF;IACF;EACF,CAAC;EACDY,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,2GAA2G;MACxHC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVxB,IAAI,EAAE;UACJoB,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAyE;UAC7DK,iBAAiB,EAAE;YACjB,IAAI,EAAE;cACJF,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVvC,mBAAmB,EAAE;kBACnByC,IAAI,EAAE;gBACR,CAAC;gBACDxC,SAAS,EAAE;kBACTwC,IAAI,EAAE;gBACR,CAAC;gBACDvC,iBAAiB,EAAE;kBACjBuC,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR;UACF,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR,CAAC;EACDC,UAAUA,CAAE;IACVC,IAAI;IACJvC;EACF,CAAC,EAAE;IACD,IAAI,CAACA,KAAK,CAACoB,aAAa,EAAE;MACxBpB,KAAK,CAACoB,aAAa,GAAGmB,IAAI,CAAClB,KAAK,CAAC,CAAC,CAAC;IACrC;EACF;AACF,CAAC,CAAC;AAAAmB,MAAA,CAAAlC,OAAA,GAAAA,OAAA,CAAAb,OAAA","ignoreList":[]}
|
|
@@ -154,8 +154,7 @@ other tags besides the \`@param\` tag (or the \`@arg\` tag if so set).`,
|
|
|
154
154
|
to ensure \`@property\` never uses hyphens. A key can also be set as \`*\`, e.g.,
|
|
155
155
|
\`'*': 'always'\` to apply hyphen checking to any tag (besides the preferred
|
|
156
156
|
\`@param\` tag which follows the main string option setting and besides any
|
|
157
|
-
other \`tags\` entries)
|
|
158
|
-
`
|
|
157
|
+
other \`tags\` entries).`
|
|
159
158
|
}
|
|
160
159
|
},
|
|
161
160
|
type: 'object'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireHyphenBeforeParamDescription.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","jsdoc","utils","mainCircumstance","tags","options","tgs","checkHyphens","jsdocTag","targetTagName","circumstance","always","desc","getTagDescription","trim","startsWithHyphen","test","hyphenNewline","lines","tokens","source","description","fixIt","replace","name","reportJSDoc","line","number","postName","forEachPreferredTag","tagEntries","Object","entries","tagName","preferredParamTag","getPreferredTagName","tag","some","tagNme","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type","additionalProperties","properties","anyOf","patternProperties","module"],"sources":["../../src/rules/requireHyphenBeforeParamDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const [\n mainCircumstance,\n {\n tags = null,\n } = {},\n ] = context.options;\n\n const tgs = /**\n * @type {null|\"any\"|{[key: string]: \"always\"|\"never\"}}\n */ (tags);\n\n /**\n * @param {import('@es-joy/jsdoccomment').JsdocTagWithInline} jsdocTag\n * @param {string} targetTagName\n * @param {\"always\"|\"never\"} [circumstance]\n * @returns {void}\n */\n const checkHyphens = (jsdocTag, targetTagName, circumstance = mainCircumstance) => {\n const always = !circumstance || circumstance === 'always';\n const desc = /** @type {string} */ (utils.getTagDescription(jsdocTag));\n if (!desc.trim()) {\n return;\n }\n\n const startsWithHyphen = (/^\\s*-/v).test(desc);\n const hyphenNewline = (/^\\s*-\\n/v).test(desc);\n\n let lines = 0;\n for (const {\n tokens,\n } of jsdocTag.source) {\n if (tokens.description) {\n break;\n }\n\n lines++;\n }\n\n if (always && !hyphenNewline) {\n if (!startsWithHyphen) {\n let fixIt = true;\n for (const {\n tokens,\n } of jsdocTag.source) {\n if (tokens.description) {\n tokens.description = tokens.description.replace(\n /^(\\s*)/v, '$1- ',\n );\n break;\n }\n\n // Linebreak after name since has no description\n if (tokens.name) {\n fixIt = false;\n break;\n }\n }\n\n if (fixIt) {\n utils.reportJSDoc(\n `There must be a hyphen before @${targetTagName} description.`,\n {\n line: jsdocTag.source[0].number + lines,\n },\n () => {},\n );\n }\n }\n } else if (startsWithHyphen) {\n utils.reportJSDoc(\n always ?\n `There must be no hyphen followed by newline after the @${targetTagName} name.` :\n `There must be no hyphen before @${targetTagName} description.`,\n {\n line: jsdocTag.source[0].number + lines,\n },\n () => {\n for (const {\n tokens,\n } of jsdocTag.source) {\n if (tokens.description) {\n tokens.description = tokens.description.replace(\n /^\\s*-\\s*/v, '',\n );\n if (hyphenNewline) {\n tokens.postName = '';\n }\n\n break;\n }\n }\n },\n true,\n );\n }\n };\n\n utils.forEachPreferredTag('param', checkHyphens);\n if (tgs) {\n const tagEntries = Object.entries(tgs);\n for (const [\n tagName,\n circumstance,\n ] of tagEntries) {\n if (tagName === '*') {\n const preferredParamTag = utils.getPreferredTagName({\n tagName: 'param',\n });\n for (const {\n tag,\n } of jsdoc.tags) {\n if (tag === preferredParamTag || tagEntries.some(([\n tagNme,\n ]) => {\n return tagNme !== '*' && tagNme === tag;\n })) {\n continue;\n }\n\n utils.forEachPreferredTag(tag, (jsdocTag, targetTagName) => {\n checkHyphens(\n jsdocTag,\n targetTagName,\n /** @type {\"always\"|\"never\"} */ (circumstance),\n );\n });\n }\n\n continue;\n }\n\n utils.forEachPreferredTag(tagName, (jsdocTag, targetTagName) => {\n checkHyphens(\n jsdocTag,\n targetTagName,\n /** @type {\"always\"|\"never\"} */ (circumstance),\n );\n });\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires a hyphen before the `@param` description (and optionally before `@property` descriptions).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-hyphen-before-param-description.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n description: `If the string is \\`\"always\"\\` then a problem is raised when there is no hyphen\nbefore the description. If it is \\`\"never\"\\` then a problem is raised when there\nis a hyphen before the description. The default value is \\`\"always\"\\`.\n\nEven if hyphens are set to \"always\" appear after the tag name, they will\nactually be forbidden in the event that they are followed immediately by\nthe end of a line (this will otherwise cause Visual Studio Code to display\nincorrectly).`,\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n description: `The options object may have the following property to indicate behavior for\nother tags besides the \\`@param\\` tag (or the \\`@arg\\` tag if so set).`,\n properties: {\n tags: {\n anyOf: [\n {\n patternProperties: {\n '.*': {\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n {\n enum: [\n 'any',\n ],\n type: 'string',\n },\n ],\n description: `Object whose keys indicate different tags to check for the\n presence or absence of hyphens; the key value should be \"always\" or \"never\",\n indicating how hyphens are to be applied, e.g., \\`{property: 'never'}\\`\n to ensure \\`@property\\` never uses hyphens. A key can also be set as \\`*\\`, e.g.,\n \\`'*': 'always'\\` to apply hyphen checking to any tag (besides the preferred\n \\`@param\\` tag which follows the main string option setting and besides any\n other \\`tags\\` entries).\n`,\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAA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,IAAI,EAAE,CACJ,KAAK,CACN;YACDC,IAAI,EAAE;UACR,CAAC,CACF;UACDzB,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;QACU;MACF,CAAC;MACDyB,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAK,MAAA,CAAArD,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"requireHyphenBeforeParamDescription.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","jsdoc","utils","mainCircumstance","tags","options","tgs","checkHyphens","jsdocTag","targetTagName","circumstance","always","desc","getTagDescription","trim","startsWithHyphen","test","hyphenNewline","lines","tokens","source","description","fixIt","replace","name","reportJSDoc","line","number","postName","forEachPreferredTag","tagEntries","Object","entries","tagName","preferredParamTag","getPreferredTagName","tag","some","tagNme","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type","additionalProperties","properties","anyOf","patternProperties","module"],"sources":["../../src/rules/requireHyphenBeforeParamDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const [\n mainCircumstance,\n {\n tags = null,\n } = {},\n ] = context.options;\n\n const tgs = /**\n * @type {null|\"any\"|{[key: string]: \"always\"|\"never\"}}\n */ (tags);\n\n /**\n * @param {import('@es-joy/jsdoccomment').JsdocTagWithInline} jsdocTag\n * @param {string} targetTagName\n * @param {\"always\"|\"never\"} [circumstance]\n * @returns {void}\n */\n const checkHyphens = (jsdocTag, targetTagName, circumstance = mainCircumstance) => {\n const always = !circumstance || circumstance === 'always';\n const desc = /** @type {string} */ (utils.getTagDescription(jsdocTag));\n if (!desc.trim()) {\n return;\n }\n\n const startsWithHyphen = (/^\\s*-/v).test(desc);\n const hyphenNewline = (/^\\s*-\\n/v).test(desc);\n\n let lines = 0;\n for (const {\n tokens,\n } of jsdocTag.source) {\n if (tokens.description) {\n break;\n }\n\n lines++;\n }\n\n if (always && !hyphenNewline) {\n if (!startsWithHyphen) {\n let fixIt = true;\n for (const {\n tokens,\n } of jsdocTag.source) {\n if (tokens.description) {\n tokens.description = tokens.description.replace(\n /^(\\s*)/v, '$1- ',\n );\n break;\n }\n\n // Linebreak after name since has no description\n if (tokens.name) {\n fixIt = false;\n break;\n }\n }\n\n if (fixIt) {\n utils.reportJSDoc(\n `There must be a hyphen before @${targetTagName} description.`,\n {\n line: jsdocTag.source[0].number + lines,\n },\n () => {},\n );\n }\n }\n } else if (startsWithHyphen) {\n utils.reportJSDoc(\n always ?\n `There must be no hyphen followed by newline after the @${targetTagName} name.` :\n `There must be no hyphen before @${targetTagName} description.`,\n {\n line: jsdocTag.source[0].number + lines,\n },\n () => {\n for (const {\n tokens,\n } of jsdocTag.source) {\n if (tokens.description) {\n tokens.description = tokens.description.replace(\n /^\\s*-\\s*/v, '',\n );\n if (hyphenNewline) {\n tokens.postName = '';\n }\n\n break;\n }\n }\n },\n true,\n );\n }\n };\n\n utils.forEachPreferredTag('param', checkHyphens);\n if (tgs) {\n const tagEntries = Object.entries(tgs);\n for (const [\n tagName,\n circumstance,\n ] of tagEntries) {\n if (tagName === '*') {\n const preferredParamTag = utils.getPreferredTagName({\n tagName: 'param',\n });\n for (const {\n tag,\n } of jsdoc.tags) {\n if (tag === preferredParamTag || tagEntries.some(([\n tagNme,\n ]) => {\n return tagNme !== '*' && tagNme === tag;\n })) {\n continue;\n }\n\n utils.forEachPreferredTag(tag, (jsdocTag, targetTagName) => {\n checkHyphens(\n jsdocTag,\n targetTagName,\n /** @type {\"always\"|\"never\"} */ (circumstance),\n );\n });\n }\n\n continue;\n }\n\n utils.forEachPreferredTag(tagName, (jsdocTag, targetTagName) => {\n checkHyphens(\n jsdocTag,\n targetTagName,\n /** @type {\"always\"|\"never\"} */ (circumstance),\n );\n });\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires a hyphen before the `@param` description (and optionally before `@property` descriptions).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-hyphen-before-param-description.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n description: `If the string is \\`\"always\"\\` then a problem is raised when there is no hyphen\nbefore the description. If it is \\`\"never\"\\` then a problem is raised when there\nis a hyphen before the description. The default value is \\`\"always\"\\`.\n\nEven if hyphens are set to \"always\" appear after the tag name, they will\nactually be forbidden in the event that they are followed immediately by\nthe end of a line (this will otherwise cause Visual Studio Code to display\nincorrectly).`,\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n description: `The options object may have the following property to indicate behavior for\nother tags besides the \\`@param\\` tag (or the \\`@arg\\` tag if so set).`,\n properties: {\n tags: {\n anyOf: [\n {\n patternProperties: {\n '.*': {\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n {\n enum: [\n 'any',\n ],\n type: 'string',\n },\n ],\n description: `Object whose keys indicate different tags to check for the\n presence or absence of hyphens; the key value should be \"always\" or \"never\",\n indicating how hyphens are to be applied, e.g., \\`{property: 'never'}\\`\n to ensure \\`@property\\` never uses hyphens. A key can also be set as \\`*\\`, e.g.,\n \\`'*': 'always'\\` to apply hyphen checking to any tag (besides the preferred\n \\`@param\\` tag which follows the main string option setting and besides any\n other \\`tags\\` entries).`,\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\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;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK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ACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAK,MAAA,CAAArD,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -47,8 +47,7 @@ no parameters or return values are found.`,
|
|
|
47
47
|
boolean, this option can be set to the string \`"no-setter"\` to indicate that
|
|
48
48
|
getters should be checked but only when there is no setter. This may be useful
|
|
49
49
|
if one only wishes documentation on one of the two accessors. Defaults to
|
|
50
|
-
\`false
|
|
51
|
-
`
|
|
50
|
+
\`false\`.`
|
|
52
51
|
},
|
|
53
52
|
checkSetters: {
|
|
54
53
|
anyOf: [{
|
|
@@ -122,8 +121,7 @@ Defaults to \`true\`.`,
|
|
|
122
121
|
functions/methods with no parameters or return values (intended where
|
|
123
122
|
function/method names are sufficient for themselves as documentation).
|
|
124
123
|
|
|
125
|
-
Defaults to \`false
|
|
126
|
-
`,
|
|
124
|
+
Defaults to \`false\`.`,
|
|
127
125
|
type: 'boolean'
|
|
128
126
|
},
|
|
129
127
|
exemptOverloadedImplementations: {
|
|
@@ -157,8 +155,7 @@ otherwise noted):
|
|
|
157
155
|
- \`ancestorsOnly\` - Optimization to only check node ancestors to check if node is exported
|
|
158
156
|
- \`esm\` - ESM exports are checked for JSDoc comments (Defaults to \`true\`)
|
|
159
157
|
- \`cjs\` - CommonJS exports are checked for JSDoc comments (Defaults to \`true\`)
|
|
160
|
-
- \`window\` - Window global exports are checked for JSDoc comments
|
|
161
|
-
`,
|
|
158
|
+
- \`window\` - Window global exports are checked for JSDoc comments`,
|
|
162
159
|
oneOf: [{
|
|
163
160
|
default: false,
|
|
164
161
|
type: 'boolean'
|