eslint-plugin-jsdoc 50.4.0 → 50.4.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/dist/rules/matchName.cjs
CHANGED
|
@@ -37,8 +37,9 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
37
37
|
}
|
|
38
38
|
let reported = false;
|
|
39
39
|
for (const tag of applicableTags) {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
40
|
+
const tagName = tag.name.replace(/^\[/u, '').replace(/(=.*)?\]$/u, '');
|
|
41
|
+
const allowed = !allowNameRegex || allowNameRegex.test(tagName);
|
|
42
|
+
const disallowed = disallowNameRegex && disallowNameRegex.test(tagName);
|
|
42
43
|
const hasRegex = allowNameRegex || disallowNameRegex;
|
|
43
44
|
if (hasRegex && allowed && !disallowed) {
|
|
44
45
|
continue;
|
|
@@ -59,9 +60,9 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
59
60
|
} = match[( /** @type {import('../iterateJsdoc.js').Integer} */lastIndex)];
|
|
60
61
|
if (!message) {
|
|
61
62
|
if (hasRegex) {
|
|
62
|
-
message = disallowed ? `Only allowing names not matching \`${disallowNameRegex}\` but found "${
|
|
63
|
+
message = disallowed ? `Only allowing names not matching \`${disallowNameRegex}\` but found "${tagName}".` : `Only allowing names matching \`${allowNameRegex}\` but found "${tagName}".`;
|
|
63
64
|
} else {
|
|
64
|
-
message = `Prohibited context for "${
|
|
65
|
+
message = `Prohibited context for "${tagName}".`;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
utils.reportJSDoc(message, hasRegex ? tag : null,
|
|
@@ -70,7 +71,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
70
71
|
// Could also supply `context`, `comment`, `tags`
|
|
71
72
|
allowName,
|
|
72
73
|
disallowName,
|
|
73
|
-
name:
|
|
74
|
+
name: tagName
|
|
74
75
|
});
|
|
75
76
|
if (!hasRegex) {
|
|
76
77
|
reported = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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","
|
|
1
|
+
{"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","tagName","name","replace","allowed","test","disallowed","hasRegex","fixer","src","source","tokens","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 tagName = tag.name.replace(/^\\[/u, '').replace(/(=.*)?\\]$/u, '');\n const allowed = !allowNameRegex || allowNameRegex.test(tagName);\n const disallowed = disallowNameRegex && disallowNameRegex.test(tagName);\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 \"${tagName}\".` :\n `Only allowing names matching \\`${allowNameRegex}\\` but found \"${tagName}\".`;\n } else {\n message = `Prohibited context for \"${tagName}\".`;\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: tagName,\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,GAAAC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E;QACVpC,KAAK,EAAE;UACLmC,oBAAoB,EAAE,KAAK;UAC3BE,KAAK,EAAE;YACLD,UAAU,EAAE;cACVlC,SAAS,EAAE;gBACToC,IAAI,EAAE;cACR,CAAC;cACDC,OAAO,EAAE;gBACPD,IAAI,EAAE;cACR,CAAC;cACD5C,OAAO,EAAE;gBACP4C,IAAI,EAAE;cACR,CAAC;cACDnC,YAAY,EAAE;gBACZmC,IAAI,EAAE;cACR,CAAC;cACDb,OAAO,EAAE;gBACPa,IAAI,EAAE;cACR,CAAC;cACDjC,IAAI,EAAE;gBACJgC,KAAK,EAAE;kBACLC,IAAI,EAAE;gBACR,CAAC;gBACDA,IAAI,EAAE;cACR;YACF,CAAC;YACDA,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDE,QAAQ,EAAE,CACR,OAAO,CACR;MACDF,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAG,MAAA,CAAAjD,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
package/src/rules/matchName.js
CHANGED
|
@@ -38,8 +38,9 @@ export default iterateJsdoc(({
|
|
|
38
38
|
|
|
39
39
|
let reported = false;
|
|
40
40
|
for (const tag of applicableTags) {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
41
|
+
const tagName = tag.name.replace(/^\[/u, '').replace(/(=.*)?\]$/u, '');
|
|
42
|
+
const allowed = !allowNameRegex || allowNameRegex.test(tagName);
|
|
43
|
+
const disallowed = disallowNameRegex && disallowNameRegex.test(tagName);
|
|
43
44
|
const hasRegex = allowNameRegex || disallowNameRegex;
|
|
44
45
|
if (hasRegex && allowed && !disallowed) {
|
|
45
46
|
continue;
|
|
@@ -66,10 +67,10 @@ export default iterateJsdoc(({
|
|
|
66
67
|
if (!message) {
|
|
67
68
|
if (hasRegex) {
|
|
68
69
|
message = disallowed ?
|
|
69
|
-
`Only allowing names not matching \`${disallowNameRegex}\` but found "${
|
|
70
|
-
`Only allowing names matching \`${allowNameRegex}\` but found "${
|
|
70
|
+
`Only allowing names not matching \`${disallowNameRegex}\` but found "${tagName}".` :
|
|
71
|
+
`Only allowing names matching \`${allowNameRegex}\` but found "${tagName}".`;
|
|
71
72
|
} else {
|
|
72
|
-
message = `Prohibited context for "${
|
|
73
|
+
message = `Prohibited context for "${tagName}".`;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -86,7 +87,7 @@ export default iterateJsdoc(({
|
|
|
86
87
|
// Could also supply `context`, `comment`, `tags`
|
|
87
88
|
allowName,
|
|
88
89
|
disallowName,
|
|
89
|
-
name:
|
|
90
|
+
name: tagName,
|
|
90
91
|
},
|
|
91
92
|
);
|
|
92
93
|
if (!hasRegex) {
|