|
1 |
- {"version":3,"sources":["../../src/rules/requireAsteriskPrefix.js"],"names":["context","jsdoc","utils","indent","defaultRequireValue","tags","tagMap","options","source","always","never","currentTag","some","number","tokens","delimiter","tag","end","description","neverFix","postDelimiter","checkNever","checkValue","includes","reportJSDoc","column","line","alwaysFix","start","checkAlways","slice","any","iterateAllJsdocs","meta","fixable","schema","enum","type","additionalProperties","properties","items"],"mappings":";;;;;;;AAAA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,KAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,QAAM,CAACC,mBAAmB,GAAG,QAAvB,EAAiC;AACrCC,IAAAA,IAAI,EAAEC,MAAM,GAAG;AADsB,MAEnC,EAFE,IAEIN,OAAO,CAACO,OAFlB;AAIA,QAAM;AAACC,IAAAA;AAAD,MAAWP,KAAjB;AAEA,QAAMQ,MAAM,GAAGL,mBAAmB,KAAK,QAAvC;AACA,QAAMM,KAAK,GAAGN,mBAAmB,KAAK,OAAtC;AAEA,MAAIO,UAAJ;AACAH,EAAAA,MAAM,CAACI,IAAP,CAAY,CAAC;AAACC,IAAAA,MAAD;AAASC,IAAAA;AAAT,GAAD,KAAsB;AAAA;;AAChC,UAAM;AAACC,MAAAA,SAAD;AAAYC,MAAAA,GAAZ;AAAiBC,MAAAA,GAAjB;AAAsBC,MAAAA;AAAtB,QAAqCJ,MAA3C;;AAEA,UAAMK,QAAQ,GAAG,MAAM;AACrBL,MAAAA,MAAM,CAACC,SAAP,GAAmB,EAAnB;AACAD,MAAAA,MAAM,CAACM,aAAP,GAAuB,EAAvB;AACD,KAHD;;AAIA,UAAMC,UAAU,GAAIC,UAAD,IAAgB;AAAA;;AACjC,UAAIP,SAAS,IAAIA,SAAS,KAAK,KAA3B,KACFL,KAAK,IAAI,oBAACJ,MAAM,CAACG,MAAR,2CAAC,eAAec,QAAf,CAAwBD,UAAxB,CAAD,CAAT,qB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AE;AADD,eADF;AAILA,cAAAA,IAAI,EAAE;AAJD;AAbG,WADR;AAqBJA,UAAAA,IAAI,EAAE;AArBF;AADI,OAFd;AA2BEA,MAAAA,IAAI,EAAE;AA3BR,KALM,CAFJ;AAqCJA,IAAAA,IAAI,EAAE;AArCF;AAFL,CAzGY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n indent,\n}) => {\n const [defaultRequireValue = 'always', {\n tags: tagMap = {},\n } = {}] = context.options;\n\n const {source} = jsdoc;\n\n const always = defaultRequireValue === 'always';\n const never = defaultRequireValue === 'never';\n\n let currentTag;\n source.some(({number, tokens}) => {\n const {delimiter, tag, end, description} = tokens;\n\n const neverFix = () => {\n tokens.delimiter = '';\n tokens.postDelimiter = '';\n };\n const checkNever = (checkValue) => {\n if (delimiter && delimiter !== '/**' && (\n never && !tagMap.always?.includes(checkValue) ||\n tagMap.never?.includes(checkValue)\n )) {\n utils.reportJSDoc('Expected JSDoc line to have no prefix.', {\n column: 0,\n line: number,\n }, neverFix);\n\n return true;\n }\n\n return false;\n };\n\n const alwaysFix = () => {\n if (!tokens.start) {\n tokens.start = indent + ' ';\n }\n tokens.delimiter = '*';\n tokens.postDelimiter = tag || description ? ' ' : '';\n };\n const checkAlways = (checkValue) => {\n if (\n !delimiter && (\n always && !tagMap.never?.includes(checkValue) ||\n tagMap.always?.includes(checkValue)\n )\n ) {\n utils.reportJSDoc('Expected JSDoc line to have the prefix.', {\n column: 0,\n line: number,\n }, alwaysFix);\n\n return true;\n }\n\n return false;\n };\n\n if (tag) {\n // Remove at sign\n currentTag = tag.slice(1);\n }\n\n if (\n // If this is the end but has a tag, the delimiter will also be\n // populated and will be safely ignored later\n end && !tag\n ) {\n return false;\n }\n\n if (!currentTag) {\n if (tagMap.any?.includes('*description')) {\n return false;\n }\n if (checkNever('*description')) {\n return true;\n }\n if (checkAlways('*description')) {\n return true;\n }\n\n return false;\n }\n\n if (tagMap.any?.includes(currentTag)) {\n return false;\n }\n\n if (checkNever(currentTag)) {\n return true;\n }\n\n if (checkAlways(currentTag)) {\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n fixable: 'code',\n schema: [\n {\n enum: ['always', 'never', 'any'],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n tags: {\n properties: {\n always: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n any: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n never: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"file":"requireAsteriskPrefix.js"}
|