eslint-plugin-jsdoc 38.0.0 → 38.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7161,6 +7161,16 @@ function quux () {
7161
7161
  }
7162
7162
  // "jsdoc/match-description": ["error"|"warn", {"matchDescription":"[\\s\\S]*\\S$"}]
7163
7163
  // Message: JSDoc description does not satisfy the regex pattern.
7164
+
7165
+ /**
7166
+ *
7167
+ * This function does lots of things.
7168
+ */
7169
+ function quux () {
7170
+
7171
+ }
7172
+ // "jsdoc/match-description": ["error"|"warn", {"matchDescription":"^\\S[\\s\\S]*\\S$"}]
7173
+ // Message: JSDoc description does not satisfy the regex pattern.
7164
7174
  ````
7165
7175
 
7166
7176
  The following patterns are not considered problems:
@@ -7675,6 +7685,14 @@ function quux () {
7675
7685
  function quux () {}
7676
7686
  // "jsdoc/match-name": ["error"|"warn", ]
7677
7687
  // Message: Rule `no-restricted-syntax` is missing a `match` option.
7688
+
7689
+ /**
7690
+ * @param {
7691
+ * someType
7692
+ * } opt_a
7693
+ */
7694
+ // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","replacement":""}]}]
7695
+ // Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
7678
7696
  ````
7679
7697
 
7680
7698
  The following patterns are not considered problems:
@@ -58,7 +58,12 @@ var _default = (0, _iterateJsdoc.default)(({
58
58
  }
59
59
 
60
60
  const fixer = () => {
61
- tag.source[0].tokens.name = tag.source[0].tokens.name.replace(disallowNameRegex, replacement);
61
+ for (const src of tag.source) {
62
+ if (src.tokens.name) {
63
+ src.tokens.name = src.tokens.name.replace(disallowNameRegex, replacement);
64
+ break;
65
+ }
66
+ }
62
67
  };
63
68
 
64
69
  let {
@@ -1 +1 @@
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","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;;;;AAEA;eACe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA,IAAI,EAAE;AACJC,IAAAA;AADI,GAJqB;AAO3BC,EAAAA;AAP2B,CAAD,KAQtB;AACJ,QAAM;AACJC,IAAAA;AADI,MAEFN,OAAO,CAACO,OAAR,CAAgB,CAAhB,KAAsB,EAF1B;;AAGA,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,CACL,GADK;AAJH,MAOFL,KAAK,CAACF,SAAD,CAPT;AASA,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;;AACA,OAAK,MAAMC,GAAX,IAAkBJ,cAAlB,EAAkC;AAChC,UAAMK,OAAO,GAAG,CAACR,cAAD,IAAmBA,cAAc,CAACS,IAAf,CAAoBF,GAAG,CAACG,IAAxB,CAAnC;AACA,UAAMC,UAAU,GAAGT,iBAAiB,IAAIA,iBAAi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;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,iGADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,OAAO,EAAE,MALL;AAMJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,mBAAmB,EAAE,KADvB;AAEEC,MAAAA,UAAU,EAAE;AACVlC,QAAAA,KAAK,EAAE;AACLiC,UAAAA,mBAAmB,EAAE,KADhB;AAELE,UAAAA,KAAK,EAAE;AACLD,YAAAA,UAAU,EAAE;AACVhC,cAAAA,SAAS,EAAE;AACTkC,gBAAAA,IAAI,EAAE;AADG,eADD;AAIVC,cAAAA,OAAO,EAAE;AACPD,gBAAAA,IAAI,EAAE;AADC,eAJC;AAOV1C,cAAAA,OAAO,EAAE;AACP0C,gBAAAA,IAAI,EAAE;AADC,eAPC;AAUVjC,cAAAA,YAAY,EAAE;AACZiC,gBAAAA,IAAI,EAAE;AADM,eAVJ;AAaVb,cAAAA,OAAO,EAAE;AACPa,gBAAAA,IAAI,EAAE;AADC,eAbC;AAgBV/B,cAAAA,IAAI,EAAE;AACJ8B,gBAAAA,KAAK,EAAE;AACLC,kBAAAA,IAAI,EAAE;AADD,iBADH;AAIJA,gBAAAA,IAAI,EAAE;AAJF;AAhBI,aADP;AAwBLA,YAAAA,IAAI,EAAE;AAxBD,WAFF;AA4BLA,UAAAA,IAAI,EAAE;AA5BD;AADG,OAFd;AAkCEE,MAAAA,QAAQ,EAAE,CACR,OADQ,CAlCZ;AAqCEF,MAAAA,IAAI,EAAE;AArCR,KADM,CANJ;AA+CJA,IAAAA,IAAI,EAAE;AA/CF;AAFL,CAvFY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n// eslint-disable-next-line complexity\nexport default iterateJsdoc(({\n context,\n jsdoc,\n report,\n info: {\n lastIndex,\n },\n utils,\n}) => {\n const {\n match,\n } = 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 '*',\n ],\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 for (const tag of applicableTags) {\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 continue;\n }\n\n if (!hasRegex && reported) {\n continue;\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 {\n message,\n } = 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: [\n 'match',\n ],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"matchName.js"}
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","tag","allowed","test","name","disallowed","hasRegex","fixer","src","source","tokens","replace","message","reportJSDoc","undefined","matchContext","meta","docs","description","url","fixable","schema","additionalProperies","properties","items","type","comment","required"],"mappings":";;;;;;;AAAA;;;;AAEA;eACe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA,IAAI,EAAE;AACJC,IAAAA;AADI,GAJqB;AAO3BC,EAAAA;AAP2B,CAAD,KAQtB;AACJ,QAAM;AACJC,IAAAA;AADI,MAEFN,OAAO,CAACO,OAAR,CAAgB,CAAhB,KAAsB,EAF1B;;AAGA,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,CACL,GADK;AAJH,MAOFL,KAAK,CAACF,SAAD,CAPT;AASA,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,cAA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G,OAFd;AAkCEE,MAAAA,QAAQ,EAAE,CACR,OADQ,CAlCZ;AAqCEF,MAAAA,IAAI,EAAE;AArCR,KADM,CANJ;AA+CJA,IAAAA,IAAI,EAAE;AA/CF;AAFL,CA5FY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n// eslint-disable-next-line complexity\nexport default iterateJsdoc(({\n context,\n jsdoc,\n report,\n info: {\n lastIndex,\n },\n utils,\n}) => {\n const {\n match,\n } = 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 '*',\n ],\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 for (const tag of applicableTags) {\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 continue;\n }\n\n if (!hasRegex && reported) {\n continue;\n }\n\n const fixer = () => {\n for (const src of tag.source) {\n if (src.tokens.name) {\n src.tokens.name = src.tokens.name.replace(\n disallowNameRegex, replacement,\n );\n break;\n }\n }\n };\n\n let {\n message,\n } = 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: [\n 'match',\n ],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"matchName.js"}
package/package.json CHANGED
@@ -116,5 +116,5 @@
116
116
  "test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
117
117
  "test-index": "npm run test-no-cov -- test/rules/index.js"
118
118
  },
119
- "version": "38.0.0"
119
+ "version": "38.0.1"
120
120
  }