eslint-plugin-jsdoc 53.0.0 → 54.0.0
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/WarnSettings.cjs +35 -18
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/alignTransform.cjs +305 -224
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/defaultTagOrder.cjs +43 -132
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/exportParser.cjs +696 -478
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateRule.cjs +242 -0
- package/dist/generateRule.cjs.map +1 -0
- package/dist/getDefaultTagStructureForMode.cjs +288 -184
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +550 -364
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.d.ts +65 -68
- package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
- package/dist/index.cjs +410 -2
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/iterateJsdoc.cjs +2005 -1528
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.ts +350 -358
- package/dist/iterateJsdoc.d.ts.map +1 -1
- package/dist/jsdocUtils.cjs +1376 -1009
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkAccess.cjs +36 -29
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +54 -41
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +484 -327
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +65 -50
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +311 -220
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +335 -227
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +106 -78
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkSyntax.cjs +34 -21
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +210 -188
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +178 -121
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +385 -291
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +146 -100
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +306 -228
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +72 -62
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.cjs +56 -36
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.cjs +99 -62
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +142 -105
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +105 -70
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +222 -160
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +128 -73
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +352 -235
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +86 -63
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +57 -35
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.cjs +48 -26
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noDefaults.cjs +79 -52
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +165 -115
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +89 -48
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +79 -45
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +80 -59
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +388 -297
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +159 -108
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +129 -89
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +262 -201
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireExample.cjs +104 -73
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +129 -75
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +133 -85
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +557 -384
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +526 -336
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamDescription.cjs +80 -55
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +50 -32
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamType.cjs +80 -55
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireProperty.cjs +42 -31
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.cjs +25 -17
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyName.cjs +25 -17
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyType.cjs +25 -17
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +203 -125
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +103 -60
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +54 -39
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsType.cjs +50 -32
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +178 -119
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireThrows.cjs +95 -61
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +166 -106
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +152 -96
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +444 -258
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +266 -179
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +127 -92
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +265 -252
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/tagNames.cjs +170 -134
- package/dist/tagNames.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +474 -246
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/package.json +24 -40
- package/src/WarnSettings.js +34 -0
- package/src/alignTransform.js +358 -0
- package/src/defaultTagOrder.js +169 -0
- package/src/exportParser.js +978 -0
- package/src/getDefaultTagStructureForMode.js +969 -0
- package/src/getJsdocProcessorPlugin.js +672 -0
- package/src/index.js +530 -0
- package/src/iterateJsdoc.js +2541 -0
- package/src/jsdocUtils.js +1896 -0
- package/src/rules/checkAccess.js +45 -0
- package/src/rules/checkAlignment.js +63 -0
- package/src/rules/checkExamples.js +589 -0
- package/src/rules/checkIndentation.js +75 -0
- package/src/rules/checkLineAlignment.js +372 -0
- package/src/rules/checkParamNames.js +474 -0
- package/src/rules/checkPropertyNames.js +152 -0
- package/src/rules/checkSyntax.js +30 -0
- package/src/rules/checkTagNames.js +314 -0
- package/src/rules/checkTemplateNames.js +204 -0
- package/src/rules/checkTypes.js +535 -0
- package/src/rules/checkValues.js +248 -0
- package/src/rules/convertToJsdocComments.js +398 -0
- package/src/rules/emptyTags.js +98 -0
- package/src/rules/implementsOnClasses.js +64 -0
- package/src/rules/importsAsDependencies.js +133 -0
- package/src/rules/informativeDocs.js +189 -0
- package/src/rules/linesBeforeBlock.js +134 -0
- package/src/rules/matchDescription.js +286 -0
- package/src/rules/matchName.js +151 -0
- package/src/rules/multilineBlocks.js +493 -0
- package/src/rules/noBadBlocks.js +119 -0
- package/src/rules/noBlankBlockDescriptions.js +69 -0
- package/src/rules/noBlankBlocks.js +53 -0
- package/src/rules/noDefaults.js +85 -0
- package/src/rules/noMissingSyntax.js +195 -0
- package/src/rules/noMultiAsterisks.js +134 -0
- package/src/rules/noRestrictedSyntax.js +91 -0
- package/src/rules/noTypes.js +93 -0
- package/src/rules/noUndefinedTypes.js +543 -0
- package/src/rules/requireAsteriskPrefix.js +190 -0
- package/src/rules/requireDescription.js +161 -0
- package/src/rules/requireDescriptionCompleteSentence.js +335 -0
- package/src/rules/requireExample.js +118 -0
- package/src/rules/requireFileOverview.js +154 -0
- package/src/rules/requireHyphenBeforeParamDescription.js +176 -0
- package/src/rules/requireJsdoc.js +743 -0
- package/src/rules/requireParam.js +602 -0
- package/src/rules/requireParamDescription.js +89 -0
- package/src/rules/requireParamName.js +55 -0
- package/src/rules/requireParamType.js +89 -0
- package/src/rules/requireProperty.js +48 -0
- package/src/rules/requirePropertyDescription.js +25 -0
- package/src/rules/requirePropertyName.js +25 -0
- package/src/rules/requirePropertyType.js +25 -0
- package/src/rules/requireReturns.js +238 -0
- package/src/rules/requireReturnsCheck.js +145 -0
- package/src/rules/requireReturnsDescription.js +59 -0
- package/src/rules/requireReturnsType.js +51 -0
- package/src/rules/requireTemplate.js +201 -0
- package/src/rules/requireThrows.js +111 -0
- package/src/rules/requireYields.js +216 -0
- package/src/rules/requireYieldsCheck.js +208 -0
- package/src/rules/sortTags.js +558 -0
- package/src/rules/tagLines.js +359 -0
- package/src/rules/textEscaping.js +154 -0
- package/src/rules/validTypes.js +401 -0
- package/src/tagNames.js +238 -0
- package/src/utils/hasReturnValue.js +572 -0
- package/dist/WarnSettings.js +0 -20
- package/dist/WarnSettings.js.map +0 -1
- package/dist/_virtual/rolldown_runtime.cjs +0 -32
- package/dist/_virtual/rolldown_runtime.js +0 -11
- package/dist/alignTransform.js +0 -241
- package/dist/alignTransform.js.map +0 -1
- package/dist/defaultTagOrder.js +0 -134
- package/dist/defaultTagOrder.js.map +0 -1
- package/dist/exportParser.js +0 -518
- package/dist/exportParser.js.map +0 -1
- package/dist/getDefaultTagStructureForMode.js +0 -188
- package/dist/getDefaultTagStructureForMode.js.map +0 -1
- package/dist/getJsdocProcessorPlugin.d.cts +0 -70
- package/dist/getJsdocProcessorPlugin.d.cts.map +0 -1
- package/dist/getJsdocProcessorPlugin.js +0 -383
- package/dist/getJsdocProcessorPlugin.js.map +0 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.js +0 -3
- package/dist/iterateJsdoc.d.cts +0 -471
- package/dist/iterateJsdoc.d.cts.map +0 -1
- package/dist/iterateJsdoc.js +0 -1617
- package/dist/iterateJsdoc.js.map +0 -1
- package/dist/jsdocUtils.js +0 -1123
- package/dist/jsdocUtils.js.map +0 -1
- package/dist/plugin.cjs +0 -427
- package/dist/plugin.cjs.map +0 -1
- package/dist/plugin.js +0 -427
- package/dist/plugin.js.map +0 -1
- package/dist/rules/checkAccess.js +0 -33
- package/dist/rules/checkAccess.js.map +0 -1
- package/dist/rules/checkAlignment.js +0 -47
- package/dist/rules/checkAlignment.js.map +0 -1
- package/dist/rules/checkExamples.js +0 -348
- package/dist/rules/checkExamples.js.map +0 -1
- package/dist/rules/checkIndentation.js +0 -59
- package/dist/rules/checkIndentation.js.map +0 -1
- package/dist/rules/checkLineAlignment.js +0 -229
- package/dist/rules/checkLineAlignment.js.map +0 -1
- package/dist/rules/checkParamNames.js +0 -237
- package/dist/rules/checkParamNames.js.map +0 -1
- package/dist/rules/checkPropertyNames.js +0 -88
- package/dist/rules/checkPropertyNames.js.map +0 -1
- package/dist/rules/checkSyntax.js +0 -25
- package/dist/rules/checkSyntax.js.map +0 -1
- package/dist/rules/checkTagNames.js +0 -191
- package/dist/rules/checkTagNames.js.map +0 -1
- package/dist/rules/checkTemplateNames.js +0 -124
- package/dist/rules/checkTemplateNames.js.map +0 -1
- package/dist/rules/checkTypes.js +0 -299
- package/dist/rules/checkTypes.js.map +0 -1
- package/dist/rules/checkValues.js +0 -103
- package/dist/rules/checkValues.js.map +0 -1
- package/dist/rules/convertToJsdocComments.js +0 -231
- package/dist/rules/convertToJsdocComments.js.map +0 -1
- package/dist/rules/emptyTags.js +0 -67
- package/dist/rules/emptyTags.js.map +0 -1
- package/dist/rules/implementsOnClasses.js +0 -40
- package/dist/rules/implementsOnClasses.js.map +0 -1
- package/dist/rules/importsAsDependencies.js +0 -68
- package/dist/rules/importsAsDependencies.js.map +0 -1
- package/dist/rules/informativeDocs.js +0 -110
- package/dist/rules/informativeDocs.js.map +0 -1
- package/dist/rules/linesBeforeBlock.js +0 -75
- package/dist/rules/linesBeforeBlock.js.map +0 -1
- package/dist/rules/matchDescription.js +0 -167
- package/dist/rules/matchDescription.js.map +0 -1
- package/dist/rules/matchName.js +0 -77
- package/dist/rules/matchName.js.map +0 -1
- package/dist/rules/multilineBlocks.js +0 -245
- package/dist/rules/multilineBlocks.js.map +0 -1
- package/dist/rules/noBadBlocks.js +0 -68
- package/dist/rules/noBadBlocks.js.map +0 -1
- package/dist/rules/noBlankBlockDescriptions.js +0 -41
- package/dist/rules/noBlankBlockDescriptions.js.map +0 -1
- package/dist/rules/noBlankBlocks.js +0 -30
- package/dist/rules/noBlankBlocks.js.map +0 -1
- package/dist/rules/noDefaults.js +0 -56
- package/dist/rules/noDefaults.js.map +0 -1
- package/dist/rules/noMissingSyntax.js +0 -126
- package/dist/rules/noMissingSyntax.js.map +0 -1
- package/dist/rules/noMultiAsterisks.js +0 -58
- package/dist/rules/noMultiAsterisks.js.map +0 -1
- package/dist/rules/noRestrictedSyntax.js +0 -49
- package/dist/rules/noRestrictedSyntax.js.map +0 -1
- package/dist/rules/noTypes.js +0 -65
- package/dist/rules/noTypes.js.map +0 -1
- package/dist/rules/noUndefinedTypes.js +0 -303
- package/dist/rules/noUndefinedTypes.js.map +0 -1
- package/dist/rules/requireAsteriskPrefix.js +0 -112
- package/dist/rules/requireAsteriskPrefix.js.map +0 -1
- package/dist/rules/requireDescription.js +0 -95
- package/dist/rules/requireDescription.js.map +0 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +0 -220
- package/dist/rules/requireDescriptionCompleteSentence.js.map +0 -1
- package/dist/rules/requireExample.js +0 -77
- package/dist/rules/requireExample.js.map +0 -1
- package/dist/rules/requireFileOverview.js +0 -81
- package/dist/rules/requireFileOverview.js.map +0 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +0 -89
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +0 -1
- package/dist/rules/requireJsdoc.js +0 -404
- package/dist/rules/requireJsdoc.js.map +0 -1
- package/dist/rules/requireParam.js +0 -344
- package/dist/rules/requireParam.js.map +0 -1
- package/dist/rules/requireParamDescription.js +0 -59
- package/dist/rules/requireParamDescription.js.map +0 -1
- package/dist/rules/requireParamName.js +0 -36
- package/dist/rules/requireParamName.js.map +0 -1
- package/dist/rules/requireParamType.js +0 -59
- package/dist/rules/requireParamType.js.map +0 -1
- package/dist/rules/requireProperty.js +0 -35
- package/dist/rules/requireProperty.js.map +0 -1
- package/dist/rules/requirePropertyDescription.js +0 -21
- package/dist/rules/requirePropertyDescription.js.map +0 -1
- package/dist/rules/requirePropertyName.js +0 -21
- package/dist/rules/requirePropertyName.js.map +0 -1
- package/dist/rules/requirePropertyType.js +0 -21
- package/dist/rules/requirePropertyType.js.map +0 -1
- package/dist/rules/requireReturns.js +0 -131
- package/dist/rules/requireReturns.js.map +0 -1
- package/dist/rules/requireReturnsCheck.js +0 -66
- package/dist/rules/requireReturnsCheck.js.map +0 -1
- package/dist/rules/requireReturnsDescription.js +0 -43
- package/dist/rules/requireReturnsDescription.js.map +0 -1
- package/dist/rules/requireReturnsType.js +0 -36
- package/dist/rules/requireReturnsType.js.map +0 -1
- package/dist/rules/requireTemplate.js +0 -122
- package/dist/rules/requireTemplate.js.map +0 -1
- package/dist/rules/requireThrows.js +0 -67
- package/dist/rules/requireThrows.js.map +0 -1
- package/dist/rules/requireYields.js +0 -115
- package/dist/rules/requireYields.js.map +0 -1
- package/dist/rules/requireYieldsCheck.js +0 -105
- package/dist/rules/requireYieldsCheck.js.map +0 -1
- package/dist/rules/sortTags.js +0 -262
- package/dist/rules/sortTags.js.map +0 -1
- package/dist/rules/tagLines.js +0 -183
- package/dist/rules/tagLines.js.map +0 -1
- package/dist/rules/textEscaping.js +0 -102
- package/dist/rules/textEscaping.js.map +0 -1
- package/dist/rules/validTypes.js +0 -259
- package/dist/rules/validTypes.js.map +0 -1
- package/dist/tagNames.js +0 -144
- package/dist/tagNames.js.map +0 -1
- package/dist/utils/hasReturnValue.js +0 -265
- package/dist/utils/hasReturnValue.js.map +0 -1
|
@@ -1,405 +1,578 @@
|
|
|
1
|
-
|
|
2
|
-
const require_hasReturnValue = require('../utils/hasReturnValue.cjs');
|
|
3
|
-
const require_jsdocUtils = require('../jsdocUtils.cjs');
|
|
4
|
-
const require_iterateJsdoc = require('../iterateJsdoc.cjs');
|
|
5
|
-
const require_exportParser = require('../exportParser.cjs');
|
|
6
|
-
const __es_joy_jsdoccomment = require_rolldown_runtime.__toESM(require("@es-joy/jsdoccomment"));
|
|
1
|
+
"use strict";
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _exportParser = _interopRequireDefault(require("../exportParser.cjs"));
|
|
8
|
+
var _iterateJsdoc = require("../iterateJsdoc.cjs");
|
|
9
|
+
var _jsdocUtils = require("../jsdocUtils.cjs");
|
|
10
|
+
var _jsdoccomment = require("@es-joy/jsdoccomment");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
12
|
/**
|
|
10
|
-
* @typedef {{
|
|
11
|
-
* ancestorsOnly: boolean,
|
|
12
|
-
* esm: boolean,
|
|
13
|
-
* initModuleExports: boolean,
|
|
14
|
-
* initWindow: boolean
|
|
15
|
-
* }} RequireJsdocOpts
|
|
16
|
-
*/
|
|
13
|
+
* @typedef {{
|
|
14
|
+
* ancestorsOnly: boolean,
|
|
15
|
+
* esm: boolean,
|
|
16
|
+
* initModuleExports: boolean,
|
|
17
|
+
* initWindow: boolean
|
|
18
|
+
* }} RequireJsdocOpts
|
|
19
|
+
*/
|
|
20
|
+
|
|
17
21
|
/**
|
|
18
|
-
* @typedef {import('eslint').Rule.Node|
|
|
19
|
-
* import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
|
|
20
|
-
*/
|
|
22
|
+
* @typedef {import('eslint').Rule.Node|
|
|
23
|
+
* import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
|
|
24
|
+
*/
|
|
25
|
+
|
|
21
26
|
/** @type {import('json-schema').JSONSchema4} */
|
|
22
27
|
const OPTIONS_SCHEMA = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
properties: {
|
|
30
|
+
checkConstructors: {
|
|
31
|
+
default: true,
|
|
32
|
+
type: 'boolean'
|
|
33
|
+
},
|
|
34
|
+
checkGetters: {
|
|
35
|
+
anyOf: [{
|
|
36
|
+
type: 'boolean'
|
|
37
|
+
}, {
|
|
38
|
+
enum: ['no-setter'],
|
|
39
|
+
type: 'string'
|
|
40
|
+
}],
|
|
41
|
+
default: true
|
|
42
|
+
},
|
|
43
|
+
checkSetters: {
|
|
44
|
+
anyOf: [{
|
|
45
|
+
type: 'boolean'
|
|
46
|
+
}, {
|
|
47
|
+
enum: ['no-getter'],
|
|
48
|
+
type: 'string'
|
|
49
|
+
}],
|
|
50
|
+
default: true
|
|
51
|
+
},
|
|
52
|
+
contexts: {
|
|
53
|
+
items: {
|
|
54
|
+
anyOf: [{
|
|
55
|
+
type: 'string'
|
|
56
|
+
}, {
|
|
57
|
+
additionalProperties: false,
|
|
58
|
+
properties: {
|
|
59
|
+
context: {
|
|
60
|
+
type: 'string'
|
|
61
|
+
},
|
|
62
|
+
inlineCommentBlock: {
|
|
63
|
+
type: 'boolean'
|
|
64
|
+
},
|
|
65
|
+
minLineCount: {
|
|
66
|
+
type: 'integer'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
type: 'object'
|
|
70
|
+
}]
|
|
71
|
+
},
|
|
72
|
+
type: 'array'
|
|
73
|
+
},
|
|
74
|
+
enableFixer: {
|
|
75
|
+
default: true,
|
|
76
|
+
type: 'boolean'
|
|
77
|
+
},
|
|
78
|
+
exemptEmptyConstructors: {
|
|
79
|
+
default: false,
|
|
80
|
+
type: 'boolean'
|
|
81
|
+
},
|
|
82
|
+
exemptEmptyFunctions: {
|
|
83
|
+
default: false,
|
|
84
|
+
type: 'boolean'
|
|
85
|
+
},
|
|
86
|
+
fixerMessage: {
|
|
87
|
+
default: '',
|
|
88
|
+
type: 'string'
|
|
89
|
+
},
|
|
90
|
+
minLineCount: {
|
|
91
|
+
type: 'integer'
|
|
92
|
+
},
|
|
93
|
+
publicOnly: {
|
|
94
|
+
oneOf: [{
|
|
95
|
+
default: false,
|
|
96
|
+
type: 'boolean'
|
|
97
|
+
}, {
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
default: {},
|
|
100
|
+
properties: {
|
|
101
|
+
ancestorsOnly: {
|
|
102
|
+
type: 'boolean'
|
|
103
|
+
},
|
|
104
|
+
cjs: {
|
|
105
|
+
type: 'boolean'
|
|
106
|
+
},
|
|
107
|
+
esm: {
|
|
108
|
+
type: 'boolean'
|
|
109
|
+
},
|
|
110
|
+
window: {
|
|
111
|
+
type: 'boolean'
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
type: 'object'
|
|
115
|
+
}]
|
|
116
|
+
},
|
|
117
|
+
require: {
|
|
118
|
+
additionalProperties: false,
|
|
119
|
+
default: {},
|
|
120
|
+
properties: {
|
|
121
|
+
ArrowFunctionExpression: {
|
|
122
|
+
default: false,
|
|
123
|
+
type: 'boolean'
|
|
124
|
+
},
|
|
125
|
+
ClassDeclaration: {
|
|
126
|
+
default: false,
|
|
127
|
+
type: 'boolean'
|
|
128
|
+
},
|
|
129
|
+
ClassExpression: {
|
|
130
|
+
default: false,
|
|
131
|
+
type: 'boolean'
|
|
132
|
+
},
|
|
133
|
+
FunctionDeclaration: {
|
|
134
|
+
default: true,
|
|
135
|
+
type: 'boolean'
|
|
136
|
+
},
|
|
137
|
+
FunctionExpression: {
|
|
138
|
+
default: false,
|
|
139
|
+
type: 'boolean'
|
|
140
|
+
},
|
|
141
|
+
MethodDefinition: {
|
|
142
|
+
default: false,
|
|
143
|
+
type: 'boolean'
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
type: 'object'
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
type: 'object'
|
|
119
150
|
};
|
|
151
|
+
|
|
120
152
|
/**
|
|
121
|
-
* @param {string} interfaceName
|
|
122
|
-
* @param {string} methodName
|
|
123
|
-
* @param {import("eslint").Scope.Scope | null} scope
|
|
124
|
-
* @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
|
|
125
|
-
*/
|
|
153
|
+
* @param {string} interfaceName
|
|
154
|
+
* @param {string} methodName
|
|
155
|
+
* @param {import("eslint").Scope.Scope | null} scope
|
|
156
|
+
* @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
|
|
157
|
+
*/
|
|
126
158
|
const getMethodOnInterface = (interfaceName, methodName, scope) => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
159
|
+
let scp = scope;
|
|
160
|
+
while (scp) {
|
|
161
|
+
for (const {
|
|
162
|
+
identifiers,
|
|
163
|
+
name
|
|
164
|
+
} of scp.variables) {
|
|
165
|
+
if (interfaceName !== name) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
for (const identifier of identifiers) {
|
|
169
|
+
const interfaceDeclaration = /** @type {import('@typescript-eslint/types').TSESTree.Identifier & {parent: import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration}} */identifier.parent;
|
|
170
|
+
/* c8 ignore next 3 -- TS */
|
|
171
|
+
if (interfaceDeclaration.type !== 'TSInterfaceDeclaration') {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
for (const bodyItem of interfaceDeclaration.body.body) {
|
|
175
|
+
const methodSig = /** @type {import('@typescript-eslint/types').TSESTree.TSMethodSignature} */
|
|
176
|
+
bodyItem;
|
|
177
|
+
if (methodName === /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */methodSig.key.name) {
|
|
178
|
+
return methodSig;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
scp = scp.upper;
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
144
186
|
};
|
|
187
|
+
|
|
145
188
|
/**
|
|
146
|
-
* @param {import('eslint').Rule.Node} node
|
|
147
|
-
* @param {import('eslint').SourceCode} sourceCode
|
|
148
|
-
* @param {import('eslint').Rule.RuleContext} context
|
|
149
|
-
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
150
|
-
*/
|
|
189
|
+
* @param {import('eslint').Rule.Node} node
|
|
190
|
+
* @param {import('eslint').SourceCode} sourceCode
|
|
191
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
192
|
+
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
193
|
+
*/
|
|
151
194
|
const isExemptedImplementer = (node, sourceCode, context, settings) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
195
|
+
if (node.type === 'FunctionExpression' && node.parent.type === 'MethodDefinition' && node.parent.parent.type === 'ClassBody' && node.parent.parent.parent.type === 'ClassDeclaration' && 'implements' in node.parent.parent.parent) {
|
|
196
|
+
const implments = /** @type {import('@typescript-eslint/types').TSESTree.TSClassImplements[]} */
|
|
197
|
+
node.parent.parent.parent.implements;
|
|
198
|
+
const {
|
|
199
|
+
name: methodName
|
|
200
|
+
} = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
|
|
201
|
+
node.parent.key;
|
|
202
|
+
for (const impl of implments) {
|
|
203
|
+
const {
|
|
204
|
+
name: interfaceName
|
|
205
|
+
} = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
|
|
206
|
+
impl.expression;
|
|
207
|
+
const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (sourceCode.getScope && /* c8 ignore next 2 */
|
|
208
|
+
sourceCode.getScope(node) || context.getScope()));
|
|
209
|
+
if (interfaceMethodNode) {
|
|
210
|
+
// @ts-expect-error Ok
|
|
211
|
+
const comment = (0, _jsdoccomment.getJSDocComment)(sourceCode, interfaceMethodNode, settings);
|
|
212
|
+
if (comment) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return false;
|
|
165
219
|
};
|
|
220
|
+
|
|
166
221
|
/**
|
|
167
|
-
* @param {import('eslint').Rule.RuleContext} context
|
|
168
|
-
* @param {import('json-schema').JSONSchema4Object} baseObject
|
|
169
|
-
* @param {string} option
|
|
170
|
-
* @param {string} key
|
|
171
|
-
* @returns {boolean|undefined}
|
|
172
|
-
*/
|
|
222
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
223
|
+
* @param {import('json-schema').JSONSchema4Object} baseObject
|
|
224
|
+
* @param {string} option
|
|
225
|
+
* @param {string} key
|
|
226
|
+
* @returns {boolean|undefined}
|
|
227
|
+
*/
|
|
173
228
|
const getOption = (context, baseObject, option, key) => {
|
|
174
|
-
|
|
175
|
-
|
|
229
|
+
if (context.options[0] && option in context.options[0] && (
|
|
230
|
+
// Todo: boolean shouldn't be returning property, but
|
|
231
|
+
// tests currently require
|
|
232
|
+
typeof context.options[0][option] === 'boolean' || key in context.options[0][option])) {
|
|
233
|
+
return context.options[0][option][key];
|
|
234
|
+
}
|
|
235
|
+
return /** @type {{[key: string]: {default?: boolean|undefined}}} */baseObject.properties[key].default;
|
|
176
236
|
};
|
|
237
|
+
|
|
177
238
|
/**
|
|
178
|
-
* @param {import('eslint').Rule.RuleContext} context
|
|
179
|
-
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
180
|
-
* @returns {{
|
|
181
|
-
* contexts: (string|{
|
|
182
|
-
* context: string,
|
|
183
|
-
* inlineCommentBlock: boolean,
|
|
184
|
-
* minLineCount: import('../iterateJsdoc.js').Integer
|
|
185
|
-
* })[],
|
|
186
|
-
* enableFixer: boolean,
|
|
187
|
-
* exemptEmptyConstructors: boolean,
|
|
188
|
-
* exemptEmptyFunctions: boolean,
|
|
189
|
-
* fixerMessage: string,
|
|
190
|
-
* minLineCount: undefined|import('../iterateJsdoc.js').Integer,
|
|
191
|
-
* publicOnly: boolean|{[key: string]: boolean|undefined}
|
|
192
|
-
* require: {[key: string]: boolean|undefined}
|
|
193
|
-
* }}
|
|
194
|
-
*/
|
|
239
|
+
* @param {import('eslint').Rule.RuleContext} context
|
|
240
|
+
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
241
|
+
* @returns {{
|
|
242
|
+
* contexts: (string|{
|
|
243
|
+
* context: string,
|
|
244
|
+
* inlineCommentBlock: boolean,
|
|
245
|
+
* minLineCount: import('../iterateJsdoc.js').Integer
|
|
246
|
+
* })[],
|
|
247
|
+
* enableFixer: boolean,
|
|
248
|
+
* exemptEmptyConstructors: boolean,
|
|
249
|
+
* exemptEmptyFunctions: boolean,
|
|
250
|
+
* fixerMessage: string,
|
|
251
|
+
* minLineCount: undefined|import('../iterateJsdoc.js').Integer,
|
|
252
|
+
* publicOnly: boolean|{[key: string]: boolean|undefined}
|
|
253
|
+
* require: {[key: string]: boolean|undefined}
|
|
254
|
+
* }}
|
|
255
|
+
*/
|
|
195
256
|
const getOptions = (context, settings) => {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
257
|
+
const {
|
|
258
|
+
contexts = settings.contexts || [],
|
|
259
|
+
enableFixer = true,
|
|
260
|
+
exemptEmptyConstructors = true,
|
|
261
|
+
exemptEmptyFunctions = false,
|
|
262
|
+
fixerMessage = '',
|
|
263
|
+
minLineCount = undefined,
|
|
264
|
+
publicOnly
|
|
265
|
+
} = context.options[0] || {};
|
|
266
|
+
return {
|
|
267
|
+
contexts,
|
|
268
|
+
enableFixer,
|
|
269
|
+
exemptEmptyConstructors,
|
|
270
|
+
exemptEmptyFunctions,
|
|
271
|
+
fixerMessage,
|
|
272
|
+
minLineCount,
|
|
273
|
+
publicOnly: (baseObj => {
|
|
274
|
+
if (!publicOnly) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** @type {{[key: string]: boolean|undefined}} */
|
|
279
|
+
const properties = {};
|
|
280
|
+
for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
|
|
281
|
+
/** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
|
|
282
|
+
const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */baseObj, 'publicOnly', prop);
|
|
283
|
+
properties[prop] = opt;
|
|
284
|
+
}
|
|
285
|
+
return properties;
|
|
286
|
+
})(/** @type {import('json-schema').JSONSchema4Object} */
|
|
287
|
+
(/** @type {import('json-schema').JSONSchema4Object} */
|
|
288
|
+
(/** @type {import('json-schema').JSONSchema4Object} */
|
|
289
|
+
OPTIONS_SCHEMA.properties.publicOnly).oneOf)[1]),
|
|
290
|
+
require: (baseObj => {
|
|
291
|
+
/** @type {{[key: string]: boolean|undefined}} */
|
|
292
|
+
const properties = {};
|
|
293
|
+
for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
|
|
294
|
+
/** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
|
|
295
|
+
const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */
|
|
296
|
+
baseObj, 'require', prop);
|
|
297
|
+
properties[prop] = opt;
|
|
298
|
+
}
|
|
299
|
+
return properties;
|
|
300
|
+
})(/** @type {import('json-schema').JSONSchema4Object} */
|
|
301
|
+
OPTIONS_SCHEMA.properties.require)
|
|
302
|
+
};
|
|
236
303
|
};
|
|
304
|
+
|
|
237
305
|
/** @type {import('eslint').Rule.RuleModule} */
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const { context: ctx } = ctxt;
|
|
266
|
-
return ctx === (info.selector || node.type);
|
|
267
|
-
}) || {};
|
|
268
|
-
if (underMinLine(contextMinLineCount)) return;
|
|
269
|
-
}
|
|
270
|
-
const jsDocNode = (0, __es_joy_jsdoccomment.getJSDocComment)(sourceCode, node, settings);
|
|
271
|
-
if (jsDocNode) return;
|
|
272
|
-
if (require_jsdocUtils.exemptSpeciaMethods({
|
|
273
|
-
description: "",
|
|
274
|
-
inlineTags: [],
|
|
275
|
-
problems: [],
|
|
276
|
-
source: [],
|
|
277
|
-
tags: []
|
|
278
|
-
}, node, context, [OPTIONS_SCHEMA])) return;
|
|
279
|
-
if (exemptEmptyFunctions && info.isFunctionContext || exemptEmptyConstructors && require_jsdocUtils.isConstructor(node)) {
|
|
280
|
-
const functionParameterNames = require_jsdocUtils.getFunctionParameterNames(node);
|
|
281
|
-
if (!functionParameterNames.length && !require_hasReturnValue.hasReturnValue(node)) return;
|
|
282
|
-
}
|
|
283
|
-
if (isExemptedImplementer(node, sourceCode, context, settings)) return;
|
|
284
|
-
const fix = (fixer) => {
|
|
285
|
-
const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
|
|
286
|
-
/** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
|
|
287
|
-
let baseNode = (0, __es_joy_jsdoccomment.getReducedASTNode)(node, sourceCode);
|
|
288
|
-
const decorator = (0, __es_joy_jsdoccomment.getDecorator)(baseNode);
|
|
289
|
-
if (decorator) baseNode = decorator;
|
|
290
|
-
const indent = require_jsdocUtils.getIndent({ text: sourceCode.getText(
|
|
291
|
-
baseNode,
|
|
292
|
-
/** @type {import('eslint').AST.SourceLocation} */
|
|
293
|
-
baseNode.loc.start.column
|
|
294
|
-
) });
|
|
295
|
-
const { inlineCommentBlock } = contexts.find((contxt) => {
|
|
296
|
-
if (typeof contxt === "string") return false;
|
|
297
|
-
const { context: ctxt } = contxt;
|
|
298
|
-
return ctxt === node.type;
|
|
299
|
-
}) || {};
|
|
300
|
-
const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${"\n".repeat(lines)}${indent.slice(0, -1)}`;
|
|
301
|
-
return fixer.insertTextBefore(baseNode, insertion);
|
|
302
|
-
};
|
|
303
|
-
const report = () => {
|
|
304
|
-
const { start } = node.loc;
|
|
305
|
-
const loc = {
|
|
306
|
-
end: {
|
|
307
|
-
column: 0,
|
|
308
|
-
line: start.line + 1
|
|
309
|
-
},
|
|
310
|
-
start
|
|
311
|
-
};
|
|
312
|
-
context.report({
|
|
313
|
-
fix: enableFixer ? fix : null,
|
|
314
|
-
loc,
|
|
315
|
-
messageId: "missingJsDoc",
|
|
316
|
-
node
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
if (publicOnly) {
|
|
320
|
-
/** @type {RequireJsdocOpts} */
|
|
321
|
-
const opt = {
|
|
322
|
-
ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
|
|
323
|
-
esm: Boolean(publicOnly?.esm ?? true),
|
|
324
|
-
initModuleExports: Boolean(publicOnly?.cjs ?? true),
|
|
325
|
-
initWindow: Boolean(publicOnly?.window ?? false)
|
|
326
|
-
};
|
|
327
|
-
const exported = require_exportParser.default.isUncommentedExport(node, sourceCode, opt, settings);
|
|
328
|
-
if (exported) report();
|
|
329
|
-
} else report();
|
|
330
|
-
};
|
|
331
|
-
/**
|
|
332
|
-
* @param {string} prop
|
|
333
|
-
* @returns {boolean}
|
|
334
|
-
*/
|
|
335
|
-
const hasOption = (prop) => {
|
|
336
|
-
return requireOption[prop] || contexts.some((ctxt) => {
|
|
337
|
-
return typeof ctxt === "object" ? ctxt.context === prop : ctxt === prop;
|
|
338
|
-
});
|
|
339
|
-
};
|
|
340
|
-
return {
|
|
341
|
-
...require_jsdocUtils.getContextObject(require_jsdocUtils.enforcedContexts(context, [], settings), checkJsDoc),
|
|
342
|
-
ArrowFunctionExpression(node) {
|
|
343
|
-
if (!hasOption("ArrowFunctionExpression")) return;
|
|
344
|
-
if ([
|
|
345
|
-
"AssignmentExpression",
|
|
346
|
-
"ExportDefaultDeclaration",
|
|
347
|
-
"VariableDeclarator"
|
|
348
|
-
].includes(node.parent.type) || [
|
|
349
|
-
"ClassProperty",
|
|
350
|
-
"ObjectProperty",
|
|
351
|
-
"Property",
|
|
352
|
-
"PropertyDefinition"
|
|
353
|
-
].includes(node.parent.type) && node === node.parent.value) checkJsDoc({ isFunctionContext: true }, null, node);
|
|
354
|
-
},
|
|
355
|
-
ClassDeclaration(node) {
|
|
356
|
-
if (!hasOption("ClassDeclaration")) return;
|
|
357
|
-
checkJsDoc({ isFunctionContext: false }, null, node);
|
|
358
|
-
},
|
|
359
|
-
ClassExpression(node) {
|
|
360
|
-
if (!hasOption("ClassExpression")) return;
|
|
361
|
-
checkJsDoc({ isFunctionContext: false }, null, node);
|
|
362
|
-
},
|
|
363
|
-
FunctionDeclaration(node) {
|
|
364
|
-
if (!hasOption("FunctionDeclaration")) return;
|
|
365
|
-
checkJsDoc({ isFunctionContext: true }, null, node);
|
|
366
|
-
},
|
|
367
|
-
FunctionExpression(node) {
|
|
368
|
-
if (!hasOption("FunctionExpression")) return;
|
|
369
|
-
if ([
|
|
370
|
-
"AssignmentExpression",
|
|
371
|
-
"ExportDefaultDeclaration",
|
|
372
|
-
"VariableDeclarator"
|
|
373
|
-
].includes(node.parent.type) || [
|
|
374
|
-
"ClassProperty",
|
|
375
|
-
"ObjectProperty",
|
|
376
|
-
"Property",
|
|
377
|
-
"PropertyDefinition"
|
|
378
|
-
].includes(node.parent.type) && node === node.parent.value) checkJsDoc({ isFunctionContext: true }, null, node);
|
|
379
|
-
},
|
|
380
|
-
MethodDefinition(node) {
|
|
381
|
-
if (!hasOption("MethodDefinition")) return;
|
|
382
|
-
checkJsDoc({
|
|
383
|
-
isFunctionContext: true,
|
|
384
|
-
selector: "MethodDefinition"
|
|
385
|
-
}, null, node.value);
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
},
|
|
389
|
-
meta: {
|
|
390
|
-
docs: {
|
|
391
|
-
category: "Stylistic Issues",
|
|
392
|
-
description: "Require JSDoc comments",
|
|
393
|
-
recommended: true,
|
|
394
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header"
|
|
395
|
-
},
|
|
396
|
-
fixable: "code",
|
|
397
|
-
messages: { missingJsDoc: "Missing JSDoc comment." },
|
|
398
|
-
schema: [OPTIONS_SCHEMA],
|
|
399
|
-
type: "suggestion"
|
|
400
|
-
}
|
|
401
|
-
};
|
|
306
|
+
var _default = exports.default = {
|
|
307
|
+
create(context) {
|
|
308
|
+
/* c8 ignore next -- Fallback to deprecated method */
|
|
309
|
+
const {
|
|
310
|
+
sourceCode = context.getSourceCode()
|
|
311
|
+
} = context;
|
|
312
|
+
const settings = (0, _iterateJsdoc.getSettings)(context);
|
|
313
|
+
if (!settings) {
|
|
314
|
+
return {};
|
|
315
|
+
}
|
|
316
|
+
const opts = getOptions(context, settings);
|
|
317
|
+
const {
|
|
318
|
+
contexts,
|
|
319
|
+
enableFixer,
|
|
320
|
+
exemptEmptyConstructors,
|
|
321
|
+
exemptEmptyFunctions,
|
|
322
|
+
fixerMessage,
|
|
323
|
+
minLineCount,
|
|
324
|
+
require: requireOption
|
|
325
|
+
} = opts;
|
|
326
|
+
const publicOnly =
|
|
327
|
+
/**
|
|
328
|
+
* @type {{
|
|
329
|
+
* [key: string]: boolean | undefined;
|
|
330
|
+
* }}
|
|
331
|
+
*/
|
|
332
|
+
opts.publicOnly;
|
|
402
333
|
|
|
403
|
-
|
|
404
|
-
|
|
334
|
+
/**
|
|
335
|
+
* @type {import('../iterateJsdoc.js').CheckJsdoc}
|
|
336
|
+
*/
|
|
337
|
+
const checkJsDoc = (info, _handler, node) => {
|
|
338
|
+
if (
|
|
339
|
+
// Optimize
|
|
340
|
+
minLineCount !== undefined || contexts.some(ctxt => {
|
|
341
|
+
if (typeof ctxt === 'string') {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
const {
|
|
345
|
+
minLineCount: count
|
|
346
|
+
} = ctxt;
|
|
347
|
+
return count !== undefined;
|
|
348
|
+
})) {
|
|
349
|
+
/**
|
|
350
|
+
* @param {undefined|import('../iterateJsdoc.js').Integer} count
|
|
351
|
+
*/
|
|
352
|
+
const underMinLine = count => {
|
|
353
|
+
return count !== undefined && count > (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
|
|
354
|
+
};
|
|
355
|
+
if (underMinLine(minLineCount)) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const {
|
|
359
|
+
minLineCount: contextMinLineCount
|
|
360
|
+
} =
|
|
361
|
+
/**
|
|
362
|
+
* @type {{
|
|
363
|
+
* context: string;
|
|
364
|
+
* inlineCommentBlock: boolean;
|
|
365
|
+
* minLineCount: number;
|
|
366
|
+
* }}
|
|
367
|
+
*/
|
|
368
|
+
contexts.find(ctxt => {
|
|
369
|
+
if (typeof ctxt === 'string') {
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
const {
|
|
373
|
+
context: ctx
|
|
374
|
+
} = ctxt;
|
|
375
|
+
return ctx === (info.selector || node.type);
|
|
376
|
+
}) || {};
|
|
377
|
+
if (underMinLine(contextMinLineCount)) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const jsDocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
|
|
382
|
+
if (jsDocNode) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// For those who have options configured against ANY constructors (or
|
|
387
|
+
// setters or getters) being reported
|
|
388
|
+
if ((0, _jsdocUtils.exemptSpeciaMethods)({
|
|
389
|
+
description: '',
|
|
390
|
+
inlineTags: [],
|
|
391
|
+
problems: [],
|
|
392
|
+
source: [],
|
|
393
|
+
tags: []
|
|
394
|
+
}, node, context, [OPTIONS_SCHEMA])) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (
|
|
398
|
+
// Avoid reporting param-less, return-less functions (when
|
|
399
|
+
// `exemptEmptyFunctions` option is set)
|
|
400
|
+
exemptEmptyFunctions && info.isFunctionContext ||
|
|
401
|
+
// Avoid reporting param-less, return-less constructor methods (when
|
|
402
|
+
// `exemptEmptyConstructors` option is set)
|
|
403
|
+
exemptEmptyConstructors && (0, _jsdocUtils.isConstructor)(node)) {
|
|
404
|
+
const functionParameterNames = (0, _jsdocUtils.getFunctionParameterNames)(node);
|
|
405
|
+
if (!functionParameterNames.length && !(0, _jsdocUtils.hasReturnValue)(node)) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (isExemptedImplementer(node, sourceCode, context, settings)) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => {
|
|
413
|
+
// Default to one line break if the `minLines`/`maxLines` settings allow
|
|
414
|
+
const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
|
|
415
|
+
/** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
|
|
416
|
+
let baseNode = (0, _jsdoccomment.getReducedASTNode)(node, sourceCode);
|
|
417
|
+
const decorator = (0, _jsdoccomment.getDecorator)(/** @type {import('eslint').Rule.Node} */
|
|
418
|
+
baseNode);
|
|
419
|
+
if (decorator) {
|
|
420
|
+
baseNode = decorator;
|
|
421
|
+
}
|
|
422
|
+
const indent = (0, _jsdocUtils.getIndent)({
|
|
423
|
+
text: sourceCode.getText(/** @type {import('eslint').Rule.Node} */baseNode, /** @type {import('eslint').AST.SourceLocation} */
|
|
424
|
+
(/** @type {import('eslint').Rule.Node} */baseNode.loc).start.column)
|
|
425
|
+
});
|
|
426
|
+
const {
|
|
427
|
+
inlineCommentBlock
|
|
428
|
+
} =
|
|
429
|
+
/**
|
|
430
|
+
* @type {{
|
|
431
|
+
* context: string,
|
|
432
|
+
* inlineCommentBlock: boolean,
|
|
433
|
+
* minLineCount: import('../iterateJsdoc.js').Integer
|
|
434
|
+
* }}
|
|
435
|
+
*/
|
|
436
|
+
contexts.find(contxt => {
|
|
437
|
+
if (typeof contxt === 'string') {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
const {
|
|
441
|
+
context: ctxt
|
|
442
|
+
} = contxt;
|
|
443
|
+
return ctxt === node.type;
|
|
444
|
+
}) || {};
|
|
445
|
+
const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
|
|
446
|
+
return fixer.insertTextBefore(/** @type {import('eslint').Rule.Node} */
|
|
447
|
+
baseNode, insertion);
|
|
448
|
+
};
|
|
449
|
+
const report = () => {
|
|
450
|
+
const {
|
|
451
|
+
start
|
|
452
|
+
} = /** @type {import('eslint').AST.SourceLocation} */node.loc;
|
|
453
|
+
const loc = {
|
|
454
|
+
end: {
|
|
455
|
+
column: 0,
|
|
456
|
+
line: start.line + 1
|
|
457
|
+
},
|
|
458
|
+
start
|
|
459
|
+
};
|
|
460
|
+
context.report({
|
|
461
|
+
fix: enableFixer ? fix : null,
|
|
462
|
+
loc,
|
|
463
|
+
messageId: 'missingJsDoc',
|
|
464
|
+
node
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
if (publicOnly) {
|
|
468
|
+
/** @type {RequireJsdocOpts} */
|
|
469
|
+
const opt = {
|
|
470
|
+
ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
|
|
471
|
+
esm: Boolean(publicOnly?.esm ?? true),
|
|
472
|
+
initModuleExports: Boolean(publicOnly?.cjs ?? true),
|
|
473
|
+
initWindow: Boolean(publicOnly?.window ?? false)
|
|
474
|
+
};
|
|
475
|
+
const exported = _exportParser.default.isUncommentedExport(node, sourceCode, opt, settings);
|
|
476
|
+
if (exported) {
|
|
477
|
+
report();
|
|
478
|
+
}
|
|
479
|
+
} else {
|
|
480
|
+
report();
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* @param {string} prop
|
|
486
|
+
* @returns {boolean}
|
|
487
|
+
*/
|
|
488
|
+
const hasOption = prop => {
|
|
489
|
+
return requireOption[prop] || contexts.some(ctxt => {
|
|
490
|
+
return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
|
|
491
|
+
});
|
|
492
|
+
};
|
|
493
|
+
return {
|
|
494
|
+
...(0, _jsdocUtils.getContextObject)((0, _jsdocUtils.enforcedContexts)(context, [], settings), checkJsDoc),
|
|
495
|
+
ArrowFunctionExpression(node) {
|
|
496
|
+
if (!hasOption('ArrowFunctionExpression')) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
|
|
500
|
+
/**
|
|
501
|
+
* @type {import('@typescript-eslint/types').TSESTree.Property|
|
|
502
|
+
* import('@typescript-eslint/types').TSESTree.PropertyDefinition
|
|
503
|
+
* }
|
|
504
|
+
*/
|
|
505
|
+
node.parent.value) {
|
|
506
|
+
checkJsDoc({
|
|
507
|
+
isFunctionContext: true
|
|
508
|
+
}, null, node);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
ClassDeclaration(node) {
|
|
512
|
+
if (!hasOption('ClassDeclaration')) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
checkJsDoc({
|
|
516
|
+
isFunctionContext: false
|
|
517
|
+
}, null, node);
|
|
518
|
+
},
|
|
519
|
+
ClassExpression(node) {
|
|
520
|
+
if (!hasOption('ClassExpression')) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
checkJsDoc({
|
|
524
|
+
isFunctionContext: false
|
|
525
|
+
}, null, node);
|
|
526
|
+
},
|
|
527
|
+
FunctionDeclaration(node) {
|
|
528
|
+
if (!hasOption('FunctionDeclaration')) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
checkJsDoc({
|
|
532
|
+
isFunctionContext: true
|
|
533
|
+
}, null, node);
|
|
534
|
+
},
|
|
535
|
+
FunctionExpression(node) {
|
|
536
|
+
if (!hasOption('FunctionExpression')) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
if (['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
|
|
540
|
+
/**
|
|
541
|
+
* @type {import('@typescript-eslint/types').TSESTree.Property|
|
|
542
|
+
* import('@typescript-eslint/types').TSESTree.PropertyDefinition
|
|
543
|
+
* }
|
|
544
|
+
*/
|
|
545
|
+
node.parent.value) {
|
|
546
|
+
checkJsDoc({
|
|
547
|
+
isFunctionContext: true
|
|
548
|
+
}, null, node);
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
MethodDefinition(node) {
|
|
552
|
+
if (!hasOption('MethodDefinition')) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
checkJsDoc({
|
|
556
|
+
isFunctionContext: true,
|
|
557
|
+
selector: 'MethodDefinition'
|
|
558
|
+
}, null, /** @type {import('eslint').Rule.Node} */node.value);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
},
|
|
562
|
+
meta: {
|
|
563
|
+
docs: {
|
|
564
|
+
category: 'Stylistic Issues',
|
|
565
|
+
description: 'Require JSDoc comments',
|
|
566
|
+
recommended: true,
|
|
567
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header'
|
|
568
|
+
},
|
|
569
|
+
fixable: 'code',
|
|
570
|
+
messages: {
|
|
571
|
+
missingJsDoc: 'Missing JSDoc comment.'
|
|
572
|
+
},
|
|
573
|
+
schema: [OPTIONS_SCHEMA],
|
|
574
|
+
type: 'suggestion'
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
module.exports = exports.default;
|
|
405
578
|
//# sourceMappingURL=requireJsdoc.cjs.map
|