@typescript-eslint/eslint-plugin 8.71.3-alpha.13 → 8.71.3-alpha.15

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.
@@ -380,7 +380,7 @@ exports.default = (0, util_1.createRule)({
380
380
  return;
381
381
  }
382
382
  const propertyType = services.getTypeAtLocation(node.property);
383
- if (propertyType.isLiteral()) {
383
+ if ((0, util_1.isTypeLiteralType)(propertyType)) {
384
384
  const objectType = services.getTypeAtLocation(node.object);
385
385
  const propertyName = propertyType.isStringLiteral()
386
386
  ? propertyType.value
@@ -94,7 +94,7 @@ function describeLiteralType(type) {
94
94
  if ((0, util_1.isTypeBigIntLiteralType)(type)) {
95
95
  return `${type.value.negative ? '-' : ''}${type.value.base10Value}n`;
96
96
  }
97
- if (type.isLiteral()) {
97
+ if ((0, util_1.isTypeLiteralType)(type)) {
98
98
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
99
99
  return type.value.toString();
100
100
  }
@@ -66,7 +66,7 @@ function isPossiblyNonNullish(type) {
66
66
  .some(t => !isNullishType(t) && !(0, util_1.isTypeFlagSet)(t, ts.TypeFlags.Void));
67
67
  }
68
68
  function toStaticValue(type) {
69
- // type.isLiteral() only covers numbers/bigints and strings, hence the rest of the branches.
69
+ // isTypeLiteralType() only covers numbers/bigints and strings, hence the rest of the branches.
70
70
  if (tsutils.isBooleanLiteralType(type)) {
71
71
  return { value: tsutils.isTrueLiteralType(type) };
72
72
  }
@@ -76,7 +76,7 @@ function toStaticValue(type) {
76
76
  if (type.flags === ts.TypeFlags.Null) {
77
77
  return { value: null };
78
78
  }
79
- if (type.isLiteral()) {
79
+ if ((0, util_1.isTypeLiteralType)(type)) {
80
80
  return { value: (0, util_1.getValueOfLiteralType)(type) };
81
81
  }
82
82
  return undefined;
@@ -217,7 +217,7 @@ exports.default = (0, util_1.createRule)({
217
217
  return areMutuallyAssignable(uncast, cast);
218
218
  }
219
219
  function isTypeLiteral(type) {
220
- return type.isLiteral() || tsutils.isBooleanLiteralType(type);
220
+ return (0, util_1.isTypeLiteralType)(type) || tsutils.isBooleanLiteralType(type);
221
221
  }
222
222
  function hasIndexSignature(type) {
223
223
  return tsutils
@@ -1,5 +1,39 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ const tsutils = __importStar(require("ts-api-utils"));
3
37
  const util_1 = require("../util");
4
38
  exports.default = (0, util_1.createRule)({
5
39
  name: 'require-array-sort-compare',
@@ -40,7 +74,10 @@ exports.default = (0, util_1.createRule)({
40
74
  function isStringArrayNode(node) {
41
75
  const type = (0, util_1.getConstrainedTypeAtLocation)(services, node);
42
76
  if (checker.isArrayType(type) || checker.isTupleType(type)) {
43
- const typeArgs = checker.getTypeArguments(type);
77
+ // Before TS 5.1, a constrained type parameter's array type has an extra `this` type argument
78
+ const typeArgs = checker
79
+ .getTypeArguments(type)
80
+ .slice(0, type.target.typeParameters?.length);
44
81
  return typeArgs.every(arg => {
45
82
  const typeName = (0, util_1.getTypeName)(checker, checker.getBaseConstraintOfType(arg) ?? arg);
46
83
  return typeName === 'string';
@@ -56,7 +93,7 @@ exports.default = (0, util_1.createRule)({
56
93
  if (options.ignoreStringArrays && isStringArrayNode(callee.object)) {
57
94
  return;
58
95
  }
59
- if ((0, util_1.isTypeArrayTypeOrUnionOfArrayTypes)(calleeObjType, checker)) {
96
+ if (isAlwaysArray(calleeObjType, checker)) {
60
97
  context.report({ node: callee.parent, messageId: 'requireCompare' });
61
98
  }
62
99
  }
@@ -65,4 +102,9 @@ exports.default = (0, util_1.createRule)({
65
102
  };
66
103
  },
67
104
  });
105
+ function isAlwaysArray(type, checker) {
106
+ return tsutils
107
+ .unionConstituents(type)
108
+ .every(t => checker.isArrayType(t) || checker.isTupleType(t));
109
+ }
68
110
  //# sourceMappingURL=require-array-sort-compare.js.map
@@ -34,12 +34,13 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.isPossiblyTruthy = exports.isPossiblyFalsy = void 0;
37
+ const type_utils_1 = require("@typescript-eslint/type-utils");
37
38
  const tsutils = __importStar(require("ts-api-utils"));
38
39
  const ts = __importStar(require("typescript"));
39
40
  const getValueOfLiteralType_1 = require("./getValueOfLiteralType");
40
41
  // Truthiness utilities
41
42
  const isTruthyLiteral = (type) => tsutils.isTrueLiteralType(type) ||
42
- (type.isLiteral() && !!(0, getValueOfLiteralType_1.getValueOfLiteralType)(type));
43
+ ((0, type_utils_1.isTypeLiteralType)(type) && !!(0, getValueOfLiteralType_1.getValueOfLiteralType)(type));
43
44
  const isPossiblyFalsy = (type) => tsutils
44
45
  .unionConstituents(type)
45
46
  // Intersections like `string & {}` can also be possibly falsy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.71.3-alpha.13",
3
+ "version": "8.71.3-alpha.15",
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.3-alpha.13",
51
- "@typescript-eslint/type-utils": "8.71.3-alpha.13",
52
- "@typescript-eslint/utils": "8.71.3-alpha.13",
53
- "@typescript-eslint/visitor-keys": "8.71.3-alpha.13",
50
+ "@typescript-eslint/scope-manager": "8.71.3-alpha.15",
51
+ "@typescript-eslint/type-utils": "8.71.3-alpha.15",
52
+ "@typescript-eslint/utils": "8.71.3-alpha.15",
53
+ "@typescript-eslint/visitor-keys": "8.71.3-alpha.15",
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.3-alpha.13",
64
- "@typescript-eslint/rule-tester": "8.71.3-alpha.13",
63
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.71.3-alpha.15",
64
+ "@typescript-eslint/rule-tester": "8.71.3-alpha.15",
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.3-alpha.13",
84
+ "@typescript-eslint/parser": "^8.71.3-alpha.15",
85
85
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
86
86
  "typescript": ">=4.8.4 <6.1.0"
87
87
  },