eslint-plugin-jsdoc 39.6.7 → 39.6.8

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 CHANGED
@@ -17813,7 +17813,7 @@ function quux () {
17813
17813
  // Message: JSDoc @returns declaration present but return expression not available in function.
17814
17814
 
17815
17815
  /**
17816
- * @returns Baz.
17816
+ * @returns {SomeType} Baz.
17817
17817
  */
17818
17818
  function foo() {
17819
17819
  switch (true) {
@@ -17827,7 +17827,7 @@ function foo() {
17827
17827
  // Message: JSDoc @returns declaration present but return expression not available in function.
17828
17828
 
17829
17829
  /**
17830
- * @returns Baz.
17830
+ * @returns {SomeType} Baz.
17831
17831
  */
17832
17832
  function foo() {
17833
17833
  switch (true) {
@@ -18243,6 +18243,16 @@ function assertNumber(val) {
18243
18243
  */
18244
18244
  export function readFixture(path: string): Promise<Buffer>;
18245
18245
 
18246
+ /**
18247
+ * Reads a test fixture.
18248
+ *
18249
+ * @param path The path to resolve relative to the fixture base. It will be normalized for the
18250
+ * operating system.
18251
+ *
18252
+ * @returns {SomeType} The file contents as buffer.
18253
+ */
18254
+ export function readFixture(path: string): Promise<Buffer>;
18255
+
18246
18256
  /**
18247
18257
  * Reads a test fixture.
18248
18258
  *
@@ -18430,6 +18440,41 @@ function foo( bar ) {
18430
18440
  return functionWithUnknownReturnType();
18431
18441
  }
18432
18442
  }
18443
+
18444
+ /**
18445
+ * @returns Baz.
18446
+ */
18447
+ function foo() {
18448
+ switch (true) {
18449
+ default:
18450
+ switch (false) {
18451
+ default: return;
18452
+ }
18453
+ return "baz";
18454
+ }
18455
+ };
18456
+
18457
+ /**
18458
+ * @returns Baz.
18459
+ */
18460
+ function foo() {
18461
+ switch (true) {
18462
+ default:
18463
+ switch (false) {
18464
+ default: return;
18465
+ }
18466
+ return "baz";
18467
+ }
18468
+ };
18469
+
18470
+ /**
18471
+ * @returns
18472
+ */
18473
+ const quux = (someVar) => {
18474
+ if (someVar) {
18475
+ return true;
18476
+ }
18477
+ };
18433
18478
  ````
18434
18479
 
18435
18480
 
@@ -69,7 +69,7 @@ var _default = (0, _iterateJsdoc.default)(({
69
69
  }
70
70
 
71
71
  // In case a return value is declared in JSDoc, we also expect one in the code.
72
- if (!returnNever && (reportMissingReturnForUndefinedTypes || !utils.mayBeUndefinedTypeTag(tag)) && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync, true) && (!exemptGenerators || !node.generator)) {
72
+ if (!returnNever && (reportMissingReturnForUndefinedTypes || !utils.mayBeUndefinedTypeTag(tag)) && (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync) || tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync, true)) && (!exemptGenerators || !node.generator)) {
73
73
  report(`JSDoc @${tagName} declaration present but return expression not available in function.`);
74
74
  }
75
75
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"requireReturnsCheck.js","names":["canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","iterateJsdoc","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","type","trim","test","returnNever","hasValueOrExecutorHasNonEmptyResolveValue","mayBeUndefinedTypeTag","generator","meta","docs","description","url","schema","additionalProperties","properties","default"],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n if (exemptAsync && utils.isAsync()) {\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 === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [\n tag,\n ] = tags;\n\n const type = tag.type.trim();\n\n // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions\n if (/asserts\\s/u.test(type)) {\n return;\n }\n\n const returnNever = type === 'never';\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !utils.mayBeUndefinedTypeTag(tag)\n ) &&\n !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n true,\n ) && (!exemptGenerators || !node.generator)\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-check',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n type: 'boolean',\n },\n exemptGenerators: {\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n 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AAC,CAAC;AAAA;AAAA"}
1
+ {"version":3,"file":"requireReturnsCheck.js","names":["canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","iterateJsdoc","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","type","trim","test","returnNever","hasValueOrExecutorHasNonEmptyResolveValue","mayBeUndefinedTypeTag","generator","meta","docs","description","url","schema","additionalProperties","properties","default"],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n if (exemptAsync && utils.isAsync()) {\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 === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [\n tag,\n ] = tags;\n\n const type = tag.type.trim();\n\n // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions\n if (/asserts\\s/u.test(type)) {\n return;\n }\n\n const returnNever = type === 'never';\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !utils.mayBeUndefinedTypeTag(tag)\n ) &&\n (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) ||\n tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n true,\n )) &&\n (!exemptGenerators || !node.generator)\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-returns-check',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n type: 'boolean',\n },\n exemptGenerators: {\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AAA2C;AAE3C,MAAMA,OAAO,GAAG,CAACC,KAAK,EAAEC,QAAQ,KAAK;EACnC,MAAMC,WAAW,GAAG;EAClB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,aAAa,EACb,WAAW,CACZ;EAED,IAAID,QAAQ,CAACE,IAAI,KAAK,SAAS,EAAE;IAC/B;IACAD,WAAW,CAACE,IAAI,CAAC,QAAQ,CAAC;EAC5B;EAEA,OAAOJ,KAAK,CAACK,OAAO,CAACH,WAAW,CAAC,IAC/BF,KAAK,CAACM,aAAa,EAAE,IACrBN,KAAK,CAACO,WAAW,CAAC,WAAW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AASM,OAAQ,6EAA4E,CAAC;IAEtG;EACF;;EAEA;EACA,IACE,CAACS,WAAW,KAEVZ,oCAAoC,IACpC,CAACd,KAAK,CAAC4B,qBAAqB,CAACN,GAAG,CAAC,CAClC,KACAA,GAAG,CAACC,IAAI,KAAK,EAAE,IAAI,CAACvB,KAAK,CAAC2B,yCAAyC,CAClEf,WAAW,CACZ,IACDU,GAAG,CAACC,IAAI,KAAK,EAAE,IAAI,CAACvB,KAAK,CAAC2B,yCAAyC,CACjEf,WAAW,EACX,IAAI,CACL,CAAC,KACD,CAACC,gBAAgB,IAAI,CAACH,IAAI,CAACmB,SAAS,CAAC,EACtC;IACAlB,MAAM,CAAE,UAASM,OAAQ,uEAAsE,CAAC;EAClG;AACF,CAAC,EAAE;EACDa,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,iGAAiG;MAC9GC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVxB,WAAW,EAAE;UACXyB,OAAO,EAAE,IAAI;UACbd,IAAI,EAAE;QACR,CAAC;QACDV,gBAAgB,EAAE;UAChBU,IAAI,EAAE;QACR,CAAC;QACDT,oCAAoC,EAAE;UACpCuB,OAAO,EAAE,KAAK;UACdd,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
package/package.json CHANGED
@@ -120,5 +120,5 @@
120
120
  "test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
121
121
  "test-index": "npm run test-no-cov -- test/rules/index.js"
122
122
  },
123
- "version": "39.6.7"
123
+ "version": "39.6.8"
124
124
  }