eslint-plugin-nextfriday 1.7.0 → 1.8.0
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/CHANGELOG.md +10 -0
- package/README.md +11 -8
- package/docs/rules/NO_LAZY_IDENTIFIERS.md +106 -0
- package/lib/index.cjs +270 -131
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +14 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.js +270 -131
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
40
40
|
// package.json
|
|
41
41
|
var package_default = {
|
|
42
42
|
name: "eslint-plugin-nextfriday",
|
|
43
|
-
version: "1.
|
|
43
|
+
version: "1.8.0",
|
|
44
44
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
45
45
|
keywords: [
|
|
46
46
|
"eslint",
|
|
@@ -1140,11 +1140,147 @@ var noLogicInParams = createRule14({
|
|
|
1140
1140
|
});
|
|
1141
1141
|
var no_logic_in_params_default = noLogicInParams;
|
|
1142
1142
|
|
|
1143
|
-
// src/rules/no-
|
|
1143
|
+
// src/rules/no-lazy-identifiers.ts
|
|
1144
1144
|
var import_utils17 = require("@typescript-eslint/utils");
|
|
1145
1145
|
var createRule15 = import_utils17.ESLintUtils.RuleCreator(
|
|
1146
1146
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1147
1147
|
);
|
|
1148
|
+
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
1149
|
+
var MIN_LENGTH = 3;
|
|
1150
|
+
var MIN_SEQUENCE_LENGTH = 4;
|
|
1151
|
+
var hasRepeatedChars = (name) => {
|
|
1152
|
+
const lowerName = name.toLowerCase();
|
|
1153
|
+
return lowerName.split("").some((char, index) => {
|
|
1154
|
+
if (index > lowerName.length - 3) {
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
return char === lowerName[index + 1] && char === lowerName[index + 2];
|
|
1158
|
+
});
|
|
1159
|
+
};
|
|
1160
|
+
var hasKeyboardSequence = (name) => {
|
|
1161
|
+
const lowerName = name.toLowerCase();
|
|
1162
|
+
if (lowerName.length < MIN_SEQUENCE_LENGTH) {
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1165
|
+
return KEYBOARD_ROWS.some((row) => {
|
|
1166
|
+
const positions = Array.from({ length: row.length - MIN_SEQUENCE_LENGTH + 1 }, (_, i) => i);
|
|
1167
|
+
return positions.some((start) => {
|
|
1168
|
+
const sequence = row.slice(start, start + MIN_SEQUENCE_LENGTH);
|
|
1169
|
+
const reverseSequence = sequence.split("").reverse().join("");
|
|
1170
|
+
return lowerName.includes(sequence) || lowerName.includes(reverseSequence);
|
|
1171
|
+
});
|
|
1172
|
+
});
|
|
1173
|
+
};
|
|
1174
|
+
var isLazyIdentifier = (name) => {
|
|
1175
|
+
if (name.length < MIN_LENGTH) {
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
if (name.startsWith("_")) {
|
|
1179
|
+
return false;
|
|
1180
|
+
}
|
|
1181
|
+
if (hasRepeatedChars(name)) {
|
|
1182
|
+
return true;
|
|
1183
|
+
}
|
|
1184
|
+
if (hasKeyboardSequence(name)) {
|
|
1185
|
+
return true;
|
|
1186
|
+
}
|
|
1187
|
+
return false;
|
|
1188
|
+
};
|
|
1189
|
+
var noLazyIdentifiers = createRule15({
|
|
1190
|
+
name: "no-lazy-identifiers",
|
|
1191
|
+
meta: {
|
|
1192
|
+
type: "problem",
|
|
1193
|
+
docs: {
|
|
1194
|
+
description: "Disallow lazy, meaningless variable names that hurt code readability"
|
|
1195
|
+
},
|
|
1196
|
+
messages: {
|
|
1197
|
+
noLazyIdentifier: "Avoid lazy identifier '{{name}}'. Use a descriptive name that clearly indicates the purpose."
|
|
1198
|
+
},
|
|
1199
|
+
schema: []
|
|
1200
|
+
},
|
|
1201
|
+
defaultOptions: [],
|
|
1202
|
+
create(context) {
|
|
1203
|
+
const checkIdentifier = (node) => {
|
|
1204
|
+
const { name } = node;
|
|
1205
|
+
if (!isLazyIdentifier(name)) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
context.report({
|
|
1209
|
+
node,
|
|
1210
|
+
messageId: "noLazyIdentifier",
|
|
1211
|
+
data: { name }
|
|
1212
|
+
});
|
|
1213
|
+
};
|
|
1214
|
+
const checkPattern = (pattern) => {
|
|
1215
|
+
if (pattern.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
1216
|
+
checkIdentifier(pattern);
|
|
1217
|
+
} else if (pattern.type === import_utils17.AST_NODE_TYPES.ObjectPattern) {
|
|
1218
|
+
pattern.properties.forEach((prop) => {
|
|
1219
|
+
if (prop.type === import_utils17.AST_NODE_TYPES.Property && prop.value.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
1220
|
+
checkIdentifier(prop.value);
|
|
1221
|
+
} else if (prop.type === import_utils17.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
1222
|
+
checkIdentifier(prop.argument);
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
} else if (pattern.type === import_utils17.AST_NODE_TYPES.ArrayPattern) {
|
|
1226
|
+
pattern.elements.forEach((element) => {
|
|
1227
|
+
if (element?.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
1228
|
+
checkIdentifier(element);
|
|
1229
|
+
} else if (element?.type === import_utils17.AST_NODE_TYPES.RestElement && element.argument.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
1230
|
+
checkIdentifier(element.argument);
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
} else if (pattern.type === import_utils17.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
1234
|
+
checkIdentifier(pattern.left);
|
|
1235
|
+
} else if (pattern.type === import_utils17.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
1236
|
+
checkIdentifier(pattern.argument);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
return {
|
|
1240
|
+
VariableDeclarator(node) {
|
|
1241
|
+
checkPattern(node.id);
|
|
1242
|
+
},
|
|
1243
|
+
FunctionDeclaration(node) {
|
|
1244
|
+
if (node.id) {
|
|
1245
|
+
checkIdentifier(node.id);
|
|
1246
|
+
}
|
|
1247
|
+
node.params.forEach((param) => checkPattern(param));
|
|
1248
|
+
},
|
|
1249
|
+
FunctionExpression(node) {
|
|
1250
|
+
if (node.id) {
|
|
1251
|
+
checkIdentifier(node.id);
|
|
1252
|
+
}
|
|
1253
|
+
node.params.forEach((param) => checkPattern(param));
|
|
1254
|
+
},
|
|
1255
|
+
ArrowFunctionExpression(node) {
|
|
1256
|
+
node.params.forEach((param) => checkPattern(param));
|
|
1257
|
+
},
|
|
1258
|
+
CatchClause(node) {
|
|
1259
|
+
if (node.param) {
|
|
1260
|
+
checkPattern(node.param);
|
|
1261
|
+
}
|
|
1262
|
+
},
|
|
1263
|
+
ClassDeclaration(node) {
|
|
1264
|
+
if (node.id) {
|
|
1265
|
+
checkIdentifier(node.id);
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
TSTypeAliasDeclaration(node) {
|
|
1269
|
+
checkIdentifier(node.id);
|
|
1270
|
+
},
|
|
1271
|
+
TSInterfaceDeclaration(node) {
|
|
1272
|
+
checkIdentifier(node.id);
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
1278
|
+
|
|
1279
|
+
// src/rules/no-single-char-variables.ts
|
|
1280
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
1281
|
+
var createRule16 = import_utils18.ESLintUtils.RuleCreator(
|
|
1282
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1283
|
+
);
|
|
1148
1284
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
1149
1285
|
var ALLOWED_UNDERSCORE = "_";
|
|
1150
1286
|
var isForLoopInit = (node) => {
|
|
@@ -1154,7 +1290,7 @@ var isForLoopInit = (node) => {
|
|
|
1154
1290
|
if (!parentNode) {
|
|
1155
1291
|
return false;
|
|
1156
1292
|
}
|
|
1157
|
-
if (parentNode.type ===
|
|
1293
|
+
if (parentNode.type === import_utils18.AST_NODE_TYPES.ForStatement) {
|
|
1158
1294
|
const { init } = parentNode;
|
|
1159
1295
|
if (init && init === current) {
|
|
1160
1296
|
return true;
|
|
@@ -1173,7 +1309,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
1173
1309
|
}
|
|
1174
1310
|
return false;
|
|
1175
1311
|
};
|
|
1176
|
-
var noSingleCharVariables =
|
|
1312
|
+
var noSingleCharVariables = createRule16({
|
|
1177
1313
|
name: "no-single-char-variables",
|
|
1178
1314
|
meta: {
|
|
1179
1315
|
type: "suggestion",
|
|
@@ -1202,27 +1338,27 @@ var noSingleCharVariables = createRule15({
|
|
|
1202
1338
|
});
|
|
1203
1339
|
};
|
|
1204
1340
|
const checkPattern = (pattern, declarationNode) => {
|
|
1205
|
-
if (pattern.type ===
|
|
1341
|
+
if (pattern.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1206
1342
|
checkIdentifier(pattern, declarationNode);
|
|
1207
|
-
} else if (pattern.type ===
|
|
1343
|
+
} else if (pattern.type === import_utils18.AST_NODE_TYPES.ObjectPattern) {
|
|
1208
1344
|
pattern.properties.forEach((prop) => {
|
|
1209
|
-
if (prop.type ===
|
|
1345
|
+
if (prop.type === import_utils18.AST_NODE_TYPES.Property && prop.value.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1210
1346
|
checkIdentifier(prop.value, declarationNode);
|
|
1211
|
-
} else if (prop.type ===
|
|
1347
|
+
} else if (prop.type === import_utils18.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1212
1348
|
checkIdentifier(prop.argument, declarationNode);
|
|
1213
1349
|
}
|
|
1214
1350
|
});
|
|
1215
|
-
} else if (pattern.type ===
|
|
1351
|
+
} else if (pattern.type === import_utils18.AST_NODE_TYPES.ArrayPattern) {
|
|
1216
1352
|
pattern.elements.forEach((element) => {
|
|
1217
|
-
if (element?.type ===
|
|
1353
|
+
if (element?.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1218
1354
|
checkIdentifier(element, declarationNode);
|
|
1219
|
-
} else if (element?.type ===
|
|
1355
|
+
} else if (element?.type === import_utils18.AST_NODE_TYPES.RestElement && element.argument.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1220
1356
|
checkIdentifier(element.argument, declarationNode);
|
|
1221
1357
|
}
|
|
1222
1358
|
});
|
|
1223
|
-
} else if (pattern.type ===
|
|
1359
|
+
} else if (pattern.type === import_utils18.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1224
1360
|
checkIdentifier(pattern.left, declarationNode);
|
|
1225
|
-
} else if (pattern.type ===
|
|
1361
|
+
} else if (pattern.type === import_utils18.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1226
1362
|
checkIdentifier(pattern.argument, declarationNode);
|
|
1227
1363
|
}
|
|
1228
1364
|
};
|
|
@@ -1256,11 +1392,11 @@ var noSingleCharVariables = createRule15({
|
|
|
1256
1392
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
1257
1393
|
|
|
1258
1394
|
// src/rules/prefer-destructuring-params.ts
|
|
1259
|
-
var
|
|
1260
|
-
var
|
|
1395
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
1396
|
+
var createRule17 = import_utils19.ESLintUtils.RuleCreator(
|
|
1261
1397
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1262
1398
|
);
|
|
1263
|
-
var preferDestructuringParams =
|
|
1399
|
+
var preferDestructuringParams = createRule17({
|
|
1264
1400
|
name: "prefer-destructuring-params",
|
|
1265
1401
|
meta: {
|
|
1266
1402
|
type: "suggestion",
|
|
@@ -1276,18 +1412,18 @@ var preferDestructuringParams = createRule16({
|
|
|
1276
1412
|
create(context) {
|
|
1277
1413
|
const isCallbackFunction2 = (node) => {
|
|
1278
1414
|
const { parent } = node;
|
|
1279
|
-
return parent?.type ===
|
|
1415
|
+
return parent?.type === import_utils19.AST_NODE_TYPES.CallExpression;
|
|
1280
1416
|
};
|
|
1281
1417
|
const isDeveloperFunction = (node) => {
|
|
1282
|
-
if (node.type ===
|
|
1418
|
+
if (node.type === import_utils19.AST_NODE_TYPES.FunctionDeclaration) {
|
|
1283
1419
|
return true;
|
|
1284
1420
|
}
|
|
1285
|
-
if (node.type ===
|
|
1421
|
+
if (node.type === import_utils19.AST_NODE_TYPES.FunctionExpression || node.type === import_utils19.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
1286
1422
|
if (isCallbackFunction2(node)) {
|
|
1287
1423
|
return false;
|
|
1288
1424
|
}
|
|
1289
1425
|
const { parent } = node;
|
|
1290
|
-
return parent?.type ===
|
|
1426
|
+
return parent?.type === import_utils19.AST_NODE_TYPES.VariableDeclarator || parent?.type === import_utils19.AST_NODE_TYPES.AssignmentExpression || parent?.type === import_utils19.AST_NODE_TYPES.Property || parent?.type === import_utils19.AST_NODE_TYPES.MethodDefinition;
|
|
1291
1427
|
}
|
|
1292
1428
|
return false;
|
|
1293
1429
|
};
|
|
@@ -1299,7 +1435,7 @@ var preferDestructuringParams = createRule16({
|
|
|
1299
1435
|
if (!isDeveloperFunction(node)) {
|
|
1300
1436
|
return;
|
|
1301
1437
|
}
|
|
1302
|
-
if (node.type ===
|
|
1438
|
+
if (node.type === import_utils19.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
1303
1439
|
const functionName = node.id.name;
|
|
1304
1440
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
1305
1441
|
return;
|
|
@@ -1309,7 +1445,7 @@ var preferDestructuringParams = createRule16({
|
|
|
1309
1445
|
return;
|
|
1310
1446
|
}
|
|
1311
1447
|
const hasNonDestructuredParams = node.params.some(
|
|
1312
|
-
(param) => param.type !==
|
|
1448
|
+
(param) => param.type !== import_utils19.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils19.AST_NODE_TYPES.RestElement
|
|
1313
1449
|
);
|
|
1314
1450
|
if (hasNonDestructuredParams) {
|
|
1315
1451
|
context.report({
|
|
@@ -1328,8 +1464,8 @@ var preferDestructuringParams = createRule16({
|
|
|
1328
1464
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
1329
1465
|
|
|
1330
1466
|
// src/rules/prefer-function-declaration.ts
|
|
1331
|
-
var
|
|
1332
|
-
var
|
|
1467
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
1468
|
+
var createRule18 = import_utils20.ESLintUtils.RuleCreator(
|
|
1333
1469
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1334
1470
|
);
|
|
1335
1471
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -1338,33 +1474,33 @@ var isCallbackContext = (node) => {
|
|
|
1338
1474
|
if (!parent) {
|
|
1339
1475
|
return false;
|
|
1340
1476
|
}
|
|
1341
|
-
if (parent.type ===
|
|
1477
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
1342
1478
|
return true;
|
|
1343
1479
|
}
|
|
1344
|
-
if (parent.type ===
|
|
1480
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
1345
1481
|
return true;
|
|
1346
1482
|
}
|
|
1347
|
-
if (parent.type ===
|
|
1483
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.ReturnStatement) {
|
|
1348
1484
|
return true;
|
|
1349
1485
|
}
|
|
1350
|
-
if (parent.type ===
|
|
1486
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.Property) {
|
|
1351
1487
|
return true;
|
|
1352
1488
|
}
|
|
1353
|
-
if (parent.type ===
|
|
1489
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.ArrayExpression) {
|
|
1354
1490
|
return true;
|
|
1355
1491
|
}
|
|
1356
|
-
if (parent.type ===
|
|
1492
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.ConditionalExpression) {
|
|
1357
1493
|
return true;
|
|
1358
1494
|
}
|
|
1359
|
-
if (parent.type ===
|
|
1495
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.LogicalExpression) {
|
|
1360
1496
|
return true;
|
|
1361
1497
|
}
|
|
1362
|
-
if (parent.type ===
|
|
1498
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
1363
1499
|
return true;
|
|
1364
1500
|
}
|
|
1365
1501
|
return false;
|
|
1366
1502
|
};
|
|
1367
|
-
var preferFunctionDeclaration =
|
|
1503
|
+
var preferFunctionDeclaration = createRule18({
|
|
1368
1504
|
name: "prefer-function-declaration",
|
|
1369
1505
|
meta: {
|
|
1370
1506
|
type: "suggestion",
|
|
@@ -1385,14 +1521,14 @@ var preferFunctionDeclaration = createRule17({
|
|
|
1385
1521
|
}
|
|
1386
1522
|
return {
|
|
1387
1523
|
VariableDeclarator(node) {
|
|
1388
|
-
if (node.id.type !==
|
|
1524
|
+
if (node.id.type !== import_utils20.AST_NODE_TYPES.Identifier) {
|
|
1389
1525
|
return;
|
|
1390
1526
|
}
|
|
1391
1527
|
const { init } = node;
|
|
1392
1528
|
if (!init) {
|
|
1393
1529
|
return;
|
|
1394
1530
|
}
|
|
1395
|
-
if (init.type ===
|
|
1531
|
+
if (init.type === import_utils20.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
1396
1532
|
if (isCallbackContext(init)) {
|
|
1397
1533
|
return;
|
|
1398
1534
|
}
|
|
@@ -1402,7 +1538,7 @@ var preferFunctionDeclaration = createRule17({
|
|
|
1402
1538
|
data: { name: node.id.name }
|
|
1403
1539
|
});
|
|
1404
1540
|
}
|
|
1405
|
-
if (init.type ===
|
|
1541
|
+
if (init.type === import_utils20.AST_NODE_TYPES.FunctionExpression) {
|
|
1406
1542
|
if (isCallbackContext(init)) {
|
|
1407
1543
|
return;
|
|
1408
1544
|
}
|
|
@@ -1419,11 +1555,11 @@ var preferFunctionDeclaration = createRule17({
|
|
|
1419
1555
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
1420
1556
|
|
|
1421
1557
|
// src/rules/prefer-import-type.ts
|
|
1422
|
-
var
|
|
1423
|
-
var
|
|
1558
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
1559
|
+
var createRule19 = import_utils21.ESLintUtils.RuleCreator(
|
|
1424
1560
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1425
1561
|
);
|
|
1426
|
-
var preferImportType =
|
|
1562
|
+
var preferImportType = createRule19({
|
|
1427
1563
|
name: "prefer-import-type",
|
|
1428
1564
|
meta: {
|
|
1429
1565
|
type: "suggestion",
|
|
@@ -1442,22 +1578,22 @@ var preferImportType = createRule18({
|
|
|
1442
1578
|
let current = node;
|
|
1443
1579
|
while (current) {
|
|
1444
1580
|
switch (current.type) {
|
|
1445
|
-
case
|
|
1446
|
-
case
|
|
1447
|
-
case
|
|
1448
|
-
case
|
|
1449
|
-
case
|
|
1450
|
-
case
|
|
1451
|
-
case
|
|
1452
|
-
case
|
|
1453
|
-
case
|
|
1454
|
-
case
|
|
1455
|
-
case
|
|
1456
|
-
case
|
|
1457
|
-
case
|
|
1581
|
+
case import_utils21.AST_NODE_TYPES.TSTypeReference:
|
|
1582
|
+
case import_utils21.AST_NODE_TYPES.TSTypeAnnotation:
|
|
1583
|
+
case import_utils21.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
1584
|
+
case import_utils21.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
1585
|
+
case import_utils21.AST_NODE_TYPES.TSClassImplements:
|
|
1586
|
+
case import_utils21.AST_NODE_TYPES.TSTypeQuery:
|
|
1587
|
+
case import_utils21.AST_NODE_TYPES.TSTypeAssertion:
|
|
1588
|
+
case import_utils21.AST_NODE_TYPES.TSAsExpression:
|
|
1589
|
+
case import_utils21.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
1590
|
+
case import_utils21.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
1591
|
+
case import_utils21.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
1592
|
+
case import_utils21.AST_NODE_TYPES.TSTypeParameter:
|
|
1593
|
+
case import_utils21.AST_NODE_TYPES.TSQualifiedName:
|
|
1458
1594
|
return true;
|
|
1459
|
-
case
|
|
1460
|
-
case
|
|
1595
|
+
case import_utils21.AST_NODE_TYPES.MemberExpression:
|
|
1596
|
+
case import_utils21.AST_NODE_TYPES.Identifier:
|
|
1461
1597
|
current = current.parent;
|
|
1462
1598
|
break;
|
|
1463
1599
|
default:
|
|
@@ -1487,26 +1623,26 @@ var preferImportType = createRule18({
|
|
|
1487
1623
|
return false;
|
|
1488
1624
|
}
|
|
1489
1625
|
switch (parent.type) {
|
|
1490
|
-
case
|
|
1491
|
-
case
|
|
1492
|
-
case
|
|
1493
|
-
case
|
|
1494
|
-
case
|
|
1495
|
-
case
|
|
1496
|
-
case
|
|
1497
|
-
case
|
|
1498
|
-
case
|
|
1499
|
-
case
|
|
1500
|
-
case
|
|
1501
|
-
case
|
|
1502
|
-
case
|
|
1503
|
-
case
|
|
1504
|
-
case
|
|
1505
|
-
case
|
|
1506
|
-
case
|
|
1507
|
-
case
|
|
1508
|
-
case
|
|
1509
|
-
case
|
|
1626
|
+
case import_utils21.AST_NODE_TYPES.CallExpression:
|
|
1627
|
+
case import_utils21.AST_NODE_TYPES.NewExpression:
|
|
1628
|
+
case import_utils21.AST_NODE_TYPES.JSXOpeningElement:
|
|
1629
|
+
case import_utils21.AST_NODE_TYPES.JSXClosingElement:
|
|
1630
|
+
case import_utils21.AST_NODE_TYPES.MemberExpression:
|
|
1631
|
+
case import_utils21.AST_NODE_TYPES.VariableDeclarator:
|
|
1632
|
+
case import_utils21.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
1633
|
+
case import_utils21.AST_NODE_TYPES.SpreadElement:
|
|
1634
|
+
case import_utils21.AST_NODE_TYPES.ExportSpecifier:
|
|
1635
|
+
case import_utils21.AST_NODE_TYPES.ArrayExpression:
|
|
1636
|
+
case import_utils21.AST_NODE_TYPES.ObjectExpression:
|
|
1637
|
+
case import_utils21.AST_NODE_TYPES.BinaryExpression:
|
|
1638
|
+
case import_utils21.AST_NODE_TYPES.LogicalExpression:
|
|
1639
|
+
case import_utils21.AST_NODE_TYPES.UnaryExpression:
|
|
1640
|
+
case import_utils21.AST_NODE_TYPES.ReturnStatement:
|
|
1641
|
+
case import_utils21.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
1642
|
+
case import_utils21.AST_NODE_TYPES.ConditionalExpression:
|
|
1643
|
+
case import_utils21.AST_NODE_TYPES.AwaitExpression:
|
|
1644
|
+
case import_utils21.AST_NODE_TYPES.YieldExpression:
|
|
1645
|
+
case import_utils21.AST_NODE_TYPES.Property:
|
|
1510
1646
|
return true;
|
|
1511
1647
|
default:
|
|
1512
1648
|
return false;
|
|
@@ -1530,13 +1666,13 @@ var preferImportType = createRule18({
|
|
|
1530
1666
|
}
|
|
1531
1667
|
const scope = context.sourceCode.getScope(node);
|
|
1532
1668
|
const isTypeOnlyImport = node.specifiers.every((specifier) => {
|
|
1533
|
-
if (specifier.type ===
|
|
1669
|
+
if (specifier.type === import_utils21.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
1534
1670
|
return false;
|
|
1535
1671
|
}
|
|
1536
|
-
if (specifier.type ===
|
|
1672
|
+
if (specifier.type === import_utils21.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
1537
1673
|
return false;
|
|
1538
1674
|
}
|
|
1539
|
-
if (specifier.type ===
|
|
1675
|
+
if (specifier.type === import_utils21.AST_NODE_TYPES.ImportSpecifier) {
|
|
1540
1676
|
const localName = specifier.local.name;
|
|
1541
1677
|
return !isUsedAsValue(localName, scope);
|
|
1542
1678
|
}
|
|
@@ -1562,11 +1698,11 @@ var preferImportType = createRule18({
|
|
|
1562
1698
|
var prefer_import_type_default = preferImportType;
|
|
1563
1699
|
|
|
1564
1700
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
1565
|
-
var
|
|
1566
|
-
var
|
|
1701
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
1702
|
+
var createRule20 = import_utils22.ESLintUtils.RuleCreator(
|
|
1567
1703
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1568
1704
|
);
|
|
1569
|
-
var preferInterfaceOverInlineTypes =
|
|
1705
|
+
var preferInterfaceOverInlineTypes = createRule20({
|
|
1570
1706
|
name: "prefer-interface-over-inline-types",
|
|
1571
1707
|
meta: {
|
|
1572
1708
|
type: "suggestion",
|
|
@@ -1582,54 +1718,54 @@ var preferInterfaceOverInlineTypes = createRule19({
|
|
|
1582
1718
|
defaultOptions: [],
|
|
1583
1719
|
create(context) {
|
|
1584
1720
|
function hasJSXInConditional(node) {
|
|
1585
|
-
return node.consequent.type ===
|
|
1721
|
+
return node.consequent.type === import_utils22.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils22.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils22.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils22.AST_NODE_TYPES.JSXFragment;
|
|
1586
1722
|
}
|
|
1587
1723
|
function hasJSXInLogical(node) {
|
|
1588
|
-
return node.right.type ===
|
|
1724
|
+
return node.right.type === import_utils22.AST_NODE_TYPES.JSXElement || node.right.type === import_utils22.AST_NODE_TYPES.JSXFragment;
|
|
1589
1725
|
}
|
|
1590
1726
|
function hasJSXReturn(block) {
|
|
1591
1727
|
return block.body.some((stmt) => {
|
|
1592
|
-
if (stmt.type ===
|
|
1593
|
-
return stmt.argument.type ===
|
|
1728
|
+
if (stmt.type === import_utils22.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
1729
|
+
return stmt.argument.type === import_utils22.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils22.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils22.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils22.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
1594
1730
|
}
|
|
1595
1731
|
return false;
|
|
1596
1732
|
});
|
|
1597
1733
|
}
|
|
1598
1734
|
function isReactComponent2(node) {
|
|
1599
|
-
if (node.type ===
|
|
1600
|
-
if (node.body.type ===
|
|
1735
|
+
if (node.type === import_utils22.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
1736
|
+
if (node.body.type === import_utils22.AST_NODE_TYPES.JSXElement || node.body.type === import_utils22.AST_NODE_TYPES.JSXFragment) {
|
|
1601
1737
|
return true;
|
|
1602
1738
|
}
|
|
1603
|
-
if (node.body.type ===
|
|
1739
|
+
if (node.body.type === import_utils22.AST_NODE_TYPES.BlockStatement) {
|
|
1604
1740
|
return hasJSXReturn(node.body);
|
|
1605
1741
|
}
|
|
1606
|
-
} else if (node.type ===
|
|
1607
|
-
if (node.body && node.body.type ===
|
|
1742
|
+
} else if (node.type === import_utils22.AST_NODE_TYPES.FunctionExpression || node.type === import_utils22.AST_NODE_TYPES.FunctionDeclaration) {
|
|
1743
|
+
if (node.body && node.body.type === import_utils22.AST_NODE_TYPES.BlockStatement) {
|
|
1608
1744
|
return hasJSXReturn(node.body);
|
|
1609
1745
|
}
|
|
1610
1746
|
}
|
|
1611
1747
|
return false;
|
|
1612
1748
|
}
|
|
1613
1749
|
function isInlineTypeAnnotation(node) {
|
|
1614
|
-
if (node.type ===
|
|
1750
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSTypeLiteral) {
|
|
1615
1751
|
return true;
|
|
1616
1752
|
}
|
|
1617
|
-
if (node.type ===
|
|
1618
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
1753
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
1754
|
+
return node.typeArguments.params.some((param) => param.type === import_utils22.AST_NODE_TYPES.TSTypeLiteral);
|
|
1619
1755
|
}
|
|
1620
|
-
if (node.type ===
|
|
1756
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSUnionType) {
|
|
1621
1757
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
1622
1758
|
}
|
|
1623
1759
|
return false;
|
|
1624
1760
|
}
|
|
1625
1761
|
function hasInlineObjectType(node) {
|
|
1626
|
-
if (node.type ===
|
|
1762
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSTypeLiteral) {
|
|
1627
1763
|
return true;
|
|
1628
1764
|
}
|
|
1629
|
-
if (node.type ===
|
|
1630
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
1765
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
1766
|
+
return node.typeArguments.params.some((param) => param.type === import_utils22.AST_NODE_TYPES.TSTypeLiteral);
|
|
1631
1767
|
}
|
|
1632
|
-
if (node.type ===
|
|
1768
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSUnionType) {
|
|
1633
1769
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
1634
1770
|
}
|
|
1635
1771
|
return false;
|
|
@@ -1642,7 +1778,7 @@ var preferInterfaceOverInlineTypes = createRule19({
|
|
|
1642
1778
|
return;
|
|
1643
1779
|
}
|
|
1644
1780
|
const param = node.params[0];
|
|
1645
|
-
if (param.type ===
|
|
1781
|
+
if (param.type === import_utils22.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
1646
1782
|
const { typeAnnotation } = param.typeAnnotation;
|
|
1647
1783
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
1648
1784
|
context.report({
|
|
@@ -1662,11 +1798,11 @@ var preferInterfaceOverInlineTypes = createRule19({
|
|
|
1662
1798
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
1663
1799
|
|
|
1664
1800
|
// src/rules/prefer-jsx-template-literals.ts
|
|
1665
|
-
var
|
|
1666
|
-
var
|
|
1801
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
1802
|
+
var createRule21 = import_utils23.ESLintUtils.RuleCreator(
|
|
1667
1803
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1668
1804
|
);
|
|
1669
|
-
var preferJSXTemplateLiterals =
|
|
1805
|
+
var preferJSXTemplateLiterals = createRule21({
|
|
1670
1806
|
name: "prefer-jsx-template-literals",
|
|
1671
1807
|
meta: {
|
|
1672
1808
|
type: "suggestion",
|
|
@@ -1735,9 +1871,9 @@ var preferJSXTemplateLiterals = createRule20({
|
|
|
1735
1871
|
if (!child || !nextChild) {
|
|
1736
1872
|
return;
|
|
1737
1873
|
}
|
|
1738
|
-
if (child.type ===
|
|
1874
|
+
if (child.type === import_utils23.AST_NODE_TYPES.JSXText && nextChild.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1739
1875
|
handleTextBeforeExpression(child, nextChild);
|
|
1740
|
-
} else if (child.type ===
|
|
1876
|
+
} else if (child.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils23.AST_NODE_TYPES.JSXText) {
|
|
1741
1877
|
handleExpressionBeforeText(child, nextChild);
|
|
1742
1878
|
}
|
|
1743
1879
|
}
|
|
@@ -1750,11 +1886,11 @@ var preferJSXTemplateLiterals = createRule20({
|
|
|
1750
1886
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
1751
1887
|
|
|
1752
1888
|
// src/rules/prefer-named-param-types.ts
|
|
1753
|
-
var
|
|
1754
|
-
var
|
|
1889
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
1890
|
+
var createRule22 = import_utils24.ESLintUtils.RuleCreator(
|
|
1755
1891
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1756
1892
|
);
|
|
1757
|
-
var preferNamedParamTypes =
|
|
1893
|
+
var preferNamedParamTypes = createRule22({
|
|
1758
1894
|
name: "prefer-named-param-types",
|
|
1759
1895
|
meta: {
|
|
1760
1896
|
type: "suggestion",
|
|
@@ -1769,16 +1905,16 @@ var preferNamedParamTypes = createRule21({
|
|
|
1769
1905
|
defaultOptions: [],
|
|
1770
1906
|
create(context) {
|
|
1771
1907
|
function hasInlineObjectType(param) {
|
|
1772
|
-
if (param.type ===
|
|
1908
|
+
if (param.type === import_utils24.AST_NODE_TYPES.AssignmentPattern) {
|
|
1773
1909
|
return hasInlineObjectType(param.left);
|
|
1774
1910
|
}
|
|
1775
|
-
if (param.type ===
|
|
1776
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
1911
|
+
if (param.type === import_utils24.AST_NODE_TYPES.ObjectPattern) {
|
|
1912
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils24.AST_NODE_TYPES.TSTypeLiteral) {
|
|
1777
1913
|
return true;
|
|
1778
1914
|
}
|
|
1779
1915
|
}
|
|
1780
|
-
if (param.type ===
|
|
1781
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
1916
|
+
if (param.type === import_utils24.AST_NODE_TYPES.Identifier) {
|
|
1917
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils24.AST_NODE_TYPES.TSTypeLiteral) {
|
|
1782
1918
|
return true;
|
|
1783
1919
|
}
|
|
1784
1920
|
}
|
|
@@ -1812,11 +1948,11 @@ var preferNamedParamTypes = createRule21({
|
|
|
1812
1948
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
1813
1949
|
|
|
1814
1950
|
// src/rules/prefer-react-import-types.ts
|
|
1815
|
-
var
|
|
1816
|
-
var
|
|
1951
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
1952
|
+
var createRule23 = import_utils25.ESLintUtils.RuleCreator(
|
|
1817
1953
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1818
1954
|
);
|
|
1819
|
-
var preferReactImportTypes =
|
|
1955
|
+
var preferReactImportTypes = createRule23({
|
|
1820
1956
|
name: "prefer-react-import-types",
|
|
1821
1957
|
meta: {
|
|
1822
1958
|
type: "suggestion",
|
|
@@ -1892,7 +2028,7 @@ var preferReactImportTypes = createRule22({
|
|
|
1892
2028
|
]);
|
|
1893
2029
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
1894
2030
|
function checkMemberExpression(node) {
|
|
1895
|
-
if (node.object.type ===
|
|
2031
|
+
if (node.object.type === import_utils25.AST_NODE_TYPES.Identifier && node.object.name === "React" && node.property.type === import_utils25.AST_NODE_TYPES.Identifier && allReactExports.has(node.property.name)) {
|
|
1896
2032
|
const typeName = node.property.name;
|
|
1897
2033
|
const isType = reactTypes.has(typeName);
|
|
1898
2034
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -1909,7 +2045,7 @@ var preferReactImportTypes = createRule22({
|
|
|
1909
2045
|
return {
|
|
1910
2046
|
MemberExpression: checkMemberExpression,
|
|
1911
2047
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
1912
|
-
if (node.left.type ===
|
|
2048
|
+
if (node.left.type === import_utils25.AST_NODE_TYPES.Identifier && node.left.name === "React" && node.right.type === import_utils25.AST_NODE_TYPES.Identifier && allReactExports.has(node.right.name)) {
|
|
1913
2049
|
const typeName = node.right.name;
|
|
1914
2050
|
const isType = reactTypes.has(typeName);
|
|
1915
2051
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -1929,11 +2065,11 @@ var preferReactImportTypes = createRule22({
|
|
|
1929
2065
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
1930
2066
|
|
|
1931
2067
|
// src/rules/react-props-destructure.ts
|
|
1932
|
-
var
|
|
1933
|
-
var
|
|
2068
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
2069
|
+
var createRule24 = import_utils26.ESLintUtils.RuleCreator(
|
|
1934
2070
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1935
2071
|
);
|
|
1936
|
-
var reactPropsDestructure =
|
|
2072
|
+
var reactPropsDestructure = createRule24({
|
|
1937
2073
|
name: "react-props-destructure",
|
|
1938
2074
|
meta: {
|
|
1939
2075
|
type: "suggestion",
|
|
@@ -1949,29 +2085,29 @@ var reactPropsDestructure = createRule23({
|
|
|
1949
2085
|
defaultOptions: [],
|
|
1950
2086
|
create(context) {
|
|
1951
2087
|
function hasJSXInConditional(node) {
|
|
1952
|
-
return node.consequent.type ===
|
|
2088
|
+
return node.consequent.type === import_utils26.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils26.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils26.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils26.AST_NODE_TYPES.JSXFragment;
|
|
1953
2089
|
}
|
|
1954
2090
|
function hasJSXInLogical(node) {
|
|
1955
|
-
return node.right.type ===
|
|
2091
|
+
return node.right.type === import_utils26.AST_NODE_TYPES.JSXElement || node.right.type === import_utils26.AST_NODE_TYPES.JSXFragment;
|
|
1956
2092
|
}
|
|
1957
2093
|
function hasJSXReturn(block) {
|
|
1958
2094
|
return block.body.some((stmt) => {
|
|
1959
|
-
if (stmt.type ===
|
|
1960
|
-
return stmt.argument.type ===
|
|
2095
|
+
if (stmt.type === import_utils26.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
2096
|
+
return stmt.argument.type === import_utils26.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils26.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils26.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils26.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
1961
2097
|
}
|
|
1962
2098
|
return false;
|
|
1963
2099
|
});
|
|
1964
2100
|
}
|
|
1965
2101
|
function isReactComponent2(node) {
|
|
1966
|
-
if (node.type ===
|
|
1967
|
-
if (node.body.type ===
|
|
2102
|
+
if (node.type === import_utils26.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
2103
|
+
if (node.body.type === import_utils26.AST_NODE_TYPES.JSXElement || node.body.type === import_utils26.AST_NODE_TYPES.JSXFragment) {
|
|
1968
2104
|
return true;
|
|
1969
2105
|
}
|
|
1970
|
-
if (node.body.type ===
|
|
2106
|
+
if (node.body.type === import_utils26.AST_NODE_TYPES.BlockStatement) {
|
|
1971
2107
|
return hasJSXReturn(node.body);
|
|
1972
2108
|
}
|
|
1973
|
-
} else if (node.type ===
|
|
1974
|
-
if (node.body && node.body.type ===
|
|
2109
|
+
} else if (node.type === import_utils26.AST_NODE_TYPES.FunctionExpression || node.type === import_utils26.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2110
|
+
if (node.body && node.body.type === import_utils26.AST_NODE_TYPES.BlockStatement) {
|
|
1975
2111
|
return hasJSXReturn(node.body);
|
|
1976
2112
|
}
|
|
1977
2113
|
}
|
|
@@ -1985,9 +2121,9 @@ var reactPropsDestructure = createRule23({
|
|
|
1985
2121
|
return;
|
|
1986
2122
|
}
|
|
1987
2123
|
const param = node.params[0];
|
|
1988
|
-
if (param.type ===
|
|
1989
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
1990
|
-
if (prop.key.type ===
|
|
2124
|
+
if (param.type === import_utils26.AST_NODE_TYPES.ObjectPattern) {
|
|
2125
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils26.AST_NODE_TYPES.Property).map((prop) => {
|
|
2126
|
+
if (prop.key.type === import_utils26.AST_NODE_TYPES.Identifier) {
|
|
1991
2127
|
return prop.key.name;
|
|
1992
2128
|
}
|
|
1993
2129
|
return null;
|
|
@@ -2032,6 +2168,7 @@ var rules = {
|
|
|
2032
2168
|
"no-emoji": no_emoji_default,
|
|
2033
2169
|
"no-env-fallback": no_env_fallback_default,
|
|
2034
2170
|
"require-explicit-return-type": require_explicit_return_type_default,
|
|
2171
|
+
"no-lazy-identifiers": no_lazy_identifiers_default,
|
|
2035
2172
|
"no-logic-in-params": no_logic_in_params_default,
|
|
2036
2173
|
"no-single-char-variables": no_single_char_variables_default,
|
|
2037
2174
|
"prefer-destructuring-params": prefer_destructuring_params_default,
|
|
@@ -2063,6 +2200,7 @@ var baseRules = {
|
|
|
2063
2200
|
"nextfriday/no-direct-date": "warn",
|
|
2064
2201
|
"nextfriday/no-logic-in-params": "warn",
|
|
2065
2202
|
"nextfriday/no-env-fallback": "warn",
|
|
2203
|
+
"nextfriday/no-lazy-identifiers": "warn",
|
|
2066
2204
|
"nextfriday/no-single-char-variables": "warn"
|
|
2067
2205
|
};
|
|
2068
2206
|
var baseRecommendedRules = {
|
|
@@ -2081,6 +2219,7 @@ var baseRecommendedRules = {
|
|
|
2081
2219
|
"nextfriday/no-direct-date": "error",
|
|
2082
2220
|
"nextfriday/no-logic-in-params": "error",
|
|
2083
2221
|
"nextfriday/no-env-fallback": "error",
|
|
2222
|
+
"nextfriday/no-lazy-identifiers": "error",
|
|
2084
2223
|
"nextfriday/no-single-char-variables": "error"
|
|
2085
2224
|
};
|
|
2086
2225
|
var jsxRules = {
|