@typescript-eslint/eslint-plugin 8.44.1-alpha.0 → 8.44.1-alpha.2
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-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;;
|
|
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;;AAS1D,wBA8UG"}
|
|
@@ -43,6 +43,11 @@ var Usefulness;
|
|
|
43
43
|
Usefulness["Never"] = "will";
|
|
44
44
|
Usefulness["Sometimes"] = "may";
|
|
45
45
|
})(Usefulness || (Usefulness = {}));
|
|
46
|
+
const canHaveTypeParameters = (declaration) => {
|
|
47
|
+
return (ts.isTypeAliasDeclaration(declaration) ||
|
|
48
|
+
ts.isInterfaceDeclaration(declaration) ||
|
|
49
|
+
ts.isClassDeclaration(declaration));
|
|
50
|
+
};
|
|
46
51
|
exports.default = (0, util_1.createRule)({
|
|
47
52
|
name: 'no-base-to-string',
|
|
48
53
|
meta: {
|
|
@@ -184,6 +189,14 @@ exports.default = (0, util_1.createRule)({
|
|
|
184
189
|
type.flags & ts.TypeFlags.BooleanLiteral) {
|
|
185
190
|
return Usefulness.Always;
|
|
186
191
|
}
|
|
192
|
+
const symbol = type.aliasSymbol ?? type.getSymbol();
|
|
193
|
+
const decl = symbol?.getDeclarations()?.[0];
|
|
194
|
+
if (decl &&
|
|
195
|
+
canHaveTypeParameters(decl) &&
|
|
196
|
+
decl.typeParameters &&
|
|
197
|
+
ignoredTypeNames.includes(symbol.name)) {
|
|
198
|
+
return Usefulness.Always;
|
|
199
|
+
}
|
|
187
200
|
if (ignoredTypeNames.includes((0, util_1.getTypeName)(checker, type))) {
|
|
188
201
|
return Usefulness.Always;
|
|
189
202
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unsafe-enum-comparison.d.ts","sourceRoot":"","sources":["../../src/rules/no-unsafe-enum-comparison.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;;
|
|
1
|
+
{"version":3,"file":"no-unsafe-enum-comparison.d.ts","sourceRoot":"","sources":["../../src/rules/no-unsafe-enum-comparison.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;;AAiEnE,wBAsJG"}
|
|
@@ -46,16 +46,18 @@ function typeViolates(leftTypeParts, rightType) {
|
|
|
46
46
|
(leftEnumValueTypes.has(ts.TypeFlags.String) && isStringLike(rightType)));
|
|
47
47
|
}
|
|
48
48
|
function isNumberLike(type) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
return tsutils
|
|
50
|
+
.unionConstituents(type)
|
|
51
|
+
.every(unionPart => tsutils
|
|
52
|
+
.intersectionConstituents(unionPart)
|
|
53
|
+
.some(intersectionPart => tsutils.isTypeFlagSet(intersectionPart, ts.TypeFlags.Number | ts.TypeFlags.NumberLike)));
|
|
53
54
|
}
|
|
54
55
|
function isStringLike(type) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
return tsutils
|
|
57
|
+
.unionConstituents(type)
|
|
58
|
+
.every(unionPart => tsutils
|
|
59
|
+
.intersectionConstituents(unionPart)
|
|
60
|
+
.some(intersectionPart => tsutils.isTypeFlagSet(intersectionPart, ts.TypeFlags.String | ts.TypeFlags.StringLike)));
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* @returns What type a type's enum value is (number or string), if either.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.44.1-alpha.
|
|
3
|
+
"version": "8.44.1-alpha.2",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@eslint-community/regexpp": "^4.10.0",
|
|
62
|
-
"@typescript-eslint/scope-manager": "8.44.1-alpha.
|
|
63
|
-
"@typescript-eslint/type-utils": "8.44.1-alpha.
|
|
64
|
-
"@typescript-eslint/utils": "8.44.1-alpha.
|
|
65
|
-
"@typescript-eslint/visitor-keys": "8.44.1-alpha.
|
|
62
|
+
"@typescript-eslint/scope-manager": "8.44.1-alpha.2",
|
|
63
|
+
"@typescript-eslint/type-utils": "8.44.1-alpha.2",
|
|
64
|
+
"@typescript-eslint/utils": "8.44.1-alpha.2",
|
|
65
|
+
"@typescript-eslint/visitor-keys": "8.44.1-alpha.2",
|
|
66
66
|
"graphemer": "^1.4.0",
|
|
67
67
|
"ignore": "^7.0.0",
|
|
68
68
|
"natural-compare": "^1.4.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/mdast": "^4.0.3",
|
|
73
73
|
"@types/natural-compare": "*",
|
|
74
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.44.1-alpha.
|
|
75
|
-
"@typescript-eslint/rule-tester": "8.44.1-alpha.
|
|
74
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.44.1-alpha.2",
|
|
75
|
+
"@typescript-eslint/rule-tester": "8.44.1-alpha.2",
|
|
76
76
|
"@vitest/coverage-v8": "^3.1.3",
|
|
77
77
|
"ajv": "^6.12.6",
|
|
78
78
|
"cross-fetch": "*",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"vitest": "^3.1.3"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@typescript-eslint/parser": "^8.44.1-alpha.
|
|
95
|
+
"@typescript-eslint/parser": "^8.44.1-alpha.2",
|
|
96
96
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
97
97
|
"typescript": ">=4.8.4 <6.0.0"
|
|
98
98
|
},
|