eslint-plugin-nextfriday 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +33 -61
- package/docs/agents/domain.md +51 -0
- package/docs/agents/issue-tracker.md +22 -0
- package/docs/agents/triage-labels.md +15 -0
- package/docs/rules/ENFORCE_CONSTANT_CASE.md +28 -17
- package/docs/rules/NO_INLINE_NESTED_OBJECT.md +45 -27
- package/docs/rules/PREFER_GUARD_CLAUSE.md +2 -0
- package/docs/rules/PREFER_IMPORT_TYPE.md +5 -0
- package/docs/rules/PREFER_INTERFACE_FOR_COMPONENT_PROPS.md +53 -0
- package/docs/rules/PREFER_NAMED_PARAM_TYPES.md +5 -1
- package/docs/rules/PREFER_PROPS_WITH_CHILDREN.md +112 -0
- package/lib/index.cjs +667 -757
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +92 -200
- package/lib/index.d.ts +92 -200
- package/lib/index.js +634 -724
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/docs/rules/ENFORCE_CURLY_NEWLINE.md +0 -55
- package/docs/rules/FILE_KEBAB_CASE.md +0 -70
- package/docs/rules/JSX_PASCAL_CASE.md +0 -71
- package/docs/rules/NEXTJS_REQUIRE_PUBLIC_ENV.md +0 -44
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: "
|
|
43
|
+
version: "4.0.0",
|
|
44
44
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
45
45
|
keywords: [
|
|
46
46
|
"eslint",
|
|
@@ -436,6 +436,10 @@ var import_node_path = require("path");
|
|
|
436
436
|
var import_utils3 = require("@typescript-eslint/utils");
|
|
437
437
|
var getFileExtension = (filename) => (0, import_node_path.extname)(filename).slice(1);
|
|
438
438
|
var getBaseName = (filename) => (0, import_node_path.basename)(filename, (0, import_node_path.extname)(filename));
|
|
439
|
+
var isJsxFile = (filename) => {
|
|
440
|
+
const ext = getFileExtension(filename);
|
|
441
|
+
return ext === "jsx" || ext === "tsx";
|
|
442
|
+
};
|
|
439
443
|
var isConfigFile = (filename) => {
|
|
440
444
|
const baseName = getBaseName(filename);
|
|
441
445
|
return /\.(config|rc|setup|spec|test)$/.test(baseName) || /\.(config|rc|setup|spec|test)\./.test(filename) || /^\.(eslintrc|babelrc|prettierrc)/.test(filename);
|
|
@@ -447,40 +451,14 @@ var createRule3 = import_utils4.ESLintUtils.RuleCreator(
|
|
|
447
451
|
);
|
|
448
452
|
var SCREAMING_SNAKE_CASE_REGEX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
449
453
|
var SNAKE_CASE_REGEX2 = /^[a-z]+_[a-z0-9_]*$/;
|
|
450
|
-
var BOOLEAN_PREFIXES2 = ["is", "has", "should", "can", "did", "will", "was", "are", "does", "had"];
|
|
451
454
|
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
|
-
}
|
|
455
|
+
var isMagicLiteral = (init) => {
|
|
468
456
|
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;
|
|
457
|
+
return typeof init.value === "string" || typeof init.value === "number";
|
|
473
458
|
}
|
|
474
|
-
if (init.type === import_utils4.AST_NODE_TYPES.
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if (init.type === import_utils4.AST_NODE_TYPES.ArrayExpression) {
|
|
478
|
-
return init.elements.every((el) => el !== null && el.type !== import_utils4.AST_NODE_TYPES.SpreadElement && isStaticValue2(el));
|
|
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
|
-
);
|
|
459
|
+
if (init.type === import_utils4.AST_NODE_TYPES.UnaryExpression) {
|
|
460
|
+
const { argument, operator } = init;
|
|
461
|
+
return (operator === "-" || operator === "+") && argument.type === import_utils4.AST_NODE_TYPES.Literal && typeof argument.value === "number";
|
|
484
462
|
}
|
|
485
463
|
return false;
|
|
486
464
|
};
|
|
@@ -494,13 +472,12 @@ var isGlobalScope2 = (node) => {
|
|
|
494
472
|
}
|
|
495
473
|
return false;
|
|
496
474
|
};
|
|
497
|
-
var isFunctionOrComponent = (init) => init.type === import_utils4.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils4.AST_NODE_TYPES.FunctionExpression;
|
|
498
475
|
var enforceConstantCase = createRule3({
|
|
499
476
|
name: "enforce-constant-case",
|
|
500
477
|
meta: {
|
|
501
478
|
type: "suggestion",
|
|
502
479
|
docs: {
|
|
503
|
-
description: "Enforce SCREAMING_SNAKE_CASE for global
|
|
480
|
+
description: "Enforce SCREAMING_SNAKE_CASE for global magic-number and magic-text constants"
|
|
504
481
|
},
|
|
505
482
|
messages: {
|
|
506
483
|
useScreamingSnakeCase: "Constant '{{ name }}' should use SCREAMING_SNAKE_CASE. Rename to '{{ suggestion }}'.",
|
|
@@ -522,16 +499,10 @@ var enforceConstantCase = createRule3({
|
|
|
522
499
|
if (declarator.id.type !== import_utils4.AST_NODE_TYPES.Identifier || !declarator.init) {
|
|
523
500
|
return;
|
|
524
501
|
}
|
|
525
|
-
if (
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
if (!isStaticValue2(declarator.init)) {
|
|
502
|
+
if (!isMagicLiteral(declarator.init)) {
|
|
529
503
|
return;
|
|
530
504
|
}
|
|
531
505
|
const { name } = declarator.id;
|
|
532
|
-
if (isBooleanLiteral2(declarator.init) && startsWithBooleanPrefix2(name)) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
506
|
if (SNAKE_CASE_REGEX2.test(name)) {
|
|
536
507
|
context.report({
|
|
537
508
|
node: declarator.id,
|
|
@@ -554,84 +525,13 @@ var enforceConstantCase = createRule3({
|
|
|
554
525
|
});
|
|
555
526
|
var enforce_constant_case_default = enforceConstantCase;
|
|
556
527
|
|
|
557
|
-
// src/rules/enforce-curly-newline.ts
|
|
558
|
-
var import_utils6 = require("@typescript-eslint/utils");
|
|
559
|
-
var createRule4 = import_utils6.ESLintUtils.RuleCreator(
|
|
560
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
561
|
-
);
|
|
562
|
-
var enforceCurlyNewline = createRule4({
|
|
563
|
-
name: "enforce-curly-newline",
|
|
564
|
-
meta: {
|
|
565
|
-
type: "layout",
|
|
566
|
-
docs: {
|
|
567
|
-
description: "Enforce curly braces for multi-line if statements and forbid them for single-line"
|
|
568
|
-
},
|
|
569
|
-
fixable: "code",
|
|
570
|
-
messages: {
|
|
571
|
-
requireBraces: "Multi-line if statements must use curly braces.",
|
|
572
|
-
forbidBraces: "Single-line if statements must not use curly braces."
|
|
573
|
-
},
|
|
574
|
-
schema: []
|
|
575
|
-
},
|
|
576
|
-
defaultOptions: [],
|
|
577
|
-
create(context) {
|
|
578
|
-
const { sourceCode } = context;
|
|
579
|
-
return {
|
|
580
|
-
IfStatement(node) {
|
|
581
|
-
const { consequent } = node;
|
|
582
|
-
const startLine = node.loc.start.line;
|
|
583
|
-
const endLine = node.loc.end.line;
|
|
584
|
-
const isSingleLine2 = startLine === endLine;
|
|
585
|
-
const hasBraces = consequent.type === import_utils6.AST_NODE_TYPES.BlockStatement;
|
|
586
|
-
if (isSingleLine2 && hasBraces) {
|
|
587
|
-
if (consequent.body.length !== 1) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
const innerStatement = consequent.body[0];
|
|
591
|
-
const innerText = sourceCode.getText(innerStatement);
|
|
592
|
-
context.report({
|
|
593
|
-
node: consequent,
|
|
594
|
-
messageId: "forbidBraces",
|
|
595
|
-
fix(fixer) {
|
|
596
|
-
return fixer.replaceText(consequent, innerText);
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
if (!isSingleLine2 && !hasBraces) {
|
|
601
|
-
context.report({
|
|
602
|
-
node: consequent,
|
|
603
|
-
messageId: "requireBraces",
|
|
604
|
-
fix(fixer) {
|
|
605
|
-
const consequentText = sourceCode.getText(consequent);
|
|
606
|
-
const closingParen = sourceCode.getTokenBefore(consequent);
|
|
607
|
-
if (!closingParen) {
|
|
608
|
-
return null;
|
|
609
|
-
}
|
|
610
|
-
const ifStartLine = sourceCode.lines[startLine - 1];
|
|
611
|
-
const indentRegex = /^(\s*)/;
|
|
612
|
-
const indentMatch = indentRegex.exec(ifStartLine);
|
|
613
|
-
const baseIndent = indentMatch ? indentMatch[1] : "";
|
|
614
|
-
const bodyIndent = `${baseIndent} `;
|
|
615
|
-
const newText = ` {
|
|
616
|
-
${bodyIndent}${consequentText.trim()}
|
|
617
|
-
${baseIndent}}`;
|
|
618
|
-
return fixer.replaceTextRange([closingParen.range[1], consequent.range[1]], newText);
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
var enforce_curly_newline_default = enforceCurlyNewline;
|
|
627
|
-
|
|
628
528
|
// src/rules/enforce-hook-naming.ts
|
|
629
529
|
var import_path = __toESM(require("path"), 1);
|
|
630
|
-
var
|
|
631
|
-
var
|
|
530
|
+
var import_utils6 = require("@typescript-eslint/utils");
|
|
531
|
+
var createRule4 = import_utils6.ESLintUtils.RuleCreator(
|
|
632
532
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
633
533
|
);
|
|
634
|
-
var enforceHookNaming =
|
|
534
|
+
var enforceHookNaming = createRule4({
|
|
635
535
|
name: "enforce-hook-naming",
|
|
636
536
|
meta: {
|
|
637
537
|
type: "suggestion",
|
|
@@ -670,22 +570,22 @@ var enforceHookNaming = createRule5({
|
|
|
670
570
|
};
|
|
671
571
|
return {
|
|
672
572
|
ExportNamedDeclaration(node) {
|
|
673
|
-
if (node.declaration?.type ===
|
|
573
|
+
if (node.declaration?.type === import_utils6.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
674
574
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "missingUsePrefix");
|
|
675
575
|
}
|
|
676
|
-
if (node.declaration?.type ===
|
|
576
|
+
if (node.declaration?.type === import_utils6.AST_NODE_TYPES.VariableDeclaration) {
|
|
677
577
|
node.declaration.declarations.forEach((declarator) => {
|
|
678
|
-
if (declarator.id.type ===
|
|
578
|
+
if (declarator.id.type === import_utils6.AST_NODE_TYPES.Identifier) {
|
|
679
579
|
checkFunctionName(declarator.id.name, declarator.id, "missingUsePrefix");
|
|
680
580
|
}
|
|
681
581
|
});
|
|
682
582
|
}
|
|
683
583
|
},
|
|
684
584
|
ExportDefaultDeclaration(node) {
|
|
685
|
-
if (node.declaration.type ===
|
|
585
|
+
if (node.declaration.type === import_utils6.AST_NODE_TYPES.Identifier) {
|
|
686
586
|
checkFunctionName(node.declaration.name, node.declaration, "defaultExportMissingUsePrefix");
|
|
687
587
|
}
|
|
688
|
-
if (node.declaration.type ===
|
|
588
|
+
if (node.declaration.type === import_utils6.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
689
589
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "defaultExportMissingUsePrefix");
|
|
690
590
|
}
|
|
691
591
|
}
|
|
@@ -695,26 +595,26 @@ var enforceHookNaming = createRule5({
|
|
|
695
595
|
var enforce_hook_naming_default = enforceHookNaming;
|
|
696
596
|
|
|
697
597
|
// src/rules/enforce-property-case.ts
|
|
698
|
-
var
|
|
699
|
-
var
|
|
598
|
+
var import_utils7 = require("@typescript-eslint/utils");
|
|
599
|
+
var createRule5 = import_utils7.ESLintUtils.RuleCreator(
|
|
700
600
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
701
601
|
);
|
|
702
602
|
var SNAKE_CASE_REGEX3 = /^[a-z]+_[a-z0-9_]*$/;
|
|
703
603
|
var SCREAMING_SNAKE_CASE_REGEX2 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
704
604
|
var isInsideAsConst = (node) => {
|
|
705
605
|
const { parent } = node;
|
|
706
|
-
if (parent.type ===
|
|
606
|
+
if (parent.type === import_utils7.AST_NODE_TYPES.TSAsExpression && parent.typeAnnotation.type === import_utils7.AST_NODE_TYPES.TSTypeReference && parent.typeAnnotation.typeName.type === import_utils7.AST_NODE_TYPES.Identifier && parent.typeAnnotation.typeName.name === "const") {
|
|
707
607
|
return true;
|
|
708
608
|
}
|
|
709
|
-
if (parent.type ===
|
|
609
|
+
if (parent.type === import_utils7.AST_NODE_TYPES.ArrayExpression) {
|
|
710
610
|
const grandparent = parent.parent;
|
|
711
|
-
if (grandparent?.type ===
|
|
611
|
+
if (grandparent?.type === import_utils7.AST_NODE_TYPES.TSAsExpression && grandparent.typeAnnotation.type === import_utils7.AST_NODE_TYPES.TSTypeReference && grandparent.typeAnnotation.typeName.type === import_utils7.AST_NODE_TYPES.Identifier && grandparent.typeAnnotation.typeName.name === "const") {
|
|
712
612
|
return true;
|
|
713
613
|
}
|
|
714
614
|
}
|
|
715
615
|
return false;
|
|
716
616
|
};
|
|
717
|
-
var enforcePropertyCase =
|
|
617
|
+
var enforcePropertyCase = createRule5({
|
|
718
618
|
name: "enforce-property-case",
|
|
719
619
|
meta: {
|
|
720
620
|
type: "suggestion",
|
|
@@ -730,7 +630,7 @@ var enforcePropertyCase = createRule6({
|
|
|
730
630
|
create(context) {
|
|
731
631
|
return {
|
|
732
632
|
Property(node) {
|
|
733
|
-
if (node.parent.type !==
|
|
633
|
+
if (node.parent.type !== import_utils7.AST_NODE_TYPES.ObjectExpression) {
|
|
734
634
|
return;
|
|
735
635
|
}
|
|
736
636
|
if (isInsideAsConst(node.parent)) {
|
|
@@ -739,7 +639,7 @@ var enforcePropertyCase = createRule6({
|
|
|
739
639
|
if (node.computed) {
|
|
740
640
|
return;
|
|
741
641
|
}
|
|
742
|
-
if (node.key.type !==
|
|
642
|
+
if (node.key.type !== import_utils7.AST_NODE_TYPES.Identifier) {
|
|
743
643
|
return;
|
|
744
644
|
}
|
|
745
645
|
const { name } = node.key;
|
|
@@ -758,11 +658,11 @@ var enforce_property_case_default = enforcePropertyCase;
|
|
|
758
658
|
|
|
759
659
|
// src/rules/enforce-props-suffix.ts
|
|
760
660
|
var import_path2 = __toESM(require("path"), 1);
|
|
761
|
-
var
|
|
762
|
-
var
|
|
661
|
+
var import_utils8 = require("@typescript-eslint/utils");
|
|
662
|
+
var createRule6 = import_utils8.ESLintUtils.RuleCreator(
|
|
763
663
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
764
664
|
);
|
|
765
|
-
var enforcePropsSuffix =
|
|
665
|
+
var enforcePropsSuffix = createRule6({
|
|
766
666
|
name: "enforce-props-suffix",
|
|
767
667
|
meta: {
|
|
768
668
|
type: "suggestion",
|
|
@@ -796,13 +696,13 @@ var enforcePropsSuffix = createRule7({
|
|
|
796
696
|
};
|
|
797
697
|
return {
|
|
798
698
|
TSInterfaceDeclaration(node) {
|
|
799
|
-
if (node.id.type ===
|
|
699
|
+
if (node.id.type === import_utils8.AST_NODE_TYPES.Identifier) {
|
|
800
700
|
checkTypeName(node.id.name, node.id);
|
|
801
701
|
}
|
|
802
702
|
},
|
|
803
703
|
TSTypeAliasDeclaration(node) {
|
|
804
|
-
if (node.id.type ===
|
|
805
|
-
if (node.typeAnnotation.type ===
|
|
704
|
+
if (node.id.type === import_utils8.AST_NODE_TYPES.Identifier) {
|
|
705
|
+
if (node.typeAnnotation.type === import_utils8.AST_NODE_TYPES.TSTypeLiteral) {
|
|
806
706
|
checkTypeName(node.id.name, node.id);
|
|
807
707
|
}
|
|
808
708
|
}
|
|
@@ -813,11 +713,11 @@ var enforcePropsSuffix = createRule7({
|
|
|
813
713
|
var enforce_props_suffix_default = enforcePropsSuffix;
|
|
814
714
|
|
|
815
715
|
// src/rules/enforce-readonly-component-props.ts
|
|
816
|
-
var
|
|
817
|
-
var
|
|
716
|
+
var import_utils9 = require("@typescript-eslint/utils");
|
|
717
|
+
var createRule7 = import_utils9.ESLintUtils.RuleCreator(
|
|
818
718
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
819
719
|
);
|
|
820
|
-
var enforceReadonlyComponentProps =
|
|
720
|
+
var enforceReadonlyComponentProps = createRule7({
|
|
821
721
|
name: "enforce-readonly-component-props",
|
|
822
722
|
meta: {
|
|
823
723
|
type: "suggestion",
|
|
@@ -833,40 +733,40 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
833
733
|
defaultOptions: [],
|
|
834
734
|
create(context) {
|
|
835
735
|
function hasJSXInConditional(node) {
|
|
836
|
-
return node.consequent.type ===
|
|
736
|
+
return node.consequent.type === import_utils9.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils9.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils9.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils9.AST_NODE_TYPES.JSXFragment;
|
|
837
737
|
}
|
|
838
738
|
function hasJSXInLogical(node) {
|
|
839
|
-
return node.right.type ===
|
|
739
|
+
return node.right.type === import_utils9.AST_NODE_TYPES.JSXElement || node.right.type === import_utils9.AST_NODE_TYPES.JSXFragment;
|
|
840
740
|
}
|
|
841
741
|
function hasJSXReturn(block) {
|
|
842
742
|
return block.body.some((stmt) => {
|
|
843
|
-
if (stmt.type ===
|
|
844
|
-
return stmt.argument.type ===
|
|
743
|
+
if (stmt.type === import_utils9.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
744
|
+
return stmt.argument.type === import_utils9.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils9.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils9.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils9.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
845
745
|
}
|
|
846
746
|
return false;
|
|
847
747
|
});
|
|
848
748
|
}
|
|
849
749
|
function isReactComponent2(node) {
|
|
850
|
-
if (node.type ===
|
|
851
|
-
if (node.body.type ===
|
|
750
|
+
if (node.type === import_utils9.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
751
|
+
if (node.body.type === import_utils9.AST_NODE_TYPES.JSXElement || node.body.type === import_utils9.AST_NODE_TYPES.JSXFragment) {
|
|
852
752
|
return true;
|
|
853
753
|
}
|
|
854
|
-
if (node.body.type ===
|
|
754
|
+
if (node.body.type === import_utils9.AST_NODE_TYPES.BlockStatement) {
|
|
855
755
|
return hasJSXReturn(node.body);
|
|
856
756
|
}
|
|
857
|
-
} else if (node.type ===
|
|
858
|
-
if (node.body && node.body.type ===
|
|
757
|
+
} else if (node.type === import_utils9.AST_NODE_TYPES.FunctionExpression || node.type === import_utils9.AST_NODE_TYPES.FunctionDeclaration) {
|
|
758
|
+
if (node.body && node.body.type === import_utils9.AST_NODE_TYPES.BlockStatement) {
|
|
859
759
|
return hasJSXReturn(node.body);
|
|
860
760
|
}
|
|
861
761
|
}
|
|
862
762
|
return false;
|
|
863
763
|
}
|
|
864
764
|
function isNamedType(node) {
|
|
865
|
-
return node.type ===
|
|
765
|
+
return node.type === import_utils9.AST_NODE_TYPES.TSTypeReference;
|
|
866
766
|
}
|
|
867
767
|
function isAlreadyReadonly(node) {
|
|
868
|
-
if (node.type ===
|
|
869
|
-
if (node.typeName.type ===
|
|
768
|
+
if (node.type === import_utils9.AST_NODE_TYPES.TSTypeReference && node.typeName) {
|
|
769
|
+
if (node.typeName.type === import_utils9.AST_NODE_TYPES.Identifier && node.typeName.name === "Readonly") {
|
|
870
770
|
return true;
|
|
871
771
|
}
|
|
872
772
|
}
|
|
@@ -880,7 +780,7 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
880
780
|
return;
|
|
881
781
|
}
|
|
882
782
|
const param = node.params[0];
|
|
883
|
-
if (param.type ===
|
|
783
|
+
if (param.type === import_utils9.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
884
784
|
const { typeAnnotation } = param.typeAnnotation;
|
|
885
785
|
if (isNamedType(typeAnnotation) && !isAlreadyReadonly(typeAnnotation)) {
|
|
886
786
|
const { sourceCode } = context;
|
|
@@ -905,8 +805,8 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
905
805
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
906
806
|
|
|
907
807
|
// src/rules/enforce-service-naming.ts
|
|
908
|
-
var
|
|
909
|
-
var
|
|
808
|
+
var import_utils10 = require("@typescript-eslint/utils");
|
|
809
|
+
var createRule8 = import_utils10.ESLintUtils.RuleCreator(
|
|
910
810
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
911
811
|
);
|
|
912
812
|
var BANNED_PREFIXES = {
|
|
@@ -915,7 +815,7 @@ var BANNED_PREFIXES = {
|
|
|
915
815
|
handle: ["create", "verify"],
|
|
916
816
|
set: ["update", "save", "patch"]
|
|
917
817
|
};
|
|
918
|
-
var enforceServiceNaming =
|
|
818
|
+
var enforceServiceNaming = createRule8({
|
|
919
819
|
name: "enforce-service-naming",
|
|
920
820
|
meta: {
|
|
921
821
|
type: "suggestion",
|
|
@@ -958,12 +858,12 @@ var enforceServiceNaming = createRule9({
|
|
|
958
858
|
};
|
|
959
859
|
return {
|
|
960
860
|
ExportNamedDeclaration(node) {
|
|
961
|
-
if (node.declaration?.type ===
|
|
861
|
+
if (node.declaration?.type === import_utils10.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
962
862
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
963
863
|
}
|
|
964
|
-
if (node.declaration?.type ===
|
|
864
|
+
if (node.declaration?.type === import_utils10.AST_NODE_TYPES.VariableDeclaration) {
|
|
965
865
|
node.declaration.declarations.forEach((declarator) => {
|
|
966
|
-
if (declarator.id.type ===
|
|
866
|
+
if (declarator.id.type === import_utils10.AST_NODE_TYPES.Identifier && declarator.init?.type === import_utils10.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
967
867
|
checkExportedFunction(declarator.init, declarator.id);
|
|
968
868
|
}
|
|
969
869
|
});
|
|
@@ -975,11 +875,11 @@ var enforceServiceNaming = createRule9({
|
|
|
975
875
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
976
876
|
|
|
977
877
|
// src/rules/enforce-sorted-destructuring.ts
|
|
978
|
-
var
|
|
979
|
-
var
|
|
878
|
+
var import_utils11 = require("@typescript-eslint/utils");
|
|
879
|
+
var createRule9 = import_utils11.ESLintUtils.RuleCreator(
|
|
980
880
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
981
881
|
);
|
|
982
|
-
var enforceSortedDestructuring =
|
|
882
|
+
var enforceSortedDestructuring = createRule9({
|
|
983
883
|
name: "enforce-sorted-destructuring",
|
|
984
884
|
meta: {
|
|
985
885
|
type: "suggestion",
|
|
@@ -995,19 +895,19 @@ var enforceSortedDestructuring = createRule10({
|
|
|
995
895
|
defaultOptions: [],
|
|
996
896
|
create(context) {
|
|
997
897
|
function getPropertyName(property) {
|
|
998
|
-
if (property.type ===
|
|
898
|
+
if (property.type === import_utils11.AST_NODE_TYPES.RestElement) {
|
|
999
899
|
return null;
|
|
1000
900
|
}
|
|
1001
|
-
if (property.key.type ===
|
|
901
|
+
if (property.key.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1002
902
|
return property.key.name;
|
|
1003
903
|
}
|
|
1004
904
|
return null;
|
|
1005
905
|
}
|
|
1006
906
|
function hasDefaultValue(property) {
|
|
1007
|
-
return property.value.type ===
|
|
907
|
+
return property.value.type === import_utils11.AST_NODE_TYPES.AssignmentPattern && Boolean(property.value.right);
|
|
1008
908
|
}
|
|
1009
909
|
function checkVariableDeclarator(node) {
|
|
1010
|
-
if (node.id.type !==
|
|
910
|
+
if (node.id.type !== import_utils11.AST_NODE_TYPES.ObjectPattern) {
|
|
1011
911
|
return;
|
|
1012
912
|
}
|
|
1013
913
|
const { properties } = node.id;
|
|
@@ -1015,7 +915,7 @@ var enforceSortedDestructuring = createRule10({
|
|
|
1015
915
|
return;
|
|
1016
916
|
}
|
|
1017
917
|
const propertyInfo = properties.map((prop) => {
|
|
1018
|
-
if (prop.type ===
|
|
918
|
+
if (prop.type === import_utils11.AST_NODE_TYPES.RestElement) {
|
|
1019
919
|
return null;
|
|
1020
920
|
}
|
|
1021
921
|
return {
|
|
@@ -1054,20 +954,20 @@ var enforceSortedDestructuring = createRule10({
|
|
|
1054
954
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
1055
955
|
|
|
1056
956
|
// src/rules/enforce-type-declaration-order.ts
|
|
1057
|
-
var
|
|
1058
|
-
var
|
|
957
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
958
|
+
var createRule10 = import_utils12.ESLintUtils.RuleCreator(
|
|
1059
959
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1060
960
|
);
|
|
1061
961
|
function getTypeDeclarationName(node) {
|
|
1062
|
-
if (node.type ===
|
|
962
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSInterfaceDeclaration && node.id.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1063
963
|
return { name: node.id.name, position: node.range[0] };
|
|
1064
964
|
}
|
|
1065
|
-
if (node.type ===
|
|
965
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSTypeAliasDeclaration && node.id.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1066
966
|
return { name: node.id.name, position: node.range[0] };
|
|
1067
967
|
}
|
|
1068
968
|
return null;
|
|
1069
969
|
}
|
|
1070
|
-
var enforceTypeDeclarationOrder =
|
|
970
|
+
var enforceTypeDeclarationOrder = createRule10({
|
|
1071
971
|
name: "enforce-type-declaration-order",
|
|
1072
972
|
meta: {
|
|
1073
973
|
type: "suggestion",
|
|
@@ -1098,7 +998,7 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1098
998
|
}
|
|
1099
999
|
},
|
|
1100
1000
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
1101
|
-
if (node.typeName.type !==
|
|
1001
|
+
if (node.typeName.type !== import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1102
1002
|
return;
|
|
1103
1003
|
}
|
|
1104
1004
|
const referencedName = node.typeName.name;
|
|
@@ -1134,55 +1034,9 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1134
1034
|
});
|
|
1135
1035
|
var enforce_type_declaration_order_default = enforceTypeDeclarationOrder;
|
|
1136
1036
|
|
|
1137
|
-
// src/rules/file-kebab-case.ts
|
|
1138
|
-
var import_path3 = __toESM(require("path"), 1);
|
|
1139
|
-
var import_utils14 = require("@typescript-eslint/utils");
|
|
1140
|
-
var createRule12 = import_utils14.ESLintUtils.RuleCreator(
|
|
1141
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1142
|
-
);
|
|
1143
|
-
var isKebabCase = (str) => {
|
|
1144
|
-
if (/\.(config|rc|setup|spec|test)$/.test(str) || /^[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*$/.test(str)) {
|
|
1145
|
-
return /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)*$/.test(str);
|
|
1146
|
-
}
|
|
1147
|
-
return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(str);
|
|
1148
|
-
};
|
|
1149
|
-
var fileKebabCase = createRule12({
|
|
1150
|
-
name: "file-kebab-case",
|
|
1151
|
-
meta: {
|
|
1152
|
-
type: "problem",
|
|
1153
|
-
docs: {
|
|
1154
|
-
description: "Enforce kebab-case filenames for .ts and .js files"
|
|
1155
|
-
},
|
|
1156
|
-
messages: {
|
|
1157
|
-
fileKebabCase: "File names must be kebab-case"
|
|
1158
|
-
},
|
|
1159
|
-
schema: []
|
|
1160
|
-
},
|
|
1161
|
-
defaultOptions: [],
|
|
1162
|
-
create(context) {
|
|
1163
|
-
return {
|
|
1164
|
-
Program() {
|
|
1165
|
-
const { filename } = context;
|
|
1166
|
-
const ext = import_path3.default.extname(filename);
|
|
1167
|
-
if (ext !== ".ts" && ext !== ".js") {
|
|
1168
|
-
return;
|
|
1169
|
-
}
|
|
1170
|
-
const basename2 = import_path3.default.basename(filename, ext);
|
|
1171
|
-
if (!isKebabCase(basename2)) {
|
|
1172
|
-
context.report({
|
|
1173
|
-
loc: { line: 1, column: 0 },
|
|
1174
|
-
messageId: "fileKebabCase"
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1181
|
-
var file_kebab_case_default = fileKebabCase;
|
|
1182
|
-
|
|
1183
1037
|
// src/rules/index-export-only.ts
|
|
1184
|
-
var
|
|
1185
|
-
var
|
|
1038
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
1039
|
+
var createRule11 = import_utils13.ESLintUtils.RuleCreator(
|
|
1186
1040
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1187
1041
|
);
|
|
1188
1042
|
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
@@ -1190,26 +1044,26 @@ var isAllowedExportNamed = (node) => {
|
|
|
1190
1044
|
if (!node.declaration) {
|
|
1191
1045
|
return true;
|
|
1192
1046
|
}
|
|
1193
|
-
return node.declaration.type ===
|
|
1047
|
+
return node.declaration.type === import_utils13.AST_NODE_TYPES.TSTypeAliasDeclaration || node.declaration.type === import_utils13.AST_NODE_TYPES.TSInterfaceDeclaration;
|
|
1194
1048
|
};
|
|
1195
|
-
var isAllowedExportDefault = (node) => node.declaration.type ===
|
|
1049
|
+
var isAllowedExportDefault = (node) => node.declaration.type === import_utils13.AST_NODE_TYPES.Identifier;
|
|
1196
1050
|
var isAllowedTopLevel = (node) => {
|
|
1197
1051
|
switch (node.type) {
|
|
1198
|
-
case
|
|
1199
|
-
case
|
|
1200
|
-
case
|
|
1201
|
-
case
|
|
1202
|
-
case
|
|
1052
|
+
case import_utils13.AST_NODE_TYPES.ImportDeclaration:
|
|
1053
|
+
case import_utils13.AST_NODE_TYPES.ExportAllDeclaration:
|
|
1054
|
+
case import_utils13.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
1055
|
+
case import_utils13.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
1056
|
+
case import_utils13.AST_NODE_TYPES.TSImportEqualsDeclaration:
|
|
1203
1057
|
return true;
|
|
1204
|
-
case
|
|
1058
|
+
case import_utils13.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
1205
1059
|
return isAllowedExportNamed(node);
|
|
1206
|
-
case
|
|
1060
|
+
case import_utils13.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
1207
1061
|
return isAllowedExportDefault(node);
|
|
1208
1062
|
default:
|
|
1209
1063
|
return false;
|
|
1210
1064
|
}
|
|
1211
1065
|
};
|
|
1212
|
-
var indexExportOnly =
|
|
1066
|
+
var indexExportOnly = createRule11({
|
|
1213
1067
|
name: "index-export-only",
|
|
1214
1068
|
meta: {
|
|
1215
1069
|
type: "suggestion",
|
|
@@ -1243,11 +1097,11 @@ var indexExportOnly = createRule13({
|
|
|
1243
1097
|
var index_export_only_default = indexExportOnly;
|
|
1244
1098
|
|
|
1245
1099
|
// src/rules/jsx-newline-between-elements.ts
|
|
1246
|
-
var
|
|
1247
|
-
var
|
|
1100
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
1101
|
+
var createRule12 = import_utils15.ESLintUtils.RuleCreator(
|
|
1248
1102
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1249
1103
|
);
|
|
1250
|
-
var jsxNewlineBetweenElements =
|
|
1104
|
+
var jsxNewlineBetweenElements = createRule12({
|
|
1251
1105
|
name: "jsx-newline-between-elements",
|
|
1252
1106
|
meta: {
|
|
1253
1107
|
type: "layout",
|
|
@@ -1265,7 +1119,7 @@ var jsxNewlineBetweenElements = createRule14({
|
|
|
1265
1119
|
create(context) {
|
|
1266
1120
|
const { sourceCode } = context;
|
|
1267
1121
|
function isSignificantJSXChild(node) {
|
|
1268
|
-
return node.type ===
|
|
1122
|
+
return node.type === import_utils15.AST_NODE_TYPES.JSXElement || node.type === import_utils15.AST_NODE_TYPES.JSXFragment || node.type === import_utils15.AST_NODE_TYPES.JSXExpressionContainer;
|
|
1269
1123
|
}
|
|
1270
1124
|
function isMultiLine(node) {
|
|
1271
1125
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1315,11 +1169,11 @@ var jsxNewlineBetweenElements = createRule14({
|
|
|
1315
1169
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1316
1170
|
|
|
1317
1171
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1318
|
-
var
|
|
1319
|
-
var
|
|
1172
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
1173
|
+
var createRule13 = import_utils16.ESLintUtils.RuleCreator(
|
|
1320
1174
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1321
1175
|
);
|
|
1322
|
-
var jsxNoInlineObjectProp =
|
|
1176
|
+
var jsxNoInlineObjectProp = createRule13({
|
|
1323
1177
|
name: "jsx-no-inline-object-prop",
|
|
1324
1178
|
meta: {
|
|
1325
1179
|
type: "suggestion",
|
|
@@ -1335,7 +1189,7 @@ var jsxNoInlineObjectProp = createRule15({
|
|
|
1335
1189
|
create(context) {
|
|
1336
1190
|
return {
|
|
1337
1191
|
JSXAttribute(node) {
|
|
1338
|
-
if (node.value?.type ===
|
|
1192
|
+
if (node.value?.type === import_utils16.AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === import_utils16.AST_NODE_TYPES.ObjectExpression) {
|
|
1339
1193
|
context.report({
|
|
1340
1194
|
node: node.value,
|
|
1341
1195
|
messageId: "noInlineObject"
|
|
@@ -1348,17 +1202,17 @@ var jsxNoInlineObjectProp = createRule15({
|
|
|
1348
1202
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1349
1203
|
|
|
1350
1204
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1351
|
-
var
|
|
1352
|
-
var
|
|
1205
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
1206
|
+
var createRule14 = import_utils17.ESLintUtils.RuleCreator(
|
|
1353
1207
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1354
1208
|
);
|
|
1355
1209
|
function isJSXElementOrFragment(node) {
|
|
1356
|
-
return node.type ===
|
|
1210
|
+
return node.type === import_utils17.AST_NODE_TYPES.JSXElement || node.type === import_utils17.AST_NODE_TYPES.JSXFragment;
|
|
1357
1211
|
}
|
|
1358
1212
|
function isSingleLine(node) {
|
|
1359
1213
|
return node.loc.start.line === node.loc.end.line;
|
|
1360
1214
|
}
|
|
1361
|
-
var jsxNoNewlineSingleLineElements =
|
|
1215
|
+
var jsxNoNewlineSingleLineElements = createRule14({
|
|
1362
1216
|
name: "jsx-no-newline-single-line-elements",
|
|
1363
1217
|
meta: {
|
|
1364
1218
|
type: "layout",
|
|
@@ -1376,7 +1230,7 @@ var jsxNoNewlineSingleLineElements = createRule16({
|
|
|
1376
1230
|
const { sourceCode } = context;
|
|
1377
1231
|
function checkSiblings(children) {
|
|
1378
1232
|
const nonWhitespace = children.filter(
|
|
1379
|
-
(child) => !(child.type ===
|
|
1233
|
+
(child) => !(child.type === import_utils17.AST_NODE_TYPES.JSXText && child.value.trim() === "")
|
|
1380
1234
|
);
|
|
1381
1235
|
nonWhitespace.forEach((next, index) => {
|
|
1382
1236
|
if (index === 0) {
|
|
@@ -1427,11 +1281,11 @@ ${indent}`);
|
|
|
1427
1281
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1428
1282
|
|
|
1429
1283
|
// src/rules/jsx-no-non-component-function.ts
|
|
1430
|
-
var
|
|
1431
|
-
var
|
|
1284
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
1285
|
+
var createRule15 = import_utils18.ESLintUtils.RuleCreator(
|
|
1432
1286
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1433
1287
|
);
|
|
1434
|
-
var jsxNoNonComponentFunction =
|
|
1288
|
+
var jsxNoNonComponentFunction = createRule15({
|
|
1435
1289
|
name: "jsx-no-non-component-function",
|
|
1436
1290
|
meta: {
|
|
1437
1291
|
type: "problem",
|
|
@@ -1451,13 +1305,13 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1451
1305
|
return {};
|
|
1452
1306
|
}
|
|
1453
1307
|
function isReactComponent2(node) {
|
|
1454
|
-
const functionName = node.type ===
|
|
1308
|
+
const functionName = node.type === import_utils18.AST_NODE_TYPES.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1455
1309
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1456
1310
|
return true;
|
|
1457
1311
|
}
|
|
1458
1312
|
if (node.returnType?.typeAnnotation) {
|
|
1459
1313
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1460
|
-
if (returnTypeNode.type ===
|
|
1314
|
+
if (returnTypeNode.type === import_utils18.AST_NODE_TYPES.TSTypeReference && returnTypeNode.typeName.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1461
1315
|
const typeName = returnTypeNode.typeName.name;
|
|
1462
1316
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1463
1317
|
return true;
|
|
@@ -1474,13 +1328,13 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1474
1328
|
if (!parent) {
|
|
1475
1329
|
return;
|
|
1476
1330
|
}
|
|
1477
|
-
if (parent.type ===
|
|
1331
|
+
if (parent.type === import_utils18.AST_NODE_TYPES.ExportDefaultDeclaration || parent.type === import_utils18.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1478
1332
|
return;
|
|
1479
1333
|
}
|
|
1480
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1334
|
+
if (declaratorNode?.parent?.parent?.type === import_utils18.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1481
1335
|
return;
|
|
1482
1336
|
}
|
|
1483
|
-
if (declaratorNode?.id.type ===
|
|
1337
|
+
if (declaratorNode?.id.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1484
1338
|
const varName = declaratorNode.id.name;
|
|
1485
1339
|
if (/^[A-Z]/.test(varName)) {
|
|
1486
1340
|
return;
|
|
@@ -1505,20 +1359,20 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1505
1359
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1506
1360
|
|
|
1507
1361
|
// src/rules/jsx-no-ternary-null.ts
|
|
1508
|
-
var
|
|
1509
|
-
var
|
|
1362
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
1363
|
+
var createRule16 = import_utils20.ESLintUtils.RuleCreator(
|
|
1510
1364
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1511
1365
|
);
|
|
1512
1366
|
function isNullOrUndefined(node) {
|
|
1513
|
-
if (node.type ===
|
|
1367
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Literal && node.value === null) {
|
|
1514
1368
|
return true;
|
|
1515
1369
|
}
|
|
1516
|
-
if (node.type ===
|
|
1370
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Identifier && node.name === "undefined") {
|
|
1517
1371
|
return true;
|
|
1518
1372
|
}
|
|
1519
1373
|
return false;
|
|
1520
1374
|
}
|
|
1521
|
-
var jsxNoTernaryNull =
|
|
1375
|
+
var jsxNoTernaryNull = createRule16({
|
|
1522
1376
|
name: "jsx-no-ternary-null",
|
|
1523
1377
|
meta: {
|
|
1524
1378
|
type: "suggestion",
|
|
@@ -1536,7 +1390,7 @@ var jsxNoTernaryNull = createRule18({
|
|
|
1536
1390
|
return {
|
|
1537
1391
|
JSXExpressionContainer(node) {
|
|
1538
1392
|
const { expression } = node;
|
|
1539
|
-
if (expression.type !==
|
|
1393
|
+
if (expression.type !== import_utils20.AST_NODE_TYPES.ConditionalExpression) {
|
|
1540
1394
|
return;
|
|
1541
1395
|
}
|
|
1542
1396
|
const { test, consequent, alternate } = expression;
|
|
@@ -1568,11 +1422,11 @@ var jsxNoTernaryNull = createRule18({
|
|
|
1568
1422
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1569
1423
|
|
|
1570
1424
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1571
|
-
var
|
|
1572
|
-
var
|
|
1425
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
1426
|
+
var createRule17 = import_utils21.ESLintUtils.RuleCreator(
|
|
1573
1427
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1574
1428
|
);
|
|
1575
|
-
var jsxNoVariableInCallback =
|
|
1429
|
+
var jsxNoVariableInCallback = createRule17({
|
|
1576
1430
|
name: "jsx-no-variable-in-callback",
|
|
1577
1431
|
meta: {
|
|
1578
1432
|
type: "suggestion",
|
|
@@ -1589,7 +1443,7 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1589
1443
|
function isInsideJSX(node) {
|
|
1590
1444
|
let current = node.parent;
|
|
1591
1445
|
while (current) {
|
|
1592
|
-
if (current.type ===
|
|
1446
|
+
if (current.type === import_utils21.AST_NODE_TYPES.JSXElement || current.type === import_utils21.AST_NODE_TYPES.JSXFragment) {
|
|
1593
1447
|
return true;
|
|
1594
1448
|
}
|
|
1595
1449
|
current = current.parent;
|
|
@@ -1603,11 +1457,11 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1603
1457
|
if (!isInsideJSX(node)) {
|
|
1604
1458
|
return false;
|
|
1605
1459
|
}
|
|
1606
|
-
if (node.parent.type ===
|
|
1460
|
+
if (node.parent.type === import_utils21.AST_NODE_TYPES.CallExpression || node.parent.type === import_utils21.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1607
1461
|
return true;
|
|
1608
1462
|
}
|
|
1609
|
-
if (node.parent.type ===
|
|
1610
|
-
if (node.parent.parent.type ===
|
|
1463
|
+
if (node.parent.type === import_utils21.AST_NODE_TYPES.ArrayExpression && node.parent.parent) {
|
|
1464
|
+
if (node.parent.parent.type === import_utils21.AST_NODE_TYPES.CallExpression || node.parent.parent.type === import_utils21.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1611
1465
|
return true;
|
|
1612
1466
|
}
|
|
1613
1467
|
}
|
|
@@ -1618,11 +1472,11 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1618
1472
|
return;
|
|
1619
1473
|
}
|
|
1620
1474
|
const { body } = node;
|
|
1621
|
-
if (body.type !==
|
|
1475
|
+
if (body.type !== import_utils21.AST_NODE_TYPES.BlockStatement) {
|
|
1622
1476
|
return;
|
|
1623
1477
|
}
|
|
1624
1478
|
body.body.forEach((statement) => {
|
|
1625
|
-
if (statement.type ===
|
|
1479
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.VariableDeclaration) {
|
|
1626
1480
|
context.report({
|
|
1627
1481
|
node: statement,
|
|
1628
1482
|
messageId: "noVariableInCallback"
|
|
@@ -1638,53 +1492,12 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1638
1492
|
});
|
|
1639
1493
|
var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
1640
1494
|
|
|
1641
|
-
// src/rules/jsx-pascal-case.ts
|
|
1642
|
-
var import_path4 = __toESM(require("path"), 1);
|
|
1643
|
-
var import_utils24 = require("@typescript-eslint/utils");
|
|
1644
|
-
var createRule20 = import_utils24.ESLintUtils.RuleCreator(
|
|
1645
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1646
|
-
);
|
|
1647
|
-
var isPascalCase = (str) => /^[A-Z][a-zA-Z0-9]*$/.test(str) && !/^[A-Z]+$/.test(str);
|
|
1648
|
-
var jsxPascalCase = createRule20({
|
|
1649
|
-
name: "jsx-pascal-case",
|
|
1650
|
-
meta: {
|
|
1651
|
-
type: "problem",
|
|
1652
|
-
docs: {
|
|
1653
|
-
description: "Enforce PascalCase filenames for .jsx and .tsx files"
|
|
1654
|
-
},
|
|
1655
|
-
messages: {
|
|
1656
|
-
jsxPascalCase: "JSX/TSX file names must be PascalCase"
|
|
1657
|
-
},
|
|
1658
|
-
schema: []
|
|
1659
|
-
},
|
|
1660
|
-
defaultOptions: [],
|
|
1661
|
-
create(context) {
|
|
1662
|
-
return {
|
|
1663
|
-
Program() {
|
|
1664
|
-
const { filename } = context;
|
|
1665
|
-
const ext = import_path4.default.extname(filename);
|
|
1666
|
-
if (ext !== ".jsx" && ext !== ".tsx") {
|
|
1667
|
-
return;
|
|
1668
|
-
}
|
|
1669
|
-
const basename2 = import_path4.default.basename(filename, ext);
|
|
1670
|
-
if (!isPascalCase(basename2)) {
|
|
1671
|
-
context.report({
|
|
1672
|
-
loc: { line: 1, column: 0 },
|
|
1673
|
-
messageId: "jsxPascalCase"
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
};
|
|
1678
|
-
}
|
|
1679
|
-
});
|
|
1680
|
-
var jsx_pascal_case_default = jsxPascalCase;
|
|
1681
|
-
|
|
1682
1495
|
// src/rules/jsx-require-suspense.ts
|
|
1683
|
-
var
|
|
1684
|
-
var
|
|
1496
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
1497
|
+
var createRule18 = import_utils22.ESLintUtils.RuleCreator(
|
|
1685
1498
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1686
1499
|
);
|
|
1687
|
-
var jsxRequireSuspense =
|
|
1500
|
+
var jsxRequireSuspense = createRule18({
|
|
1688
1501
|
name: "jsx-require-suspense",
|
|
1689
1502
|
meta: {
|
|
1690
1503
|
type: "problem",
|
|
@@ -1702,7 +1515,7 @@ var jsxRequireSuspense = createRule21({
|
|
|
1702
1515
|
const isInsideSuspense = (node) => {
|
|
1703
1516
|
let current = node.parent;
|
|
1704
1517
|
while (current) {
|
|
1705
|
-
if (current.type ===
|
|
1518
|
+
if (current.type === import_utils22.AST_NODE_TYPES.JSXElement && current.openingElement.name.type === import_utils22.AST_NODE_TYPES.JSXIdentifier && current.openingElement.name.name === "Suspense") {
|
|
1706
1519
|
return true;
|
|
1707
1520
|
}
|
|
1708
1521
|
current = current.parent;
|
|
@@ -1711,16 +1524,16 @@ var jsxRequireSuspense = createRule21({
|
|
|
1711
1524
|
};
|
|
1712
1525
|
return {
|
|
1713
1526
|
VariableDeclarator(node) {
|
|
1714
|
-
if (node.id.type ===
|
|
1527
|
+
if (node.id.type === import_utils22.AST_NODE_TYPES.Identifier && node.init?.type === import_utils22.AST_NODE_TYPES.CallExpression) {
|
|
1715
1528
|
const { callee } = node.init;
|
|
1716
|
-
const isLazyCall = callee.type ===
|
|
1529
|
+
const isLazyCall = callee.type === import_utils22.AST_NODE_TYPES.Identifier && callee.name === "lazy" || callee.type === import_utils22.AST_NODE_TYPES.MemberExpression && callee.object.type === import_utils22.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === import_utils22.AST_NODE_TYPES.Identifier && callee.property.name === "lazy";
|
|
1717
1530
|
if (isLazyCall) {
|
|
1718
1531
|
lazyComponents.add(node.id.name);
|
|
1719
1532
|
}
|
|
1720
1533
|
}
|
|
1721
1534
|
},
|
|
1722
1535
|
JSXOpeningElement(node) {
|
|
1723
|
-
if (node.name.type ===
|
|
1536
|
+
if (node.name.type === import_utils22.AST_NODE_TYPES.JSXIdentifier) {
|
|
1724
1537
|
const componentName = node.name.name;
|
|
1725
1538
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1726
1539
|
context.report({
|
|
@@ -1739,11 +1552,11 @@ var jsxRequireSuspense = createRule21({
|
|
|
1739
1552
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1740
1553
|
|
|
1741
1554
|
// src/rules/jsx-simple-props.ts
|
|
1742
|
-
var
|
|
1743
|
-
var
|
|
1555
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
1556
|
+
var createRule19 = import_utils23.ESLintUtils.RuleCreator(
|
|
1744
1557
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1745
1558
|
);
|
|
1746
|
-
var jsxSimpleProps =
|
|
1559
|
+
var jsxSimpleProps = createRule19({
|
|
1747
1560
|
name: "jsx-simple-props",
|
|
1748
1561
|
meta: {
|
|
1749
1562
|
type: "suggestion",
|
|
@@ -1758,25 +1571,25 @@ var jsxSimpleProps = createRule22({
|
|
|
1758
1571
|
defaultOptions: [],
|
|
1759
1572
|
create(context) {
|
|
1760
1573
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1574
|
+
import_utils23.AST_NODE_TYPES.Identifier,
|
|
1575
|
+
import_utils23.AST_NODE_TYPES.Literal,
|
|
1576
|
+
import_utils23.AST_NODE_TYPES.JSXElement,
|
|
1577
|
+
import_utils23.AST_NODE_TYPES.JSXFragment,
|
|
1578
|
+
import_utils23.AST_NODE_TYPES.MemberExpression,
|
|
1579
|
+
import_utils23.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
1580
|
+
import_utils23.AST_NODE_TYPES.FunctionExpression
|
|
1768
1581
|
]);
|
|
1769
1582
|
return {
|
|
1770
1583
|
JSXAttribute(node) {
|
|
1771
1584
|
if (!node.value) {
|
|
1772
1585
|
return;
|
|
1773
1586
|
}
|
|
1774
|
-
if (node.value.type ===
|
|
1587
|
+
if (node.value.type === import_utils23.AST_NODE_TYPES.Literal) {
|
|
1775
1588
|
return;
|
|
1776
1589
|
}
|
|
1777
|
-
if (node.value.type ===
|
|
1590
|
+
if (node.value.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1778
1591
|
const { expression } = node.value;
|
|
1779
|
-
if (expression.type ===
|
|
1592
|
+
if (expression.type === import_utils23.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1780
1593
|
return;
|
|
1781
1594
|
}
|
|
1782
1595
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1793,8 +1606,8 @@ var jsxSimpleProps = createRule22({
|
|
|
1793
1606
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1794
1607
|
|
|
1795
1608
|
// src/rules/jsx-sort-props.ts
|
|
1796
|
-
var
|
|
1797
|
-
var
|
|
1609
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
1610
|
+
var createRule20 = import_utils24.ESLintUtils.RuleCreator(
|
|
1798
1611
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1799
1612
|
);
|
|
1800
1613
|
var TYPE_GROUP = {
|
|
@@ -1808,15 +1621,15 @@ var TYPE_GROUP = {
|
|
|
1808
1621
|
SHORTHAND: 8
|
|
1809
1622
|
};
|
|
1810
1623
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1811
|
-
[
|
|
1812
|
-
[
|
|
1813
|
-
[
|
|
1814
|
-
[
|
|
1815
|
-
[
|
|
1816
|
-
[
|
|
1624
|
+
[import_utils24.AST_NODE_TYPES.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1625
|
+
[import_utils24.AST_NODE_TYPES.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1626
|
+
[import_utils24.AST_NODE_TYPES.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1627
|
+
[import_utils24.AST_NODE_TYPES.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1628
|
+
[import_utils24.AST_NODE_TYPES.JSXElement, TYPE_GROUP.JSX],
|
|
1629
|
+
[import_utils24.AST_NODE_TYPES.JSXFragment, TYPE_GROUP.JSX]
|
|
1817
1630
|
]);
|
|
1818
1631
|
function isHyphenatedName(node) {
|
|
1819
|
-
return node.name.type ===
|
|
1632
|
+
return node.name.type === import_utils24.AST_NODE_TYPES.JSXIdentifier && node.name.name.includes("-");
|
|
1820
1633
|
}
|
|
1821
1634
|
function getStringGroup(node) {
|
|
1822
1635
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1828,13 +1641,13 @@ function getLiteralValueGroup(value) {
|
|
|
1828
1641
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1829
1642
|
}
|
|
1830
1643
|
function getExpressionGroup(expression) {
|
|
1831
|
-
if (expression.type ===
|
|
1644
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.Literal) {
|
|
1832
1645
|
return getLiteralValueGroup(expression.value);
|
|
1833
1646
|
}
|
|
1834
|
-
if (expression.type ===
|
|
1647
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.TemplateLiteral) {
|
|
1835
1648
|
return null;
|
|
1836
1649
|
}
|
|
1837
|
-
if (expression.type ===
|
|
1650
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.Identifier && expression.name === "undefined") {
|
|
1838
1651
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1839
1652
|
}
|
|
1840
1653
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1843,17 +1656,17 @@ function getTypeGroup(node) {
|
|
|
1843
1656
|
if (node.value === null) {
|
|
1844
1657
|
return TYPE_GROUP.SHORTHAND;
|
|
1845
1658
|
}
|
|
1846
|
-
if (node.value.type ===
|
|
1659
|
+
if (node.value.type === import_utils24.AST_NODE_TYPES.Literal) {
|
|
1847
1660
|
if (typeof node.value.value === "string") {
|
|
1848
1661
|
return getStringGroup(node);
|
|
1849
1662
|
}
|
|
1850
1663
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1851
1664
|
}
|
|
1852
|
-
if (node.value.type !==
|
|
1665
|
+
if (node.value.type !== import_utils24.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1853
1666
|
return null;
|
|
1854
1667
|
}
|
|
1855
1668
|
const { expression } = node.value;
|
|
1856
|
-
if (expression.type ===
|
|
1669
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1857
1670
|
return null;
|
|
1858
1671
|
}
|
|
1859
1672
|
const group = getExpressionGroup(expression);
|
|
@@ -1865,7 +1678,7 @@ function getTypeGroup(node) {
|
|
|
1865
1678
|
function hasUnsortedProps(attributes) {
|
|
1866
1679
|
let lastGroup = 0;
|
|
1867
1680
|
return attributes.some((attribute) => {
|
|
1868
|
-
if (attribute.type ===
|
|
1681
|
+
if (attribute.type === import_utils24.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1869
1682
|
lastGroup = 0;
|
|
1870
1683
|
return false;
|
|
1871
1684
|
}
|
|
@@ -1889,7 +1702,7 @@ function getSegments(attributes) {
|
|
|
1889
1702
|
const result = [];
|
|
1890
1703
|
let current = [];
|
|
1891
1704
|
attributes.forEach((attr) => {
|
|
1892
|
-
if (attr.type ===
|
|
1705
|
+
if (attr.type === import_utils24.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1893
1706
|
if (current.length > 0) {
|
|
1894
1707
|
result.push(current);
|
|
1895
1708
|
current = [];
|
|
@@ -1903,7 +1716,7 @@ function getSegments(attributes) {
|
|
|
1903
1716
|
}
|
|
1904
1717
|
return result;
|
|
1905
1718
|
}
|
|
1906
|
-
var jsxSortProps =
|
|
1719
|
+
var jsxSortProps = createRule20({
|
|
1907
1720
|
name: "jsx-sort-props",
|
|
1908
1721
|
meta: {
|
|
1909
1722
|
type: "suggestion",
|
|
@@ -1938,11 +1751,11 @@ var jsxSortProps = createRule23({
|
|
|
1938
1751
|
var jsx_sort_props_default = jsxSortProps;
|
|
1939
1752
|
|
|
1940
1753
|
// src/rules/jsx-spread-props-last.ts
|
|
1941
|
-
var
|
|
1942
|
-
var
|
|
1754
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
1755
|
+
var createRule21 = import_utils25.ESLintUtils.RuleCreator(
|
|
1943
1756
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1944
1757
|
);
|
|
1945
|
-
var jsxSpreadPropsLast =
|
|
1758
|
+
var jsxSpreadPropsLast = createRule21({
|
|
1946
1759
|
name: "jsx-spread-props-last",
|
|
1947
1760
|
meta: {
|
|
1948
1761
|
type: "suggestion",
|
|
@@ -1961,12 +1774,12 @@ var jsxSpreadPropsLast = createRule24({
|
|
|
1961
1774
|
const { attributes } = node;
|
|
1962
1775
|
let lastNonSpreadIndex = -1;
|
|
1963
1776
|
attributes.forEach((attribute, index) => {
|
|
1964
|
-
if (attribute.type !==
|
|
1777
|
+
if (attribute.type !== import_utils25.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1965
1778
|
lastNonSpreadIndex = index;
|
|
1966
1779
|
}
|
|
1967
1780
|
});
|
|
1968
1781
|
attributes.forEach((attribute, index) => {
|
|
1969
|
-
if (attribute.type ===
|
|
1782
|
+
if (attribute.type === import_utils25.AST_NODE_TYPES.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1970
1783
|
context.report({
|
|
1971
1784
|
node: attribute,
|
|
1972
1785
|
messageId: "spreadNotLast"
|
|
@@ -1980,12 +1793,12 @@ var jsxSpreadPropsLast = createRule24({
|
|
|
1980
1793
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1981
1794
|
|
|
1982
1795
|
// src/rules/newline-after-multiline-block.ts
|
|
1983
|
-
var
|
|
1984
|
-
var
|
|
1796
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
1797
|
+
var createRule22 = import_utils26.ESLintUtils.RuleCreator(
|
|
1985
1798
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1986
1799
|
);
|
|
1987
1800
|
function isImportDeclaration(node) {
|
|
1988
|
-
return node.type ===
|
|
1801
|
+
return node.type === import_utils26.AST_NODE_TYPES.ImportDeclaration;
|
|
1989
1802
|
}
|
|
1990
1803
|
function checkStatements(statements, context) {
|
|
1991
1804
|
const { sourceCode } = context;
|
|
@@ -2020,7 +1833,7 @@ function checkStatements(statements, context) {
|
|
|
2020
1833
|
}
|
|
2021
1834
|
});
|
|
2022
1835
|
}
|
|
2023
|
-
var newlineAfterMultilineBlock =
|
|
1836
|
+
var newlineAfterMultilineBlock = createRule22({
|
|
2024
1837
|
name: "newline-after-multiline-block",
|
|
2025
1838
|
meta: {
|
|
2026
1839
|
type: "layout",
|
|
@@ -2048,11 +1861,11 @@ var newlineAfterMultilineBlock = createRule25({
|
|
|
2048
1861
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
2049
1862
|
|
|
2050
1863
|
// src/rules/newline-before-return.ts
|
|
2051
|
-
var
|
|
2052
|
-
var
|
|
1864
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
1865
|
+
var createRule23 = import_utils27.ESLintUtils.RuleCreator(
|
|
2053
1866
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2054
1867
|
);
|
|
2055
|
-
var newlineBeforeReturn =
|
|
1868
|
+
var newlineBeforeReturn = createRule23({
|
|
2056
1869
|
name: "newline-before-return",
|
|
2057
1870
|
meta: {
|
|
2058
1871
|
type: "layout",
|
|
@@ -2070,7 +1883,7 @@ var newlineBeforeReturn = createRule26({
|
|
|
2070
1883
|
const { sourceCode } = context;
|
|
2071
1884
|
function checkReturnStatement(node) {
|
|
2072
1885
|
const { parent } = node;
|
|
2073
|
-
if (!parent || parent.type !==
|
|
1886
|
+
if (!parent || parent.type !== import_utils27.AST_NODE_TYPES.BlockStatement) {
|
|
2074
1887
|
return;
|
|
2075
1888
|
}
|
|
2076
1889
|
const { body: statements } = parent;
|
|
@@ -2106,61 +1919,12 @@ var newlineBeforeReturn = createRule26({
|
|
|
2106
1919
|
});
|
|
2107
1920
|
var newline_before_return_default = newlineBeforeReturn;
|
|
2108
1921
|
|
|
2109
|
-
// src/rules/nextjs-require-public-env.ts
|
|
2110
|
-
var import_utils31 = require("@typescript-eslint/utils");
|
|
2111
|
-
var createRule27 = import_utils31.ESLintUtils.RuleCreator(
|
|
2112
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2113
|
-
);
|
|
2114
|
-
var nextjsRequirePublicEnv = createRule27({
|
|
2115
|
-
name: "nextjs-require-public-env",
|
|
2116
|
-
meta: {
|
|
2117
|
-
type: "problem",
|
|
2118
|
-
docs: {
|
|
2119
|
-
description: "Require NEXT_PUBLIC_ prefix for environment variables in client components"
|
|
2120
|
-
},
|
|
2121
|
-
messages: {
|
|
2122
|
-
requirePublicPrefix: "Environment variable '{{ name }}' must use NEXT_PUBLIC_ prefix in client components. Use 'NEXT_PUBLIC_{{ name }}' instead."
|
|
2123
|
-
},
|
|
2124
|
-
schema: []
|
|
2125
|
-
},
|
|
2126
|
-
defaultOptions: [],
|
|
2127
|
-
create(context) {
|
|
2128
|
-
let isClientComponent = false;
|
|
2129
|
-
return {
|
|
2130
|
-
Program(node) {
|
|
2131
|
-
const firstStatement = node.body[0];
|
|
2132
|
-
if (firstStatement?.type === import_utils31.AST_NODE_TYPES.ExpressionStatement && firstStatement.expression.type === import_utils31.AST_NODE_TYPES.Literal && firstStatement.expression.value === "use client") {
|
|
2133
|
-
isClientComponent = true;
|
|
2134
|
-
}
|
|
2135
|
-
},
|
|
2136
|
-
MemberExpression(node) {
|
|
2137
|
-
if (!isClientComponent) {
|
|
2138
|
-
return;
|
|
2139
|
-
}
|
|
2140
|
-
if (node.object.type === import_utils31.AST_NODE_TYPES.MemberExpression && node.object.object.type === import_utils31.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === import_utils31.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === import_utils31.AST_NODE_TYPES.Identifier) {
|
|
2141
|
-
const envVarName = node.property.name;
|
|
2142
|
-
if (!envVarName.startsWith("NEXT_PUBLIC_") && envVarName !== "NODE_ENV") {
|
|
2143
|
-
context.report({
|
|
2144
|
-
node: node.property,
|
|
2145
|
-
messageId: "requirePublicPrefix",
|
|
2146
|
-
data: {
|
|
2147
|
-
name: envVarName
|
|
2148
|
-
}
|
|
2149
|
-
});
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
};
|
|
2154
|
-
}
|
|
2155
|
-
});
|
|
2156
|
-
var nextjs_require_public_env_default = nextjsRequirePublicEnv;
|
|
2157
|
-
|
|
2158
1922
|
// src/rules/no-complex-inline-return.ts
|
|
2159
|
-
var
|
|
2160
|
-
var
|
|
1923
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
1924
|
+
var createRule24 = import_utils28.ESLintUtils.RuleCreator(
|
|
2161
1925
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2162
1926
|
);
|
|
2163
|
-
var noComplexInlineReturn =
|
|
1927
|
+
var noComplexInlineReturn = createRule24({
|
|
2164
1928
|
name: "no-complex-inline-return",
|
|
2165
1929
|
meta: {
|
|
2166
1930
|
type: "suggestion",
|
|
@@ -2176,13 +1940,13 @@ var noComplexInlineReturn = createRule28({
|
|
|
2176
1940
|
create(context) {
|
|
2177
1941
|
const isComplexExpression = (node) => {
|
|
2178
1942
|
if (!node) return false;
|
|
2179
|
-
if (node.type ===
|
|
1943
|
+
if (node.type === import_utils28.AST_NODE_TYPES.ConditionalExpression) {
|
|
2180
1944
|
return true;
|
|
2181
1945
|
}
|
|
2182
|
-
if (node.type ===
|
|
1946
|
+
if (node.type === import_utils28.AST_NODE_TYPES.LogicalExpression) {
|
|
2183
1947
|
return true;
|
|
2184
1948
|
}
|
|
2185
|
-
if (node.type ===
|
|
1949
|
+
if (node.type === import_utils28.AST_NODE_TYPES.NewExpression) {
|
|
2186
1950
|
return true;
|
|
2187
1951
|
}
|
|
2188
1952
|
return false;
|
|
@@ -2202,11 +1966,11 @@ var noComplexInlineReturn = createRule28({
|
|
|
2202
1966
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
2203
1967
|
|
|
2204
1968
|
// src/rules/no-direct-date.ts
|
|
2205
|
-
var
|
|
2206
|
-
var
|
|
1969
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
1970
|
+
var createRule25 = import_utils29.ESLintUtils.RuleCreator(
|
|
2207
1971
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2208
1972
|
);
|
|
2209
|
-
var noDirectDate =
|
|
1973
|
+
var noDirectDate = createRule25({
|
|
2210
1974
|
name: "no-direct-date",
|
|
2211
1975
|
meta: {
|
|
2212
1976
|
type: "problem",
|
|
@@ -2224,7 +1988,7 @@ var noDirectDate = createRule29({
|
|
|
2224
1988
|
create(context) {
|
|
2225
1989
|
return {
|
|
2226
1990
|
NewExpression(node) {
|
|
2227
|
-
if (node.callee.type ===
|
|
1991
|
+
if (node.callee.type === import_utils29.AST_NODE_TYPES.Identifier && node.callee.name === "Date") {
|
|
2228
1992
|
context.report({
|
|
2229
1993
|
node,
|
|
2230
1994
|
messageId: "noNewDate"
|
|
@@ -2232,7 +1996,7 @@ var noDirectDate = createRule29({
|
|
|
2232
1996
|
}
|
|
2233
1997
|
},
|
|
2234
1998
|
CallExpression(node) {
|
|
2235
|
-
if (node.callee.type ===
|
|
1999
|
+
if (node.callee.type === import_utils29.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils29.AST_NODE_TYPES.Identifier && node.callee.object.name === "Date" && node.callee.property.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
2236
2000
|
const methodName = node.callee.property.name;
|
|
2237
2001
|
if (methodName === "now") {
|
|
2238
2002
|
context.report({
|
|
@@ -2255,11 +2019,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
2255
2019
|
|
|
2256
2020
|
// src/rules/no-emoji.ts
|
|
2257
2021
|
var import_emoji_regex = __toESM(require("emoji-regex"), 1);
|
|
2258
|
-
var
|
|
2259
|
-
var
|
|
2022
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
2023
|
+
var createRule26 = import_utils30.ESLintUtils.RuleCreator(
|
|
2260
2024
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2261
2025
|
);
|
|
2262
|
-
var noEmoji =
|
|
2026
|
+
var noEmoji = createRule26({
|
|
2263
2027
|
name: "no-emoji",
|
|
2264
2028
|
meta: {
|
|
2265
2029
|
type: "problem",
|
|
@@ -2293,11 +2057,11 @@ var noEmoji = createRule30({
|
|
|
2293
2057
|
var no_emoji_default = noEmoji;
|
|
2294
2058
|
|
|
2295
2059
|
// src/rules/no-env-fallback.ts
|
|
2296
|
-
var
|
|
2297
|
-
var
|
|
2060
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
2061
|
+
var createRule27 = import_utils31.ESLintUtils.RuleCreator(
|
|
2298
2062
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2299
2063
|
);
|
|
2300
|
-
var noEnvFallback =
|
|
2064
|
+
var noEnvFallback = createRule27({
|
|
2301
2065
|
name: "no-env-fallback",
|
|
2302
2066
|
meta: {
|
|
2303
2067
|
type: "problem",
|
|
@@ -2312,16 +2076,16 @@ var noEnvFallback = createRule31({
|
|
|
2312
2076
|
defaultOptions: [],
|
|
2313
2077
|
create(context) {
|
|
2314
2078
|
const isProcessEnvAccess = (node) => {
|
|
2315
|
-
if (node.type !==
|
|
2079
|
+
if (node.type !== import_utils31.AST_NODE_TYPES.MemberExpression) {
|
|
2316
2080
|
return false;
|
|
2317
2081
|
}
|
|
2318
2082
|
const { object } = node;
|
|
2319
|
-
if (object.type !==
|
|
2083
|
+
if (object.type !== import_utils31.AST_NODE_TYPES.MemberExpression) {
|
|
2320
2084
|
return false;
|
|
2321
2085
|
}
|
|
2322
2086
|
const processNode = object.object;
|
|
2323
2087
|
const envNode = object.property;
|
|
2324
|
-
return processNode.type ===
|
|
2088
|
+
return processNode.type === import_utils31.AST_NODE_TYPES.Identifier && processNode.name === "process" && envNode.type === import_utils31.AST_NODE_TYPES.Identifier && envNode.name === "env";
|
|
2325
2089
|
};
|
|
2326
2090
|
return {
|
|
2327
2091
|
LogicalExpression(node) {
|
|
@@ -2346,11 +2110,11 @@ var noEnvFallback = createRule31({
|
|
|
2346
2110
|
var no_env_fallback_default = noEnvFallback;
|
|
2347
2111
|
|
|
2348
2112
|
// src/rules/no-inline-default-export.ts
|
|
2349
|
-
var
|
|
2350
|
-
var
|
|
2113
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2114
|
+
var createRule28 = import_utils32.ESLintUtils.RuleCreator(
|
|
2351
2115
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2352
2116
|
);
|
|
2353
|
-
var noInlineDefaultExport =
|
|
2117
|
+
var noInlineDefaultExport = createRule28({
|
|
2354
2118
|
name: "no-inline-default-export",
|
|
2355
2119
|
meta: {
|
|
2356
2120
|
type: "suggestion",
|
|
@@ -2369,7 +2133,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2369
2133
|
return {
|
|
2370
2134
|
ExportDefaultDeclaration(node) {
|
|
2371
2135
|
const { declaration } = node;
|
|
2372
|
-
if (declaration.type ===
|
|
2136
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2373
2137
|
if (declaration.id) {
|
|
2374
2138
|
context.report({
|
|
2375
2139
|
node,
|
|
@@ -2384,7 +2148,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2384
2148
|
});
|
|
2385
2149
|
}
|
|
2386
2150
|
}
|
|
2387
|
-
if (declaration.type ===
|
|
2151
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.ClassDeclaration) {
|
|
2388
2152
|
if (declaration.id) {
|
|
2389
2153
|
context.report({
|
|
2390
2154
|
node,
|
|
@@ -2399,7 +2163,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2399
2163
|
});
|
|
2400
2164
|
}
|
|
2401
2165
|
}
|
|
2402
|
-
if (declaration.type ===
|
|
2166
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils32.AST_NODE_TYPES.FunctionExpression) {
|
|
2403
2167
|
context.report({
|
|
2404
2168
|
node,
|
|
2405
2169
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2412,14 +2176,14 @@ var noInlineDefaultExport = createRule32({
|
|
|
2412
2176
|
if (!declaration) {
|
|
2413
2177
|
return;
|
|
2414
2178
|
}
|
|
2415
|
-
if (declaration.type ===
|
|
2179
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2416
2180
|
context.report({
|
|
2417
2181
|
node,
|
|
2418
2182
|
messageId: "noInlineNamedExport",
|
|
2419
2183
|
data: { type: "function", name: declaration.id.name }
|
|
2420
2184
|
});
|
|
2421
2185
|
}
|
|
2422
|
-
if (declaration.type ===
|
|
2186
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2423
2187
|
context.report({
|
|
2424
2188
|
node,
|
|
2425
2189
|
messageId: "noInlineNamedExport",
|
|
@@ -2433,36 +2197,45 @@ var noInlineDefaultExport = createRule32({
|
|
|
2433
2197
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2434
2198
|
|
|
2435
2199
|
// src/rules/no-inline-nested-object.ts
|
|
2436
|
-
var
|
|
2437
|
-
var
|
|
2200
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2201
|
+
var createRule29 = import_utils33.ESLintUtils.RuleCreator(
|
|
2438
2202
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2439
2203
|
);
|
|
2440
2204
|
function isObjectOrArray(node) {
|
|
2441
|
-
return node.type ===
|
|
2205
|
+
return node.type === import_utils33.AST_NODE_TYPES.ObjectExpression || node.type === import_utils33.AST_NODE_TYPES.ArrayExpression || node.type === import_utils33.AST_NODE_TYPES.TSAsExpression;
|
|
2442
2206
|
}
|
|
2443
2207
|
function getInnerExpression(node) {
|
|
2444
|
-
if (node.type ===
|
|
2208
|
+
if (node.type === import_utils33.AST_NODE_TYPES.TSAsExpression) {
|
|
2445
2209
|
return getInnerExpression(node.expression);
|
|
2446
2210
|
}
|
|
2447
2211
|
return node;
|
|
2448
2212
|
}
|
|
2449
|
-
function
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2213
|
+
function isNestedStructure(node) {
|
|
2214
|
+
const inner = getInnerExpression(node);
|
|
2215
|
+
return inner.type === import_utils33.AST_NODE_TYPES.ObjectExpression || inner.type === import_utils33.AST_NODE_TYPES.ArrayExpression;
|
|
2216
|
+
}
|
|
2217
|
+
function containsNestedStructure(node) {
|
|
2218
|
+
if (node.type === import_utils33.AST_NODE_TYPES.ObjectExpression) {
|
|
2219
|
+
return node.properties.some((prop) => {
|
|
2220
|
+
if (prop.type !== import_utils33.AST_NODE_TYPES.Property) return false;
|
|
2221
|
+
return isNestedStructure(prop.value);
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
return node.elements.some((el) => {
|
|
2225
|
+
if (el === null) return false;
|
|
2226
|
+
return isNestedStructure(el);
|
|
2454
2227
|
});
|
|
2455
2228
|
}
|
|
2456
|
-
var noInlineNestedObject =
|
|
2229
|
+
var noInlineNestedObject = createRule29({
|
|
2457
2230
|
name: "no-inline-nested-object",
|
|
2458
2231
|
meta: {
|
|
2459
2232
|
type: "layout",
|
|
2460
2233
|
docs: {
|
|
2461
|
-
description: "Require nested objects
|
|
2234
|
+
description: "Require object or array values that contain further nested objects or arrays to span multiple lines"
|
|
2462
2235
|
},
|
|
2463
2236
|
fixable: "whitespace",
|
|
2464
2237
|
messages: {
|
|
2465
|
-
requireMultiline: "
|
|
2238
|
+
requireMultiline: "Inline collections containing nested objects or arrays should span multiple lines"
|
|
2466
2239
|
},
|
|
2467
2240
|
schema: []
|
|
2468
2241
|
},
|
|
@@ -2475,23 +2248,20 @@ var noInlineNestedObject = createRule33({
|
|
|
2475
2248
|
return;
|
|
2476
2249
|
}
|
|
2477
2250
|
const valueNode = getInnerExpression(node.value);
|
|
2478
|
-
if (valueNode.type !==
|
|
2251
|
+
if (valueNode.type !== import_utils33.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils33.AST_NODE_TYPES.ArrayExpression) {
|
|
2479
2252
|
return;
|
|
2480
2253
|
}
|
|
2481
2254
|
if (!valueNode.loc) {
|
|
2482
2255
|
return;
|
|
2483
2256
|
}
|
|
2484
|
-
const elements = valueNode.type === import_utils37.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2485
|
-
if (elements.length <= 1) {
|
|
2486
|
-
return;
|
|
2487
|
-
}
|
|
2488
|
-
if (valueNode.type === import_utils37.AST_NODE_TYPES.ArrayExpression && arrayContainsOnlyPrimitives(valueNode)) {
|
|
2489
|
-
return;
|
|
2490
|
-
}
|
|
2491
2257
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
2492
2258
|
if (isMultiline) {
|
|
2493
2259
|
return;
|
|
2494
2260
|
}
|
|
2261
|
+
if (!containsNestedStructure(valueNode)) {
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
const elements = valueNode.type === import_utils33.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2495
2265
|
context.report({
|
|
2496
2266
|
node: valueNode,
|
|
2497
2267
|
messageId: "requireMultiline",
|
|
@@ -2504,7 +2274,7 @@ var noInlineNestedObject = createRule33({
|
|
|
2504
2274
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2505
2275
|
const innerIndent = `${indent} `;
|
|
2506
2276
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2507
|
-
const isObject = valueNode.type ===
|
|
2277
|
+
const isObject = valueNode.type === import_utils33.AST_NODE_TYPES.ObjectExpression;
|
|
2508
2278
|
const openChar = isObject ? "{" : "[";
|
|
2509
2279
|
const closeChar = isObject ? "}" : "]";
|
|
2510
2280
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2521,20 +2291,20 @@ ${indent}${closeChar}`;
|
|
|
2521
2291
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2522
2292
|
|
|
2523
2293
|
// src/rules/no-inline-return-properties.ts
|
|
2524
|
-
var
|
|
2525
|
-
var
|
|
2294
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2295
|
+
var createRule30 = import_utils34.ESLintUtils.RuleCreator(
|
|
2526
2296
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2527
2297
|
);
|
|
2528
2298
|
var isShorthandProperty = (property) => {
|
|
2529
|
-
if (property.type ===
|
|
2299
|
+
if (property.type === import_utils34.AST_NODE_TYPES.SpreadElement) {
|
|
2530
2300
|
return true;
|
|
2531
2301
|
}
|
|
2532
|
-
if (property.type !==
|
|
2302
|
+
if (property.type !== import_utils34.AST_NODE_TYPES.Property) {
|
|
2533
2303
|
return false;
|
|
2534
2304
|
}
|
|
2535
2305
|
return property.shorthand;
|
|
2536
2306
|
};
|
|
2537
|
-
var noInlineReturnProperties =
|
|
2307
|
+
var noInlineReturnProperties = createRule30({
|
|
2538
2308
|
name: "no-inline-return-properties",
|
|
2539
2309
|
meta: {
|
|
2540
2310
|
type: "suggestion",
|
|
@@ -2550,20 +2320,20 @@ var noInlineReturnProperties = createRule34({
|
|
|
2550
2320
|
create(context) {
|
|
2551
2321
|
return {
|
|
2552
2322
|
ReturnStatement(node) {
|
|
2553
|
-
if (!node.argument || node.argument.type !==
|
|
2323
|
+
if (!node.argument || node.argument.type !== import_utils34.AST_NODE_TYPES.ObjectExpression) {
|
|
2554
2324
|
return;
|
|
2555
2325
|
}
|
|
2556
2326
|
node.argument.properties.forEach((property) => {
|
|
2557
2327
|
if (isShorthandProperty(property)) {
|
|
2558
2328
|
return;
|
|
2559
2329
|
}
|
|
2560
|
-
if (property.type !==
|
|
2330
|
+
if (property.type !== import_utils34.AST_NODE_TYPES.Property) {
|
|
2561
2331
|
return;
|
|
2562
2332
|
}
|
|
2563
2333
|
let keyName = null;
|
|
2564
|
-
if (property.key.type ===
|
|
2334
|
+
if (property.key.type === import_utils34.AST_NODE_TYPES.Identifier) {
|
|
2565
2335
|
keyName = property.key.name;
|
|
2566
|
-
} else if (property.key.type ===
|
|
2336
|
+
} else if (property.key.type === import_utils34.AST_NODE_TYPES.Literal) {
|
|
2567
2337
|
keyName = String(property.key.value);
|
|
2568
2338
|
}
|
|
2569
2339
|
context.report({
|
|
@@ -2579,12 +2349,12 @@ var noInlineReturnProperties = createRule34({
|
|
|
2579
2349
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2580
2350
|
|
|
2581
2351
|
// src/rules/no-inline-type-import.ts
|
|
2582
|
-
var
|
|
2583
|
-
var
|
|
2352
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2353
|
+
var createRule31 = import_utils35.ESLintUtils.RuleCreator(
|
|
2584
2354
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2585
2355
|
);
|
|
2586
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2587
|
-
var noInlineTypeImport =
|
|
2356
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === import_utils35.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2357
|
+
var noInlineTypeImport = createRule31({
|
|
2588
2358
|
name: "no-inline-type-import",
|
|
2589
2359
|
meta: {
|
|
2590
2360
|
type: "suggestion",
|
|
@@ -2621,7 +2391,7 @@ var noInlineTypeImport = createRule35({
|
|
|
2621
2391
|
);
|
|
2622
2392
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2623
2393
|
const valueSpecifiers = node.specifiers.filter(
|
|
2624
|
-
(specifier) => !(specifier.type ===
|
|
2394
|
+
(specifier) => !(specifier.type === import_utils35.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type")
|
|
2625
2395
|
);
|
|
2626
2396
|
if (valueSpecifiers.length === 0) {
|
|
2627
2397
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2629,11 +2399,11 @@ var noInlineTypeImport = createRule35({
|
|
|
2629
2399
|
const parts = [];
|
|
2630
2400
|
const namedValueSpecifiers = [];
|
|
2631
2401
|
for (const specifier of valueSpecifiers) {
|
|
2632
|
-
if (specifier.type ===
|
|
2402
|
+
if (specifier.type === import_utils35.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
2633
2403
|
parts.push(specifier.local.name);
|
|
2634
|
-
} else if (specifier.type ===
|
|
2404
|
+
} else if (specifier.type === import_utils35.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
2635
2405
|
parts.push(`* as ${specifier.local.name}`);
|
|
2636
|
-
} else if (specifier.type ===
|
|
2406
|
+
} else if (specifier.type === import_utils35.AST_NODE_TYPES.ImportSpecifier) {
|
|
2637
2407
|
namedValueSpecifiers.push(specifier);
|
|
2638
2408
|
}
|
|
2639
2409
|
}
|
|
@@ -2653,8 +2423,8 @@ ${typeImport}`);
|
|
|
2653
2423
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2654
2424
|
|
|
2655
2425
|
// src/rules/no-lazy-identifiers.ts
|
|
2656
|
-
var
|
|
2657
|
-
var
|
|
2426
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2427
|
+
var createRule32 = import_utils36.ESLintUtils.RuleCreator(
|
|
2658
2428
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2659
2429
|
);
|
|
2660
2430
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2695,7 +2465,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2695
2465
|
}
|
|
2696
2466
|
return false;
|
|
2697
2467
|
};
|
|
2698
|
-
var noLazyIdentifiers =
|
|
2468
|
+
var noLazyIdentifiers = createRule32({
|
|
2699
2469
|
name: "no-lazy-identifiers",
|
|
2700
2470
|
meta: {
|
|
2701
2471
|
type: "problem",
|
|
@@ -2721,27 +2491,27 @@ var noLazyIdentifiers = createRule36({
|
|
|
2721
2491
|
});
|
|
2722
2492
|
};
|
|
2723
2493
|
const checkPattern = (pattern) => {
|
|
2724
|
-
if (pattern.type ===
|
|
2494
|
+
if (pattern.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2725
2495
|
checkIdentifier(pattern);
|
|
2726
|
-
} else if (pattern.type ===
|
|
2496
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.ObjectPattern) {
|
|
2727
2497
|
pattern.properties.forEach((prop) => {
|
|
2728
|
-
if (prop.type ===
|
|
2498
|
+
if (prop.type === import_utils36.AST_NODE_TYPES.Property && prop.value.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2729
2499
|
checkIdentifier(prop.value);
|
|
2730
|
-
} else if (prop.type ===
|
|
2500
|
+
} else if (prop.type === import_utils36.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2731
2501
|
checkIdentifier(prop.argument);
|
|
2732
2502
|
}
|
|
2733
2503
|
});
|
|
2734
|
-
} else if (pattern.type ===
|
|
2504
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.ArrayPattern) {
|
|
2735
2505
|
pattern.elements.forEach((element) => {
|
|
2736
|
-
if (element?.type ===
|
|
2506
|
+
if (element?.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2737
2507
|
checkIdentifier(element);
|
|
2738
|
-
} else if (element?.type ===
|
|
2508
|
+
} else if (element?.type === import_utils36.AST_NODE_TYPES.RestElement && element.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2739
2509
|
checkIdentifier(element.argument);
|
|
2740
2510
|
}
|
|
2741
2511
|
});
|
|
2742
|
-
} else if (pattern.type ===
|
|
2512
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2743
2513
|
checkIdentifier(pattern.left);
|
|
2744
|
-
} else if (pattern.type ===
|
|
2514
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2745
2515
|
checkIdentifier(pattern.argument);
|
|
2746
2516
|
}
|
|
2747
2517
|
};
|
|
@@ -2786,11 +2556,11 @@ var noLazyIdentifiers = createRule36({
|
|
|
2786
2556
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2787
2557
|
|
|
2788
2558
|
// src/rules/no-logic-in-params.ts
|
|
2789
|
-
var
|
|
2790
|
-
var
|
|
2559
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2560
|
+
var createRule33 = import_utils37.ESLintUtils.RuleCreator(
|
|
2791
2561
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2792
2562
|
);
|
|
2793
|
-
var noLogicInParams =
|
|
2563
|
+
var noLogicInParams = createRule33({
|
|
2794
2564
|
name: "no-logic-in-params",
|
|
2795
2565
|
meta: {
|
|
2796
2566
|
type: "suggestion",
|
|
@@ -2805,20 +2575,20 @@ var noLogicInParams = createRule37({
|
|
|
2805
2575
|
defaultOptions: [],
|
|
2806
2576
|
create(context) {
|
|
2807
2577
|
const isComplexExpression = (node) => {
|
|
2808
|
-
if (node.type ===
|
|
2578
|
+
if (node.type === import_utils37.AST_NODE_TYPES.SpreadElement) {
|
|
2809
2579
|
return false;
|
|
2810
2580
|
}
|
|
2811
|
-
if (node.type ===
|
|
2581
|
+
if (node.type === import_utils37.AST_NODE_TYPES.ConditionalExpression) {
|
|
2812
2582
|
return true;
|
|
2813
2583
|
}
|
|
2814
|
-
if (node.type ===
|
|
2584
|
+
if (node.type === import_utils37.AST_NODE_TYPES.LogicalExpression) {
|
|
2815
2585
|
return true;
|
|
2816
2586
|
}
|
|
2817
|
-
if (node.type ===
|
|
2587
|
+
if (node.type === import_utils37.AST_NODE_TYPES.BinaryExpression) {
|
|
2818
2588
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2819
2589
|
return logicalOperators.includes(node.operator);
|
|
2820
2590
|
}
|
|
2821
|
-
if (node.type ===
|
|
2591
|
+
if (node.type === import_utils37.AST_NODE_TYPES.UnaryExpression) {
|
|
2822
2592
|
return node.operator === "!";
|
|
2823
2593
|
}
|
|
2824
2594
|
return false;
|
|
@@ -2831,7 +2601,7 @@ var noLogicInParams = createRule37({
|
|
|
2831
2601
|
messageId: "noLogicInParams"
|
|
2832
2602
|
});
|
|
2833
2603
|
}
|
|
2834
|
-
if (arg.type ===
|
|
2604
|
+
if (arg.type === import_utils37.AST_NODE_TYPES.ArrayExpression) {
|
|
2835
2605
|
arg.elements.forEach((element) => {
|
|
2836
2606
|
if (element && isComplexExpression(element)) {
|
|
2837
2607
|
context.report({
|
|
@@ -2856,46 +2626,46 @@ var noLogicInParams = createRule37({
|
|
|
2856
2626
|
var no_logic_in_params_default = noLogicInParams;
|
|
2857
2627
|
|
|
2858
2628
|
// src/rules/no-misleading-constant-case.ts
|
|
2859
|
-
var
|
|
2860
|
-
var
|
|
2629
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2630
|
+
var createRule34 = import_utils38.ESLintUtils.RuleCreator(
|
|
2861
2631
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2862
2632
|
);
|
|
2863
2633
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2864
|
-
var
|
|
2865
|
-
var
|
|
2866
|
-
if (
|
|
2634
|
+
var isAsConstAssertion = (node) => node.type === import_utils38.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === import_utils38.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils38.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2635
|
+
var isStaticValue2 = (init) => {
|
|
2636
|
+
if (isAsConstAssertion(init)) {
|
|
2867
2637
|
return true;
|
|
2868
2638
|
}
|
|
2869
|
-
if (init.type ===
|
|
2639
|
+
if (init.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2870
2640
|
return true;
|
|
2871
2641
|
}
|
|
2872
|
-
if (init.type ===
|
|
2642
|
+
if (init.type === import_utils38.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2873
2643
|
return true;
|
|
2874
2644
|
}
|
|
2875
|
-
if (init.type ===
|
|
2645
|
+
if (init.type === import_utils38.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2876
2646
|
return true;
|
|
2877
2647
|
}
|
|
2878
|
-
if (init.type ===
|
|
2879
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
2648
|
+
if (init.type === import_utils38.AST_NODE_TYPES.ArrayExpression) {
|
|
2649
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils38.AST_NODE_TYPES.SpreadElement && isStaticValue2(el));
|
|
2880
2650
|
}
|
|
2881
|
-
if (init.type ===
|
|
2651
|
+
if (init.type === import_utils38.AST_NODE_TYPES.ObjectExpression) {
|
|
2882
2652
|
return init.properties.every(
|
|
2883
|
-
(prop) => prop.type ===
|
|
2653
|
+
(prop) => prop.type === import_utils38.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
2884
2654
|
);
|
|
2885
2655
|
}
|
|
2886
2656
|
return false;
|
|
2887
2657
|
};
|
|
2888
2658
|
var isGlobalScope3 = (node) => {
|
|
2889
2659
|
const { parent } = node;
|
|
2890
|
-
if (parent.type ===
|
|
2660
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.Program) {
|
|
2891
2661
|
return true;
|
|
2892
2662
|
}
|
|
2893
|
-
if (parent.type ===
|
|
2663
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils38.AST_NODE_TYPES.Program) {
|
|
2894
2664
|
return true;
|
|
2895
2665
|
}
|
|
2896
2666
|
return false;
|
|
2897
2667
|
};
|
|
2898
|
-
var noMisleadingConstantCase =
|
|
2668
|
+
var noMisleadingConstantCase = createRule34({
|
|
2899
2669
|
name: "no-misleading-constant-case",
|
|
2900
2670
|
meta: {
|
|
2901
2671
|
type: "suggestion",
|
|
@@ -2914,7 +2684,7 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2914
2684
|
return {
|
|
2915
2685
|
VariableDeclaration(node) {
|
|
2916
2686
|
node.declarations.forEach((declarator) => {
|
|
2917
|
-
if (declarator.id.type !==
|
|
2687
|
+
if (declarator.id.type !== import_utils38.AST_NODE_TYPES.Identifier) {
|
|
2918
2688
|
return;
|
|
2919
2689
|
}
|
|
2920
2690
|
const { name } = declarator.id;
|
|
@@ -2940,7 +2710,7 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2940
2710
|
if (!declarator.init) {
|
|
2941
2711
|
return;
|
|
2942
2712
|
}
|
|
2943
|
-
if (!
|
|
2713
|
+
if (!isStaticValue2(declarator.init)) {
|
|
2944
2714
|
context.report({
|
|
2945
2715
|
node: declarator.id,
|
|
2946
2716
|
messageId: "dynamicScreamingCase",
|
|
@@ -2955,11 +2725,11 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2955
2725
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2956
2726
|
|
|
2957
2727
|
// src/rules/no-nested-interface-declaration.ts
|
|
2958
|
-
var
|
|
2959
|
-
var
|
|
2728
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2729
|
+
var createRule35 = import_utils39.ESLintUtils.RuleCreator(
|
|
2960
2730
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2961
2731
|
);
|
|
2962
|
-
var noNestedInterfaceDeclaration =
|
|
2732
|
+
var noNestedInterfaceDeclaration = createRule35({
|
|
2963
2733
|
name: "no-nested-interface-declaration",
|
|
2964
2734
|
meta: {
|
|
2965
2735
|
type: "suggestion",
|
|
@@ -2980,15 +2750,15 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2980
2750
|
return;
|
|
2981
2751
|
}
|
|
2982
2752
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2983
|
-
if (typeAnnotation.type ===
|
|
2753
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2984
2754
|
context.report({
|
|
2985
2755
|
node: typeAnnotation,
|
|
2986
2756
|
messageId: "noNestedInterface"
|
|
2987
2757
|
});
|
|
2988
2758
|
return;
|
|
2989
2759
|
}
|
|
2990
|
-
if (typeAnnotation.type ===
|
|
2991
|
-
if (typeAnnotation.elementType.type ===
|
|
2760
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSArrayType) {
|
|
2761
|
+
if (typeAnnotation.elementType.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2992
2762
|
context.report({
|
|
2993
2763
|
node: typeAnnotation.elementType,
|
|
2994
2764
|
messageId: "noNestedInterface"
|
|
@@ -2996,9 +2766,9 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2996
2766
|
}
|
|
2997
2767
|
return;
|
|
2998
2768
|
}
|
|
2999
|
-
if (typeAnnotation.type ===
|
|
2769
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
3000
2770
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
3001
|
-
if (param.type ===
|
|
2771
|
+
if (param.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3002
2772
|
context.report({
|
|
3003
2773
|
node: param,
|
|
3004
2774
|
messageId: "noNestedInterface"
|
|
@@ -3013,11 +2783,11 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
3013
2783
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
3014
2784
|
|
|
3015
2785
|
// src/rules/no-nested-ternary.ts
|
|
3016
|
-
var
|
|
3017
|
-
var
|
|
2786
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2787
|
+
var createRule36 = import_utils40.ESLintUtils.RuleCreator(
|
|
3018
2788
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3019
2789
|
);
|
|
3020
|
-
var noNestedTernary =
|
|
2790
|
+
var noNestedTernary = createRule36({
|
|
3021
2791
|
name: "no-nested-ternary",
|
|
3022
2792
|
meta: {
|
|
3023
2793
|
type: "suggestion",
|
|
@@ -3034,13 +2804,13 @@ var noNestedTernary = createRule40({
|
|
|
3034
2804
|
return {
|
|
3035
2805
|
ConditionalExpression(node) {
|
|
3036
2806
|
const { consequent, alternate } = node;
|
|
3037
|
-
if (consequent.type ===
|
|
2807
|
+
if (consequent.type === import_utils40.AST_NODE_TYPES.ConditionalExpression) {
|
|
3038
2808
|
context.report({
|
|
3039
2809
|
node: consequent,
|
|
3040
2810
|
messageId: "noNestedTernary"
|
|
3041
2811
|
});
|
|
3042
2812
|
}
|
|
3043
|
-
if (alternate.type ===
|
|
2813
|
+
if (alternate.type === import_utils40.AST_NODE_TYPES.ConditionalExpression) {
|
|
3044
2814
|
context.report({
|
|
3045
2815
|
node: alternate,
|
|
3046
2816
|
messageId: "noNestedTernary"
|
|
@@ -3053,11 +2823,11 @@ var noNestedTernary = createRule40({
|
|
|
3053
2823
|
var no_nested_ternary_default = noNestedTernary;
|
|
3054
2824
|
|
|
3055
2825
|
// src/rules/no-relative-imports.ts
|
|
3056
|
-
var
|
|
3057
|
-
var
|
|
2826
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2827
|
+
var createRule37 = import_utils41.ESLintUtils.RuleCreator(
|
|
3058
2828
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3059
2829
|
);
|
|
3060
|
-
var noRelativeImports =
|
|
2830
|
+
var noRelativeImports = createRule37({
|
|
3061
2831
|
name: "no-relative-imports",
|
|
3062
2832
|
meta: {
|
|
3063
2833
|
type: "suggestion",
|
|
@@ -3081,22 +2851,22 @@ var noRelativeImports = createRule41({
|
|
|
3081
2851
|
};
|
|
3082
2852
|
return {
|
|
3083
2853
|
ImportDeclaration(node) {
|
|
3084
|
-
if (node.source.type ===
|
|
2854
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3085
2855
|
checkImportPath(node.source.value, node);
|
|
3086
2856
|
}
|
|
3087
2857
|
},
|
|
3088
2858
|
ImportExpression(node) {
|
|
3089
|
-
if (node.source.type ===
|
|
2859
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3090
2860
|
checkImportPath(node.source.value, node);
|
|
3091
2861
|
}
|
|
3092
2862
|
},
|
|
3093
2863
|
ExportNamedDeclaration(node) {
|
|
3094
|
-
if (node.source?.type ===
|
|
2864
|
+
if (node.source?.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3095
2865
|
checkImportPath(node.source.value, node);
|
|
3096
2866
|
}
|
|
3097
2867
|
},
|
|
3098
2868
|
ExportAllDeclaration(node) {
|
|
3099
|
-
if (node.source.type ===
|
|
2869
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3100
2870
|
checkImportPath(node.source.value, node);
|
|
3101
2871
|
}
|
|
3102
2872
|
}
|
|
@@ -3106,8 +2876,8 @@ var noRelativeImports = createRule41({
|
|
|
3106
2876
|
var no_relative_imports_default = noRelativeImports;
|
|
3107
2877
|
|
|
3108
2878
|
// src/rules/no-single-char-variables.ts
|
|
3109
|
-
var
|
|
3110
|
-
var
|
|
2879
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2880
|
+
var createRule38 = import_utils42.ESLintUtils.RuleCreator(
|
|
3111
2881
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3112
2882
|
);
|
|
3113
2883
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -3119,7 +2889,7 @@ var isForLoopInit = (node) => {
|
|
|
3119
2889
|
if (!parentNode) {
|
|
3120
2890
|
return false;
|
|
3121
2891
|
}
|
|
3122
|
-
if (parentNode.type ===
|
|
2892
|
+
if (parentNode.type === import_utils42.AST_NODE_TYPES.ForStatement) {
|
|
3123
2893
|
const { init } = parentNode;
|
|
3124
2894
|
if (init && init === current) {
|
|
3125
2895
|
return true;
|
|
@@ -3138,7 +2908,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
3138
2908
|
}
|
|
3139
2909
|
return false;
|
|
3140
2910
|
};
|
|
3141
|
-
var noSingleCharVariables =
|
|
2911
|
+
var noSingleCharVariables = createRule38({
|
|
3142
2912
|
name: "no-single-char-variables",
|
|
3143
2913
|
meta: {
|
|
3144
2914
|
type: "suggestion",
|
|
@@ -3167,27 +2937,27 @@ var noSingleCharVariables = createRule42({
|
|
|
3167
2937
|
});
|
|
3168
2938
|
};
|
|
3169
2939
|
const checkPattern = (pattern, declarationNode) => {
|
|
3170
|
-
if (pattern.type ===
|
|
2940
|
+
if (pattern.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3171
2941
|
checkIdentifier(pattern, declarationNode);
|
|
3172
|
-
} else if (pattern.type ===
|
|
2942
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.ObjectPattern) {
|
|
3173
2943
|
pattern.properties.forEach((prop) => {
|
|
3174
|
-
if (prop.type ===
|
|
2944
|
+
if (prop.type === import_utils42.AST_NODE_TYPES.Property && prop.value.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3175
2945
|
checkIdentifier(prop.value, declarationNode);
|
|
3176
|
-
} else if (prop.type ===
|
|
2946
|
+
} else if (prop.type === import_utils42.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3177
2947
|
checkIdentifier(prop.argument, declarationNode);
|
|
3178
2948
|
}
|
|
3179
2949
|
});
|
|
3180
|
-
} else if (pattern.type ===
|
|
2950
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.ArrayPattern) {
|
|
3181
2951
|
pattern.elements.forEach((element) => {
|
|
3182
|
-
if (element?.type ===
|
|
2952
|
+
if (element?.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3183
2953
|
checkIdentifier(element, declarationNode);
|
|
3184
|
-
} else if (element?.type ===
|
|
2954
|
+
} else if (element?.type === import_utils42.AST_NODE_TYPES.RestElement && element.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3185
2955
|
checkIdentifier(element.argument, declarationNode);
|
|
3186
2956
|
}
|
|
3187
2957
|
});
|
|
3188
|
-
} else if (pattern.type ===
|
|
2958
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3189
2959
|
checkIdentifier(pattern.left, declarationNode);
|
|
3190
|
-
} else if (pattern.type ===
|
|
2960
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3191
2961
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3192
2962
|
}
|
|
3193
2963
|
};
|
|
@@ -3221,11 +2991,11 @@ var noSingleCharVariables = createRule42({
|
|
|
3221
2991
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3222
2992
|
|
|
3223
2993
|
// src/rules/prefer-async-await.ts
|
|
3224
|
-
var
|
|
3225
|
-
var
|
|
2994
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2995
|
+
var createRule39 = import_utils43.ESLintUtils.RuleCreator(
|
|
3226
2996
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3227
2997
|
);
|
|
3228
|
-
var preferAsyncAwait =
|
|
2998
|
+
var preferAsyncAwait = createRule39({
|
|
3229
2999
|
name: "prefer-async-await",
|
|
3230
3000
|
meta: {
|
|
3231
3001
|
type: "suggestion",
|
|
@@ -3241,7 +3011,7 @@ var preferAsyncAwait = createRule43({
|
|
|
3241
3011
|
create(context) {
|
|
3242
3012
|
return {
|
|
3243
3013
|
CallExpression(node) {
|
|
3244
|
-
if (node.callee.type ===
|
|
3014
|
+
if (node.callee.type === import_utils43.AST_NODE_TYPES.MemberExpression && node.callee.property.type === import_utils43.AST_NODE_TYPES.Identifier && node.callee.property.name === "then") {
|
|
3245
3015
|
context.report({
|
|
3246
3016
|
node: node.callee.property,
|
|
3247
3017
|
messageId: "preferAsyncAwait"
|
|
@@ -3254,11 +3024,11 @@ var preferAsyncAwait = createRule43({
|
|
|
3254
3024
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3255
3025
|
|
|
3256
3026
|
// src/rules/prefer-destructuring-params.ts
|
|
3257
|
-
var
|
|
3258
|
-
var
|
|
3027
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
3028
|
+
var createRule40 = import_utils44.ESLintUtils.RuleCreator(
|
|
3259
3029
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3260
3030
|
);
|
|
3261
|
-
var preferDestructuringParams =
|
|
3031
|
+
var preferDestructuringParams = createRule40({
|
|
3262
3032
|
name: "prefer-destructuring-params",
|
|
3263
3033
|
meta: {
|
|
3264
3034
|
type: "suggestion",
|
|
@@ -3274,18 +3044,18 @@ var preferDestructuringParams = createRule44({
|
|
|
3274
3044
|
create(context) {
|
|
3275
3045
|
const isCallbackFunction2 = (node) => {
|
|
3276
3046
|
const { parent } = node;
|
|
3277
|
-
return parent?.type ===
|
|
3047
|
+
return parent?.type === import_utils44.AST_NODE_TYPES.CallExpression;
|
|
3278
3048
|
};
|
|
3279
3049
|
const isDeveloperFunction = (node) => {
|
|
3280
|
-
if (node.type ===
|
|
3050
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3281
3051
|
return true;
|
|
3282
3052
|
}
|
|
3283
|
-
if (node.type ===
|
|
3053
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionExpression || node.type === import_utils44.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3284
3054
|
if (isCallbackFunction2(node)) {
|
|
3285
3055
|
return false;
|
|
3286
3056
|
}
|
|
3287
3057
|
const { parent } = node;
|
|
3288
|
-
return parent?.type ===
|
|
3058
|
+
return parent?.type === import_utils44.AST_NODE_TYPES.VariableDeclarator || parent?.type === import_utils44.AST_NODE_TYPES.AssignmentExpression || parent?.type === import_utils44.AST_NODE_TYPES.Property || parent?.type === import_utils44.AST_NODE_TYPES.MethodDefinition;
|
|
3289
3059
|
}
|
|
3290
3060
|
return false;
|
|
3291
3061
|
};
|
|
@@ -3297,7 +3067,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3297
3067
|
if (!isDeveloperFunction(node)) {
|
|
3298
3068
|
return;
|
|
3299
3069
|
}
|
|
3300
|
-
if (node.type ===
|
|
3070
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3301
3071
|
const functionName = node.id.name;
|
|
3302
3072
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3303
3073
|
return;
|
|
@@ -3307,7 +3077,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3307
3077
|
return;
|
|
3308
3078
|
}
|
|
3309
3079
|
const hasNonDestructuredParams = node.params.some(
|
|
3310
|
-
(param) => param.type !==
|
|
3080
|
+
(param) => param.type !== import_utils44.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils44.AST_NODE_TYPES.RestElement
|
|
3311
3081
|
);
|
|
3312
3082
|
if (hasNonDestructuredParams) {
|
|
3313
3083
|
context.report({
|
|
@@ -3326,8 +3096,8 @@ var preferDestructuringParams = createRule44({
|
|
|
3326
3096
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3327
3097
|
|
|
3328
3098
|
// src/rules/prefer-function-declaration.ts
|
|
3329
|
-
var
|
|
3330
|
-
var
|
|
3099
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
3100
|
+
var createRule41 = import_utils45.ESLintUtils.RuleCreator(
|
|
3331
3101
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3332
3102
|
);
|
|
3333
3103
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3336,33 +3106,33 @@ var isCallbackContext = (node) => {
|
|
|
3336
3106
|
if (!parent) {
|
|
3337
3107
|
return false;
|
|
3338
3108
|
}
|
|
3339
|
-
if (parent.type ===
|
|
3109
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3340
3110
|
return true;
|
|
3341
3111
|
}
|
|
3342
|
-
if (parent.type ===
|
|
3112
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3343
3113
|
return true;
|
|
3344
3114
|
}
|
|
3345
|
-
if (parent.type ===
|
|
3115
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ReturnStatement) {
|
|
3346
3116
|
return true;
|
|
3347
3117
|
}
|
|
3348
|
-
if (parent.type ===
|
|
3118
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.Property) {
|
|
3349
3119
|
return true;
|
|
3350
3120
|
}
|
|
3351
|
-
if (parent.type ===
|
|
3121
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
3352
3122
|
return true;
|
|
3353
3123
|
}
|
|
3354
|
-
if (parent.type ===
|
|
3124
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ConditionalExpression) {
|
|
3355
3125
|
return true;
|
|
3356
3126
|
}
|
|
3357
|
-
if (parent.type ===
|
|
3127
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.LogicalExpression) {
|
|
3358
3128
|
return true;
|
|
3359
3129
|
}
|
|
3360
|
-
if (parent.type ===
|
|
3130
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3361
3131
|
return true;
|
|
3362
3132
|
}
|
|
3363
3133
|
return false;
|
|
3364
3134
|
};
|
|
3365
|
-
var preferFunctionDeclaration =
|
|
3135
|
+
var preferFunctionDeclaration = createRule41({
|
|
3366
3136
|
name: "prefer-function-declaration",
|
|
3367
3137
|
meta: {
|
|
3368
3138
|
type: "suggestion",
|
|
@@ -3383,14 +3153,14 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3383
3153
|
}
|
|
3384
3154
|
return {
|
|
3385
3155
|
VariableDeclarator(node) {
|
|
3386
|
-
if (node.id.type !==
|
|
3156
|
+
if (node.id.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
3387
3157
|
return;
|
|
3388
3158
|
}
|
|
3389
3159
|
const { init } = node;
|
|
3390
3160
|
if (!init) {
|
|
3391
3161
|
return;
|
|
3392
3162
|
}
|
|
3393
|
-
if (init.type ===
|
|
3163
|
+
if (init.type === import_utils45.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3394
3164
|
if (isCallbackContext(init)) {
|
|
3395
3165
|
return;
|
|
3396
3166
|
}
|
|
@@ -3400,7 +3170,7 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3400
3170
|
data: { name: node.id.name }
|
|
3401
3171
|
});
|
|
3402
3172
|
}
|
|
3403
|
-
if (init.type ===
|
|
3173
|
+
if (init.type === import_utils45.AST_NODE_TYPES.FunctionExpression) {
|
|
3404
3174
|
if (isCallbackContext(init)) {
|
|
3405
3175
|
return;
|
|
3406
3176
|
}
|
|
@@ -3417,11 +3187,11 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3417
3187
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3418
3188
|
|
|
3419
3189
|
// src/rules/prefer-guard-clause.ts
|
|
3420
|
-
var
|
|
3421
|
-
var
|
|
3190
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3191
|
+
var createRule42 = import_utils46.ESLintUtils.RuleCreator(
|
|
3422
3192
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3423
3193
|
);
|
|
3424
|
-
var preferGuardClause =
|
|
3194
|
+
var preferGuardClause = createRule42({
|
|
3425
3195
|
name: "prefer-guard-clause",
|
|
3426
3196
|
meta: {
|
|
3427
3197
|
type: "suggestion",
|
|
@@ -3438,8 +3208,8 @@ var preferGuardClause = createRule46({
|
|
|
3438
3208
|
return {
|
|
3439
3209
|
IfStatement(node) {
|
|
3440
3210
|
const { consequent } = node;
|
|
3441
|
-
if (consequent.type ===
|
|
3442
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3211
|
+
if (consequent.type === import_utils46.AST_NODE_TYPES.BlockStatement) {
|
|
3212
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === import_utils46.AST_NODE_TYPES.IfStatement);
|
|
3443
3213
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3444
3214
|
context.report({
|
|
3445
3215
|
node,
|
|
@@ -3447,7 +3217,7 @@ var preferGuardClause = createRule46({
|
|
|
3447
3217
|
});
|
|
3448
3218
|
}
|
|
3449
3219
|
}
|
|
3450
|
-
if (consequent.type ===
|
|
3220
|
+
if (consequent.type === import_utils46.AST_NODE_TYPES.IfStatement) {
|
|
3451
3221
|
context.report({
|
|
3452
3222
|
node,
|
|
3453
3223
|
messageId: "preferGuardClause"
|
|
@@ -3460,11 +3230,11 @@ var preferGuardClause = createRule46({
|
|
|
3460
3230
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3461
3231
|
|
|
3462
3232
|
// src/rules/prefer-import-type.ts
|
|
3463
|
-
var
|
|
3464
|
-
var
|
|
3233
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3234
|
+
var createRule43 = import_utils47.ESLintUtils.RuleCreator(
|
|
3465
3235
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3466
3236
|
);
|
|
3467
|
-
var preferImportType =
|
|
3237
|
+
var preferImportType = createRule43({
|
|
3468
3238
|
name: "prefer-import-type",
|
|
3469
3239
|
meta: {
|
|
3470
3240
|
type: "suggestion",
|
|
@@ -3483,22 +3253,22 @@ var preferImportType = createRule47({
|
|
|
3483
3253
|
let current = node;
|
|
3484
3254
|
while (current) {
|
|
3485
3255
|
switch (current.type) {
|
|
3486
|
-
case
|
|
3487
|
-
case
|
|
3488
|
-
case
|
|
3489
|
-
case
|
|
3490
|
-
case
|
|
3491
|
-
case
|
|
3492
|
-
case
|
|
3493
|
-
case
|
|
3494
|
-
case
|
|
3495
|
-
case
|
|
3496
|
-
case
|
|
3497
|
-
case
|
|
3498
|
-
case
|
|
3256
|
+
case import_utils47.AST_NODE_TYPES.TSTypeReference:
|
|
3257
|
+
case import_utils47.AST_NODE_TYPES.TSTypeAnnotation:
|
|
3258
|
+
case import_utils47.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
3259
|
+
case import_utils47.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
3260
|
+
case import_utils47.AST_NODE_TYPES.TSClassImplements:
|
|
3261
|
+
case import_utils47.AST_NODE_TYPES.TSTypeQuery:
|
|
3262
|
+
case import_utils47.AST_NODE_TYPES.TSTypeAssertion:
|
|
3263
|
+
case import_utils47.AST_NODE_TYPES.TSAsExpression:
|
|
3264
|
+
case import_utils47.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
3265
|
+
case import_utils47.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3266
|
+
case import_utils47.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3267
|
+
case import_utils47.AST_NODE_TYPES.TSTypeParameter:
|
|
3268
|
+
case import_utils47.AST_NODE_TYPES.TSQualifiedName:
|
|
3499
3269
|
return true;
|
|
3500
|
-
case
|
|
3501
|
-
case
|
|
3270
|
+
case import_utils47.AST_NODE_TYPES.MemberExpression:
|
|
3271
|
+
case import_utils47.AST_NODE_TYPES.Identifier:
|
|
3502
3272
|
current = current.parent;
|
|
3503
3273
|
break;
|
|
3504
3274
|
default:
|
|
@@ -3528,27 +3298,27 @@ var preferImportType = createRule47({
|
|
|
3528
3298
|
return false;
|
|
3529
3299
|
}
|
|
3530
3300
|
switch (parent.type) {
|
|
3531
|
-
case
|
|
3532
|
-
case
|
|
3533
|
-
case
|
|
3534
|
-
case
|
|
3535
|
-
case
|
|
3536
|
-
case
|
|
3537
|
-
case
|
|
3538
|
-
case
|
|
3539
|
-
case
|
|
3540
|
-
case
|
|
3541
|
-
case
|
|
3542
|
-
case
|
|
3543
|
-
case
|
|
3544
|
-
case
|
|
3545
|
-
case
|
|
3546
|
-
case
|
|
3547
|
-
case
|
|
3548
|
-
case
|
|
3549
|
-
case
|
|
3550
|
-
case
|
|
3551
|
-
case
|
|
3301
|
+
case import_utils47.AST_NODE_TYPES.CallExpression:
|
|
3302
|
+
case import_utils47.AST_NODE_TYPES.NewExpression:
|
|
3303
|
+
case import_utils47.AST_NODE_TYPES.JSXOpeningElement:
|
|
3304
|
+
case import_utils47.AST_NODE_TYPES.JSXClosingElement:
|
|
3305
|
+
case import_utils47.AST_NODE_TYPES.MemberExpression:
|
|
3306
|
+
case import_utils47.AST_NODE_TYPES.VariableDeclarator:
|
|
3307
|
+
case import_utils47.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
3308
|
+
case import_utils47.AST_NODE_TYPES.SpreadElement:
|
|
3309
|
+
case import_utils47.AST_NODE_TYPES.ExportSpecifier:
|
|
3310
|
+
case import_utils47.AST_NODE_TYPES.ArrayExpression:
|
|
3311
|
+
case import_utils47.AST_NODE_TYPES.ObjectExpression:
|
|
3312
|
+
case import_utils47.AST_NODE_TYPES.BinaryExpression:
|
|
3313
|
+
case import_utils47.AST_NODE_TYPES.LogicalExpression:
|
|
3314
|
+
case import_utils47.AST_NODE_TYPES.UnaryExpression:
|
|
3315
|
+
case import_utils47.AST_NODE_TYPES.ReturnStatement:
|
|
3316
|
+
case import_utils47.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
3317
|
+
case import_utils47.AST_NODE_TYPES.ConditionalExpression:
|
|
3318
|
+
case import_utils47.AST_NODE_TYPES.AwaitExpression:
|
|
3319
|
+
case import_utils47.AST_NODE_TYPES.YieldExpression:
|
|
3320
|
+
case import_utils47.AST_NODE_TYPES.Property:
|
|
3321
|
+
case import_utils47.AST_NODE_TYPES.JSXExpressionContainer:
|
|
3552
3322
|
return true;
|
|
3553
3323
|
default:
|
|
3554
3324
|
return false;
|
|
@@ -3559,6 +3329,12 @@ var preferImportType = createRule47({
|
|
|
3559
3329
|
if (node.importKind === "type") {
|
|
3560
3330
|
return;
|
|
3561
3331
|
}
|
|
3332
|
+
const hasInlineTypeSpecifier = node.specifiers.some(
|
|
3333
|
+
(specifier) => specifier.type === import_utils47.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type"
|
|
3334
|
+
);
|
|
3335
|
+
if (hasInlineTypeSpecifier) {
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3562
3338
|
if (context.filename.includes(".test.") || context.filename.includes(".spec.") || context.filename.includes("__tests__")) {
|
|
3563
3339
|
return;
|
|
3564
3340
|
}
|
|
@@ -3572,13 +3348,13 @@ var preferImportType = createRule47({
|
|
|
3572
3348
|
}
|
|
3573
3349
|
const scope = context.sourceCode.getScope(node);
|
|
3574
3350
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3575
|
-
if (specifier.type ===
|
|
3351
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3576
3352
|
return false;
|
|
3577
3353
|
}
|
|
3578
|
-
if (specifier.type ===
|
|
3354
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3579
3355
|
return false;
|
|
3580
3356
|
}
|
|
3581
|
-
if (specifier.type ===
|
|
3357
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportSpecifier) {
|
|
3582
3358
|
const localName = specifier.local.name;
|
|
3583
3359
|
return !isUsedAsValue(localName, scope);
|
|
3584
3360
|
}
|
|
@@ -3604,19 +3380,19 @@ var preferImportType = createRule47({
|
|
|
3604
3380
|
var prefer_import_type_default = preferImportType;
|
|
3605
3381
|
|
|
3606
3382
|
// src/rules/prefer-inline-literal-union.ts
|
|
3607
|
-
var
|
|
3608
|
-
var
|
|
3383
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3384
|
+
var createRule44 = import_utils48.ESLintUtils.RuleCreator(
|
|
3609
3385
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3610
3386
|
);
|
|
3611
3387
|
function isLiteralUnionType(node) {
|
|
3612
|
-
if (node.type !==
|
|
3388
|
+
if (node.type !== import_utils48.AST_NODE_TYPES.TSUnionType) {
|
|
3613
3389
|
return false;
|
|
3614
3390
|
}
|
|
3615
3391
|
return node.types.every(
|
|
3616
|
-
(member) => member.type ===
|
|
3392
|
+
(member) => member.type === import_utils48.AST_NODE_TYPES.TSLiteralType || member.type === import_utils48.AST_NODE_TYPES.TSNullKeyword || member.type === import_utils48.AST_NODE_TYPES.TSUndefinedKeyword
|
|
3617
3393
|
);
|
|
3618
3394
|
}
|
|
3619
|
-
var preferInlineLiteralUnion =
|
|
3395
|
+
var preferInlineLiteralUnion = createRule44({
|
|
3620
3396
|
name: "prefer-inline-literal-union",
|
|
3621
3397
|
meta: {
|
|
3622
3398
|
type: "suggestion",
|
|
@@ -3643,10 +3419,10 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3643
3419
|
return;
|
|
3644
3420
|
}
|
|
3645
3421
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3646
|
-
if (typeAnnotation.type !==
|
|
3422
|
+
if (typeAnnotation.type !== import_utils48.AST_NODE_TYPES.TSTypeReference) {
|
|
3647
3423
|
return;
|
|
3648
3424
|
}
|
|
3649
|
-
if (typeAnnotation.typeName.type !==
|
|
3425
|
+
if (typeAnnotation.typeName.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
3650
3426
|
return;
|
|
3651
3427
|
}
|
|
3652
3428
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3670,12 +3446,12 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3670
3446
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3671
3447
|
|
|
3672
3448
|
// src/rules/prefer-inline-type-export.ts
|
|
3673
|
-
var
|
|
3674
|
-
var
|
|
3449
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3450
|
+
var createRule45 = import_utils49.ESLintUtils.RuleCreator(
|
|
3675
3451
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3676
3452
|
);
|
|
3677
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3678
|
-
var preferInlineTypeExport =
|
|
3453
|
+
var isTypeDeclaration = (node) => node.type === import_utils49.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils49.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
3454
|
+
var preferInlineTypeExport = createRule45({
|
|
3679
3455
|
name: "prefer-inline-type-export",
|
|
3680
3456
|
meta: {
|
|
3681
3457
|
type: "suggestion",
|
|
@@ -3692,12 +3468,12 @@ var preferInlineTypeExport = createRule49({
|
|
|
3692
3468
|
create(context) {
|
|
3693
3469
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3694
3470
|
function collectDeclaration(node) {
|
|
3695
|
-
if (node.parent.type !==
|
|
3471
|
+
if (node.parent.type !== import_utils49.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3696
3472
|
typeDeclarations.set(node.id.name, node);
|
|
3697
3473
|
}
|
|
3698
3474
|
}
|
|
3699
3475
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3700
|
-
if (specifier.local.type !==
|
|
3476
|
+
if (specifier.local.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3701
3477
|
return;
|
|
3702
3478
|
}
|
|
3703
3479
|
const { name } = specifier.local;
|
|
@@ -3730,16 +3506,16 @@ var preferInlineTypeExport = createRule49({
|
|
|
3730
3506
|
return {
|
|
3731
3507
|
Program(node) {
|
|
3732
3508
|
node.body.forEach((statement) => {
|
|
3733
|
-
if (statement.type ===
|
|
3509
|
+
if (statement.type === import_utils49.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils49.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3734
3510
|
collectDeclaration(statement);
|
|
3735
3511
|
}
|
|
3736
3512
|
});
|
|
3737
3513
|
node.body.forEach((statement) => {
|
|
3738
|
-
if (statement.type !==
|
|
3514
|
+
if (statement.type !== import_utils49.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3739
3515
|
return;
|
|
3740
3516
|
}
|
|
3741
3517
|
statement.specifiers.forEach((specifier) => {
|
|
3742
|
-
if (specifier.local.type !==
|
|
3518
|
+
if (specifier.local.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3743
3519
|
return;
|
|
3744
3520
|
}
|
|
3745
3521
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3755,12 +3531,69 @@ var preferInlineTypeExport = createRule49({
|
|
|
3755
3531
|
});
|
|
3756
3532
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3757
3533
|
|
|
3534
|
+
// src/rules/prefer-interface-for-component-props.ts
|
|
3535
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3536
|
+
var createRule46 = import_utils50.ESLintUtils.RuleCreator(
|
|
3537
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3538
|
+
);
|
|
3539
|
+
var preferInterfaceForComponentProps = createRule46({
|
|
3540
|
+
name: "prefer-interface-for-component-props",
|
|
3541
|
+
meta: {
|
|
3542
|
+
type: "suggestion",
|
|
3543
|
+
docs: {
|
|
3544
|
+
description: "Enforce 'interface' over 'type' alias for component prop declarations in component files (*.tsx, *.jsx)"
|
|
3545
|
+
},
|
|
3546
|
+
fixable: "code",
|
|
3547
|
+
schema: [],
|
|
3548
|
+
messages: {
|
|
3549
|
+
preferInterface: "Component props '{{ name }}' should use 'interface' instead of 'type' alias."
|
|
3550
|
+
}
|
|
3551
|
+
},
|
|
3552
|
+
defaultOptions: [],
|
|
3553
|
+
create(context) {
|
|
3554
|
+
if (!isJsxFile(context.filename)) {
|
|
3555
|
+
return {};
|
|
3556
|
+
}
|
|
3557
|
+
return {
|
|
3558
|
+
TSTypeAliasDeclaration(node) {
|
|
3559
|
+
if (node.id.type !== import_utils50.AST_NODE_TYPES.Identifier) {
|
|
3560
|
+
return;
|
|
3561
|
+
}
|
|
3562
|
+
if (!node.id.name.endsWith("Props")) {
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3565
|
+
if (node.typeAnnotation.type !== import_utils50.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3566
|
+
return;
|
|
3567
|
+
}
|
|
3568
|
+
const { name } = node.id;
|
|
3569
|
+
context.report({
|
|
3570
|
+
node: node.id,
|
|
3571
|
+
messageId: "preferInterface",
|
|
3572
|
+
data: { name },
|
|
3573
|
+
fix(fixer) {
|
|
3574
|
+
const { sourceCode } = context;
|
|
3575
|
+
const typeText = sourceCode.getText(node.typeAnnotation);
|
|
3576
|
+
const typeParamsText = node.typeParameters ? sourceCode.getText(node.typeParameters) : "";
|
|
3577
|
+
const newText = `interface ${name}${typeParamsText} ${typeText}`;
|
|
3578
|
+
const tokenAfter = sourceCode.getTokenAfter(node);
|
|
3579
|
+
if (tokenAfter && tokenAfter.value === ";") {
|
|
3580
|
+
return fixer.replaceTextRange([node.range[0], tokenAfter.range[1]], newText);
|
|
3581
|
+
}
|
|
3582
|
+
return fixer.replaceText(node, newText);
|
|
3583
|
+
}
|
|
3584
|
+
});
|
|
3585
|
+
}
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
});
|
|
3589
|
+
var prefer_interface_for_component_props_default = preferInterfaceForComponentProps;
|
|
3590
|
+
|
|
3758
3591
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3759
|
-
var
|
|
3760
|
-
var
|
|
3592
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3593
|
+
var createRule47 = import_utils52.ESLintUtils.RuleCreator(
|
|
3761
3594
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3762
3595
|
);
|
|
3763
|
-
var preferInterfaceOverInlineTypes =
|
|
3596
|
+
var preferInterfaceOverInlineTypes = createRule47({
|
|
3764
3597
|
name: "prefer-interface-over-inline-types",
|
|
3765
3598
|
meta: {
|
|
3766
3599
|
type: "suggestion",
|
|
@@ -3776,54 +3609,54 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3776
3609
|
defaultOptions: [],
|
|
3777
3610
|
create(context) {
|
|
3778
3611
|
function hasJSXInConditional(node) {
|
|
3779
|
-
return node.consequent.type ===
|
|
3612
|
+
return node.consequent.type === import_utils52.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils52.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils52.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils52.AST_NODE_TYPES.JSXFragment;
|
|
3780
3613
|
}
|
|
3781
3614
|
function hasJSXInLogical(node) {
|
|
3782
|
-
return node.right.type ===
|
|
3615
|
+
return node.right.type === import_utils52.AST_NODE_TYPES.JSXElement || node.right.type === import_utils52.AST_NODE_TYPES.JSXFragment;
|
|
3783
3616
|
}
|
|
3784
3617
|
function hasJSXReturn(block) {
|
|
3785
3618
|
return block.body.some((stmt) => {
|
|
3786
|
-
if (stmt.type ===
|
|
3787
|
-
return stmt.argument.type ===
|
|
3619
|
+
if (stmt.type === import_utils52.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
3620
|
+
return stmt.argument.type === import_utils52.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils52.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils52.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils52.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3788
3621
|
}
|
|
3789
3622
|
return false;
|
|
3790
3623
|
});
|
|
3791
3624
|
}
|
|
3792
3625
|
function isReactComponent2(node) {
|
|
3793
|
-
if (node.type ===
|
|
3794
|
-
if (node.body.type ===
|
|
3626
|
+
if (node.type === import_utils52.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3627
|
+
if (node.body.type === import_utils52.AST_NODE_TYPES.JSXElement || node.body.type === import_utils52.AST_NODE_TYPES.JSXFragment) {
|
|
3795
3628
|
return true;
|
|
3796
3629
|
}
|
|
3797
|
-
if (node.body.type ===
|
|
3630
|
+
if (node.body.type === import_utils52.AST_NODE_TYPES.BlockStatement) {
|
|
3798
3631
|
return hasJSXReturn(node.body);
|
|
3799
3632
|
}
|
|
3800
|
-
} else if (node.type ===
|
|
3801
|
-
if (node.body && node.body.type ===
|
|
3633
|
+
} else if (node.type === import_utils52.AST_NODE_TYPES.FunctionExpression || node.type === import_utils52.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3634
|
+
if (node.body && node.body.type === import_utils52.AST_NODE_TYPES.BlockStatement) {
|
|
3802
3635
|
return hasJSXReturn(node.body);
|
|
3803
3636
|
}
|
|
3804
3637
|
}
|
|
3805
3638
|
return false;
|
|
3806
3639
|
}
|
|
3807
3640
|
function isInlineTypeAnnotation(node) {
|
|
3808
|
-
if (node.type ===
|
|
3641
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3809
3642
|
return true;
|
|
3810
3643
|
}
|
|
3811
|
-
if (node.type ===
|
|
3812
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3644
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3645
|
+
return node.typeArguments.params.some((param) => param.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral);
|
|
3813
3646
|
}
|
|
3814
|
-
if (node.type ===
|
|
3647
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
3815
3648
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3816
3649
|
}
|
|
3817
3650
|
return false;
|
|
3818
3651
|
}
|
|
3819
3652
|
function hasInlineObjectType(node) {
|
|
3820
|
-
if (node.type ===
|
|
3653
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3821
3654
|
return true;
|
|
3822
3655
|
}
|
|
3823
|
-
if (node.type ===
|
|
3824
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3656
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3657
|
+
return node.typeArguments.params.some((param) => param.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral);
|
|
3825
3658
|
}
|
|
3826
|
-
if (node.type ===
|
|
3659
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
3827
3660
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3828
3661
|
}
|
|
3829
3662
|
return false;
|
|
@@ -3836,7 +3669,7 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3836
3669
|
return;
|
|
3837
3670
|
}
|
|
3838
3671
|
const param = node.params[0];
|
|
3839
|
-
if (param.type ===
|
|
3672
|
+
if (param.type === import_utils52.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3840
3673
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3841
3674
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3842
3675
|
context.report({
|
|
@@ -3856,11 +3689,11 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3856
3689
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3857
3690
|
|
|
3858
3691
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3859
|
-
var
|
|
3860
|
-
var
|
|
3692
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3693
|
+
var createRule48 = import_utils53.ESLintUtils.RuleCreator(
|
|
3861
3694
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3862
3695
|
);
|
|
3863
|
-
var preferJSXTemplateLiterals =
|
|
3696
|
+
var preferJSXTemplateLiterals = createRule48({
|
|
3864
3697
|
name: "prefer-jsx-template-literals",
|
|
3865
3698
|
meta: {
|
|
3866
3699
|
type: "suggestion",
|
|
@@ -3929,9 +3762,9 @@ var preferJSXTemplateLiterals = createRule51({
|
|
|
3929
3762
|
if (!child || !nextChild) {
|
|
3930
3763
|
return;
|
|
3931
3764
|
}
|
|
3932
|
-
if (child.type ===
|
|
3765
|
+
if (child.type === import_utils53.AST_NODE_TYPES.JSXText && nextChild.type === import_utils53.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3933
3766
|
handleTextBeforeExpression(child, nextChild);
|
|
3934
|
-
} else if (child.type ===
|
|
3767
|
+
} else if (child.type === import_utils53.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils53.AST_NODE_TYPES.JSXText) {
|
|
3935
3768
|
handleExpressionBeforeText(child, nextChild);
|
|
3936
3769
|
}
|
|
3937
3770
|
}
|
|
@@ -3944,11 +3777,32 @@ var preferJSXTemplateLiterals = createRule51({
|
|
|
3944
3777
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3945
3778
|
|
|
3946
3779
|
// src/rules/prefer-named-param-types.ts
|
|
3947
|
-
var
|
|
3948
|
-
var
|
|
3780
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3781
|
+
var createRule49 = import_utils54.ESLintUtils.RuleCreator(
|
|
3949
3782
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3950
3783
|
);
|
|
3951
|
-
var
|
|
3784
|
+
var returnsJsx2 = (node) => {
|
|
3785
|
+
if (node.type === import_utils54.AST_NODE_TYPES.JSXElement || node.type === import_utils54.AST_NODE_TYPES.JSXFragment) {
|
|
3786
|
+
return true;
|
|
3787
|
+
}
|
|
3788
|
+
if (node.type === import_utils54.AST_NODE_TYPES.ConditionalExpression) {
|
|
3789
|
+
return returnsJsx2(node.consequent) || returnsJsx2(node.alternate);
|
|
3790
|
+
}
|
|
3791
|
+
if (node.type === import_utils54.AST_NODE_TYPES.LogicalExpression) {
|
|
3792
|
+
return returnsJsx2(node.left) || returnsJsx2(node.right);
|
|
3793
|
+
}
|
|
3794
|
+
return false;
|
|
3795
|
+
};
|
|
3796
|
+
var bodyReturnsJsx2 = (body) => {
|
|
3797
|
+
if (body.type !== import_utils54.AST_NODE_TYPES.BlockStatement) {
|
|
3798
|
+
return returnsJsx2(body);
|
|
3799
|
+
}
|
|
3800
|
+
return body.body.some(
|
|
3801
|
+
(stmt) => stmt.type === import_utils54.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && returnsJsx2(stmt.argument)
|
|
3802
|
+
);
|
|
3803
|
+
};
|
|
3804
|
+
var isReactComponentFunction = (node) => bodyReturnsJsx2(node.body);
|
|
3805
|
+
var preferNamedParamTypes = createRule49({
|
|
3952
3806
|
name: "prefer-named-param-types",
|
|
3953
3807
|
meta: {
|
|
3954
3808
|
type: "suggestion",
|
|
@@ -3963,16 +3817,16 @@ var preferNamedParamTypes = createRule52({
|
|
|
3963
3817
|
defaultOptions: [],
|
|
3964
3818
|
create(context) {
|
|
3965
3819
|
function hasInlineObjectType(param) {
|
|
3966
|
-
if (param.type ===
|
|
3820
|
+
if (param.type === import_utils54.AST_NODE_TYPES.AssignmentPattern) {
|
|
3967
3821
|
return hasInlineObjectType(param.left);
|
|
3968
3822
|
}
|
|
3969
|
-
if (param.type ===
|
|
3970
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3823
|
+
if (param.type === import_utils54.AST_NODE_TYPES.ObjectPattern) {
|
|
3824
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3971
3825
|
return true;
|
|
3972
3826
|
}
|
|
3973
3827
|
}
|
|
3974
|
-
if (param.type ===
|
|
3975
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3828
|
+
if (param.type === import_utils54.AST_NODE_TYPES.Identifier) {
|
|
3829
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils54.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3976
3830
|
return true;
|
|
3977
3831
|
}
|
|
3978
3832
|
}
|
|
@@ -3985,6 +3839,9 @@ var preferNamedParamTypes = createRule52({
|
|
|
3985
3839
|
} else if ("value" in node && node.value) {
|
|
3986
3840
|
params = node.value.params;
|
|
3987
3841
|
}
|
|
3842
|
+
if ((node.type === import_utils54.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils54.AST_NODE_TYPES.FunctionExpression || node.type === import_utils54.AST_NODE_TYPES.ArrowFunctionExpression) && params.length === 1 && params[0].type === import_utils54.AST_NODE_TYPES.Identifier && isReactComponentFunction(node)) {
|
|
3843
|
+
return;
|
|
3844
|
+
}
|
|
3988
3845
|
params.forEach((param) => {
|
|
3989
3846
|
if (hasInlineObjectType(param)) {
|
|
3990
3847
|
context.report({
|
|
@@ -4005,12 +3862,91 @@ var preferNamedParamTypes = createRule52({
|
|
|
4005
3862
|
});
|
|
4006
3863
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
4007
3864
|
|
|
3865
|
+
// src/rules/prefer-props-with-children.ts
|
|
3866
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
3867
|
+
var createRule50 = import_utils55.ESLintUtils.RuleCreator(
|
|
3868
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3869
|
+
);
|
|
3870
|
+
var preferPropsWithChildren = createRule50({
|
|
3871
|
+
name: "prefer-props-with-children",
|
|
3872
|
+
meta: {
|
|
3873
|
+
type: "suggestion",
|
|
3874
|
+
docs: {
|
|
3875
|
+
description: "Prefer PropsWithChildren<T> over manually declaring children: ReactNode in component props"
|
|
3876
|
+
},
|
|
3877
|
+
schema: [],
|
|
3878
|
+
messages: {
|
|
3879
|
+
usePropsWithChildren: "Use 'PropsWithChildren<T>' instead of manually declaring 'children: ReactNode'."
|
|
3880
|
+
}
|
|
3881
|
+
},
|
|
3882
|
+
defaultOptions: [],
|
|
3883
|
+
create(context) {
|
|
3884
|
+
function isReactNodeType(typeNode) {
|
|
3885
|
+
if (!typeNode) {
|
|
3886
|
+
return false;
|
|
3887
|
+
}
|
|
3888
|
+
if (typeNode.type !== import_utils55.AST_NODE_TYPES.TSTypeReference) {
|
|
3889
|
+
return false;
|
|
3890
|
+
}
|
|
3891
|
+
const { typeName } = typeNode;
|
|
3892
|
+
if (typeName.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
3893
|
+
return typeName.name === "ReactNode";
|
|
3894
|
+
}
|
|
3895
|
+
if (typeName.type === import_utils55.AST_NODE_TYPES.TSQualifiedName && typeName.left.type === import_utils55.AST_NODE_TYPES.Identifier && typeName.left.name === "React" && typeName.right.type === import_utils55.AST_NODE_TYPES.Identifier && typeName.right.name === "ReactNode") {
|
|
3896
|
+
return true;
|
|
3897
|
+
}
|
|
3898
|
+
return false;
|
|
3899
|
+
}
|
|
3900
|
+
function findChildrenReactNode(members) {
|
|
3901
|
+
for (const member of members) {
|
|
3902
|
+
if (member.type !== import_utils55.AST_NODE_TYPES.TSPropertySignature) {
|
|
3903
|
+
continue;
|
|
3904
|
+
}
|
|
3905
|
+
if (member.key.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
3906
|
+
continue;
|
|
3907
|
+
}
|
|
3908
|
+
if (member.key.name !== "children") {
|
|
3909
|
+
continue;
|
|
3910
|
+
}
|
|
3911
|
+
if (!member.typeAnnotation) {
|
|
3912
|
+
continue;
|
|
3913
|
+
}
|
|
3914
|
+
if (isReactNodeType(member.typeAnnotation.typeAnnotation)) {
|
|
3915
|
+
return member;
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
return void 0;
|
|
3919
|
+
}
|
|
3920
|
+
return {
|
|
3921
|
+
TSInterfaceDeclaration(node) {
|
|
3922
|
+
const childrenMember = findChildrenReactNode(node.body.body);
|
|
3923
|
+
if (childrenMember) {
|
|
3924
|
+
context.report({
|
|
3925
|
+
node: childrenMember,
|
|
3926
|
+
messageId: "usePropsWithChildren"
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
},
|
|
3930
|
+
TSTypeLiteral(node) {
|
|
3931
|
+
const childrenMember = findChildrenReactNode(node.members);
|
|
3932
|
+
if (childrenMember) {
|
|
3933
|
+
context.report({
|
|
3934
|
+
node: childrenMember,
|
|
3935
|
+
messageId: "usePropsWithChildren"
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
};
|
|
3940
|
+
}
|
|
3941
|
+
});
|
|
3942
|
+
var prefer_props_with_children_default = preferPropsWithChildren;
|
|
3943
|
+
|
|
4008
3944
|
// src/rules/prefer-react-import-types.ts
|
|
4009
|
-
var
|
|
4010
|
-
var
|
|
3945
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
3946
|
+
var createRule51 = import_utils56.ESLintUtils.RuleCreator(
|
|
4011
3947
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4012
3948
|
);
|
|
4013
|
-
var preferReactImportTypes =
|
|
3949
|
+
var preferReactImportTypes = createRule51({
|
|
4014
3950
|
name: "prefer-react-import-types",
|
|
4015
3951
|
meta: {
|
|
4016
3952
|
type: "suggestion",
|
|
@@ -4086,7 +4022,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4086
4022
|
]);
|
|
4087
4023
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
4088
4024
|
function checkMemberExpression(node) {
|
|
4089
|
-
if (node.object.type ===
|
|
4025
|
+
if (node.object.type === import_utils56.AST_NODE_TYPES.Identifier && node.object.name === "React" && node.property.type === import_utils56.AST_NODE_TYPES.Identifier && allReactExports.has(node.property.name)) {
|
|
4090
4026
|
const typeName = node.property.name;
|
|
4091
4027
|
const isType = reactTypes.has(typeName);
|
|
4092
4028
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4103,7 +4039,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4103
4039
|
return {
|
|
4104
4040
|
MemberExpression: checkMemberExpression,
|
|
4105
4041
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
4106
|
-
if (node.left.type ===
|
|
4042
|
+
if (node.left.type === import_utils56.AST_NODE_TYPES.Identifier && node.left.name === "React" && node.right.type === import_utils56.AST_NODE_TYPES.Identifier && allReactExports.has(node.right.name)) {
|
|
4107
4043
|
const typeName = node.right.name;
|
|
4108
4044
|
const isType = reactTypes.has(typeName);
|
|
4109
4045
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4123,11 +4059,11 @@ var preferReactImportTypes = createRule53({
|
|
|
4123
4059
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4124
4060
|
|
|
4125
4061
|
// src/rules/react-props-destructure.ts
|
|
4126
|
-
var
|
|
4127
|
-
var
|
|
4062
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
4063
|
+
var createRule52 = import_utils57.ESLintUtils.RuleCreator(
|
|
4128
4064
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4129
4065
|
);
|
|
4130
|
-
var reactPropsDestructure =
|
|
4066
|
+
var reactPropsDestructure = createRule52({
|
|
4131
4067
|
name: "react-props-destructure",
|
|
4132
4068
|
meta: {
|
|
4133
4069
|
type: "suggestion",
|
|
@@ -4143,29 +4079,29 @@ var reactPropsDestructure = createRule54({
|
|
|
4143
4079
|
defaultOptions: [],
|
|
4144
4080
|
create(context) {
|
|
4145
4081
|
function hasJSXInConditional(node) {
|
|
4146
|
-
return node.consequent.type ===
|
|
4082
|
+
return node.consequent.type === import_utils57.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils57.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils57.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils57.AST_NODE_TYPES.JSXFragment;
|
|
4147
4083
|
}
|
|
4148
4084
|
function hasJSXInLogical(node) {
|
|
4149
|
-
return node.right.type ===
|
|
4085
|
+
return node.right.type === import_utils57.AST_NODE_TYPES.JSXElement || node.right.type === import_utils57.AST_NODE_TYPES.JSXFragment;
|
|
4150
4086
|
}
|
|
4151
4087
|
function hasJSXReturn(block) {
|
|
4152
4088
|
return block.body.some((stmt) => {
|
|
4153
|
-
if (stmt.type ===
|
|
4154
|
-
return stmt.argument.type ===
|
|
4089
|
+
if (stmt.type === import_utils57.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4090
|
+
return stmt.argument.type === import_utils57.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils57.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils57.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils57.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
4155
4091
|
}
|
|
4156
4092
|
return false;
|
|
4157
4093
|
});
|
|
4158
4094
|
}
|
|
4159
4095
|
function isReactComponent2(node) {
|
|
4160
|
-
if (node.type ===
|
|
4161
|
-
if (node.body.type ===
|
|
4096
|
+
if (node.type === import_utils57.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4097
|
+
if (node.body.type === import_utils57.AST_NODE_TYPES.JSXElement || node.body.type === import_utils57.AST_NODE_TYPES.JSXFragment) {
|
|
4162
4098
|
return true;
|
|
4163
4099
|
}
|
|
4164
|
-
if (node.body.type ===
|
|
4100
|
+
if (node.body.type === import_utils57.AST_NODE_TYPES.BlockStatement) {
|
|
4165
4101
|
return hasJSXReturn(node.body);
|
|
4166
4102
|
}
|
|
4167
|
-
} else if (node.type ===
|
|
4168
|
-
if (node.body && node.body.type ===
|
|
4103
|
+
} else if (node.type === import_utils57.AST_NODE_TYPES.FunctionExpression || node.type === import_utils57.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4104
|
+
if (node.body && node.body.type === import_utils57.AST_NODE_TYPES.BlockStatement) {
|
|
4169
4105
|
return hasJSXReturn(node.body);
|
|
4170
4106
|
}
|
|
4171
4107
|
}
|
|
@@ -4179,9 +4115,9 @@ var reactPropsDestructure = createRule54({
|
|
|
4179
4115
|
return;
|
|
4180
4116
|
}
|
|
4181
4117
|
const param = node.params[0];
|
|
4182
|
-
if (param.type ===
|
|
4183
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4184
|
-
if (prop.key.type ===
|
|
4118
|
+
if (param.type === import_utils57.AST_NODE_TYPES.ObjectPattern) {
|
|
4119
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils57.AST_NODE_TYPES.Property).map((prop) => {
|
|
4120
|
+
if (prop.key.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
4185
4121
|
return prop.key.name;
|
|
4186
4122
|
}
|
|
4187
4123
|
return null;
|
|
@@ -4208,57 +4144,57 @@ var reactPropsDestructure = createRule54({
|
|
|
4208
4144
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4209
4145
|
|
|
4210
4146
|
// src/rules/require-explicit-return-type.ts
|
|
4211
|
-
var
|
|
4212
|
-
var
|
|
4147
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
4148
|
+
var createRule53 = import_utils58.ESLintUtils.RuleCreator(
|
|
4213
4149
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4214
4150
|
);
|
|
4215
4151
|
var isReactComponent = (node) => {
|
|
4216
|
-
if (node.type ===
|
|
4152
|
+
if (node.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4217
4153
|
const { parent } = node;
|
|
4218
|
-
if (parent?.type ===
|
|
4154
|
+
if (parent?.type === import_utils58.AST_NODE_TYPES.VariableDeclarator) {
|
|
4219
4155
|
const { id } = parent;
|
|
4220
|
-
if (id.type ===
|
|
4156
|
+
if (id.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
4221
4157
|
return /^[A-Z]/.test(id.name);
|
|
4222
4158
|
}
|
|
4223
4159
|
}
|
|
4224
4160
|
}
|
|
4225
|
-
if (node.type ===
|
|
4161
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4226
4162
|
return /^[A-Z]/.test(node.id.name);
|
|
4227
4163
|
}
|
|
4228
4164
|
return false;
|
|
4229
4165
|
};
|
|
4230
4166
|
var isCallbackFunction = (node) => {
|
|
4231
|
-
if (node.type ===
|
|
4167
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4232
4168
|
return false;
|
|
4233
4169
|
}
|
|
4234
4170
|
const { parent } = node;
|
|
4235
4171
|
if (!parent) {
|
|
4236
4172
|
return false;
|
|
4237
4173
|
}
|
|
4238
|
-
if (parent.type ===
|
|
4174
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4239
4175
|
return true;
|
|
4240
4176
|
}
|
|
4241
|
-
if (parent.type ===
|
|
4177
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.Property) {
|
|
4242
4178
|
return true;
|
|
4243
4179
|
}
|
|
4244
|
-
if (parent.type ===
|
|
4180
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.ArrayExpression) {
|
|
4245
4181
|
return true;
|
|
4246
4182
|
}
|
|
4247
4183
|
return false;
|
|
4248
4184
|
};
|
|
4249
4185
|
var getFunctionName = (node) => {
|
|
4250
|
-
if (node.type ===
|
|
4186
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4251
4187
|
return node.id.name;
|
|
4252
4188
|
}
|
|
4253
|
-
if (node.type ===
|
|
4189
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4254
4190
|
return node.id.name;
|
|
4255
4191
|
}
|
|
4256
|
-
if ((node.type ===
|
|
4192
|
+
if ((node.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils58.AST_NODE_TYPES.FunctionExpression) && node.parent?.type === import_utils58.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
4257
4193
|
return node.parent.id.name;
|
|
4258
4194
|
}
|
|
4259
4195
|
return null;
|
|
4260
4196
|
};
|
|
4261
|
-
var requireExplicitReturnType =
|
|
4197
|
+
var requireExplicitReturnType = createRule53({
|
|
4262
4198
|
name: "require-explicit-return-type",
|
|
4263
4199
|
meta: {
|
|
4264
4200
|
type: "suggestion",
|
|
@@ -4307,8 +4243,8 @@ var requireExplicitReturnType = createRule55({
|
|
|
4307
4243
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4308
4244
|
|
|
4309
4245
|
// src/rules/sort-exports.ts
|
|
4310
|
-
var
|
|
4311
|
-
var
|
|
4246
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4247
|
+
var createRule54 = import_utils59.ESLintUtils.RuleCreator(
|
|
4312
4248
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4313
4249
|
);
|
|
4314
4250
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4322,7 +4258,7 @@ function getExportGroup(node) {
|
|
|
4322
4258
|
}
|
|
4323
4259
|
return 1;
|
|
4324
4260
|
}
|
|
4325
|
-
var sortExports =
|
|
4261
|
+
var sortExports = createRule54({
|
|
4326
4262
|
name: "sort-exports",
|
|
4327
4263
|
meta: {
|
|
4328
4264
|
type: "suggestion",
|
|
@@ -4362,7 +4298,7 @@ var sortExports = createRule56({
|
|
|
4362
4298
|
Program(node) {
|
|
4363
4299
|
const exportGroups = [];
|
|
4364
4300
|
node.body.forEach((statement) => {
|
|
4365
|
-
if (statement.type !==
|
|
4301
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4366
4302
|
if (exportGroups.length > 0) {
|
|
4367
4303
|
checkOrder(exportGroups);
|
|
4368
4304
|
exportGroups.length = 0;
|
|
@@ -4381,8 +4317,8 @@ var sortExports = createRule56({
|
|
|
4381
4317
|
var sort_exports_default = sortExports;
|
|
4382
4318
|
|
|
4383
4319
|
// src/rules/sort-imports.ts
|
|
4384
|
-
var
|
|
4385
|
-
var
|
|
4320
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4321
|
+
var createRule55 = import_utils60.ESLintUtils.RuleCreator(
|
|
4386
4322
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4387
4323
|
);
|
|
4388
4324
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4449,7 +4385,7 @@ function getImportGroup(node) {
|
|
|
4449
4385
|
function isTypeOnlyImport(node) {
|
|
4450
4386
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4451
4387
|
}
|
|
4452
|
-
var sortImports =
|
|
4388
|
+
var sortImports = createRule55({
|
|
4453
4389
|
name: "sort-imports",
|
|
4454
4390
|
meta: {
|
|
4455
4391
|
type: "suggestion",
|
|
@@ -4493,7 +4429,7 @@ var sortImports = createRule57({
|
|
|
4493
4429
|
Program(node) {
|
|
4494
4430
|
const importGroups = [];
|
|
4495
4431
|
node.body.forEach((statement) => {
|
|
4496
|
-
if (statement.type !==
|
|
4432
|
+
if (statement.type !== import_utils60.AST_NODE_TYPES.ImportDeclaration) {
|
|
4497
4433
|
if (importGroups.length > 0) {
|
|
4498
4434
|
checkOrder(importGroups);
|
|
4499
4435
|
importGroups.length = 0;
|
|
@@ -4515,13 +4451,13 @@ var sortImports = createRule57({
|
|
|
4515
4451
|
var sort_imports_default = sortImports;
|
|
4516
4452
|
|
|
4517
4453
|
// src/rules/sort-type-alphabetically.ts
|
|
4518
|
-
var
|
|
4519
|
-
var
|
|
4454
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
4455
|
+
var createRule56 = import_utils61.ESLintUtils.RuleCreator(
|
|
4520
4456
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4521
4457
|
);
|
|
4522
4458
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4523
4459
|
const properties = members.filter(
|
|
4524
|
-
(member) => member.type ===
|
|
4460
|
+
(member) => member.type === import_utils61.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils61.AST_NODE_TYPES.Identifier
|
|
4525
4461
|
);
|
|
4526
4462
|
if (properties.length < 2) {
|
|
4527
4463
|
return true;
|
|
@@ -4532,7 +4468,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4532
4468
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4533
4469
|
return isRequiredSorted && isOptionalSorted;
|
|
4534
4470
|
}
|
|
4535
|
-
var sortTypeAlphabetically =
|
|
4471
|
+
var sortTypeAlphabetically = createRule56({
|
|
4536
4472
|
name: "sort-type-alphabetically",
|
|
4537
4473
|
meta: {
|
|
4538
4474
|
type: "suggestion",
|
|
@@ -4550,7 +4486,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4550
4486
|
function fixMembers(fixer, members) {
|
|
4551
4487
|
const { sourceCode } = context;
|
|
4552
4488
|
const properties = members.filter(
|
|
4553
|
-
(member) => member.type ===
|
|
4489
|
+
(member) => member.type === import_utils61.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils61.AST_NODE_TYPES.Identifier
|
|
4554
4490
|
);
|
|
4555
4491
|
const required = properties.filter((prop) => !prop.optional);
|
|
4556
4492
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4587,7 +4523,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4587
4523
|
}
|
|
4588
4524
|
},
|
|
4589
4525
|
TSTypeAliasDeclaration(node) {
|
|
4590
|
-
if (node.typeAnnotation.type !==
|
|
4526
|
+
if (node.typeAnnotation.type !== import_utils61.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4591
4527
|
return;
|
|
4592
4528
|
}
|
|
4593
4529
|
const { members } = node.typeAnnotation;
|
|
@@ -4607,13 +4543,13 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4607
4543
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4608
4544
|
|
|
4609
4545
|
// src/rules/sort-type-required-first.ts
|
|
4610
|
-
var
|
|
4611
|
-
var
|
|
4546
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
4547
|
+
var createRule57 = import_utils62.ESLintUtils.RuleCreator(
|
|
4612
4548
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4613
4549
|
);
|
|
4614
4550
|
function isRequiredBeforeOptional(members) {
|
|
4615
4551
|
const properties = members.filter(
|
|
4616
|
-
(member) => member.type ===
|
|
4552
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4617
4553
|
);
|
|
4618
4554
|
if (properties.length < 2) {
|
|
4619
4555
|
return true;
|
|
@@ -4624,7 +4560,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4624
4560
|
}
|
|
4625
4561
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4626
4562
|
}
|
|
4627
|
-
var sortTypeRequiredFirst =
|
|
4563
|
+
var sortTypeRequiredFirst = createRule57({
|
|
4628
4564
|
name: "sort-type-required-first",
|
|
4629
4565
|
meta: {
|
|
4630
4566
|
type: "suggestion",
|
|
@@ -4642,7 +4578,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4642
4578
|
function fixMembers(fixer, members) {
|
|
4643
4579
|
const { sourceCode } = context;
|
|
4644
4580
|
const properties = members.filter(
|
|
4645
|
-
(member) => member.type ===
|
|
4581
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4646
4582
|
);
|
|
4647
4583
|
const required = properties.filter((prop) => !prop.optional);
|
|
4648
4584
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4663,7 +4599,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4663
4599
|
}
|
|
4664
4600
|
},
|
|
4665
4601
|
TSTypeAliasDeclaration(node) {
|
|
4666
|
-
if (node.typeAnnotation.type !==
|
|
4602
|
+
if (node.typeAnnotation.type !== import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4667
4603
|
return;
|
|
4668
4604
|
}
|
|
4669
4605
|
const { members } = node.typeAnnotation;
|
|
@@ -4691,7 +4627,6 @@ var rules = {
|
|
|
4691
4627
|
"boolean-naming-prefix": boolean_naming_prefix_default,
|
|
4692
4628
|
"enforce-camel-case": enforce_camel_case_default,
|
|
4693
4629
|
"enforce-constant-case": enforce_constant_case_default,
|
|
4694
|
-
"enforce-curly-newline": enforce_curly_newline_default,
|
|
4695
4630
|
"enforce-hook-naming": enforce_hook_naming_default,
|
|
4696
4631
|
"enforce-property-case": enforce_property_case_default,
|
|
4697
4632
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
@@ -4699,7 +4634,6 @@ var rules = {
|
|
|
4699
4634
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4700
4635
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4701
4636
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4702
|
-
"file-kebab-case": file_kebab_case_default,
|
|
4703
4637
|
"index-export-only": index_export_only_default,
|
|
4704
4638
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
4705
4639
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
@@ -4707,14 +4641,12 @@ var rules = {
|
|
|
4707
4641
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
4708
4642
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4709
4643
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4710
|
-
"jsx-pascal-case": jsx_pascal_case_default,
|
|
4711
4644
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
4712
4645
|
"jsx-simple-props": jsx_simple_props_default,
|
|
4713
4646
|
"jsx-sort-props": jsx_sort_props_default,
|
|
4714
4647
|
"jsx-spread-props-last": jsx_spread_props_last_default,
|
|
4715
4648
|
"newline-after-multiline-block": newline_after_multiline_block_default,
|
|
4716
4649
|
"newline-before-return": newline_before_return_default,
|
|
4717
|
-
"nextjs-require-public-env": nextjs_require_public_env_default,
|
|
4718
4650
|
"no-complex-inline-return": no_complex_inline_return_default,
|
|
4719
4651
|
"no-direct-date": no_direct_date_default,
|
|
4720
4652
|
"no-emoji": no_emoji_default,
|
|
@@ -4737,9 +4669,11 @@ var rules = {
|
|
|
4737
4669
|
"prefer-import-type": prefer_import_type_default,
|
|
4738
4670
|
"prefer-inline-literal-union": prefer_inline_literal_union_default,
|
|
4739
4671
|
"prefer-inline-type-export": prefer_inline_type_export_default,
|
|
4672
|
+
"prefer-interface-for-component-props": prefer_interface_for_component_props_default,
|
|
4740
4673
|
"prefer-interface-over-inline-types": prefer_interface_over_inline_types_default,
|
|
4741
4674
|
"prefer-jsx-template-literals": prefer_jsx_template_literals_default,
|
|
4742
4675
|
"prefer-named-param-types": prefer_named_param_types_default,
|
|
4676
|
+
"prefer-props-with-children": prefer_props_with_children_default,
|
|
4743
4677
|
"prefer-react-import-types": prefer_react_import_types_default,
|
|
4744
4678
|
"react-props-destructure": react_props_destructure_default,
|
|
4745
4679
|
"require-explicit-return-type": require_explicit_return_type_default,
|
|
@@ -4756,13 +4690,11 @@ var baseRules = {
|
|
|
4756
4690
|
"nextfriday/boolean-naming-prefix": "warn",
|
|
4757
4691
|
"nextfriday/enforce-camel-case": "warn",
|
|
4758
4692
|
"nextfriday/enforce-constant-case": "warn",
|
|
4759
|
-
"nextfriday/enforce-curly-newline": "warn",
|
|
4760
4693
|
"nextfriday/enforce-hook-naming": "warn",
|
|
4761
4694
|
"nextfriday/enforce-property-case": "warn",
|
|
4762
4695
|
"nextfriday/enforce-service-naming": "warn",
|
|
4763
4696
|
"nextfriday/enforce-sorted-destructuring": "warn",
|
|
4764
4697
|
"nextfriday/enforce-type-declaration-order": "warn",
|
|
4765
|
-
"nextfriday/file-kebab-case": "warn",
|
|
4766
4698
|
"nextfriday/index-export-only": "warn",
|
|
4767
4699
|
"nextfriday/newline-after-multiline-block": "warn",
|
|
4768
4700
|
"nextfriday/newline-before-return": "warn",
|
|
@@ -4800,13 +4732,11 @@ var baseRecommendedRules = {
|
|
|
4800
4732
|
"nextfriday/boolean-naming-prefix": "error",
|
|
4801
4733
|
"nextfriday/enforce-camel-case": "error",
|
|
4802
4734
|
"nextfriday/enforce-constant-case": "error",
|
|
4803
|
-
"nextfriday/enforce-curly-newline": "error",
|
|
4804
4735
|
"nextfriday/enforce-hook-naming": "error",
|
|
4805
4736
|
"nextfriday/enforce-property-case": "error",
|
|
4806
4737
|
"nextfriday/enforce-service-naming": "error",
|
|
4807
4738
|
"nextfriday/enforce-sorted-destructuring": "error",
|
|
4808
4739
|
"nextfriday/enforce-type-declaration-order": "error",
|
|
4809
|
-
"nextfriday/file-kebab-case": "error",
|
|
4810
4740
|
"nextfriday/index-export-only": "error",
|
|
4811
4741
|
"nextfriday/newline-after-multiline-block": "error",
|
|
4812
4742
|
"nextfriday/newline-before-return": "error",
|
|
@@ -4849,13 +4779,14 @@ var jsxRules = {
|
|
|
4849
4779
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
4850
4780
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4851
4781
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4852
|
-
"nextfriday/jsx-pascal-case": "warn",
|
|
4853
4782
|
"nextfriday/jsx-require-suspense": "warn",
|
|
4854
4783
|
"nextfriday/jsx-simple-props": "warn",
|
|
4855
4784
|
"nextfriday/jsx-sort-props": "warn",
|
|
4856
4785
|
"nextfriday/jsx-spread-props-last": "warn",
|
|
4786
|
+
"nextfriday/prefer-interface-for-component-props": "warn",
|
|
4857
4787
|
"nextfriday/prefer-interface-over-inline-types": "warn",
|
|
4858
4788
|
"nextfriday/prefer-jsx-template-literals": "warn",
|
|
4789
|
+
"nextfriday/prefer-props-with-children": "warn",
|
|
4859
4790
|
"nextfriday/react-props-destructure": "warn"
|
|
4860
4791
|
};
|
|
4861
4792
|
var jsxRecommendedRules = {
|
|
@@ -4867,41 +4798,22 @@ var jsxRecommendedRules = {
|
|
|
4867
4798
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
4868
4799
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4869
4800
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4870
|
-
"nextfriday/jsx-pascal-case": "error",
|
|
4871
4801
|
"nextfriday/jsx-require-suspense": "error",
|
|
4872
4802
|
"nextfriday/jsx-simple-props": "error",
|
|
4873
4803
|
"nextfriday/jsx-sort-props": "error",
|
|
4874
4804
|
"nextfriday/jsx-spread-props-last": "error",
|
|
4805
|
+
"nextfriday/prefer-interface-for-component-props": "error",
|
|
4875
4806
|
"nextfriday/prefer-interface-over-inline-types": "error",
|
|
4876
4807
|
"nextfriday/prefer-jsx-template-literals": "error",
|
|
4808
|
+
"nextfriday/prefer-props-with-children": "error",
|
|
4877
4809
|
"nextfriday/react-props-destructure": "error"
|
|
4878
4810
|
};
|
|
4879
|
-
var nextjsOnlyRules = {
|
|
4880
|
-
"nextfriday/nextjs-require-public-env": "warn"
|
|
4881
|
-
};
|
|
4882
|
-
var nextjsOnlyRecommendedRules = {
|
|
4883
|
-
"nextfriday/nextjs-require-public-env": "error"
|
|
4884
|
-
};
|
|
4885
4811
|
var createConfig = (configRules) => ({
|
|
4886
4812
|
plugins: {
|
|
4887
4813
|
nextfriday: plugin
|
|
4888
4814
|
},
|
|
4889
4815
|
rules: configRules
|
|
4890
4816
|
});
|
|
4891
|
-
var NEXTJS_ROUTING_GLOBS = [
|
|
4892
|
-
"app/**/*.{js,jsx,ts,tsx}",
|
|
4893
|
-
"src/app/**/*.{js,jsx,ts,tsx}",
|
|
4894
|
-
"pages/**/*.{js,jsx,ts,tsx}",
|
|
4895
|
-
"src/pages/**/*.{js,jsx,ts,tsx}"
|
|
4896
|
-
];
|
|
4897
|
-
var nextjsRoutingOverride = {
|
|
4898
|
-
files: NEXTJS_ROUTING_GLOBS,
|
|
4899
|
-
rules: {
|
|
4900
|
-
"nextfriday/file-kebab-case": "off",
|
|
4901
|
-
"nextfriday/jsx-pascal-case": "off"
|
|
4902
|
-
}
|
|
4903
|
-
};
|
|
4904
|
-
var createNextjsConfig = (configRules) => [createConfig(configRules), nextjsRoutingOverride];
|
|
4905
4817
|
var configs = {
|
|
4906
4818
|
base: createConfig(baseRules),
|
|
4907
4819
|
"base/recommended": createConfig(baseRecommendedRules),
|
|
@@ -4913,15 +4825,13 @@ var configs = {
|
|
|
4913
4825
|
...baseRecommendedRules,
|
|
4914
4826
|
...jsxRecommendedRules
|
|
4915
4827
|
}),
|
|
4916
|
-
nextjs:
|
|
4828
|
+
nextjs: createConfig({
|
|
4917
4829
|
...baseRules,
|
|
4918
|
-
...jsxRules
|
|
4919
|
-
...nextjsOnlyRules
|
|
4830
|
+
...jsxRules
|
|
4920
4831
|
}),
|
|
4921
|
-
"nextjs/recommended":
|
|
4832
|
+
"nextjs/recommended": createConfig({
|
|
4922
4833
|
...baseRecommendedRules,
|
|
4923
|
-
...jsxRecommendedRules
|
|
4924
|
-
...nextjsOnlyRecommendedRules
|
|
4834
|
+
...jsxRecommendedRules
|
|
4925
4835
|
})
|
|
4926
4836
|
};
|
|
4927
4837
|
var nextfridayPlugin = {
|