eslint-plugin-jsdoc 56.0.0 → 56.0.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/dist/cjs/getJsdocProcessorPlugin.d.cts +5 -1
- package/dist/cjs/iterateJsdoc.d.cts +6 -2
- package/dist/getJsdocProcessorPlugin.cts +3 -1
- package/dist/iterateJsdoc.cts +9 -4
- package/package.json +4 -4
- package/src/getJsdocProcessorPlugin.cts +3 -1
- package/src/iterateJsdoc.cts +9 -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,44 +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
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ utils, }) => {
|
|
8
|
-
const propertyAssociatedTags = utils.filterTags(({ tag, }) => {
|
|
9
|
-
return [
|
|
10
|
-
'namespace', 'typedef',
|
|
11
|
-
].includes(tag);
|
|
12
|
-
});
|
|
13
|
-
if (!propertyAssociatedTags.length) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const targetTagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
17
|
-
tagName: 'property',
|
|
18
|
-
}));
|
|
19
|
-
if (utils.hasATag([
|
|
20
|
-
targetTagName,
|
|
21
|
-
])) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
for (const propertyAssociatedTag of propertyAssociatedTags) {
|
|
25
|
-
if (![
|
|
26
|
-
'object', 'Object', 'PlainObject',
|
|
27
|
-
].includes(propertyAssociatedTag.type)) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
utils.reportJSDoc(`Missing JSDoc @${targetTagName}.`, null, () => {
|
|
31
|
-
utils.addTag(targetTagName);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
iterateAllJsdocs: true,
|
|
36
|
-
meta: {
|
|
37
|
-
docs: {
|
|
38
|
-
description: 'Requires that all `@typedef` and `@namespace` tags have `@property` when their type is a plain `object`, `Object`, or `PlainObject`.',
|
|
39
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property.md#repos-sticky-header',
|
|
40
|
-
},
|
|
41
|
-
fixable: 'code',
|
|
42
|
-
type: 'suggestion',
|
|
43
|
-
},
|
|
44
|
-
});
|
|
@@ -1,22 +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
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
|
|
8
|
-
utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {
|
|
9
|
-
if (!jsdoc.description.trim()) {
|
|
10
|
-
report(`Missing JSDoc @${targetTagName} "${jsdoc.name}" description.`, null, jsdoc);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}, {
|
|
14
|
-
iterateAllJsdocs: true,
|
|
15
|
-
meta: {
|
|
16
|
-
docs: {
|
|
17
|
-
description: 'Requires that each `@property` tag has a `description` value.',
|
|
18
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-description.md#repos-sticky-header',
|
|
19
|
-
},
|
|
20
|
-
type: 'suggestion',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
@@ -1,22 +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
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
|
|
8
|
-
utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {
|
|
9
|
-
if (jsdoc.tag && jsdoc.name === '') {
|
|
10
|
-
report(`There must be an identifier after @${targetTagName} ${jsdoc.type === '' ? 'type' : 'tag'}.`, null, jsdoc);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}, {
|
|
14
|
-
iterateAllJsdocs: true,
|
|
15
|
-
meta: {
|
|
16
|
-
docs: {
|
|
17
|
-
description: 'Requires that all function `@property` tags have names.',
|
|
18
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header',
|
|
19
|
-
},
|
|
20
|
-
type: 'suggestion',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
@@ -1,22 +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
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
|
|
8
|
-
utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {
|
|
9
|
-
if (!jsdoc.type) {
|
|
10
|
-
report(`Missing JSDoc @${targetTagName} "${jsdoc.name}" type.`, null, jsdoc);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}, {
|
|
14
|
-
iterateAllJsdocs: true,
|
|
15
|
-
meta: {
|
|
16
|
-
docs: {
|
|
17
|
-
description: 'Requires that each `@property` tag has a `type` value.',
|
|
18
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header',
|
|
19
|
-
},
|
|
20
|
-
type: 'suggestion',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
@@ -1,197 +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 exportParser_js_1 = __importDefault(require("../exportParser.js"));
|
|
7
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
8
|
-
/**
|
|
9
|
-
* We can skip checking for a return value, in case the documentation is inherited
|
|
10
|
-
* or the method is either a constructor or an abstract method.
|
|
11
|
-
*
|
|
12
|
-
* In either of these cases the return value is optional or not defined.
|
|
13
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
14
|
-
* a reference to the utils which are used to probe if a tag is present or not.
|
|
15
|
-
* @returns {boolean}
|
|
16
|
-
* true in case deep checking can be skipped; otherwise false.
|
|
17
|
-
*/
|
|
18
|
-
const canSkip = (utils) => {
|
|
19
|
-
return utils.hasATag([
|
|
20
|
-
// inheritdoc implies that all documentation is inherited
|
|
21
|
-
// see https://jsdoc.app/tags-inheritdoc.html
|
|
22
|
-
//
|
|
23
|
-
// Abstract methods are by definition incomplete,
|
|
24
|
-
// so it is not an error if it declares a return value but does not implement it.
|
|
25
|
-
'abstract',
|
|
26
|
-
'virtual',
|
|
27
|
-
// Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html)
|
|
28
|
-
// So we can bail out here, too.
|
|
29
|
-
'class',
|
|
30
|
-
'constructor',
|
|
31
|
-
// Return type is specified by type in @type
|
|
32
|
-
'type',
|
|
33
|
-
// This seems to imply a class as well
|
|
34
|
-
'interface',
|
|
35
|
-
]) ||
|
|
36
|
-
utils.avoidDocs();
|
|
37
|
-
};
|
|
38
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, info: { comment, }, node, report, settings, utils, }) => {
|
|
39
|
-
const { contexts, enableFixer = false, forceRequireReturn = false, forceReturnsWithAsync = false, publicOnly = false, } = context.options[0] || {};
|
|
40
|
-
// A preflight check. We do not need to run a deep check
|
|
41
|
-
// in case the @returns comment is optional or undefined.
|
|
42
|
-
if (canSkip(utils)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
/** @type {boolean|undefined} */
|
|
46
|
-
let forceRequireReturnContext;
|
|
47
|
-
if (contexts) {
|
|
48
|
-
const { foundContext, } = utils.findContext(contexts, comment);
|
|
49
|
-
if (typeof foundContext === 'object') {
|
|
50
|
-
forceRequireReturnContext = foundContext.forceRequireReturn;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const tagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
54
|
-
tagName: 'returns',
|
|
55
|
-
}));
|
|
56
|
-
if (!tagName) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const tags = utils.getTags(tagName);
|
|
60
|
-
if (tags.length > 1) {
|
|
61
|
-
report(`Found more than one @${tagName} declaration.`);
|
|
62
|
-
}
|
|
63
|
-
const iteratingFunction = utils.isIteratingFunction();
|
|
64
|
-
// In case the code returns something, we expect a return value in JSDoc.
|
|
65
|
-
const [tag,] = tags;
|
|
66
|
-
const missingReturnTag = typeof tag === 'undefined' || tag === null;
|
|
67
|
-
const shouldReport = () => {
|
|
68
|
-
if (!missingReturnTag) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
if (publicOnly) {
|
|
72
|
-
/** @type {import('./requireJsdoc.js').RequireJsdocOpts} */
|
|
73
|
-
const opt = {
|
|
74
|
-
ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
|
|
75
|
-
esm: Boolean(publicOnly?.esm ?? true),
|
|
76
|
-
initModuleExports: Boolean(publicOnly?.cjs ?? true),
|
|
77
|
-
initWindow: Boolean(publicOnly?.window ?? false),
|
|
78
|
-
};
|
|
79
|
-
/* c8 ignore next -- Fallback to deprecated method */
|
|
80
|
-
const { sourceCode = context.getSourceCode(), } = context;
|
|
81
|
-
const exported = exportParser_js_1.default.isUncommentedExport(
|
|
82
|
-
/** @type {import('eslint').Rule.Node} */ (node), sourceCode, opt, settings);
|
|
83
|
-
if (!exported) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if ((forceRequireReturn || forceRequireReturnContext) && (iteratingFunction || utils.isVirtualFunction())) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
const isAsync = !iteratingFunction && utils.hasTag('async') ||
|
|
91
|
-
iteratingFunction && utils.isAsync();
|
|
92
|
-
if (forceReturnsWithAsync && isAsync) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(forceReturnsWithAsync);
|
|
96
|
-
};
|
|
97
|
-
if (shouldReport()) {
|
|
98
|
-
utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => {
|
|
99
|
-
utils.addTag(tagName);
|
|
100
|
-
} : null);
|
|
101
|
-
}
|
|
102
|
-
}, {
|
|
103
|
-
contextDefaults: true,
|
|
104
|
-
meta: {
|
|
105
|
-
docs: {
|
|
106
|
-
description: 'Requires that returns are documented.',
|
|
107
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header',
|
|
108
|
-
},
|
|
109
|
-
fixable: 'code',
|
|
110
|
-
schema: [
|
|
111
|
-
{
|
|
112
|
-
additionalProperties: false,
|
|
113
|
-
properties: {
|
|
114
|
-
checkConstructors: {
|
|
115
|
-
default: false,
|
|
116
|
-
type: 'boolean',
|
|
117
|
-
},
|
|
118
|
-
checkGetters: {
|
|
119
|
-
default: true,
|
|
120
|
-
type: 'boolean',
|
|
121
|
-
},
|
|
122
|
-
contexts: {
|
|
123
|
-
items: {
|
|
124
|
-
anyOf: [
|
|
125
|
-
{
|
|
126
|
-
type: 'string',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
additionalProperties: false,
|
|
130
|
-
properties: {
|
|
131
|
-
comment: {
|
|
132
|
-
type: 'string',
|
|
133
|
-
},
|
|
134
|
-
context: {
|
|
135
|
-
type: 'string',
|
|
136
|
-
},
|
|
137
|
-
forceRequireReturn: {
|
|
138
|
-
type: 'boolean',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
type: 'object',
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
},
|
|
145
|
-
type: 'array',
|
|
146
|
-
},
|
|
147
|
-
enableFixer: {
|
|
148
|
-
type: 'boolean',
|
|
149
|
-
},
|
|
150
|
-
exemptedBy: {
|
|
151
|
-
items: {
|
|
152
|
-
type: 'string',
|
|
153
|
-
},
|
|
154
|
-
type: 'array',
|
|
155
|
-
},
|
|
156
|
-
forceRequireReturn: {
|
|
157
|
-
default: false,
|
|
158
|
-
type: 'boolean',
|
|
159
|
-
},
|
|
160
|
-
forceReturnsWithAsync: {
|
|
161
|
-
default: false,
|
|
162
|
-
type: 'boolean',
|
|
163
|
-
},
|
|
164
|
-
publicOnly: {
|
|
165
|
-
oneOf: [
|
|
166
|
-
{
|
|
167
|
-
default: false,
|
|
168
|
-
type: 'boolean',
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
additionalProperties: false,
|
|
172
|
-
default: {},
|
|
173
|
-
properties: {
|
|
174
|
-
ancestorsOnly: {
|
|
175
|
-
type: 'boolean',
|
|
176
|
-
},
|
|
177
|
-
cjs: {
|
|
178
|
-
type: 'boolean',
|
|
179
|
-
},
|
|
180
|
-
esm: {
|
|
181
|
-
type: 'boolean',
|
|
182
|
-
},
|
|
183
|
-
window: {
|
|
184
|
-
type: 'boolean',
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
type: 'object',
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
type: 'object',
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
type: 'suggestion',
|
|
196
|
-
},
|
|
197
|
-
});
|
|
@@ -1,108 +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 return is documented but
|
|
16
|
-
// not present within the function.
|
|
17
|
-
// A subclass may inherit the doc and implement the
|
|
18
|
-
// missing return.
|
|
19
|
-
'abstract',
|
|
20
|
-
'virtual',
|
|
21
|
-
// A constructor function returns `this` by default, so may be `@returns`
|
|
22
|
-
// tag indicating this but no explicit return
|
|
23
|
-
'class',
|
|
24
|
-
'constructor',
|
|
25
|
-
'interface',
|
|
26
|
-
];
|
|
27
|
-
if (settings.mode === 'closure') {
|
|
28
|
-
// Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned
|
|
29
|
-
voidingTags.push('record');
|
|
30
|
-
}
|
|
31
|
-
return utils.hasATag(voidingTags) ||
|
|
32
|
-
utils.isConstructor() ||
|
|
33
|
-
utils.classHasTag('interface') ||
|
|
34
|
-
settings.mode === 'closure' && utils.classHasTag('record');
|
|
35
|
-
};
|
|
36
|
-
// eslint-disable-next-line complexity -- Temporary
|
|
37
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, node, report, settings, utils, }) => {
|
|
38
|
-
const { exemptAsync = true, exemptGenerators = settings.mode === 'typescript', reportMissingReturnForUndefinedTypes = false, } = context.options[0] || {};
|
|
39
|
-
if (canSkip(utils, settings)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (exemptAsync && utils.isAsync()) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const tagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
46
|
-
tagName: 'returns',
|
|
47
|
-
}));
|
|
48
|
-
if (!tagName) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const tags = utils.getTags(tagName);
|
|
52
|
-
if (tags.length === 0) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (tags.length > 1) {
|
|
56
|
-
report(`Found more than one @${tagName} declaration.`);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const [tag,] = tags;
|
|
60
|
-
const type = tag.type.trim();
|
|
61
|
-
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
|
|
62
|
-
if (/asserts\s/v.test(type)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const returnNever = type === 'never';
|
|
66
|
-
if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {
|
|
67
|
-
report(`JSDoc @${tagName} declaration set with "never" but return expression is present in function.`);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
// In case a return value is declared in JSDoc, we also expect one in the code.
|
|
71
|
-
if (!returnNever &&
|
|
72
|
-
(reportMissingReturnForUndefinedTypes ||
|
|
73
|
-
!utils.mayBeUndefinedTypeTag(tag)) &&
|
|
74
|
-
(tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync) ||
|
|
75
|
-
tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync, true)) &&
|
|
76
|
-
Boolean(!exemptGenerators || !node ||
|
|
77
|
-
!('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) ||
|
|
78
|
-
!( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */(node)).generator)) {
|
|
79
|
-
report(`JSDoc @${tagName} declaration present but return expression not available in function.`);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
meta: {
|
|
83
|
-
docs: {
|
|
84
|
-
description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.',
|
|
85
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header',
|
|
86
|
-
},
|
|
87
|
-
schema: [
|
|
88
|
-
{
|
|
89
|
-
additionalProperties: false,
|
|
90
|
-
properties: {
|
|
91
|
-
exemptAsync: {
|
|
92
|
-
default: true,
|
|
93
|
-
type: 'boolean',
|
|
94
|
-
},
|
|
95
|
-
exemptGenerators: {
|
|
96
|
-
type: 'boolean',
|
|
97
|
-
},
|
|
98
|
-
reportMissingReturnForUndefinedTypes: {
|
|
99
|
-
default: false,
|
|
100
|
-
type: 'boolean',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
type: 'object',
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
type: 'suggestion',
|
|
107
|
-
},
|
|
108
|
-
});
|
|
@@ -1,58 +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
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
|
|
8
|
-
utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {
|
|
9
|
-
const type = jsdocTag.type && jsdocTag.type.trim();
|
|
10
|
-
if ([
|
|
11
|
-
'Promise<undefined>', 'Promise<void>', 'undefined', 'void',
|
|
12
|
-
].includes(type)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (!jsdocTag.description.trim()) {
|
|
16
|
-
report(`Missing JSDoc @${targetTagName} description.`, null, jsdocTag);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}, {
|
|
20
|
-
contextDefaults: true,
|
|
21
|
-
meta: {
|
|
22
|
-
docs: {
|
|
23
|
-
description: 'Requires that the `@returns` tag has a `description` value.',
|
|
24
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header',
|
|
25
|
-
},
|
|
26
|
-
schema: [
|
|
27
|
-
{
|
|
28
|
-
additionalProperties: false,
|
|
29
|
-
properties: {
|
|
30
|
-
contexts: {
|
|
31
|
-
items: {
|
|
32
|
-
anyOf: [
|
|
33
|
-
{
|
|
34
|
-
type: 'string',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
additionalProperties: false,
|
|
38
|
-
properties: {
|
|
39
|
-
comment: {
|
|
40
|
-
type: 'string',
|
|
41
|
-
},
|
|
42
|
-
context: {
|
|
43
|
-
type: 'string',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
type: 'object',
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
type: 'array',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
type: 'object',
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
type: 'suggestion',
|
|
57
|
-
},
|
|
58
|
-
});
|
|
@@ -1,52 +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
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ report, utils, }) => {
|
|
8
|
-
utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {
|
|
9
|
-
if (!jsdocTag.type) {
|
|
10
|
-
report(`Missing JSDoc @${targetTagName} type.`, null, jsdocTag);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}, {
|
|
14
|
-
contextDefaults: true,
|
|
15
|
-
meta: {
|
|
16
|
-
docs: {
|
|
17
|
-
description: 'Requires that `@returns` tag has `type` value.',
|
|
18
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header',
|
|
19
|
-
},
|
|
20
|
-
schema: [
|
|
21
|
-
{
|
|
22
|
-
additionalProperties: false,
|
|
23
|
-
properties: {
|
|
24
|
-
contexts: {
|
|
25
|
-
items: {
|
|
26
|
-
anyOf: [
|
|
27
|
-
{
|
|
28
|
-
type: 'string',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
additionalProperties: false,
|
|
32
|
-
properties: {
|
|
33
|
-
comment: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
},
|
|
36
|
-
context: {
|
|
37
|
-
type: 'string',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
type: 'object',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
type: 'array',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
type: 'object',
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
type: 'suggestion',
|
|
51
|
-
},
|
|
52
|
-
});
|