1 line
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			1 line
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| {"version":3,"file":"matchName.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","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","additionalProperties","properties","items","type","comment","required","module"],"sources":["../../src/rules/matchName.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\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[/** @type {import('../iterateJsdoc.js').Integer} */ (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[/** @type {import('../iterateJsdoc.js').Integer} */ (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/blob/main/docs/rules/match-name.md#repos-sticky-header',\n    },\n    fixable: 'code',\n    schema: [\n      {\n        additionalProperties: false,\n        properties: {\n          match: {\n            additionalProperties: 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"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AAAA,IAAAG,QAAA,GA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