eslint-plugin-jsdoc 37.9.3 → 37.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +349 -90
- package/dist/exportParser.js +3 -3
- package/dist/exportParser.js.map +1 -1
- package/dist/jsdocUtils.js +11 -1
- package/dist/jsdocUtils.js.map +1 -1
- package/dist/rules/requireReturns.js +1 -1
- package/dist/rules/requireReturns.js.map +1 -1
- package/package.json +7 -7
|
@@ -82,7 +82,7 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
82
82
|
return true;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(forceReturnsWithAsync);
|
|
85
|
+
return !isAsync && iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(forceReturnsWithAsync);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
if (shouldReport()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/requireReturns.js"],"names":["canSkip","utils","hasATag","avoidDocs","report","context","forceRequireReturn","forceReturnsWithAsync","options","tagName","getPreferredTagName","tags","getTags","length","iteratingFunction","isIteratingFunction","tag","missingReturnTag","shouldReport","isVirtualFunction","isAsync","hasTag","hasValueOrExecutorHasNonEmptyResolveValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","checkConstructors","default","type","checkGetters","contexts","items","anyOf","comment","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAO,GAAIC,KAAD,IAAW;AACzB,SAAOA,KAAK,CAACC,OAAN,CAAc,CACnB;AACA;AACA;AACA;AACA;AACA,YANmB,EAOnB,SAPmB,EASnB;AACA;AACA,SAXmB,EAYnB,aAZmB,EAcnB;AACA,QAfmB,EAiBnB;AACA,aAlBmB,CAAd,KAoBLD,KAAK,CAACE,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P;AACD;;AAED,
|
|
1
|
+
{"version":3,"sources":["../../src/rules/requireReturns.js"],"names":["canSkip","utils","hasATag","avoidDocs","report","context","forceRequireReturn","forceReturnsWithAsync","options","tagName","getPreferredTagName","tags","getTags","length","iteratingFunction","isIteratingFunction","tag","missingReturnTag","shouldReport","isVirtualFunction","isAsync","hasTag","hasValueOrExecutorHasNonEmptyResolveValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","checkConstructors","default","type","checkGetters","contexts","items","anyOf","comment","exemptedBy"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,OAAO,GAAIC,KAAD,IAAW;AACzB,SAAOA,KAAK,CAACC,OAAN,CAAc,CACnB;AACA;AACA;AACA;AACA;AACA,YANmB,EAOnB,SAPmB,EASnB;AACA;AACA,SAXmB,EAYnB,aAZmB,EAcnB;AACA,QAfmB,EAiBnB;AACA,aAlBmB,CAAd,KAoBLD,KAAK,CAACE,SAAN,EApBF;AAqBD,CAtBD;;eAwBe,2BAAa,CAAC;AAC3BC,EAAAA,MAD2B;AAE3BH,EAAAA,KAF2B;AAG3BI,EAAAA;AAH2B,CAAD,KAItB;AACJ,QAAM;AACJC,IAAAA,kBAAkB,GAAG,KADjB;AAEJC,IAAAA,qBAAqB,GAAG;AAFpB,MAGFF,OAAO,CAACG,OAAR,CAAgB,CAAhB,KAAsB,EAH1B,CADI,CAMJ;AACA;;AACA,MAAIR,OAAO,CAACC,KAAD,CAAX,EAAoB;AAClB;AACD;;AAED,QAAMQ,OAAO,GAAGR,KAAK,CAACS,mBAAN,CAA0B;AACxCD,IAAAA,OAAO,EAAE;AAD+B,GAA1B,CAAhB;;AAGA,MAAI,CAACA,OAAL,EAAc;AACZ;AACD;;AAED,QAAME,IAAI,GAAGV,KAAK,CAACW,OAAN,CAAcH,OAAd,CAAb;;AAEA,MAAIE,IAAI,CAACE,MAAL,GAAc,CAAlB,EAAqB;AACnB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,UAAAA,OAAO,EAAE,IADG;AAEZC,UAAAA,IAAI,EAAE;AAFM,SALJ;AASVE,QAAAA,QAAQ,EAAE;AACRC,UAAAA,KAAK,EAAE;AACLC,YAAAA,KAAK,EAAE,CACL;AACEJ,cAAAA,IAAI,EAAE;AADR,aADK,EAIL;AACEJ,cAAAA,oBAAoB,EAAE,KADxB;AAEEC,cAAAA,UAAU,EAAE;AACVQ,gBAAAA,OAAO,EAAE;AACPL,kBAAAA,IAAI,EAAE;AADC,iBADC;AAIV5B,gBAAAA,OAAO,EAAE;AACP4B,kBAAAA,IAAI,EAAE;AADC;AAJC,eAFd;AAUEA,cAAAA,IAAI,EAAE;AAVR,aAJK;AADF,WADC;AAoBRA,UAAAA,IAAI,EAAE;AApBE,SATA;AA+BVM,QAAAA,UAAU,EAAE;AACVH,UAAAA,KAAK,EAAE;AACLH,YAAAA,IAAI,EAAE;AADD,WADG;AAIVA,UAAAA,IAAI,EAAE;AAJI,SA/BF;AAqCV3B,QAAAA,kBAAkB,EAAE;AAClB0B,UAAAA,OAAO,EAAE,KADS;AAElBC,UAAAA,IAAI,EAAE;AAFY,SArCV;AAyCV1B,QAAAA,qBAAqB,EAAE;AACrByB,UAAAA,OAAO,EAAE,KADY;AAErBC,UAAAA,IAAI,EAAE;AAFe;AAzCb,OAFd;AAgDEA,MAAAA,IAAI,EAAE;AAhDR,KADM,CALJ;AAyDJA,IAAAA,IAAI,EAAE;AAzDF;AAFL,CA/DY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n/**\n * We can skip checking for a return value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n *\n * In either of these cases the return value is optional or not defined.\n *\n * @param {*} utils\n * a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean}\n * true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not an error if it declares a return value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html)\n // So we can bail out here, too.\n 'class',\n 'constructor',\n\n // Return type is specified by type in @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n context,\n}) => {\n const {\n forceRequireReturn = false,\n forceReturnsWithAsync = false,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @returns comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = utils.getPreferredTagName({\n tagName: 'returns',\n });\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n }\n\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingReturnTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingReturnTag) {\n return false;\n }\n\n if (forceRequireReturn && (\n iteratingFunction || utils.isVirtualFunction()\n )) {\n return true;\n }\n\n const isAsync = !iteratingFunction && utils.hasTag('async') ||\n iteratingFunction && utils.isAsync();\n\n if (forceReturnsWithAsync && isAsync) {\n return true;\n }\n\n return !isAsync && iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(\n forceReturnsWithAsync,\n );\n };\n\n if (shouldReport()) {\n report(`Missing JSDoc @${tagName} declaration.`);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that returns are documented.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkConstructors: {\n default: false,\n type: 'boolean',\n },\n checkGetters: {\n default: true,\n type: 'boolean',\n },\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireReturn: {\n default: false,\n type: 'boolean',\n },\n forceReturnsWithAsync: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"requireReturns.js"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"description": "JSDoc linting rules for ESLint.",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@babel/cli": "^7.17.
|
|
19
|
+
"@babel/cli": "^7.17.6",
|
|
20
20
|
"@babel/core": "^7.17.5",
|
|
21
21
|
"@babel/eslint-parser": "^7.17.0",
|
|
22
22
|
"@babel/node": "^7.16.8",
|
|
@@ -25,26 +25,26 @@
|
|
|
25
25
|
"@babel/preset-env": "^7.16.11",
|
|
26
26
|
"@babel/register": "^7.17.0",
|
|
27
27
|
"@hkdobrev/run-if-changed": "^0.3.1",
|
|
28
|
-
"@typescript-eslint/parser": "^5.
|
|
28
|
+
"@typescript-eslint/parser": "^5.13.0",
|
|
29
29
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
30
30
|
"babel-plugin-istanbul": "^6.1.1",
|
|
31
31
|
"camelcase": "^6.3.0",
|
|
32
32
|
"chai": "^4.3.6",
|
|
33
33
|
"cross-env": "^7.0.3",
|
|
34
34
|
"decamelize": "^5.0.1",
|
|
35
|
-
"eslint": "^8.
|
|
35
|
+
"eslint": "^8.10.0",
|
|
36
36
|
"eslint-config-canonical": "^33.0.1",
|
|
37
|
-
"gitdown": "^3.1.
|
|
37
|
+
"gitdown": "^3.1.5",
|
|
38
38
|
"glob": "^7.2.0",
|
|
39
39
|
"husky": "^7.0.4",
|
|
40
40
|
"lint-staged": "^12.3.4",
|
|
41
41
|
"lodash.defaultsdeep": "^4.6.1",
|
|
42
|
-
"mocha": "^9.2.
|
|
42
|
+
"mocha": "^9.2.1",
|
|
43
43
|
"nyc": "^15.1.0",
|
|
44
44
|
"open-editor": "^3.0.0",
|
|
45
45
|
"rimraf": "^3.0.2",
|
|
46
46
|
"semantic-release": "^19.0.2",
|
|
47
|
-
"typescript": "^4.
|
|
47
|
+
"typescript": "^4.6.2"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": "^12 || ^14 || ^16 || ^17"
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
|
|
117
117
|
"test-index": "npm run test-no-cov -- test/rules/index.js"
|
|
118
118
|
},
|
|
119
|
-
"version": "37.9.
|
|
119
|
+
"version": "37.9.6"
|
|
120
120
|
}
|