eslint-plugin-mgw-eslint-rules 2.3.38 → 2.3.40
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.
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -44219,9 +44219,19 @@ var rule6 = createRule6({
|
|
|
44219
44219
|
create(context) {
|
|
44220
44220
|
const services = (0, import_eslint_utils2.getParserServices)(context);
|
|
44221
44221
|
const checker = services.program.getTypeChecker();
|
|
44222
|
-
|
|
44223
|
-
|
|
44224
|
-
|
|
44222
|
+
function isTypeArrayLike(types) {
|
|
44223
|
+
for (const type of types) {
|
|
44224
|
+
if (["ArrayLike", "Set", "ReadonlySet", "Map", "ReadonlyMap"].includes(type)) {
|
|
44225
|
+
return true;
|
|
44226
|
+
}
|
|
44227
|
+
if (/(Array|\[])$/.test(type) || /^\[.*]$/.test(type)) {
|
|
44228
|
+
return true;
|
|
44229
|
+
}
|
|
44230
|
+
}
|
|
44231
|
+
return false;
|
|
44232
|
+
}
|
|
44233
|
+
function getTypesWithoutGeneric(types) {
|
|
44234
|
+
return types.replace(/<[^>]*>/g, "").split("|").map((t) => t.trim());
|
|
44225
44235
|
}
|
|
44226
44236
|
function fixNodeName(node, name) {
|
|
44227
44237
|
const sourceCode = context.sourceCode;
|
|
@@ -44256,8 +44266,7 @@ var rule6 = createRule6({
|
|
|
44256
44266
|
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
44257
44267
|
const type = checker.getTypeAtLocation(tsNode);
|
|
44258
44268
|
const typeName = checker.typeToString(type);
|
|
44259
|
-
|
|
44260
|
-
if (!typeNameWithoutGeneric || !listeArraysTypes.includes(typeNameWithoutGeneric) || !/(Array|\[])$/.test(typeNameWithoutGeneric) || !/^\[.*]$/.test(typeNameWithoutGeneric)) {
|
|
44269
|
+
if (!isTypeArrayLike(getTypesWithoutGeneric(typeName))) {
|
|
44261
44270
|
return;
|
|
44262
44271
|
}
|
|
44263
44272
|
const listSuffixRegexp = /liste?$/i;
|