@typescript-eslint/eslint-plugin 8.34.2-alpha.3 → 8.35.1-alpha.0

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,6 +1,7 @@
1
1
  export type Options = [
2
2
  {
3
3
  ignoredTypeNames?: string[];
4
+ checkUnknown?: boolean;
4
5
  }
5
6
  ];
6
7
  export type MessageIds = 'baseArrayJoin' | 'baseToString';
@@ -1 +1 @@
1
- {"version":3,"file":"no-base-to-string.d.ts","sourceRoot":"","sources":["../../src/rules/no-base-to-string.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC7B;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,cAAc,CAAC;;AAE1D,wBAwTG"}
1
+ {"version":3,"file":"no-base-to-string.d.ts","sourceRoot":"","sources":["../../src/rules/no-base-to-string.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,cAAc,CAAC;;AAE1D,wBAmUG"}
@@ -61,6 +61,10 @@ exports.default = (0, util_1.createRule)({
61
61
  type: 'object',
62
62
  additionalProperties: false,
63
63
  properties: {
64
+ checkUnknown: {
65
+ type: 'boolean',
66
+ description: 'Whether to also check values of type `unknown`',
67
+ },
64
68
  ignoredTypeNames: {
65
69
  type: 'array',
66
70
  description: 'Stringified regular expressions of type names to ignore.',
@@ -74,6 +78,7 @@ exports.default = (0, util_1.createRule)({
74
78
  },
75
79
  defaultOptions: [
76
80
  {
81
+ checkUnknown: false,
77
82
  ignoredTypeNames: ['Error', 'RegExp', 'URL', 'URLSearchParams'],
78
83
  },
79
84
  ],
@@ -172,7 +177,7 @@ exports.default = (0, util_1.createRule)({
172
177
  return collectToStringCertainty(constraint, visited);
173
178
  }
174
179
  // unconstrained generic means `unknown`
175
- return Usefulness.Always;
180
+ return option.checkUnknown ? Usefulness.Sometimes : Usefulness.Always;
176
181
  }
177
182
  // the Boolean type definition missing toString()
178
183
  if (type.flags & ts.TypeFlags.Boolean ||
@@ -197,7 +202,11 @@ exports.default = (0, util_1.createRule)({
197
202
  const toString = checker.getPropertyOfType(type, 'toString') ??
198
203
  checker.getPropertyOfType(type, 'toLocaleString');
199
204
  if (!toString) {
200
- // e.g. any/unknown
205
+ // unknown
206
+ if (option.checkUnknown && type.flags === ts.TypeFlags.Unknown) {
207
+ return Usefulness.Sometimes;
208
+ }
209
+ // e.g. any
201
210
  return Usefulness.Always;
202
211
  }
203
212
  const declarations = toString.getDeclarations();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.34.2-alpha.3",
3
+ "version": "8.35.1-alpha.0",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -60,10 +60,10 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@eslint-community/regexpp": "^4.10.0",
63
- "@typescript-eslint/scope-manager": "8.34.2-alpha.3",
64
- "@typescript-eslint/type-utils": "8.34.2-alpha.3",
65
- "@typescript-eslint/utils": "8.34.2-alpha.3",
66
- "@typescript-eslint/visitor-keys": "8.34.2-alpha.3",
63
+ "@typescript-eslint/scope-manager": "8.35.1-alpha.0",
64
+ "@typescript-eslint/type-utils": "8.35.1-alpha.0",
65
+ "@typescript-eslint/utils": "8.35.1-alpha.0",
66
+ "@typescript-eslint/visitor-keys": "8.35.1-alpha.0",
67
67
  "graphemer": "^1.4.0",
68
68
  "ignore": "^7.0.0",
69
69
  "natural-compare": "^1.4.0",
@@ -72,8 +72,8 @@
72
72
  "devDependencies": {
73
73
  "@types/mdast": "^4.0.3",
74
74
  "@types/natural-compare": "*",
75
- "@typescript-eslint/rule-schema-to-typescript-types": "8.34.2-alpha.3",
76
- "@typescript-eslint/rule-tester": "8.34.2-alpha.3",
75
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.35.1-alpha.0",
76
+ "@typescript-eslint/rule-tester": "8.35.1-alpha.0",
77
77
  "@vitest/coverage-v8": "^3.1.3",
78
78
  "ajv": "^6.12.6",
79
79
  "cross-fetch": "*",
@@ -93,7 +93,7 @@
93
93
  "vitest": "^3.1.3"
94
94
  },
95
95
  "peerDependencies": {
96
- "@typescript-eslint/parser": "^8.34.2-alpha.3",
96
+ "@typescript-eslint/parser": "^8.35.1-alpha.0",
97
97
  "eslint": "^8.57.0 || ^9.0.0",
98
98
  "typescript": ">=4.8.4 <5.9.0"
99
99
  },