eslint-plugin-jsdoc 50.8.0 → 51.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alignTransform.cjs +5 -5
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/exportParser.cjs +2 -3
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateRule.cjs +2 -5
- package/dist/generateRule.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +2 -4
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/iterateJsdoc.cjs +29 -34
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/jsdocUtils.cjs +19 -31
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +3 -3
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +2 -3
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +1 -2
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +1 -2
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +11 -13
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +2 -3
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +1 -1
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +8 -11
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +1 -2
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +5 -5
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +1 -1
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +5 -9
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +4 -8
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +5 -6
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +4 -4
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +2 -3
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +3 -6
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +8 -12
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +1 -2
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +7 -15
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/package.json +5 -5
- package/src/getJsdocProcessorPlugin.js +1 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertToJsdocComments.cjs","names":["_iterateJsdoc","require","_jsdocUtils","_jsdoccomment","_default","exports","default","create","context","sourceCode","getSourceCode","settings","getSettings","allowedPrefixes","contexts","contextsAfter","contextsBeforeAndAfter","enableFixer","enforceJsdocLineStyle","lineOrBlockStyle","options","reportingNonJsdoc","report","messageId","comment","node","fixer","_comment$loc","_comment$loc2","loc","end","column","line","start","fix","getFixer","addComment","ctxts","lines","minLines","maxLines","baseNode","getReducedASTNode","decorator","getDecorator","indent","getIndent","text","getText","inlineCommentBlock","find","contxt","ctxt","type","reportings","checkNonJsdoc","_info","_handler","getNonJsdocComment","some","prefix","value","trimStart","startsWith","commentToAdd","insertion","trim","trimEnd","repeat","replaceText","checkNonJsdocAfter","getFollowingComment","slice","remove","insertTextBefore","parent","getContextObject","enforcedContexts","meta","docs","description","url","fixable","messages","blockCommentsJsdocStyle","lineCommentsJsdocStyle","schema","additionalProperties","properties","items","anyOf","enum","module"],"sources":["../../src/rules/convertToJsdocComments.js"],"sourcesContent":["import {\n getSettings,\n} from '../iterateJsdoc.js';\nimport {\n enforcedContexts,\n getContextObject,\n getIndent,\n} from '../jsdocUtils.js';\nimport {\n getDecorator,\n getFollowingComment,\n getNonJsdocComment,\n getReducedASTNode,\n} from '@es-joy/jsdoccomment';\n\n/** @type {import('eslint').Rule.RuleModule} */\nexport default {\n create (context) {\n /**\n * @typedef {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} Token\n */\n\n /**\n * @callback AddComment\n * @param {boolean|undefined} inlineCommentBlock\n * @param {Token} comment\n * @param {string} indent\n * @param {number} lines\n * @param {import('eslint').Rule.RuleFixer} fixer\n */\n\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n sourceCode = context.getSourceCode(),\n } = context;\n const settings = getSettings(context);\n if (!settings) {\n return {};\n }\n\n const {\n allowedPrefixes = [\n '@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',\n ],\n contexts = settings.contexts || [],\n contextsAfter = /** @type {string[]} */ ([]),\n contextsBeforeAndAfter = [\n 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',\n ],\n enableFixer = true,\n enforceJsdocLineStyle = 'multi',\n lineOrBlockStyle = 'both',\n } = context.options[0] ?? {};\n\n let reportingNonJsdoc = false;\n\n /**\n * @param {string} messageId\n * @param {import('estree').Comment|Token} comment\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').Rule.ReportFixer} fixer\n */\n const report = (messageId, comment, node, fixer) => {\n const loc = {\n end: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n start: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n };\n\n context.report({\n fix: enableFixer ? fixer : null,\n loc,\n messageId,\n node,\n });\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const getFixer = (node, comment, addComment, ctxts) => {\n return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n // Default to one line break if the `minLines`/`maxLines` settings allow\n const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;\n let baseNode =\n /**\n * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node}\n */ (\n getReducedASTNode(node, sourceCode)\n );\n\n const decorator = getDecorator(\n /** @type {import('eslint').Rule.Node} */\n (baseNode),\n );\n if (decorator) {\n baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (\n decorator\n );\n }\n\n const indent = getIndent({\n text: sourceCode.getText(\n /** @type {import('eslint').Rule.Node} */ (baseNode),\n /** @type {import('eslint').AST.SourceLocation} */\n (\n /** @type {import('eslint').Rule.Node} */ (baseNode).loc\n ).start.column,\n ),\n });\n\n const {\n inlineCommentBlock,\n } =\n /**\n * @type {{\n * context: string,\n * inlineCommentBlock: boolean,\n * minLineCount: import('../iterateJsdoc.js').Integer\n * }[]}\n */ (ctxts).find((contxt) => {\n if (typeof contxt === 'string') {\n return false;\n }\n\n const {\n context: ctxt,\n } = contxt;\n return ctxt === node.type;\n }) || {};\n\n return addComment(inlineCommentBlock, comment, indent, lines, fixer);\n };\n };\n\n /**\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {import('eslint').Rule.Node} node\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const reportings = (comment, node, addComment, ctxts) => {\n const fixer = getFixer(node, comment, addComment, ctxts);\n\n if (comment.type === 'Block') {\n if (lineOrBlockStyle === 'line') {\n return;\n }\n\n report('blockCommentsJsdocStyle', comment, node, fixer);\n return;\n }\n\n if (comment.type === 'Line') {\n if (lineOrBlockStyle === 'block') {\n return;\n }\n\n report('lineCommentsJsdocStyle', comment, node, fixer);\n }\n };\n\n /**\n * @type {import('../iterateJsdoc.js').CheckJsdoc}\n */\n const checkNonJsdoc = (_info, _handler, node) => {\n const comment = getNonJsdocComment(sourceCode, node, settings);\n\n if (\n !comment ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n reportingNonJsdoc = true;\n\n /** @type {AddComment} */\n // eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}`;\n\n return fixer.replaceText(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n insertion,\n );\n };\n\n reportings(comment, node, addComment, contexts);\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const checkNonJsdocAfter = (node, ctxts) => {\n const comment = getFollowingComment(sourceCode, node);\n\n if (\n !comment ||\n comment.value.startsWith('*') ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n /** @type {AddComment} */\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}${lines ? `\\n${indent.slice(1)}` : ' '}`;\n\n return [\n fixer.remove(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n ), fixer.insertTextBefore(\n node.type === 'VariableDeclarator' ? node.parent : node,\n insertion,\n ),\n ];\n };\n\n reportings(comment, node, addComment, ctxts);\n };\n\n // Todo: add contexts to check after (and handle if want both before and after)\n return {\n ...getContextObject(\n enforcedContexts(context, true, settings),\n checkNonJsdoc,\n ),\n ...getContextObject(\n contextsAfter,\n (_info, _handler, node) => {\n checkNonJsdocAfter(node, contextsAfter);\n },\n ),\n ...getContextObject(\n contextsBeforeAndAfter,\n (_info, _handler, node) => {\n checkNonJsdoc({}, null, node);\n if (!reportingNonJsdoc) {\n checkNonJsdocAfter(node, contextsBeforeAndAfter);\n }\n },\n ),\n };\n },\n meta: {\n docs: {\n description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',\n },\n\n fixable: 'code',\n\n messages: {\n blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',\n lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowedPrefixes: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsAfter: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsBeforeAndAfter: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n type: 'boolean',\n },\n enforceJsdocLineStyle: {\n enum: [\n 'multi', 'single',\n ],\n type: 'string',\n },\n lineOrBlockStyle: {\n enum: [\n 'block', 'line', 'both',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,aAAA,GAAAF,OAAA;AAOA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe;EACbC,MAAMA,CAAEC,OAAO,EAAE;IACf;AACJ;AACA;AACA;AACA;AACA;AACA;;IAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;IAEI;IACA,MAAM;MACJC,UAAU,GAAGD,OAAO,CAACE,aAAa,CAAC;IACrC,CAAC,GAAGF,OAAO;IACX,MAAMG,QAAQ,GAAG,IAAAC,yBAAW,EAACJ,OAAO,CAAC;IACrC,IAAI,CAACG,QAAQ,EAAE;MACb,OAAO,CAAC,CAAC;IACX;IAEA,MAAM;MACJE,eAAe,GAAG,CAChB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CACzD;MACDC,QAAQ,GAAGH,QAAQ,CAACG,QAAQ,IAAI,EAAE;MAClCC,aAAa,IAAG,uBAAyB,EAAE,CAAC;MAC5CC,sBAAsB,GAAG,CACvB,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,CAClE;MACDC,WAAW,GAAG,IAAI;MAClBC,qBAAqB,GAAG,OAAO;MAC/BC,gBAAgB,GAAG;IACrB,CAAC,GAAGX,OAAO,CAACY,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAIC,iBAAiB,GAAG,KAAK;;IAE7B;AACJ;AACA;AACA;AACA;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;cAC3BC,UAAU,EAAE;gBACVhF,OAAO,EAAE;kBACP6C,IAAI,EAAE;gBACR,CAAC;gBACDJ,kBAAkB,EAAE;kBAClBI,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDrC,sBAAsB,EAAE;UACtByE,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACErC,IAAI,EAAE;YACR,CAAC,EACD;cACEkC,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVhF,OAAO,EAAE;kBACP6C,IAAI,EAAE;gBACR,CAAC;gBACDJ,kBAAkB,EAAE;kBAClBI,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDpC,WAAW,EAAE;UACXoC,IAAI,EAAE;QACR,CAAC;QACDnC,qBAAqB,EAAE;UACrByE,IAAI,EAAE,CACJ,OAAO,EAAE,QAAQ,CAClB;UACDtC,IAAI,EAAE;QACR,CAAC;QACDlC,gBAAgB,EAAE;UAChBwE,IAAI,EAAE,CACJ,OAAO,EAAE,MAAM,EAAE,MAAM,CACxB;UACDtC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC;AAAAuC,MAAA,CAAAvF,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertToJsdocComments.cjs","names":["_iterateJsdoc","require","_jsdocUtils","_jsdoccomment","_default","exports","default","create","context","sourceCode","getSourceCode","settings","getSettings","allowedPrefixes","contexts","contextsAfter","contextsBeforeAndAfter","enableFixer","enforceJsdocLineStyle","lineOrBlockStyle","options","reportingNonJsdoc","report","messageId","comment","node","fixer","loc","end","column","line","start","fix","getFixer","addComment","ctxts","lines","minLines","maxLines","baseNode","getReducedASTNode","decorator","getDecorator","indent","getIndent","text","getText","inlineCommentBlock","find","contxt","ctxt","type","reportings","checkNonJsdoc","_info","_handler","getNonJsdocComment","some","prefix","value","trimStart","startsWith","commentToAdd","insertion","trim","trimEnd","repeat","replaceText","checkNonJsdocAfter","getFollowingComment","slice","remove","insertTextBefore","parent","getContextObject","enforcedContexts","meta","docs","description","url","fixable","messages","blockCommentsJsdocStyle","lineCommentsJsdocStyle","schema","additionalProperties","properties","items","anyOf","enum","module"],"sources":["../../src/rules/convertToJsdocComments.js"],"sourcesContent":["import {\n getSettings,\n} from '../iterateJsdoc.js';\nimport {\n enforcedContexts,\n getContextObject,\n getIndent,\n} from '../jsdocUtils.js';\nimport {\n getDecorator,\n getFollowingComment,\n getNonJsdocComment,\n getReducedASTNode,\n} from '@es-joy/jsdoccomment';\n\n/** @type {import('eslint').Rule.RuleModule} */\nexport default {\n create (context) {\n /**\n * @typedef {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} Token\n */\n\n /**\n * @callback AddComment\n * @param {boolean|undefined} inlineCommentBlock\n * @param {Token} comment\n * @param {string} indent\n * @param {number} lines\n * @param {import('eslint').Rule.RuleFixer} fixer\n */\n\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n sourceCode = context.getSourceCode(),\n } = context;\n const settings = getSettings(context);\n if (!settings) {\n return {};\n }\n\n const {\n allowedPrefixes = [\n '@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',\n ],\n contexts = settings.contexts || [],\n contextsAfter = /** @type {string[]} */ ([]),\n contextsBeforeAndAfter = [\n 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',\n ],\n enableFixer = true,\n enforceJsdocLineStyle = 'multi',\n lineOrBlockStyle = 'both',\n } = context.options[0] ?? {};\n\n let reportingNonJsdoc = false;\n\n /**\n * @param {string} messageId\n * @param {import('estree').Comment|Token} comment\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').Rule.ReportFixer} fixer\n */\n const report = (messageId, comment, node, fixer) => {\n const loc = {\n end: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n start: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n };\n\n context.report({\n fix: enableFixer ? fixer : null,\n loc,\n messageId,\n node,\n });\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const getFixer = (node, comment, addComment, ctxts) => {\n return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n // Default to one line break if the `minLines`/`maxLines` settings allow\n const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;\n let baseNode =\n /**\n * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node}\n */ (\n getReducedASTNode(node, sourceCode)\n );\n\n const decorator = getDecorator(\n /** @type {import('eslint').Rule.Node} */\n (baseNode),\n );\n if (decorator) {\n baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (\n decorator\n );\n }\n\n const indent = getIndent({\n text: sourceCode.getText(\n /** @type {import('eslint').Rule.Node} */ (baseNode),\n /** @type {import('eslint').AST.SourceLocation} */\n (\n /** @type {import('eslint').Rule.Node} */ (baseNode).loc\n ).start.column,\n ),\n });\n\n const {\n inlineCommentBlock,\n } =\n /**\n * @type {{\n * context: string,\n * inlineCommentBlock: boolean,\n * minLineCount: import('../iterateJsdoc.js').Integer\n * }[]}\n */ (ctxts).find((contxt) => {\n if (typeof contxt === 'string') {\n return false;\n }\n\n const {\n context: ctxt,\n } = contxt;\n return ctxt === node.type;\n }) || {};\n\n return addComment(inlineCommentBlock, comment, indent, lines, fixer);\n };\n };\n\n /**\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {import('eslint').Rule.Node} node\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const reportings = (comment, node, addComment, ctxts) => {\n const fixer = getFixer(node, comment, addComment, ctxts);\n\n if (comment.type === 'Block') {\n if (lineOrBlockStyle === 'line') {\n return;\n }\n\n report('blockCommentsJsdocStyle', comment, node, fixer);\n return;\n }\n\n if (comment.type === 'Line') {\n if (lineOrBlockStyle === 'block') {\n return;\n }\n\n report('lineCommentsJsdocStyle', comment, node, fixer);\n }\n };\n\n /**\n * @type {import('../iterateJsdoc.js').CheckJsdoc}\n */\n const checkNonJsdoc = (_info, _handler, node) => {\n const comment = getNonJsdocComment(sourceCode, node, settings);\n\n if (\n !comment ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n reportingNonJsdoc = true;\n\n /** @type {AddComment} */\n // eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}`;\n\n return fixer.replaceText(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n insertion,\n );\n };\n\n reportings(comment, node, addComment, contexts);\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const checkNonJsdocAfter = (node, ctxts) => {\n const comment = getFollowingComment(sourceCode, node);\n\n if (\n !comment ||\n comment.value.startsWith('*') ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n /** @type {AddComment} */\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}${lines ? `\\n${indent.slice(1)}` : ' '}`;\n\n return [\n fixer.remove(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n ), fixer.insertTextBefore(\n node.type === 'VariableDeclarator' ? node.parent : node,\n insertion,\n ),\n ];\n };\n\n reportings(comment, node, addComment, ctxts);\n };\n\n // Todo: add contexts to check after (and handle if want both before and after)\n return {\n ...getContextObject(\n enforcedContexts(context, true, settings),\n checkNonJsdoc,\n ),\n ...getContextObject(\n contextsAfter,\n (_info, _handler, node) => {\n checkNonJsdocAfter(node, contextsAfter);\n },\n ),\n ...getContextObject(\n contextsBeforeAndAfter,\n (_info, _handler, node) => {\n checkNonJsdoc({}, null, node);\n if (!reportingNonJsdoc) {\n checkNonJsdocAfter(node, contextsBeforeAndAfter);\n }\n },\n ),\n };\n },\n meta: {\n docs: {\n description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',\n },\n\n fixable: 'code',\n\n messages: {\n blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',\n lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowedPrefixes: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsAfter: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsBeforeAndAfter: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n type: 'boolean',\n },\n enforceJsdocLineStyle: {\n enum: [\n 'multi', 'single',\n ],\n type: 'string',\n },\n lineOrBlockStyle: {\n enum: [\n 'block', 'line', 'both',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,aAAA,GAAAF,OAAA;AAOA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe;EACbC,MAAMA,CAAEC,OAAO,EAAE;IACf;AACJ;AACA;AACA;AACA;AACA;AACA;;IAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;IAEI;IACA,MAAM;MACJC,UAAU,GAAGD,OAAO,CAACE,aAAa,CAAC;IACrC,CAAC,GAAGF,OAAO;IACX,MAAMG,QAAQ,GAAG,IAAAC,yBAAW,EAACJ,OAAO,CAAC;IACrC,IAAI,CAACG,QAAQ,EAAE;MACb,OAAO,CAAC,CAAC;IACX;IAEA,MAAM;MACJE,eAAe,GAAG,CAChB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CACzD;MACDC,QAAQ,GAAGH,QAAQ,CAACG,QAAQ,IAAI,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UACbwE,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACErC,IAAI,EAAE;YACR,CAAC,EACD;cACEkC,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACV9E,OAAO,EAAE;kBACP2C,IAAI,EAAE;gBACR,CAAC;gBACDJ,kBAAkB,EAAE;kBAClBI,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDnC,sBAAsB,EAAE;UACtBuE,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACErC,IAAI,EAAE;YACR,CAAC,EACD;cACEkC,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACV9E,OAAO,EAAE;kBACP2C,IAAI,EAAE;gBACR,CAAC;gBACDJ,kBAAkB,EAAE;kBAClBI,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDlC,WAAW,EAAE;UACXkC,IAAI,EAAE;QACR,CAAC;QACDjC,qBAAqB,EAAE;UACrBuE,IAAI,EAAE,CACJ,OAAO,EAAE,QAAQ,CAClB;UACDtC,IAAI,EAAE;QACR,CAAC;QACDhC,gBAAgB,EAAE;UAChBsE,IAAI,EAAE,CACJ,OAAO,EAAE,MAAM,EAAE,MAAM,CACxB;UACDtC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC;AAAAuC,MAAA,CAAArF,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -19,7 +19,7 @@ const defaultUselessWords = ['a', 'an', 'i', 'in', 'of', 's', 'the'];
|
|
|
19
19
|
* @returns {string[]}
|
|
20
20
|
*/
|
|
21
21
|
const getNamesFromNode = node => {
|
|
22
|
-
switch (node
|
|
22
|
+
switch (node?.type) {
|
|
23
23
|
case 'AccessorProperty':
|
|
24
24
|
case 'MethodDefinition':
|
|
25
25
|
case 'PropertyDefinition':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"informativeDocs.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_areDocsInformative","e","__esModule","default","defaultAliases","a","defaultUselessWords","getNamesFromNode","node","type","parent","key","id","declaration","name","declarations","init","filter","Boolean","_default","exports","iterateJsdoc","context","jsdoc","report","utils","aliases","excludedTags","uselessWords","options","nodeNames","descriptionIsRedundant","text","extraName","textTrimmed","trim","areDocsInformative","join","description","lastDescriptionLine","getDescription","descriptionReported","tag","tags","includes","reportJSDoc","line","iterateAllJsdocs","meta","docs","url","schema","additionalProperties","properties","patternProperties","items","module"],"sources":["../../src/rules/informativeDocs.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n areDocsInformative,\n} from 'are-docs-informative';\n\nconst defaultAliases = {\n a: [\n 'an', 'our',\n ],\n};\n\nconst defaultUselessWords = [\n 'a', 'an', 'i', 'in', 'of', 's', 'the',\n];\n\n/* eslint-disable complexity -- Temporary */\n\n/**\n * @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node|null|undefined} node\n * @returns {string[]}\n */\nconst getNamesFromNode = (node) => {\n switch (node?.type) {\n case 'AccessorProperty':\n case 'MethodDefinition':\n case 'PropertyDefinition':\n case 'TSAbstractAccessorProperty':\n case 'TSAbstractMethodDefinition':\n case 'TSAbstractPropertyDefinition':\n return [\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node.parent\n ).parent,\n ),\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.key),\n ),\n ];\n\n case 'ClassDeclaration':\n case 'ClassExpression':\n case 'FunctionDeclaration':\n case 'FunctionExpression':\n case 'TSDeclareFunction':\n case 'TSEnumDeclaration':\n case 'TSEnumMember':\n case 'TSInterfaceDeclaration':\n case 'TSMethodSignature':\n case 'TSModuleDeclaration':\n case 'TSTypeAliasDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.ClassDeclaration} */\n (node).id,\n );\n case 'ExportDefaultDeclaration':\n case 'ExportNamedDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */\n (node).declaration,\n );\n case 'Identifier':\n return [\n node.name,\n ];\n case 'Property':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.key),\n );\n case 'VariableDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.declarations[0]),\n );\n case 'VariableDeclarator':\n return [\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.id),\n ),\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.init),\n ),\n ].filter(Boolean);\n default:\n return [];\n }\n};\n/* eslint-enable complexity -- Temporary */\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n node,\n report,\n utils,\n}) => {\n const /** @type {{aliases: {[key: string]: string[]}, excludedTags: string[], uselessWords: string[]}} */ {\n aliases = defaultAliases,\n excludedTags = [],\n uselessWords = defaultUselessWords,\n } = context.options[0] || {};\n const nodeNames = getNamesFromNode(node);\n\n /**\n * @param {string} text\n * @param {string} extraName\n * @returns {boolean}\n */\n const descriptionIsRedundant = (text, extraName = '') => {\n const textTrimmed = text.trim();\n return Boolean(textTrimmed) && !areDocsInformative(textTrimmed, [\n extraName, nodeNames,\n ].filter(Boolean).join(' '), {\n aliases,\n uselessWords,\n });\n };\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n let descriptionReported = false;\n\n for (const tag of jsdoc.tags) {\n if (excludedTags.includes(tag.tag)) {\n continue;\n }\n\n if (descriptionIsRedundant(tag.description, tag.name)) {\n utils.reportJSDoc(\n 'This tag description only repeats the name it describes.',\n tag,\n );\n }\n\n descriptionReported ||= tag.description === description &&\n /** @type {import('comment-parser').Spec & {line: import('../iterateJsdoc.js').Integer}} */\n (tag).line === lastDescriptionLine;\n }\n\n if (!descriptionReported && descriptionIsRedundant(description)) {\n report('This description only repeats the name it describes.');\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description:\n 'This rule reports doc comments that only restate their attached name.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/informative-docs.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n aliases: {\n patternProperties: {\n '.*': {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n },\n excludedTags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n uselessWords: {\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,GAAAD,OAAA;AAE8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9B,MAAMG,cAAc,GAAG;EACrBC,CAAC,EAAE,CACD,IAAI,EAAE,KAAK;AAEf,CAAC;AAED,MAAMC,mBAAmB,GAAG,CAC1B,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CACvC;;AAED;;AAEA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAIC,IAAI,IAAK;EACjC,QAAQA,IAAI,
|
|
1
|
+
{"version":3,"file":"informativeDocs.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_areDocsInformative","e","__esModule","default","defaultAliases","a","defaultUselessWords","getNamesFromNode","node","type","parent","key","id","declaration","name","declarations","init","filter","Boolean","_default","exports","iterateJsdoc","context","jsdoc","report","utils","aliases","excludedTags","uselessWords","options","nodeNames","descriptionIsRedundant","text","extraName","textTrimmed","trim","areDocsInformative","join","description","lastDescriptionLine","getDescription","descriptionReported","tag","tags","includes","reportJSDoc","line","iterateAllJsdocs","meta","docs","url","schema","additionalProperties","properties","patternProperties","items","module"],"sources":["../../src/rules/informativeDocs.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n areDocsInformative,\n} from 'are-docs-informative';\n\nconst defaultAliases = {\n a: [\n 'an', 'our',\n ],\n};\n\nconst defaultUselessWords = [\n 'a', 'an', 'i', 'in', 'of', 's', 'the',\n];\n\n/* eslint-disable complexity -- Temporary */\n\n/**\n * @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node|null|undefined} node\n * @returns {string[]}\n */\nconst getNamesFromNode = (node) => {\n switch (node?.type) {\n case 'AccessorProperty':\n case 'MethodDefinition':\n case 'PropertyDefinition':\n case 'TSAbstractAccessorProperty':\n case 'TSAbstractMethodDefinition':\n case 'TSAbstractPropertyDefinition':\n return [\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node.parent\n ).parent,\n ),\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.key),\n ),\n ];\n\n case 'ClassDeclaration':\n case 'ClassExpression':\n case 'FunctionDeclaration':\n case 'FunctionExpression':\n case 'TSDeclareFunction':\n case 'TSEnumDeclaration':\n case 'TSEnumMember':\n case 'TSInterfaceDeclaration':\n case 'TSMethodSignature':\n case 'TSModuleDeclaration':\n case 'TSTypeAliasDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.ClassDeclaration} */\n (node).id,\n );\n case 'ExportDefaultDeclaration':\n case 'ExportNamedDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */\n (node).declaration,\n );\n case 'Identifier':\n return [\n node.name,\n ];\n case 'Property':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.key),\n );\n case 'VariableDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.declarations[0]),\n );\n case 'VariableDeclarator':\n return [\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.id),\n ),\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.init),\n ),\n ].filter(Boolean);\n default:\n return [];\n }\n};\n/* eslint-enable complexity -- Temporary */\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n node,\n report,\n utils,\n}) => {\n const /** @type {{aliases: {[key: string]: string[]}, excludedTags: string[], uselessWords: string[]}} */ {\n aliases = defaultAliases,\n excludedTags = [],\n uselessWords = defaultUselessWords,\n } = context.options[0] || {};\n const nodeNames = getNamesFromNode(node);\n\n /**\n * @param {string} text\n * @param {string} extraName\n * @returns {boolean}\n */\n const descriptionIsRedundant = (text, extraName = '') => {\n const textTrimmed = text.trim();\n return Boolean(textTrimmed) && !areDocsInformative(textTrimmed, [\n extraName, nodeNames,\n ].filter(Boolean).join(' '), {\n aliases,\n uselessWords,\n });\n };\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n let descriptionReported = false;\n\n for (const tag of jsdoc.tags) {\n if (excludedTags.includes(tag.tag)) {\n continue;\n }\n\n if (descriptionIsRedundant(tag.description, tag.name)) {\n utils.reportJSDoc(\n 'This tag description only repeats the name it describes.',\n tag,\n );\n }\n\n descriptionReported ||= tag.description === description &&\n /** @type {import('comment-parser').Spec & {line: import('../iterateJsdoc.js').Integer}} */\n (tag).line === lastDescriptionLine;\n }\n\n if (!descriptionReported && descriptionIsRedundant(description)) {\n report('This description only repeats the name it describes.');\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description:\n 'This rule reports doc comments that only restate their attached name.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/informative-docs.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n aliases: {\n patternProperties: {\n '.*': {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n },\n excludedTags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n uselessWords: {\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,GAAAD,OAAA;AAE8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9B,MAAMG,cAAc,GAAG;EACrBC,CAAC,EAAE,CACD,IAAI,EAAE,KAAK;AAEf,CAAC;AAED,MAAMC,mBAAmB,GAAG,CAC1B,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CACvC;;AAED;;AAEA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAIC,IAAI,IAAK;EACjC,QAAQA,IAAI,EAAEC,IAAI;IAChB,KAAK,kBAAkB;IACvB,KAAK,kBAAkB;IACvB,KAAK,oBAAoB;IACzB,KAAK,4BAA4B;IACjC,KAAK,4BAA4B;IACjC,KAAK,8BAA8B;MACjC,OAAO,CACL,GAAGF,gBAAgB,CACnB,+DACIC,IAAI,CAACE,MAAM,CACXA,MACJ,CAAC,EACD,GAAGH,gBAAgB,CACnB;MACGC,IAAI,CAACG,GACR,CAAC,CACF;IAEH,KAAK,kBAAkB;IACvB,KAAK,iBAAiB;IACtB,KAAK,qBAAqB;IAC1B,KAAK,oBAAoB;IACzB,KAAK,mBAAmB;IACxB,KAAK,mBAAmB;IACxB,KAAK,cAAc;IACnB,KAAK,wBAAwB;IAC7B,KAAK,mBAAmB;IACxB,KAAK,qBAAqB;IAC1B,KAAK,wBAAwB;MAC3B,OAAOJ,g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KAAK,EAAE;YACL9C,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA+C,MAAA,CAAApC,OAAA,GAAAA,OAAA,CAAAjB,OAAA","ignoreList":[]}
|
|
@@ -19,7 +19,6 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
19
19
|
sourceCode,
|
|
20
20
|
utils
|
|
21
21
|
}) => {
|
|
22
|
-
var _tokenBefore$loc, _jsdocNode$loc;
|
|
23
22
|
const {
|
|
24
23
|
checkBlockStarts,
|
|
25
24
|
excludedTags = ['type'],
|
|
@@ -36,10 +35,10 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
36
35
|
if (!tokenBefore || tokenBefore.type === 'Punctuator' && !checkBlockStarts && startPunctuators.has(tokenBefore.value)) {
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
const startLine =
|
|
42
|
-
const sameLine =
|
|
38
|
+
if (tokenBefore.loc?.end?.line + lines >= (/** @type {number} */
|
|
39
|
+
jsdocNode.loc?.start?.line)) {
|
|
40
|
+
const startLine = jsdocNode.loc?.start?.line;
|
|
41
|
+
const sameLine = tokenBefore.loc?.end?.line === startLine;
|
|
43
42
|
if (sameLine && ignoreSameLine) {
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
@@ -48,17 +47,15 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
48
47
|
const fix = fixer => {
|
|
49
48
|
let indent = '';
|
|
50
49
|
if (sameLine) {
|
|
51
|
-
|
|
52
|
-
const spaceDiff = /** @type {number} */((_jsdocNode$loc3 = jsdocNode.loc) === null || _jsdocNode$loc3 === void 0 || (_jsdocNode$loc3 = _jsdocNode$loc3.start) === null || _jsdocNode$loc3 === void 0 ? void 0 : _jsdocNode$loc3.column) - (/** @type {number} */(_tokenBefore$loc3 = tokenBefore.loc) === null || _tokenBefore$loc3 === void 0 || (_tokenBefore$loc3 = _tokenBefore$loc3.end) === null || _tokenBefore$loc3 === void 0 ? void 0 : _tokenBefore$loc3.column);
|
|
50
|
+
const spaceDiff = /** @type {number} */jsdocNode.loc?.start?.column - (/** @type {number} */tokenBefore.loc?.end?.column);
|
|
53
51
|
// @ts-expect-error Should be a comment
|
|
54
|
-
indent = /** @type {import('estree').Comment} */
|
|
52
|
+
indent = /** @type {import('estree').Comment} */jsdocNode.value.match(/^\*\n([\t ]*) \*/u)?.[1]?.slice(spaceDiff);
|
|
55
53
|
if (!indent) {
|
|
56
54
|
/** @type {import('eslint').AST.Token|import('estree').Comment|undefined} */
|
|
57
55
|
let tokenPrior = tokenBefore;
|
|
58
56
|
let startColumn;
|
|
59
|
-
while (tokenPrior &&
|
|
60
|
-
|
|
61
|
-
startColumn = (_tokenPrior$loc = tokenPrior.loc) === null || _tokenPrior$loc === void 0 || (_tokenPrior$loc = _tokenPrior$loc.start) === null || _tokenPrior$loc === void 0 ? void 0 : _tokenPrior$loc.column;
|
|
57
|
+
while (tokenPrior && tokenPrior?.loc?.start?.line === startLine) {
|
|
58
|
+
startColumn = tokenPrior.loc?.start?.column;
|
|
62
59
|
tokenPrior = tokensBefore.pop();
|
|
63
60
|
}
|
|
64
61
|
indent = ' '.repeat(/* c8 ignore next */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linesBeforeBlock.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","startPunctuators","Set","_default","exports","iterateJsdoc","context","jsdocNode","report","sourceCode","utils","
|
|
1
|
+
{"version":3,"file":"linesBeforeBlock.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","startPunctuators","Set","_default","exports","iterateJsdoc","context","jsdocNode","report","sourceCode","utils","checkBlockStarts","excludedTags","ignoreSameLine","lines","options","hasATag","tokensBefore","getTokensBefore","includeComments","tokenBefore","at","type","has","value","loc","end","line","start","startLine","sameLine","fix","fixer","indent","spaceDiff","column","match","slice","tokenPrior","startColumn","pop","repeat","insertTextAfter","iterateAllJsdocs","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","module"],"sources":["../../src/rules/linesBeforeBlock.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * Punctuators that begin a logical group should not require a line before it skipped. Specifically\n * `[` starts an array, `{` starts an object or block, `(` starts a grouping, and `=` starts a\n * declaration (like a variable or a type alias).\n */\nconst startPunctuators = new Set([\n '(', '=', '[', '{',\n]);\n\nexport default iterateJsdoc(({\n context,\n jsdocNode,\n report,\n sourceCode,\n utils,\n}) => {\n const {\n checkBlockStarts,\n excludedTags = [\n 'type',\n ],\n ignoreSameLine = true,\n lines = 1,\n } = context.options[0] || {};\n\n if (utils.hasATag(excludedTags)) {\n return;\n }\n\n const tokensBefore = sourceCode.getTokensBefore(jsdocNode, {\n includeComments: true,\n });\n const tokenBefore = tokensBefore.at(-1);\n if (\n !tokenBefore || (\n tokenBefore.type === 'Punctuator' &&\n !checkBlockStarts &&\n startPunctuators.has(tokenBefore.value)\n )\n ) {\n return;\n }\n\n if (tokenBefore.loc?.end?.line + lines >=\n /** @type {number} */\n (jsdocNode.loc?.start?.line)\n ) {\n const startLine = jsdocNode.loc?.start?.line;\n const sameLine = tokenBefore.loc?.end?.line === startLine;\n\n if (sameLine && ignoreSameLine) {\n return;\n }\n\n /** @type {import('eslint').Rule.ReportFixer} */\n const fix = (fixer) => {\n let indent = '';\n if (sameLine) {\n const spaceDiff = /** @type {number} */ (jsdocNode.loc?.start?.column) -\n /** @type {number} */ (tokenBefore.loc?.end?.column);\n // @ts-expect-error Should be a comment\n indent = /** @type {import('estree').Comment} */ (\n jsdocNode\n ).value.match(/^\\*\\n([\\t ]*) \\*/u)?.[1]?.slice(spaceDiff);\n if (!indent) {\n /** @type {import('eslint').AST.Token|import('estree').Comment|undefined} */\n let tokenPrior = tokenBefore;\n let startColumn;\n while (tokenPrior && tokenPrior?.loc?.start?.line === startLine) {\n startColumn = tokenPrior.loc?.start?.column;\n tokenPrior = tokensBefore.pop();\n }\n\n indent = ' '.repeat(\n /* c8 ignore next */\n /** @type {number} */ (startColumn ? startColumn - 1 : 0),\n );\n }\n }\n\n return fixer.insertTextAfter(\n /** @type {import('eslint').AST.Token} */\n (tokenBefore),\n '\\n'.repeat(lines) +\n (sameLine ? '\\n' + indent : ''),\n );\n };\n\n report(`Required ${lines} line(s) before JSDoc block`, fix);\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces minimum number of newlines before JSDoc comment blocks',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/lines-before-block.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkBlockStarts: {\n type: 'boolean',\n },\n excludedTags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n ignoreSameLine: {\n type: 'boolean',\n },\n lines: {\n type: 'integer',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA,MAAMG,gBAAgB,GAAG,IAAIC,GAAG,CAAC,CAC/B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CACnB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEY,IAAAK,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,SAAS;EACTC,MAAM;EACNC,UAAU;EACVC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,gBAAgB;IAChBC,YAAY,GAAG,CACb,MAAM,CACP;IACDC,cAAc,GAAG,IAAI;IACrBC,KAA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,CAAAJ,OAAA","ignoreList":[]}
|
|
@@ -32,8 +32,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
32
32
|
}
|
|
33
33
|
let sliceIndex = 2;
|
|
34
34
|
if (!commentRegexp.test(commentText)) {
|
|
35
|
-
|
|
36
|
-
const multiline = (_extraAsteriskComment = extraAsteriskCommentRegexp.exec(commentText)) === null || _extraAsteriskComment === void 0 ? void 0 : _extraAsteriskComment[0];
|
|
35
|
+
const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];
|
|
37
36
|
if (!multiline) {
|
|
38
37
|
return false;
|
|
39
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noBadBlocks.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_commentParser","e","__esModule","default","commentRegexp","extraAsteriskCommentRegexp","_default","exports","iterateJsdoc","allComments","context","makeReport","sourceCode","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","initialText","replace","trimStart","some","directive","startsWith","sliceIndex","test","
|
|
1
|
+
{"version":3,"file":"noBadBlocks.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_commentParser","e","__esModule","default","commentRegexp","extraAsteriskCommentRegexp","_default","exports","iterateJsdoc","allComments","context","makeReport","sourceCode","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","initialText","replace","trimStart","some","directive","startsWith","sliceIndex","test","multiline","exec","length","tags","commentParser","slice","tag","includes","node","report","fix","fixer","text","replaceText","checkFile","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","type","module"],"sources":["../../src/rules/noBadBlocks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n parse as commentParser,\n} from 'comment-parser';\n\n// Neither a single nor 3+ asterisks are valid jsdoc per\n// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code\nconst commentRegexp = /^\\/\\*(?!\\*)/u;\nconst extraAsteriskCommentRegexp = /^\\/\\*{3,}/u;\n\nexport default iterateJsdoc(({\n allComments,\n context,\n makeReport,\n sourceCode,\n}) => {\n const [\n {\n ignore = [\n 'ts-check',\n 'ts-expect-error',\n 'ts-ignore',\n 'ts-nocheck',\n ],\n preventAllMultiAsteriskBlocks = false,\n } = {},\n ] = context.options;\n\n let extraAsterisks = false;\n const nonJsdocNodes = /** @type {import('estree').Node[]} */ (\n allComments\n ).filter((comment) => {\n const commentText = sourceCode.getText(comment);\n\n const initialText = commentText.replace(commentRegexp, '').trimStart();\n if ([\n 'eslint',\n ].some((directive) => {\n return initialText.startsWith(directive);\n })) {\n return false;\n }\n\n let sliceIndex = 2;\n if (!commentRegexp.test(commentText)) {\n const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];\n if (!multiline) {\n return false;\n }\n\n sliceIndex = multiline.length;\n extraAsterisks = true;\n if (preventAllMultiAsteriskBlocks) {\n return true;\n }\n }\n\n const tags = (commentParser(\n `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`,\n )[0] || {}).tags ?? [];\n\n return tags.length && !tags.some(({\n tag,\n }) => {\n return ignore.includes(tag);\n });\n });\n\n if (!nonJsdocNodes.length) {\n return;\n }\n\n for (const node of nonJsdocNodes) {\n const report = /** @type {import('../iterateJsdoc.js').MakeReport} */ (\n makeReport\n )(context, node);\n\n // eslint-disable-next-line no-loop-func\n const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n const text = sourceCode.getText(node);\n\n return fixer.replaceText(\n node,\n extraAsterisks ?\n text.replace(extraAsteriskCommentRegexp, '/**') :\n text.replace('/*', '/**'),\n );\n };\n\n report('Expected JSDoc-like comment to begin with two asterisks.', fix);\n }\n}, {\n checkFile: true,\n meta: {\n docs: {\n description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n ignore: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n preventAllMultiAsteriskBlocks: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEwB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExB;AACA;AACA,MAAMG,aAAa,GAAG,cAAc;AACpC,MAAMC,0BAA0B,GAAG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEjC,IAAAK,qBAAY,EAAC,CAAC;EAC3BC,WAAW;EACXC,OAAO;EACPC,UAAU;EACVC;AACF,CAAC,KAAK;EACJ,MAAM,CACJ;IACEC,MAAM,GAAG,CACP,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,YAAY,CACb;IACDC,6BAA6B,GAAG;EAClC,CAAC,GAAG,CAAC,CAAC,CACP,GAAGJ,OAAO,CAACK,OAAO;EAEnB,IAAIC,cAAc,GAAG,KAAK;EAC1B,MAAMC,aAAa,GAAG,sCACpBR,WAAW,CACXS,MAAM,CAAEC,OAAO,IAAK;IACpB,MAAMC,WAAW,GAAGR,UAAU,CAACS,OAAO,CAACF,OAAO,CAAC;IAE/C,MAAMG,WAAW,GAAGF,WAAW,CAACG,OAAO,CAACnB,aAAa,EAAE,EAAE,CAAC,CAACoB,SAAS,CAAC,CAAC;IACtE,IAAI,CACF,QAAQ,CACT,CAACC,IAAI,CAAEC,SAAS,IAAK;MACpB,OAAOJ,WAAW,CAACK,UAAU,CAACD,SAAS,CAAC;IAC1C,CAAC,CAAC,EAAE;MACF,OAAO,KAAK;IACd;IAEA,IAAIE,UAAU,GAAG,CAAC;IAClB,IAAI,CAACxB,aAAa,CAAC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GAAG,CAAC;EACzE;AACF,CAAC,EAAE;EACDI,SAAS,EAAE,IAAI;EACfC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,kGAAkG;MAC/GC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVvC,MAAM,EAAE;UACNwC,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDxC,6BAA6B,EAAE;UAC7BwC,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,MAAA,CAAAhD,OAAA,GAAAA,OAAA,CAAAJ,OAAA","ignoreList":[]}
|
|
@@ -94,21 +94,21 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
94
94
|
/**
|
|
95
95
|
* @type {Context[]}
|
|
96
96
|
*/
|
|
97
|
-
const contexts = (context.options[0] ?? {}).contexts ??
|
|
97
|
+
const contexts = (context.options[0] ?? {}).contexts ?? settings?.contexts;
|
|
98
98
|
|
|
99
99
|
// Report when MISSING
|
|
100
100
|
contexts.some(cntxt => {
|
|
101
101
|
const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;
|
|
102
|
-
const comment = typeof cntxt === 'string' ? '' : cntxt
|
|
102
|
+
const comment = typeof cntxt === 'string' ? '' : cntxt?.comment;
|
|
103
103
|
const contextKey = contextStr === 'any' ? 'undefined' : contextStr;
|
|
104
104
|
if ((!state.selectorMap[contextKey] || !state.selectorMap[contextKey][comment] || state.selectorMap[contextKey][comment] < (
|
|
105
105
|
// @ts-expect-error comment would need an object, not string
|
|
106
|
-
|
|
106
|
+
cntxt?.minimum ?? 1)) && (contextStr !== 'any' || Object.values(state.selectorMap).every(cmmnt => {
|
|
107
107
|
return !cmmnt[comment] || cmmnt[comment] < (
|
|
108
108
|
// @ts-expect-error comment would need an object, not string
|
|
109
|
-
|
|
109
|
+
cntxt?.minimum ?? 1);
|
|
110
110
|
}))) {
|
|
111
|
-
const message = typeof cntxt === 'string' ? 'Syntax is required: {{context}}' :
|
|
111
|
+
const message = typeof cntxt === 'string' ? 'Syntax is required: {{context}}' : cntxt?.message ?? 'Syntax is required: {{context}}' + (comment ? ' with {{comment}}' : '');
|
|
112
112
|
context.report({
|
|
113
113
|
data: {
|
|
114
114
|
comment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noMissingSyntax.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","setDefaults","state","selectorMap","incrementSelector","selector","comment","_default","exports","iterateJsdoc","context","info","utils","options","contexts","contextStr","findContext","String","contextSelected","exit","settings","length","report","loc","end","column","line","start","message","some","cntxt","contextKey","minimum","Object","values","every","cmmnt","data","matchContext","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","module"],"sources":["../../src/rules/noMissingSyntax.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @typedef {{\n * comment: string,\n * context: string,\n * message: string,\n * minimum: import('../iterateJsdoc.js').Integer\n * }} ContextObject\n */\n\n/**\n * @typedef {string|ContextObject} Context\n */\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @returns {void}\n */\nconst setDefaults = (state) => {\n if (!state.selectorMap) {\n state.selectorMap = {};\n }\n};\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @param {string} selector\n * @param {string} comment\n * @returns {void}\n */\nconst incrementSelector = (state, selector, comment) => {\n if (!state.selectorMap[selector]) {\n state.selectorMap[selector] = {};\n }\n\n if (!state.selectorMap[selector][comment]) {\n state.selectorMap[selector][comment] = 0;\n }\n\n state.selectorMap[selector][comment]++;\n};\n\nexport default iterateJsdoc(({\n context,\n info: {\n comment,\n },\n state,\n utils,\n}) => {\n if (!context.options[0]) {\n // Handle error later\n return;\n }\n\n /**\n * @type {Context[]}\n */\n const contexts = context.options[0].contexts;\n\n const {\n contextStr,\n } = utils.findContext(contexts, comment);\n\n setDefaults(state);\n\n incrementSelector(state, contextStr, String(comment));\n}, {\n contextSelected: true,\n exit ({\n context,\n settings,\n state,\n }) {\n if (!context.options.length && !settings.contexts) {\n context.report({\n loc: {\n end: {\n column: 1,\n line: 1,\n },\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `contexts` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n\n /**\n * @type {Context[]}\n */\n const contexts = (context.options[0] ?? {}).contexts ?? settings?.contexts;\n\n // Report when MISSING\n contexts.some((cntxt) => {\n const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n const comment = typeof cntxt === 'string' ? '' : cntxt?.comment;\n\n const contextKey = contextStr === 'any' ? 'undefined' : contextStr;\n\n if (\n (!state.selectorMap[contextKey] ||\n !state.selectorMap[contextKey][comment] ||\n state.selectorMap[contextKey][comment] < (\n // @ts-expect-error comment would need an object, not string\n cntxt?.minimum ?? 1\n )) &&\n (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n return !cmmnt[comment] || cmmnt[comment] < (\n // @ts-expect-error comment would need an object, not string\n cntxt?.minimum ?? 1\n );\n }))\n ) {\n const message = typeof cntxt === 'string' ?\n 'Syntax is required: {{context}}' :\n cntxt?.message ?? ('Syntax is required: {{context}}' +\n (comment ? ' with {{comment}}' : ''));\n context.report({\n data: {\n comment,\n context: contextStr,\n },\n loc: {\n end: {\n column: 1,\n line: 1,\n },\n start: {\n column: 1,\n line: 1,\n },\n },\n message,\n });\n\n return true;\n }\n\n return false;\n });\n },\n matchContext: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are always expected.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-missing-syntax.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\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 message: {\n type: 'string',\n },\n minimum: {\n type: 'integer',\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;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAMG,WAAW,GAAIC,KAAK,IAAK;EAC7B,IAAI,CAACA,KAAK,CAACC,WAAW,EAAE;IACtBD,KAAK,CAACC,WAAW,GAAG,CAAC,CAAC;EACxB;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGA,CAACF,KAAK,EAAEG,QAAQ,EAAEC,OAAO,KAAK;EACtD,IAAI,CAACJ,KAAK,CAACC,WAAW,CAACE,QAAQ,CAAC,EAAE;IAChCH,KAAK,CAACC,WAAW,CAACE,QAAQ,CAAC,GAAG,CAAC,CAAC;EAClC;EAEA,IAAI,CAACH,KAAK,CAACC,WAAW,CAACE,QAAQ,CAAC,CAACC,OAAO,CAAC,EAAE;IACzCJ,KAAK,CAACC,WAAW,CAACE,QAAQ,CAAC,CAACC,OAAO,CAAC,GAAG,CAAC;EAC1C;EAEAJ,KAAK,CAACC,WAAW,CAACE,QAAQ,CAAC,CAACC,OAAO,CAAC,EAAE;AACxC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEa,IAAAS,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,IAAI,EAAE;IACJL;EACF,CAAC;EACDJ,KAAK;EACLU;AACF,CAAC,KAAK;EACJ,IAAI,CAACF,OAAO,CAACG,OAAO,CAAC,CAAC,CAAC,EAAE;IACvB;IACA;EACF;;EAEA;AACF;AACA;EACE,MAAMC,QAAQ,GAAGJ,OAAO,CAACG,OAAO,CAAC,CAAC,CAAC,CAACC,QAAQ;EAE5C,MAAM;IACJC;EACF,CAAC,GAAGH,KAAK,CAACI,WAAW,CAACF,QAAQ,EAAER,OAAO,CAAC;EAExCL,WAAW,CAACC,KAAK,CAAC;EAElBE,iBAAiB,CAACF,KAAK,EAAEa,UAAU,EAAEE,MAAM,CAACX,OAAO,CAAC,CAAC;AACvD,CAAC,EAAE;EACDY,eAAe,EAAE,IAAI;EACrBC,IAAIA,CAAE;IACJT,OAAO;IACPU,QAAQ;IACRlB;EACF,CAAC,EAAE;IACD,IAAI,CAACQ,OAAO,CAACG,OAAO,CAACQ,MAAM,IAAI,CAACD,QAAQ,CAACN,QAAQ,EAAE;MACjDJ,OAAO,CAACY,MAAM,CAAC;QACbC,GAAG,EAAE;UACHC,GAAG,EAAE;YACHC,MAAM,EAAE,CAAC;YACTC,IAAI,EAAE;UACR,CAAC;UACDC,KAAK,EAAE;YACLF,MAAM,EAAE,CAAC;YACTC,IAAI,EAAE;UACR;QACF,CAAC;QACDE,OAAO,EAAE;MACX,CAAC,CAAC;MAEF;IACF;IAEA3B,WAAW,CAACC,KAAK,CAAC;;IAElB;AACJ;AACA;IACI,MAAMY,QAAQ,GAAG,CAACJ,OAAO,CAACG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAEC,QAAQ,
|
|
1
|
+
{"version":3,"file":"noMissingSyntax.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","setDefaults","state","selectorMap","incrementSelector","selector","comment","_default","exports","iterateJsdoc","context","info","utils","options","contexts","contextStr","findContext","String","contextSelected","exit","settings","length","report","loc","end","column","line","start","message","some","cntxt","contextKey","minimum","Object","values","every","cmmnt","data","matchContext","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","module"],"sources":["../../src/rules/noMissingSyntax.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @typedef {{\n * comment: string,\n * context: string,\n * message: string,\n * minimum: import('../iterateJsdoc.js').Integer\n * }} ContextObject\n */\n\n/**\n * @typedef {string|ContextObject} Context\n */\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @returns {void}\n */\nconst setDefaults = (state) => {\n if (!state.selectorMap) {\n state.selectorMap = {};\n }\n};\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @param {string} selector\n * @param {string} comment\n * @returns {void}\n */\nconst incrementSelector = (state, selector, comment) => {\n if (!state.selectorMap[selector]) {\n state.selectorMap[selector] = {};\n }\n\n if (!state.selectorMap[selector][comment]) {\n state.selectorMap[selector][comment] = 0;\n }\n\n state.selectorMap[selector][comment]++;\n};\n\nexport default iterateJsdoc(({\n context,\n info: {\n comment,\n },\n state,\n utils,\n}) => {\n if (!context.options[0]) {\n // Handle error later\n return;\n }\n\n /**\n * @type {Context[]}\n */\n const contexts = context.options[0].contexts;\n\n const {\n contextStr,\n } = utils.findContext(contexts, comment);\n\n setDefaults(state);\n\n incrementSelector(state, contextStr, String(comment));\n}, {\n contextSelected: true,\n exit ({\n context,\n settings,\n state,\n }) {\n if (!context.options.length && !settings.contexts) {\n context.report({\n loc: {\n end: {\n column: 1,\n line: 1,\n },\n start: {\n column: 1,\n line: 1,\n },\n },\n message: 'Rule `no-missing-syntax` is missing a `contexts` option.',\n });\n\n return;\n }\n\n setDefaults(state);\n\n /**\n * @type {Context[]}\n */\n const contexts = (context.options[0] ?? {}).contexts ?? settings?.contexts;\n\n // Report when MISSING\n contexts.some((cntxt) => {\n const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n const comment = typeof cntxt === 'string' ? '' : cntxt?.comment;\n\n const contextKey = contextStr === 'any' ? 'undefined' : contextStr;\n\n if (\n (!state.selectorMap[contextKey] ||\n !state.selectorMap[contextKey][comment] ||\n state.selectorMap[contextKey][comment] < (\n // @ts-expect-error comment would need an object, not string\n cntxt?.minimum ?? 1\n )) &&\n (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n return !cmmnt[comment] || cmmnt[comment] < (\n // @ts-expect-error comment would need an object, not string\n cntxt?.minimum ?? 1\n );\n }))\n ) {\n const message = typeof cntxt === 'string' ?\n 'Syntax is required: {{context}}' :\n cntxt?.message ?? ('Syntax is required: {{context}}' +\n (comment ? ' with {{comment}}' : ''));\n context.report({\n data: {\n comment,\n context: contextStr,\n },\n loc: {\n end: {\n column: 1,\n line: 1,\n },\n start: {\n column: 1,\n line: 1,\n },\n },\n message,\n });\n\n return true;\n }\n\n return false;\n });\n },\n matchContext: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are always expected.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-missing-syntax.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\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 message: {\n type: 'string',\n },\n minimum: {\n type: 'integer',\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;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAMG,WAAW,GAAIC,KAAK,IAAK;EAC7B,IAAI,CAACA,KAAK,CAAC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ACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,MAAA,CAAA1C,OAAA,GAAAA,OAAA,CAAAR,OAAA","ignoreList":[]}
|
|
@@ -31,7 +31,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
31
31
|
if (!foundContext) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const message = /** @type {import('../iterateJsdoc.js').ContextObject} */
|
|
34
|
+
const message = /** @type {import('../iterateJsdoc.js').ContextObject} */foundContext?.message ?? 'Syntax is restricted: {{context}}' + (comment ? ' with {{comment}}' : '');
|
|
35
35
|
report(message, null, null, comment ? {
|
|
36
36
|
comment,
|
|
37
37
|
context: contextStr
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noRestrictedSyntax.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","info","comment","report","utils","options","length","contexts","contextStr","foundContext","findContext","message","contextSelected","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","required","nonGlobalSettings","module"],"sources":["../../src/rules/noRestrictedSyntax.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n info: {\n comment,\n },\n report,\n utils,\n}) => {\n if (!context.options.length) {\n report('Rule `no-restricted-syntax` is missing a `contexts` option.');\n\n return;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n const {\n contextStr,\n foundContext,\n } = utils.findContext(contexts, comment);\n\n // We are not on the *particular* matching context/comment, so don't assume\n // we need reporting\n if (!foundContext) {\n return;\n }\n\n const message = /** @type {import('../iterateJsdoc.js').ContextObject} */ (\n foundContext\n )?.message ??\n 'Syntax is restricted: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n\n report(message, null, null, comment ? {\n comment,\n context: contextStr,\n } : {\n context: contextStr,\n });\n}, {\n contextSelected: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are present.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\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 message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n required: [\n 'contexts',\n ],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n nonGlobalSettings: true,\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,IAAI,EAAE;IACJC;EACF,CAAC;EACDC,MAAM;EACNC;AACF,CAAC,KAAK;EACJ,IAAI,CAACJ,OAAO,CAACK,OAAO,CAACC,MAAM,EAAE;IAC3BH,MAAM,CAAC,6DAA6D,CAAC;IAErE;EACF;EAEA,MAAM;IACJI;EACF,CAAC,GAAGP,OAAO,CAACK,OAAO,CAAC,CAAC,CAAC;EAEtB,MAAM;IACJG,UAAU;IACVC;EACF,CAAC,GAAGL,KAAK,CAACM,WAAW,CAACH,QAAQ,EAAEL,OAAO,CAAC;;EAExC;EACA;EACA,IAAI,CAACO,YAAY,EAAE;IACjB;EACF;EAEA,MAAME,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"noRestrictedSyntax.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","info","comment","report","utils","options","length","contexts","contextStr","foundContext","findContext","message","contextSelected","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","anyOf","type","required","nonGlobalSettings","module"],"sources":["../../src/rules/noRestrictedSyntax.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n info: {\n comment,\n },\n report,\n utils,\n}) => {\n if (!context.options.length) {\n report('Rule `no-restricted-syntax` is missing a `contexts` option.');\n\n return;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n const {\n contextStr,\n foundContext,\n } = utils.findContext(contexts, comment);\n\n // We are not on the *particular* matching context/comment, so don't assume\n // we need reporting\n if (!foundContext) {\n return;\n }\n\n const message = /** @type {import('../iterateJsdoc.js').ContextObject} */ (\n foundContext\n )?.message ??\n 'Syntax is restricted: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n\n report(message, null, null, comment ? {\n comment,\n context: contextStr,\n } : {\n context: contextStr,\n });\n}, {\n contextSelected: true,\n meta: {\n docs: {\n description: 'Reports when certain comment structures are present.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\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 message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n required: [\n 'contexts',\n ],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n nonGlobalSettings: true,\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;EAC3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UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDC,QAAQ,EAAE,CACR,UAAU,CACX;MACDD,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR,CAAC;EACDE,iBAAiB,EAAE;AACrB,CAAC,CAAC;AAAAC,MAAA,CAAA5B,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -28,7 +28,6 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
28
28
|
sourceCode,
|
|
29
29
|
utils
|
|
30
30
|
}) => {
|
|
31
|
-
var _globalScope$childSco;
|
|
32
31
|
const {
|
|
33
32
|
scopeManager
|
|
34
33
|
} = sourceCode;
|
|
@@ -93,7 +92,6 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
93
92
|
return tag === 'import';
|
|
94
93
|
});
|
|
95
94
|
}).flatMap(tag => {
|
|
96
|
-
var _Object$values$, _Object$values$2;
|
|
97
95
|
const {
|
|
98
96
|
description,
|
|
99
97
|
name,
|
|
@@ -103,7 +101,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
103
101
|
const imprt = 'import ' + (description ? `${typePart}${name} ${description}` : `${typePart}${name}`);
|
|
104
102
|
const importsExports = (0, _parseImportsExports.parseImportsExports)(imprt.trim());
|
|
105
103
|
const types = [];
|
|
106
|
-
const namedImports =
|
|
104
|
+
const namedImports = Object.values(importsExports.namedImports || {})[0]?.[0];
|
|
107
105
|
if (namedImports) {
|
|
108
106
|
if (namedImports.default) {
|
|
109
107
|
types.push(namedImports.default);
|
|
@@ -112,7 +110,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
112
110
|
types.push(...Object.keys(namedImports.names));
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
|
-
const namespaceImports =
|
|
113
|
+
const namespaceImports = Object.values(importsExports.namespaceImports || {})[0]?.[0];
|
|
116
114
|
if (namespaceImports) {
|
|
117
115
|
if (namespaceImports.namespace) {
|
|
118
116
|
types.push(namespaceImports.namespace);
|
|
@@ -126,8 +124,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
126
124
|
const ancestorNodes = [];
|
|
127
125
|
let currentNode = node;
|
|
128
126
|
// No need for Program node?
|
|
129
|
-
while (
|
|
130
|
-
var _currentNode;
|
|
127
|
+
while (currentNode?.parent) {
|
|
131
128
|
ancestorNodes.push(currentNode);
|
|
132
129
|
currentNode = currentNode.parent;
|
|
133
130
|
}
|
|
@@ -158,7 +155,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
158
155
|
|
|
159
156
|
// In modules, including Node, there is a global scope at top with the
|
|
160
157
|
// Program scope inside
|
|
161
|
-
const cjsOrESMScope =
|
|
158
|
+
const cjsOrESMScope = globalScope.childScopes[0]?.block?.type === 'Program';
|
|
162
159
|
|
|
163
160
|
/**
|
|
164
161
|
* @param {import("eslint").Scope.Scope | null} scope
|
|
@@ -257,8 +254,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
257
254
|
value
|
|
258
255
|
} = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde;
|
|
259
256
|
if (type === 'JsdocTypeName') {
|
|
260
|
-
|
|
261
|
-
const structuredTypes = (_structuredTags$tag$t = structuredTags[tag.tag]) === null || _structuredTags$tag$t === void 0 ? void 0 : _structuredTags$tag$t.type;
|
|
257
|
+
const structuredTypes = structuredTags[tag.tag]?.type;
|
|
262
258
|
if (!allDefinedTypes.has(value) && (!Array.isArray(structuredTypes) || !structuredTypes.includes(value))) {
|
|
263
259
|
if (!disableReporting) {
|
|
264
260
|
report(`The type '${value}' is undefined.`, null, tag);
|