es-check 9.6.2 → 9.6.3
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.
|
@@ -43,6 +43,7 @@ const ES16_FEATURES = {
|
|
|
43
43
|
astInfo: {
|
|
44
44
|
nodeType: "CallExpression",
|
|
45
45
|
property: "union",
|
|
46
|
+
requireSetLikeCall: true,
|
|
46
47
|
},
|
|
47
48
|
},
|
|
48
49
|
SetIntersection: {
|
|
@@ -51,6 +52,7 @@ const ES16_FEATURES = {
|
|
|
51
52
|
astInfo: {
|
|
52
53
|
nodeType: "CallExpression",
|
|
53
54
|
property: "intersection",
|
|
55
|
+
requireSetLikeCall: true,
|
|
54
56
|
},
|
|
55
57
|
},
|
|
56
58
|
SetDifference: {
|
|
@@ -59,6 +61,7 @@ const ES16_FEATURES = {
|
|
|
59
61
|
astInfo: {
|
|
60
62
|
nodeType: "CallExpression",
|
|
61
63
|
property: "difference",
|
|
64
|
+
requireSetLikeCall: true,
|
|
62
65
|
},
|
|
63
66
|
},
|
|
64
67
|
SetSymmetricDifference: {
|
|
@@ -67,6 +70,7 @@ const ES16_FEATURES = {
|
|
|
67
70
|
astInfo: {
|
|
68
71
|
nodeType: "CallExpression",
|
|
69
72
|
property: "symmetricDifference",
|
|
73
|
+
requireSetLikeCall: true,
|
|
70
74
|
},
|
|
71
75
|
},
|
|
72
76
|
SetIsSubsetOf: {
|
|
@@ -75,6 +79,7 @@ const ES16_FEATURES = {
|
|
|
75
79
|
astInfo: {
|
|
76
80
|
nodeType: "CallExpression",
|
|
77
81
|
property: "isSubsetOf",
|
|
82
|
+
requireSetLikeCall: true,
|
|
78
83
|
},
|
|
79
84
|
},
|
|
80
85
|
SetIsSupersetOf: {
|
|
@@ -83,6 +88,7 @@ const ES16_FEATURES = {
|
|
|
83
88
|
astInfo: {
|
|
84
89
|
nodeType: "CallExpression",
|
|
85
90
|
property: "isSupersetOf",
|
|
91
|
+
requireSetLikeCall: true,
|
|
86
92
|
},
|
|
87
93
|
},
|
|
88
94
|
SetIsDisjointFrom: {
|
|
@@ -91,6 +97,7 @@ const ES16_FEATURES = {
|
|
|
91
97
|
astInfo: {
|
|
92
98
|
nodeType: "CallExpression",
|
|
93
99
|
property: "isDisjointFrom",
|
|
100
|
+
requireSetLikeCall: true,
|
|
94
101
|
},
|
|
95
102
|
},
|
|
96
103
|
Float16Array: {
|
package/lib/helpers/ast.js
CHANGED
|
@@ -121,7 +121,8 @@ function isArrayConstructorCall(calleeObject) {
|
|
|
121
121
|
if (isMemberExpressionCallee) {
|
|
122
122
|
const innerProperty = innerCallee.property;
|
|
123
123
|
const hasPropertyName = innerProperty?.name;
|
|
124
|
-
const isArrayMethod =
|
|
124
|
+
const isArrayMethod =
|
|
125
|
+
hasPropertyName && ARRAY_METHODS.has(innerProperty.name);
|
|
125
126
|
return isArrayMethod;
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -143,6 +144,65 @@ function isArrayLikeCall(node) {
|
|
|
143
144
|
return isArray;
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
// ── Set-like call detection (mirrors Array-like approach) ──
|
|
148
|
+
|
|
149
|
+
const SET_LIKE_NAMES = new Set(["set", "sets", "seta", "setb", "set1", "set2"]);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Words that start/end with "set" but are not Set instances.
|
|
153
|
+
* Used as a blocklist when the broader startsWith/endsWith heuristic is active.
|
|
154
|
+
*/
|
|
155
|
+
const COMMON_NON_SET_NAMES = new Set([
|
|
156
|
+
"settings",
|
|
157
|
+
"setup",
|
|
158
|
+
"setter",
|
|
159
|
+
"setstate",
|
|
160
|
+
"setvalue",
|
|
161
|
+
"setdata",
|
|
162
|
+
"setitem",
|
|
163
|
+
"setinterval",
|
|
164
|
+
"settimeout",
|
|
165
|
+
"offset",
|
|
166
|
+
"dataset",
|
|
167
|
+
"reset",
|
|
168
|
+
"asset",
|
|
169
|
+
"charset",
|
|
170
|
+
"onset",
|
|
171
|
+
"subset",
|
|
172
|
+
"mindset",
|
|
173
|
+
"closet",
|
|
174
|
+
"baseset",
|
|
175
|
+
]);
|
|
176
|
+
|
|
177
|
+
function isSetConstructorCall(calleeObject) {
|
|
178
|
+
// new Set() or new Set([...])
|
|
179
|
+
if (
|
|
180
|
+
calleeObject.type === "NewExpression" &&
|
|
181
|
+
calleeObject.callee?.name === "Set"
|
|
182
|
+
) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function isSetLikeIdentifier(calleeObject) {
|
|
189
|
+
if (calleeObject.type !== "Identifier") return false;
|
|
190
|
+
const name = calleeObject.name.toLowerCase();
|
|
191
|
+
if (COMMON_NON_SET_NAMES.has(name)) return false;
|
|
192
|
+
return (
|
|
193
|
+
SET_LIKE_NAMES.has(name) || name.startsWith("set") || name.endsWith("set")
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function isSetLikeCall(node) {
|
|
198
|
+
const calleeObject = node.callee?.object;
|
|
199
|
+
if (!calleeObject) return false;
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
isSetConstructorCall(calleeObject) || isSetLikeIdentifier(calleeObject)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
146
206
|
function checkMap(node, astInfo) {
|
|
147
207
|
const callee = node.callee;
|
|
148
208
|
const calleeObject = callee?.object;
|
|
@@ -196,6 +256,9 @@ function checkMap(node, astInfo) {
|
|
|
196
256
|
const hasArrayLikeCallMismatch =
|
|
197
257
|
astInfo.requireArrayLikeCall && !isArrayLikeCall(node);
|
|
198
258
|
|
|
259
|
+
const hasSetLikeCallMismatch =
|
|
260
|
+
astInfo.requireSetLikeCall && !isSetLikeCall(node);
|
|
261
|
+
|
|
199
262
|
const hasMismatch =
|
|
200
263
|
hasKindMismatch ||
|
|
201
264
|
hasOperatorMismatch ||
|
|
@@ -208,7 +271,8 @@ function checkMap(node, astInfo) {
|
|
|
208
271
|
hasOptionsCauseMismatch ||
|
|
209
272
|
hasExcludedCallerType ||
|
|
210
273
|
hasNumericArgMismatch ||
|
|
211
|
-
hasArrayLikeCallMismatch
|
|
274
|
+
hasArrayLikeCallMismatch ||
|
|
275
|
+
hasSetLikeCallMismatch;
|
|
212
276
|
|
|
213
277
|
if (hasMismatch) return false;
|
|
214
278
|
|