1 |
- {"version":3,"sources":["../../src/rules/checkAlignment.js"],"names":["trimStart","string","replace","sourceCode","jsdocNode","report","indent","indentLevel","length","sourceLines","getText","split","slice","map","line","filter","fix","fixer","replacement","index","ignored","join","replaceText","some","lineNum","iterateAllJsdocs","meta","docs","description","url","fixable","type"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,SAAS,GAAIC,MAAD,IAAY;AAC5B,SAAOA,MAAM,CAACC,OAAP,CAAe,OAAf,EAAwB,EAAxB,CAAP;AACD,CAFD;;eAIe,2BAAa,CAAC;AAC3BC,EAAAA,UAD2B;AAE3BC,EAAAA,SAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ;AACA,QAAMC,WAAW,GAAGD,MAAM,CAACE,MAAP,GAAgB,CAApC;AACA,QAAMC,WAAW,GAAGN,UAAU,CAACO,OAAX,CAAmBN,SAAnB,EAA8BO,KAA9B,CAAoC,IAApC,EACjBC,KADiB,CACX,CADW,EAEjBC,GAFiB,CAEZC,IAAD,IAAU;AACb,WAAOA,IAAI,CAACH,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAAP;AACD,GAJiB,EAKjBI,MALiB,CAKTD,IAAD,IAAU;AAChB,WAAO,CAACd,SAAS,CAACc,IAAD,CAAT,CAAgBN,MAAxB;AACD,GAPiB,CAApB;;AASA,QAAMQ,GAAG,GAAIC,KAAD,IAAW;AACrB,UAAMC,WAAW,GAAGf,UAAU,CAACO,OAAX,CAAmBN,SAAnB,EAA8BO,KAA9B,CAAoC,IAApC,EACjBE,GADiB,CACb,CAACC,IAAD,EAAOK,KAAP,KAAiB;AACpB;AACA,YAAMC,OAAO,GAAG,CAACD,KAAD,IAAUnB,SAAS,CAACc,IAAI,CAACH,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAAD,CAAT,CAA8BH,MAAxD;AAEA,aAAOY,OAAO,GAAGN,IAAH,GAAW,GAAER,MAAO,IAAGN,SAAS,CAACc,IAAD,CAAO,EAArD;AACD,KANiB,EAOjBO,IAPiB,CAOZ,IAPY,CAApB;AASA,WAAOJ,KAAK,CAACK,WAAN,CAAkBlB,SAAlB,EAA6Bc,WAA7B,CAAP;AACD,GAXD;;AAaAT,EAAAA,WAAW,CAACc,IAAZ,CAAiB,CAACT,IAAD,EAAOU,OAAP,KAAmB;AAClC,QAAIV,IAAI,CAACN,MAAL,KAAgBD,WAApB,EAAiC;AAC/BF,MAAAA,MAAM,CAAC,qCAAD,EAAwCW,GAAxC,EAA6C;AACjDF,QAAAA,IAAI,EAAEU,OAAO,GAAG;AADiC,OAA7C,CAAN;AAIA,aAAO,IAAP;AACD;;AAED,WAAO,KAAP;AACD,GAVD;AAWD,CAzCc,EAyCZ;AACDC,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,qDADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,OAAO,EAAE,MALL;AAMJC,IAAAA,IAAI,EAAE;AANF;AAFL,CAzCY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst trimStart = (string) => {\n return string.replace(/^\\s+/u, '');\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n jsdocNode,\n report,\n indent,\n}) => {\n // `indent` is whitespace from line 1 (`/**`), so slice and account for \"/\".\n const indentLevel = indent.length + 1;\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n')\n .slice(1)\n .map((line) => {\n return line.split('*')[0];\n })\n .filter((line) => {\n return !trimStart(line).length;\n });\n\n const fix = (fixer) => {\n const replacement = sourceCode.getText(jsdocNode).split('\\n')\n .map((line, index) => {\n // Ignore the first line and all lines not starting with `*`\n const ignored = !index || trimStart(line.split('*')[0]).length;\n\n return ignored ? line : `${indent} ${trimStart(line)}`;\n })\n .join('\\n');\n\n return fixer.replaceText(jsdocNode, replacement);\n };\n\n sourceLines.some((line, lineNum) => {\n if (line.length !== indentLevel) {\n report('Expected JSDoc block to be aligned.', fix, {\n line: lineNum + 1,\n });\n\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block asterisks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-alignment',\n },\n fixable: 'code',\n type: 'layout',\n },\n});\n"],"file":"checkAlignment.js"}
|