blob: 20cc48fbb059bc61656bbfcf109214fb3ad39776 [file] [log] [blame]
{"version":3,"sources":["../../src/rules/checkIndentation.js"],"names":["maskExcludedContent","str","excludeTags","regContent","RegExp","join","replace","match","margin","code","Array","length","maskCodeBlocks","sourceCode","jsdocNode","report","context","options","reg","textWithoutCodeBlocks","getText","text","test","lineBreaks","slice","lastIndex","line","iterateAllJsdocs","meta","schema","additionalProperties","properties","items","pattern","type"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,mBAAmB,GAAG,CAACC,GAAD,EAAMC,WAAN,KAAsB;AAChD,QAAMC,UAAU,GAAG,IAAIC,MAAJ,CAAY,yBAAwBF,WAAW,CAACG,IAAZ,CAAiB,GAAjB,CAAsB,2DAA1D,EAAsH,IAAtH,CAAnB;AAEA,SAAOJ,GAAG,CAACK,OAAJ,CAAYH,UAAZ,EAAwB,CAACI,KAAD,EAAQC,MAAR,EAAgBC,IAAhB,KAAyB;AACtD,WAAO,IAAIC,KAAJ,CAAUD,IAAI,CAACF,KAAL,CAAW,MAAX,EAAmBI,MAAnB,GAA4B,CAAtC,EAAyCN,IAAzC,CAA8CG,MAAM,GAAG,IAAvD,CAAP;AACD,GAFM,CAAP;AAGD,CAND;;AAQA,MAAMI,cAAc,GAAIX,GAAD,IAAS;AAC9B,QAAME,UAAU,GAAG,4EAAnB;AAEA,SAAOF,GAAG,CAACK,OAAJ,CAAYH,UAAZ,EAAwB,CAACI,KAAD,EAAQC,MAAR,EAAgBC,IAAhB,KAAyB;AACtD,WAAO,IAAIC,KAAJ,CAAUD,IAAI,CAACF,KAAL,CAAW,MAAX,EAAmBI,MAAnB,GAA4B,CAAtC,EAAyCN,IAAzC,CAA8CG,MAAM,GAAG,IAAvD,CAAP;AACD,GAFM,CAAP;AAGD,CAND;;eAQe,2BAAa,CAAC;AAC3BK,EAAAA,UAD2B;AAE3BC,EAAAA,SAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,QAAMC,OAAO,GAAGD,OAAO,CAACC,OAAR,CAAgB,CAAhB,KAAsB,EAAtC;AADI,+BAIAA,OAJA,CAGFf,WAHE;AAAA,QAGFA,WAHE,qCAGY,CAAC,SAAD,CAHZ;AAMJ,QAAMgB,GAAG,GAAG,IAAId,MAAJ,CAAW,iCAAX,CAAZ;AACA,QAAMe,qBAAqB,GAAGP,cAAc,CAACC,UAAU,CAACO,OAAX,CAAmBN,SAAnB,CAAD,CAA5C;AACA,QAAMO,IAAI,GAAGnB,WAAW,CAACS,MAAZ,GAAqBX,mBAAmB,CAACmB,qBAAD,EAAwBjB,WAAxB,CAAxC,GAA+EiB,qBAA5F;;AAEA,MAAID,GAAG,CAACI,IAAJ,CAASD,IAAT,CAAJ,EAAoB;AAClB,UAAME,UAAU,GAAGF,IAAI,CAACG,KAAL,CAAW,CAAX,EAAcN,GAAG,CAACO,SAAlB,EAA6BlB,KAA7B,CAAmC,MAAnC,KAA8C,EAAjE;AACAQ,IAAAA,MAAM,CAAC,+BAAD,EAAkC,IAAlC,EAAwC;AAC5CW,MAAAA,IAAI,EAAEH,UAAU,CAACZ;AAD2B,KAAxC,CAAN;AAGD;AACF,CArBc,EAqBZ;AACDgB,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,MAAM,EAAE,CAAC;AACPC,MAAAA,oBAAoB,EAAE,KADf;AAEPC,MAAAA,UAAU,EAAE;AACV7B,QAAAA,WAAW,EAAE;AACX8B,UAAAA,KAAK,EAAE;AACLC,YAAAA,OAAO,EAAE,QADJ;AAELC,YAAAA,IAAI,EAAE;AAFD,WADI;AAKXA,UAAAA,IAAI,EAAE;AALK;AADH,OAFL;AAWPA,MAAAA,IAAI,EAAE;AAXC,KAAD,CADJ;AAcJA,IAAAA,IAAI,EAAE;AAdF;AAFL,CArBY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst maskExcludedContent = (str, excludeTags) => {\n const regContent = new RegExp(`([ \\\\t]+\\\\*)[ \\\\t]@(?:${excludeTags.join('|')})(?=[ \\\\n])([\\\\w|\\\\W]*?\\\\n)(?=[ \\\\t]*\\\\*(?:[ \\\\t]*@|\\\\/))`, 'gu');\n\n return str.replace(regContent, (match, margin, code) => {\n return new Array(code.match(/\\n/gu).length + 1).join(margin + '\\n');\n });\n};\n\nconst maskCodeBlocks = (str) => {\n const regContent = /([ \\t]+\\*)[ \\t]```[^\\n]*?([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*(?:```|@)|\\/))/gu;\n\n return str.replace(regContent, (match, margin, code) => {\n return new Array(code.match(/\\n/gu).length + 1).join(margin + '\\n');\n });\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n jsdocNode,\n report,\n context,\n}) => {\n const options = context.options[0] || {};\n const {\n excludeTags = ['example'],\n } = options;\n\n const reg = new RegExp(/^(?:\\/?\\**|[ \\t]*)\\*[ \\t]{2}/gmu);\n const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode));\n const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks;\n\n if (reg.test(text)) {\n const lineBreaks = text.slice(0, reg.lastIndex).match(/\\n/gu) || [];\n report('There must be no indentation.', null, {\n line: lineBreaks.length,\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n schema: [{\n additionalProperties: false,\n properties: {\n excludeTags: {\n items: {\n pattern: '^\\\\S+$',\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n }],\n type: 'layout',\n },\n});\n"],"file":"checkIndentation.js"}