eslint-plugin-complete 1.0.12 → 1.0.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"no-mutable-return.d.ts","sourceRoot":"","sources":["../../src/rules/no-mutable-return.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMvD,KAAK,UAAU,GAAG,cAAc,GAAG,YAAY,GAAG,YAAY,CAAC;AAE/D,eAAO,MAAM,eAAe,wHAoD1B,CAAC"}
1
+ {"version":3,"file":"no-mutable-return.d.ts","sourceRoot":"","sources":["../../src/rules/no-mutable-return.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMvD,KAAK,UAAU,GAAG,cAAc,GAAG,YAAY,GAAG,YAAY,CAAC;AAE/D,eAAO,MAAM,eAAe,wHAsD1B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { isTypeReferenceType } from "@typescript-eslint/type-utils";
1
+ import { isPromiseLike, isTypeReferenceType, } from "@typescript-eslint/type-utils";
2
2
  import { ESLintUtils } from "@typescript-eslint/utils";
3
3
  import { getTypeName, unionTypeParts } from "../typeUtils.js";
4
4
  import { createRule } from "../utils.js";
@@ -28,7 +28,8 @@ export const noMutableReturn = createRule({
28
28
  const signatures = type.getCallSignatures();
29
29
  for (const signature of signatures) {
30
30
  const returnType = signature.getReturnType();
31
- for (const t of unionTypeParts(returnType)) {
31
+ const realReturnType = getRealType(parserServices.program, returnType);
32
+ for (const t of unionTypeParts(realReturnType)) {
32
33
  const messageId = getErrorMessageId(t);
33
34
  if (messageId !== undefined) {
34
35
  context.report({
@@ -47,20 +48,23 @@ export const noMutableReturn = createRule({
47
48
  };
48
49
  },
49
50
  });
50
- function getErrorMessageId(type) {
51
- const typeName = getTypeName(type);
52
- if (typeName === undefined) {
53
- return undefined;
54
- }
55
- // Handle unwrapping promises.
56
- if (typeName === "Promise"
51
+ /** If the type is a `Promise`, this will unwrap it. */
52
+ function getRealType(program, type) {
53
+ if (isPromiseLike(program, type)
57
54
  && isTypeReferenceType(type)
58
55
  && type.typeArguments !== undefined) {
59
56
  const typeArgument = type.typeArguments[0];
60
57
  if (typeArgument !== undefined) {
61
- return getErrorMessageId(typeArgument);
58
+ return typeArgument;
62
59
  }
63
60
  }
61
+ return type;
62
+ }
63
+ function getErrorMessageId(type) {
64
+ const typeName = getTypeName(type);
65
+ if (typeName === undefined) {
66
+ return undefined;
67
+ }
64
68
  // This would be "ReadonlyMap" if it was the read-only version.
65
69
  if (typeName === "Map") {
66
70
  return "mutableMap";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-complete",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "An ESLint plugin that contains useful rules.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -53,11 +53,11 @@
53
53
  "@babel/preset-env": "7.26.9",
54
54
  "@babel/preset-typescript": "7.26.0",
55
55
  "@types/jest": "29.5.14",
56
- "@types/node": "22.13.9",
56
+ "@types/node": "22.13.10",
57
57
  "@typescript-eslint/rule-tester": "8.26.0",
58
58
  "@typescript-eslint/types": "8.26.0",
59
- "complete-common": "1.3.0",
60
- "complete-node": "5.1.1",
59
+ "complete-common": "2.0.0",
60
+ "complete-node": "5.1.2",
61
61
  "jest": "29.7.0",
62
62
  "prettier": "3.5.3",
63
63
  "typescript": "5.8.2"