|
1 |
- {"version":3,"sources":["../../src/rules/matchName.js"],"names":["context","jsdoc","report","info","lastIndex","utils","match","options","allowName","disallowName","replacement","tags","allowNameRegex","getRegexFromString","disallowNameRegex","applicableTags","includes","getPresentTags","reported","forEach","tag","allowed","test","name","disallowed","hasRegex","fixer","source","tokens","replace","message","reportJSDoc","undefined","matchContext","meta","docs","description","url","fixable","schema","additionalProperies","properties","items","type","comment","required"],"mappings":";;;;;;;AAAA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA,IAAI,EAAE;AAACC,IAAAA;AAAD,GAJqB;AAK3BC,EAAAA;AAL2B,CAAD,KAMtB;AACJ,QAAM;AAACC,IAAAA;AAAD,MAAUN,OAAO,CAACO,OAAR,CAAgB,CAAhB,KAAsB,EAAtC;;AACA,MAAI,CAACD,KAAL,EAAY;AACVJ,IAAAA,MAAM,CAAC,0DAAD,CAAN;AAEA;AACD;;AAED,QAAM;AACJM,IAAAA,SADI;AAEJC,IAAAA,YAFI;AAGJC,IAAAA,WAHI;AAIJC,IAAAA,IAAI,GAAG,CAAC,GAAD;AAJH,MAKFL,KAAK,CAACF,SAAD,CALT;AAOA,QAAMQ,cAAc,GAAGJ,SAAS,IAAIH,KAAK,CAACQ,kBAAN,CAAyBL,SAAzB,CAApC;AACA,QAAMM,iBAAiB,GAAGL,YAAY,IAAIJ,KAAK,CAACQ,kBAAN,CAAyBJ,YAAzB,CAA1C;AAEA,MAAIM,cAAc,GAAGd,KAAK,CAACU,IAA3B;;AACA,MAAI,CAACA,IAAI,CAACK,QAAL,CAAc,GAAd,CAAL,EAAyB;AACvBD,IAAAA,cAAc,GAAGV,KAAK,CAACY,cAAN,CAAqBN,IAArB,CAAjB;AACD;;AAED,MAAIO,QAAQ,GAAG,KAAf;AACAH,EAAAA,cAAc,CAACI,OAAf,CAAwBC,GAAD,IAAS;AAC9B,UAAMC,OAAO,GAA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export default iterateJsdoc(({\n context,\n jsdoc,\n report,\n info: {lastIndex},\n utils,\n}) => {\n const {match} = context.options[0] || {};\n if (!match) {\n report('Rule `no-restricted-syntax` is missing a `match` option.');\n\n return;\n }\n\n const {\n allowName,\n disallowName,\n replacement,\n tags = ['*'],\n } = match[lastIndex];\n\n const allowNameRegex = allowName && utils.getRegexFromString(allowName);\n const disallowNameRegex = disallowName && utils.getRegexFromString(disallowName);\n\n let applicableTags = jsdoc.tags;\n if (!tags.includes('*')) {\n applicableTags = utils.getPresentTags(tags);\n }\n\n let reported = false;\n applicableTags.forEach((tag) => {\n const allowed = !allowNameRegex || allowNameRegex.test(tag.name);\n const disallowed = disallowNameRegex && disallowNameRegex.test(tag.name);\n const hasRegex = allowNameRegex || disallowNameRegex;\n if (hasRegex && allowed && !disallowed) {\n return;\n }\n if (!hasRegex && reported) {\n return;\n }\n\n const fixer = () => {\n tag.source[0].tokens.name = tag.source[0].tokens.name.replace(\n disallowNameRegex, replacement,\n );\n };\n\n let {message} = match[lastIndex];\n if (!message) {\n if (hasRegex) {\n message = disallowed ?\n `Only allowing names not matching \\`${disallowNameRegex}\\` but found \"${tag.name}\".` :\n `Only allowing names matching \\`${allowNameRegex}\\` but found \"${tag.name}\".`;\n } else {\n message = `Prohibited context for \"${tag.name}\".`;\n }\n }\n\n utils.reportJSDoc(\n message,\n hasRegex ? tag : null,\n\n // We could match up\n disallowNameRegex && replacement !== undefined ?\n fixer :\n null,\n false,\n {\n // Could also supply `context`, `comment`, `tags`\n allowName,\n disallowName,\n name: tag.name,\n },\n );\n if (!hasRegex) {\n reported = true;\n }\n });\n}, {\n matchContext: true,\n meta: {\n docs: {\n description: 'Reports the name portion of a JSDoc tag if matching or not matching a given regular expression.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-name',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperies: false,\n properties: {\n match: {\n additionalProperies: false,\n items: {\n properties: {\n allowName: {\n type: 'string',\n },\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n disallowName: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n type: 'array',\n },\n },\n required: ['match'],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"matchName.js"}
|