@typescript-eslint/eslint-plugin 8.50.2-alpha.0 → 8.50.2-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.
|
@@ -57,8 +57,6 @@ exports.default = (0, util_1.createRule)({
|
|
|
57
57
|
create(context) {
|
|
58
58
|
const services = (0, util_1.getParserServices)(context);
|
|
59
59
|
const checker = services.program.getTypeChecker();
|
|
60
|
-
const compilerOptions = services.program.getCompilerOptions();
|
|
61
|
-
const isNoUncheckedIndexedAccess = tsutils.isCompilerOptionEnabled(compilerOptions, 'noUncheckedIndexedAccess');
|
|
62
60
|
function canBeUndefined(type) {
|
|
63
61
|
if ((0, util_1.isTypeAnyType)(type) || (0, util_1.isTypeUnknownType)(type)) {
|
|
64
62
|
return true;
|
|
@@ -70,10 +68,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
70
68
|
function getPropertyType(objectType, propertyName) {
|
|
71
69
|
const symbol = objectType.getProperty(propertyName);
|
|
72
70
|
if (!symbol) {
|
|
73
|
-
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
return objectType.getStringIndexType() ?? null;
|
|
71
|
+
return null;
|
|
77
72
|
}
|
|
78
73
|
return checker.getTypeOfSymbol(symbol);
|
|
79
74
|
}
|
|
@@ -84,9 +79,6 @@ exports.default = (0, util_1.createRule)({
|
|
|
84
79
|
return tupleArgs[elementIndex];
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
|
-
if (isNoUncheckedIndexedAccess) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
82
|
return arrayType.getNumberIndexType() ?? null;
|
|
91
83
|
}
|
|
92
84
|
function checkAssignmentPattern(node) {
|
|
@@ -111,6 +103,10 @@ exports.default = (0, util_1.createRule)({
|
|
|
111
103
|
return;
|
|
112
104
|
}
|
|
113
105
|
const signatures = contextualType.getCallSignatures();
|
|
106
|
+
if (signatures.length === 0 ||
|
|
107
|
+
signatures[0].getDeclaration() === tsFunc) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
114
110
|
const params = signatures[0].getParameters();
|
|
115
111
|
if (paramIndex < params.length) {
|
|
116
112
|
const paramSymbol = params[paramIndex];
|
|
@@ -139,11 +135,15 @@ exports.default = (0, util_1.createRule)({
|
|
|
139
135
|
if (!sourceType) {
|
|
140
136
|
return;
|
|
141
137
|
}
|
|
138
|
+
if (!checker.isTupleType(sourceType)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const tupleArgs = checker.getTypeArguments(sourceType);
|
|
142
142
|
const elementIndex = parent.elements.indexOf(node);
|
|
143
|
-
|
|
144
|
-
if (!elementType) {
|
|
143
|
+
if (elementIndex < 0 || elementIndex >= tupleArgs.length) {
|
|
145
144
|
return;
|
|
146
145
|
}
|
|
146
|
+
const elementType = tupleArgs[elementIndex];
|
|
147
147
|
if (!canBeUndefined(elementType)) {
|
|
148
148
|
reportUselessDefault(node, 'property', 'uselessDefaultAssignment');
|
|
149
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.50.2-alpha.
|
|
3
|
+
"version": "8.50.2-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.50.2-alpha.
|
|
63
|
-
"@typescript-eslint/type-utils": "8.50.2-alpha.
|
|
64
|
-
"@typescript-eslint/utils": "8.50.2-alpha.
|
|
65
|
-
"@typescript-eslint/visitor-keys": "8.50.2-alpha.
|
|
62
|
+
"@typescript-eslint/scope-manager": "8.50.2-alpha.2",
|
|
63
|
+
"@typescript-eslint/type-utils": "8.50.2-alpha.2",
|
|
64
|
+
"@typescript-eslint/utils": "8.50.2-alpha.2",
|
|
65
|
+
"@typescript-eslint/visitor-keys": "8.50.2-alpha.2",
|
|
66
66
|
"ignore": "^7.0.0",
|
|
67
67
|
"natural-compare": "^1.4.0",
|
|
68
68
|
"ts-api-utils": "^2.1.0"
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/mdast": "^4.0.3",
|
|
72
72
|
"@types/natural-compare": "*",
|
|
73
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.50.2-alpha.
|
|
74
|
-
"@typescript-eslint/rule-tester": "8.50.2-alpha.
|
|
73
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.50.2-alpha.2",
|
|
74
|
+
"@typescript-eslint/rule-tester": "8.50.2-alpha.2",
|
|
75
75
|
"@vitest/coverage-v8": "^3.1.3",
|
|
76
76
|
"ajv": "^6.12.6",
|
|
77
77
|
"cross-fetch": "*",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"vitest": "^3.1.3"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@typescript-eslint/parser": "^8.50.2-alpha.
|
|
94
|
+
"@typescript-eslint/parser": "^8.50.2-alpha.2",
|
|
95
95
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
96
96
|
"typescript": ">=4.8.4 <6.0.0"
|
|
97
97
|
},
|