@typescript-eslint/eslint-plugin 8.71.1-alpha.10 → 8.71.1-alpha.11

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.
@@ -317,7 +317,27 @@ exports.default = (0, util_1.createRule)({
317
317
  ? node.argument
318
318
  : node.body;
319
319
  const type = (0, util_1.getConstrainedTypeAtLocation)(services, targetNode);
320
- return tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike);
320
+ if (!tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike)) {
321
+ return false;
322
+ }
323
+ const functionNode = (0, util_1.nullThrows)(node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression
324
+ ? node
325
+ : (0, getParentFunctionNode_1.getParentFunctionNode)(node), 'Expected a return statement to be inside a function.');
326
+ return functionDeclarationAllowsEmptyReturn(functionNode);
327
+ }
328
+ function functionDeclarationAllowsEmptyReturn(functionNode) {
329
+ if (!functionNode.returnType) {
330
+ return true;
331
+ }
332
+ const declaredReturnType = services.getTypeFromTypeNode(functionNode.returnType.typeAnnotation);
333
+ const checker = services.program.getTypeChecker();
334
+ const resolvedReturnType = functionNode.async
335
+ ? (checker.getAwaitedType(declaredReturnType) ?? declaredReturnType)
336
+ : declaredReturnType;
337
+ return tsutils
338
+ .unionConstituents(resolvedReturnType)
339
+ .some(part => tsutils.isTypeFlagSet(part, ts.TypeFlags.Any) ||
340
+ tsutils.isTypeFlagSet(part, ts.TypeFlags.VoidLike));
321
341
  }
322
342
  function isFunctionReturnTypeIncludesVoid(functionType) {
323
343
  const callSignatures = tsutils.getCallSignaturesOfType(functionType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.71.1-alpha.10",
3
+ "version": "8.71.1-alpha.11",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -47,10 +47,10 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@eslint-community/regexpp": "^4.12.2",
50
- "@typescript-eslint/scope-manager": "8.71.1-alpha.10",
51
- "@typescript-eslint/type-utils": "8.71.1-alpha.10",
52
- "@typescript-eslint/utils": "8.71.1-alpha.10",
53
- "@typescript-eslint/visitor-keys": "8.71.1-alpha.10",
50
+ "@typescript-eslint/scope-manager": "8.71.1-alpha.11",
51
+ "@typescript-eslint/type-utils": "8.71.1-alpha.11",
52
+ "@typescript-eslint/utils": "8.71.1-alpha.11",
53
+ "@typescript-eslint/visitor-keys": "8.71.1-alpha.11",
54
54
  "ignore": "^7.0.5",
55
55
  "natural-compare": "^1.4.0",
56
56
  "ts-api-utils": "^2.5.0"
@@ -60,8 +60,8 @@
60
60
  "@types/mdast": "^4.0.4",
61
61
  "@types/natural-compare": "^1.4.3",
62
62
  "@types/react": "^18.3.21",
63
- "@typescript-eslint/rule-schema-to-typescript-types": "8.71.1-alpha.10",
64
- "@typescript-eslint/rule-tester": "8.71.1-alpha.10",
63
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.71.1-alpha.11",
64
+ "@typescript-eslint/rule-tester": "8.71.1-alpha.11",
65
65
  "@typescript/native": "npm:typescript@^7.0.2",
66
66
  "@vitest/coverage-v8": "^4.0.18",
67
67
  "ajv": "^6.12.6",
@@ -81,7 +81,7 @@
81
81
  "vitest": "^4.0.18"
82
82
  },
83
83
  "peerDependencies": {
84
- "@typescript-eslint/parser": "^8.71.1-alpha.10",
84
+ "@typescript-eslint/parser": "^8.71.1-alpha.11",
85
85
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
86
86
  "typescript": ">=4.8.4 <6.1.0"
87
87
  },