eslint-plugin-nextfriday 3.0.0 → 3.2.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 +23 -0
- package/README.md +153 -26
- package/docs/rules/ENFORCE_CONSTANT_CASE.md +65 -3
- package/docs/rules/FILE_KEBAB_CASE.md +7 -1
- package/docs/rules/INDEX_EXPORT_ONLY.md +88 -0
- package/docs/rules/JSX_PASCAL_CASE.md +6 -2
- package/docs/rules/NO_INLINE_TYPE_IMPORT.md +86 -0
- package/lib/index.cjs +536 -393
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +88 -0
- package/lib/index.d.ts +88 -0
- package/lib/index.js +536 -393
- 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: "3.
|
|
43
|
+
version: "3.2.0",
|
|
44
44
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
45
45
|
keywords: [
|
|
46
46
|
"eslint",
|
|
@@ -1180,12 +1180,74 @@ var fileKebabCase = createRule12({
|
|
|
1180
1180
|
});
|
|
1181
1181
|
var file_kebab_case_default = fileKebabCase;
|
|
1182
1182
|
|
|
1183
|
-
// src/rules/
|
|
1183
|
+
// src/rules/index-export-only.ts
|
|
1184
1184
|
var import_utils15 = require("@typescript-eslint/utils");
|
|
1185
1185
|
var createRule13 = import_utils15.ESLintUtils.RuleCreator(
|
|
1186
1186
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1187
1187
|
);
|
|
1188
|
-
var
|
|
1188
|
+
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
1189
|
+
var isAllowedExportNamed = (node) => {
|
|
1190
|
+
if (!node.declaration) {
|
|
1191
|
+
return true;
|
|
1192
|
+
}
|
|
1193
|
+
return node.declaration.type === import_utils15.AST_NODE_TYPES.TSTypeAliasDeclaration || node.declaration.type === import_utils15.AST_NODE_TYPES.TSInterfaceDeclaration;
|
|
1194
|
+
};
|
|
1195
|
+
var isAllowedExportDefault = (node) => node.declaration.type === import_utils15.AST_NODE_TYPES.Identifier;
|
|
1196
|
+
var isAllowedTopLevel = (node) => {
|
|
1197
|
+
switch (node.type) {
|
|
1198
|
+
case import_utils15.AST_NODE_TYPES.ImportDeclaration:
|
|
1199
|
+
case import_utils15.AST_NODE_TYPES.ExportAllDeclaration:
|
|
1200
|
+
case import_utils15.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
1201
|
+
case import_utils15.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
1202
|
+
case import_utils15.AST_NODE_TYPES.TSImportEqualsDeclaration:
|
|
1203
|
+
return true;
|
|
1204
|
+
case import_utils15.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
1205
|
+
return isAllowedExportNamed(node);
|
|
1206
|
+
case import_utils15.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
1207
|
+
return isAllowedExportDefault(node);
|
|
1208
|
+
default:
|
|
1209
|
+
return false;
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
var indexExportOnly = createRule13({
|
|
1213
|
+
name: "index-export-only",
|
|
1214
|
+
meta: {
|
|
1215
|
+
type: "suggestion",
|
|
1216
|
+
docs: {
|
|
1217
|
+
description: "Restrict index files to imports, re-exports, and type declarations only."
|
|
1218
|
+
},
|
|
1219
|
+
messages: {
|
|
1220
|
+
indexExportOnly: "Index files must contain only imports, re-exports, and type declarations. Move runtime code to a separate module and re-export it from here."
|
|
1221
|
+
},
|
|
1222
|
+
schema: []
|
|
1223
|
+
},
|
|
1224
|
+
defaultOptions: [],
|
|
1225
|
+
create(context) {
|
|
1226
|
+
if (!isIndexFile(context.filename)) {
|
|
1227
|
+
return {};
|
|
1228
|
+
}
|
|
1229
|
+
return {
|
|
1230
|
+
Program(node) {
|
|
1231
|
+
for (const statement of node.body) {
|
|
1232
|
+
if (!isAllowedTopLevel(statement)) {
|
|
1233
|
+
context.report({
|
|
1234
|
+
node: statement,
|
|
1235
|
+
messageId: "indexExportOnly"
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
var index_export_only_default = indexExportOnly;
|
|
1244
|
+
|
|
1245
|
+
// src/rules/jsx-newline-between-elements.ts
|
|
1246
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
1247
|
+
var createRule14 = import_utils17.ESLintUtils.RuleCreator(
|
|
1248
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1249
|
+
);
|
|
1250
|
+
var jsxNewlineBetweenElements = createRule14({
|
|
1189
1251
|
name: "jsx-newline-between-elements",
|
|
1190
1252
|
meta: {
|
|
1191
1253
|
type: "layout",
|
|
@@ -1203,7 +1265,7 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1203
1265
|
create(context) {
|
|
1204
1266
|
const { sourceCode } = context;
|
|
1205
1267
|
function isSignificantJSXChild(node) {
|
|
1206
|
-
return node.type ===
|
|
1268
|
+
return node.type === import_utils17.AST_NODE_TYPES.JSXElement || node.type === import_utils17.AST_NODE_TYPES.JSXFragment || node.type === import_utils17.AST_NODE_TYPES.JSXExpressionContainer;
|
|
1207
1269
|
}
|
|
1208
1270
|
function isMultiLine(node) {
|
|
1209
1271
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1253,11 +1315,11 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1253
1315
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1254
1316
|
|
|
1255
1317
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1256
|
-
var
|
|
1257
|
-
var
|
|
1318
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
1319
|
+
var createRule15 = import_utils18.ESLintUtils.RuleCreator(
|
|
1258
1320
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1259
1321
|
);
|
|
1260
|
-
var jsxNoInlineObjectProp =
|
|
1322
|
+
var jsxNoInlineObjectProp = createRule15({
|
|
1261
1323
|
name: "jsx-no-inline-object-prop",
|
|
1262
1324
|
meta: {
|
|
1263
1325
|
type: "suggestion",
|
|
@@ -1273,7 +1335,7 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1273
1335
|
create(context) {
|
|
1274
1336
|
return {
|
|
1275
1337
|
JSXAttribute(node) {
|
|
1276
|
-
if (node.value?.type ===
|
|
1338
|
+
if (node.value?.type === import_utils18.AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === import_utils18.AST_NODE_TYPES.ObjectExpression) {
|
|
1277
1339
|
context.report({
|
|
1278
1340
|
node: node.value,
|
|
1279
1341
|
messageId: "noInlineObject"
|
|
@@ -1286,17 +1348,17 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1286
1348
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1287
1349
|
|
|
1288
1350
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1289
|
-
var
|
|
1290
|
-
var
|
|
1351
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
1352
|
+
var createRule16 = import_utils19.ESLintUtils.RuleCreator(
|
|
1291
1353
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1292
1354
|
);
|
|
1293
1355
|
function isJSXElementOrFragment(node) {
|
|
1294
|
-
return node.type ===
|
|
1356
|
+
return node.type === import_utils19.AST_NODE_TYPES.JSXElement || node.type === import_utils19.AST_NODE_TYPES.JSXFragment;
|
|
1295
1357
|
}
|
|
1296
1358
|
function isSingleLine(node) {
|
|
1297
1359
|
return node.loc.start.line === node.loc.end.line;
|
|
1298
1360
|
}
|
|
1299
|
-
var jsxNoNewlineSingleLineElements =
|
|
1361
|
+
var jsxNoNewlineSingleLineElements = createRule16({
|
|
1300
1362
|
name: "jsx-no-newline-single-line-elements",
|
|
1301
1363
|
meta: {
|
|
1302
1364
|
type: "layout",
|
|
@@ -1314,7 +1376,7 @@ var jsxNoNewlineSingleLineElements = createRule15({
|
|
|
1314
1376
|
const { sourceCode } = context;
|
|
1315
1377
|
function checkSiblings(children) {
|
|
1316
1378
|
const nonWhitespace = children.filter(
|
|
1317
|
-
(child) => !(child.type ===
|
|
1379
|
+
(child) => !(child.type === import_utils19.AST_NODE_TYPES.JSXText && child.value.trim() === "")
|
|
1318
1380
|
);
|
|
1319
1381
|
nonWhitespace.forEach((next, index) => {
|
|
1320
1382
|
if (index === 0) {
|
|
@@ -1365,11 +1427,11 @@ ${indent}`);
|
|
|
1365
1427
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1366
1428
|
|
|
1367
1429
|
// src/rules/jsx-no-non-component-function.ts
|
|
1368
|
-
var
|
|
1369
|
-
var
|
|
1430
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
1431
|
+
var createRule17 = import_utils20.ESLintUtils.RuleCreator(
|
|
1370
1432
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1371
1433
|
);
|
|
1372
|
-
var jsxNoNonComponentFunction =
|
|
1434
|
+
var jsxNoNonComponentFunction = createRule17({
|
|
1373
1435
|
name: "jsx-no-non-component-function",
|
|
1374
1436
|
meta: {
|
|
1375
1437
|
type: "problem",
|
|
@@ -1389,13 +1451,13 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1389
1451
|
return {};
|
|
1390
1452
|
}
|
|
1391
1453
|
function isReactComponent2(node) {
|
|
1392
|
-
const functionName = node.type ===
|
|
1454
|
+
const functionName = node.type === import_utils20.AST_NODE_TYPES.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1393
1455
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1394
1456
|
return true;
|
|
1395
1457
|
}
|
|
1396
1458
|
if (node.returnType?.typeAnnotation) {
|
|
1397
1459
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1398
|
-
if (returnTypeNode.type ===
|
|
1460
|
+
if (returnTypeNode.type === import_utils20.AST_NODE_TYPES.TSTypeReference && returnTypeNode.typeName.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
1399
1461
|
const typeName = returnTypeNode.typeName.name;
|
|
1400
1462
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1401
1463
|
return true;
|
|
@@ -1412,13 +1474,13 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1412
1474
|
if (!parent) {
|
|
1413
1475
|
return;
|
|
1414
1476
|
}
|
|
1415
|
-
if (parent.type ===
|
|
1477
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.ExportDefaultDeclaration || parent.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1416
1478
|
return;
|
|
1417
1479
|
}
|
|
1418
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1480
|
+
if (declaratorNode?.parent?.parent?.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1419
1481
|
return;
|
|
1420
1482
|
}
|
|
1421
|
-
if (declaratorNode?.id.type ===
|
|
1483
|
+
if (declaratorNode?.id.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
1422
1484
|
const varName = declaratorNode.id.name;
|
|
1423
1485
|
if (/^[A-Z]/.test(varName)) {
|
|
1424
1486
|
return;
|
|
@@ -1443,20 +1505,20 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1443
1505
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1444
1506
|
|
|
1445
1507
|
// src/rules/jsx-no-ternary-null.ts
|
|
1446
|
-
var
|
|
1447
|
-
var
|
|
1508
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
1509
|
+
var createRule18 = import_utils22.ESLintUtils.RuleCreator(
|
|
1448
1510
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1449
1511
|
);
|
|
1450
1512
|
function isNullOrUndefined(node) {
|
|
1451
|
-
if (node.type ===
|
|
1513
|
+
if (node.type === import_utils22.AST_NODE_TYPES.Literal && node.value === null) {
|
|
1452
1514
|
return true;
|
|
1453
1515
|
}
|
|
1454
|
-
if (node.type ===
|
|
1516
|
+
if (node.type === import_utils22.AST_NODE_TYPES.Identifier && node.name === "undefined") {
|
|
1455
1517
|
return true;
|
|
1456
1518
|
}
|
|
1457
1519
|
return false;
|
|
1458
1520
|
}
|
|
1459
|
-
var jsxNoTernaryNull =
|
|
1521
|
+
var jsxNoTernaryNull = createRule18({
|
|
1460
1522
|
name: "jsx-no-ternary-null",
|
|
1461
1523
|
meta: {
|
|
1462
1524
|
type: "suggestion",
|
|
@@ -1474,7 +1536,7 @@ var jsxNoTernaryNull = createRule17({
|
|
|
1474
1536
|
return {
|
|
1475
1537
|
JSXExpressionContainer(node) {
|
|
1476
1538
|
const { expression } = node;
|
|
1477
|
-
if (expression.type !==
|
|
1539
|
+
if (expression.type !== import_utils22.AST_NODE_TYPES.ConditionalExpression) {
|
|
1478
1540
|
return;
|
|
1479
1541
|
}
|
|
1480
1542
|
const { test, consequent, alternate } = expression;
|
|
@@ -1506,11 +1568,11 @@ var jsxNoTernaryNull = createRule17({
|
|
|
1506
1568
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1507
1569
|
|
|
1508
1570
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1509
|
-
var
|
|
1510
|
-
var
|
|
1571
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
1572
|
+
var createRule19 = import_utils23.ESLintUtils.RuleCreator(
|
|
1511
1573
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1512
1574
|
);
|
|
1513
|
-
var jsxNoVariableInCallback =
|
|
1575
|
+
var jsxNoVariableInCallback = createRule19({
|
|
1514
1576
|
name: "jsx-no-variable-in-callback",
|
|
1515
1577
|
meta: {
|
|
1516
1578
|
type: "suggestion",
|
|
@@ -1527,7 +1589,7 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1527
1589
|
function isInsideJSX(node) {
|
|
1528
1590
|
let current = node.parent;
|
|
1529
1591
|
while (current) {
|
|
1530
|
-
if (current.type ===
|
|
1592
|
+
if (current.type === import_utils23.AST_NODE_TYPES.JSXElement || current.type === import_utils23.AST_NODE_TYPES.JSXFragment) {
|
|
1531
1593
|
return true;
|
|
1532
1594
|
}
|
|
1533
1595
|
current = current.parent;
|
|
@@ -1541,11 +1603,11 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1541
1603
|
if (!isInsideJSX(node)) {
|
|
1542
1604
|
return false;
|
|
1543
1605
|
}
|
|
1544
|
-
if (node.parent.type ===
|
|
1606
|
+
if (node.parent.type === import_utils23.AST_NODE_TYPES.CallExpression || node.parent.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1545
1607
|
return true;
|
|
1546
1608
|
}
|
|
1547
|
-
if (node.parent.type ===
|
|
1548
|
-
if (node.parent.parent.type ===
|
|
1609
|
+
if (node.parent.type === import_utils23.AST_NODE_TYPES.ArrayExpression && node.parent.parent) {
|
|
1610
|
+
if (node.parent.parent.type === import_utils23.AST_NODE_TYPES.CallExpression || node.parent.parent.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1549
1611
|
return true;
|
|
1550
1612
|
}
|
|
1551
1613
|
}
|
|
@@ -1556,11 +1618,11 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1556
1618
|
return;
|
|
1557
1619
|
}
|
|
1558
1620
|
const { body } = node;
|
|
1559
|
-
if (body.type !==
|
|
1621
|
+
if (body.type !== import_utils23.AST_NODE_TYPES.BlockStatement) {
|
|
1560
1622
|
return;
|
|
1561
1623
|
}
|
|
1562
1624
|
body.body.forEach((statement) => {
|
|
1563
|
-
if (statement.type ===
|
|
1625
|
+
if (statement.type === import_utils23.AST_NODE_TYPES.VariableDeclaration) {
|
|
1564
1626
|
context.report({
|
|
1565
1627
|
node: statement,
|
|
1566
1628
|
messageId: "noVariableInCallback"
|
|
@@ -1578,12 +1640,12 @@ var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
|
1578
1640
|
|
|
1579
1641
|
// src/rules/jsx-pascal-case.ts
|
|
1580
1642
|
var import_path4 = __toESM(require("path"), 1);
|
|
1581
|
-
var
|
|
1582
|
-
var
|
|
1643
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
1644
|
+
var createRule20 = import_utils24.ESLintUtils.RuleCreator(
|
|
1583
1645
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1584
1646
|
);
|
|
1585
1647
|
var isPascalCase = (str) => /^[A-Z][a-zA-Z0-9]*$/.test(str) && !/^[A-Z]+$/.test(str);
|
|
1586
|
-
var jsxPascalCase =
|
|
1648
|
+
var jsxPascalCase = createRule20({
|
|
1587
1649
|
name: "jsx-pascal-case",
|
|
1588
1650
|
meta: {
|
|
1589
1651
|
type: "problem",
|
|
@@ -1618,11 +1680,11 @@ var jsxPascalCase = createRule19({
|
|
|
1618
1680
|
var jsx_pascal_case_default = jsxPascalCase;
|
|
1619
1681
|
|
|
1620
1682
|
// src/rules/jsx-require-suspense.ts
|
|
1621
|
-
var
|
|
1622
|
-
var
|
|
1683
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
1684
|
+
var createRule21 = import_utils25.ESLintUtils.RuleCreator(
|
|
1623
1685
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1624
1686
|
);
|
|
1625
|
-
var jsxRequireSuspense =
|
|
1687
|
+
var jsxRequireSuspense = createRule21({
|
|
1626
1688
|
name: "jsx-require-suspense",
|
|
1627
1689
|
meta: {
|
|
1628
1690
|
type: "problem",
|
|
@@ -1640,7 +1702,7 @@ var jsxRequireSuspense = createRule20({
|
|
|
1640
1702
|
const isInsideSuspense = (node) => {
|
|
1641
1703
|
let current = node.parent;
|
|
1642
1704
|
while (current) {
|
|
1643
|
-
if (current.type ===
|
|
1705
|
+
if (current.type === import_utils25.AST_NODE_TYPES.JSXElement && current.openingElement.name.type === import_utils25.AST_NODE_TYPES.JSXIdentifier && current.openingElement.name.name === "Suspense") {
|
|
1644
1706
|
return true;
|
|
1645
1707
|
}
|
|
1646
1708
|
current = current.parent;
|
|
@@ -1649,16 +1711,16 @@ var jsxRequireSuspense = createRule20({
|
|
|
1649
1711
|
};
|
|
1650
1712
|
return {
|
|
1651
1713
|
VariableDeclarator(node) {
|
|
1652
|
-
if (node.id.type ===
|
|
1714
|
+
if (node.id.type === import_utils25.AST_NODE_TYPES.Identifier && node.init?.type === import_utils25.AST_NODE_TYPES.CallExpression) {
|
|
1653
1715
|
const { callee } = node.init;
|
|
1654
|
-
const isLazyCall = callee.type ===
|
|
1716
|
+
const isLazyCall = callee.type === import_utils25.AST_NODE_TYPES.Identifier && callee.name === "lazy" || callee.type === import_utils25.AST_NODE_TYPES.MemberExpression && callee.object.type === import_utils25.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === import_utils25.AST_NODE_TYPES.Identifier && callee.property.name === "lazy";
|
|
1655
1717
|
if (isLazyCall) {
|
|
1656
1718
|
lazyComponents.add(node.id.name);
|
|
1657
1719
|
}
|
|
1658
1720
|
}
|
|
1659
1721
|
},
|
|
1660
1722
|
JSXOpeningElement(node) {
|
|
1661
|
-
if (node.name.type ===
|
|
1723
|
+
if (node.name.type === import_utils25.AST_NODE_TYPES.JSXIdentifier) {
|
|
1662
1724
|
const componentName = node.name.name;
|
|
1663
1725
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1664
1726
|
context.report({
|
|
@@ -1677,11 +1739,11 @@ var jsxRequireSuspense = createRule20({
|
|
|
1677
1739
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1678
1740
|
|
|
1679
1741
|
// src/rules/jsx-simple-props.ts
|
|
1680
|
-
var
|
|
1681
|
-
var
|
|
1742
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
1743
|
+
var createRule22 = import_utils26.ESLintUtils.RuleCreator(
|
|
1682
1744
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1683
1745
|
);
|
|
1684
|
-
var jsxSimpleProps =
|
|
1746
|
+
var jsxSimpleProps = createRule22({
|
|
1685
1747
|
name: "jsx-simple-props",
|
|
1686
1748
|
meta: {
|
|
1687
1749
|
type: "suggestion",
|
|
@@ -1696,25 +1758,25 @@ var jsxSimpleProps = createRule21({
|
|
|
1696
1758
|
defaultOptions: [],
|
|
1697
1759
|
create(context) {
|
|
1698
1760
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1761
|
+
import_utils26.AST_NODE_TYPES.Identifier,
|
|
1762
|
+
import_utils26.AST_NODE_TYPES.Literal,
|
|
1763
|
+
import_utils26.AST_NODE_TYPES.JSXElement,
|
|
1764
|
+
import_utils26.AST_NODE_TYPES.JSXFragment,
|
|
1765
|
+
import_utils26.AST_NODE_TYPES.MemberExpression,
|
|
1766
|
+
import_utils26.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
1767
|
+
import_utils26.AST_NODE_TYPES.FunctionExpression
|
|
1706
1768
|
]);
|
|
1707
1769
|
return {
|
|
1708
1770
|
JSXAttribute(node) {
|
|
1709
1771
|
if (!node.value) {
|
|
1710
1772
|
return;
|
|
1711
1773
|
}
|
|
1712
|
-
if (node.value.type ===
|
|
1774
|
+
if (node.value.type === import_utils26.AST_NODE_TYPES.Literal) {
|
|
1713
1775
|
return;
|
|
1714
1776
|
}
|
|
1715
|
-
if (node.value.type ===
|
|
1777
|
+
if (node.value.type === import_utils26.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1716
1778
|
const { expression } = node.value;
|
|
1717
|
-
if (expression.type ===
|
|
1779
|
+
if (expression.type === import_utils26.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1718
1780
|
return;
|
|
1719
1781
|
}
|
|
1720
1782
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1731,8 +1793,8 @@ var jsxSimpleProps = createRule21({
|
|
|
1731
1793
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1732
1794
|
|
|
1733
1795
|
// src/rules/jsx-sort-props.ts
|
|
1734
|
-
var
|
|
1735
|
-
var
|
|
1796
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
1797
|
+
var createRule23 = import_utils27.ESLintUtils.RuleCreator(
|
|
1736
1798
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1737
1799
|
);
|
|
1738
1800
|
var TYPE_GROUP = {
|
|
@@ -1746,15 +1808,15 @@ var TYPE_GROUP = {
|
|
|
1746
1808
|
SHORTHAND: 8
|
|
1747
1809
|
};
|
|
1748
1810
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1749
|
-
[
|
|
1750
|
-
[
|
|
1751
|
-
[
|
|
1752
|
-
[
|
|
1753
|
-
[
|
|
1754
|
-
[
|
|
1811
|
+
[import_utils27.AST_NODE_TYPES.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1812
|
+
[import_utils27.AST_NODE_TYPES.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1813
|
+
[import_utils27.AST_NODE_TYPES.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1814
|
+
[import_utils27.AST_NODE_TYPES.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1815
|
+
[import_utils27.AST_NODE_TYPES.JSXElement, TYPE_GROUP.JSX],
|
|
1816
|
+
[import_utils27.AST_NODE_TYPES.JSXFragment, TYPE_GROUP.JSX]
|
|
1755
1817
|
]);
|
|
1756
1818
|
function isHyphenatedName(node) {
|
|
1757
|
-
return node.name.type ===
|
|
1819
|
+
return node.name.type === import_utils27.AST_NODE_TYPES.JSXIdentifier && node.name.name.includes("-");
|
|
1758
1820
|
}
|
|
1759
1821
|
function getStringGroup(node) {
|
|
1760
1822
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1766,13 +1828,13 @@ function getLiteralValueGroup(value) {
|
|
|
1766
1828
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1767
1829
|
}
|
|
1768
1830
|
function getExpressionGroup(expression) {
|
|
1769
|
-
if (expression.type ===
|
|
1831
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.Literal) {
|
|
1770
1832
|
return getLiteralValueGroup(expression.value);
|
|
1771
1833
|
}
|
|
1772
|
-
if (expression.type ===
|
|
1834
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.TemplateLiteral) {
|
|
1773
1835
|
return null;
|
|
1774
1836
|
}
|
|
1775
|
-
if (expression.type ===
|
|
1837
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.Identifier && expression.name === "undefined") {
|
|
1776
1838
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1777
1839
|
}
|
|
1778
1840
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1781,17 +1843,17 @@ function getTypeGroup(node) {
|
|
|
1781
1843
|
if (node.value === null) {
|
|
1782
1844
|
return TYPE_GROUP.SHORTHAND;
|
|
1783
1845
|
}
|
|
1784
|
-
if (node.value.type ===
|
|
1846
|
+
if (node.value.type === import_utils27.AST_NODE_TYPES.Literal) {
|
|
1785
1847
|
if (typeof node.value.value === "string") {
|
|
1786
1848
|
return getStringGroup(node);
|
|
1787
1849
|
}
|
|
1788
1850
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1789
1851
|
}
|
|
1790
|
-
if (node.value.type !==
|
|
1852
|
+
if (node.value.type !== import_utils27.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1791
1853
|
return null;
|
|
1792
1854
|
}
|
|
1793
1855
|
const { expression } = node.value;
|
|
1794
|
-
if (expression.type ===
|
|
1856
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1795
1857
|
return null;
|
|
1796
1858
|
}
|
|
1797
1859
|
const group = getExpressionGroup(expression);
|
|
@@ -1803,7 +1865,7 @@ function getTypeGroup(node) {
|
|
|
1803
1865
|
function hasUnsortedProps(attributes) {
|
|
1804
1866
|
let lastGroup = 0;
|
|
1805
1867
|
return attributes.some((attribute) => {
|
|
1806
|
-
if (attribute.type ===
|
|
1868
|
+
if (attribute.type === import_utils27.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1807
1869
|
lastGroup = 0;
|
|
1808
1870
|
return false;
|
|
1809
1871
|
}
|
|
@@ -1827,7 +1889,7 @@ function getSegments(attributes) {
|
|
|
1827
1889
|
const result = [];
|
|
1828
1890
|
let current = [];
|
|
1829
1891
|
attributes.forEach((attr) => {
|
|
1830
|
-
if (attr.type ===
|
|
1892
|
+
if (attr.type === import_utils27.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1831
1893
|
if (current.length > 0) {
|
|
1832
1894
|
result.push(current);
|
|
1833
1895
|
current = [];
|
|
@@ -1841,7 +1903,7 @@ function getSegments(attributes) {
|
|
|
1841
1903
|
}
|
|
1842
1904
|
return result;
|
|
1843
1905
|
}
|
|
1844
|
-
var jsxSortProps =
|
|
1906
|
+
var jsxSortProps = createRule23({
|
|
1845
1907
|
name: "jsx-sort-props",
|
|
1846
1908
|
meta: {
|
|
1847
1909
|
type: "suggestion",
|
|
@@ -1876,11 +1938,11 @@ var jsxSortProps = createRule22({
|
|
|
1876
1938
|
var jsx_sort_props_default = jsxSortProps;
|
|
1877
1939
|
|
|
1878
1940
|
// src/rules/jsx-spread-props-last.ts
|
|
1879
|
-
var
|
|
1880
|
-
var
|
|
1941
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
1942
|
+
var createRule24 = import_utils28.ESLintUtils.RuleCreator(
|
|
1881
1943
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1882
1944
|
);
|
|
1883
|
-
var jsxSpreadPropsLast =
|
|
1945
|
+
var jsxSpreadPropsLast = createRule24({
|
|
1884
1946
|
name: "jsx-spread-props-last",
|
|
1885
1947
|
meta: {
|
|
1886
1948
|
type: "suggestion",
|
|
@@ -1899,12 +1961,12 @@ var jsxSpreadPropsLast = createRule23({
|
|
|
1899
1961
|
const { attributes } = node;
|
|
1900
1962
|
let lastNonSpreadIndex = -1;
|
|
1901
1963
|
attributes.forEach((attribute, index) => {
|
|
1902
|
-
if (attribute.type !==
|
|
1964
|
+
if (attribute.type !== import_utils28.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1903
1965
|
lastNonSpreadIndex = index;
|
|
1904
1966
|
}
|
|
1905
1967
|
});
|
|
1906
1968
|
attributes.forEach((attribute, index) => {
|
|
1907
|
-
if (attribute.type ===
|
|
1969
|
+
if (attribute.type === import_utils28.AST_NODE_TYPES.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1908
1970
|
context.report({
|
|
1909
1971
|
node: attribute,
|
|
1910
1972
|
messageId: "spreadNotLast"
|
|
@@ -1918,12 +1980,12 @@ var jsxSpreadPropsLast = createRule23({
|
|
|
1918
1980
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1919
1981
|
|
|
1920
1982
|
// src/rules/newline-after-multiline-block.ts
|
|
1921
|
-
var
|
|
1922
|
-
var
|
|
1983
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
1984
|
+
var createRule25 = import_utils29.ESLintUtils.RuleCreator(
|
|
1923
1985
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1924
1986
|
);
|
|
1925
1987
|
function isImportDeclaration(node) {
|
|
1926
|
-
return node.type ===
|
|
1988
|
+
return node.type === import_utils29.AST_NODE_TYPES.ImportDeclaration;
|
|
1927
1989
|
}
|
|
1928
1990
|
function checkStatements(statements, context) {
|
|
1929
1991
|
const { sourceCode } = context;
|
|
@@ -1958,7 +2020,7 @@ function checkStatements(statements, context) {
|
|
|
1958
2020
|
}
|
|
1959
2021
|
});
|
|
1960
2022
|
}
|
|
1961
|
-
var newlineAfterMultilineBlock =
|
|
2023
|
+
var newlineAfterMultilineBlock = createRule25({
|
|
1962
2024
|
name: "newline-after-multiline-block",
|
|
1963
2025
|
meta: {
|
|
1964
2026
|
type: "layout",
|
|
@@ -1986,11 +2048,11 @@ var newlineAfterMultilineBlock = createRule24({
|
|
|
1986
2048
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
1987
2049
|
|
|
1988
2050
|
// src/rules/newline-before-return.ts
|
|
1989
|
-
var
|
|
1990
|
-
var
|
|
2051
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
2052
|
+
var createRule26 = import_utils30.ESLintUtils.RuleCreator(
|
|
1991
2053
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1992
2054
|
);
|
|
1993
|
-
var newlineBeforeReturn =
|
|
2055
|
+
var newlineBeforeReturn = createRule26({
|
|
1994
2056
|
name: "newline-before-return",
|
|
1995
2057
|
meta: {
|
|
1996
2058
|
type: "layout",
|
|
@@ -2008,7 +2070,7 @@ var newlineBeforeReturn = createRule25({
|
|
|
2008
2070
|
const { sourceCode } = context;
|
|
2009
2071
|
function checkReturnStatement(node) {
|
|
2010
2072
|
const { parent } = node;
|
|
2011
|
-
if (!parent || parent.type !==
|
|
2073
|
+
if (!parent || parent.type !== import_utils30.AST_NODE_TYPES.BlockStatement) {
|
|
2012
2074
|
return;
|
|
2013
2075
|
}
|
|
2014
2076
|
const { body: statements } = parent;
|
|
@@ -2045,11 +2107,11 @@ var newlineBeforeReturn = createRule25({
|
|
|
2045
2107
|
var newline_before_return_default = newlineBeforeReturn;
|
|
2046
2108
|
|
|
2047
2109
|
// src/rules/nextjs-require-public-env.ts
|
|
2048
|
-
var
|
|
2049
|
-
var
|
|
2110
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
2111
|
+
var createRule27 = import_utils31.ESLintUtils.RuleCreator(
|
|
2050
2112
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2051
2113
|
);
|
|
2052
|
-
var nextjsRequirePublicEnv =
|
|
2114
|
+
var nextjsRequirePublicEnv = createRule27({
|
|
2053
2115
|
name: "nextjs-require-public-env",
|
|
2054
2116
|
meta: {
|
|
2055
2117
|
type: "problem",
|
|
@@ -2067,7 +2129,7 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2067
2129
|
return {
|
|
2068
2130
|
Program(node) {
|
|
2069
2131
|
const firstStatement = node.body[0];
|
|
2070
|
-
if (firstStatement?.type ===
|
|
2132
|
+
if (firstStatement?.type === import_utils31.AST_NODE_TYPES.ExpressionStatement && firstStatement.expression.type === import_utils31.AST_NODE_TYPES.Literal && firstStatement.expression.value === "use client") {
|
|
2071
2133
|
isClientComponent = true;
|
|
2072
2134
|
}
|
|
2073
2135
|
},
|
|
@@ -2075,7 +2137,7 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2075
2137
|
if (!isClientComponent) {
|
|
2076
2138
|
return;
|
|
2077
2139
|
}
|
|
2078
|
-
if (node.object.type ===
|
|
2140
|
+
if (node.object.type === import_utils31.AST_NODE_TYPES.MemberExpression && node.object.object.type === import_utils31.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === import_utils31.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === import_utils31.AST_NODE_TYPES.Identifier) {
|
|
2079
2141
|
const envVarName = node.property.name;
|
|
2080
2142
|
if (!envVarName.startsWith("NEXT_PUBLIC_") && envVarName !== "NODE_ENV") {
|
|
2081
2143
|
context.report({
|
|
@@ -2094,11 +2156,11 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2094
2156
|
var nextjs_require_public_env_default = nextjsRequirePublicEnv;
|
|
2095
2157
|
|
|
2096
2158
|
// src/rules/no-complex-inline-return.ts
|
|
2097
|
-
var
|
|
2098
|
-
var
|
|
2159
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2160
|
+
var createRule28 = import_utils32.ESLintUtils.RuleCreator(
|
|
2099
2161
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2100
2162
|
);
|
|
2101
|
-
var noComplexInlineReturn =
|
|
2163
|
+
var noComplexInlineReturn = createRule28({
|
|
2102
2164
|
name: "no-complex-inline-return",
|
|
2103
2165
|
meta: {
|
|
2104
2166
|
type: "suggestion",
|
|
@@ -2114,13 +2176,13 @@ var noComplexInlineReturn = createRule27({
|
|
|
2114
2176
|
create(context) {
|
|
2115
2177
|
const isComplexExpression = (node) => {
|
|
2116
2178
|
if (!node) return false;
|
|
2117
|
-
if (node.type ===
|
|
2179
|
+
if (node.type === import_utils32.AST_NODE_TYPES.ConditionalExpression) {
|
|
2118
2180
|
return true;
|
|
2119
2181
|
}
|
|
2120
|
-
if (node.type ===
|
|
2182
|
+
if (node.type === import_utils32.AST_NODE_TYPES.LogicalExpression) {
|
|
2121
2183
|
return true;
|
|
2122
2184
|
}
|
|
2123
|
-
if (node.type ===
|
|
2185
|
+
if (node.type === import_utils32.AST_NODE_TYPES.NewExpression) {
|
|
2124
2186
|
return true;
|
|
2125
2187
|
}
|
|
2126
2188
|
return false;
|
|
@@ -2140,11 +2202,11 @@ var noComplexInlineReturn = createRule27({
|
|
|
2140
2202
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
2141
2203
|
|
|
2142
2204
|
// src/rules/no-direct-date.ts
|
|
2143
|
-
var
|
|
2144
|
-
var
|
|
2205
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2206
|
+
var createRule29 = import_utils33.ESLintUtils.RuleCreator(
|
|
2145
2207
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2146
2208
|
);
|
|
2147
|
-
var noDirectDate =
|
|
2209
|
+
var noDirectDate = createRule29({
|
|
2148
2210
|
name: "no-direct-date",
|
|
2149
2211
|
meta: {
|
|
2150
2212
|
type: "problem",
|
|
@@ -2162,7 +2224,7 @@ var noDirectDate = createRule28({
|
|
|
2162
2224
|
create(context) {
|
|
2163
2225
|
return {
|
|
2164
2226
|
NewExpression(node) {
|
|
2165
|
-
if (node.callee.type ===
|
|
2227
|
+
if (node.callee.type === import_utils33.AST_NODE_TYPES.Identifier && node.callee.name === "Date") {
|
|
2166
2228
|
context.report({
|
|
2167
2229
|
node,
|
|
2168
2230
|
messageId: "noNewDate"
|
|
@@ -2170,7 +2232,7 @@ var noDirectDate = createRule28({
|
|
|
2170
2232
|
}
|
|
2171
2233
|
},
|
|
2172
2234
|
CallExpression(node) {
|
|
2173
|
-
if (node.callee.type ===
|
|
2235
|
+
if (node.callee.type === import_utils33.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils33.AST_NODE_TYPES.Identifier && node.callee.object.name === "Date" && node.callee.property.type === import_utils33.AST_NODE_TYPES.Identifier) {
|
|
2174
2236
|
const methodName = node.callee.property.name;
|
|
2175
2237
|
if (methodName === "now") {
|
|
2176
2238
|
context.report({
|
|
@@ -2193,11 +2255,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
2193
2255
|
|
|
2194
2256
|
// src/rules/no-emoji.ts
|
|
2195
2257
|
var import_emoji_regex = __toESM(require("emoji-regex"), 1);
|
|
2196
|
-
var
|
|
2197
|
-
var
|
|
2258
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2259
|
+
var createRule30 = import_utils34.ESLintUtils.RuleCreator(
|
|
2198
2260
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2199
2261
|
);
|
|
2200
|
-
var noEmoji =
|
|
2262
|
+
var noEmoji = createRule30({
|
|
2201
2263
|
name: "no-emoji",
|
|
2202
2264
|
meta: {
|
|
2203
2265
|
type: "problem",
|
|
@@ -2231,11 +2293,11 @@ var noEmoji = createRule29({
|
|
|
2231
2293
|
var no_emoji_default = noEmoji;
|
|
2232
2294
|
|
|
2233
2295
|
// src/rules/no-env-fallback.ts
|
|
2234
|
-
var
|
|
2235
|
-
var
|
|
2296
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2297
|
+
var createRule31 = import_utils35.ESLintUtils.RuleCreator(
|
|
2236
2298
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2237
2299
|
);
|
|
2238
|
-
var noEnvFallback =
|
|
2300
|
+
var noEnvFallback = createRule31({
|
|
2239
2301
|
name: "no-env-fallback",
|
|
2240
2302
|
meta: {
|
|
2241
2303
|
type: "problem",
|
|
@@ -2250,16 +2312,16 @@ var noEnvFallback = createRule30({
|
|
|
2250
2312
|
defaultOptions: [],
|
|
2251
2313
|
create(context) {
|
|
2252
2314
|
const isProcessEnvAccess = (node) => {
|
|
2253
|
-
if (node.type !==
|
|
2315
|
+
if (node.type !== import_utils35.AST_NODE_TYPES.MemberExpression) {
|
|
2254
2316
|
return false;
|
|
2255
2317
|
}
|
|
2256
2318
|
const { object } = node;
|
|
2257
|
-
if (object.type !==
|
|
2319
|
+
if (object.type !== import_utils35.AST_NODE_TYPES.MemberExpression) {
|
|
2258
2320
|
return false;
|
|
2259
2321
|
}
|
|
2260
2322
|
const processNode = object.object;
|
|
2261
2323
|
const envNode = object.property;
|
|
2262
|
-
return processNode.type ===
|
|
2324
|
+
return processNode.type === import_utils35.AST_NODE_TYPES.Identifier && processNode.name === "process" && envNode.type === import_utils35.AST_NODE_TYPES.Identifier && envNode.name === "env";
|
|
2263
2325
|
};
|
|
2264
2326
|
return {
|
|
2265
2327
|
LogicalExpression(node) {
|
|
@@ -2284,11 +2346,11 @@ var noEnvFallback = createRule30({
|
|
|
2284
2346
|
var no_env_fallback_default = noEnvFallback;
|
|
2285
2347
|
|
|
2286
2348
|
// src/rules/no-inline-default-export.ts
|
|
2287
|
-
var
|
|
2288
|
-
var
|
|
2349
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2350
|
+
var createRule32 = import_utils36.ESLintUtils.RuleCreator(
|
|
2289
2351
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2290
2352
|
);
|
|
2291
|
-
var noInlineDefaultExport =
|
|
2353
|
+
var noInlineDefaultExport = createRule32({
|
|
2292
2354
|
name: "no-inline-default-export",
|
|
2293
2355
|
meta: {
|
|
2294
2356
|
type: "suggestion",
|
|
@@ -2307,7 +2369,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2307
2369
|
return {
|
|
2308
2370
|
ExportDefaultDeclaration(node) {
|
|
2309
2371
|
const { declaration } = node;
|
|
2310
|
-
if (declaration.type ===
|
|
2372
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2311
2373
|
if (declaration.id) {
|
|
2312
2374
|
context.report({
|
|
2313
2375
|
node,
|
|
@@ -2322,7 +2384,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2322
2384
|
});
|
|
2323
2385
|
}
|
|
2324
2386
|
}
|
|
2325
|
-
if (declaration.type ===
|
|
2387
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.ClassDeclaration) {
|
|
2326
2388
|
if (declaration.id) {
|
|
2327
2389
|
context.report({
|
|
2328
2390
|
node,
|
|
@@ -2337,7 +2399,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2337
2399
|
});
|
|
2338
2400
|
}
|
|
2339
2401
|
}
|
|
2340
|
-
if (declaration.type ===
|
|
2402
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils36.AST_NODE_TYPES.FunctionExpression) {
|
|
2341
2403
|
context.report({
|
|
2342
2404
|
node,
|
|
2343
2405
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2350,14 +2412,14 @@ var noInlineDefaultExport = createRule31({
|
|
|
2350
2412
|
if (!declaration) {
|
|
2351
2413
|
return;
|
|
2352
2414
|
}
|
|
2353
|
-
if (declaration.type ===
|
|
2415
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2354
2416
|
context.report({
|
|
2355
2417
|
node,
|
|
2356
2418
|
messageId: "noInlineNamedExport",
|
|
2357
2419
|
data: { type: "function", name: declaration.id.name }
|
|
2358
2420
|
});
|
|
2359
2421
|
}
|
|
2360
|
-
if (declaration.type ===
|
|
2422
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2361
2423
|
context.report({
|
|
2362
2424
|
node,
|
|
2363
2425
|
messageId: "noInlineNamedExport",
|
|
@@ -2371,15 +2433,15 @@ var noInlineDefaultExport = createRule31({
|
|
|
2371
2433
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2372
2434
|
|
|
2373
2435
|
// src/rules/no-inline-nested-object.ts
|
|
2374
|
-
var
|
|
2375
|
-
var
|
|
2436
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2437
|
+
var createRule33 = import_utils37.ESLintUtils.RuleCreator(
|
|
2376
2438
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2377
2439
|
);
|
|
2378
2440
|
function isObjectOrArray(node) {
|
|
2379
|
-
return node.type ===
|
|
2441
|
+
return node.type === import_utils37.AST_NODE_TYPES.ObjectExpression || node.type === import_utils37.AST_NODE_TYPES.ArrayExpression || node.type === import_utils37.AST_NODE_TYPES.TSAsExpression;
|
|
2380
2442
|
}
|
|
2381
2443
|
function getInnerExpression(node) {
|
|
2382
|
-
if (node.type ===
|
|
2444
|
+
if (node.type === import_utils37.AST_NODE_TYPES.TSAsExpression) {
|
|
2383
2445
|
return getInnerExpression(node.expression);
|
|
2384
2446
|
}
|
|
2385
2447
|
return node;
|
|
@@ -2388,10 +2450,10 @@ function arrayContainsOnlyPrimitives(node) {
|
|
|
2388
2450
|
return node.elements.every((el) => {
|
|
2389
2451
|
if (el === null) return true;
|
|
2390
2452
|
const inner = getInnerExpression(el);
|
|
2391
|
-
return inner.type ===
|
|
2453
|
+
return inner.type === import_utils37.AST_NODE_TYPES.Literal || inner.type === import_utils37.AST_NODE_TYPES.Identifier || inner.type === import_utils37.AST_NODE_TYPES.TemplateLiteral || inner.type === import_utils37.AST_NODE_TYPES.UnaryExpression;
|
|
2392
2454
|
});
|
|
2393
2455
|
}
|
|
2394
|
-
var noInlineNestedObject =
|
|
2456
|
+
var noInlineNestedObject = createRule33({
|
|
2395
2457
|
name: "no-inline-nested-object",
|
|
2396
2458
|
meta: {
|
|
2397
2459
|
type: "layout",
|
|
@@ -2413,17 +2475,17 @@ var noInlineNestedObject = createRule32({
|
|
|
2413
2475
|
return;
|
|
2414
2476
|
}
|
|
2415
2477
|
const valueNode = getInnerExpression(node.value);
|
|
2416
|
-
if (valueNode.type !==
|
|
2478
|
+
if (valueNode.type !== import_utils37.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils37.AST_NODE_TYPES.ArrayExpression) {
|
|
2417
2479
|
return;
|
|
2418
2480
|
}
|
|
2419
2481
|
if (!valueNode.loc) {
|
|
2420
2482
|
return;
|
|
2421
2483
|
}
|
|
2422
|
-
const elements = valueNode.type ===
|
|
2484
|
+
const elements = valueNode.type === import_utils37.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2423
2485
|
if (elements.length <= 1) {
|
|
2424
2486
|
return;
|
|
2425
2487
|
}
|
|
2426
|
-
if (valueNode.type ===
|
|
2488
|
+
if (valueNode.type === import_utils37.AST_NODE_TYPES.ArrayExpression && arrayContainsOnlyPrimitives(valueNode)) {
|
|
2427
2489
|
return;
|
|
2428
2490
|
}
|
|
2429
2491
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
@@ -2442,7 +2504,7 @@ var noInlineNestedObject = createRule32({
|
|
|
2442
2504
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2443
2505
|
const innerIndent = `${indent} `;
|
|
2444
2506
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2445
|
-
const isObject = valueNode.type ===
|
|
2507
|
+
const isObject = valueNode.type === import_utils37.AST_NODE_TYPES.ObjectExpression;
|
|
2446
2508
|
const openChar = isObject ? "{" : "[";
|
|
2447
2509
|
const closeChar = isObject ? "}" : "]";
|
|
2448
2510
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2459,20 +2521,20 @@ ${indent}${closeChar}`;
|
|
|
2459
2521
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2460
2522
|
|
|
2461
2523
|
// src/rules/no-inline-return-properties.ts
|
|
2462
|
-
var
|
|
2463
|
-
var
|
|
2524
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2525
|
+
var createRule34 = import_utils38.ESLintUtils.RuleCreator(
|
|
2464
2526
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2465
2527
|
);
|
|
2466
2528
|
var isShorthandProperty = (property) => {
|
|
2467
|
-
if (property.type ===
|
|
2529
|
+
if (property.type === import_utils38.AST_NODE_TYPES.SpreadElement) {
|
|
2468
2530
|
return true;
|
|
2469
2531
|
}
|
|
2470
|
-
if (property.type !==
|
|
2532
|
+
if (property.type !== import_utils38.AST_NODE_TYPES.Property) {
|
|
2471
2533
|
return false;
|
|
2472
2534
|
}
|
|
2473
2535
|
return property.shorthand;
|
|
2474
2536
|
};
|
|
2475
|
-
var noInlineReturnProperties =
|
|
2537
|
+
var noInlineReturnProperties = createRule34({
|
|
2476
2538
|
name: "no-inline-return-properties",
|
|
2477
2539
|
meta: {
|
|
2478
2540
|
type: "suggestion",
|
|
@@ -2488,20 +2550,20 @@ var noInlineReturnProperties = createRule33({
|
|
|
2488
2550
|
create(context) {
|
|
2489
2551
|
return {
|
|
2490
2552
|
ReturnStatement(node) {
|
|
2491
|
-
if (!node.argument || node.argument.type !==
|
|
2553
|
+
if (!node.argument || node.argument.type !== import_utils38.AST_NODE_TYPES.ObjectExpression) {
|
|
2492
2554
|
return;
|
|
2493
2555
|
}
|
|
2494
2556
|
node.argument.properties.forEach((property) => {
|
|
2495
2557
|
if (isShorthandProperty(property)) {
|
|
2496
2558
|
return;
|
|
2497
2559
|
}
|
|
2498
|
-
if (property.type !==
|
|
2560
|
+
if (property.type !== import_utils38.AST_NODE_TYPES.Property) {
|
|
2499
2561
|
return;
|
|
2500
2562
|
}
|
|
2501
2563
|
let keyName = null;
|
|
2502
|
-
if (property.key.type ===
|
|
2564
|
+
if (property.key.type === import_utils38.AST_NODE_TYPES.Identifier) {
|
|
2503
2565
|
keyName = property.key.name;
|
|
2504
|
-
} else if (property.key.type ===
|
|
2566
|
+
} else if (property.key.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2505
2567
|
keyName = String(property.key.value);
|
|
2506
2568
|
}
|
|
2507
2569
|
context.report({
|
|
@@ -2516,9 +2578,83 @@ var noInlineReturnProperties = createRule33({
|
|
|
2516
2578
|
});
|
|
2517
2579
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2518
2580
|
|
|
2581
|
+
// src/rules/no-inline-type-import.ts
|
|
2582
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2583
|
+
var createRule35 = import_utils39.ESLintUtils.RuleCreator(
|
|
2584
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2585
|
+
);
|
|
2586
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === import_utils39.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2587
|
+
var noInlineTypeImport = createRule35({
|
|
2588
|
+
name: "no-inline-type-import",
|
|
2589
|
+
meta: {
|
|
2590
|
+
type: "suggestion",
|
|
2591
|
+
docs: {
|
|
2592
|
+
description: "Disallow inline 'type' markers on import specifiers. Use 'import type' or split into a separate type-only import statement."
|
|
2593
|
+
},
|
|
2594
|
+
fixable: "code",
|
|
2595
|
+
messages: {
|
|
2596
|
+
noInlineTypeImport: "Avoid inline 'type' markers on import specifiers. Hoist to 'import type' or split into a separate type-only import statement."
|
|
2597
|
+
},
|
|
2598
|
+
schema: []
|
|
2599
|
+
},
|
|
2600
|
+
defaultOptions: [],
|
|
2601
|
+
create(context) {
|
|
2602
|
+
return {
|
|
2603
|
+
ImportDeclaration(node) {
|
|
2604
|
+
const inlineTypeSpecifiers = node.specifiers.filter(isInlineTypeSpecifier);
|
|
2605
|
+
if (inlineTypeSpecifiers.length === 0) {
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2608
|
+
context.report({
|
|
2609
|
+
node,
|
|
2610
|
+
messageId: "noInlineTypeImport",
|
|
2611
|
+
fix(fixer) {
|
|
2612
|
+
if (node.importKind === "type") {
|
|
2613
|
+
return inlineTypeSpecifiers.map(
|
|
2614
|
+
(specifier) => fixer.removeRange([specifier.range[0], specifier.imported.range[0]])
|
|
2615
|
+
);
|
|
2616
|
+
}
|
|
2617
|
+
const sourceText = context.sourceCode.getText(node.source);
|
|
2618
|
+
const fileText = context.sourceCode.text;
|
|
2619
|
+
const typeSpecifierTexts = inlineTypeSpecifiers.map(
|
|
2620
|
+
(specifier) => fileText.slice(specifier.imported.range[0], specifier.range[1])
|
|
2621
|
+
);
|
|
2622
|
+
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2623
|
+
const valueSpecifiers = node.specifiers.filter(
|
|
2624
|
+
(specifier) => !(specifier.type === import_utils39.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type")
|
|
2625
|
+
);
|
|
2626
|
+
if (valueSpecifiers.length === 0) {
|
|
2627
|
+
return fixer.replaceText(node, typeImport);
|
|
2628
|
+
}
|
|
2629
|
+
const parts = [];
|
|
2630
|
+
const namedValueSpecifiers = [];
|
|
2631
|
+
for (const specifier of valueSpecifiers) {
|
|
2632
|
+
if (specifier.type === import_utils39.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
2633
|
+
parts.push(specifier.local.name);
|
|
2634
|
+
} else if (specifier.type === import_utils39.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
2635
|
+
parts.push(`* as ${specifier.local.name}`);
|
|
2636
|
+
} else if (specifier.type === import_utils39.AST_NODE_TYPES.ImportSpecifier) {
|
|
2637
|
+
namedValueSpecifiers.push(specifier);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
if (namedValueSpecifiers.length > 0) {
|
|
2641
|
+
const namedTexts = namedValueSpecifiers.map((specifier) => context.sourceCode.getText(specifier));
|
|
2642
|
+
parts.push(`{ ${namedTexts.join(", ")} }`);
|
|
2643
|
+
}
|
|
2644
|
+
const valueImport = `import ${parts.join(", ")} from ${sourceText};`;
|
|
2645
|
+
return fixer.replaceText(node, `${valueImport}
|
|
2646
|
+
${typeImport}`);
|
|
2647
|
+
}
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
var no_inline_type_import_default = noInlineTypeImport;
|
|
2654
|
+
|
|
2519
2655
|
// src/rules/no-lazy-identifiers.ts
|
|
2520
|
-
var
|
|
2521
|
-
var
|
|
2656
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2657
|
+
var createRule36 = import_utils40.ESLintUtils.RuleCreator(
|
|
2522
2658
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2523
2659
|
);
|
|
2524
2660
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2559,7 +2695,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2559
2695
|
}
|
|
2560
2696
|
return false;
|
|
2561
2697
|
};
|
|
2562
|
-
var noLazyIdentifiers =
|
|
2698
|
+
var noLazyIdentifiers = createRule36({
|
|
2563
2699
|
name: "no-lazy-identifiers",
|
|
2564
2700
|
meta: {
|
|
2565
2701
|
type: "problem",
|
|
@@ -2585,27 +2721,27 @@ var noLazyIdentifiers = createRule34({
|
|
|
2585
2721
|
});
|
|
2586
2722
|
};
|
|
2587
2723
|
const checkPattern = (pattern) => {
|
|
2588
|
-
if (pattern.type ===
|
|
2724
|
+
if (pattern.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2589
2725
|
checkIdentifier(pattern);
|
|
2590
|
-
} else if (pattern.type ===
|
|
2726
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.ObjectPattern) {
|
|
2591
2727
|
pattern.properties.forEach((prop) => {
|
|
2592
|
-
if (prop.type ===
|
|
2728
|
+
if (prop.type === import_utils40.AST_NODE_TYPES.Property && prop.value.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2593
2729
|
checkIdentifier(prop.value);
|
|
2594
|
-
} else if (prop.type ===
|
|
2730
|
+
} else if (prop.type === import_utils40.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2595
2731
|
checkIdentifier(prop.argument);
|
|
2596
2732
|
}
|
|
2597
2733
|
});
|
|
2598
|
-
} else if (pattern.type ===
|
|
2734
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.ArrayPattern) {
|
|
2599
2735
|
pattern.elements.forEach((element) => {
|
|
2600
|
-
if (element?.type ===
|
|
2736
|
+
if (element?.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2601
2737
|
checkIdentifier(element);
|
|
2602
|
-
} else if (element?.type ===
|
|
2738
|
+
} else if (element?.type === import_utils40.AST_NODE_TYPES.RestElement && element.argument.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2603
2739
|
checkIdentifier(element.argument);
|
|
2604
2740
|
}
|
|
2605
2741
|
});
|
|
2606
|
-
} else if (pattern.type ===
|
|
2742
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2607
2743
|
checkIdentifier(pattern.left);
|
|
2608
|
-
} else if (pattern.type ===
|
|
2744
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2609
2745
|
checkIdentifier(pattern.argument);
|
|
2610
2746
|
}
|
|
2611
2747
|
};
|
|
@@ -2650,11 +2786,11 @@ var noLazyIdentifiers = createRule34({
|
|
|
2650
2786
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2651
2787
|
|
|
2652
2788
|
// src/rules/no-logic-in-params.ts
|
|
2653
|
-
var
|
|
2654
|
-
var
|
|
2789
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2790
|
+
var createRule37 = import_utils41.ESLintUtils.RuleCreator(
|
|
2655
2791
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2656
2792
|
);
|
|
2657
|
-
var noLogicInParams =
|
|
2793
|
+
var noLogicInParams = createRule37({
|
|
2658
2794
|
name: "no-logic-in-params",
|
|
2659
2795
|
meta: {
|
|
2660
2796
|
type: "suggestion",
|
|
@@ -2669,20 +2805,20 @@ var noLogicInParams = createRule35({
|
|
|
2669
2805
|
defaultOptions: [],
|
|
2670
2806
|
create(context) {
|
|
2671
2807
|
const isComplexExpression = (node) => {
|
|
2672
|
-
if (node.type ===
|
|
2808
|
+
if (node.type === import_utils41.AST_NODE_TYPES.SpreadElement) {
|
|
2673
2809
|
return false;
|
|
2674
2810
|
}
|
|
2675
|
-
if (node.type ===
|
|
2811
|
+
if (node.type === import_utils41.AST_NODE_TYPES.ConditionalExpression) {
|
|
2676
2812
|
return true;
|
|
2677
2813
|
}
|
|
2678
|
-
if (node.type ===
|
|
2814
|
+
if (node.type === import_utils41.AST_NODE_TYPES.LogicalExpression) {
|
|
2679
2815
|
return true;
|
|
2680
2816
|
}
|
|
2681
|
-
if (node.type ===
|
|
2817
|
+
if (node.type === import_utils41.AST_NODE_TYPES.BinaryExpression) {
|
|
2682
2818
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2683
2819
|
return logicalOperators.includes(node.operator);
|
|
2684
2820
|
}
|
|
2685
|
-
if (node.type ===
|
|
2821
|
+
if (node.type === import_utils41.AST_NODE_TYPES.UnaryExpression) {
|
|
2686
2822
|
return node.operator === "!";
|
|
2687
2823
|
}
|
|
2688
2824
|
return false;
|
|
@@ -2695,7 +2831,7 @@ var noLogicInParams = createRule35({
|
|
|
2695
2831
|
messageId: "noLogicInParams"
|
|
2696
2832
|
});
|
|
2697
2833
|
}
|
|
2698
|
-
if (arg.type ===
|
|
2834
|
+
if (arg.type === import_utils41.AST_NODE_TYPES.ArrayExpression) {
|
|
2699
2835
|
arg.elements.forEach((element) => {
|
|
2700
2836
|
if (element && isComplexExpression(element)) {
|
|
2701
2837
|
context.report({
|
|
@@ -2720,46 +2856,46 @@ var noLogicInParams = createRule35({
|
|
|
2720
2856
|
var no_logic_in_params_default = noLogicInParams;
|
|
2721
2857
|
|
|
2722
2858
|
// src/rules/no-misleading-constant-case.ts
|
|
2723
|
-
var
|
|
2724
|
-
var
|
|
2859
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2860
|
+
var createRule38 = import_utils42.ESLintUtils.RuleCreator(
|
|
2725
2861
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2726
2862
|
);
|
|
2727
2863
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2728
|
-
var isAsConstAssertion2 = (node) => node.type ===
|
|
2864
|
+
var isAsConstAssertion2 = (node) => node.type === import_utils42.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === import_utils42.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils42.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2729
2865
|
var isStaticValue3 = (init) => {
|
|
2730
2866
|
if (isAsConstAssertion2(init)) {
|
|
2731
2867
|
return true;
|
|
2732
2868
|
}
|
|
2733
|
-
if (init.type ===
|
|
2869
|
+
if (init.type === import_utils42.AST_NODE_TYPES.Literal) {
|
|
2734
2870
|
return true;
|
|
2735
2871
|
}
|
|
2736
|
-
if (init.type ===
|
|
2872
|
+
if (init.type === import_utils42.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils42.AST_NODE_TYPES.Literal) {
|
|
2737
2873
|
return true;
|
|
2738
2874
|
}
|
|
2739
|
-
if (init.type ===
|
|
2875
|
+
if (init.type === import_utils42.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2740
2876
|
return true;
|
|
2741
2877
|
}
|
|
2742
|
-
if (init.type ===
|
|
2743
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
2878
|
+
if (init.type === import_utils42.AST_NODE_TYPES.ArrayExpression) {
|
|
2879
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils42.AST_NODE_TYPES.SpreadElement && isStaticValue3(el));
|
|
2744
2880
|
}
|
|
2745
|
-
if (init.type ===
|
|
2881
|
+
if (init.type === import_utils42.AST_NODE_TYPES.ObjectExpression) {
|
|
2746
2882
|
return init.properties.every(
|
|
2747
|
-
(prop) => prop.type ===
|
|
2883
|
+
(prop) => prop.type === import_utils42.AST_NODE_TYPES.Property && isStaticValue3(prop.value)
|
|
2748
2884
|
);
|
|
2749
2885
|
}
|
|
2750
2886
|
return false;
|
|
2751
2887
|
};
|
|
2752
2888
|
var isGlobalScope3 = (node) => {
|
|
2753
2889
|
const { parent } = node;
|
|
2754
|
-
if (parent.type ===
|
|
2890
|
+
if (parent.type === import_utils42.AST_NODE_TYPES.Program) {
|
|
2755
2891
|
return true;
|
|
2756
2892
|
}
|
|
2757
|
-
if (parent.type ===
|
|
2893
|
+
if (parent.type === import_utils42.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils42.AST_NODE_TYPES.Program) {
|
|
2758
2894
|
return true;
|
|
2759
2895
|
}
|
|
2760
2896
|
return false;
|
|
2761
2897
|
};
|
|
2762
|
-
var noMisleadingConstantCase =
|
|
2898
|
+
var noMisleadingConstantCase = createRule38({
|
|
2763
2899
|
name: "no-misleading-constant-case",
|
|
2764
2900
|
meta: {
|
|
2765
2901
|
type: "suggestion",
|
|
@@ -2778,7 +2914,7 @@ var noMisleadingConstantCase = createRule36({
|
|
|
2778
2914
|
return {
|
|
2779
2915
|
VariableDeclaration(node) {
|
|
2780
2916
|
node.declarations.forEach((declarator) => {
|
|
2781
|
-
if (declarator.id.type !==
|
|
2917
|
+
if (declarator.id.type !== import_utils42.AST_NODE_TYPES.Identifier) {
|
|
2782
2918
|
return;
|
|
2783
2919
|
}
|
|
2784
2920
|
const { name } = declarator.id;
|
|
@@ -2819,11 +2955,11 @@ var noMisleadingConstantCase = createRule36({
|
|
|
2819
2955
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2820
2956
|
|
|
2821
2957
|
// src/rules/no-nested-interface-declaration.ts
|
|
2822
|
-
var
|
|
2823
|
-
var
|
|
2958
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2959
|
+
var createRule39 = import_utils43.ESLintUtils.RuleCreator(
|
|
2824
2960
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2825
2961
|
);
|
|
2826
|
-
var noNestedInterfaceDeclaration =
|
|
2962
|
+
var noNestedInterfaceDeclaration = createRule39({
|
|
2827
2963
|
name: "no-nested-interface-declaration",
|
|
2828
2964
|
meta: {
|
|
2829
2965
|
type: "suggestion",
|
|
@@ -2844,15 +2980,15 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2844
2980
|
return;
|
|
2845
2981
|
}
|
|
2846
2982
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2847
|
-
if (typeAnnotation.type ===
|
|
2983
|
+
if (typeAnnotation.type === import_utils43.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2848
2984
|
context.report({
|
|
2849
2985
|
node: typeAnnotation,
|
|
2850
2986
|
messageId: "noNestedInterface"
|
|
2851
2987
|
});
|
|
2852
2988
|
return;
|
|
2853
2989
|
}
|
|
2854
|
-
if (typeAnnotation.type ===
|
|
2855
|
-
if (typeAnnotation.elementType.type ===
|
|
2990
|
+
if (typeAnnotation.type === import_utils43.AST_NODE_TYPES.TSArrayType) {
|
|
2991
|
+
if (typeAnnotation.elementType.type === import_utils43.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2856
2992
|
context.report({
|
|
2857
2993
|
node: typeAnnotation.elementType,
|
|
2858
2994
|
messageId: "noNestedInterface"
|
|
@@ -2860,9 +2996,9 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2860
2996
|
}
|
|
2861
2997
|
return;
|
|
2862
2998
|
}
|
|
2863
|
-
if (typeAnnotation.type ===
|
|
2999
|
+
if (typeAnnotation.type === import_utils43.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2864
3000
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2865
|
-
if (param.type ===
|
|
3001
|
+
if (param.type === import_utils43.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2866
3002
|
context.report({
|
|
2867
3003
|
node: param,
|
|
2868
3004
|
messageId: "noNestedInterface"
|
|
@@ -2877,11 +3013,11 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2877
3013
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2878
3014
|
|
|
2879
3015
|
// src/rules/no-nested-ternary.ts
|
|
2880
|
-
var
|
|
2881
|
-
var
|
|
3016
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
3017
|
+
var createRule40 = import_utils44.ESLintUtils.RuleCreator(
|
|
2882
3018
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2883
3019
|
);
|
|
2884
|
-
var noNestedTernary =
|
|
3020
|
+
var noNestedTernary = createRule40({
|
|
2885
3021
|
name: "no-nested-ternary",
|
|
2886
3022
|
meta: {
|
|
2887
3023
|
type: "suggestion",
|
|
@@ -2898,13 +3034,13 @@ var noNestedTernary = createRule38({
|
|
|
2898
3034
|
return {
|
|
2899
3035
|
ConditionalExpression(node) {
|
|
2900
3036
|
const { consequent, alternate } = node;
|
|
2901
|
-
if (consequent.type ===
|
|
3037
|
+
if (consequent.type === import_utils44.AST_NODE_TYPES.ConditionalExpression) {
|
|
2902
3038
|
context.report({
|
|
2903
3039
|
node: consequent,
|
|
2904
3040
|
messageId: "noNestedTernary"
|
|
2905
3041
|
});
|
|
2906
3042
|
}
|
|
2907
|
-
if (alternate.type ===
|
|
3043
|
+
if (alternate.type === import_utils44.AST_NODE_TYPES.ConditionalExpression) {
|
|
2908
3044
|
context.report({
|
|
2909
3045
|
node: alternate,
|
|
2910
3046
|
messageId: "noNestedTernary"
|
|
@@ -2917,11 +3053,11 @@ var noNestedTernary = createRule38({
|
|
|
2917
3053
|
var no_nested_ternary_default = noNestedTernary;
|
|
2918
3054
|
|
|
2919
3055
|
// src/rules/no-relative-imports.ts
|
|
2920
|
-
var
|
|
2921
|
-
var
|
|
3056
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
3057
|
+
var createRule41 = import_utils45.ESLintUtils.RuleCreator(
|
|
2922
3058
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2923
3059
|
);
|
|
2924
|
-
var noRelativeImports =
|
|
3060
|
+
var noRelativeImports = createRule41({
|
|
2925
3061
|
name: "no-relative-imports",
|
|
2926
3062
|
meta: {
|
|
2927
3063
|
type: "suggestion",
|
|
@@ -2945,22 +3081,22 @@ var noRelativeImports = createRule39({
|
|
|
2945
3081
|
};
|
|
2946
3082
|
return {
|
|
2947
3083
|
ImportDeclaration(node) {
|
|
2948
|
-
if (node.source.type ===
|
|
3084
|
+
if (node.source.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2949
3085
|
checkImportPath(node.source.value, node);
|
|
2950
3086
|
}
|
|
2951
3087
|
},
|
|
2952
3088
|
ImportExpression(node) {
|
|
2953
|
-
if (node.source.type ===
|
|
3089
|
+
if (node.source.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2954
3090
|
checkImportPath(node.source.value, node);
|
|
2955
3091
|
}
|
|
2956
3092
|
},
|
|
2957
3093
|
ExportNamedDeclaration(node) {
|
|
2958
|
-
if (node.source?.type ===
|
|
3094
|
+
if (node.source?.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2959
3095
|
checkImportPath(node.source.value, node);
|
|
2960
3096
|
}
|
|
2961
3097
|
},
|
|
2962
3098
|
ExportAllDeclaration(node) {
|
|
2963
|
-
if (node.source.type ===
|
|
3099
|
+
if (node.source.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2964
3100
|
checkImportPath(node.source.value, node);
|
|
2965
3101
|
}
|
|
2966
3102
|
}
|
|
@@ -2970,8 +3106,8 @@ var noRelativeImports = createRule39({
|
|
|
2970
3106
|
var no_relative_imports_default = noRelativeImports;
|
|
2971
3107
|
|
|
2972
3108
|
// src/rules/no-single-char-variables.ts
|
|
2973
|
-
var
|
|
2974
|
-
var
|
|
3109
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3110
|
+
var createRule42 = import_utils46.ESLintUtils.RuleCreator(
|
|
2975
3111
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2976
3112
|
);
|
|
2977
3113
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -2983,7 +3119,7 @@ var isForLoopInit = (node) => {
|
|
|
2983
3119
|
if (!parentNode) {
|
|
2984
3120
|
return false;
|
|
2985
3121
|
}
|
|
2986
|
-
if (parentNode.type ===
|
|
3122
|
+
if (parentNode.type === import_utils46.AST_NODE_TYPES.ForStatement) {
|
|
2987
3123
|
const { init } = parentNode;
|
|
2988
3124
|
if (init && init === current) {
|
|
2989
3125
|
return true;
|
|
@@ -3002,7 +3138,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
3002
3138
|
}
|
|
3003
3139
|
return false;
|
|
3004
3140
|
};
|
|
3005
|
-
var noSingleCharVariables =
|
|
3141
|
+
var noSingleCharVariables = createRule42({
|
|
3006
3142
|
name: "no-single-char-variables",
|
|
3007
3143
|
meta: {
|
|
3008
3144
|
type: "suggestion",
|
|
@@ -3031,27 +3167,27 @@ var noSingleCharVariables = createRule40({
|
|
|
3031
3167
|
});
|
|
3032
3168
|
};
|
|
3033
3169
|
const checkPattern = (pattern, declarationNode) => {
|
|
3034
|
-
if (pattern.type ===
|
|
3170
|
+
if (pattern.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3035
3171
|
checkIdentifier(pattern, declarationNode);
|
|
3036
|
-
} else if (pattern.type ===
|
|
3172
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.ObjectPattern) {
|
|
3037
3173
|
pattern.properties.forEach((prop) => {
|
|
3038
|
-
if (prop.type ===
|
|
3174
|
+
if (prop.type === import_utils46.AST_NODE_TYPES.Property && prop.value.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3039
3175
|
checkIdentifier(prop.value, declarationNode);
|
|
3040
|
-
} else if (prop.type ===
|
|
3176
|
+
} else if (prop.type === import_utils46.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3041
3177
|
checkIdentifier(prop.argument, declarationNode);
|
|
3042
3178
|
}
|
|
3043
3179
|
});
|
|
3044
|
-
} else if (pattern.type ===
|
|
3180
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.ArrayPattern) {
|
|
3045
3181
|
pattern.elements.forEach((element) => {
|
|
3046
|
-
if (element?.type ===
|
|
3182
|
+
if (element?.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3047
3183
|
checkIdentifier(element, declarationNode);
|
|
3048
|
-
} else if (element?.type ===
|
|
3184
|
+
} else if (element?.type === import_utils46.AST_NODE_TYPES.RestElement && element.argument.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3049
3185
|
checkIdentifier(element.argument, declarationNode);
|
|
3050
3186
|
}
|
|
3051
3187
|
});
|
|
3052
|
-
} else if (pattern.type ===
|
|
3188
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3053
3189
|
checkIdentifier(pattern.left, declarationNode);
|
|
3054
|
-
} else if (pattern.type ===
|
|
3190
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3055
3191
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3056
3192
|
}
|
|
3057
3193
|
};
|
|
@@ -3085,11 +3221,11 @@ var noSingleCharVariables = createRule40({
|
|
|
3085
3221
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3086
3222
|
|
|
3087
3223
|
// src/rules/prefer-async-await.ts
|
|
3088
|
-
var
|
|
3089
|
-
var
|
|
3224
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3225
|
+
var createRule43 = import_utils47.ESLintUtils.RuleCreator(
|
|
3090
3226
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3091
3227
|
);
|
|
3092
|
-
var preferAsyncAwait =
|
|
3228
|
+
var preferAsyncAwait = createRule43({
|
|
3093
3229
|
name: "prefer-async-await",
|
|
3094
3230
|
meta: {
|
|
3095
3231
|
type: "suggestion",
|
|
@@ -3105,7 +3241,7 @@ var preferAsyncAwait = createRule41({
|
|
|
3105
3241
|
create(context) {
|
|
3106
3242
|
return {
|
|
3107
3243
|
CallExpression(node) {
|
|
3108
|
-
if (node.callee.type ===
|
|
3244
|
+
if (node.callee.type === import_utils47.AST_NODE_TYPES.MemberExpression && node.callee.property.type === import_utils47.AST_NODE_TYPES.Identifier && node.callee.property.name === "then") {
|
|
3109
3245
|
context.report({
|
|
3110
3246
|
node: node.callee.property,
|
|
3111
3247
|
messageId: "preferAsyncAwait"
|
|
@@ -3118,11 +3254,11 @@ var preferAsyncAwait = createRule41({
|
|
|
3118
3254
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3119
3255
|
|
|
3120
3256
|
// src/rules/prefer-destructuring-params.ts
|
|
3121
|
-
var
|
|
3122
|
-
var
|
|
3257
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3258
|
+
var createRule44 = import_utils48.ESLintUtils.RuleCreator(
|
|
3123
3259
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3124
3260
|
);
|
|
3125
|
-
var preferDestructuringParams =
|
|
3261
|
+
var preferDestructuringParams = createRule44({
|
|
3126
3262
|
name: "prefer-destructuring-params",
|
|
3127
3263
|
meta: {
|
|
3128
3264
|
type: "suggestion",
|
|
@@ -3138,18 +3274,18 @@ var preferDestructuringParams = createRule42({
|
|
|
3138
3274
|
create(context) {
|
|
3139
3275
|
const isCallbackFunction2 = (node) => {
|
|
3140
3276
|
const { parent } = node;
|
|
3141
|
-
return parent?.type ===
|
|
3277
|
+
return parent?.type === import_utils48.AST_NODE_TYPES.CallExpression;
|
|
3142
3278
|
};
|
|
3143
3279
|
const isDeveloperFunction = (node) => {
|
|
3144
|
-
if (node.type ===
|
|
3280
|
+
if (node.type === import_utils48.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3145
3281
|
return true;
|
|
3146
3282
|
}
|
|
3147
|
-
if (node.type ===
|
|
3283
|
+
if (node.type === import_utils48.AST_NODE_TYPES.FunctionExpression || node.type === import_utils48.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3148
3284
|
if (isCallbackFunction2(node)) {
|
|
3149
3285
|
return false;
|
|
3150
3286
|
}
|
|
3151
3287
|
const { parent } = node;
|
|
3152
|
-
return parent?.type ===
|
|
3288
|
+
return parent?.type === import_utils48.AST_NODE_TYPES.VariableDeclarator || parent?.type === import_utils48.AST_NODE_TYPES.AssignmentExpression || parent?.type === import_utils48.AST_NODE_TYPES.Property || parent?.type === import_utils48.AST_NODE_TYPES.MethodDefinition;
|
|
3153
3289
|
}
|
|
3154
3290
|
return false;
|
|
3155
3291
|
};
|
|
@@ -3161,7 +3297,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3161
3297
|
if (!isDeveloperFunction(node)) {
|
|
3162
3298
|
return;
|
|
3163
3299
|
}
|
|
3164
|
-
if (node.type ===
|
|
3300
|
+
if (node.type === import_utils48.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3165
3301
|
const functionName = node.id.name;
|
|
3166
3302
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3167
3303
|
return;
|
|
@@ -3171,7 +3307,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3171
3307
|
return;
|
|
3172
3308
|
}
|
|
3173
3309
|
const hasNonDestructuredParams = node.params.some(
|
|
3174
|
-
(param) => param.type !==
|
|
3310
|
+
(param) => param.type !== import_utils48.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils48.AST_NODE_TYPES.RestElement
|
|
3175
3311
|
);
|
|
3176
3312
|
if (hasNonDestructuredParams) {
|
|
3177
3313
|
context.report({
|
|
@@ -3190,8 +3326,8 @@ var preferDestructuringParams = createRule42({
|
|
|
3190
3326
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3191
3327
|
|
|
3192
3328
|
// src/rules/prefer-function-declaration.ts
|
|
3193
|
-
var
|
|
3194
|
-
var
|
|
3329
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3330
|
+
var createRule45 = import_utils49.ESLintUtils.RuleCreator(
|
|
3195
3331
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3196
3332
|
);
|
|
3197
3333
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3200,33 +3336,33 @@ var isCallbackContext = (node) => {
|
|
|
3200
3336
|
if (!parent) {
|
|
3201
3337
|
return false;
|
|
3202
3338
|
}
|
|
3203
|
-
if (parent.type ===
|
|
3339
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3204
3340
|
return true;
|
|
3205
3341
|
}
|
|
3206
|
-
if (parent.type ===
|
|
3342
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3207
3343
|
return true;
|
|
3208
3344
|
}
|
|
3209
|
-
if (parent.type ===
|
|
3345
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.ReturnStatement) {
|
|
3210
3346
|
return true;
|
|
3211
3347
|
}
|
|
3212
|
-
if (parent.type ===
|
|
3348
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.Property) {
|
|
3213
3349
|
return true;
|
|
3214
3350
|
}
|
|
3215
|
-
if (parent.type ===
|
|
3351
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.ArrayExpression) {
|
|
3216
3352
|
return true;
|
|
3217
3353
|
}
|
|
3218
|
-
if (parent.type ===
|
|
3354
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.ConditionalExpression) {
|
|
3219
3355
|
return true;
|
|
3220
3356
|
}
|
|
3221
|
-
if (parent.type ===
|
|
3357
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.LogicalExpression) {
|
|
3222
3358
|
return true;
|
|
3223
3359
|
}
|
|
3224
|
-
if (parent.type ===
|
|
3360
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3225
3361
|
return true;
|
|
3226
3362
|
}
|
|
3227
3363
|
return false;
|
|
3228
3364
|
};
|
|
3229
|
-
var preferFunctionDeclaration =
|
|
3365
|
+
var preferFunctionDeclaration = createRule45({
|
|
3230
3366
|
name: "prefer-function-declaration",
|
|
3231
3367
|
meta: {
|
|
3232
3368
|
type: "suggestion",
|
|
@@ -3247,14 +3383,14 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3247
3383
|
}
|
|
3248
3384
|
return {
|
|
3249
3385
|
VariableDeclarator(node) {
|
|
3250
|
-
if (node.id.type !==
|
|
3386
|
+
if (node.id.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3251
3387
|
return;
|
|
3252
3388
|
}
|
|
3253
3389
|
const { init } = node;
|
|
3254
3390
|
if (!init) {
|
|
3255
3391
|
return;
|
|
3256
3392
|
}
|
|
3257
|
-
if (init.type ===
|
|
3393
|
+
if (init.type === import_utils49.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3258
3394
|
if (isCallbackContext(init)) {
|
|
3259
3395
|
return;
|
|
3260
3396
|
}
|
|
@@ -3264,7 +3400,7 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3264
3400
|
data: { name: node.id.name }
|
|
3265
3401
|
});
|
|
3266
3402
|
}
|
|
3267
|
-
if (init.type ===
|
|
3403
|
+
if (init.type === import_utils49.AST_NODE_TYPES.FunctionExpression) {
|
|
3268
3404
|
if (isCallbackContext(init)) {
|
|
3269
3405
|
return;
|
|
3270
3406
|
}
|
|
@@ -3281,11 +3417,11 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3281
3417
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3282
3418
|
|
|
3283
3419
|
// src/rules/prefer-guard-clause.ts
|
|
3284
|
-
var
|
|
3285
|
-
var
|
|
3420
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3421
|
+
var createRule46 = import_utils50.ESLintUtils.RuleCreator(
|
|
3286
3422
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3287
3423
|
);
|
|
3288
|
-
var preferGuardClause =
|
|
3424
|
+
var preferGuardClause = createRule46({
|
|
3289
3425
|
name: "prefer-guard-clause",
|
|
3290
3426
|
meta: {
|
|
3291
3427
|
type: "suggestion",
|
|
@@ -3302,8 +3438,8 @@ var preferGuardClause = createRule44({
|
|
|
3302
3438
|
return {
|
|
3303
3439
|
IfStatement(node) {
|
|
3304
3440
|
const { consequent } = node;
|
|
3305
|
-
if (consequent.type ===
|
|
3306
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3441
|
+
if (consequent.type === import_utils50.AST_NODE_TYPES.BlockStatement) {
|
|
3442
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === import_utils50.AST_NODE_TYPES.IfStatement);
|
|
3307
3443
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3308
3444
|
context.report({
|
|
3309
3445
|
node,
|
|
@@ -3311,7 +3447,7 @@ var preferGuardClause = createRule44({
|
|
|
3311
3447
|
});
|
|
3312
3448
|
}
|
|
3313
3449
|
}
|
|
3314
|
-
if (consequent.type ===
|
|
3450
|
+
if (consequent.type === import_utils50.AST_NODE_TYPES.IfStatement) {
|
|
3315
3451
|
context.report({
|
|
3316
3452
|
node,
|
|
3317
3453
|
messageId: "preferGuardClause"
|
|
@@ -3324,11 +3460,11 @@ var preferGuardClause = createRule44({
|
|
|
3324
3460
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3325
3461
|
|
|
3326
3462
|
// src/rules/prefer-import-type.ts
|
|
3327
|
-
var
|
|
3328
|
-
var
|
|
3463
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
3464
|
+
var createRule47 = import_utils51.ESLintUtils.RuleCreator(
|
|
3329
3465
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3330
3466
|
);
|
|
3331
|
-
var preferImportType =
|
|
3467
|
+
var preferImportType = createRule47({
|
|
3332
3468
|
name: "prefer-import-type",
|
|
3333
3469
|
meta: {
|
|
3334
3470
|
type: "suggestion",
|
|
@@ -3347,22 +3483,22 @@ var preferImportType = createRule45({
|
|
|
3347
3483
|
let current = node;
|
|
3348
3484
|
while (current) {
|
|
3349
3485
|
switch (current.type) {
|
|
3350
|
-
case
|
|
3351
|
-
case
|
|
3352
|
-
case
|
|
3353
|
-
case
|
|
3354
|
-
case
|
|
3355
|
-
case
|
|
3356
|
-
case
|
|
3357
|
-
case
|
|
3358
|
-
case
|
|
3359
|
-
case
|
|
3360
|
-
case
|
|
3361
|
-
case
|
|
3362
|
-
case
|
|
3486
|
+
case import_utils51.AST_NODE_TYPES.TSTypeReference:
|
|
3487
|
+
case import_utils51.AST_NODE_TYPES.TSTypeAnnotation:
|
|
3488
|
+
case import_utils51.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
3489
|
+
case import_utils51.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
3490
|
+
case import_utils51.AST_NODE_TYPES.TSClassImplements:
|
|
3491
|
+
case import_utils51.AST_NODE_TYPES.TSTypeQuery:
|
|
3492
|
+
case import_utils51.AST_NODE_TYPES.TSTypeAssertion:
|
|
3493
|
+
case import_utils51.AST_NODE_TYPES.TSAsExpression:
|
|
3494
|
+
case import_utils51.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
3495
|
+
case import_utils51.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3496
|
+
case import_utils51.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3497
|
+
case import_utils51.AST_NODE_TYPES.TSTypeParameter:
|
|
3498
|
+
case import_utils51.AST_NODE_TYPES.TSQualifiedName:
|
|
3363
3499
|
return true;
|
|
3364
|
-
case
|
|
3365
|
-
case
|
|
3500
|
+
case import_utils51.AST_NODE_TYPES.MemberExpression:
|
|
3501
|
+
case import_utils51.AST_NODE_TYPES.Identifier:
|
|
3366
3502
|
current = current.parent;
|
|
3367
3503
|
break;
|
|
3368
3504
|
default:
|
|
@@ -3392,27 +3528,27 @@ var preferImportType = createRule45({
|
|
|
3392
3528
|
return false;
|
|
3393
3529
|
}
|
|
3394
3530
|
switch (parent.type) {
|
|
3395
|
-
case
|
|
3396
|
-
case
|
|
3397
|
-
case
|
|
3398
|
-
case
|
|
3399
|
-
case
|
|
3400
|
-
case
|
|
3401
|
-
case
|
|
3402
|
-
case
|
|
3403
|
-
case
|
|
3404
|
-
case
|
|
3405
|
-
case
|
|
3406
|
-
case
|
|
3407
|
-
case
|
|
3408
|
-
case
|
|
3409
|
-
case
|
|
3410
|
-
case
|
|
3411
|
-
case
|
|
3412
|
-
case
|
|
3413
|
-
case
|
|
3414
|
-
case
|
|
3415
|
-
case
|
|
3531
|
+
case import_utils51.AST_NODE_TYPES.CallExpression:
|
|
3532
|
+
case import_utils51.AST_NODE_TYPES.NewExpression:
|
|
3533
|
+
case import_utils51.AST_NODE_TYPES.JSXOpeningElement:
|
|
3534
|
+
case import_utils51.AST_NODE_TYPES.JSXClosingElement:
|
|
3535
|
+
case import_utils51.AST_NODE_TYPES.MemberExpression:
|
|
3536
|
+
case import_utils51.AST_NODE_TYPES.VariableDeclarator:
|
|
3537
|
+
case import_utils51.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
3538
|
+
case import_utils51.AST_NODE_TYPES.SpreadElement:
|
|
3539
|
+
case import_utils51.AST_NODE_TYPES.ExportSpecifier:
|
|
3540
|
+
case import_utils51.AST_NODE_TYPES.ArrayExpression:
|
|
3541
|
+
case import_utils51.AST_NODE_TYPES.ObjectExpression:
|
|
3542
|
+
case import_utils51.AST_NODE_TYPES.BinaryExpression:
|
|
3543
|
+
case import_utils51.AST_NODE_TYPES.LogicalExpression:
|
|
3544
|
+
case import_utils51.AST_NODE_TYPES.UnaryExpression:
|
|
3545
|
+
case import_utils51.AST_NODE_TYPES.ReturnStatement:
|
|
3546
|
+
case import_utils51.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
3547
|
+
case import_utils51.AST_NODE_TYPES.ConditionalExpression:
|
|
3548
|
+
case import_utils51.AST_NODE_TYPES.AwaitExpression:
|
|
3549
|
+
case import_utils51.AST_NODE_TYPES.YieldExpression:
|
|
3550
|
+
case import_utils51.AST_NODE_TYPES.Property:
|
|
3551
|
+
case import_utils51.AST_NODE_TYPES.JSXExpressionContainer:
|
|
3416
3552
|
return true;
|
|
3417
3553
|
default:
|
|
3418
3554
|
return false;
|
|
@@ -3436,13 +3572,13 @@ var preferImportType = createRule45({
|
|
|
3436
3572
|
}
|
|
3437
3573
|
const scope = context.sourceCode.getScope(node);
|
|
3438
3574
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3439
|
-
if (specifier.type ===
|
|
3575
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3440
3576
|
return false;
|
|
3441
3577
|
}
|
|
3442
|
-
if (specifier.type ===
|
|
3578
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3443
3579
|
return false;
|
|
3444
3580
|
}
|
|
3445
|
-
if (specifier.type ===
|
|
3581
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportSpecifier) {
|
|
3446
3582
|
const localName = specifier.local.name;
|
|
3447
3583
|
return !isUsedAsValue(localName, scope);
|
|
3448
3584
|
}
|
|
@@ -3468,19 +3604,19 @@ var preferImportType = createRule45({
|
|
|
3468
3604
|
var prefer_import_type_default = preferImportType;
|
|
3469
3605
|
|
|
3470
3606
|
// src/rules/prefer-inline-literal-union.ts
|
|
3471
|
-
var
|
|
3472
|
-
var
|
|
3607
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3608
|
+
var createRule48 = import_utils52.ESLintUtils.RuleCreator(
|
|
3473
3609
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3474
3610
|
);
|
|
3475
3611
|
function isLiteralUnionType(node) {
|
|
3476
|
-
if (node.type !==
|
|
3612
|
+
if (node.type !== import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
3477
3613
|
return false;
|
|
3478
3614
|
}
|
|
3479
3615
|
return node.types.every(
|
|
3480
|
-
(member) => member.type ===
|
|
3616
|
+
(member) => member.type === import_utils52.AST_NODE_TYPES.TSLiteralType || member.type === import_utils52.AST_NODE_TYPES.TSNullKeyword || member.type === import_utils52.AST_NODE_TYPES.TSUndefinedKeyword
|
|
3481
3617
|
);
|
|
3482
3618
|
}
|
|
3483
|
-
var preferInlineLiteralUnion =
|
|
3619
|
+
var preferInlineLiteralUnion = createRule48({
|
|
3484
3620
|
name: "prefer-inline-literal-union",
|
|
3485
3621
|
meta: {
|
|
3486
3622
|
type: "suggestion",
|
|
@@ -3507,10 +3643,10 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3507
3643
|
return;
|
|
3508
3644
|
}
|
|
3509
3645
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3510
|
-
if (typeAnnotation.type !==
|
|
3646
|
+
if (typeAnnotation.type !== import_utils52.AST_NODE_TYPES.TSTypeReference) {
|
|
3511
3647
|
return;
|
|
3512
3648
|
}
|
|
3513
|
-
if (typeAnnotation.typeName.type !==
|
|
3649
|
+
if (typeAnnotation.typeName.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3514
3650
|
return;
|
|
3515
3651
|
}
|
|
3516
3652
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3534,12 +3670,12 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3534
3670
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3535
3671
|
|
|
3536
3672
|
// src/rules/prefer-inline-type-export.ts
|
|
3537
|
-
var
|
|
3538
|
-
var
|
|
3673
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3674
|
+
var createRule49 = import_utils53.ESLintUtils.RuleCreator(
|
|
3539
3675
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3540
3676
|
);
|
|
3541
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3542
|
-
var preferInlineTypeExport =
|
|
3677
|
+
var isTypeDeclaration = (node) => node.type === import_utils53.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils53.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
3678
|
+
var preferInlineTypeExport = createRule49({
|
|
3543
3679
|
name: "prefer-inline-type-export",
|
|
3544
3680
|
meta: {
|
|
3545
3681
|
type: "suggestion",
|
|
@@ -3556,12 +3692,12 @@ var preferInlineTypeExport = createRule47({
|
|
|
3556
3692
|
create(context) {
|
|
3557
3693
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3558
3694
|
function collectDeclaration(node) {
|
|
3559
|
-
if (node.parent.type !==
|
|
3695
|
+
if (node.parent.type !== import_utils53.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3560
3696
|
typeDeclarations.set(node.id.name, node);
|
|
3561
3697
|
}
|
|
3562
3698
|
}
|
|
3563
3699
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3564
|
-
if (specifier.local.type !==
|
|
3700
|
+
if (specifier.local.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
3565
3701
|
return;
|
|
3566
3702
|
}
|
|
3567
3703
|
const { name } = specifier.local;
|
|
@@ -3594,16 +3730,16 @@ var preferInlineTypeExport = createRule47({
|
|
|
3594
3730
|
return {
|
|
3595
3731
|
Program(node) {
|
|
3596
3732
|
node.body.forEach((statement) => {
|
|
3597
|
-
if (statement.type ===
|
|
3733
|
+
if (statement.type === import_utils53.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils53.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3598
3734
|
collectDeclaration(statement);
|
|
3599
3735
|
}
|
|
3600
3736
|
});
|
|
3601
3737
|
node.body.forEach((statement) => {
|
|
3602
|
-
if (statement.type !==
|
|
3738
|
+
if (statement.type !== import_utils53.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3603
3739
|
return;
|
|
3604
3740
|
}
|
|
3605
3741
|
statement.specifiers.forEach((specifier) => {
|
|
3606
|
-
if (specifier.local.type !==
|
|
3742
|
+
if (specifier.local.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
3607
3743
|
return;
|
|
3608
3744
|
}
|
|
3609
3745
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3620,11 +3756,11 @@ var preferInlineTypeExport = createRule47({
|
|
|
3620
3756
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3621
3757
|
|
|
3622
3758
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3623
|
-
var
|
|
3624
|
-
var
|
|
3759
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3760
|
+
var createRule50 = import_utils54.ESLintUtils.RuleCreator(
|
|
3625
3761
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3626
3762
|
);
|
|
3627
|
-
var preferInterfaceOverInlineTypes =
|
|
3763
|
+
var preferInterfaceOverInlineTypes = createRule50({
|
|
3628
3764
|
name: "prefer-interface-over-inline-types",
|
|
3629
3765
|
meta: {
|
|
3630
3766
|
type: "suggestion",
|
|
@@ -3640,54 +3776,54 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3640
3776
|
defaultOptions: [],
|
|
3641
3777
|
create(context) {
|
|
3642
3778
|
function hasJSXInConditional(node) {
|
|
3643
|
-
return node.consequent.type ===
|
|
3779
|
+
return node.consequent.type === import_utils54.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils54.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils54.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils54.AST_NODE_TYPES.JSXFragment;
|
|
3644
3780
|
}
|
|
3645
3781
|
function hasJSXInLogical(node) {
|
|
3646
|
-
return node.right.type ===
|
|
3782
|
+
return node.right.type === import_utils54.AST_NODE_TYPES.JSXElement || node.right.type === import_utils54.AST_NODE_TYPES.JSXFragment;
|
|
3647
3783
|
}
|
|
3648
3784
|
function hasJSXReturn(block) {
|
|
3649
3785
|
return block.body.some((stmt) => {
|
|
3650
|
-
if (stmt.type ===
|
|
3651
|
-
return stmt.argument.type ===
|
|
3786
|
+
if (stmt.type === import_utils54.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
3787
|
+
return stmt.argument.type === import_utils54.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils54.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils54.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils54.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3652
3788
|
}
|
|
3653
3789
|
return false;
|
|
3654
3790
|
});
|
|
3655
3791
|
}
|
|
3656
3792
|
function isReactComponent2(node) {
|
|
3657
|
-
if (node.type ===
|
|
3658
|
-
if (node.body.type ===
|
|
3793
|
+
if (node.type === import_utils54.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3794
|
+
if (node.body.type === import_utils54.AST_NODE_TYPES.JSXElement || node.body.type === import_utils54.AST_NODE_TYPES.JSXFragment) {
|
|
3659
3795
|
return true;
|
|
3660
3796
|
}
|
|
3661
|
-
if (node.body.type ===
|
|
3797
|
+
if (node.body.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
3662
3798
|
return hasJSXReturn(node.body);
|
|
3663
3799
|
}
|
|
3664
|
-
} else if (node.type ===
|
|
3665
|
-
if (node.body && node.body.type ===
|
|
3800
|
+
} else if (node.type === import_utils54.AST_NODE_TYPES.FunctionExpression || node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3801
|
+
if (node.body && node.body.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
3666
3802
|
return hasJSXReturn(node.body);
|
|
3667
3803
|
}
|
|
3668
3804
|
}
|
|
3669
3805
|
return false;
|
|
3670
3806
|
}
|
|
3671
3807
|
function isInlineTypeAnnotation(node) {
|
|
3672
|
-
if (node.type ===
|
|
3808
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3673
3809
|
return true;
|
|
3674
3810
|
}
|
|
3675
|
-
if (node.type ===
|
|
3676
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3811
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3812
|
+
return node.typeArguments.params.some((param) => param.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral);
|
|
3677
3813
|
}
|
|
3678
|
-
if (node.type ===
|
|
3814
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSUnionType) {
|
|
3679
3815
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3680
3816
|
}
|
|
3681
3817
|
return false;
|
|
3682
3818
|
}
|
|
3683
3819
|
function hasInlineObjectType(node) {
|
|
3684
|
-
if (node.type ===
|
|
3820
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3685
3821
|
return true;
|
|
3686
3822
|
}
|
|
3687
|
-
if (node.type ===
|
|
3688
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3823
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3824
|
+
return node.typeArguments.params.some((param) => param.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral);
|
|
3689
3825
|
}
|
|
3690
|
-
if (node.type ===
|
|
3826
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSUnionType) {
|
|
3691
3827
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3692
3828
|
}
|
|
3693
3829
|
return false;
|
|
@@ -3700,7 +3836,7 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3700
3836
|
return;
|
|
3701
3837
|
}
|
|
3702
3838
|
const param = node.params[0];
|
|
3703
|
-
if (param.type ===
|
|
3839
|
+
if (param.type === import_utils54.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3704
3840
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3705
3841
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3706
3842
|
context.report({
|
|
@@ -3720,11 +3856,11 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3720
3856
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3721
3857
|
|
|
3722
3858
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3723
|
-
var
|
|
3724
|
-
var
|
|
3859
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
3860
|
+
var createRule51 = import_utils55.ESLintUtils.RuleCreator(
|
|
3725
3861
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3726
3862
|
);
|
|
3727
|
-
var preferJSXTemplateLiterals =
|
|
3863
|
+
var preferJSXTemplateLiterals = createRule51({
|
|
3728
3864
|
name: "prefer-jsx-template-literals",
|
|
3729
3865
|
meta: {
|
|
3730
3866
|
type: "suggestion",
|
|
@@ -3793,9 +3929,9 @@ var preferJSXTemplateLiterals = createRule49({
|
|
|
3793
3929
|
if (!child || !nextChild) {
|
|
3794
3930
|
return;
|
|
3795
3931
|
}
|
|
3796
|
-
if (child.type ===
|
|
3932
|
+
if (child.type === import_utils55.AST_NODE_TYPES.JSXText && nextChild.type === import_utils55.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3797
3933
|
handleTextBeforeExpression(child, nextChild);
|
|
3798
|
-
} else if (child.type ===
|
|
3934
|
+
} else if (child.type === import_utils55.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils55.AST_NODE_TYPES.JSXText) {
|
|
3799
3935
|
handleExpressionBeforeText(child, nextChild);
|
|
3800
3936
|
}
|
|
3801
3937
|
}
|
|
@@ -3808,11 +3944,11 @@ var preferJSXTemplateLiterals = createRule49({
|
|
|
3808
3944
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3809
3945
|
|
|
3810
3946
|
// src/rules/prefer-named-param-types.ts
|
|
3811
|
-
var
|
|
3812
|
-
var
|
|
3947
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
3948
|
+
var createRule52 = import_utils56.ESLintUtils.RuleCreator(
|
|
3813
3949
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3814
3950
|
);
|
|
3815
|
-
var preferNamedParamTypes =
|
|
3951
|
+
var preferNamedParamTypes = createRule52({
|
|
3816
3952
|
name: "prefer-named-param-types",
|
|
3817
3953
|
meta: {
|
|
3818
3954
|
type: "suggestion",
|
|
@@ -3827,16 +3963,16 @@ var preferNamedParamTypes = createRule50({
|
|
|
3827
3963
|
defaultOptions: [],
|
|
3828
3964
|
create(context) {
|
|
3829
3965
|
function hasInlineObjectType(param) {
|
|
3830
|
-
if (param.type ===
|
|
3966
|
+
if (param.type === import_utils56.AST_NODE_TYPES.AssignmentPattern) {
|
|
3831
3967
|
return hasInlineObjectType(param.left);
|
|
3832
3968
|
}
|
|
3833
|
-
if (param.type ===
|
|
3834
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3969
|
+
if (param.type === import_utils56.AST_NODE_TYPES.ObjectPattern) {
|
|
3970
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils56.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3835
3971
|
return true;
|
|
3836
3972
|
}
|
|
3837
3973
|
}
|
|
3838
|
-
if (param.type ===
|
|
3839
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3974
|
+
if (param.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
3975
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils56.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3840
3976
|
return true;
|
|
3841
3977
|
}
|
|
3842
3978
|
}
|
|
@@ -3870,11 +4006,11 @@ var preferNamedParamTypes = createRule50({
|
|
|
3870
4006
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3871
4007
|
|
|
3872
4008
|
// src/rules/prefer-react-import-types.ts
|
|
3873
|
-
var
|
|
3874
|
-
var
|
|
4009
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
4010
|
+
var createRule53 = import_utils57.ESLintUtils.RuleCreator(
|
|
3875
4011
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3876
4012
|
);
|
|
3877
|
-
var preferReactImportTypes =
|
|
4013
|
+
var preferReactImportTypes = createRule53({
|
|
3878
4014
|
name: "prefer-react-import-types",
|
|
3879
4015
|
meta: {
|
|
3880
4016
|
type: "suggestion",
|
|
@@ -3950,7 +4086,7 @@ var preferReactImportTypes = createRule51({
|
|
|
3950
4086
|
]);
|
|
3951
4087
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
3952
4088
|
function checkMemberExpression(node) {
|
|
3953
|
-
if (node.object.type ===
|
|
4089
|
+
if (node.object.type === import_utils57.AST_NODE_TYPES.Identifier && node.object.name === "React" && node.property.type === import_utils57.AST_NODE_TYPES.Identifier && allReactExports.has(node.property.name)) {
|
|
3954
4090
|
const typeName = node.property.name;
|
|
3955
4091
|
const isType = reactTypes.has(typeName);
|
|
3956
4092
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3967,7 +4103,7 @@ var preferReactImportTypes = createRule51({
|
|
|
3967
4103
|
return {
|
|
3968
4104
|
MemberExpression: checkMemberExpression,
|
|
3969
4105
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
3970
|
-
if (node.left.type ===
|
|
4106
|
+
if (node.left.type === import_utils57.AST_NODE_TYPES.Identifier && node.left.name === "React" && node.right.type === import_utils57.AST_NODE_TYPES.Identifier && allReactExports.has(node.right.name)) {
|
|
3971
4107
|
const typeName = node.right.name;
|
|
3972
4108
|
const isType = reactTypes.has(typeName);
|
|
3973
4109
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3987,11 +4123,11 @@ var preferReactImportTypes = createRule51({
|
|
|
3987
4123
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
3988
4124
|
|
|
3989
4125
|
// src/rules/react-props-destructure.ts
|
|
3990
|
-
var
|
|
3991
|
-
var
|
|
4126
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
4127
|
+
var createRule54 = import_utils58.ESLintUtils.RuleCreator(
|
|
3992
4128
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3993
4129
|
);
|
|
3994
|
-
var reactPropsDestructure =
|
|
4130
|
+
var reactPropsDestructure = createRule54({
|
|
3995
4131
|
name: "react-props-destructure",
|
|
3996
4132
|
meta: {
|
|
3997
4133
|
type: "suggestion",
|
|
@@ -4007,29 +4143,29 @@ var reactPropsDestructure = createRule52({
|
|
|
4007
4143
|
defaultOptions: [],
|
|
4008
4144
|
create(context) {
|
|
4009
4145
|
function hasJSXInConditional(node) {
|
|
4010
|
-
return node.consequent.type ===
|
|
4146
|
+
return node.consequent.type === import_utils58.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils58.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils58.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils58.AST_NODE_TYPES.JSXFragment;
|
|
4011
4147
|
}
|
|
4012
4148
|
function hasJSXInLogical(node) {
|
|
4013
|
-
return node.right.type ===
|
|
4149
|
+
return node.right.type === import_utils58.AST_NODE_TYPES.JSXElement || node.right.type === import_utils58.AST_NODE_TYPES.JSXFragment;
|
|
4014
4150
|
}
|
|
4015
4151
|
function hasJSXReturn(block) {
|
|
4016
4152
|
return block.body.some((stmt) => {
|
|
4017
|
-
if (stmt.type ===
|
|
4018
|
-
return stmt.argument.type ===
|
|
4153
|
+
if (stmt.type === import_utils58.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4154
|
+
return stmt.argument.type === import_utils58.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils58.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils58.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils58.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
4019
4155
|
}
|
|
4020
4156
|
return false;
|
|
4021
4157
|
});
|
|
4022
4158
|
}
|
|
4023
4159
|
function isReactComponent2(node) {
|
|
4024
|
-
if (node.type ===
|
|
4025
|
-
if (node.body.type ===
|
|
4160
|
+
if (node.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4161
|
+
if (node.body.type === import_utils58.AST_NODE_TYPES.JSXElement || node.body.type === import_utils58.AST_NODE_TYPES.JSXFragment) {
|
|
4026
4162
|
return true;
|
|
4027
4163
|
}
|
|
4028
|
-
if (node.body.type ===
|
|
4164
|
+
if (node.body.type === import_utils58.AST_NODE_TYPES.BlockStatement) {
|
|
4029
4165
|
return hasJSXReturn(node.body);
|
|
4030
4166
|
}
|
|
4031
|
-
} else if (node.type ===
|
|
4032
|
-
if (node.body && node.body.type ===
|
|
4167
|
+
} else if (node.type === import_utils58.AST_NODE_TYPES.FunctionExpression || node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4168
|
+
if (node.body && node.body.type === import_utils58.AST_NODE_TYPES.BlockStatement) {
|
|
4033
4169
|
return hasJSXReturn(node.body);
|
|
4034
4170
|
}
|
|
4035
4171
|
}
|
|
@@ -4043,9 +4179,9 @@ var reactPropsDestructure = createRule52({
|
|
|
4043
4179
|
return;
|
|
4044
4180
|
}
|
|
4045
4181
|
const param = node.params[0];
|
|
4046
|
-
if (param.type ===
|
|
4047
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4048
|
-
if (prop.key.type ===
|
|
4182
|
+
if (param.type === import_utils58.AST_NODE_TYPES.ObjectPattern) {
|
|
4183
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils58.AST_NODE_TYPES.Property).map((prop) => {
|
|
4184
|
+
if (prop.key.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
4049
4185
|
return prop.key.name;
|
|
4050
4186
|
}
|
|
4051
4187
|
return null;
|
|
@@ -4072,57 +4208,57 @@ var reactPropsDestructure = createRule52({
|
|
|
4072
4208
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4073
4209
|
|
|
4074
4210
|
// src/rules/require-explicit-return-type.ts
|
|
4075
|
-
var
|
|
4076
|
-
var
|
|
4211
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4212
|
+
var createRule55 = import_utils59.ESLintUtils.RuleCreator(
|
|
4077
4213
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4078
4214
|
);
|
|
4079
4215
|
var isReactComponent = (node) => {
|
|
4080
|
-
if (node.type ===
|
|
4216
|
+
if (node.type === import_utils59.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4081
4217
|
const { parent } = node;
|
|
4082
|
-
if (parent?.type ===
|
|
4218
|
+
if (parent?.type === import_utils59.AST_NODE_TYPES.VariableDeclarator) {
|
|
4083
4219
|
const { id } = parent;
|
|
4084
|
-
if (id.type ===
|
|
4220
|
+
if (id.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
4085
4221
|
return /^[A-Z]/.test(id.name);
|
|
4086
4222
|
}
|
|
4087
4223
|
}
|
|
4088
4224
|
}
|
|
4089
|
-
if (node.type ===
|
|
4225
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4090
4226
|
return /^[A-Z]/.test(node.id.name);
|
|
4091
4227
|
}
|
|
4092
4228
|
return false;
|
|
4093
4229
|
};
|
|
4094
4230
|
var isCallbackFunction = (node) => {
|
|
4095
|
-
if (node.type ===
|
|
4231
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4096
4232
|
return false;
|
|
4097
4233
|
}
|
|
4098
4234
|
const { parent } = node;
|
|
4099
4235
|
if (!parent) {
|
|
4100
4236
|
return false;
|
|
4101
4237
|
}
|
|
4102
|
-
if (parent.type ===
|
|
4238
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4103
4239
|
return true;
|
|
4104
4240
|
}
|
|
4105
|
-
if (parent.type ===
|
|
4241
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.Property) {
|
|
4106
4242
|
return true;
|
|
4107
4243
|
}
|
|
4108
|
-
if (parent.type ===
|
|
4244
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.ArrayExpression) {
|
|
4109
4245
|
return true;
|
|
4110
4246
|
}
|
|
4111
4247
|
return false;
|
|
4112
4248
|
};
|
|
4113
4249
|
var getFunctionName = (node) => {
|
|
4114
|
-
if (node.type ===
|
|
4250
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4115
4251
|
return node.id.name;
|
|
4116
4252
|
}
|
|
4117
|
-
if (node.type ===
|
|
4253
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4118
4254
|
return node.id.name;
|
|
4119
4255
|
}
|
|
4120
|
-
if ((node.type ===
|
|
4256
|
+
if ((node.type === import_utils59.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils59.AST_NODE_TYPES.FunctionExpression) && node.parent?.type === import_utils59.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
4121
4257
|
return node.parent.id.name;
|
|
4122
4258
|
}
|
|
4123
4259
|
return null;
|
|
4124
4260
|
};
|
|
4125
|
-
var requireExplicitReturnType =
|
|
4261
|
+
var requireExplicitReturnType = createRule55({
|
|
4126
4262
|
name: "require-explicit-return-type",
|
|
4127
4263
|
meta: {
|
|
4128
4264
|
type: "suggestion",
|
|
@@ -4171,8 +4307,8 @@ var requireExplicitReturnType = createRule53({
|
|
|
4171
4307
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4172
4308
|
|
|
4173
4309
|
// src/rules/sort-exports.ts
|
|
4174
|
-
var
|
|
4175
|
-
var
|
|
4310
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4311
|
+
var createRule56 = import_utils60.ESLintUtils.RuleCreator(
|
|
4176
4312
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4177
4313
|
);
|
|
4178
4314
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4186,7 +4322,7 @@ function getExportGroup(node) {
|
|
|
4186
4322
|
}
|
|
4187
4323
|
return 1;
|
|
4188
4324
|
}
|
|
4189
|
-
var sortExports =
|
|
4325
|
+
var sortExports = createRule56({
|
|
4190
4326
|
name: "sort-exports",
|
|
4191
4327
|
meta: {
|
|
4192
4328
|
type: "suggestion",
|
|
@@ -4226,7 +4362,7 @@ var sortExports = createRule54({
|
|
|
4226
4362
|
Program(node) {
|
|
4227
4363
|
const exportGroups = [];
|
|
4228
4364
|
node.body.forEach((statement) => {
|
|
4229
|
-
if (statement.type !==
|
|
4365
|
+
if (statement.type !== import_utils60.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4230
4366
|
if (exportGroups.length > 0) {
|
|
4231
4367
|
checkOrder(exportGroups);
|
|
4232
4368
|
exportGroups.length = 0;
|
|
@@ -4245,8 +4381,8 @@ var sortExports = createRule54({
|
|
|
4245
4381
|
var sort_exports_default = sortExports;
|
|
4246
4382
|
|
|
4247
4383
|
// src/rules/sort-imports.ts
|
|
4248
|
-
var
|
|
4249
|
-
var
|
|
4384
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
4385
|
+
var createRule57 = import_utils61.ESLintUtils.RuleCreator(
|
|
4250
4386
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4251
4387
|
);
|
|
4252
4388
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4313,7 +4449,7 @@ function getImportGroup(node) {
|
|
|
4313
4449
|
function isTypeOnlyImport(node) {
|
|
4314
4450
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4315
4451
|
}
|
|
4316
|
-
var sortImports =
|
|
4452
|
+
var sortImports = createRule57({
|
|
4317
4453
|
name: "sort-imports",
|
|
4318
4454
|
meta: {
|
|
4319
4455
|
type: "suggestion",
|
|
@@ -4357,7 +4493,7 @@ var sortImports = createRule55({
|
|
|
4357
4493
|
Program(node) {
|
|
4358
4494
|
const importGroups = [];
|
|
4359
4495
|
node.body.forEach((statement) => {
|
|
4360
|
-
if (statement.type !==
|
|
4496
|
+
if (statement.type !== import_utils61.AST_NODE_TYPES.ImportDeclaration) {
|
|
4361
4497
|
if (importGroups.length > 0) {
|
|
4362
4498
|
checkOrder(importGroups);
|
|
4363
4499
|
importGroups.length = 0;
|
|
@@ -4379,13 +4515,13 @@ var sortImports = createRule55({
|
|
|
4379
4515
|
var sort_imports_default = sortImports;
|
|
4380
4516
|
|
|
4381
4517
|
// src/rules/sort-type-alphabetically.ts
|
|
4382
|
-
var
|
|
4383
|
-
var
|
|
4518
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
4519
|
+
var createRule58 = import_utils62.ESLintUtils.RuleCreator(
|
|
4384
4520
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4385
4521
|
);
|
|
4386
4522
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4387
4523
|
const properties = members.filter(
|
|
4388
|
-
(member) => member.type ===
|
|
4524
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4389
4525
|
);
|
|
4390
4526
|
if (properties.length < 2) {
|
|
4391
4527
|
return true;
|
|
@@ -4396,7 +4532,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4396
4532
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4397
4533
|
return isRequiredSorted && isOptionalSorted;
|
|
4398
4534
|
}
|
|
4399
|
-
var sortTypeAlphabetically =
|
|
4535
|
+
var sortTypeAlphabetically = createRule58({
|
|
4400
4536
|
name: "sort-type-alphabetically",
|
|
4401
4537
|
meta: {
|
|
4402
4538
|
type: "suggestion",
|
|
@@ -4414,7 +4550,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4414
4550
|
function fixMembers(fixer, members) {
|
|
4415
4551
|
const { sourceCode } = context;
|
|
4416
4552
|
const properties = members.filter(
|
|
4417
|
-
(member) => member.type ===
|
|
4553
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4418
4554
|
);
|
|
4419
4555
|
const required = properties.filter((prop) => !prop.optional);
|
|
4420
4556
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4451,7 +4587,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4451
4587
|
}
|
|
4452
4588
|
},
|
|
4453
4589
|
TSTypeAliasDeclaration(node) {
|
|
4454
|
-
if (node.typeAnnotation.type !==
|
|
4590
|
+
if (node.typeAnnotation.type !== import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4455
4591
|
return;
|
|
4456
4592
|
}
|
|
4457
4593
|
const { members } = node.typeAnnotation;
|
|
@@ -4471,13 +4607,13 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4471
4607
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4472
4608
|
|
|
4473
4609
|
// src/rules/sort-type-required-first.ts
|
|
4474
|
-
var
|
|
4475
|
-
var
|
|
4610
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
4611
|
+
var createRule59 = import_utils63.ESLintUtils.RuleCreator(
|
|
4476
4612
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4477
4613
|
);
|
|
4478
4614
|
function isRequiredBeforeOptional(members) {
|
|
4479
4615
|
const properties = members.filter(
|
|
4480
|
-
(member) => member.type ===
|
|
4616
|
+
(member) => member.type === import_utils63.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils63.AST_NODE_TYPES.Identifier
|
|
4481
4617
|
);
|
|
4482
4618
|
if (properties.length < 2) {
|
|
4483
4619
|
return true;
|
|
@@ -4488,7 +4624,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4488
4624
|
}
|
|
4489
4625
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4490
4626
|
}
|
|
4491
|
-
var sortTypeRequiredFirst =
|
|
4627
|
+
var sortTypeRequiredFirst = createRule59({
|
|
4492
4628
|
name: "sort-type-required-first",
|
|
4493
4629
|
meta: {
|
|
4494
4630
|
type: "suggestion",
|
|
@@ -4506,7 +4642,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4506
4642
|
function fixMembers(fixer, members) {
|
|
4507
4643
|
const { sourceCode } = context;
|
|
4508
4644
|
const properties = members.filter(
|
|
4509
|
-
(member) => member.type ===
|
|
4645
|
+
(member) => member.type === import_utils63.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils63.AST_NODE_TYPES.Identifier
|
|
4510
4646
|
);
|
|
4511
4647
|
const required = properties.filter((prop) => !prop.optional);
|
|
4512
4648
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4527,7 +4663,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4527
4663
|
}
|
|
4528
4664
|
},
|
|
4529
4665
|
TSTypeAliasDeclaration(node) {
|
|
4530
|
-
if (node.typeAnnotation.type !==
|
|
4666
|
+
if (node.typeAnnotation.type !== import_utils63.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4531
4667
|
return;
|
|
4532
4668
|
}
|
|
4533
4669
|
const { members } = node.typeAnnotation;
|
|
@@ -4564,6 +4700,7 @@ var rules = {
|
|
|
4564
4700
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4565
4701
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4566
4702
|
"file-kebab-case": file_kebab_case_default,
|
|
4703
|
+
"index-export-only": index_export_only_default,
|
|
4567
4704
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
4568
4705
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
4569
4706
|
"jsx-no-newline-single-line-elements": jsx_no_newline_single_line_elements_default,
|
|
@@ -4585,6 +4722,7 @@ var rules = {
|
|
|
4585
4722
|
"no-inline-default-export": no_inline_default_export_default,
|
|
4586
4723
|
"no-inline-nested-object": no_inline_nested_object_default,
|
|
4587
4724
|
"no-inline-return-properties": no_inline_return_properties_default,
|
|
4725
|
+
"no-inline-type-import": no_inline_type_import_default,
|
|
4588
4726
|
"no-lazy-identifiers": no_lazy_identifiers_default,
|
|
4589
4727
|
"no-logic-in-params": no_logic_in_params_default,
|
|
4590
4728
|
"no-misleading-constant-case": no_misleading_constant_case_default,
|
|
@@ -4625,6 +4763,7 @@ var baseRules = {
|
|
|
4625
4763
|
"nextfriday/enforce-sorted-destructuring": "warn",
|
|
4626
4764
|
"nextfriday/enforce-type-declaration-order": "warn",
|
|
4627
4765
|
"nextfriday/file-kebab-case": "warn",
|
|
4766
|
+
"nextfriday/index-export-only": "warn",
|
|
4628
4767
|
"nextfriday/newline-after-multiline-block": "warn",
|
|
4629
4768
|
"nextfriday/newline-before-return": "warn",
|
|
4630
4769
|
"nextfriday/no-complex-inline-return": "warn",
|
|
@@ -4634,6 +4773,7 @@ var baseRules = {
|
|
|
4634
4773
|
"nextfriday/no-inline-default-export": "warn",
|
|
4635
4774
|
"nextfriday/no-inline-nested-object": "warn",
|
|
4636
4775
|
"nextfriday/no-inline-return-properties": "warn",
|
|
4776
|
+
"nextfriday/no-inline-type-import": "warn",
|
|
4637
4777
|
"nextfriday/no-lazy-identifiers": "warn",
|
|
4638
4778
|
"nextfriday/no-logic-in-params": "warn",
|
|
4639
4779
|
"nextfriday/no-misleading-constant-case": "warn",
|
|
@@ -4667,6 +4807,7 @@ var baseRecommendedRules = {
|
|
|
4667
4807
|
"nextfriday/enforce-sorted-destructuring": "error",
|
|
4668
4808
|
"nextfriday/enforce-type-declaration-order": "error",
|
|
4669
4809
|
"nextfriday/file-kebab-case": "error",
|
|
4810
|
+
"nextfriday/index-export-only": "error",
|
|
4670
4811
|
"nextfriday/newline-after-multiline-block": "error",
|
|
4671
4812
|
"nextfriday/newline-before-return": "error",
|
|
4672
4813
|
"nextfriday/no-complex-inline-return": "error",
|
|
@@ -4676,6 +4817,7 @@ var baseRecommendedRules = {
|
|
|
4676
4817
|
"nextfriday/no-inline-default-export": "error",
|
|
4677
4818
|
"nextfriday/no-inline-nested-object": "error",
|
|
4678
4819
|
"nextfriday/no-inline-return-properties": "error",
|
|
4820
|
+
"nextfriday/no-inline-type-import": "error",
|
|
4679
4821
|
"nextfriday/no-lazy-identifiers": "error",
|
|
4680
4822
|
"nextfriday/no-logic-in-params": "error",
|
|
4681
4823
|
"nextfriday/no-misleading-constant-case": "error",
|
|
@@ -4747,14 +4889,15 @@ var createConfig = (configRules) => ({
|
|
|
4747
4889
|
rules: configRules
|
|
4748
4890
|
});
|
|
4749
4891
|
var NEXTJS_ROUTING_GLOBS = [
|
|
4750
|
-
"app/**/*.{jsx,tsx}",
|
|
4751
|
-
"src/app/**/*.{jsx,tsx}",
|
|
4752
|
-
"pages/**/*.{jsx,tsx}",
|
|
4753
|
-
"src/pages/**/*.{jsx,tsx}"
|
|
4892
|
+
"app/**/*.{js,jsx,ts,tsx}",
|
|
4893
|
+
"src/app/**/*.{js,jsx,ts,tsx}",
|
|
4894
|
+
"pages/**/*.{js,jsx,ts,tsx}",
|
|
4895
|
+
"src/pages/**/*.{js,jsx,ts,tsx}"
|
|
4754
4896
|
];
|
|
4755
4897
|
var nextjsRoutingOverride = {
|
|
4756
4898
|
files: NEXTJS_ROUTING_GLOBS,
|
|
4757
4899
|
rules: {
|
|
4900
|
+
"nextfriday/file-kebab-case": "off",
|
|
4758
4901
|
"nextfriday/jsx-pascal-case": "off"
|
|
4759
4902
|
}
|
|
4760
4903
|
};
|