@typescript-eslint/eslint-plugin 8.51.1-alpha.1 → 8.51.1-alpha.10
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.
|
@@ -66,13 +66,6 @@ exports.default = (0, util_1.createRule)({
|
|
|
66
66
|
.unionConstituents(type)
|
|
67
67
|
.some(part => (0, util_1.isTypeFlagSet)(part, ts.TypeFlags.Undefined));
|
|
68
68
|
}
|
|
69
|
-
function getPropertyType(objectType, propertyName) {
|
|
70
|
-
const symbol = objectType.getProperty(propertyName);
|
|
71
|
-
if (!symbol) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return checker.getTypeOfSymbol(symbol);
|
|
75
|
-
}
|
|
76
69
|
function getArrayElementType(arrayType, elementIndex) {
|
|
77
70
|
if (checker.isTupleType(arrayType)) {
|
|
78
71
|
const tupleArgs = checker.getTypeArguments(arrayType);
|
|
@@ -167,7 +160,26 @@ exports.default = (0, util_1.createRule)({
|
|
|
167
160
|
if (!propertyName) {
|
|
168
161
|
return null;
|
|
169
162
|
}
|
|
170
|
-
|
|
163
|
+
const symbol = sourceType.getProperty(propertyName);
|
|
164
|
+
if (!symbol) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
if (symbol.flags & ts.SymbolFlags.Optional &&
|
|
168
|
+
hasConditionalInitializer(objectPattern)) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return checker.getTypeOfSymbol(symbol);
|
|
172
|
+
}
|
|
173
|
+
function hasConditionalInitializer(node) {
|
|
174
|
+
const parent = node.parent;
|
|
175
|
+
if (!parent) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (parent.type === utils_1.AST_NODE_TYPES.VariableDeclarator && parent.init) {
|
|
179
|
+
return (parent.init.type === utils_1.AST_NODE_TYPES.ConditionalExpression ||
|
|
180
|
+
parent.init.type === utils_1.AST_NODE_TYPES.LogicalExpression);
|
|
181
|
+
}
|
|
182
|
+
return hasConditionalInitializer(parent);
|
|
171
183
|
}
|
|
172
184
|
function getSourceTypeForPattern(pattern) {
|
|
173
185
|
const parent = (0, util_1.nullThrows)(pattern.parent, util_1.NullThrowsReasons.MissingParent);
|
|
@@ -189,12 +201,11 @@ exports.default = (0, util_1.createRule)({
|
|
|
189
201
|
return getTypeOfProperty(parent);
|
|
190
202
|
}
|
|
191
203
|
if (parent.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
|
|
192
|
-
const
|
|
193
|
-
const arrayType = getSourceTypeForPattern(arrayPattern);
|
|
204
|
+
const arrayType = getSourceTypeForPattern(parent);
|
|
194
205
|
if (!arrayType) {
|
|
195
206
|
return null;
|
|
196
207
|
}
|
|
197
|
-
const elementIndex =
|
|
208
|
+
const elementIndex = parent.elements.indexOf(pattern);
|
|
198
209
|
return getArrayElementType(arrayType, elementIndex);
|
|
199
210
|
}
|
|
200
211
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.51.1-alpha.
|
|
3
|
+
"version": "8.51.1-alpha.10",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -58,39 +58,39 @@
|
|
|
58
58
|
"typecheck": "yarn run -BT nx typecheck"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@eslint-community/regexpp": "^4.
|
|
62
|
-
"@typescript-eslint/scope-manager": "8.51.1-alpha.
|
|
63
|
-
"@typescript-eslint/type-utils": "8.51.1-alpha.
|
|
64
|
-
"@typescript-eslint/utils": "8.51.1-alpha.
|
|
65
|
-
"@typescript-eslint/visitor-keys": "8.51.1-alpha.
|
|
66
|
-
"ignore": "^7.0.
|
|
61
|
+
"@eslint-community/regexpp": "^4.12.2",
|
|
62
|
+
"@typescript-eslint/scope-manager": "8.51.1-alpha.10",
|
|
63
|
+
"@typescript-eslint/type-utils": "8.51.1-alpha.10",
|
|
64
|
+
"@typescript-eslint/utils": "8.51.1-alpha.10",
|
|
65
|
+
"@typescript-eslint/visitor-keys": "8.51.1-alpha.10",
|
|
66
|
+
"ignore": "^7.0.5",
|
|
67
67
|
"natural-compare": "^1.4.0",
|
|
68
|
-
"ts-api-utils": "^2.
|
|
68
|
+
"ts-api-utils": "^2.4.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@types/mdast": "^4.0.
|
|
71
|
+
"@types/mdast": "^4.0.4",
|
|
72
72
|
"@types/natural-compare": "*",
|
|
73
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.51.1-alpha.
|
|
74
|
-
"@typescript-eslint/rule-tester": "8.51.1-alpha.
|
|
75
|
-
"@vitest/coverage-v8": "^3.
|
|
73
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.51.1-alpha.10",
|
|
74
|
+
"@typescript-eslint/rule-tester": "8.51.1-alpha.10",
|
|
75
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
76
76
|
"ajv": "^6.12.6",
|
|
77
77
|
"eslint": "*",
|
|
78
78
|
"json-schema": "*",
|
|
79
|
-
"markdown-table": "^3.0.
|
|
80
|
-
"marked": "^15.0.
|
|
81
|
-
"mdast-util-from-markdown": "^2.0.
|
|
79
|
+
"markdown-table": "^3.0.4",
|
|
80
|
+
"marked": "^15.0.12",
|
|
81
|
+
"mdast-util-from-markdown": "^2.0.2",
|
|
82
82
|
"mdast-util-mdx": "^3.0.0",
|
|
83
83
|
"micromark-extension-mdxjs": "^3.0.0",
|
|
84
|
-
"prettier": "3.7.
|
|
84
|
+
"prettier": "3.7.4",
|
|
85
85
|
"rimraf": "*",
|
|
86
|
-
"title-case": "^4.
|
|
86
|
+
"title-case": "^4.3.2",
|
|
87
87
|
"tsx": "*",
|
|
88
88
|
"typescript": "*",
|
|
89
89
|
"unist-util-visit": "^5.0.0",
|
|
90
|
-
"vitest": "^3.
|
|
90
|
+
"vitest": "^3.2.4"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"@typescript-eslint/parser": "^8.51.1-alpha.
|
|
93
|
+
"@typescript-eslint/parser": "^8.51.1-alpha.10",
|
|
94
94
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
95
95
|
"typescript": ">=4.8.4 <6.0.0"
|
|
96
96
|
},
|