eslint-plugin-jsdoc 48.8.0 → 48.8.2
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 +3 -0
- package/dist/defaultTagOrder.cjs +1 -1
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +7 -1
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +7 -1
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/package.json +1 -1
- package/src/defaultTagOrder.js +1 -1
- package/src/rules/checkTemplateNames.js +10 -3
- package/src/rules/requireTemplate.js +10 -3
package/README.md
CHANGED
|
@@ -93,6 +93,7 @@ Finally, enable all of the rules that you would like to use.
|
|
|
93
93
|
"jsdoc/check-indentation": 1,
|
|
94
94
|
"jsdoc/check-line-alignment": 1,
|
|
95
95
|
"jsdoc/check-param-names": 1, // Recommended
|
|
96
|
+
"jsdoc/check-template-names": 1,
|
|
96
97
|
"jsdoc/check-property-names": 1, // Recommended
|
|
97
98
|
"jsdoc/check-syntax": 1,
|
|
98
99
|
"jsdoc/check-tag-names": 1, // Recommended
|
|
@@ -130,6 +131,7 @@ Finally, enable all of the rules that you would like to use.
|
|
|
130
131
|
"jsdoc/require-returns-check": 1, // Recommended
|
|
131
132
|
"jsdoc/require-returns-description": 1, // Recommended
|
|
132
133
|
"jsdoc/require-returns-type": 1, // Recommended
|
|
134
|
+
"jsdoc/require-template": 1,
|
|
133
135
|
"jsdoc/require-throws": 1,
|
|
134
136
|
"jsdoc/require-yields": 1, // Recommended
|
|
135
137
|
"jsdoc/require-yields-check": 1, // Recommended
|
|
@@ -261,6 +263,7 @@ non-default-recommended fixer).
|
|
|
261
263
|
|:heavy_check_mark:|:wrench:|[check-property-names](./docs/rules/check-property-names.md#readme)|Checks for dupe `@property` names, that nested property names have roots|
|
|
262
264
|
|||[check-syntax](./docs/rules/check-syntax.md#readme)|Reports use against current mode (currently only prohibits Closure-specific syntax)|
|
|
263
265
|
|:heavy_check_mark:|:wrench:|[check-tag-names](./docs/rules/check-tag-names.md#readme)|Reports invalid jsdoc (block) tag names|
|
|
266
|
+
| || [check-template-names](./docs/rules/check-template-names.md#readme)|Checks that any `@template` names are actually used in the connected `@typedef` or type alias.
|
|
264
267
|
|:heavy_check_mark:|:wrench:|[check-types](./docs/rules/check-types.md#readme)|Reports types deemed invalid (customizable and with defaults, for preventing and/or recommending replacements)|
|
|
265
268
|
|:heavy_check_mark:||[check-values](./docs/rules/check-values.md#readme)|Checks for expected content within some miscellaneous tags (`@version`, `@since`, `@license`, `@author`)|
|
|
266
269
|
| || [convert-to-jsdoc-comments](./docs/rules/convert-to-jsdoc-comments.md#readme) | Converts line and block comments preceding or following specified nodes into JSDoc comments|
|
package/dist/defaultTagOrder.cjs
CHANGED
|
@@ -11,7 +11,7 @@ const defaultTagOrder = [{
|
|
|
11
11
|
// Module/file-level
|
|
12
12
|
'module', 'exports', 'file', 'fileoverview', 'overview', 'import',
|
|
13
13
|
// Identifying (name, type)
|
|
14
|
-
'
|
|
14
|
+
'template', 'typedef', 'interface', 'record', 'name', 'kind', 'type', 'alias', 'external', 'host', 'callback', 'func', 'function', 'method', 'class', 'constructor',
|
|
15
15
|
// Relationships
|
|
16
16
|
'modifies', 'mixes', 'mixin', 'mixinClass', 'mixinFunction', 'namespace', 'borrows', 'constructs', 'lends', 'implements', 'requires',
|
|
17
17
|
// Long descriptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTagOrder.cjs","names":["defaultTagOrder","tags","_default","exports","default","module"],"sources":["../src/defaultTagOrder.js"],"sourcesContent":["const defaultTagOrder = [\n {\n tags: [\n // Brief descriptions\n 'summary',\n 'typeSummary',\n\n // Module/file-level\n 'module',\n 'exports',\n 'file',\n 'fileoverview',\n 'overview',\n 'import',\n\n // Identifying (name, type)\n '
|
|
1
|
+
{"version":3,"file":"defaultTagOrder.cjs","names":["defaultTagOrder","tags","_default","exports","default","module"],"sources":["../src/defaultTagOrder.js"],"sourcesContent":["const defaultTagOrder = [\n {\n tags: [\n // Brief descriptions\n 'summary',\n 'typeSummary',\n\n // Module/file-level\n 'module',\n 'exports',\n 'file',\n 'fileoverview',\n 'overview',\n 'import',\n\n // Identifying (name, type)\n 'template',\n 'typedef',\n 'interface',\n 'record',\n 'name',\n 'kind',\n 'type',\n 'alias',\n 'external',\n 'host',\n 'callback',\n 'func',\n 'function',\n 'method',\n 'class',\n 'constructor',\n\n // Relationships\n 'modifies',\n 'mixes',\n 'mixin',\n 'mixinClass',\n 'mixinFunction',\n 'namespace',\n 'borrows',\n 'constructs',\n 'lends',\n 'implements',\n 'requires',\n\n // Long descriptions\n 'desc',\n 'description',\n 'classdesc',\n 'tutorial',\n 'copyright',\n 'license',\n\n // Simple annotations\n\n // TypeScript\n 'internal',\n 'overload',\n\n 'const',\n 'constant',\n 'final',\n 'global',\n 'readonly',\n 'abstract',\n 'virtual',\n 'var',\n 'member',\n 'memberof',\n 'memberof!',\n 'inner',\n 'instance',\n 'inheritdoc',\n 'inheritDoc',\n 'override',\n 'hideconstructor',\n\n // Core function/object info\n 'param',\n 'arg',\n 'argument',\n 'prop',\n 'property',\n 'return',\n 'returns',\n\n // Important behavior details\n 'async',\n 'generator',\n 'default',\n 'defaultvalue',\n 'enum',\n 'augments',\n 'extends',\n 'throws',\n 'exception',\n 'yield',\n 'yields',\n 'event',\n 'fires',\n 'emits',\n 'listens',\n 'this',\n\n // TypeScript\n 'satisfies',\n\n // Access\n 'static',\n 'private',\n 'protected',\n 'public',\n 'access',\n 'package',\n\n '-other',\n\n // Supplementary descriptions\n 'see',\n 'example',\n\n // METADATA\n\n // Other Closure (undocumented) metadata\n 'closurePrimitive',\n 'customElement',\n 'expose',\n 'hidden',\n 'idGenerator',\n 'meaning',\n 'ngInject',\n 'owner',\n 'wizaction',\n\n // Other Closure (documented) metadata\n 'define',\n 'dict',\n 'export',\n 'externs',\n 'implicitCast',\n 'noalias',\n 'nocollapse',\n 'nocompile',\n 'noinline',\n 'nosideeffects',\n 'polymer',\n 'polymerBehavior',\n 'preserve',\n 'struct',\n 'suppress',\n 'unrestricted',\n\n // @homer0/prettier-plugin-jsdoc metadata\n 'category',\n\n // Non-Closure metadata\n 'ignore',\n 'author',\n 'version',\n 'variation',\n 'since',\n 'deprecated',\n 'todo',\n ],\n },\n];\n\nexport default defaultTagOrder;\n"],"mappings":";;;;;;AAAA,MAAMA,eAAe,GAAG,CACtB;EACEC,IAAI,EAAE;EACJ;EACA,SAAS,EACT,aAAa;EAEb;EACA,QAAQ,EACR,SAAS,EACT,MAAM,EACN,cAAc,EACd,UAAU,EACV,QAAQ;EAER;EACA,UAAU,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,EACV,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACV,QAAQ,EACR,OAAO,EACP,aAAa;EAEb;EACA,UAAU,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,eAAe,EACf,WAAW,EACX,SAAS,EACT,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,UAAU;EAEV;EACA,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS;EAET;;EAEA;EACA,UAAU,EACV,UAAU,EAEV,OAAO,EACP,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,OAAO,EACP,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB;EAEjB;EACA,OAAO,EACP,KAAK,EACL,UAAU,EACV,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS;EAET;EACA,OAAO,EACP,WAAW,EACX,SAAS,EACT,cAAc,EACd,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,EACT,MAAM;EAEN;EACA,WAAW;EAEX;EACA,QAAQ,EACR,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EAET,QAAQ;EAER;EACA,KAAK,EACL,SAAS;EAET;;EAEA;EACA,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW;EAEX;EACA,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,EACd,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,cAAc;EAEd;EACA,UAAU;EAEV;EACA,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,OAAO,EACP,YAAY,EACZ,MAAM;AAEV,CAAC,CACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaJ,eAAe;AAAAK,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -72,7 +72,13 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
const potentialType = typedefTags[0].type;
|
|
75
|
-
|
|
75
|
+
let parsedType;
|
|
76
|
+
try {
|
|
77
|
+
parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialType) : (0, _jsdoccomment.parse)( /** @type {string} */potentialType, mode);
|
|
78
|
+
} catch {
|
|
79
|
+
// Todo: Should handle types in @prop/erty
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
76
82
|
(0, _jsdoccomment.traverse)(parsedType, nde => {
|
|
77
83
|
const {
|
|
78
84
|
type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkTemplateNames.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","mode","templateTags","getTags","usedNames","Set","checkParameters","aliasDeclaration","params","typeParameters","name","add","tag","names","split","has","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","length","potentialType","parsedType","tryParseType","parseType","traverse","value","test","iterateAllJsdocs","meta","docs","description","url","schema","module"],"sources":["../../src/rules/checkTemplateNames.js"],"sourcesContent":["import {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n utils,\n node,\n settings,\n report,\n}) => {\n const {\n mode\n } = settings;\n\n const templateTags = utils.getTags('template');\n\n const usedNames = new Set();\n /**\n * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkParameters = (aliasDeclaration) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n for (const name of names) {\n if (!usedNames.has(name)) {\n report(`@template ${name} not in use`, null, tag);\n }\n }\n }\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n switch (nde.type) {\n case 'ExportNamedDeclaration':\n if (nde.declaration?.type === 'TSTypeAliasDeclaration') {\n checkParameters(nde.declaration);\n }\n break;\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n const potentialType = typedefTags[0].type;\n
|
|
1
|
+
{"version":3,"file":"checkTemplateNames.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","mode","templateTags","getTags","usedNames","Set","checkParameters","aliasDeclaration","params","typeParameters","name","add","tag","names","split","has","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","length","potentialType","parsedType","tryParseType","parseType","traverse","value","test","iterateAllJsdocs","meta","docs","description","url","schema","module"],"sources":["../../src/rules/checkTemplateNames.js"],"sourcesContent":["import {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n utils,\n node,\n settings,\n report,\n}) => {\n const {\n mode\n } = settings;\n\n const templateTags = utils.getTags('template');\n\n const usedNames = new Set();\n /**\n * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkParameters = (aliasDeclaration) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n for (const name of names) {\n if (!usedNames.has(name)) {\n report(`@template ${name} not in use`, null, tag);\n }\n }\n }\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n switch (nde.type) {\n case 'ExportNamedDeclaration':\n if (nde.declaration?.type === 'TSTypeAliasDeclaration') {\n checkParameters(nde.declaration);\n }\n break;\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n const potentialType = typedefTags[0].type;\n\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode)\n } catch {\n // Todo: Should handle types in @prop/erty\n return;\n }\n\n traverse(parsedType, (nde) => {\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {\n usedNames.add(value);\n }\n });\n\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n for (const name of names) {\n if (!usedNames.has(name)) {\n report(`@template ${name} not in use`, null, tag);\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that any `@template` names are actually used in the connected `@typedef` or type alias.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',\n },\n schema: [],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8C,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,KAAK;EACLC,IAAI;EACJC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC;EACF,CAAC,GAAGF,QAAQ;EAEZ,MAAMG,YAAY,GAAGL,KAAK,CAACM,OAAO,CAAC,UAAU,CAAC;EAE9C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3B;AACF;AACA;EACE,MAAMC,eAAe,GAAIC,gBAAgB,IAAK;IAC5C;IACA,MAAM;MAACC;IAAM,CAAC,GAAGD,gBAAgB,CAACE,cAAc,IAAI;MAACD,MAAM,EAAE;IAAE,CAAC;IAChE,KAAK,MAAM;MAACE,IAAI,EAAE;QAACA;MAAI;IAAC,CAAC,IAAIF,MAAM,EAAE;MACnCJ,SAAS,CAACO,GAAG,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CAAC;EAC1D,CAAC,CAAC,MAAM;IACN;IACA;EACF;EAEA,IAAA0B,sBAAQ,EAACH,UAAU,EAAGN,GAAG,IAAK;IAC5B,MAAM;MACJC,IAAI;MACJS;IACF,CAAC,GAAG,2DAA6DV,GAAI;IACrE,IAAIC,IAAI,KAAK,eAAe,IAAK,SAAS,CAAEU,IAAI,CAACD,KAAK,CAAC,EAAE;MACvDxB,SAAS,CAACO,GAAG,CAACiB,KAAK,CAAC;IACtB;EACF,CAAC,CAAC;EAEF,KAAK,MAAMhB,GAAG,IAAIV,YAAY,EAAE;IAC9B,MAAM;MAACQ;IAAI,CAAC,GAAGE,GAAG;IAClB,MAAMC,KAAK,GAAGH,IAAI,CAACI,KAAK,CAAC,MAAM,CAAC;IAChC,KAAK,MAAMJ,IAAI,IAAIG,KAAK,EAAE;MACxB,IAAI,CAACT,SAAS,CAACW,GAAG,CAACL,IAAI,CAAC,EAAE;QACxBV,MAAM,CAAC,aAAaU,IAAI,aAAa,EAAE,IAAI,EAAEE,GAAG,CAAC;MACnD;IACF;EACF;AACF,CAAC,EAAE;EACDkB,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,gGAAgG;MAC7GC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,EAAE;IACVhB,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAiB,MAAA,CAAA1C,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
|
@@ -84,7 +84,13 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
const potentialType = typedefTags[0].type;
|
|
87
|
-
|
|
87
|
+
let parsedType;
|
|
88
|
+
try {
|
|
89
|
+
parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialType) : (0, _jsdoccomment.parse)( /** @type {string} */potentialType, mode);
|
|
90
|
+
} catch {
|
|
91
|
+
// Todo: Should handle types in @prop/erty
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
88
94
|
(0, _jsdoccomment.traverse)(parsedType, nde => {
|
|
89
95
|
const {
|
|
90
96
|
type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requireTemplate.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","requireSeparateTemplates","options","mode","usedNames","Set","templateTags","getTags","templateNames","flatMap","name","split","tag","names","length","checkParameters","aliasDeclaration","params","typeParameters","add","usedName","includes","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","potentialType","parsedType","tryParseType","parseType","traverse","value","test","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireTemplate.js"],"sourcesContent":["import {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n utils,\n node,\n settings,\n report,\n}) => {\n const {\n requireSeparateTemplates = false,\n } = context.options[0] || {};\n\n const {\n mode\n } = settings;\n\n const usedNames = new Set();\n const templateTags = utils.getTags('template');\n const templateNames = templateTags.flatMap(({name}) => {\n return name.split(/,\\s*/);\n });\n\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n if (requireSeparateTemplates && names.length > 1) {\n report(`Missing separate @template for ${names[1]}`, null, tag);\n }\n }\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkParameters = (aliasDeclaration) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @template ${usedName}`);\n }\n }\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n switch (nde.type) {\n case 'ExportNamedDeclaration':\n if (nde.declaration?.type === 'TSTypeAliasDeclaration') {\n checkParameters(nde.declaration);\n }\n break;\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n const potentialType = typedefTags[0].type;\n
|
|
1
|
+
{"version":3,"file":"requireTemplate.cjs","names":["_jsdoccomment","require","_iterateJsdoc","_interopRequireDefault","e","__esModule","default","_default","exports","iterateJsdoc","context","utils","node","settings","report","requireSeparateTemplates","options","mode","usedNames","Set","templateTags","getTags","templateNames","flatMap","name","split","tag","names","length","checkParameters","aliasDeclaration","params","typeParameters","add","usedName","includes","handleTypeAliases","_nde$declaration","nde","type","declaration","typedefTags","potentialType","parsedType","tryParseType","parseType","traverse","value","test","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireTemplate.js"],"sourcesContent":["import {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n utils,\n node,\n settings,\n report,\n}) => {\n const {\n requireSeparateTemplates = false,\n } = context.options[0] || {};\n\n const {\n mode\n } = settings;\n\n const usedNames = new Set();\n const templateTags = utils.getTags('template');\n const templateNames = templateTags.flatMap(({name}) => {\n return name.split(/,\\s*/);\n });\n\n for (const tag of templateTags) {\n const {name} = tag;\n const names = name.split(/,\\s*/);\n if (requireSeparateTemplates && names.length > 1) {\n report(`Missing separate @template for ${names[1]}`, null, tag);\n }\n }\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkParameters = (aliasDeclaration) => {\n /* c8 ignore next -- Guard */\n const {params} = aliasDeclaration.typeParameters ?? {params: []};\n for (const {name: {name}} of params) {\n usedNames.add(name);\n }\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @template ${usedName}`);\n }\n }\n };\n\n const handleTypeAliases = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n switch (nde.type) {\n case 'ExportNamedDeclaration':\n if (nde.declaration?.type === 'TSTypeAliasDeclaration') {\n checkParameters(nde.declaration);\n }\n break;\n case 'TSTypeAliasDeclaration':\n checkParameters(nde);\n break;\n }\n };\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypeAliases();\n return;\n }\n\n const potentialType = typedefTags[0].type;\n\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialType)) :\n parseType(/** @type {string} */ (potentialType), mode)\n } catch {\n // Todo: Should handle types in @prop/erty\n return;\n }\n\n traverse(parsedType, (nde) => {\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) {\n usedNames.add(value);\n }\n });\n\n // Could check against whitelist/blacklist\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @template ${usedName}`, null, typedefTags[0]);\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires template tags for each generic type parameter',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n requireSeparateTemplates: {\n type: 'boolean'\n }\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,aAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8C,SAAAE,uBAAAC,CAAA,WAAAA,CAA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AAK,eAAe,IAAK,SAAS,CAAES,IAAI,CAACD,KAAK,CAAC,EAAE;MACvD7B,SAAS,CAACe,GAAG,CAACc,KAAK,CAAC;IACtB;EACF,CAAC,CAAC;;EAEF;EACA,KAAK,MAAMb,QAAQ,IAAIhB,SAAS,EAAE;IAChC,IAAI,CAACI,aAAa,CAACa,QAAQ,CAACD,QAAQ,CAAC,EAAE;MACrCpB,MAAM,CAAC,qBAAqBoB,QAAQ,EAAE,EAAE,IAAI,EAAEO,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/D;EACF;AACF,CAAC,EAAE;EACDQ,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,wDAAwD;MACrEC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVzC,wBAAwB,EAAE;UACxBwB,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAkB,MAAA,CAAAjD,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
package/src/defaultTagOrder.js
CHANGED
|
@@ -65,9 +65,16 @@ export default iterateJsdoc(({
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const potentialType = typedefTags[0].type;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
|
|
69
|
+
let parsedType;
|
|
70
|
+
try {
|
|
71
|
+
parsedType = mode === 'permissive' ?
|
|
72
|
+
tryParseType(/** @type {string} */ (potentialType)) :
|
|
73
|
+
parseType(/** @type {string} */ (potentialType), mode)
|
|
74
|
+
} catch {
|
|
75
|
+
// Todo: Should handle types in @prop/erty
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
71
78
|
|
|
72
79
|
traverse(parsedType, (nde) => {
|
|
73
80
|
const {
|
|
@@ -76,9 +76,16 @@ export default iterateJsdoc(({
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const potentialType = typedefTags[0].type;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
|
|
80
|
+
let parsedType;
|
|
81
|
+
try {
|
|
82
|
+
parsedType = mode === 'permissive' ?
|
|
83
|
+
tryParseType(/** @type {string} */ (potentialType)) :
|
|
84
|
+
parseType(/** @type {string} */ (potentialType), mode)
|
|
85
|
+
} catch {
|
|
86
|
+
// Todo: Should handle types in @prop/erty
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
82
89
|
|
|
83
90
|
traverse(parsedType, (nde) => {
|
|
84
91
|
const {
|