mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
1 line
15 KiB
Plaintext
1 line
15 KiB
Plaintext
{"version":3,"sources":["../../src/rules/requireJsdoc.js"],"names":["OPTIONS_SCHEMA","additionalProperties","properties","contexts","items","type","exemptEmptyFunctions","default","publicOnly","oneOf","ancestorsOnly","cjs","esm","window","require","ArrowFunctionExpression","ClassDeclaration","ClassExpression","FunctionDeclaration","FunctionExpression","MethodDefinition","getOption","context","baseObject","option","key","_","has","options","getOptions","baseObj","get","Object","keys","reduce","obj","prop","opt","create","sourceCode","getSourceCode","settings","requireOption","checkJsDoc","node","jsDocNode","functionParameterNames","jsdocUtils","getFunctionParameterNames","length","hasReturnValue","fix","fixer","lines","minLines","maxLines","indent","getIndent","insertion","repeat","slice","baseNode","includes","parent","insertTextBefore","report","loc","end","start","messageId","Boolean","initModuleExports","initWindow","parseResult","exportParser","parse","ast","exported","isExported","assign","getContextObject","enforcedContexts","value","meta","doc","category","description","recommended","url","fixable","messages","missingJsDoc","schema"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,cAAc,GAAG;AACrBC,EAAAA,oBAAoB,EAAE,KADD;AAErBC,EAAAA,UAAU,EAAE;AACVC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,KAAK,EAAE;AACLC,QAAAA,IAAI,EAAE;AADD,OADC;AAIRA,MAAAA,IAAI,EAAE;AAJE,KADA;AAOVC,IAAAA,oBAAoB,EAAE;AACpBC,MAAAA,OAAO,EAAE,KADW;AAEpBF,MAAAA,IAAI,EAAE;AAFc,KAPZ;AAWVG,IAAAA,UAAU,EAAE;AACVC,MAAAA,KAAK,EAAE,CACL;AACEF,QAAAA,OAAO,EAAE,KADX;AAEEF,QAAAA,IAAI,EAAE;AAFR,OADK,EAKL;AACEJ,QAAAA,oBAAoB,EAAE,KADxB;AAEEM,QAAAA,OAAO,EAAE,EAFX;AAGEL,QAAAA,UAAU,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AAA,UAAU,CAACC,IAAD,CAAV;AACD,OAnCH;;AAqCEzB,MAAAA,kBAAkB,CAAEyB,IAAF,EAAQ;AACxB,YAAIF,aAAa,CAACtB,gBAAd,IAAkCwB,IAAI,CAACmB,MAAL,CAAY1D,IAAZ,KAAqB,kBAA3D,EAA+E;AAC7EsC,UAAAA,UAAU,CAACC,IAAD,CAAV;AAEA;AACD;;AAED,YAAI,CAACF,aAAa,CAACvB,kBAAnB,EAAuC;AACrC;AACD;;AAED,YACE,CAAC,oBAAD,EAAuB,sBAAvB,EAA+C,0BAA/C,EAA2E2C,QAA3E,CAAoFlB,IAAI,CAACmB,MAAL,CAAY1D,IAAhG,KACAuC,IAAI,CAACmB,MAAL,CAAY1D,IAAZ,KAAqB,UAArB,IAAmCuC,IAAI,KAAKA,IAAI,CAACmB,MAAL,CAAYmB,KAF1D,EAGE;AACAvC,UAAAA,UAAU,CAACC,IAAD,CAAV;AACD;AACF;;AAtDH,KAFK,CAAP;AA2DD,GA9HY;;AA+HbuC,EAAAA,IAAI,EAAE;AACJC,IAAAA,GAAG,EAAE;AACHC,MAAAA,QAAQ,EAAE,kBADP;AAEHC,MAAAA,WAAW,EAAE,wBAFV;AAGHC,MAAAA,WAAW,EAAE,MAHV;AAIHC,MAAAA,GAAG,EAAE;AAJF,KADD;AAQJC,IAAAA,OAAO,EAAE,MARL;AAUJC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,YAAY,EAAE;AADN,KAVN;AAcJC,IAAAA,MAAM,EAAE,CACN5F,cADM,CAdJ;AAkBJK,IAAAA,IAAI,EAAE;AAlBF;AA/HO,C","sourcesContent":["import _ from 'lodash';\nimport jsdocUtils from '../jsdocUtils';\nimport exportParser from '../exportParser';\nimport getJSDocComment from '../eslint/getJSDocComment';\nimport warnRemovedSettings from '../warnRemovedSettings';\nimport {getSettings} from '../iterateJsdoc';\n\nconst OPTIONS_SCHEMA = {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n exemptEmptyFunctions: {\n default: false,\n type: 'boolean',\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 return {\n exemptEmptyFunctions: context.options[0] ? context.options[0].exemptEmptyFunctions : false,\n publicOnly: ((baseObj) => {\n const publicOnly = _.get(context, 'options[0].publicOnly');\n if (!publicOnly) {\n return false;\n }\n\n return Object.keys(baseObj.properties).reduce((obj, prop) => {\n const opt = getOption(context, baseObj, 'publicOnly', prop);\n obj[prop] = opt;\n\n return obj;\n }, {});\n })(OPTIONS_SCHEMA.properties.publicOnly.oneOf[1]),\n require: ((baseObj) => {\n return Object.keys(baseObj.properties).reduce((obj, prop) => {\n const opt = getOption(context, baseObj, 'require', prop);\n obj[prop] = opt;\n\n return obj;\n }, {});\n })(OPTIONS_SCHEMA.properties.require),\n };\n};\n\nexport default {\n create (context) {\n warnRemovedSettings(context, 'require-jsdoc');\n\n const sourceCode = context.getSourceCode();\n const settings = getSettings(context);\n\n const {require: requireOption, publicOnly, exemptEmptyFunctions} = getOptions(context);\n\n const checkJsDoc = (node) => {\n const jsDocNode = getJSDocComment(sourceCode, node, settings);\n\n if (jsDocNode) {\n return;\n }\n\n if (exemptEmptyFunctions) {\n const functionParameterNames = jsdocUtils.getFunctionParameterNames(node);\n if (!functionParameterNames.length && !jsdocUtils.hasReturnValue(node, context)) {\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 const indent = jsdocUtils.getIndent(sourceCode);\n const insertion = `/**\\n${indent}*\\n${indent}*/${'\\n'.repeat(lines)}${indent.slice(0, -1)}`;\n const baseNode = [\n 'ExportDefaultDeclaration', 'ExportNamedDeclaration',\n ].includes(node.parent && node.parent.type) ? node.parent : node;\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,\n loc,\n messageId: 'missingJsDoc',\n node,\n });\n };\n\n if (publicOnly) {\n const opt = {\n ancestorsOnly: Boolean(_.get(publicOnly, 'ancestorsOnly', false)),\n esm: Boolean(_.get(publicOnly, 'esm', true)),\n initModuleExports: Boolean(_.get(publicOnly, 'cjs', true)),\n initWindow: Boolean(_.get(publicOnly, 'window', false)),\n };\n const parseResult = exportParser.parse(sourceCode.ast, node, opt);\n const exported = exportParser.isExported(node, parseResult, opt);\n\n if (exported) {\n report();\n }\n } else {\n report();\n }\n };\n\n // eslint-disable-next-line fp/no-mutating-assign\n return Object.assign(\n jsdocUtils.getContextObject(jsdocUtils.enforcedContexts(context, []), checkJsDoc),\n {\n ArrowFunctionExpression (node) {\n if (!requireOption.ArrowFunctionExpression) {\n return;\n }\n\n if (!['VariableDeclarator', 'ExportDefaultDeclaration'].includes(node.parent.type)) {\n return;\n }\n\n checkJsDoc(node);\n },\n\n ClassDeclaration (node) {\n if (!requireOption.ClassDeclaration) {\n return;\n }\n\n checkJsDoc(node);\n },\n\n ClassExpression (node) {\n if (!requireOption.ClassExpression) {\n return;\n }\n\n checkJsDoc(node);\n },\n\n FunctionDeclaration (node) {\n if (!requireOption.FunctionDeclaration) {\n return;\n }\n\n checkJsDoc(node);\n },\n\n FunctionExpression (node) {\n if (requireOption.MethodDefinition && node.parent.type === 'MethodDefinition') {\n checkJsDoc(node);\n\n return;\n }\n\n if (!requireOption.FunctionExpression) {\n return;\n }\n\n if (\n ['VariableDeclarator', 'AssignmentExpression', 'ExportDefaultDeclaration'].includes(node.parent.type) ||\n node.parent.type === 'Property' && node === node.parent.value\n ) {\n checkJsDoc(node);\n }\n },\n },\n );\n },\n meta: {\n doc: {\n category: 'Stylistic Issues',\n description: 'Require JSDoc comments',\n recommended: 'true',\n url: 'https://github.com/gajus/eslint-plugin-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"} |