eslint-plugin-jsdoc 56.0.0 → 56.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/package.json +4 -4
- package/dist/cjs/WarnSettings.js +0 -30
- package/dist/cjs/alignTransform.js +0 -285
- package/dist/cjs/defaultTagOrder.js +0 -152
- package/dist/cjs/exportParser.js +0 -754
- package/dist/cjs/getDefaultTagStructureForMode.js +0 -840
- package/dist/cjs/getJsdocProcessorPlugin.cjs +0 -4
- package/dist/cjs/getJsdocProcessorPlugin.js +0 -553
- package/dist/cjs/index-cjs.js +0 -492
- package/dist/cjs/index.cjs.cjs +0 -6
- package/dist/cjs/iterateJsdoc.cjs +0 -38
- package/dist/cjs/iterateJsdoc.js +0 -1981
- package/dist/cjs/jsdocUtils.js +0 -1470
- package/dist/cjs/rules/checkAccess.js +0 -35
- package/dist/cjs/rules/checkAlignment.js +0 -63
- package/dist/cjs/rules/checkExamples.js +0 -486
- package/dist/cjs/rules/checkIndentation.js +0 -66
- package/dist/cjs/rules/checkLineAlignment.js +0 -297
- package/dist/cjs/rules/checkParamNames.js +0 -320
- package/dist/cjs/rules/checkPropertyNames.js +0 -105
- package/dist/cjs/rules/checkSyntax.js +0 -27
- package/dist/cjs/rules/checkTagNames.js +0 -252
- package/dist/cjs/rules/checkTemplateNames.js +0 -189
- package/dist/cjs/rules/checkTypes.js +0 -421
- package/dist/cjs/rules/checkValues.js +0 -163
- package/dist/cjs/rules/convertToJsdocComments.js +0 -313
- package/dist/cjs/rules/emptyTags.js +0 -79
- package/dist/cjs/rules/implementsOnClasses.js +0 -63
- package/dist/cjs/rules/importsAsDependencies.js +0 -105
- package/dist/cjs/rules/informativeDocs.js +0 -153
- package/dist/cjs/rules/linesBeforeBlock.js +0 -106
- package/dist/cjs/rules/matchDescription.js +0 -240
- package/dist/cjs/rules/matchName.js +0 -122
- package/dist/cjs/rules/multilineBlocks.js +0 -339
- package/dist/cjs/rules/noBadBlocks.js +0 -88
- package/dist/cjs/rules/noBlankBlockDescriptions.js +0 -56
- package/dist/cjs/rules/noBlankBlocks.js +0 -41
- package/dist/cjs/rules/noDefaults.js +0 -84
- package/dist/cjs/rules/noMissingSyntax.js +0 -164
- package/dist/cjs/rules/noMultiAsterisks.js +0 -83
- package/dist/cjs/rules/noRestrictedSyntax.js +0 -75
- package/dist/cjs/rules/noTypes.js +0 -88
- package/dist/cjs/rules/noUndefinedTypes.js +0 -451
- package/dist/cjs/rules/requireAsteriskPrefix.js +0 -144
- package/dist/cjs/rules/requireDescription.js +0 -136
- package/dist/cjs/rules/requireDescriptionCompleteSentence.js +0 -258
- package/dist/cjs/rules/requireExample.js +0 -103
- package/dist/cjs/rules/requireFileOverview.js +0 -117
- package/dist/cjs/rules/requireHyphenBeforeParamDescription.js +0 -144
- package/dist/cjs/rules/requireJsdoc.js +0 -629
- package/dist/cjs/rules/requireParam.js +0 -480
- package/dist/cjs/rules/requireParamDescription.js +0 -77
- package/dist/cjs/rules/requireParamName.js +0 -52
- package/dist/cjs/rules/requireParamType.js +0 -77
- package/dist/cjs/rules/requireProperty.js +0 -44
- package/dist/cjs/rules/requirePropertyDescription.js +0 -22
- package/dist/cjs/rules/requirePropertyName.js +0 -22
- package/dist/cjs/rules/requirePropertyType.js +0 -22
- package/dist/cjs/rules/requireReturns.js +0 -197
- package/dist/cjs/rules/requireReturnsCheck.js +0 -108
- package/dist/cjs/rules/requireReturnsDescription.js +0 -58
- package/dist/cjs/rules/requireReturnsType.js +0 -52
- package/dist/cjs/rules/requireTemplate.js +0 -173
- package/dist/cjs/rules/requireThrows.js +0 -101
- package/dist/cjs/rules/requireYields.js +0 -172
- package/dist/cjs/rules/requireYieldsCheck.js +0 -164
- package/dist/cjs/rules/sortTags.js +0 -392
- package/dist/cjs/rules/tagLines.js +0 -259
- package/dist/cjs/rules/textEscaping.js +0 -125
- package/dist/cjs/rules/typeFormatting.js +0 -328
- package/dist/cjs/rules/validTypes.js +0 -333
- package/dist/cjs/tagNames.js +0 -209
- package/dist/cjs/utils/hasReturnValue.js +0 -469
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
const jsdoccomment_1 = require("@es-joy/jsdoccomment");
|
|
8
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, node, report, settings, utils, }) => {
|
|
9
|
-
if (utils.avoidDocs()) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const { requireSeparateTemplates = false, } = context.options[0] || {};
|
|
13
|
-
const { mode, } = settings;
|
|
14
|
-
const usedNames = new Set();
|
|
15
|
-
const templateTags = utils.getTags('template');
|
|
16
|
-
const templateNames = templateTags.flatMap((tag) => {
|
|
17
|
-
return utils.parseClosureTemplateTag(tag);
|
|
18
|
-
});
|
|
19
|
-
if (requireSeparateTemplates) {
|
|
20
|
-
for (const tag of templateTags) {
|
|
21
|
-
const names = utils.parseClosureTemplateTag(tag);
|
|
22
|
-
if (names.length > 1) {
|
|
23
|
-
report(`Missing separate @template for ${names[1]}`, null, tag);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|
|
|
29
|
-
* import('@typescript-eslint/types').TSESTree.ClassDeclaration|
|
|
30
|
-
* import('@typescript-eslint/types').TSESTree.TSDeclareFunction|
|
|
31
|
-
* import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|
|
|
32
|
-
* import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration
|
|
33
|
-
*/
|
|
34
|
-
const checkTypeParams = (aliasDeclaration) => {
|
|
35
|
-
const { params,
|
|
36
|
-
/* c8 ignore next -- Guard */
|
|
37
|
-
} = aliasDeclaration.typeParameters ?? {
|
|
38
|
-
/* c8 ignore next -- Guard */
|
|
39
|
-
params: [],
|
|
40
|
-
};
|
|
41
|
-
for (const { name: { name, }, } of params) {
|
|
42
|
-
usedNames.add(name);
|
|
43
|
-
}
|
|
44
|
-
for (const usedName of usedNames) {
|
|
45
|
-
if (!templateNames.includes(usedName)) {
|
|
46
|
-
report(`Missing @template ${usedName}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const handleTypes = () => {
|
|
51
|
-
const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (node);
|
|
52
|
-
if (!nde) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
switch (nde.type) {
|
|
56
|
-
case 'ClassDeclaration':
|
|
57
|
-
case 'FunctionDeclaration':
|
|
58
|
-
case 'TSDeclareFunction':
|
|
59
|
-
case 'TSInterfaceDeclaration':
|
|
60
|
-
case 'TSTypeAliasDeclaration':
|
|
61
|
-
checkTypeParams(nde);
|
|
62
|
-
break;
|
|
63
|
-
case 'ExportDefaultDeclaration':
|
|
64
|
-
switch (nde.declaration?.type) {
|
|
65
|
-
case 'ClassDeclaration':
|
|
66
|
-
case 'FunctionDeclaration':
|
|
67
|
-
case 'TSInterfaceDeclaration':
|
|
68
|
-
checkTypeParams(nde.declaration);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case 'ExportNamedDeclaration':
|
|
73
|
-
switch (nde.declaration?.type) {
|
|
74
|
-
case 'ClassDeclaration':
|
|
75
|
-
case 'FunctionDeclaration':
|
|
76
|
-
case 'TSDeclareFunction':
|
|
77
|
-
case 'TSInterfaceDeclaration':
|
|
78
|
-
case 'TSTypeAliasDeclaration':
|
|
79
|
-
checkTypeParams(nde.declaration);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const usedNameToTag = new Map();
|
|
86
|
-
/**
|
|
87
|
-
* @param {import('comment-parser').Spec} potentialTag
|
|
88
|
-
*/
|
|
89
|
-
const checkForUsedTypes = (potentialTag) => {
|
|
90
|
-
let parsedType;
|
|
91
|
-
try {
|
|
92
|
-
parsedType = mode === 'permissive' ?
|
|
93
|
-
(0, jsdoccomment_1.tryParse)(/** @type {string} */ (potentialTag.type)) :
|
|
94
|
-
(0, jsdoccomment_1.parse)(/** @type {string} */ (potentialTag.type), mode);
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
(0, jsdoccomment_1.traverse)(parsedType, (nde) => {
|
|
100
|
-
const { type, value, } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
|
|
101
|
-
if (type === 'JsdocTypeName' && (/^[A-Z]$/v).test(value)) {
|
|
102
|
-
usedNames.add(value);
|
|
103
|
-
if (!usedNameToTag.has(value)) {
|
|
104
|
-
usedNameToTag.set(value, potentialTag);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* @param {string[]} tagNames
|
|
111
|
-
*/
|
|
112
|
-
const checkTagsAndTemplates = (tagNames) => {
|
|
113
|
-
for (const tagName of tagNames) {
|
|
114
|
-
const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
115
|
-
tagName,
|
|
116
|
-
}));
|
|
117
|
-
const matchingTags = utils.getTags(preferredTagName);
|
|
118
|
-
for (const matchingTag of matchingTags) {
|
|
119
|
-
checkForUsedTypes(matchingTag);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Could check against whitelist/blacklist
|
|
123
|
-
for (const usedName of usedNames) {
|
|
124
|
-
if (!templateNames.includes(usedName)) {
|
|
125
|
-
report(`Missing @template ${usedName}`, null, usedNameToTag.get(usedName));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const callbackTags = utils.getTags('callback');
|
|
130
|
-
const functionTags = utils.getTags('function');
|
|
131
|
-
if (callbackTags.length || functionTags.length) {
|
|
132
|
-
checkTagsAndTemplates([
|
|
133
|
-
'param', 'returns',
|
|
134
|
-
]);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const typedefTags = utils.getTags('typedef');
|
|
138
|
-
if (!typedefTags.length || typedefTags.length >= 2) {
|
|
139
|
-
handleTypes();
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const potentialTypedef = typedefTags[0];
|
|
143
|
-
checkForUsedTypes(potentialTypedef);
|
|
144
|
-
checkTagsAndTemplates([
|
|
145
|
-
'property',
|
|
146
|
-
]);
|
|
147
|
-
}, {
|
|
148
|
-
iterateAllJsdocs: true,
|
|
149
|
-
meta: {
|
|
150
|
-
docs: {
|
|
151
|
-
description: 'Requires template tags for each generic type parameter',
|
|
152
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',
|
|
153
|
-
},
|
|
154
|
-
schema: [
|
|
155
|
-
{
|
|
156
|
-
additionalProperties: false,
|
|
157
|
-
properties: {
|
|
158
|
-
exemptedBy: {
|
|
159
|
-
items: {
|
|
160
|
-
type: 'string',
|
|
161
|
-
},
|
|
162
|
-
type: 'array',
|
|
163
|
-
},
|
|
164
|
-
requireSeparateTemplates: {
|
|
165
|
-
type: 'boolean',
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
type: 'object',
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
type: 'suggestion',
|
|
172
|
-
},
|
|
173
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
/**
|
|
8
|
-
* We can skip checking for a throws value, in case the documentation is inherited
|
|
9
|
-
* or the method is either a constructor or an abstract method.
|
|
10
|
-
* @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.
|
|
11
|
-
* @returns {boolean} true in case deep checking can be skipped; otherwise false.
|
|
12
|
-
*/
|
|
13
|
-
const canSkip = (utils) => {
|
|
14
|
-
return utils.hasATag([
|
|
15
|
-
// inheritdoc implies that all documentation is inherited
|
|
16
|
-
// see https://jsdoc.app/tags-inheritdoc.html
|
|
17
|
-
//
|
|
18
|
-
// Abstract methods are by definition incomplete,
|
|
19
|
-
// so it is not necessary to document that they throw an error.
|
|
20
|
-
'abstract',
|
|
21
|
-
'virtual',
|
|
22
|
-
// The designated type can itself document `@throws`
|
|
23
|
-
'type',
|
|
24
|
-
]) ||
|
|
25
|
-
utils.avoidDocs();
|
|
26
|
-
};
|
|
27
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
|
|
28
|
-
// A preflight check. We do not need to run a deep check for abstract
|
|
29
|
-
// functions.
|
|
30
|
-
if (canSkip(utils)) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const tagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
34
|
-
tagName: 'throws',
|
|
35
|
-
}));
|
|
36
|
-
if (!tagName) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const tags = utils.getTags(tagName);
|
|
40
|
-
const iteratingFunction = utils.isIteratingFunction();
|
|
41
|
-
// In case the code returns something, we expect a return value in JSDoc.
|
|
42
|
-
const [tag,] = tags;
|
|
43
|
-
const missingThrowsTag = typeof tag === 'undefined' || tag === null;
|
|
44
|
-
const shouldReport = () => {
|
|
45
|
-
if (!missingThrowsTag) {
|
|
46
|
-
if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) {
|
|
47
|
-
report(`JSDoc @${tagName} declaration set to "never" but throw value found.`);
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return iteratingFunction && utils.hasThrowValue();
|
|
52
|
-
};
|
|
53
|
-
if (shouldReport()) {
|
|
54
|
-
report(`Missing JSDoc @${tagName} declaration.`);
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
contextDefaults: true,
|
|
58
|
-
meta: {
|
|
59
|
-
docs: {
|
|
60
|
-
description: 'Requires that throw statements are documented.',
|
|
61
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header',
|
|
62
|
-
},
|
|
63
|
-
schema: [
|
|
64
|
-
{
|
|
65
|
-
additionalProperties: false,
|
|
66
|
-
properties: {
|
|
67
|
-
contexts: {
|
|
68
|
-
items: {
|
|
69
|
-
anyOf: [
|
|
70
|
-
{
|
|
71
|
-
type: 'string',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
additionalProperties: false,
|
|
75
|
-
properties: {
|
|
76
|
-
comment: {
|
|
77
|
-
type: 'string',
|
|
78
|
-
},
|
|
79
|
-
context: {
|
|
80
|
-
type: 'string',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
type: 'object',
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
type: 'array',
|
|
88
|
-
},
|
|
89
|
-
exemptedBy: {
|
|
90
|
-
items: {
|
|
91
|
-
type: 'string',
|
|
92
|
-
},
|
|
93
|
-
type: 'array',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
type: 'object',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
type: 'suggestion',
|
|
100
|
-
},
|
|
101
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
/**
|
|
8
|
-
* We can skip checking for a yield value, in case the documentation is inherited
|
|
9
|
-
* or the method has a constructor or abstract tag.
|
|
10
|
-
*
|
|
11
|
-
* In either of these cases the yield value is optional or not defined.
|
|
12
|
-
* @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.
|
|
13
|
-
* @returns {boolean} true in case deep checking can be skipped; otherwise false.
|
|
14
|
-
*/
|
|
15
|
-
const canSkip = (utils) => {
|
|
16
|
-
return utils.hasATag([
|
|
17
|
-
// inheritdoc implies that all documentation is inherited
|
|
18
|
-
// see https://jsdoc.app/tags-inheritdoc.html
|
|
19
|
-
//
|
|
20
|
-
// Abstract methods are by definition incomplete,
|
|
21
|
-
// so it is not an error if it declares a yield value but does not implement it.
|
|
22
|
-
'abstract',
|
|
23
|
-
'virtual',
|
|
24
|
-
// Constructors do not have a yield value
|
|
25
|
-
// so we can bail out here, too.
|
|
26
|
-
'class',
|
|
27
|
-
'constructor',
|
|
28
|
-
// Yield (and any `next`) type is specified accompanying the targeted
|
|
29
|
-
// @type
|
|
30
|
-
'type',
|
|
31
|
-
// This seems to imply a class as well
|
|
32
|
-
'interface',
|
|
33
|
-
]) ||
|
|
34
|
-
utils.avoidDocs();
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
38
|
-
* @param {import('../iterateJsdoc.js').Report} report
|
|
39
|
-
* @param {string} tagName
|
|
40
|
-
* @returns {[preferredTagName?: string, missingTag?: boolean]}
|
|
41
|
-
*/
|
|
42
|
-
const checkTagName = (utils, report, tagName) => {
|
|
43
|
-
const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
44
|
-
tagName,
|
|
45
|
-
}));
|
|
46
|
-
if (!preferredTagName) {
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
const tags = utils.getTags(preferredTagName);
|
|
50
|
-
if (tags.length > 1) {
|
|
51
|
-
report(`Found more than one @${preferredTagName} declaration.`);
|
|
52
|
-
}
|
|
53
|
-
// In case the code yields something, we expect a yields value in JSDoc.
|
|
54
|
-
const [tag,] = tags;
|
|
55
|
-
const missingTag = typeof tag === 'undefined' || tag === null;
|
|
56
|
-
return [
|
|
57
|
-
preferredTagName, missingTag,
|
|
58
|
-
];
|
|
59
|
-
};
|
|
60
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, report, utils, }) => {
|
|
61
|
-
const { forceRequireNext = false, forceRequireYields = false, next = false, nextWithGeneratorTag = false, withGeneratorTag = true, } = context.options[0] || {};
|
|
62
|
-
// A preflight check. We do not need to run a deep check
|
|
63
|
-
// in case the @yield comment is optional or undefined.
|
|
64
|
-
if (canSkip(utils)) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const iteratingFunction = utils.isIteratingFunction();
|
|
68
|
-
const [preferredYieldTagName, missingYieldTag,] = checkTagName(utils, report, 'yields');
|
|
69
|
-
if (preferredYieldTagName) {
|
|
70
|
-
const shouldReportYields = () => {
|
|
71
|
-
if (!missingYieldTag) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
if (withGeneratorTag && utils.hasTag('generator') ||
|
|
75
|
-
forceRequireYields && iteratingFunction && utils.isGenerator()) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
return iteratingFunction && utils.isGenerator() && utils.hasYieldValue();
|
|
79
|
-
};
|
|
80
|
-
if (shouldReportYields()) {
|
|
81
|
-
report(`Missing JSDoc @${preferredYieldTagName} declaration.`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (next || nextWithGeneratorTag || forceRequireNext) {
|
|
85
|
-
const [preferredNextTagName, missingNextTag,] = checkTagName(utils, report, 'next');
|
|
86
|
-
if (!preferredNextTagName) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const shouldReportNext = () => {
|
|
90
|
-
if (!missingNextTag) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
if (nextWithGeneratorTag && utils.hasTag('generator')) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
if (!next && !forceRequireNext ||
|
|
97
|
-
!iteratingFunction ||
|
|
98
|
-
!utils.isGenerator()) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
return forceRequireNext || utils.hasYieldReturnValue();
|
|
102
|
-
};
|
|
103
|
-
if (shouldReportNext()) {
|
|
104
|
-
report(`Missing JSDoc @${preferredNextTagName} declaration.`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
contextDefaults: true,
|
|
109
|
-
meta: {
|
|
110
|
-
docs: {
|
|
111
|
-
description: 'Requires yields are documented.',
|
|
112
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header',
|
|
113
|
-
},
|
|
114
|
-
schema: [
|
|
115
|
-
{
|
|
116
|
-
additionalProperties: false,
|
|
117
|
-
properties: {
|
|
118
|
-
contexts: {
|
|
119
|
-
items: {
|
|
120
|
-
anyOf: [
|
|
121
|
-
{
|
|
122
|
-
type: 'string',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
additionalProperties: false,
|
|
126
|
-
properties: {
|
|
127
|
-
comment: {
|
|
128
|
-
type: 'string',
|
|
129
|
-
},
|
|
130
|
-
context: {
|
|
131
|
-
type: 'string',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
type: 'object',
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
},
|
|
138
|
-
type: 'array',
|
|
139
|
-
},
|
|
140
|
-
exemptedBy: {
|
|
141
|
-
items: {
|
|
142
|
-
type: 'string',
|
|
143
|
-
},
|
|
144
|
-
type: 'array',
|
|
145
|
-
},
|
|
146
|
-
forceRequireNext: {
|
|
147
|
-
default: false,
|
|
148
|
-
type: 'boolean',
|
|
149
|
-
},
|
|
150
|
-
forceRequireYields: {
|
|
151
|
-
default: false,
|
|
152
|
-
type: 'boolean',
|
|
153
|
-
},
|
|
154
|
-
next: {
|
|
155
|
-
default: false,
|
|
156
|
-
type: 'boolean',
|
|
157
|
-
},
|
|
158
|
-
nextWithGeneratorTag: {
|
|
159
|
-
default: false,
|
|
160
|
-
type: 'boolean',
|
|
161
|
-
},
|
|
162
|
-
withGeneratorTag: {
|
|
163
|
-
default: true,
|
|
164
|
-
type: 'boolean',
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
type: 'object',
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
type: 'suggestion',
|
|
171
|
-
},
|
|
172
|
-
});
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
/**
|
|
8
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
9
|
-
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
10
|
-
* @returns {boolean}
|
|
11
|
-
*/
|
|
12
|
-
const canSkip = (utils, settings) => {
|
|
13
|
-
const voidingTags = [
|
|
14
|
-
// An abstract function is by definition incomplete
|
|
15
|
-
// so it is perfectly fine if a yield is documented but
|
|
16
|
-
// not present within the function.
|
|
17
|
-
// A subclass may inherit the doc and implement the
|
|
18
|
-
// missing yield.
|
|
19
|
-
'abstract',
|
|
20
|
-
'virtual',
|
|
21
|
-
// Constructor functions do not have a yield value
|
|
22
|
-
// so we can bail here, too.
|
|
23
|
-
'class',
|
|
24
|
-
'constructor',
|
|
25
|
-
// This seems to imply a class as well
|
|
26
|
-
'interface',
|
|
27
|
-
];
|
|
28
|
-
if (settings.mode === 'closure') {
|
|
29
|
-
// Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned
|
|
30
|
-
voidingTags.push('record');
|
|
31
|
-
}
|
|
32
|
-
return utils.hasATag(voidingTags) ||
|
|
33
|
-
utils.isConstructor() ||
|
|
34
|
-
utils.classHasTag('interface') ||
|
|
35
|
-
settings.mode === 'closure' && utils.classHasTag('record');
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
39
|
-
* @param {import('../iterateJsdoc.js').Report} report
|
|
40
|
-
* @param {string} tagName
|
|
41
|
-
* @returns {[]|[preferredTagName: string, tag: import('comment-parser').Spec]}
|
|
42
|
-
*/
|
|
43
|
-
const checkTagName = (utils, report, tagName) => {
|
|
44
|
-
const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
45
|
-
tagName,
|
|
46
|
-
}));
|
|
47
|
-
if (!preferredTagName) {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
const tags = utils.getTags(preferredTagName);
|
|
51
|
-
if (tags.length === 0) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
if (tags.length > 1) {
|
|
55
|
-
report(`Found more than one @${preferredTagName} declaration.`);
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
return [
|
|
59
|
-
preferredTagName, tags[0],
|
|
60
|
-
];
|
|
61
|
-
};
|
|
62
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, report, settings, utils, }) => {
|
|
63
|
-
if (canSkip(utils, settings)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const { checkGeneratorsOnly = false, next = false, } = context.options[0] || {};
|
|
67
|
-
const [preferredYieldTagName, yieldTag,] = checkTagName(utils, report, 'yields');
|
|
68
|
-
if (preferredYieldTagName) {
|
|
69
|
-
const shouldReportYields = () => {
|
|
70
|
-
if (
|
|
71
|
-
/** @type {import('comment-parser').Spec} */ (yieldTag).type.trim() === 'never') {
|
|
72
|
-
if (utils.hasYieldValue()) {
|
|
73
|
-
report(`JSDoc @${preferredYieldTagName} declaration set with "never" but yield expression is present in function.`);
|
|
74
|
-
}
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (checkGeneratorsOnly && !utils.isGenerator()) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
return !utils.mayBeUndefinedTypeTag(
|
|
81
|
-
/** @type {import('comment-parser').Spec} */
|
|
82
|
-
(yieldTag)) && !utils.hasYieldValue();
|
|
83
|
-
};
|
|
84
|
-
// In case a yield value is declared in JSDoc, we also expect one in the code.
|
|
85
|
-
if (shouldReportYields()) {
|
|
86
|
-
report(`JSDoc @${preferredYieldTagName} declaration present but yield expression not available in function.`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (next) {
|
|
90
|
-
const [preferredNextTagName, nextTag,] = checkTagName(utils, report, 'next');
|
|
91
|
-
if (preferredNextTagName) {
|
|
92
|
-
const shouldReportNext = () => {
|
|
93
|
-
if (
|
|
94
|
-
/** @type {import('comment-parser').Spec} */ (nextTag).type.trim() === 'never') {
|
|
95
|
-
if (utils.hasYieldReturnValue()) {
|
|
96
|
-
report(`JSDoc @${preferredNextTagName} declaration set with "never" but yield expression with return value is present in function.`);
|
|
97
|
-
}
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
if (checkGeneratorsOnly && !utils.isGenerator()) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
return !utils.mayBeUndefinedTypeTag(
|
|
104
|
-
/** @type {import('comment-parser').Spec} */
|
|
105
|
-
(nextTag)) && !utils.hasYieldReturnValue();
|
|
106
|
-
};
|
|
107
|
-
if (shouldReportNext()) {
|
|
108
|
-
report(`JSDoc @${preferredNextTagName} declaration present but yield expression with return value not available in function.`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
meta: {
|
|
114
|
-
docs: {
|
|
115
|
-
description: 'Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment.',
|
|
116
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields-check.md#repos-sticky-header',
|
|
117
|
-
},
|
|
118
|
-
schema: [
|
|
119
|
-
{
|
|
120
|
-
additionalProperties: false,
|
|
121
|
-
properties: {
|
|
122
|
-
checkGeneratorsOnly: {
|
|
123
|
-
default: false,
|
|
124
|
-
type: 'boolean',
|
|
125
|
-
},
|
|
126
|
-
contexts: {
|
|
127
|
-
items: {
|
|
128
|
-
anyOf: [
|
|
129
|
-
{
|
|
130
|
-
type: 'string',
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
additionalProperties: false,
|
|
134
|
-
properties: {
|
|
135
|
-
comment: {
|
|
136
|
-
type: 'string',
|
|
137
|
-
},
|
|
138
|
-
context: {
|
|
139
|
-
type: 'string',
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
type: 'object',
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
},
|
|
146
|
-
type: 'array',
|
|
147
|
-
},
|
|
148
|
-
exemptedBy: {
|
|
149
|
-
items: {
|
|
150
|
-
type: 'string',
|
|
151
|
-
},
|
|
152
|
-
type: 'array',
|
|
153
|
-
},
|
|
154
|
-
next: {
|
|
155
|
-
default: false,
|
|
156
|
-
type: 'boolean',
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
type: 'object',
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
type: 'suggestion',
|
|
163
|
-
},
|
|
164
|
-
});
|