1 |
- {"version":3,"sources":["../../src/rules/checkPropertyNames.js"],"names":["validatePropertyNames","targetTagName","enableFixer","jsdoc","jsdocNode","utils","propertyTags","Object","entries","tags","filter","tag","some","index","tagsIndex","dupeTagInfo","find","tgsIndex","tg","idx","name","reportJSDoc","removeTag","validatePropertyNamesDeep","jsdocPropertyNames","report","lastRealProperty","jsdocPropertyName","isPropertyPath","includes","pathRootNodeName","slice","indexOf","endsWith","context","options","jsdocPropertyNamesDeep","getJsdocTagsDeep","length","getPreferredTagName","tagName","isError","iterateAllJsdocs","meta","docs","description","url","fixable","schema","additionalProperties","properties","type"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,qBAAqB,GAAG,CAC5BC,aAD4B,EAE5BC,WAF4B,EAG5BC,KAH4B,EAGrBC,SAHqB,EAGVC,KAHU,KAIzB;AACH,QAAMC,YAAY,GAAGC,MAAM,CAACC,OAAP,CAAeL,KAAK,CAACM,IAArB,EAA2BC,MAA3B,CAAkC,CAAC,GAAGC,GAAH,CAAD,KAAa;AAClE,WAAOA,GAAG,CAACA,GAAJ,KAAYV,aAAnB;AACD,GAFoB,CAArB;AAIA,SAAOK,YAAY,CAACM,IAAb,CAAkB,CAAC,GAAGD,GAAH,CAAD,EAAUE,KAAV,KAAoB;AAC3C,QAAIC,SAAJ;AACA,UAAMC,WAAW,GAAGT,YAAY,CAACU,IAAb,CAAkB,CAAC,CAACC,QAAD,EAAWC,EAAX,CAAD,EAAiBC,GAAjB,KAAyB;AAC7DL,MAAAA,SAAS,GAAGG,QAAZ;AAEA,aAAOC,EAAE,CAACE,IAAH,KAAYT,GAAG,CAACS,IAAhB,IAAwBD,GAAG,KAAKN,KAAvC;AACD,KAJmB,CAApB;;AAKA,QAAIE,WAAJ,EAAiB;AACfV,MAAAA,KAAK,CAACgB,WAAN,CAAmB,cAAapB,aAAc,KAAIU,GAAG,CAACS,IAAK,GAA3D,EAA+DL,WAAW,CAAC,CAAD,CAA1E,EAA+Eb,WAAW,GAAG,MAAM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ADM,CANJ;AAiBJA,IAAAA,IAAI,EAAE;AAjBF;AAFL,CA7BY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst validatePropertyNames = (\n targetTagName : string,\n enableFixer : boolean,\n jsdoc, jsdocNode, utils,\n) => {\n const propertyTags = Object.entries(jsdoc.tags).filter(([, tag]) => {\n return tag.tag === targetTagName;\n });\n\n return propertyTags.some(([, tag], index) => {\n let tagsIndex;\n const dupeTagInfo = propertyTags.find(([tgsIndex, tg], idx) => {\n tagsIndex = tgsIndex;\n\n return tg.name === tag.name && idx !== index;\n });\n if (dupeTagInfo) {\n utils.reportJSDoc(`Duplicate @${targetTagName} \"${tag.name}\"`, dupeTagInfo[1], enableFixer ? () => {\n utils.removeTag(tagsIndex);\n } : null);\n\n return true;\n }\n\n return false;\n });\n};\n\nconst validatePropertyNamesDeep = (\n targetTagName : string,\n jsdocPropertyNames : Array<string>, jsdoc, report : Function,\n) => {\n let lastRealProperty;\n\n return jsdocPropertyNames.some(({name: jsdocPropertyName, idx}) => {\n const isPropertyPath = jsdocPropertyName.includes('.');\n\n if (isPropertyPath) {\n if (!lastRealProperty) {\n report(`@${targetTagName} path declaration (\"${jsdocPropertyName}\") appears before any real property.`, null, jsdoc.tags[idx]);\n\n return true;\n }\n\n let pathRootNodeName = jsdocPropertyName.slice(0, jsdocPropertyName.indexOf('.'));\n\n if (pathRootNodeName.endsWith('[]')) {\n pathRootNodeName = pathRootNodeName.slice(0, -2);\n }\n\n if (pathRootNodeName !== lastRealProperty) {\n report(\n `@${targetTagName} path declaration (\"${jsdocPropertyName}\") root node name (\"${pathRootNodeName}\") ` +\n `does not match previous real property name (\"${lastRealProperty}\").`,\n null,\n jsdoc.tags[idx],\n );\n\n return true;\n }\n } else {\n lastRealProperty = jsdocPropertyName;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n jsdocNode,\n report,\n utils,\n}) => {\n const {\n enableFixer = false,\n } = context.options[0] || {};\n const jsdocPropertyNamesDeep = utils.getJsdocTagsDeep('property');\n if (!jsdocPropertyNamesDeep.length) {\n return;\n }\n const targetTagName = utils.getPreferredTagName({tagName: 'property'});\n const isError = validatePropertyNames(\n targetTagName,\n enableFixer,\n jsdoc, jsdocNode, utils,\n );\n\n if (isError) {\n return;\n }\n\n validatePropertyNamesDeep(\n targetTagName, jsdocPropertyNamesDeep,\n jsdoc, report,\n );\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Ensures that property names in JSDoc are not duplicated on the same block and that nested properties have defined roots.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-property-names',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n enableFixer: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"checkPropertyNames.js"}
|