1 |
- {"version":3,"sources":["../../src/rules/requireJsdoc.js"],"names":["OPTIONS_SCHEMA","additionalProperties","properties","checkConstructors","default","type","checkGetters","anyOf","enum","checkSetters","contexts","items","context","inlineCommentBlock","enableFixer","exemptEmptyConstructors","exemptEmptyFunctions","fixerMessage","publicOnly","oneOf","ancestorsOnly","cjs","esm","window","require","ArrowFunctionExpression","ClassDeclaration","ClassExpression","FunctionDeclaration","FunctionExpression","MethodDefinition","getOption","baseObject","option","key","_","has","options","getOptions","baseObj","Object","keys","forEach","prop","opt","create","sourceCode","getSourceCode","settings","requireOption","checkJsDoc","info","handler","node","jsDocNode","jsdocUtils","exemptSpeciaMethods","tags","isFunctionContext","isConstructor","functionParameterNames","getFunctionParameterNames","length","hasReturnValue","fix","fixer","lines","minLines","maxLines","baseNode","decorator","indent","getIndent","text","getText","loc","start","column","find","ctxt","insertion","repeat","slice","insertTextBefore","report","end","messageId","Boolean","initModuleExports","initWindow","exported","exportParser","isUncommentedExport","hasOption","some","getContextObject","enforcedContexts","includes","parent","value","meta","docs","category","description","recommended","url","fixable","messages","missingJsDoc","schema"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AACA;;AAGA;;;;AAEA,MAAMA,cAAc,GAAG;AACrBC,EAAAA,oBAAoB,EAAE,KADD;AAErBC,EAAAA,UAAU,EAAE;AACVC,IAAAA,iBAAiB,EAAE;AACjBC,MAAAA,OAAO,EAAE,IADQ;AAEjBC,MAAAA,IAAI,EAAE;AAFW,KADT;AAKVC,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,CACL;AACEF,QAAAA,IAAI,EAAE;AADR,OADK,EAIL;AACEG,QAAAA,IAAI,EAAE,CAAC,WAAD,CADR;AAEEH,QAAAA,IAAI,EAAE;AAFR,OAJK,CADK;AAUZD,MAAAA,OAAO,EAAE;AAVG,KALJ;AAiBVK,IAAAA,YAAY,EAAE;AACZF,MAAAA,KAAK,EAAE,CACL;AACEF,QAAAA,IAAI,EAAE;AADR,OADK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AIJC,MAAAA,GAAG,EAAE;AAJD,KADF;AAQJC,IAAAA,OAAO,EAAE,MARL;AAUJC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,YAAY,EAAE;AADN,KAVN;AAcJC,IAAAA,MAAM,EAAE,CACN7G,cADM,CAdJ;AAkBJK,IAAAA,IAAI,EAAE;AAlBF;AA1KO,C","sourcesContent":["import {\n getJSDocComment, getReducedASTNode, getDecorator,\n} from '@es-joy/jsdoccomment';\nimport _ from 'lodash';\nimport exportParser from '../exportParser';\nimport {\n getSettings,\n} from '../iterateJsdoc';\nimport jsdocUtils from '../jsdocUtils';\n\nconst OPTIONS_SCHEMA = {\n additionalProperties: false,\n properties: {\n checkConstructors: {\n default: true,\n type: 'boolean',\n },\n checkGetters: {\n anyOf: [\n {\n type: 'boolean',\n },\n {\n enum: ['no-setter'],\n type: 'string',\n },\n ],\n default: true,\n },\n checkSetters: {\n anyOf: [\n {\n type: 'boolean',\n },\n {\n enum: ['no-getter'],\n type: 'string',\n },\n ],\n default: true,\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 enableFixer: {\n default: true,\n type: 'boolean',\n },\n exemptEmptyConstructors: {\n default: false,\n type: 'boolean',\n },\n exemptEmptyFunctions: {\n default: false,\n type: 'boolean',\n },\n fixerMessage: {\n default: '',\n type: 'string',\n },\n publicOnly: {\n oneOf: [\n {\n default: false,\n type: 'boolean',\n },\n {\n additionalProperties: false,\n default: {},\n properties: {\n ancestorsOnly: {\n type: 'boolean',\n },\n cjs: {\n type: 'boolean',\n },\n esm: {\n type: 'boolean',\n },\n window: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n require: {\n additionalProperties: false,\n default: {},\n properties: {\n ArrowFunctionExpression: {\n default: false,\n type: 'boolean',\n },\n ClassDeclaration: {\n default: false,\n type: 'boolean',\n },\n ClassExpression: {\n default: false,\n type: 'boolean',\n },\n FunctionDeclaration: {\n default: true,\n type: 'boolean',\n },\n FunctionExpression: {\n default: false,\n type: 'boolean',\n },\n MethodDefinition: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n};\n\nconst getOption = (context, baseObject, option, key) => {\n if (!_.has(context, `options[0][${option}][${key}]`)) {\n return baseObject.properties[key].default;\n }\n\n return context.options[0][option][key];\n};\n\nconst getOptions = (context) => {\n const {\n publicOnly,\n contexts = [],\n exemptEmptyConstructors = true,\n exemptEmptyFunctions = false,\n enableFixer = true,\n fixerMessage = '',\n } = context.options[0] || {};\n\n return {\n contexts,\n enableFixer,\n exemptEmptyConstructors,\n exemptEmptyFunctions,\n fixerMessage,\n publicOnly: ((baseObj) => {\n if (!publicOnly) {\n return false;\n }\n\n const properties = {};\n Object.keys(baseObj.properties).forEach((prop) => {\n const opt = getOption(context, baseObj, 'publicOnly', prop);\n properties[prop] = opt;\n });\n\n return properties;\n })(OPTIONS_SCHEMA.properties.publicOnly.oneOf[1]),\n require: ((baseObj) => {\n const properties = {};\n Object.keys(baseObj.properties).forEach((prop) => {\n const opt = getOption(context, baseObj, 'require', prop);\n properties[prop] = opt;\n });\n\n return properties;\n })(OPTIONS_SCHEMA.properties.require),\n };\n};\n\nexport default {\n create (context) {\n const sourceCode = context.getSourceCode();\n const settings = getSettings(context);\n if (!settings) {\n return {};\n }\n\n const {\n require: requireOption,\n contexts,\n publicOnly, exemptEmptyFunctions, exemptEmptyConstructors, enableFixer, fixerMessage,\n } = getOptions(context);\n\n const checkJsDoc = (info, handler, node) => {\n const jsDocNode = getJSDocComment(sourceCode, node, settings);\n\n if (jsDocNode) {\n return;\n }\n\n // For those who have options configured against ANY constructors (or\n // setters or getters) being reported\n if (jsdocUtils.exemptSpeciaMethods(\n {tags: []}, node, context, [OPTIONS_SCHEMA],\n )) {\n return;\n }\n\n if (\n // Avoid reporting param-less, return-less functions (when\n // `exemptEmptyFunctions` option is set)\n exemptEmptyFunctions && info.isFunctionContext ||\n\n // Avoid reporting param-less, return-less constructor methods (when\n // `exemptEmptyConstructors` option is set)\n exemptEmptyConstructors && jsdocUtils.isConstructor(node)\n ) {\n const functionParameterNames = jsdocUtils.getFunctionParameterNames(node);\n if (!functionParameterNames.length && !jsdocUtils.hasReturnValue(node)) {\n return;\n }\n }\n\n const fix = (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 = getReducedASTNode(node, sourceCode);\n\n const decorator = getDecorator(baseNode);\n if (decorator) {\n baseNode = decorator;\n }\n\n const indent = jsdocUtils.getIndent({\n text: sourceCode.getText(\n baseNode,\n baseNode.loc.start.column,\n ),\n });\n\n const {inlineCommentBlock} = contexts.find(({context: ctxt}) => {\n return ctxt === node.type;\n }) || {};\n const insertion = (inlineCommentBlock ?\n `/** ${fixerMessage}` :\n `/**\\n${indent}*${fixerMessage}\\n${indent}`) +\n `*/${'\\n'.repeat(lines)}${indent.slice(0, -1)}`;\n\n return fixer.insertTextBefore(baseNode, insertion);\n };\n\n const report = () => {\n const loc = {\n end: node.loc.start + 1,\n start: node.loc.start,\n };\n context.report({\n fix: enableFixer ? fix : null,\n loc,\n messageId: 'missingJsDoc',\n node,\n });\n };\n\n if (publicOnly) {\n const opt = {\n ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),\n esm: Boolean(publicOnly?.esm ?? true),\n initModuleExports: Boolean(publicOnly?.cjs ?? true),\n initWindow: Boolean(publicOnly?.window ?? false),\n };\n const exported = exportParser.isUncommentedExport(node, sourceCode, opt, settings);\n\n if (exported) {\n report();\n }\n } else {\n report();\n }\n };\n\n const hasOption = (prop) => {\n return requireOption[prop] || contexts.some((ctxt) => {\n return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;\n });\n };\n\n return {\n ...jsdocUtils.getContextObject(\n jsdocUtils.enforcedContexts(context, []),\n checkJsDoc,\n ),\n ArrowFunctionExpression (node) {\n if (!hasOption('ArrowFunctionExpression')) {\n return;\n }\n\n if (\n ['VariableDeclarator', 'AssignmentExpression', 'ExportDefaultDeclaration'].includes(node.parent.type) ||\n ['Property', 'ObjectProperty', 'ClassProperty'].includes(node.parent.type) && node === node.parent.value\n ) {\n checkJsDoc({isFunctionContext: true}, null, node);\n }\n },\n\n ClassDeclaration (node) {\n if (!hasOption('ClassDeclaration')) {\n return;\n }\n\n checkJsDoc({isFunctionContext: false}, null, node);\n },\n\n ClassExpression (node) {\n if (!hasOption('ClassExpression')) {\n return;\n }\n\n checkJsDoc({isFunctionContext: false}, null, node);\n },\n\n FunctionDeclaration (node) {\n if (!hasOption('FunctionDeclaration')) {\n return;\n }\n\n checkJsDoc({isFunctionContext: true}, null, node);\n },\n\n FunctionExpression (node) {\n if (hasOption('MethodDefinition') && node.parent.type === 'MethodDefinition') {\n checkJsDoc({isFunctionContext: true}, null, node);\n\n return;\n }\n\n if (!hasOption('FunctionExpression')) {\n return;\n }\n\n if (\n ['VariableDeclarator', 'AssignmentExpression', 'ExportDefaultDeclaration'].includes(node.parent.type) ||\n ['Property', 'ObjectProperty', 'ClassProperty'].includes(node.parent.type) && node === node.parent.value\n ) {\n checkJsDoc({isFunctionContext: true}, null, node);\n }\n },\n };\n },\n meta: {\n docs: {\n category: 'Stylistic Issues',\n description: 'Require JSDoc comments',\n recommended: 'true',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-jsdoc',\n },\n\n fixable: 'code',\n\n messages: {\n missingJsDoc: 'Missing JSDoc comment.',\n },\n\n schema: [\n OPTIONS_SCHEMA,\n ],\n\n type: 'suggestion',\n },\n};\n"],"file":"requireJsdoc.js"}
|