{"version":3,"sources":["../../src/rules/requireFileOverview.js"],"names":["defaultTags","file","initialCommentsOnly","mustExist","preventDuplicates","setDefaults","state","globalTags","hasDuplicates","hasTag","hasNonCommentBeforeTag","jsdocNode","utils","context","tags","options","tagName","Object","keys","targetTagName","getPreferredTagName","hasDuplicate","hasNonComment","range","exit","entries","obj","getPreferredTagNameObject","blocked","reportSettings","replacement","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","patternProperties","type","nonComment","node"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,WAAW,GAAG;AAClBC,EAAAA,IAAI,EAAE;AACJC,IAAAA,mBAAmB,EAAE,IADjB;AAEJC,IAAAA,SAAS,EAAE,IAFP;AAGJC,IAAAA,iBAAiB,EAAE;AAHf;AADY,CAApB;;AAQA,MAAMC,WAAW,GAAIC,KAAD,IAAW;AAC7B;AACA,MAAI,CAACA,KAAK,CAACC,UAAX,EAAuB;AACrBD,IAAAA,KAAK,CAACC,UAAN,GAAmB,EAAnB;AACAD,IAAAA,KAAK,CAACE,aAAN,GAAsB,EAAtB;AACAF,IAAAA,KAAK,CAACG,MAAN,GAAe,EAAf;AACAH,IAAAA,KAAK,CAACI,sBAAN,GAA+B,EAA/B;AACD;AACF,CARD;;eAUe,2BAAa,CAAC;AAC3BC,EAAAA,SAD2B;AAE3BL,EAAAA,KAF2B;AAG3BM,EAAAA,KAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,QAAM;AACJC,IAAAA,IAAI,GAAGd;AADH,MAEFa,OAAO,CAACE,OAAR,CAAgB,CAAhB,KAAsB,EAF1B;AAIAV,EAAAA,WAAW,CAACC,KAAD,CAAX;;AAEA,OAAK,MAAMU,OAAX,IAAsBC,MAAM,CAACC,IAAP,CAAYJ,IAAZ,CAAtB,EAAyC;AACvC,UAAMK,aAAa,GAAGP,KAAK,CAACQ,mBAAN,CAA0B;AAACJ,MAAAA;AAAD,KAA1B,CAAtB;AAEA,UAAMP,MAAM,GAAGU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A,IAAI,EAAE;AAbF;AADW,WADf;AAkBJA,UAAAA,IAAI,EAAE;AAlBF;AADI,OAFd;AAwBEA,MAAAA,IAAI,EAAE;AAxBR,KADM,CALJ;AAiCJA,IAAAA,IAAI,EAAE;AAjCF,GAvCL;;AA0EDC,EAAAA,UAAU,CAAE;AAACnC,IAAAA,KAAD;AAAQoC,IAAAA;AAAR,GAAF,EAAiB;AACzB,QAAI,CAACpC,KAAK,CAACgB,aAAX,EAA0B;AACxBhB,MAAAA,KAAK,CAACgB,aAAN,GAAsBoB,IAAI,CAACnB,KAAL,CAAW,CAAX,CAAtB;AACD;AACF;;AA9EA,CAhCY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst defaultTags = {\n file: {\n initialCommentsOnly: true,\n mustExist: true,\n preventDuplicates: true,\n },\n};\n\nconst setDefaults = (state) => {\n // First iteration\n if (!state.globalTags) {\n state.globalTags = {};\n state.hasDuplicates = {};\n state.hasTag = {};\n state.hasNonCommentBeforeTag = {};\n }\n};\n\nexport default iterateJsdoc(({\n jsdocNode,\n state,\n utils,\n context,\n}) => {\n const {\n tags = defaultTags,\n } = context.options[0] || {};\n\n setDefaults(state);\n\n for (const tagName of Object.keys(tags)) {\n const targetTagName = utils.getPreferredTagName({tagName});\n\n const hasTag = targetTagName && utils.hasTag(targetTagName);\n\n state.hasTag[tagName] = hasTag || state.hasTag[tagName];\n\n const hasDuplicate = state.hasDuplicates[tagName];\n\n if (hasDuplicate === false) {\n // Was marked before, so if a tag now, is a dupe\n state.hasDuplicates[tagName] = hasTag;\n } else if (!hasDuplicate && hasTag) {\n // No dupes set before, but has first tag, so change state\n // from `undefined` to `false` so can detect next time\n state.hasDuplicates[tagName] = false;\n state.hasNonCommentBeforeTag[tagName] = state.hasNonComment &&\n state.hasNonComment < jsdocNode.range[0];\n }\n }\n}, {\n exit ({context, state, utils}) {\n setDefaults(state);\n const {\n tags = defaultTags,\n } = context.options[0] || {};\n\n for (const [tagName, {\n mustExist = false,\n preventDuplicates = false,\n initialCommentsOnly = false,\n }] of Object.entries(tags)) {\n const obj = utils.getPreferredTagNameObject({tagName});\n if (obj && obj.blocked) {\n utils.reportSettings(\n `\\`settings.jsdoc.tagNamePreference\\` cannot block @${obj.tagName} ` +\n 'for the `require-file-overview` rule',\n );\n } else {\n const targetTagName = obj && obj.replacement || obj;\n if (mustExist && !state.hasTag[tagName]) {\n utils.reportSettings(`Missing @${targetTagName}`);\n }\n if (preventDuplicates && state.hasDuplicates[tagName]) {\n utils.reportSettings(\n `Duplicate @${targetTagName}`,\n );\n }\n if (initialCommentsOnly &&\n state.hasNonCommentBeforeTag[tagName]\n ) {\n utils.reportSettings(\n `@${targetTagName} should be at the beginning of the file`,\n );\n }\n }\n }\n },\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-file-overview',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n patternProperties: {\n '.*': {\n additionalProperties: false,\n properties: {\n initialCommentsOnly: {\n type: 'boolean',\n },\n mustExist: {\n type: 'boolean',\n },\n preventDuplicates: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n nonComment ({state, node}) {\n if (!state.hasNonComment) {\n state.hasNonComment = node.range[0];\n }\n },\n});\n"],"file":"requireFileOverview.js"}