{"version":3,"sources":["../../src/rules/checkValues.js"],"names":["utils","report","context","options","allowedLicenses","allowedAuthors","numericOnlyVariation","licensePattern","forEachPreferredTag","jsdocParameter","targetTagName","version","getTagDescription","trim","semver","valid","variation","Number","isInteger","licenseRegex","getRegexFromString","match","license","includes","join","author","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","items","type","anyOf"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,KAD2B;AAE3BC,EAAAA,MAF2B;AAG3BC,EAAAA;AAH2B,CAAD,KAItB;AACJ,QAAMC,OAAO,GAAGD,OAAO,CAACC,OAAR,CAAgB,CAAhB,KAAsB,EAAtC;AACA,QAAM;AACJC,IAAAA,eAAe,GAAG,IADd;AAEJC,IAAAA,cAAc,GAAG,IAFb;AAGJC,IAAAA,oBAAoB,GAAG,KAHnB;AAIJC,IAAAA,cAAc,GAAG;AAJb,MAKFJ,OALJ;AAOAH,EAAAA,KAAK,CAACQ,mBAAN,CAA0B,SAA1B,EAAqC,CAACC,cAAD,EAAiBC,aAAjB,KAAmC;AACtE,UAAMC,OAAO,GAAGX,KAAK,CAACY,iBAAN,CAAwBH,cAAxB,EAAwCI,IAAxC,EAAhB;;AACA,QAAI,CAACF,OAAL,EAAc;AACZV,MAAAA,MAAM,CACH,kBAAiBS,aAAc,SAD5B,EAEJ,IAFI,EAGJD,cAHI,CAAN;AAKD,KAND,MAMO,IAAI,CAACK,gBAAOC,KAAP,CAAaJ,OAAb,CAAL,EAA4B;AACjCV,MAAAA,MAAM,CACH,kBAAiBS,aAAc,MAAKV,KAAK,CAACY,iBAAN,CAAwBH,cAAxB,CAAwC,IADzE,EAEJ,IAFI,EAGJA,cAHI,CAAN;AAKD;AACF,GAfD;;AAgBA,MAAIH,oBAAJ,EAA0B;AACxBN,IAAAA,KAAK,CAACQ,mBAAN,CAA0B,WAA1B,EAAuC,CAACC,cAAD,EAAiBC,aAAjB,KAAmC;AACxE,YA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B,IAApB,CAA0B,GADxH,EAEJ,IAFI,EAGJf,cAHI,CAAN;AAKD;AACF,GAfD;AAgBD,CAjHc,EAiHZ;AACDiB,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,oGADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACV5B,QAAAA,cAAc,EAAE;AACd6B,UAAAA,KAAK,EAAE;AACLC,YAAAA,IAAI,EAAE;AADD,WADO;AAIdA,UAAAA,IAAI,EAAE;AAJQ,SADN;AAOV/B,QAAAA,eAAe,EAAE;AACfgC,UAAAA,KAAK,EAAE,CACL;AACEF,YAAAA,KAAK,EAAE;AACLC,cAAAA,IAAI,EAAE;AADD,aADT;AAIEA,YAAAA,IAAI,EAAE;AAJR,WADK,EAOL;AACEA,YAAAA,IAAI,EAAE;AADR,WAPK;AADQ,SAPP;AAoBV5B,QAAAA,cAAc,EAAE;AACd4B,UAAAA,IAAI,EAAE;AADQ,SApBN;AAuBV7B,QAAAA,oBAAoB,EAAE;AACpB6B,UAAAA,IAAI,EAAE;AADc;AAvBZ,OAFd;AA6BEA,MAAAA,IAAI,EAAE;AA7BR,KADM,CALJ;AAsCJA,IAAAA,IAAI,EAAE;AAtCF;AAFL,CAjHY,C","sourcesContent":["import semver from 'semver';\nimport spdxExpressionParse from 'spdx-expression-parse';\nimport iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n utils,\n report,\n context,\n}) => {\n const options = context.options[0] || {};\n const {\n allowedLicenses = null,\n allowedAuthors = null,\n numericOnlyVariation = false,\n licensePattern = '/([^\\n\\r]*)/gu',\n } = options;\n\n utils.forEachPreferredTag('version', (jsdocParameter, targetTagName) => {\n const version = utils.getTagDescription(jsdocParameter).trim();\n if (!version) {\n report(\n `Missing JSDoc @${targetTagName} value.`,\n null,\n jsdocParameter,\n );\n } else if (!semver.valid(version)) {\n report(\n `Invalid JSDoc @${targetTagName}: \"${utils.getTagDescription(jsdocParameter)}\".`,\n null,\n jsdocParameter,\n );\n }\n });\n if (numericOnlyVariation) {\n utils.forEachPreferredTag('variation', (jsdocParameter, targetTagName) => {\n const variation = utils.getTagDescription(jsdocParameter).trim();\n if (!variation) {\n report(\n `Missing JSDoc @${targetTagName} value.`,\n null,\n jsdocParameter,\n );\n } else if (\n !Number.isInteger(Number(variation)) ||\n Number(variation) <= 0\n ) {\n report(\n `Invalid JSDoc @${targetTagName}: \"${utils.getTagDescription(jsdocParameter)}\".`,\n null,\n jsdocParameter,\n );\n }\n });\n }\n utils.forEachPreferredTag('since', (jsdocParameter, targetTagName) => {\n const version = utils.getTagDescription(jsdocParameter).trim();\n if (!version) {\n report(\n `Missing JSDoc @${targetTagName} value.`,\n null,\n jsdocParameter,\n );\n } else if (!semver.valid(version)) {\n report(\n `Invalid JSDoc @${targetTagName}: \"${utils.getTagDescription(jsdocParameter)}\".`,\n null,\n jsdocParameter,\n );\n }\n });\n utils.forEachPreferredTag('license', (jsdocParameter, targetTagName) => {\n const licenseRegex = utils.getRegexFromString(licensePattern, 'g');\n const match = utils.getTagDescription(jsdocParameter).match(licenseRegex);\n const license = match && match[1] || match[0];\n if (!license.trim()) {\n report(\n `Missing JSDoc @${targetTagName} value.`,\n null,\n jsdocParameter,\n );\n } else if (allowedLicenses) {\n if (allowedLicenses !== true && !allowedLicenses.includes(license)) {\n report(\n `Invalid JSDoc @${targetTagName}: \"${license}\"; expected one of ${allowedLicenses.join(', ')}.`,\n null,\n jsdocParameter,\n );\n }\n } else {\n try {\n spdxExpressionParse(license);\n } catch {\n report(\n `Invalid JSDoc @${targetTagName}: \"${license}\"; expected SPDX expression: https://spdx.org/licenses/.`,\n null,\n jsdocParameter,\n );\n }\n }\n });\n\n utils.forEachPreferredTag('author', (jsdocParameter, targetTagName) => {\n const author = utils.getTagDescription(jsdocParameter).trim();\n if (!author) {\n report(\n `Missing JSDoc @${targetTagName} value.`,\n null,\n jsdocParameter,\n );\n } else if (allowedAuthors && !allowedAuthors.includes(author)) {\n report(\n `Invalid JSDoc @${targetTagName}: \"${utils.getTagDescription(jsdocParameter)}\"; expected one of ${allowedAuthors.join(', ')}.`,\n null,\n jsdocParameter,\n );\n }\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'This rule checks the values for a handful of tags: `@version`, `@since`, `@license` and `@author`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-values',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowedAuthors: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n allowedLicenses: {\n anyOf: [\n {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n {\n type: 'boolean',\n },\n ],\n },\n licensePattern: {\n type: 'string',\n },\n numericOnlyVariation: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"checkValues.js"}