mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
1 line
4.3 KiB
Plaintext
1 line
4.3 KiB
Plaintext
|
{"version":3,"sources":["../../src/rules/newlineAfterDescription.js"],"names":["jsdoc","report","context","jsdocNode","sourceCode","indent","always","description","trim","tags","length","_","has","options","descriptionEndsWithANewline","test","sourceLines","getText","split","splitDesc","lastDescriptionLine","fixer","injectedLine","endsWith","splice","replaceText","join","line","iterateAllJsdocs","meta","fixable","schema","enum","type","noTrim"],"mappings":";;;;;;;AAAA;;AACA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,KAD2B;AAE3BC,EAAAA,MAF2B;AAG3BC,EAAAA,OAH2B;AAI3BC,EAAAA,SAJ2B;AAK3BC,EAAAA,UAL2B;AAM3BC,EAAAA;AAN2B,CAAD,KAOtB;AACJ,MAAIC,MAAJ;;AAEA,MAAI,CAACN,KAAK,CAACO,WAAN,CAAkBC,IAAlB,EAAD,IAA6B,CAACR,KAAK,CAACS,IAAN,CAAWC,MAA7C,EAAqD;AACnD;AACD;;AAED,MAAIC,gBAAEC,GAAF,CAAMV,OAAO,CAACW,OAAd,EAAuB,CAAvB,CAAJ,EAA+B;AAC7BP,IAAAA,MAAM,GAAGJ,OAAO,CAACW,OAAR,CAAgB,CAAhB,MAAuB,QAAhC;AACD,GAFD,MAEO;AACLP,IAAAA,MAAM,GAAG,IAAT;AACD;;AAED,QAAMQ,2BAA2B,GAAI,QAAD,CAAWC,IAAX,CAAgBf,KAAK,CAACO,WAAtB,CAApC;;AAEA,MAAID,MAAJ,EAAY;AACV,QAAI,CAACQ,2BAAL,EAAkC;AAChC,YAAME,WAAW,GAAGZ,UAAU,CAACa,OAAX,CAAmBd,SAAnB,EAA8Be,KAA9B,CAAoC,IAApC,CAApB;AACA,YAAMC,SAAS,GAAGnB,KAAK,CAACO,WAAN,CAAkBW,KAAlB,CAAwB,IAAxB,CAAlB;AACA,YAAME,mBAAmB,GAAGD,SAAS,CA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,CAAC,QAAD,EAAW,OAAX,CADR;AAEEC,MAAAA,IAAI,EAAE;AAFR,KADM,CAFJ;AAQJA,IAAAA,IAAI,EAAE;AARF,GAFL;AAYDC,EAAAA,MAAM,EAAE;AAZP,CAnDY,C","sourcesContent":["import _ from 'lodash';\nimport iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n jsdocNode,\n sourceCode,\n indent,\n}) => {\n let always;\n\n if (!jsdoc.description.trim() || !jsdoc.tags.length) {\n return;\n }\n\n if (_.has(context.options, 0)) {\n always = context.options[0] === 'always';\n } else {\n always = true;\n }\n\n const descriptionEndsWithANewline = (/\\n\\r?$/).test(jsdoc.description);\n\n if (always) {\n if (!descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n const splitDesc = jsdoc.description.split('\\n');\n const lastDescriptionLine = splitDesc.length - 1;\n report('There must be a newline after the description of the JSDoc block.', (fixer) => {\n // Add the new line\n const injectedLine = `${indent} *` +\n (sourceLines[lastDescriptionLine].endsWith('\\r') ? '\\r' : '');\n sourceLines.splice(lastDescriptionLine + 1, 0, injectedLine);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n }, {\n line: lastDescriptionLine,\n });\n }\n } else if (descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n const splitDesc = jsdoc.description.split('\\n');\n const lastDescriptionLine = splitDesc.length - 1;\n report('There must be no newline after the description of the JSDoc block.', (fixer) => {\n // Remove the extra line\n sourceLines.splice(lastDescriptionLine, 1);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n },
|