eslint-plugin-nextfriday 3.1.0 → 3.2.1
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 +14 -0
- package/README.md +11 -7
- package/docs/rules/ENFORCE_CONSTANT_CASE.md +28 -17
- package/docs/rules/INDEX_EXPORT_ONLY.md +88 -0
- package/docs/rules/NO_INLINE_TYPE_IMPORT.md +86 -0
- package/lib/index.cjs +541 -432
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +84 -0
- package/lib/index.d.ts +84 -0
- package/lib/index.js +541 -432
- 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.1
|
|
43
|
+
version: "3.2.1",
|
|
44
44
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
45
45
|
keywords: [
|
|
46
46
|
"eslint",
|
|
@@ -447,40 +447,14 @@ var createRule3 = import_utils4.ESLintUtils.RuleCreator(
|
|
|
447
447
|
);
|
|
448
448
|
var SCREAMING_SNAKE_CASE_REGEX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
449
449
|
var SNAKE_CASE_REGEX2 = /^[a-z]+_[a-z0-9_]*$/;
|
|
450
|
-
var BOOLEAN_PREFIXES2 = ["is", "has", "should", "can", "did", "will", "was", "are", "does", "had"];
|
|
451
450
|
var toScreamingSnakeCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toUpperCase();
|
|
452
|
-
var
|
|
453
|
-
if (!name.startsWith(prefix)) {
|
|
454
|
-
return false;
|
|
455
|
-
}
|
|
456
|
-
if (name.length === prefix.length) {
|
|
457
|
-
return true;
|
|
458
|
-
}
|
|
459
|
-
const nextChar = name.charAt(prefix.length);
|
|
460
|
-
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
|
|
461
|
-
});
|
|
462
|
-
var isBooleanLiteral2 = (init) => init.type === import_utils4.AST_NODE_TYPES.Literal && typeof init.value === "boolean";
|
|
463
|
-
var isAsConstAssertion = (node) => node.type === import_utils4.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === import_utils4.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils4.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
464
|
-
var isStaticValue2 = (init) => {
|
|
465
|
-
if (isAsConstAssertion(init)) {
|
|
466
|
-
return true;
|
|
467
|
-
}
|
|
451
|
+
var isMagicLiteral = (init) => {
|
|
468
452
|
if (init.type === import_utils4.AST_NODE_TYPES.Literal) {
|
|
469
|
-
return
|
|
470
|
-
}
|
|
471
|
-
if (init.type === import_utils4.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils4.AST_NODE_TYPES.Literal) {
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
if (init.type === import_utils4.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
475
|
-
return true;
|
|
453
|
+
return typeof init.value === "string" || typeof init.value === "number";
|
|
476
454
|
}
|
|
477
|
-
if (init.type === import_utils4.AST_NODE_TYPES.
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (init.type === import_utils4.AST_NODE_TYPES.ObjectExpression) {
|
|
481
|
-
return init.properties.every(
|
|
482
|
-
(prop) => prop.type === import_utils4.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
483
|
-
);
|
|
455
|
+
if (init.type === import_utils4.AST_NODE_TYPES.UnaryExpression) {
|
|
456
|
+
const { argument, operator } = init;
|
|
457
|
+
return (operator === "-" || operator === "+") && argument.type === import_utils4.AST_NODE_TYPES.Literal && typeof argument.value === "number";
|
|
484
458
|
}
|
|
485
459
|
return false;
|
|
486
460
|
};
|
|
@@ -494,13 +468,12 @@ var isGlobalScope2 = (node) => {
|
|
|
494
468
|
}
|
|
495
469
|
return false;
|
|
496
470
|
};
|
|
497
|
-
var isFunctionOrComponent = (init) => init.type === import_utils4.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils4.AST_NODE_TYPES.FunctionExpression;
|
|
498
471
|
var enforceConstantCase = createRule3({
|
|
499
472
|
name: "enforce-constant-case",
|
|
500
473
|
meta: {
|
|
501
474
|
type: "suggestion",
|
|
502
475
|
docs: {
|
|
503
|
-
description: "Enforce SCREAMING_SNAKE_CASE for global
|
|
476
|
+
description: "Enforce SCREAMING_SNAKE_CASE for global magic-number and magic-text constants"
|
|
504
477
|
},
|
|
505
478
|
messages: {
|
|
506
479
|
useScreamingSnakeCase: "Constant '{{ name }}' should use SCREAMING_SNAKE_CASE. Rename to '{{ suggestion }}'.",
|
|
@@ -522,16 +495,10 @@ var enforceConstantCase = createRule3({
|
|
|
522
495
|
if (declarator.id.type !== import_utils4.AST_NODE_TYPES.Identifier || !declarator.init) {
|
|
523
496
|
return;
|
|
524
497
|
}
|
|
525
|
-
if (
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
if (!isStaticValue2(declarator.init)) {
|
|
498
|
+
if (!isMagicLiteral(declarator.init)) {
|
|
529
499
|
return;
|
|
530
500
|
}
|
|
531
501
|
const { name } = declarator.id;
|
|
532
|
-
if (isBooleanLiteral2(declarator.init) && startsWithBooleanPrefix2(name)) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
502
|
if (SNAKE_CASE_REGEX2.test(name)) {
|
|
536
503
|
context.report({
|
|
537
504
|
node: declarator.id,
|
|
@@ -1180,12 +1147,74 @@ var fileKebabCase = createRule12({
|
|
|
1180
1147
|
});
|
|
1181
1148
|
var file_kebab_case_default = fileKebabCase;
|
|
1182
1149
|
|
|
1183
|
-
// src/rules/
|
|
1150
|
+
// src/rules/index-export-only.ts
|
|
1184
1151
|
var import_utils15 = require("@typescript-eslint/utils");
|
|
1185
1152
|
var createRule13 = import_utils15.ESLintUtils.RuleCreator(
|
|
1186
1153
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1187
1154
|
);
|
|
1188
|
-
var
|
|
1155
|
+
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
1156
|
+
var isAllowedExportNamed = (node) => {
|
|
1157
|
+
if (!node.declaration) {
|
|
1158
|
+
return true;
|
|
1159
|
+
}
|
|
1160
|
+
return node.declaration.type === import_utils15.AST_NODE_TYPES.TSTypeAliasDeclaration || node.declaration.type === import_utils15.AST_NODE_TYPES.TSInterfaceDeclaration;
|
|
1161
|
+
};
|
|
1162
|
+
var isAllowedExportDefault = (node) => node.declaration.type === import_utils15.AST_NODE_TYPES.Identifier;
|
|
1163
|
+
var isAllowedTopLevel = (node) => {
|
|
1164
|
+
switch (node.type) {
|
|
1165
|
+
case import_utils15.AST_NODE_TYPES.ImportDeclaration:
|
|
1166
|
+
case import_utils15.AST_NODE_TYPES.ExportAllDeclaration:
|
|
1167
|
+
case import_utils15.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
1168
|
+
case import_utils15.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
1169
|
+
case import_utils15.AST_NODE_TYPES.TSImportEqualsDeclaration:
|
|
1170
|
+
return true;
|
|
1171
|
+
case import_utils15.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
1172
|
+
return isAllowedExportNamed(node);
|
|
1173
|
+
case import_utils15.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
1174
|
+
return isAllowedExportDefault(node);
|
|
1175
|
+
default:
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
var indexExportOnly = createRule13({
|
|
1180
|
+
name: "index-export-only",
|
|
1181
|
+
meta: {
|
|
1182
|
+
type: "suggestion",
|
|
1183
|
+
docs: {
|
|
1184
|
+
description: "Restrict index files to imports, re-exports, and type declarations only."
|
|
1185
|
+
},
|
|
1186
|
+
messages: {
|
|
1187
|
+
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."
|
|
1188
|
+
},
|
|
1189
|
+
schema: []
|
|
1190
|
+
},
|
|
1191
|
+
defaultOptions: [],
|
|
1192
|
+
create(context) {
|
|
1193
|
+
if (!isIndexFile(context.filename)) {
|
|
1194
|
+
return {};
|
|
1195
|
+
}
|
|
1196
|
+
return {
|
|
1197
|
+
Program(node) {
|
|
1198
|
+
for (const statement of node.body) {
|
|
1199
|
+
if (!isAllowedTopLevel(statement)) {
|
|
1200
|
+
context.report({
|
|
1201
|
+
node: statement,
|
|
1202
|
+
messageId: "indexExportOnly"
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
var index_export_only_default = indexExportOnly;
|
|
1211
|
+
|
|
1212
|
+
// src/rules/jsx-newline-between-elements.ts
|
|
1213
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
1214
|
+
var createRule14 = import_utils17.ESLintUtils.RuleCreator(
|
|
1215
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1216
|
+
);
|
|
1217
|
+
var jsxNewlineBetweenElements = createRule14({
|
|
1189
1218
|
name: "jsx-newline-between-elements",
|
|
1190
1219
|
meta: {
|
|
1191
1220
|
type: "layout",
|
|
@@ -1203,7 +1232,7 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1203
1232
|
create(context) {
|
|
1204
1233
|
const { sourceCode } = context;
|
|
1205
1234
|
function isSignificantJSXChild(node) {
|
|
1206
|
-
return node.type ===
|
|
1235
|
+
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
1236
|
}
|
|
1208
1237
|
function isMultiLine(node) {
|
|
1209
1238
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1253,11 +1282,11 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1253
1282
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1254
1283
|
|
|
1255
1284
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1256
|
-
var
|
|
1257
|
-
var
|
|
1285
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
1286
|
+
var createRule15 = import_utils18.ESLintUtils.RuleCreator(
|
|
1258
1287
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1259
1288
|
);
|
|
1260
|
-
var jsxNoInlineObjectProp =
|
|
1289
|
+
var jsxNoInlineObjectProp = createRule15({
|
|
1261
1290
|
name: "jsx-no-inline-object-prop",
|
|
1262
1291
|
meta: {
|
|
1263
1292
|
type: "suggestion",
|
|
@@ -1273,7 +1302,7 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1273
1302
|
create(context) {
|
|
1274
1303
|
return {
|
|
1275
1304
|
JSXAttribute(node) {
|
|
1276
|
-
if (node.value?.type ===
|
|
1305
|
+
if (node.value?.type === import_utils18.AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === import_utils18.AST_NODE_TYPES.ObjectExpression) {
|
|
1277
1306
|
context.report({
|
|
1278
1307
|
node: node.value,
|
|
1279
1308
|
messageId: "noInlineObject"
|
|
@@ -1286,17 +1315,17 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1286
1315
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1287
1316
|
|
|
1288
1317
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1289
|
-
var
|
|
1290
|
-
var
|
|
1318
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
1319
|
+
var createRule16 = import_utils19.ESLintUtils.RuleCreator(
|
|
1291
1320
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1292
1321
|
);
|
|
1293
1322
|
function isJSXElementOrFragment(node) {
|
|
1294
|
-
return node.type ===
|
|
1323
|
+
return node.type === import_utils19.AST_NODE_TYPES.JSXElement || node.type === import_utils19.AST_NODE_TYPES.JSXFragment;
|
|
1295
1324
|
}
|
|
1296
1325
|
function isSingleLine(node) {
|
|
1297
1326
|
return node.loc.start.line === node.loc.end.line;
|
|
1298
1327
|
}
|
|
1299
|
-
var jsxNoNewlineSingleLineElements =
|
|
1328
|
+
var jsxNoNewlineSingleLineElements = createRule16({
|
|
1300
1329
|
name: "jsx-no-newline-single-line-elements",
|
|
1301
1330
|
meta: {
|
|
1302
1331
|
type: "layout",
|
|
@@ -1314,7 +1343,7 @@ var jsxNoNewlineSingleLineElements = createRule15({
|
|
|
1314
1343
|
const { sourceCode } = context;
|
|
1315
1344
|
function checkSiblings(children) {
|
|
1316
1345
|
const nonWhitespace = children.filter(
|
|
1317
|
-
(child) => !(child.type ===
|
|
1346
|
+
(child) => !(child.type === import_utils19.AST_NODE_TYPES.JSXText && child.value.trim() === "")
|
|
1318
1347
|
);
|
|
1319
1348
|
nonWhitespace.forEach((next, index) => {
|
|
1320
1349
|
if (index === 0) {
|
|
@@ -1365,11 +1394,11 @@ ${indent}`);
|
|
|
1365
1394
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1366
1395
|
|
|
1367
1396
|
// src/rules/jsx-no-non-component-function.ts
|
|
1368
|
-
var
|
|
1369
|
-
var
|
|
1397
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
1398
|
+
var createRule17 = import_utils20.ESLintUtils.RuleCreator(
|
|
1370
1399
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1371
1400
|
);
|
|
1372
|
-
var jsxNoNonComponentFunction =
|
|
1401
|
+
var jsxNoNonComponentFunction = createRule17({
|
|
1373
1402
|
name: "jsx-no-non-component-function",
|
|
1374
1403
|
meta: {
|
|
1375
1404
|
type: "problem",
|
|
@@ -1389,13 +1418,13 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1389
1418
|
return {};
|
|
1390
1419
|
}
|
|
1391
1420
|
function isReactComponent2(node) {
|
|
1392
|
-
const functionName = node.type ===
|
|
1421
|
+
const functionName = node.type === import_utils20.AST_NODE_TYPES.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1393
1422
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1394
1423
|
return true;
|
|
1395
1424
|
}
|
|
1396
1425
|
if (node.returnType?.typeAnnotation) {
|
|
1397
1426
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1398
|
-
if (returnTypeNode.type ===
|
|
1427
|
+
if (returnTypeNode.type === import_utils20.AST_NODE_TYPES.TSTypeReference && returnTypeNode.typeName.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
1399
1428
|
const typeName = returnTypeNode.typeName.name;
|
|
1400
1429
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1401
1430
|
return true;
|
|
@@ -1412,13 +1441,13 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1412
1441
|
if (!parent) {
|
|
1413
1442
|
return;
|
|
1414
1443
|
}
|
|
1415
|
-
if (parent.type ===
|
|
1444
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.ExportDefaultDeclaration || parent.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1416
1445
|
return;
|
|
1417
1446
|
}
|
|
1418
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1447
|
+
if (declaratorNode?.parent?.parent?.type === import_utils20.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1419
1448
|
return;
|
|
1420
1449
|
}
|
|
1421
|
-
if (declaratorNode?.id.type ===
|
|
1450
|
+
if (declaratorNode?.id.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
1422
1451
|
const varName = declaratorNode.id.name;
|
|
1423
1452
|
if (/^[A-Z]/.test(varName)) {
|
|
1424
1453
|
return;
|
|
@@ -1443,20 +1472,20 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1443
1472
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1444
1473
|
|
|
1445
1474
|
// src/rules/jsx-no-ternary-null.ts
|
|
1446
|
-
var
|
|
1447
|
-
var
|
|
1475
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
1476
|
+
var createRule18 = import_utils22.ESLintUtils.RuleCreator(
|
|
1448
1477
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1449
1478
|
);
|
|
1450
1479
|
function isNullOrUndefined(node) {
|
|
1451
|
-
if (node.type ===
|
|
1480
|
+
if (node.type === import_utils22.AST_NODE_TYPES.Literal && node.value === null) {
|
|
1452
1481
|
return true;
|
|
1453
1482
|
}
|
|
1454
|
-
if (node.type ===
|
|
1483
|
+
if (node.type === import_utils22.AST_NODE_TYPES.Identifier && node.name === "undefined") {
|
|
1455
1484
|
return true;
|
|
1456
1485
|
}
|
|
1457
1486
|
return false;
|
|
1458
1487
|
}
|
|
1459
|
-
var jsxNoTernaryNull =
|
|
1488
|
+
var jsxNoTernaryNull = createRule18({
|
|
1460
1489
|
name: "jsx-no-ternary-null",
|
|
1461
1490
|
meta: {
|
|
1462
1491
|
type: "suggestion",
|
|
@@ -1474,7 +1503,7 @@ var jsxNoTernaryNull = createRule17({
|
|
|
1474
1503
|
return {
|
|
1475
1504
|
JSXExpressionContainer(node) {
|
|
1476
1505
|
const { expression } = node;
|
|
1477
|
-
if (expression.type !==
|
|
1506
|
+
if (expression.type !== import_utils22.AST_NODE_TYPES.ConditionalExpression) {
|
|
1478
1507
|
return;
|
|
1479
1508
|
}
|
|
1480
1509
|
const { test, consequent, alternate } = expression;
|
|
@@ -1506,11 +1535,11 @@ var jsxNoTernaryNull = createRule17({
|
|
|
1506
1535
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1507
1536
|
|
|
1508
1537
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1509
|
-
var
|
|
1510
|
-
var
|
|
1538
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
1539
|
+
var createRule19 = import_utils23.ESLintUtils.RuleCreator(
|
|
1511
1540
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1512
1541
|
);
|
|
1513
|
-
var jsxNoVariableInCallback =
|
|
1542
|
+
var jsxNoVariableInCallback = createRule19({
|
|
1514
1543
|
name: "jsx-no-variable-in-callback",
|
|
1515
1544
|
meta: {
|
|
1516
1545
|
type: "suggestion",
|
|
@@ -1527,7 +1556,7 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1527
1556
|
function isInsideJSX(node) {
|
|
1528
1557
|
let current = node.parent;
|
|
1529
1558
|
while (current) {
|
|
1530
|
-
if (current.type ===
|
|
1559
|
+
if (current.type === import_utils23.AST_NODE_TYPES.JSXElement || current.type === import_utils23.AST_NODE_TYPES.JSXFragment) {
|
|
1531
1560
|
return true;
|
|
1532
1561
|
}
|
|
1533
1562
|
current = current.parent;
|
|
@@ -1541,11 +1570,11 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1541
1570
|
if (!isInsideJSX(node)) {
|
|
1542
1571
|
return false;
|
|
1543
1572
|
}
|
|
1544
|
-
if (node.parent.type ===
|
|
1573
|
+
if (node.parent.type === import_utils23.AST_NODE_TYPES.CallExpression || node.parent.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1545
1574
|
return true;
|
|
1546
1575
|
}
|
|
1547
|
-
if (node.parent.type ===
|
|
1548
|
-
if (node.parent.parent.type ===
|
|
1576
|
+
if (node.parent.type === import_utils23.AST_NODE_TYPES.ArrayExpression && node.parent.parent) {
|
|
1577
|
+
if (node.parent.parent.type === import_utils23.AST_NODE_TYPES.CallExpression || node.parent.parent.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1549
1578
|
return true;
|
|
1550
1579
|
}
|
|
1551
1580
|
}
|
|
@@ -1556,11 +1585,11 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1556
1585
|
return;
|
|
1557
1586
|
}
|
|
1558
1587
|
const { body } = node;
|
|
1559
|
-
if (body.type !==
|
|
1588
|
+
if (body.type !== import_utils23.AST_NODE_TYPES.BlockStatement) {
|
|
1560
1589
|
return;
|
|
1561
1590
|
}
|
|
1562
1591
|
body.body.forEach((statement) => {
|
|
1563
|
-
if (statement.type ===
|
|
1592
|
+
if (statement.type === import_utils23.AST_NODE_TYPES.VariableDeclaration) {
|
|
1564
1593
|
context.report({
|
|
1565
1594
|
node: statement,
|
|
1566
1595
|
messageId: "noVariableInCallback"
|
|
@@ -1578,12 +1607,12 @@ var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
|
1578
1607
|
|
|
1579
1608
|
// src/rules/jsx-pascal-case.ts
|
|
1580
1609
|
var import_path4 = __toESM(require("path"), 1);
|
|
1581
|
-
var
|
|
1582
|
-
var
|
|
1610
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
1611
|
+
var createRule20 = import_utils24.ESLintUtils.RuleCreator(
|
|
1583
1612
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1584
1613
|
);
|
|
1585
1614
|
var isPascalCase = (str) => /^[A-Z][a-zA-Z0-9]*$/.test(str) && !/^[A-Z]+$/.test(str);
|
|
1586
|
-
var jsxPascalCase =
|
|
1615
|
+
var jsxPascalCase = createRule20({
|
|
1587
1616
|
name: "jsx-pascal-case",
|
|
1588
1617
|
meta: {
|
|
1589
1618
|
type: "problem",
|
|
@@ -1618,11 +1647,11 @@ var jsxPascalCase = createRule19({
|
|
|
1618
1647
|
var jsx_pascal_case_default = jsxPascalCase;
|
|
1619
1648
|
|
|
1620
1649
|
// src/rules/jsx-require-suspense.ts
|
|
1621
|
-
var
|
|
1622
|
-
var
|
|
1650
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
1651
|
+
var createRule21 = import_utils25.ESLintUtils.RuleCreator(
|
|
1623
1652
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1624
1653
|
);
|
|
1625
|
-
var jsxRequireSuspense =
|
|
1654
|
+
var jsxRequireSuspense = createRule21({
|
|
1626
1655
|
name: "jsx-require-suspense",
|
|
1627
1656
|
meta: {
|
|
1628
1657
|
type: "problem",
|
|
@@ -1640,7 +1669,7 @@ var jsxRequireSuspense = createRule20({
|
|
|
1640
1669
|
const isInsideSuspense = (node) => {
|
|
1641
1670
|
let current = node.parent;
|
|
1642
1671
|
while (current) {
|
|
1643
|
-
if (current.type ===
|
|
1672
|
+
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
1673
|
return true;
|
|
1645
1674
|
}
|
|
1646
1675
|
current = current.parent;
|
|
@@ -1649,16 +1678,16 @@ var jsxRequireSuspense = createRule20({
|
|
|
1649
1678
|
};
|
|
1650
1679
|
return {
|
|
1651
1680
|
VariableDeclarator(node) {
|
|
1652
|
-
if (node.id.type ===
|
|
1681
|
+
if (node.id.type === import_utils25.AST_NODE_TYPES.Identifier && node.init?.type === import_utils25.AST_NODE_TYPES.CallExpression) {
|
|
1653
1682
|
const { callee } = node.init;
|
|
1654
|
-
const isLazyCall = callee.type ===
|
|
1683
|
+
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
1684
|
if (isLazyCall) {
|
|
1656
1685
|
lazyComponents.add(node.id.name);
|
|
1657
1686
|
}
|
|
1658
1687
|
}
|
|
1659
1688
|
},
|
|
1660
1689
|
JSXOpeningElement(node) {
|
|
1661
|
-
if (node.name.type ===
|
|
1690
|
+
if (node.name.type === import_utils25.AST_NODE_TYPES.JSXIdentifier) {
|
|
1662
1691
|
const componentName = node.name.name;
|
|
1663
1692
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1664
1693
|
context.report({
|
|
@@ -1677,11 +1706,11 @@ var jsxRequireSuspense = createRule20({
|
|
|
1677
1706
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1678
1707
|
|
|
1679
1708
|
// src/rules/jsx-simple-props.ts
|
|
1680
|
-
var
|
|
1681
|
-
var
|
|
1709
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
1710
|
+
var createRule22 = import_utils26.ESLintUtils.RuleCreator(
|
|
1682
1711
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1683
1712
|
);
|
|
1684
|
-
var jsxSimpleProps =
|
|
1713
|
+
var jsxSimpleProps = createRule22({
|
|
1685
1714
|
name: "jsx-simple-props",
|
|
1686
1715
|
meta: {
|
|
1687
1716
|
type: "suggestion",
|
|
@@ -1696,25 +1725,25 @@ var jsxSimpleProps = createRule21({
|
|
|
1696
1725
|
defaultOptions: [],
|
|
1697
1726
|
create(context) {
|
|
1698
1727
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1728
|
+
import_utils26.AST_NODE_TYPES.Identifier,
|
|
1729
|
+
import_utils26.AST_NODE_TYPES.Literal,
|
|
1730
|
+
import_utils26.AST_NODE_TYPES.JSXElement,
|
|
1731
|
+
import_utils26.AST_NODE_TYPES.JSXFragment,
|
|
1732
|
+
import_utils26.AST_NODE_TYPES.MemberExpression,
|
|
1733
|
+
import_utils26.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
1734
|
+
import_utils26.AST_NODE_TYPES.FunctionExpression
|
|
1706
1735
|
]);
|
|
1707
1736
|
return {
|
|
1708
1737
|
JSXAttribute(node) {
|
|
1709
1738
|
if (!node.value) {
|
|
1710
1739
|
return;
|
|
1711
1740
|
}
|
|
1712
|
-
if (node.value.type ===
|
|
1741
|
+
if (node.value.type === import_utils26.AST_NODE_TYPES.Literal) {
|
|
1713
1742
|
return;
|
|
1714
1743
|
}
|
|
1715
|
-
if (node.value.type ===
|
|
1744
|
+
if (node.value.type === import_utils26.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1716
1745
|
const { expression } = node.value;
|
|
1717
|
-
if (expression.type ===
|
|
1746
|
+
if (expression.type === import_utils26.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1718
1747
|
return;
|
|
1719
1748
|
}
|
|
1720
1749
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1731,8 +1760,8 @@ var jsxSimpleProps = createRule21({
|
|
|
1731
1760
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1732
1761
|
|
|
1733
1762
|
// src/rules/jsx-sort-props.ts
|
|
1734
|
-
var
|
|
1735
|
-
var
|
|
1763
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
1764
|
+
var createRule23 = import_utils27.ESLintUtils.RuleCreator(
|
|
1736
1765
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1737
1766
|
);
|
|
1738
1767
|
var TYPE_GROUP = {
|
|
@@ -1746,15 +1775,15 @@ var TYPE_GROUP = {
|
|
|
1746
1775
|
SHORTHAND: 8
|
|
1747
1776
|
};
|
|
1748
1777
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1749
|
-
[
|
|
1750
|
-
[
|
|
1751
|
-
[
|
|
1752
|
-
[
|
|
1753
|
-
[
|
|
1754
|
-
[
|
|
1778
|
+
[import_utils27.AST_NODE_TYPES.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1779
|
+
[import_utils27.AST_NODE_TYPES.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1780
|
+
[import_utils27.AST_NODE_TYPES.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1781
|
+
[import_utils27.AST_NODE_TYPES.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1782
|
+
[import_utils27.AST_NODE_TYPES.JSXElement, TYPE_GROUP.JSX],
|
|
1783
|
+
[import_utils27.AST_NODE_TYPES.JSXFragment, TYPE_GROUP.JSX]
|
|
1755
1784
|
]);
|
|
1756
1785
|
function isHyphenatedName(node) {
|
|
1757
|
-
return node.name.type ===
|
|
1786
|
+
return node.name.type === import_utils27.AST_NODE_TYPES.JSXIdentifier && node.name.name.includes("-");
|
|
1758
1787
|
}
|
|
1759
1788
|
function getStringGroup(node) {
|
|
1760
1789
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1766,13 +1795,13 @@ function getLiteralValueGroup(value) {
|
|
|
1766
1795
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1767
1796
|
}
|
|
1768
1797
|
function getExpressionGroup(expression) {
|
|
1769
|
-
if (expression.type ===
|
|
1798
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.Literal) {
|
|
1770
1799
|
return getLiteralValueGroup(expression.value);
|
|
1771
1800
|
}
|
|
1772
|
-
if (expression.type ===
|
|
1801
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.TemplateLiteral) {
|
|
1773
1802
|
return null;
|
|
1774
1803
|
}
|
|
1775
|
-
if (expression.type ===
|
|
1804
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.Identifier && expression.name === "undefined") {
|
|
1776
1805
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1777
1806
|
}
|
|
1778
1807
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1781,17 +1810,17 @@ function getTypeGroup(node) {
|
|
|
1781
1810
|
if (node.value === null) {
|
|
1782
1811
|
return TYPE_GROUP.SHORTHAND;
|
|
1783
1812
|
}
|
|
1784
|
-
if (node.value.type ===
|
|
1813
|
+
if (node.value.type === import_utils27.AST_NODE_TYPES.Literal) {
|
|
1785
1814
|
if (typeof node.value.value === "string") {
|
|
1786
1815
|
return getStringGroup(node);
|
|
1787
1816
|
}
|
|
1788
1817
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1789
1818
|
}
|
|
1790
|
-
if (node.value.type !==
|
|
1819
|
+
if (node.value.type !== import_utils27.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1791
1820
|
return null;
|
|
1792
1821
|
}
|
|
1793
1822
|
const { expression } = node.value;
|
|
1794
|
-
if (expression.type ===
|
|
1823
|
+
if (expression.type === import_utils27.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1795
1824
|
return null;
|
|
1796
1825
|
}
|
|
1797
1826
|
const group = getExpressionGroup(expression);
|
|
@@ -1803,7 +1832,7 @@ function getTypeGroup(node) {
|
|
|
1803
1832
|
function hasUnsortedProps(attributes) {
|
|
1804
1833
|
let lastGroup = 0;
|
|
1805
1834
|
return attributes.some((attribute) => {
|
|
1806
|
-
if (attribute.type ===
|
|
1835
|
+
if (attribute.type === import_utils27.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1807
1836
|
lastGroup = 0;
|
|
1808
1837
|
return false;
|
|
1809
1838
|
}
|
|
@@ -1827,7 +1856,7 @@ function getSegments(attributes) {
|
|
|
1827
1856
|
const result = [];
|
|
1828
1857
|
let current = [];
|
|
1829
1858
|
attributes.forEach((attr) => {
|
|
1830
|
-
if (attr.type ===
|
|
1859
|
+
if (attr.type === import_utils27.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1831
1860
|
if (current.length > 0) {
|
|
1832
1861
|
result.push(current);
|
|
1833
1862
|
current = [];
|
|
@@ -1841,7 +1870,7 @@ function getSegments(attributes) {
|
|
|
1841
1870
|
}
|
|
1842
1871
|
return result;
|
|
1843
1872
|
}
|
|
1844
|
-
var jsxSortProps =
|
|
1873
|
+
var jsxSortProps = createRule23({
|
|
1845
1874
|
name: "jsx-sort-props",
|
|
1846
1875
|
meta: {
|
|
1847
1876
|
type: "suggestion",
|
|
@@ -1876,11 +1905,11 @@ var jsxSortProps = createRule22({
|
|
|
1876
1905
|
var jsx_sort_props_default = jsxSortProps;
|
|
1877
1906
|
|
|
1878
1907
|
// src/rules/jsx-spread-props-last.ts
|
|
1879
|
-
var
|
|
1880
|
-
var
|
|
1908
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
1909
|
+
var createRule24 = import_utils28.ESLintUtils.RuleCreator(
|
|
1881
1910
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1882
1911
|
);
|
|
1883
|
-
var jsxSpreadPropsLast =
|
|
1912
|
+
var jsxSpreadPropsLast = createRule24({
|
|
1884
1913
|
name: "jsx-spread-props-last",
|
|
1885
1914
|
meta: {
|
|
1886
1915
|
type: "suggestion",
|
|
@@ -1899,12 +1928,12 @@ var jsxSpreadPropsLast = createRule23({
|
|
|
1899
1928
|
const { attributes } = node;
|
|
1900
1929
|
let lastNonSpreadIndex = -1;
|
|
1901
1930
|
attributes.forEach((attribute, index) => {
|
|
1902
|
-
if (attribute.type !==
|
|
1931
|
+
if (attribute.type !== import_utils28.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1903
1932
|
lastNonSpreadIndex = index;
|
|
1904
1933
|
}
|
|
1905
1934
|
});
|
|
1906
1935
|
attributes.forEach((attribute, index) => {
|
|
1907
|
-
if (attribute.type ===
|
|
1936
|
+
if (attribute.type === import_utils28.AST_NODE_TYPES.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1908
1937
|
context.report({
|
|
1909
1938
|
node: attribute,
|
|
1910
1939
|
messageId: "spreadNotLast"
|
|
@@ -1918,12 +1947,12 @@ var jsxSpreadPropsLast = createRule23({
|
|
|
1918
1947
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1919
1948
|
|
|
1920
1949
|
// src/rules/newline-after-multiline-block.ts
|
|
1921
|
-
var
|
|
1922
|
-
var
|
|
1950
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
1951
|
+
var createRule25 = import_utils29.ESLintUtils.RuleCreator(
|
|
1923
1952
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1924
1953
|
);
|
|
1925
1954
|
function isImportDeclaration(node) {
|
|
1926
|
-
return node.type ===
|
|
1955
|
+
return node.type === import_utils29.AST_NODE_TYPES.ImportDeclaration;
|
|
1927
1956
|
}
|
|
1928
1957
|
function checkStatements(statements, context) {
|
|
1929
1958
|
const { sourceCode } = context;
|
|
@@ -1958,7 +1987,7 @@ function checkStatements(statements, context) {
|
|
|
1958
1987
|
}
|
|
1959
1988
|
});
|
|
1960
1989
|
}
|
|
1961
|
-
var newlineAfterMultilineBlock =
|
|
1990
|
+
var newlineAfterMultilineBlock = createRule25({
|
|
1962
1991
|
name: "newline-after-multiline-block",
|
|
1963
1992
|
meta: {
|
|
1964
1993
|
type: "layout",
|
|
@@ -1986,11 +2015,11 @@ var newlineAfterMultilineBlock = createRule24({
|
|
|
1986
2015
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
1987
2016
|
|
|
1988
2017
|
// src/rules/newline-before-return.ts
|
|
1989
|
-
var
|
|
1990
|
-
var
|
|
2018
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
2019
|
+
var createRule26 = import_utils30.ESLintUtils.RuleCreator(
|
|
1991
2020
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1992
2021
|
);
|
|
1993
|
-
var newlineBeforeReturn =
|
|
2022
|
+
var newlineBeforeReturn = createRule26({
|
|
1994
2023
|
name: "newline-before-return",
|
|
1995
2024
|
meta: {
|
|
1996
2025
|
type: "layout",
|
|
@@ -2008,7 +2037,7 @@ var newlineBeforeReturn = createRule25({
|
|
|
2008
2037
|
const { sourceCode } = context;
|
|
2009
2038
|
function checkReturnStatement(node) {
|
|
2010
2039
|
const { parent } = node;
|
|
2011
|
-
if (!parent || parent.type !==
|
|
2040
|
+
if (!parent || parent.type !== import_utils30.AST_NODE_TYPES.BlockStatement) {
|
|
2012
2041
|
return;
|
|
2013
2042
|
}
|
|
2014
2043
|
const { body: statements } = parent;
|
|
@@ -2045,11 +2074,11 @@ var newlineBeforeReturn = createRule25({
|
|
|
2045
2074
|
var newline_before_return_default = newlineBeforeReturn;
|
|
2046
2075
|
|
|
2047
2076
|
// src/rules/nextjs-require-public-env.ts
|
|
2048
|
-
var
|
|
2049
|
-
var
|
|
2077
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
2078
|
+
var createRule27 = import_utils31.ESLintUtils.RuleCreator(
|
|
2050
2079
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2051
2080
|
);
|
|
2052
|
-
var nextjsRequirePublicEnv =
|
|
2081
|
+
var nextjsRequirePublicEnv = createRule27({
|
|
2053
2082
|
name: "nextjs-require-public-env",
|
|
2054
2083
|
meta: {
|
|
2055
2084
|
type: "problem",
|
|
@@ -2067,7 +2096,7 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2067
2096
|
return {
|
|
2068
2097
|
Program(node) {
|
|
2069
2098
|
const firstStatement = node.body[0];
|
|
2070
|
-
if (firstStatement?.type ===
|
|
2099
|
+
if (firstStatement?.type === import_utils31.AST_NODE_TYPES.ExpressionStatement && firstStatement.expression.type === import_utils31.AST_NODE_TYPES.Literal && firstStatement.expression.value === "use client") {
|
|
2071
2100
|
isClientComponent = true;
|
|
2072
2101
|
}
|
|
2073
2102
|
},
|
|
@@ -2075,7 +2104,7 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2075
2104
|
if (!isClientComponent) {
|
|
2076
2105
|
return;
|
|
2077
2106
|
}
|
|
2078
|
-
if (node.object.type ===
|
|
2107
|
+
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
2108
|
const envVarName = node.property.name;
|
|
2080
2109
|
if (!envVarName.startsWith("NEXT_PUBLIC_") && envVarName !== "NODE_ENV") {
|
|
2081
2110
|
context.report({
|
|
@@ -2094,11 +2123,11 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2094
2123
|
var nextjs_require_public_env_default = nextjsRequirePublicEnv;
|
|
2095
2124
|
|
|
2096
2125
|
// src/rules/no-complex-inline-return.ts
|
|
2097
|
-
var
|
|
2098
|
-
var
|
|
2126
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2127
|
+
var createRule28 = import_utils32.ESLintUtils.RuleCreator(
|
|
2099
2128
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2100
2129
|
);
|
|
2101
|
-
var noComplexInlineReturn =
|
|
2130
|
+
var noComplexInlineReturn = createRule28({
|
|
2102
2131
|
name: "no-complex-inline-return",
|
|
2103
2132
|
meta: {
|
|
2104
2133
|
type: "suggestion",
|
|
@@ -2114,13 +2143,13 @@ var noComplexInlineReturn = createRule27({
|
|
|
2114
2143
|
create(context) {
|
|
2115
2144
|
const isComplexExpression = (node) => {
|
|
2116
2145
|
if (!node) return false;
|
|
2117
|
-
if (node.type ===
|
|
2146
|
+
if (node.type === import_utils32.AST_NODE_TYPES.ConditionalExpression) {
|
|
2118
2147
|
return true;
|
|
2119
2148
|
}
|
|
2120
|
-
if (node.type ===
|
|
2149
|
+
if (node.type === import_utils32.AST_NODE_TYPES.LogicalExpression) {
|
|
2121
2150
|
return true;
|
|
2122
2151
|
}
|
|
2123
|
-
if (node.type ===
|
|
2152
|
+
if (node.type === import_utils32.AST_NODE_TYPES.NewExpression) {
|
|
2124
2153
|
return true;
|
|
2125
2154
|
}
|
|
2126
2155
|
return false;
|
|
@@ -2140,11 +2169,11 @@ var noComplexInlineReturn = createRule27({
|
|
|
2140
2169
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
2141
2170
|
|
|
2142
2171
|
// src/rules/no-direct-date.ts
|
|
2143
|
-
var
|
|
2144
|
-
var
|
|
2172
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2173
|
+
var createRule29 = import_utils33.ESLintUtils.RuleCreator(
|
|
2145
2174
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2146
2175
|
);
|
|
2147
|
-
var noDirectDate =
|
|
2176
|
+
var noDirectDate = createRule29({
|
|
2148
2177
|
name: "no-direct-date",
|
|
2149
2178
|
meta: {
|
|
2150
2179
|
type: "problem",
|
|
@@ -2162,7 +2191,7 @@ var noDirectDate = createRule28({
|
|
|
2162
2191
|
create(context) {
|
|
2163
2192
|
return {
|
|
2164
2193
|
NewExpression(node) {
|
|
2165
|
-
if (node.callee.type ===
|
|
2194
|
+
if (node.callee.type === import_utils33.AST_NODE_TYPES.Identifier && node.callee.name === "Date") {
|
|
2166
2195
|
context.report({
|
|
2167
2196
|
node,
|
|
2168
2197
|
messageId: "noNewDate"
|
|
@@ -2170,7 +2199,7 @@ var noDirectDate = createRule28({
|
|
|
2170
2199
|
}
|
|
2171
2200
|
},
|
|
2172
2201
|
CallExpression(node) {
|
|
2173
|
-
if (node.callee.type ===
|
|
2202
|
+
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
2203
|
const methodName = node.callee.property.name;
|
|
2175
2204
|
if (methodName === "now") {
|
|
2176
2205
|
context.report({
|
|
@@ -2193,11 +2222,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
2193
2222
|
|
|
2194
2223
|
// src/rules/no-emoji.ts
|
|
2195
2224
|
var import_emoji_regex = __toESM(require("emoji-regex"), 1);
|
|
2196
|
-
var
|
|
2197
|
-
var
|
|
2225
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2226
|
+
var createRule30 = import_utils34.ESLintUtils.RuleCreator(
|
|
2198
2227
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2199
2228
|
);
|
|
2200
|
-
var noEmoji =
|
|
2229
|
+
var noEmoji = createRule30({
|
|
2201
2230
|
name: "no-emoji",
|
|
2202
2231
|
meta: {
|
|
2203
2232
|
type: "problem",
|
|
@@ -2231,11 +2260,11 @@ var noEmoji = createRule29({
|
|
|
2231
2260
|
var no_emoji_default = noEmoji;
|
|
2232
2261
|
|
|
2233
2262
|
// src/rules/no-env-fallback.ts
|
|
2234
|
-
var
|
|
2235
|
-
var
|
|
2263
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2264
|
+
var createRule31 = import_utils35.ESLintUtils.RuleCreator(
|
|
2236
2265
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2237
2266
|
);
|
|
2238
|
-
var noEnvFallback =
|
|
2267
|
+
var noEnvFallback = createRule31({
|
|
2239
2268
|
name: "no-env-fallback",
|
|
2240
2269
|
meta: {
|
|
2241
2270
|
type: "problem",
|
|
@@ -2250,16 +2279,16 @@ var noEnvFallback = createRule30({
|
|
|
2250
2279
|
defaultOptions: [],
|
|
2251
2280
|
create(context) {
|
|
2252
2281
|
const isProcessEnvAccess = (node) => {
|
|
2253
|
-
if (node.type !==
|
|
2282
|
+
if (node.type !== import_utils35.AST_NODE_TYPES.MemberExpression) {
|
|
2254
2283
|
return false;
|
|
2255
2284
|
}
|
|
2256
2285
|
const { object } = node;
|
|
2257
|
-
if (object.type !==
|
|
2286
|
+
if (object.type !== import_utils35.AST_NODE_TYPES.MemberExpression) {
|
|
2258
2287
|
return false;
|
|
2259
2288
|
}
|
|
2260
2289
|
const processNode = object.object;
|
|
2261
2290
|
const envNode = object.property;
|
|
2262
|
-
return processNode.type ===
|
|
2291
|
+
return processNode.type === import_utils35.AST_NODE_TYPES.Identifier && processNode.name === "process" && envNode.type === import_utils35.AST_NODE_TYPES.Identifier && envNode.name === "env";
|
|
2263
2292
|
};
|
|
2264
2293
|
return {
|
|
2265
2294
|
LogicalExpression(node) {
|
|
@@ -2284,11 +2313,11 @@ var noEnvFallback = createRule30({
|
|
|
2284
2313
|
var no_env_fallback_default = noEnvFallback;
|
|
2285
2314
|
|
|
2286
2315
|
// src/rules/no-inline-default-export.ts
|
|
2287
|
-
var
|
|
2288
|
-
var
|
|
2316
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2317
|
+
var createRule32 = import_utils36.ESLintUtils.RuleCreator(
|
|
2289
2318
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2290
2319
|
);
|
|
2291
|
-
var noInlineDefaultExport =
|
|
2320
|
+
var noInlineDefaultExport = createRule32({
|
|
2292
2321
|
name: "no-inline-default-export",
|
|
2293
2322
|
meta: {
|
|
2294
2323
|
type: "suggestion",
|
|
@@ -2307,7 +2336,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2307
2336
|
return {
|
|
2308
2337
|
ExportDefaultDeclaration(node) {
|
|
2309
2338
|
const { declaration } = node;
|
|
2310
|
-
if (declaration.type ===
|
|
2339
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2311
2340
|
if (declaration.id) {
|
|
2312
2341
|
context.report({
|
|
2313
2342
|
node,
|
|
@@ -2322,7 +2351,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2322
2351
|
});
|
|
2323
2352
|
}
|
|
2324
2353
|
}
|
|
2325
|
-
if (declaration.type ===
|
|
2354
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.ClassDeclaration) {
|
|
2326
2355
|
if (declaration.id) {
|
|
2327
2356
|
context.report({
|
|
2328
2357
|
node,
|
|
@@ -2337,7 +2366,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2337
2366
|
});
|
|
2338
2367
|
}
|
|
2339
2368
|
}
|
|
2340
|
-
if (declaration.type ===
|
|
2369
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils36.AST_NODE_TYPES.FunctionExpression) {
|
|
2341
2370
|
context.report({
|
|
2342
2371
|
node,
|
|
2343
2372
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2350,14 +2379,14 @@ var noInlineDefaultExport = createRule31({
|
|
|
2350
2379
|
if (!declaration) {
|
|
2351
2380
|
return;
|
|
2352
2381
|
}
|
|
2353
|
-
if (declaration.type ===
|
|
2382
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2354
2383
|
context.report({
|
|
2355
2384
|
node,
|
|
2356
2385
|
messageId: "noInlineNamedExport",
|
|
2357
2386
|
data: { type: "function", name: declaration.id.name }
|
|
2358
2387
|
});
|
|
2359
2388
|
}
|
|
2360
|
-
if (declaration.type ===
|
|
2389
|
+
if (declaration.type === import_utils36.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2361
2390
|
context.report({
|
|
2362
2391
|
node,
|
|
2363
2392
|
messageId: "noInlineNamedExport",
|
|
@@ -2371,15 +2400,15 @@ var noInlineDefaultExport = createRule31({
|
|
|
2371
2400
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2372
2401
|
|
|
2373
2402
|
// src/rules/no-inline-nested-object.ts
|
|
2374
|
-
var
|
|
2375
|
-
var
|
|
2403
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2404
|
+
var createRule33 = import_utils37.ESLintUtils.RuleCreator(
|
|
2376
2405
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2377
2406
|
);
|
|
2378
2407
|
function isObjectOrArray(node) {
|
|
2379
|
-
return node.type ===
|
|
2408
|
+
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
2409
|
}
|
|
2381
2410
|
function getInnerExpression(node) {
|
|
2382
|
-
if (node.type ===
|
|
2411
|
+
if (node.type === import_utils37.AST_NODE_TYPES.TSAsExpression) {
|
|
2383
2412
|
return getInnerExpression(node.expression);
|
|
2384
2413
|
}
|
|
2385
2414
|
return node;
|
|
@@ -2388,10 +2417,10 @@ function arrayContainsOnlyPrimitives(node) {
|
|
|
2388
2417
|
return node.elements.every((el) => {
|
|
2389
2418
|
if (el === null) return true;
|
|
2390
2419
|
const inner = getInnerExpression(el);
|
|
2391
|
-
return inner.type ===
|
|
2420
|
+
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
2421
|
});
|
|
2393
2422
|
}
|
|
2394
|
-
var noInlineNestedObject =
|
|
2423
|
+
var noInlineNestedObject = createRule33({
|
|
2395
2424
|
name: "no-inline-nested-object",
|
|
2396
2425
|
meta: {
|
|
2397
2426
|
type: "layout",
|
|
@@ -2413,17 +2442,17 @@ var noInlineNestedObject = createRule32({
|
|
|
2413
2442
|
return;
|
|
2414
2443
|
}
|
|
2415
2444
|
const valueNode = getInnerExpression(node.value);
|
|
2416
|
-
if (valueNode.type !==
|
|
2445
|
+
if (valueNode.type !== import_utils37.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils37.AST_NODE_TYPES.ArrayExpression) {
|
|
2417
2446
|
return;
|
|
2418
2447
|
}
|
|
2419
2448
|
if (!valueNode.loc) {
|
|
2420
2449
|
return;
|
|
2421
2450
|
}
|
|
2422
|
-
const elements = valueNode.type ===
|
|
2451
|
+
const elements = valueNode.type === import_utils37.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2423
2452
|
if (elements.length <= 1) {
|
|
2424
2453
|
return;
|
|
2425
2454
|
}
|
|
2426
|
-
if (valueNode.type ===
|
|
2455
|
+
if (valueNode.type === import_utils37.AST_NODE_TYPES.ArrayExpression && arrayContainsOnlyPrimitives(valueNode)) {
|
|
2427
2456
|
return;
|
|
2428
2457
|
}
|
|
2429
2458
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
@@ -2442,7 +2471,7 @@ var noInlineNestedObject = createRule32({
|
|
|
2442
2471
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2443
2472
|
const innerIndent = `${indent} `;
|
|
2444
2473
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2445
|
-
const isObject = valueNode.type ===
|
|
2474
|
+
const isObject = valueNode.type === import_utils37.AST_NODE_TYPES.ObjectExpression;
|
|
2446
2475
|
const openChar = isObject ? "{" : "[";
|
|
2447
2476
|
const closeChar = isObject ? "}" : "]";
|
|
2448
2477
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2459,20 +2488,20 @@ ${indent}${closeChar}`;
|
|
|
2459
2488
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2460
2489
|
|
|
2461
2490
|
// src/rules/no-inline-return-properties.ts
|
|
2462
|
-
var
|
|
2463
|
-
var
|
|
2491
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2492
|
+
var createRule34 = import_utils38.ESLintUtils.RuleCreator(
|
|
2464
2493
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2465
2494
|
);
|
|
2466
2495
|
var isShorthandProperty = (property) => {
|
|
2467
|
-
if (property.type ===
|
|
2496
|
+
if (property.type === import_utils38.AST_NODE_TYPES.SpreadElement) {
|
|
2468
2497
|
return true;
|
|
2469
2498
|
}
|
|
2470
|
-
if (property.type !==
|
|
2499
|
+
if (property.type !== import_utils38.AST_NODE_TYPES.Property) {
|
|
2471
2500
|
return false;
|
|
2472
2501
|
}
|
|
2473
2502
|
return property.shorthand;
|
|
2474
2503
|
};
|
|
2475
|
-
var noInlineReturnProperties =
|
|
2504
|
+
var noInlineReturnProperties = createRule34({
|
|
2476
2505
|
name: "no-inline-return-properties",
|
|
2477
2506
|
meta: {
|
|
2478
2507
|
type: "suggestion",
|
|
@@ -2488,20 +2517,20 @@ var noInlineReturnProperties = createRule33({
|
|
|
2488
2517
|
create(context) {
|
|
2489
2518
|
return {
|
|
2490
2519
|
ReturnStatement(node) {
|
|
2491
|
-
if (!node.argument || node.argument.type !==
|
|
2520
|
+
if (!node.argument || node.argument.type !== import_utils38.AST_NODE_TYPES.ObjectExpression) {
|
|
2492
2521
|
return;
|
|
2493
2522
|
}
|
|
2494
2523
|
node.argument.properties.forEach((property) => {
|
|
2495
2524
|
if (isShorthandProperty(property)) {
|
|
2496
2525
|
return;
|
|
2497
2526
|
}
|
|
2498
|
-
if (property.type !==
|
|
2527
|
+
if (property.type !== import_utils38.AST_NODE_TYPES.Property) {
|
|
2499
2528
|
return;
|
|
2500
2529
|
}
|
|
2501
2530
|
let keyName = null;
|
|
2502
|
-
if (property.key.type ===
|
|
2531
|
+
if (property.key.type === import_utils38.AST_NODE_TYPES.Identifier) {
|
|
2503
2532
|
keyName = property.key.name;
|
|
2504
|
-
} else if (property.key.type ===
|
|
2533
|
+
} else if (property.key.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2505
2534
|
keyName = String(property.key.value);
|
|
2506
2535
|
}
|
|
2507
2536
|
context.report({
|
|
@@ -2516,9 +2545,83 @@ var noInlineReturnProperties = createRule33({
|
|
|
2516
2545
|
});
|
|
2517
2546
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2518
2547
|
|
|
2548
|
+
// src/rules/no-inline-type-import.ts
|
|
2549
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2550
|
+
var createRule35 = import_utils39.ESLintUtils.RuleCreator(
|
|
2551
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2552
|
+
);
|
|
2553
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === import_utils39.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2554
|
+
var noInlineTypeImport = createRule35({
|
|
2555
|
+
name: "no-inline-type-import",
|
|
2556
|
+
meta: {
|
|
2557
|
+
type: "suggestion",
|
|
2558
|
+
docs: {
|
|
2559
|
+
description: "Disallow inline 'type' markers on import specifiers. Use 'import type' or split into a separate type-only import statement."
|
|
2560
|
+
},
|
|
2561
|
+
fixable: "code",
|
|
2562
|
+
messages: {
|
|
2563
|
+
noInlineTypeImport: "Avoid inline 'type' markers on import specifiers. Hoist to 'import type' or split into a separate type-only import statement."
|
|
2564
|
+
},
|
|
2565
|
+
schema: []
|
|
2566
|
+
},
|
|
2567
|
+
defaultOptions: [],
|
|
2568
|
+
create(context) {
|
|
2569
|
+
return {
|
|
2570
|
+
ImportDeclaration(node) {
|
|
2571
|
+
const inlineTypeSpecifiers = node.specifiers.filter(isInlineTypeSpecifier);
|
|
2572
|
+
if (inlineTypeSpecifiers.length === 0) {
|
|
2573
|
+
return;
|
|
2574
|
+
}
|
|
2575
|
+
context.report({
|
|
2576
|
+
node,
|
|
2577
|
+
messageId: "noInlineTypeImport",
|
|
2578
|
+
fix(fixer) {
|
|
2579
|
+
if (node.importKind === "type") {
|
|
2580
|
+
return inlineTypeSpecifiers.map(
|
|
2581
|
+
(specifier) => fixer.removeRange([specifier.range[0], specifier.imported.range[0]])
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
const sourceText = context.sourceCode.getText(node.source);
|
|
2585
|
+
const fileText = context.sourceCode.text;
|
|
2586
|
+
const typeSpecifierTexts = inlineTypeSpecifiers.map(
|
|
2587
|
+
(specifier) => fileText.slice(specifier.imported.range[0], specifier.range[1])
|
|
2588
|
+
);
|
|
2589
|
+
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2590
|
+
const valueSpecifiers = node.specifiers.filter(
|
|
2591
|
+
(specifier) => !(specifier.type === import_utils39.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type")
|
|
2592
|
+
);
|
|
2593
|
+
if (valueSpecifiers.length === 0) {
|
|
2594
|
+
return fixer.replaceText(node, typeImport);
|
|
2595
|
+
}
|
|
2596
|
+
const parts = [];
|
|
2597
|
+
const namedValueSpecifiers = [];
|
|
2598
|
+
for (const specifier of valueSpecifiers) {
|
|
2599
|
+
if (specifier.type === import_utils39.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
2600
|
+
parts.push(specifier.local.name);
|
|
2601
|
+
} else if (specifier.type === import_utils39.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
2602
|
+
parts.push(`* as ${specifier.local.name}`);
|
|
2603
|
+
} else if (specifier.type === import_utils39.AST_NODE_TYPES.ImportSpecifier) {
|
|
2604
|
+
namedValueSpecifiers.push(specifier);
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
if (namedValueSpecifiers.length > 0) {
|
|
2608
|
+
const namedTexts = namedValueSpecifiers.map((specifier) => context.sourceCode.getText(specifier));
|
|
2609
|
+
parts.push(`{ ${namedTexts.join(", ")} }`);
|
|
2610
|
+
}
|
|
2611
|
+
const valueImport = `import ${parts.join(", ")} from ${sourceText};`;
|
|
2612
|
+
return fixer.replaceText(node, `${valueImport}
|
|
2613
|
+
${typeImport}`);
|
|
2614
|
+
}
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
});
|
|
2620
|
+
var no_inline_type_import_default = noInlineTypeImport;
|
|
2621
|
+
|
|
2519
2622
|
// src/rules/no-lazy-identifiers.ts
|
|
2520
|
-
var
|
|
2521
|
-
var
|
|
2623
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2624
|
+
var createRule36 = import_utils40.ESLintUtils.RuleCreator(
|
|
2522
2625
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2523
2626
|
);
|
|
2524
2627
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2559,7 +2662,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2559
2662
|
}
|
|
2560
2663
|
return false;
|
|
2561
2664
|
};
|
|
2562
|
-
var noLazyIdentifiers =
|
|
2665
|
+
var noLazyIdentifiers = createRule36({
|
|
2563
2666
|
name: "no-lazy-identifiers",
|
|
2564
2667
|
meta: {
|
|
2565
2668
|
type: "problem",
|
|
@@ -2585,27 +2688,27 @@ var noLazyIdentifiers = createRule34({
|
|
|
2585
2688
|
});
|
|
2586
2689
|
};
|
|
2587
2690
|
const checkPattern = (pattern) => {
|
|
2588
|
-
if (pattern.type ===
|
|
2691
|
+
if (pattern.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2589
2692
|
checkIdentifier(pattern);
|
|
2590
|
-
} else if (pattern.type ===
|
|
2693
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.ObjectPattern) {
|
|
2591
2694
|
pattern.properties.forEach((prop) => {
|
|
2592
|
-
if (prop.type ===
|
|
2695
|
+
if (prop.type === import_utils40.AST_NODE_TYPES.Property && prop.value.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2593
2696
|
checkIdentifier(prop.value);
|
|
2594
|
-
} else if (prop.type ===
|
|
2697
|
+
} else if (prop.type === import_utils40.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2595
2698
|
checkIdentifier(prop.argument);
|
|
2596
2699
|
}
|
|
2597
2700
|
});
|
|
2598
|
-
} else if (pattern.type ===
|
|
2701
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.ArrayPattern) {
|
|
2599
2702
|
pattern.elements.forEach((element) => {
|
|
2600
|
-
if (element?.type ===
|
|
2703
|
+
if (element?.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2601
2704
|
checkIdentifier(element);
|
|
2602
|
-
} else if (element?.type ===
|
|
2705
|
+
} else if (element?.type === import_utils40.AST_NODE_TYPES.RestElement && element.argument.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2603
2706
|
checkIdentifier(element.argument);
|
|
2604
2707
|
}
|
|
2605
2708
|
});
|
|
2606
|
-
} else if (pattern.type ===
|
|
2709
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2607
2710
|
checkIdentifier(pattern.left);
|
|
2608
|
-
} else if (pattern.type ===
|
|
2711
|
+
} else if (pattern.type === import_utils40.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils40.AST_NODE_TYPES.Identifier) {
|
|
2609
2712
|
checkIdentifier(pattern.argument);
|
|
2610
2713
|
}
|
|
2611
2714
|
};
|
|
@@ -2650,11 +2753,11 @@ var noLazyIdentifiers = createRule34({
|
|
|
2650
2753
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2651
2754
|
|
|
2652
2755
|
// src/rules/no-logic-in-params.ts
|
|
2653
|
-
var
|
|
2654
|
-
var
|
|
2756
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2757
|
+
var createRule37 = import_utils41.ESLintUtils.RuleCreator(
|
|
2655
2758
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2656
2759
|
);
|
|
2657
|
-
var noLogicInParams =
|
|
2760
|
+
var noLogicInParams = createRule37({
|
|
2658
2761
|
name: "no-logic-in-params",
|
|
2659
2762
|
meta: {
|
|
2660
2763
|
type: "suggestion",
|
|
@@ -2669,20 +2772,20 @@ var noLogicInParams = createRule35({
|
|
|
2669
2772
|
defaultOptions: [],
|
|
2670
2773
|
create(context) {
|
|
2671
2774
|
const isComplexExpression = (node) => {
|
|
2672
|
-
if (node.type ===
|
|
2775
|
+
if (node.type === import_utils41.AST_NODE_TYPES.SpreadElement) {
|
|
2673
2776
|
return false;
|
|
2674
2777
|
}
|
|
2675
|
-
if (node.type ===
|
|
2778
|
+
if (node.type === import_utils41.AST_NODE_TYPES.ConditionalExpression) {
|
|
2676
2779
|
return true;
|
|
2677
2780
|
}
|
|
2678
|
-
if (node.type ===
|
|
2781
|
+
if (node.type === import_utils41.AST_NODE_TYPES.LogicalExpression) {
|
|
2679
2782
|
return true;
|
|
2680
2783
|
}
|
|
2681
|
-
if (node.type ===
|
|
2784
|
+
if (node.type === import_utils41.AST_NODE_TYPES.BinaryExpression) {
|
|
2682
2785
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2683
2786
|
return logicalOperators.includes(node.operator);
|
|
2684
2787
|
}
|
|
2685
|
-
if (node.type ===
|
|
2788
|
+
if (node.type === import_utils41.AST_NODE_TYPES.UnaryExpression) {
|
|
2686
2789
|
return node.operator === "!";
|
|
2687
2790
|
}
|
|
2688
2791
|
return false;
|
|
@@ -2695,7 +2798,7 @@ var noLogicInParams = createRule35({
|
|
|
2695
2798
|
messageId: "noLogicInParams"
|
|
2696
2799
|
});
|
|
2697
2800
|
}
|
|
2698
|
-
if (arg.type ===
|
|
2801
|
+
if (arg.type === import_utils41.AST_NODE_TYPES.ArrayExpression) {
|
|
2699
2802
|
arg.elements.forEach((element) => {
|
|
2700
2803
|
if (element && isComplexExpression(element)) {
|
|
2701
2804
|
context.report({
|
|
@@ -2720,46 +2823,46 @@ var noLogicInParams = createRule35({
|
|
|
2720
2823
|
var no_logic_in_params_default = noLogicInParams;
|
|
2721
2824
|
|
|
2722
2825
|
// src/rules/no-misleading-constant-case.ts
|
|
2723
|
-
var
|
|
2724
|
-
var
|
|
2826
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2827
|
+
var createRule38 = import_utils42.ESLintUtils.RuleCreator(
|
|
2725
2828
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2726
2829
|
);
|
|
2727
2830
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2728
|
-
var
|
|
2729
|
-
var
|
|
2730
|
-
if (
|
|
2831
|
+
var isAsConstAssertion = (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";
|
|
2832
|
+
var isStaticValue2 = (init) => {
|
|
2833
|
+
if (isAsConstAssertion(init)) {
|
|
2731
2834
|
return true;
|
|
2732
2835
|
}
|
|
2733
|
-
if (init.type ===
|
|
2836
|
+
if (init.type === import_utils42.AST_NODE_TYPES.Literal) {
|
|
2734
2837
|
return true;
|
|
2735
2838
|
}
|
|
2736
|
-
if (init.type ===
|
|
2839
|
+
if (init.type === import_utils42.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils42.AST_NODE_TYPES.Literal) {
|
|
2737
2840
|
return true;
|
|
2738
2841
|
}
|
|
2739
|
-
if (init.type ===
|
|
2842
|
+
if (init.type === import_utils42.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2740
2843
|
return true;
|
|
2741
2844
|
}
|
|
2742
|
-
if (init.type ===
|
|
2743
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
2845
|
+
if (init.type === import_utils42.AST_NODE_TYPES.ArrayExpression) {
|
|
2846
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils42.AST_NODE_TYPES.SpreadElement && isStaticValue2(el));
|
|
2744
2847
|
}
|
|
2745
|
-
if (init.type ===
|
|
2848
|
+
if (init.type === import_utils42.AST_NODE_TYPES.ObjectExpression) {
|
|
2746
2849
|
return init.properties.every(
|
|
2747
|
-
(prop) => prop.type ===
|
|
2850
|
+
(prop) => prop.type === import_utils42.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
2748
2851
|
);
|
|
2749
2852
|
}
|
|
2750
2853
|
return false;
|
|
2751
2854
|
};
|
|
2752
2855
|
var isGlobalScope3 = (node) => {
|
|
2753
2856
|
const { parent } = node;
|
|
2754
|
-
if (parent.type ===
|
|
2857
|
+
if (parent.type === import_utils42.AST_NODE_TYPES.Program) {
|
|
2755
2858
|
return true;
|
|
2756
2859
|
}
|
|
2757
|
-
if (parent.type ===
|
|
2860
|
+
if (parent.type === import_utils42.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils42.AST_NODE_TYPES.Program) {
|
|
2758
2861
|
return true;
|
|
2759
2862
|
}
|
|
2760
2863
|
return false;
|
|
2761
2864
|
};
|
|
2762
|
-
var noMisleadingConstantCase =
|
|
2865
|
+
var noMisleadingConstantCase = createRule38({
|
|
2763
2866
|
name: "no-misleading-constant-case",
|
|
2764
2867
|
meta: {
|
|
2765
2868
|
type: "suggestion",
|
|
@@ -2778,7 +2881,7 @@ var noMisleadingConstantCase = createRule36({
|
|
|
2778
2881
|
return {
|
|
2779
2882
|
VariableDeclaration(node) {
|
|
2780
2883
|
node.declarations.forEach((declarator) => {
|
|
2781
|
-
if (declarator.id.type !==
|
|
2884
|
+
if (declarator.id.type !== import_utils42.AST_NODE_TYPES.Identifier) {
|
|
2782
2885
|
return;
|
|
2783
2886
|
}
|
|
2784
2887
|
const { name } = declarator.id;
|
|
@@ -2804,7 +2907,7 @@ var noMisleadingConstantCase = createRule36({
|
|
|
2804
2907
|
if (!declarator.init) {
|
|
2805
2908
|
return;
|
|
2806
2909
|
}
|
|
2807
|
-
if (!
|
|
2910
|
+
if (!isStaticValue2(declarator.init)) {
|
|
2808
2911
|
context.report({
|
|
2809
2912
|
node: declarator.id,
|
|
2810
2913
|
messageId: "dynamicScreamingCase",
|
|
@@ -2819,11 +2922,11 @@ var noMisleadingConstantCase = createRule36({
|
|
|
2819
2922
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2820
2923
|
|
|
2821
2924
|
// src/rules/no-nested-interface-declaration.ts
|
|
2822
|
-
var
|
|
2823
|
-
var
|
|
2925
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2926
|
+
var createRule39 = import_utils43.ESLintUtils.RuleCreator(
|
|
2824
2927
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2825
2928
|
);
|
|
2826
|
-
var noNestedInterfaceDeclaration =
|
|
2929
|
+
var noNestedInterfaceDeclaration = createRule39({
|
|
2827
2930
|
name: "no-nested-interface-declaration",
|
|
2828
2931
|
meta: {
|
|
2829
2932
|
type: "suggestion",
|
|
@@ -2844,15 +2947,15 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2844
2947
|
return;
|
|
2845
2948
|
}
|
|
2846
2949
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2847
|
-
if (typeAnnotation.type ===
|
|
2950
|
+
if (typeAnnotation.type === import_utils43.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2848
2951
|
context.report({
|
|
2849
2952
|
node: typeAnnotation,
|
|
2850
2953
|
messageId: "noNestedInterface"
|
|
2851
2954
|
});
|
|
2852
2955
|
return;
|
|
2853
2956
|
}
|
|
2854
|
-
if (typeAnnotation.type ===
|
|
2855
|
-
if (typeAnnotation.elementType.type ===
|
|
2957
|
+
if (typeAnnotation.type === import_utils43.AST_NODE_TYPES.TSArrayType) {
|
|
2958
|
+
if (typeAnnotation.elementType.type === import_utils43.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2856
2959
|
context.report({
|
|
2857
2960
|
node: typeAnnotation.elementType,
|
|
2858
2961
|
messageId: "noNestedInterface"
|
|
@@ -2860,9 +2963,9 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2860
2963
|
}
|
|
2861
2964
|
return;
|
|
2862
2965
|
}
|
|
2863
|
-
if (typeAnnotation.type ===
|
|
2966
|
+
if (typeAnnotation.type === import_utils43.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2864
2967
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2865
|
-
if (param.type ===
|
|
2968
|
+
if (param.type === import_utils43.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2866
2969
|
context.report({
|
|
2867
2970
|
node: param,
|
|
2868
2971
|
messageId: "noNestedInterface"
|
|
@@ -2877,11 +2980,11 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2877
2980
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2878
2981
|
|
|
2879
2982
|
// src/rules/no-nested-ternary.ts
|
|
2880
|
-
var
|
|
2881
|
-
var
|
|
2983
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
2984
|
+
var createRule40 = import_utils44.ESLintUtils.RuleCreator(
|
|
2882
2985
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2883
2986
|
);
|
|
2884
|
-
var noNestedTernary =
|
|
2987
|
+
var noNestedTernary = createRule40({
|
|
2885
2988
|
name: "no-nested-ternary",
|
|
2886
2989
|
meta: {
|
|
2887
2990
|
type: "suggestion",
|
|
@@ -2898,13 +3001,13 @@ var noNestedTernary = createRule38({
|
|
|
2898
3001
|
return {
|
|
2899
3002
|
ConditionalExpression(node) {
|
|
2900
3003
|
const { consequent, alternate } = node;
|
|
2901
|
-
if (consequent.type ===
|
|
3004
|
+
if (consequent.type === import_utils44.AST_NODE_TYPES.ConditionalExpression) {
|
|
2902
3005
|
context.report({
|
|
2903
3006
|
node: consequent,
|
|
2904
3007
|
messageId: "noNestedTernary"
|
|
2905
3008
|
});
|
|
2906
3009
|
}
|
|
2907
|
-
if (alternate.type ===
|
|
3010
|
+
if (alternate.type === import_utils44.AST_NODE_TYPES.ConditionalExpression) {
|
|
2908
3011
|
context.report({
|
|
2909
3012
|
node: alternate,
|
|
2910
3013
|
messageId: "noNestedTernary"
|
|
@@ -2917,11 +3020,11 @@ var noNestedTernary = createRule38({
|
|
|
2917
3020
|
var no_nested_ternary_default = noNestedTernary;
|
|
2918
3021
|
|
|
2919
3022
|
// src/rules/no-relative-imports.ts
|
|
2920
|
-
var
|
|
2921
|
-
var
|
|
3023
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
3024
|
+
var createRule41 = import_utils45.ESLintUtils.RuleCreator(
|
|
2922
3025
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2923
3026
|
);
|
|
2924
|
-
var noRelativeImports =
|
|
3027
|
+
var noRelativeImports = createRule41({
|
|
2925
3028
|
name: "no-relative-imports",
|
|
2926
3029
|
meta: {
|
|
2927
3030
|
type: "suggestion",
|
|
@@ -2945,22 +3048,22 @@ var noRelativeImports = createRule39({
|
|
|
2945
3048
|
};
|
|
2946
3049
|
return {
|
|
2947
3050
|
ImportDeclaration(node) {
|
|
2948
|
-
if (node.source.type ===
|
|
3051
|
+
if (node.source.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2949
3052
|
checkImportPath(node.source.value, node);
|
|
2950
3053
|
}
|
|
2951
3054
|
},
|
|
2952
3055
|
ImportExpression(node) {
|
|
2953
|
-
if (node.source.type ===
|
|
3056
|
+
if (node.source.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2954
3057
|
checkImportPath(node.source.value, node);
|
|
2955
3058
|
}
|
|
2956
3059
|
},
|
|
2957
3060
|
ExportNamedDeclaration(node) {
|
|
2958
|
-
if (node.source?.type ===
|
|
3061
|
+
if (node.source?.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2959
3062
|
checkImportPath(node.source.value, node);
|
|
2960
3063
|
}
|
|
2961
3064
|
},
|
|
2962
3065
|
ExportAllDeclaration(node) {
|
|
2963
|
-
if (node.source.type ===
|
|
3066
|
+
if (node.source.type === import_utils45.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2964
3067
|
checkImportPath(node.source.value, node);
|
|
2965
3068
|
}
|
|
2966
3069
|
}
|
|
@@ -2970,8 +3073,8 @@ var noRelativeImports = createRule39({
|
|
|
2970
3073
|
var no_relative_imports_default = noRelativeImports;
|
|
2971
3074
|
|
|
2972
3075
|
// src/rules/no-single-char-variables.ts
|
|
2973
|
-
var
|
|
2974
|
-
var
|
|
3076
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3077
|
+
var createRule42 = import_utils46.ESLintUtils.RuleCreator(
|
|
2975
3078
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2976
3079
|
);
|
|
2977
3080
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -2983,7 +3086,7 @@ var isForLoopInit = (node) => {
|
|
|
2983
3086
|
if (!parentNode) {
|
|
2984
3087
|
return false;
|
|
2985
3088
|
}
|
|
2986
|
-
if (parentNode.type ===
|
|
3089
|
+
if (parentNode.type === import_utils46.AST_NODE_TYPES.ForStatement) {
|
|
2987
3090
|
const { init } = parentNode;
|
|
2988
3091
|
if (init && init === current) {
|
|
2989
3092
|
return true;
|
|
@@ -3002,7 +3105,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
3002
3105
|
}
|
|
3003
3106
|
return false;
|
|
3004
3107
|
};
|
|
3005
|
-
var noSingleCharVariables =
|
|
3108
|
+
var noSingleCharVariables = createRule42({
|
|
3006
3109
|
name: "no-single-char-variables",
|
|
3007
3110
|
meta: {
|
|
3008
3111
|
type: "suggestion",
|
|
@@ -3031,27 +3134,27 @@ var noSingleCharVariables = createRule40({
|
|
|
3031
3134
|
});
|
|
3032
3135
|
};
|
|
3033
3136
|
const checkPattern = (pattern, declarationNode) => {
|
|
3034
|
-
if (pattern.type ===
|
|
3137
|
+
if (pattern.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3035
3138
|
checkIdentifier(pattern, declarationNode);
|
|
3036
|
-
} else if (pattern.type ===
|
|
3139
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.ObjectPattern) {
|
|
3037
3140
|
pattern.properties.forEach((prop) => {
|
|
3038
|
-
if (prop.type ===
|
|
3141
|
+
if (prop.type === import_utils46.AST_NODE_TYPES.Property && prop.value.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3039
3142
|
checkIdentifier(prop.value, declarationNode);
|
|
3040
|
-
} else if (prop.type ===
|
|
3143
|
+
} else if (prop.type === import_utils46.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3041
3144
|
checkIdentifier(prop.argument, declarationNode);
|
|
3042
3145
|
}
|
|
3043
3146
|
});
|
|
3044
|
-
} else if (pattern.type ===
|
|
3147
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.ArrayPattern) {
|
|
3045
3148
|
pattern.elements.forEach((element) => {
|
|
3046
|
-
if (element?.type ===
|
|
3149
|
+
if (element?.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3047
3150
|
checkIdentifier(element, declarationNode);
|
|
3048
|
-
} else if (element?.type ===
|
|
3151
|
+
} else if (element?.type === import_utils46.AST_NODE_TYPES.RestElement && element.argument.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3049
3152
|
checkIdentifier(element.argument, declarationNode);
|
|
3050
3153
|
}
|
|
3051
3154
|
});
|
|
3052
|
-
} else if (pattern.type ===
|
|
3155
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3053
3156
|
checkIdentifier(pattern.left, declarationNode);
|
|
3054
|
-
} else if (pattern.type ===
|
|
3157
|
+
} else if (pattern.type === import_utils46.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3055
3158
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3056
3159
|
}
|
|
3057
3160
|
};
|
|
@@ -3085,11 +3188,11 @@ var noSingleCharVariables = createRule40({
|
|
|
3085
3188
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3086
3189
|
|
|
3087
3190
|
// src/rules/prefer-async-await.ts
|
|
3088
|
-
var
|
|
3089
|
-
var
|
|
3191
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3192
|
+
var createRule43 = import_utils47.ESLintUtils.RuleCreator(
|
|
3090
3193
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3091
3194
|
);
|
|
3092
|
-
var preferAsyncAwait =
|
|
3195
|
+
var preferAsyncAwait = createRule43({
|
|
3093
3196
|
name: "prefer-async-await",
|
|
3094
3197
|
meta: {
|
|
3095
3198
|
type: "suggestion",
|
|
@@ -3105,7 +3208,7 @@ var preferAsyncAwait = createRule41({
|
|
|
3105
3208
|
create(context) {
|
|
3106
3209
|
return {
|
|
3107
3210
|
CallExpression(node) {
|
|
3108
|
-
if (node.callee.type ===
|
|
3211
|
+
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
3212
|
context.report({
|
|
3110
3213
|
node: node.callee.property,
|
|
3111
3214
|
messageId: "preferAsyncAwait"
|
|
@@ -3118,11 +3221,11 @@ var preferAsyncAwait = createRule41({
|
|
|
3118
3221
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3119
3222
|
|
|
3120
3223
|
// src/rules/prefer-destructuring-params.ts
|
|
3121
|
-
var
|
|
3122
|
-
var
|
|
3224
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3225
|
+
var createRule44 = import_utils48.ESLintUtils.RuleCreator(
|
|
3123
3226
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3124
3227
|
);
|
|
3125
|
-
var preferDestructuringParams =
|
|
3228
|
+
var preferDestructuringParams = createRule44({
|
|
3126
3229
|
name: "prefer-destructuring-params",
|
|
3127
3230
|
meta: {
|
|
3128
3231
|
type: "suggestion",
|
|
@@ -3138,18 +3241,18 @@ var preferDestructuringParams = createRule42({
|
|
|
3138
3241
|
create(context) {
|
|
3139
3242
|
const isCallbackFunction2 = (node) => {
|
|
3140
3243
|
const { parent } = node;
|
|
3141
|
-
return parent?.type ===
|
|
3244
|
+
return parent?.type === import_utils48.AST_NODE_TYPES.CallExpression;
|
|
3142
3245
|
};
|
|
3143
3246
|
const isDeveloperFunction = (node) => {
|
|
3144
|
-
if (node.type ===
|
|
3247
|
+
if (node.type === import_utils48.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3145
3248
|
return true;
|
|
3146
3249
|
}
|
|
3147
|
-
if (node.type ===
|
|
3250
|
+
if (node.type === import_utils48.AST_NODE_TYPES.FunctionExpression || node.type === import_utils48.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3148
3251
|
if (isCallbackFunction2(node)) {
|
|
3149
3252
|
return false;
|
|
3150
3253
|
}
|
|
3151
3254
|
const { parent } = node;
|
|
3152
|
-
return parent?.type ===
|
|
3255
|
+
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
3256
|
}
|
|
3154
3257
|
return false;
|
|
3155
3258
|
};
|
|
@@ -3161,7 +3264,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3161
3264
|
if (!isDeveloperFunction(node)) {
|
|
3162
3265
|
return;
|
|
3163
3266
|
}
|
|
3164
|
-
if (node.type ===
|
|
3267
|
+
if (node.type === import_utils48.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3165
3268
|
const functionName = node.id.name;
|
|
3166
3269
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3167
3270
|
return;
|
|
@@ -3171,7 +3274,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3171
3274
|
return;
|
|
3172
3275
|
}
|
|
3173
3276
|
const hasNonDestructuredParams = node.params.some(
|
|
3174
|
-
(param) => param.type !==
|
|
3277
|
+
(param) => param.type !== import_utils48.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils48.AST_NODE_TYPES.RestElement
|
|
3175
3278
|
);
|
|
3176
3279
|
if (hasNonDestructuredParams) {
|
|
3177
3280
|
context.report({
|
|
@@ -3190,8 +3293,8 @@ var preferDestructuringParams = createRule42({
|
|
|
3190
3293
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3191
3294
|
|
|
3192
3295
|
// src/rules/prefer-function-declaration.ts
|
|
3193
|
-
var
|
|
3194
|
-
var
|
|
3296
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3297
|
+
var createRule45 = import_utils49.ESLintUtils.RuleCreator(
|
|
3195
3298
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3196
3299
|
);
|
|
3197
3300
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3200,33 +3303,33 @@ var isCallbackContext = (node) => {
|
|
|
3200
3303
|
if (!parent) {
|
|
3201
3304
|
return false;
|
|
3202
3305
|
}
|
|
3203
|
-
if (parent.type ===
|
|
3306
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3204
3307
|
return true;
|
|
3205
3308
|
}
|
|
3206
|
-
if (parent.type ===
|
|
3309
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3207
3310
|
return true;
|
|
3208
3311
|
}
|
|
3209
|
-
if (parent.type ===
|
|
3312
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.ReturnStatement) {
|
|
3210
3313
|
return true;
|
|
3211
3314
|
}
|
|
3212
|
-
if (parent.type ===
|
|
3315
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.Property) {
|
|
3213
3316
|
return true;
|
|
3214
3317
|
}
|
|
3215
|
-
if (parent.type ===
|
|
3318
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.ArrayExpression) {
|
|
3216
3319
|
return true;
|
|
3217
3320
|
}
|
|
3218
|
-
if (parent.type ===
|
|
3321
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.ConditionalExpression) {
|
|
3219
3322
|
return true;
|
|
3220
3323
|
}
|
|
3221
|
-
if (parent.type ===
|
|
3324
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.LogicalExpression) {
|
|
3222
3325
|
return true;
|
|
3223
3326
|
}
|
|
3224
|
-
if (parent.type ===
|
|
3327
|
+
if (parent.type === import_utils49.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3225
3328
|
return true;
|
|
3226
3329
|
}
|
|
3227
3330
|
return false;
|
|
3228
3331
|
};
|
|
3229
|
-
var preferFunctionDeclaration =
|
|
3332
|
+
var preferFunctionDeclaration = createRule45({
|
|
3230
3333
|
name: "prefer-function-declaration",
|
|
3231
3334
|
meta: {
|
|
3232
3335
|
type: "suggestion",
|
|
@@ -3247,14 +3350,14 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3247
3350
|
}
|
|
3248
3351
|
return {
|
|
3249
3352
|
VariableDeclarator(node) {
|
|
3250
|
-
if (node.id.type !==
|
|
3353
|
+
if (node.id.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3251
3354
|
return;
|
|
3252
3355
|
}
|
|
3253
3356
|
const { init } = node;
|
|
3254
3357
|
if (!init) {
|
|
3255
3358
|
return;
|
|
3256
3359
|
}
|
|
3257
|
-
if (init.type ===
|
|
3360
|
+
if (init.type === import_utils49.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3258
3361
|
if (isCallbackContext(init)) {
|
|
3259
3362
|
return;
|
|
3260
3363
|
}
|
|
@@ -3264,7 +3367,7 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3264
3367
|
data: { name: node.id.name }
|
|
3265
3368
|
});
|
|
3266
3369
|
}
|
|
3267
|
-
if (init.type ===
|
|
3370
|
+
if (init.type === import_utils49.AST_NODE_TYPES.FunctionExpression) {
|
|
3268
3371
|
if (isCallbackContext(init)) {
|
|
3269
3372
|
return;
|
|
3270
3373
|
}
|
|
@@ -3281,11 +3384,11 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3281
3384
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3282
3385
|
|
|
3283
3386
|
// src/rules/prefer-guard-clause.ts
|
|
3284
|
-
var
|
|
3285
|
-
var
|
|
3387
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3388
|
+
var createRule46 = import_utils50.ESLintUtils.RuleCreator(
|
|
3286
3389
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3287
3390
|
);
|
|
3288
|
-
var preferGuardClause =
|
|
3391
|
+
var preferGuardClause = createRule46({
|
|
3289
3392
|
name: "prefer-guard-clause",
|
|
3290
3393
|
meta: {
|
|
3291
3394
|
type: "suggestion",
|
|
@@ -3302,8 +3405,8 @@ var preferGuardClause = createRule44({
|
|
|
3302
3405
|
return {
|
|
3303
3406
|
IfStatement(node) {
|
|
3304
3407
|
const { consequent } = node;
|
|
3305
|
-
if (consequent.type ===
|
|
3306
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3408
|
+
if (consequent.type === import_utils50.AST_NODE_TYPES.BlockStatement) {
|
|
3409
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === import_utils50.AST_NODE_TYPES.IfStatement);
|
|
3307
3410
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3308
3411
|
context.report({
|
|
3309
3412
|
node,
|
|
@@ -3311,7 +3414,7 @@ var preferGuardClause = createRule44({
|
|
|
3311
3414
|
});
|
|
3312
3415
|
}
|
|
3313
3416
|
}
|
|
3314
|
-
if (consequent.type ===
|
|
3417
|
+
if (consequent.type === import_utils50.AST_NODE_TYPES.IfStatement) {
|
|
3315
3418
|
context.report({
|
|
3316
3419
|
node,
|
|
3317
3420
|
messageId: "preferGuardClause"
|
|
@@ -3324,11 +3427,11 @@ var preferGuardClause = createRule44({
|
|
|
3324
3427
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3325
3428
|
|
|
3326
3429
|
// src/rules/prefer-import-type.ts
|
|
3327
|
-
var
|
|
3328
|
-
var
|
|
3430
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
3431
|
+
var createRule47 = import_utils51.ESLintUtils.RuleCreator(
|
|
3329
3432
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3330
3433
|
);
|
|
3331
|
-
var preferImportType =
|
|
3434
|
+
var preferImportType = createRule47({
|
|
3332
3435
|
name: "prefer-import-type",
|
|
3333
3436
|
meta: {
|
|
3334
3437
|
type: "suggestion",
|
|
@@ -3347,22 +3450,22 @@ var preferImportType = createRule45({
|
|
|
3347
3450
|
let current = node;
|
|
3348
3451
|
while (current) {
|
|
3349
3452
|
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
|
|
3453
|
+
case import_utils51.AST_NODE_TYPES.TSTypeReference:
|
|
3454
|
+
case import_utils51.AST_NODE_TYPES.TSTypeAnnotation:
|
|
3455
|
+
case import_utils51.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
3456
|
+
case import_utils51.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
3457
|
+
case import_utils51.AST_NODE_TYPES.TSClassImplements:
|
|
3458
|
+
case import_utils51.AST_NODE_TYPES.TSTypeQuery:
|
|
3459
|
+
case import_utils51.AST_NODE_TYPES.TSTypeAssertion:
|
|
3460
|
+
case import_utils51.AST_NODE_TYPES.TSAsExpression:
|
|
3461
|
+
case import_utils51.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
3462
|
+
case import_utils51.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3463
|
+
case import_utils51.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3464
|
+
case import_utils51.AST_NODE_TYPES.TSTypeParameter:
|
|
3465
|
+
case import_utils51.AST_NODE_TYPES.TSQualifiedName:
|
|
3363
3466
|
return true;
|
|
3364
|
-
case
|
|
3365
|
-
case
|
|
3467
|
+
case import_utils51.AST_NODE_TYPES.MemberExpression:
|
|
3468
|
+
case import_utils51.AST_NODE_TYPES.Identifier:
|
|
3366
3469
|
current = current.parent;
|
|
3367
3470
|
break;
|
|
3368
3471
|
default:
|
|
@@ -3392,27 +3495,27 @@ var preferImportType = createRule45({
|
|
|
3392
3495
|
return false;
|
|
3393
3496
|
}
|
|
3394
3497
|
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
|
|
3498
|
+
case import_utils51.AST_NODE_TYPES.CallExpression:
|
|
3499
|
+
case import_utils51.AST_NODE_TYPES.NewExpression:
|
|
3500
|
+
case import_utils51.AST_NODE_TYPES.JSXOpeningElement:
|
|
3501
|
+
case import_utils51.AST_NODE_TYPES.JSXClosingElement:
|
|
3502
|
+
case import_utils51.AST_NODE_TYPES.MemberExpression:
|
|
3503
|
+
case import_utils51.AST_NODE_TYPES.VariableDeclarator:
|
|
3504
|
+
case import_utils51.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
3505
|
+
case import_utils51.AST_NODE_TYPES.SpreadElement:
|
|
3506
|
+
case import_utils51.AST_NODE_TYPES.ExportSpecifier:
|
|
3507
|
+
case import_utils51.AST_NODE_TYPES.ArrayExpression:
|
|
3508
|
+
case import_utils51.AST_NODE_TYPES.ObjectExpression:
|
|
3509
|
+
case import_utils51.AST_NODE_TYPES.BinaryExpression:
|
|
3510
|
+
case import_utils51.AST_NODE_TYPES.LogicalExpression:
|
|
3511
|
+
case import_utils51.AST_NODE_TYPES.UnaryExpression:
|
|
3512
|
+
case import_utils51.AST_NODE_TYPES.ReturnStatement:
|
|
3513
|
+
case import_utils51.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
3514
|
+
case import_utils51.AST_NODE_TYPES.ConditionalExpression:
|
|
3515
|
+
case import_utils51.AST_NODE_TYPES.AwaitExpression:
|
|
3516
|
+
case import_utils51.AST_NODE_TYPES.YieldExpression:
|
|
3517
|
+
case import_utils51.AST_NODE_TYPES.Property:
|
|
3518
|
+
case import_utils51.AST_NODE_TYPES.JSXExpressionContainer:
|
|
3416
3519
|
return true;
|
|
3417
3520
|
default:
|
|
3418
3521
|
return false;
|
|
@@ -3436,13 +3539,13 @@ var preferImportType = createRule45({
|
|
|
3436
3539
|
}
|
|
3437
3540
|
const scope = context.sourceCode.getScope(node);
|
|
3438
3541
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3439
|
-
if (specifier.type ===
|
|
3542
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3440
3543
|
return false;
|
|
3441
3544
|
}
|
|
3442
|
-
if (specifier.type ===
|
|
3545
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3443
3546
|
return false;
|
|
3444
3547
|
}
|
|
3445
|
-
if (specifier.type ===
|
|
3548
|
+
if (specifier.type === import_utils51.AST_NODE_TYPES.ImportSpecifier) {
|
|
3446
3549
|
const localName = specifier.local.name;
|
|
3447
3550
|
return !isUsedAsValue(localName, scope);
|
|
3448
3551
|
}
|
|
@@ -3468,19 +3571,19 @@ var preferImportType = createRule45({
|
|
|
3468
3571
|
var prefer_import_type_default = preferImportType;
|
|
3469
3572
|
|
|
3470
3573
|
// src/rules/prefer-inline-literal-union.ts
|
|
3471
|
-
var
|
|
3472
|
-
var
|
|
3574
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3575
|
+
var createRule48 = import_utils52.ESLintUtils.RuleCreator(
|
|
3473
3576
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3474
3577
|
);
|
|
3475
3578
|
function isLiteralUnionType(node) {
|
|
3476
|
-
if (node.type !==
|
|
3579
|
+
if (node.type !== import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
3477
3580
|
return false;
|
|
3478
3581
|
}
|
|
3479
3582
|
return node.types.every(
|
|
3480
|
-
(member) => member.type ===
|
|
3583
|
+
(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
3584
|
);
|
|
3482
3585
|
}
|
|
3483
|
-
var preferInlineLiteralUnion =
|
|
3586
|
+
var preferInlineLiteralUnion = createRule48({
|
|
3484
3587
|
name: "prefer-inline-literal-union",
|
|
3485
3588
|
meta: {
|
|
3486
3589
|
type: "suggestion",
|
|
@@ -3507,10 +3610,10 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3507
3610
|
return;
|
|
3508
3611
|
}
|
|
3509
3612
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3510
|
-
if (typeAnnotation.type !==
|
|
3613
|
+
if (typeAnnotation.type !== import_utils52.AST_NODE_TYPES.TSTypeReference) {
|
|
3511
3614
|
return;
|
|
3512
3615
|
}
|
|
3513
|
-
if (typeAnnotation.typeName.type !==
|
|
3616
|
+
if (typeAnnotation.typeName.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3514
3617
|
return;
|
|
3515
3618
|
}
|
|
3516
3619
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3534,12 +3637,12 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3534
3637
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3535
3638
|
|
|
3536
3639
|
// src/rules/prefer-inline-type-export.ts
|
|
3537
|
-
var
|
|
3538
|
-
var
|
|
3640
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3641
|
+
var createRule49 = import_utils53.ESLintUtils.RuleCreator(
|
|
3539
3642
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3540
3643
|
);
|
|
3541
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3542
|
-
var preferInlineTypeExport =
|
|
3644
|
+
var isTypeDeclaration = (node) => node.type === import_utils53.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils53.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
3645
|
+
var preferInlineTypeExport = createRule49({
|
|
3543
3646
|
name: "prefer-inline-type-export",
|
|
3544
3647
|
meta: {
|
|
3545
3648
|
type: "suggestion",
|
|
@@ -3556,12 +3659,12 @@ var preferInlineTypeExport = createRule47({
|
|
|
3556
3659
|
create(context) {
|
|
3557
3660
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3558
3661
|
function collectDeclaration(node) {
|
|
3559
|
-
if (node.parent.type !==
|
|
3662
|
+
if (node.parent.type !== import_utils53.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3560
3663
|
typeDeclarations.set(node.id.name, node);
|
|
3561
3664
|
}
|
|
3562
3665
|
}
|
|
3563
3666
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3564
|
-
if (specifier.local.type !==
|
|
3667
|
+
if (specifier.local.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
3565
3668
|
return;
|
|
3566
3669
|
}
|
|
3567
3670
|
const { name } = specifier.local;
|
|
@@ -3594,16 +3697,16 @@ var preferInlineTypeExport = createRule47({
|
|
|
3594
3697
|
return {
|
|
3595
3698
|
Program(node) {
|
|
3596
3699
|
node.body.forEach((statement) => {
|
|
3597
|
-
if (statement.type ===
|
|
3700
|
+
if (statement.type === import_utils53.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils53.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3598
3701
|
collectDeclaration(statement);
|
|
3599
3702
|
}
|
|
3600
3703
|
});
|
|
3601
3704
|
node.body.forEach((statement) => {
|
|
3602
|
-
if (statement.type !==
|
|
3705
|
+
if (statement.type !== import_utils53.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3603
3706
|
return;
|
|
3604
3707
|
}
|
|
3605
3708
|
statement.specifiers.forEach((specifier) => {
|
|
3606
|
-
if (specifier.local.type !==
|
|
3709
|
+
if (specifier.local.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
3607
3710
|
return;
|
|
3608
3711
|
}
|
|
3609
3712
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3620,11 +3723,11 @@ var preferInlineTypeExport = createRule47({
|
|
|
3620
3723
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3621
3724
|
|
|
3622
3725
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3623
|
-
var
|
|
3624
|
-
var
|
|
3726
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3727
|
+
var createRule50 = import_utils54.ESLintUtils.RuleCreator(
|
|
3625
3728
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3626
3729
|
);
|
|
3627
|
-
var preferInterfaceOverInlineTypes =
|
|
3730
|
+
var preferInterfaceOverInlineTypes = createRule50({
|
|
3628
3731
|
name: "prefer-interface-over-inline-types",
|
|
3629
3732
|
meta: {
|
|
3630
3733
|
type: "suggestion",
|
|
@@ -3640,54 +3743,54 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3640
3743
|
defaultOptions: [],
|
|
3641
3744
|
create(context) {
|
|
3642
3745
|
function hasJSXInConditional(node) {
|
|
3643
|
-
return node.consequent.type ===
|
|
3746
|
+
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
3747
|
}
|
|
3645
3748
|
function hasJSXInLogical(node) {
|
|
3646
|
-
return node.right.type ===
|
|
3749
|
+
return node.right.type === import_utils54.AST_NODE_TYPES.JSXElement || node.right.type === import_utils54.AST_NODE_TYPES.JSXFragment;
|
|
3647
3750
|
}
|
|
3648
3751
|
function hasJSXReturn(block) {
|
|
3649
3752
|
return block.body.some((stmt) => {
|
|
3650
|
-
if (stmt.type ===
|
|
3651
|
-
return stmt.argument.type ===
|
|
3753
|
+
if (stmt.type === import_utils54.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
3754
|
+
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
3755
|
}
|
|
3653
3756
|
return false;
|
|
3654
3757
|
});
|
|
3655
3758
|
}
|
|
3656
3759
|
function isReactComponent2(node) {
|
|
3657
|
-
if (node.type ===
|
|
3658
|
-
if (node.body.type ===
|
|
3760
|
+
if (node.type === import_utils54.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3761
|
+
if (node.body.type === import_utils54.AST_NODE_TYPES.JSXElement || node.body.type === import_utils54.AST_NODE_TYPES.JSXFragment) {
|
|
3659
3762
|
return true;
|
|
3660
3763
|
}
|
|
3661
|
-
if (node.body.type ===
|
|
3764
|
+
if (node.body.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
3662
3765
|
return hasJSXReturn(node.body);
|
|
3663
3766
|
}
|
|
3664
|
-
} else if (node.type ===
|
|
3665
|
-
if (node.body && node.body.type ===
|
|
3767
|
+
} else if (node.type === import_utils54.AST_NODE_TYPES.FunctionExpression || node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3768
|
+
if (node.body && node.body.type === import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
3666
3769
|
return hasJSXReturn(node.body);
|
|
3667
3770
|
}
|
|
3668
3771
|
}
|
|
3669
3772
|
return false;
|
|
3670
3773
|
}
|
|
3671
3774
|
function isInlineTypeAnnotation(node) {
|
|
3672
|
-
if (node.type ===
|
|
3775
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3673
3776
|
return true;
|
|
3674
3777
|
}
|
|
3675
|
-
if (node.type ===
|
|
3676
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3778
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3779
|
+
return node.typeArguments.params.some((param) => param.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral);
|
|
3677
3780
|
}
|
|
3678
|
-
if (node.type ===
|
|
3781
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSUnionType) {
|
|
3679
3782
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3680
3783
|
}
|
|
3681
3784
|
return false;
|
|
3682
3785
|
}
|
|
3683
3786
|
function hasInlineObjectType(node) {
|
|
3684
|
-
if (node.type ===
|
|
3787
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3685
3788
|
return true;
|
|
3686
3789
|
}
|
|
3687
|
-
if (node.type ===
|
|
3688
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3790
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3791
|
+
return node.typeArguments.params.some((param) => param.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral);
|
|
3689
3792
|
}
|
|
3690
|
-
if (node.type ===
|
|
3793
|
+
if (node.type === import_utils54.AST_NODE_TYPES.TSUnionType) {
|
|
3691
3794
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3692
3795
|
}
|
|
3693
3796
|
return false;
|
|
@@ -3700,7 +3803,7 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3700
3803
|
return;
|
|
3701
3804
|
}
|
|
3702
3805
|
const param = node.params[0];
|
|
3703
|
-
if (param.type ===
|
|
3806
|
+
if (param.type === import_utils54.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3704
3807
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3705
3808
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3706
3809
|
context.report({
|
|
@@ -3720,11 +3823,11 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3720
3823
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3721
3824
|
|
|
3722
3825
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3723
|
-
var
|
|
3724
|
-
var
|
|
3826
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
3827
|
+
var createRule51 = import_utils55.ESLintUtils.RuleCreator(
|
|
3725
3828
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3726
3829
|
);
|
|
3727
|
-
var preferJSXTemplateLiterals =
|
|
3830
|
+
var preferJSXTemplateLiterals = createRule51({
|
|
3728
3831
|
name: "prefer-jsx-template-literals",
|
|
3729
3832
|
meta: {
|
|
3730
3833
|
type: "suggestion",
|
|
@@ -3793,9 +3896,9 @@ var preferJSXTemplateLiterals = createRule49({
|
|
|
3793
3896
|
if (!child || !nextChild) {
|
|
3794
3897
|
return;
|
|
3795
3898
|
}
|
|
3796
|
-
if (child.type ===
|
|
3899
|
+
if (child.type === import_utils55.AST_NODE_TYPES.JSXText && nextChild.type === import_utils55.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3797
3900
|
handleTextBeforeExpression(child, nextChild);
|
|
3798
|
-
} else if (child.type ===
|
|
3901
|
+
} else if (child.type === import_utils55.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils55.AST_NODE_TYPES.JSXText) {
|
|
3799
3902
|
handleExpressionBeforeText(child, nextChild);
|
|
3800
3903
|
}
|
|
3801
3904
|
}
|
|
@@ -3808,11 +3911,11 @@ var preferJSXTemplateLiterals = createRule49({
|
|
|
3808
3911
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3809
3912
|
|
|
3810
3913
|
// src/rules/prefer-named-param-types.ts
|
|
3811
|
-
var
|
|
3812
|
-
var
|
|
3914
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
3915
|
+
var createRule52 = import_utils56.ESLintUtils.RuleCreator(
|
|
3813
3916
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3814
3917
|
);
|
|
3815
|
-
var preferNamedParamTypes =
|
|
3918
|
+
var preferNamedParamTypes = createRule52({
|
|
3816
3919
|
name: "prefer-named-param-types",
|
|
3817
3920
|
meta: {
|
|
3818
3921
|
type: "suggestion",
|
|
@@ -3827,16 +3930,16 @@ var preferNamedParamTypes = createRule50({
|
|
|
3827
3930
|
defaultOptions: [],
|
|
3828
3931
|
create(context) {
|
|
3829
3932
|
function hasInlineObjectType(param) {
|
|
3830
|
-
if (param.type ===
|
|
3933
|
+
if (param.type === import_utils56.AST_NODE_TYPES.AssignmentPattern) {
|
|
3831
3934
|
return hasInlineObjectType(param.left);
|
|
3832
3935
|
}
|
|
3833
|
-
if (param.type ===
|
|
3834
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3936
|
+
if (param.type === import_utils56.AST_NODE_TYPES.ObjectPattern) {
|
|
3937
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils56.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3835
3938
|
return true;
|
|
3836
3939
|
}
|
|
3837
3940
|
}
|
|
3838
|
-
if (param.type ===
|
|
3839
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3941
|
+
if (param.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
3942
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils56.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3840
3943
|
return true;
|
|
3841
3944
|
}
|
|
3842
3945
|
}
|
|
@@ -3870,11 +3973,11 @@ var preferNamedParamTypes = createRule50({
|
|
|
3870
3973
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3871
3974
|
|
|
3872
3975
|
// src/rules/prefer-react-import-types.ts
|
|
3873
|
-
var
|
|
3874
|
-
var
|
|
3976
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
3977
|
+
var createRule53 = import_utils57.ESLintUtils.RuleCreator(
|
|
3875
3978
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3876
3979
|
);
|
|
3877
|
-
var preferReactImportTypes =
|
|
3980
|
+
var preferReactImportTypes = createRule53({
|
|
3878
3981
|
name: "prefer-react-import-types",
|
|
3879
3982
|
meta: {
|
|
3880
3983
|
type: "suggestion",
|
|
@@ -3950,7 +4053,7 @@ var preferReactImportTypes = createRule51({
|
|
|
3950
4053
|
]);
|
|
3951
4054
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
3952
4055
|
function checkMemberExpression(node) {
|
|
3953
|
-
if (node.object.type ===
|
|
4056
|
+
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
4057
|
const typeName = node.property.name;
|
|
3955
4058
|
const isType = reactTypes.has(typeName);
|
|
3956
4059
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3967,7 +4070,7 @@ var preferReactImportTypes = createRule51({
|
|
|
3967
4070
|
return {
|
|
3968
4071
|
MemberExpression: checkMemberExpression,
|
|
3969
4072
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
3970
|
-
if (node.left.type ===
|
|
4073
|
+
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
4074
|
const typeName = node.right.name;
|
|
3972
4075
|
const isType = reactTypes.has(typeName);
|
|
3973
4076
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3987,11 +4090,11 @@ var preferReactImportTypes = createRule51({
|
|
|
3987
4090
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
3988
4091
|
|
|
3989
4092
|
// src/rules/react-props-destructure.ts
|
|
3990
|
-
var
|
|
3991
|
-
var
|
|
4093
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
4094
|
+
var createRule54 = import_utils58.ESLintUtils.RuleCreator(
|
|
3992
4095
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3993
4096
|
);
|
|
3994
|
-
var reactPropsDestructure =
|
|
4097
|
+
var reactPropsDestructure = createRule54({
|
|
3995
4098
|
name: "react-props-destructure",
|
|
3996
4099
|
meta: {
|
|
3997
4100
|
type: "suggestion",
|
|
@@ -4007,29 +4110,29 @@ var reactPropsDestructure = createRule52({
|
|
|
4007
4110
|
defaultOptions: [],
|
|
4008
4111
|
create(context) {
|
|
4009
4112
|
function hasJSXInConditional(node) {
|
|
4010
|
-
return node.consequent.type ===
|
|
4113
|
+
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
4114
|
}
|
|
4012
4115
|
function hasJSXInLogical(node) {
|
|
4013
|
-
return node.right.type ===
|
|
4116
|
+
return node.right.type === import_utils58.AST_NODE_TYPES.JSXElement || node.right.type === import_utils58.AST_NODE_TYPES.JSXFragment;
|
|
4014
4117
|
}
|
|
4015
4118
|
function hasJSXReturn(block) {
|
|
4016
4119
|
return block.body.some((stmt) => {
|
|
4017
|
-
if (stmt.type ===
|
|
4018
|
-
return stmt.argument.type ===
|
|
4120
|
+
if (stmt.type === import_utils58.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4121
|
+
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
4122
|
}
|
|
4020
4123
|
return false;
|
|
4021
4124
|
});
|
|
4022
4125
|
}
|
|
4023
4126
|
function isReactComponent2(node) {
|
|
4024
|
-
if (node.type ===
|
|
4025
|
-
if (node.body.type ===
|
|
4127
|
+
if (node.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4128
|
+
if (node.body.type === import_utils58.AST_NODE_TYPES.JSXElement || node.body.type === import_utils58.AST_NODE_TYPES.JSXFragment) {
|
|
4026
4129
|
return true;
|
|
4027
4130
|
}
|
|
4028
|
-
if (node.body.type ===
|
|
4131
|
+
if (node.body.type === import_utils58.AST_NODE_TYPES.BlockStatement) {
|
|
4029
4132
|
return hasJSXReturn(node.body);
|
|
4030
4133
|
}
|
|
4031
|
-
} else if (node.type ===
|
|
4032
|
-
if (node.body && node.body.type ===
|
|
4134
|
+
} else if (node.type === import_utils58.AST_NODE_TYPES.FunctionExpression || node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4135
|
+
if (node.body && node.body.type === import_utils58.AST_NODE_TYPES.BlockStatement) {
|
|
4033
4136
|
return hasJSXReturn(node.body);
|
|
4034
4137
|
}
|
|
4035
4138
|
}
|
|
@@ -4043,9 +4146,9 @@ var reactPropsDestructure = createRule52({
|
|
|
4043
4146
|
return;
|
|
4044
4147
|
}
|
|
4045
4148
|
const param = node.params[0];
|
|
4046
|
-
if (param.type ===
|
|
4047
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4048
|
-
if (prop.key.type ===
|
|
4149
|
+
if (param.type === import_utils58.AST_NODE_TYPES.ObjectPattern) {
|
|
4150
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils58.AST_NODE_TYPES.Property).map((prop) => {
|
|
4151
|
+
if (prop.key.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
4049
4152
|
return prop.key.name;
|
|
4050
4153
|
}
|
|
4051
4154
|
return null;
|
|
@@ -4072,57 +4175,57 @@ var reactPropsDestructure = createRule52({
|
|
|
4072
4175
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4073
4176
|
|
|
4074
4177
|
// src/rules/require-explicit-return-type.ts
|
|
4075
|
-
var
|
|
4076
|
-
var
|
|
4178
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4179
|
+
var createRule55 = import_utils59.ESLintUtils.RuleCreator(
|
|
4077
4180
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4078
4181
|
);
|
|
4079
4182
|
var isReactComponent = (node) => {
|
|
4080
|
-
if (node.type ===
|
|
4183
|
+
if (node.type === import_utils59.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4081
4184
|
const { parent } = node;
|
|
4082
|
-
if (parent?.type ===
|
|
4185
|
+
if (parent?.type === import_utils59.AST_NODE_TYPES.VariableDeclarator) {
|
|
4083
4186
|
const { id } = parent;
|
|
4084
|
-
if (id.type ===
|
|
4187
|
+
if (id.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
4085
4188
|
return /^[A-Z]/.test(id.name);
|
|
4086
4189
|
}
|
|
4087
4190
|
}
|
|
4088
4191
|
}
|
|
4089
|
-
if (node.type ===
|
|
4192
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4090
4193
|
return /^[A-Z]/.test(node.id.name);
|
|
4091
4194
|
}
|
|
4092
4195
|
return false;
|
|
4093
4196
|
};
|
|
4094
4197
|
var isCallbackFunction = (node) => {
|
|
4095
|
-
if (node.type ===
|
|
4198
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4096
4199
|
return false;
|
|
4097
4200
|
}
|
|
4098
4201
|
const { parent } = node;
|
|
4099
4202
|
if (!parent) {
|
|
4100
4203
|
return false;
|
|
4101
4204
|
}
|
|
4102
|
-
if (parent.type ===
|
|
4205
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4103
4206
|
return true;
|
|
4104
4207
|
}
|
|
4105
|
-
if (parent.type ===
|
|
4208
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.Property) {
|
|
4106
4209
|
return true;
|
|
4107
4210
|
}
|
|
4108
|
-
if (parent.type ===
|
|
4211
|
+
if (parent.type === import_utils59.AST_NODE_TYPES.ArrayExpression) {
|
|
4109
4212
|
return true;
|
|
4110
4213
|
}
|
|
4111
4214
|
return false;
|
|
4112
4215
|
};
|
|
4113
4216
|
var getFunctionName = (node) => {
|
|
4114
|
-
if (node.type ===
|
|
4217
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4115
4218
|
return node.id.name;
|
|
4116
4219
|
}
|
|
4117
|
-
if (node.type ===
|
|
4220
|
+
if (node.type === import_utils59.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4118
4221
|
return node.id.name;
|
|
4119
4222
|
}
|
|
4120
|
-
if ((node.type ===
|
|
4223
|
+
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
4224
|
return node.parent.id.name;
|
|
4122
4225
|
}
|
|
4123
4226
|
return null;
|
|
4124
4227
|
};
|
|
4125
|
-
var requireExplicitReturnType =
|
|
4228
|
+
var requireExplicitReturnType = createRule55({
|
|
4126
4229
|
name: "require-explicit-return-type",
|
|
4127
4230
|
meta: {
|
|
4128
4231
|
type: "suggestion",
|
|
@@ -4171,8 +4274,8 @@ var requireExplicitReturnType = createRule53({
|
|
|
4171
4274
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4172
4275
|
|
|
4173
4276
|
// src/rules/sort-exports.ts
|
|
4174
|
-
var
|
|
4175
|
-
var
|
|
4277
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4278
|
+
var createRule56 = import_utils60.ESLintUtils.RuleCreator(
|
|
4176
4279
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4177
4280
|
);
|
|
4178
4281
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4186,7 +4289,7 @@ function getExportGroup(node) {
|
|
|
4186
4289
|
}
|
|
4187
4290
|
return 1;
|
|
4188
4291
|
}
|
|
4189
|
-
var sortExports =
|
|
4292
|
+
var sortExports = createRule56({
|
|
4190
4293
|
name: "sort-exports",
|
|
4191
4294
|
meta: {
|
|
4192
4295
|
type: "suggestion",
|
|
@@ -4226,7 +4329,7 @@ var sortExports = createRule54({
|
|
|
4226
4329
|
Program(node) {
|
|
4227
4330
|
const exportGroups = [];
|
|
4228
4331
|
node.body.forEach((statement) => {
|
|
4229
|
-
if (statement.type !==
|
|
4332
|
+
if (statement.type !== import_utils60.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4230
4333
|
if (exportGroups.length > 0) {
|
|
4231
4334
|
checkOrder(exportGroups);
|
|
4232
4335
|
exportGroups.length = 0;
|
|
@@ -4245,8 +4348,8 @@ var sortExports = createRule54({
|
|
|
4245
4348
|
var sort_exports_default = sortExports;
|
|
4246
4349
|
|
|
4247
4350
|
// src/rules/sort-imports.ts
|
|
4248
|
-
var
|
|
4249
|
-
var
|
|
4351
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
4352
|
+
var createRule57 = import_utils61.ESLintUtils.RuleCreator(
|
|
4250
4353
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4251
4354
|
);
|
|
4252
4355
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4313,7 +4416,7 @@ function getImportGroup(node) {
|
|
|
4313
4416
|
function isTypeOnlyImport(node) {
|
|
4314
4417
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4315
4418
|
}
|
|
4316
|
-
var sortImports =
|
|
4419
|
+
var sortImports = createRule57({
|
|
4317
4420
|
name: "sort-imports",
|
|
4318
4421
|
meta: {
|
|
4319
4422
|
type: "suggestion",
|
|
@@ -4357,7 +4460,7 @@ var sortImports = createRule55({
|
|
|
4357
4460
|
Program(node) {
|
|
4358
4461
|
const importGroups = [];
|
|
4359
4462
|
node.body.forEach((statement) => {
|
|
4360
|
-
if (statement.type !==
|
|
4463
|
+
if (statement.type !== import_utils61.AST_NODE_TYPES.ImportDeclaration) {
|
|
4361
4464
|
if (importGroups.length > 0) {
|
|
4362
4465
|
checkOrder(importGroups);
|
|
4363
4466
|
importGroups.length = 0;
|
|
@@ -4379,13 +4482,13 @@ var sortImports = createRule55({
|
|
|
4379
4482
|
var sort_imports_default = sortImports;
|
|
4380
4483
|
|
|
4381
4484
|
// src/rules/sort-type-alphabetically.ts
|
|
4382
|
-
var
|
|
4383
|
-
var
|
|
4485
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
4486
|
+
var createRule58 = import_utils62.ESLintUtils.RuleCreator(
|
|
4384
4487
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4385
4488
|
);
|
|
4386
4489
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4387
4490
|
const properties = members.filter(
|
|
4388
|
-
(member) => member.type ===
|
|
4491
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4389
4492
|
);
|
|
4390
4493
|
if (properties.length < 2) {
|
|
4391
4494
|
return true;
|
|
@@ -4396,7 +4499,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4396
4499
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4397
4500
|
return isRequiredSorted && isOptionalSorted;
|
|
4398
4501
|
}
|
|
4399
|
-
var sortTypeAlphabetically =
|
|
4502
|
+
var sortTypeAlphabetically = createRule58({
|
|
4400
4503
|
name: "sort-type-alphabetically",
|
|
4401
4504
|
meta: {
|
|
4402
4505
|
type: "suggestion",
|
|
@@ -4414,7 +4517,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4414
4517
|
function fixMembers(fixer, members) {
|
|
4415
4518
|
const { sourceCode } = context;
|
|
4416
4519
|
const properties = members.filter(
|
|
4417
|
-
(member) => member.type ===
|
|
4520
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4418
4521
|
);
|
|
4419
4522
|
const required = properties.filter((prop) => !prop.optional);
|
|
4420
4523
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4451,7 +4554,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4451
4554
|
}
|
|
4452
4555
|
},
|
|
4453
4556
|
TSTypeAliasDeclaration(node) {
|
|
4454
|
-
if (node.typeAnnotation.type !==
|
|
4557
|
+
if (node.typeAnnotation.type !== import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4455
4558
|
return;
|
|
4456
4559
|
}
|
|
4457
4560
|
const { members } = node.typeAnnotation;
|
|
@@ -4471,13 +4574,13 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4471
4574
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4472
4575
|
|
|
4473
4576
|
// src/rules/sort-type-required-first.ts
|
|
4474
|
-
var
|
|
4475
|
-
var
|
|
4577
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
4578
|
+
var createRule59 = import_utils63.ESLintUtils.RuleCreator(
|
|
4476
4579
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4477
4580
|
);
|
|
4478
4581
|
function isRequiredBeforeOptional(members) {
|
|
4479
4582
|
const properties = members.filter(
|
|
4480
|
-
(member) => member.type ===
|
|
4583
|
+
(member) => member.type === import_utils63.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils63.AST_NODE_TYPES.Identifier
|
|
4481
4584
|
);
|
|
4482
4585
|
if (properties.length < 2) {
|
|
4483
4586
|
return true;
|
|
@@ -4488,7 +4591,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4488
4591
|
}
|
|
4489
4592
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4490
4593
|
}
|
|
4491
|
-
var sortTypeRequiredFirst =
|
|
4594
|
+
var sortTypeRequiredFirst = createRule59({
|
|
4492
4595
|
name: "sort-type-required-first",
|
|
4493
4596
|
meta: {
|
|
4494
4597
|
type: "suggestion",
|
|
@@ -4506,7 +4609,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4506
4609
|
function fixMembers(fixer, members) {
|
|
4507
4610
|
const { sourceCode } = context;
|
|
4508
4611
|
const properties = members.filter(
|
|
4509
|
-
(member) => member.type ===
|
|
4612
|
+
(member) => member.type === import_utils63.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils63.AST_NODE_TYPES.Identifier
|
|
4510
4613
|
);
|
|
4511
4614
|
const required = properties.filter((prop) => !prop.optional);
|
|
4512
4615
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4527,7 +4630,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4527
4630
|
}
|
|
4528
4631
|
},
|
|
4529
4632
|
TSTypeAliasDeclaration(node) {
|
|
4530
|
-
if (node.typeAnnotation.type !==
|
|
4633
|
+
if (node.typeAnnotation.type !== import_utils63.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4531
4634
|
return;
|
|
4532
4635
|
}
|
|
4533
4636
|
const { members } = node.typeAnnotation;
|
|
@@ -4564,6 +4667,7 @@ var rules = {
|
|
|
4564
4667
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4565
4668
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4566
4669
|
"file-kebab-case": file_kebab_case_default,
|
|
4670
|
+
"index-export-only": index_export_only_default,
|
|
4567
4671
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
4568
4672
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
4569
4673
|
"jsx-no-newline-single-line-elements": jsx_no_newline_single_line_elements_default,
|
|
@@ -4585,6 +4689,7 @@ var rules = {
|
|
|
4585
4689
|
"no-inline-default-export": no_inline_default_export_default,
|
|
4586
4690
|
"no-inline-nested-object": no_inline_nested_object_default,
|
|
4587
4691
|
"no-inline-return-properties": no_inline_return_properties_default,
|
|
4692
|
+
"no-inline-type-import": no_inline_type_import_default,
|
|
4588
4693
|
"no-lazy-identifiers": no_lazy_identifiers_default,
|
|
4589
4694
|
"no-logic-in-params": no_logic_in_params_default,
|
|
4590
4695
|
"no-misleading-constant-case": no_misleading_constant_case_default,
|
|
@@ -4625,6 +4730,7 @@ var baseRules = {
|
|
|
4625
4730
|
"nextfriday/enforce-sorted-destructuring": "warn",
|
|
4626
4731
|
"nextfriday/enforce-type-declaration-order": "warn",
|
|
4627
4732
|
"nextfriday/file-kebab-case": "warn",
|
|
4733
|
+
"nextfriday/index-export-only": "warn",
|
|
4628
4734
|
"nextfriday/newline-after-multiline-block": "warn",
|
|
4629
4735
|
"nextfriday/newline-before-return": "warn",
|
|
4630
4736
|
"nextfriday/no-complex-inline-return": "warn",
|
|
@@ -4634,6 +4740,7 @@ var baseRules = {
|
|
|
4634
4740
|
"nextfriday/no-inline-default-export": "warn",
|
|
4635
4741
|
"nextfriday/no-inline-nested-object": "warn",
|
|
4636
4742
|
"nextfriday/no-inline-return-properties": "warn",
|
|
4743
|
+
"nextfriday/no-inline-type-import": "warn",
|
|
4637
4744
|
"nextfriday/no-lazy-identifiers": "warn",
|
|
4638
4745
|
"nextfriday/no-logic-in-params": "warn",
|
|
4639
4746
|
"nextfriday/no-misleading-constant-case": "warn",
|
|
@@ -4667,6 +4774,7 @@ var baseRecommendedRules = {
|
|
|
4667
4774
|
"nextfriday/enforce-sorted-destructuring": "error",
|
|
4668
4775
|
"nextfriday/enforce-type-declaration-order": "error",
|
|
4669
4776
|
"nextfriday/file-kebab-case": "error",
|
|
4777
|
+
"nextfriday/index-export-only": "error",
|
|
4670
4778
|
"nextfriday/newline-after-multiline-block": "error",
|
|
4671
4779
|
"nextfriday/newline-before-return": "error",
|
|
4672
4780
|
"nextfriday/no-complex-inline-return": "error",
|
|
@@ -4676,6 +4784,7 @@ var baseRecommendedRules = {
|
|
|
4676
4784
|
"nextfriday/no-inline-default-export": "error",
|
|
4677
4785
|
"nextfriday/no-inline-nested-object": "error",
|
|
4678
4786
|
"nextfriday/no-inline-return-properties": "error",
|
|
4787
|
+
"nextfriday/no-inline-type-import": "error",
|
|
4679
4788
|
"nextfriday/no-lazy-identifiers": "error",
|
|
4680
4789
|
"nextfriday/no-logic-in-params": "error",
|
|
4681
4790
|
"nextfriday/no-misleading-constant-case": "error",
|