eslint-plugin-nextfriday 3.2.1 → 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 +16 -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/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 +657 -714
- 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 +624 -681
- 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);
|
|
@@ -521,84 +525,13 @@ var enforceConstantCase = createRule3({
|
|
|
521
525
|
});
|
|
522
526
|
var enforce_constant_case_default = enforceConstantCase;
|
|
523
527
|
|
|
524
|
-
// src/rules/enforce-curly-newline.ts
|
|
525
|
-
var import_utils6 = require("@typescript-eslint/utils");
|
|
526
|
-
var createRule4 = import_utils6.ESLintUtils.RuleCreator(
|
|
527
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
528
|
-
);
|
|
529
|
-
var enforceCurlyNewline = createRule4({
|
|
530
|
-
name: "enforce-curly-newline",
|
|
531
|
-
meta: {
|
|
532
|
-
type: "layout",
|
|
533
|
-
docs: {
|
|
534
|
-
description: "Enforce curly braces for multi-line if statements and forbid them for single-line"
|
|
535
|
-
},
|
|
536
|
-
fixable: "code",
|
|
537
|
-
messages: {
|
|
538
|
-
requireBraces: "Multi-line if statements must use curly braces.",
|
|
539
|
-
forbidBraces: "Single-line if statements must not use curly braces."
|
|
540
|
-
},
|
|
541
|
-
schema: []
|
|
542
|
-
},
|
|
543
|
-
defaultOptions: [],
|
|
544
|
-
create(context) {
|
|
545
|
-
const { sourceCode } = context;
|
|
546
|
-
return {
|
|
547
|
-
IfStatement(node) {
|
|
548
|
-
const { consequent } = node;
|
|
549
|
-
const startLine = node.loc.start.line;
|
|
550
|
-
const endLine = node.loc.end.line;
|
|
551
|
-
const isSingleLine2 = startLine === endLine;
|
|
552
|
-
const hasBraces = consequent.type === import_utils6.AST_NODE_TYPES.BlockStatement;
|
|
553
|
-
if (isSingleLine2 && hasBraces) {
|
|
554
|
-
if (consequent.body.length !== 1) {
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
const innerStatement = consequent.body[0];
|
|
558
|
-
const innerText = sourceCode.getText(innerStatement);
|
|
559
|
-
context.report({
|
|
560
|
-
node: consequent,
|
|
561
|
-
messageId: "forbidBraces",
|
|
562
|
-
fix(fixer) {
|
|
563
|
-
return fixer.replaceText(consequent, innerText);
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
if (!isSingleLine2 && !hasBraces) {
|
|
568
|
-
context.report({
|
|
569
|
-
node: consequent,
|
|
570
|
-
messageId: "requireBraces",
|
|
571
|
-
fix(fixer) {
|
|
572
|
-
const consequentText = sourceCode.getText(consequent);
|
|
573
|
-
const closingParen = sourceCode.getTokenBefore(consequent);
|
|
574
|
-
if (!closingParen) {
|
|
575
|
-
return null;
|
|
576
|
-
}
|
|
577
|
-
const ifStartLine = sourceCode.lines[startLine - 1];
|
|
578
|
-
const indentRegex = /^(\s*)/;
|
|
579
|
-
const indentMatch = indentRegex.exec(ifStartLine);
|
|
580
|
-
const baseIndent = indentMatch ? indentMatch[1] : "";
|
|
581
|
-
const bodyIndent = `${baseIndent} `;
|
|
582
|
-
const newText = ` {
|
|
583
|
-
${bodyIndent}${consequentText.trim()}
|
|
584
|
-
${baseIndent}}`;
|
|
585
|
-
return fixer.replaceTextRange([closingParen.range[1], consequent.range[1]], newText);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
var enforce_curly_newline_default = enforceCurlyNewline;
|
|
594
|
-
|
|
595
528
|
// src/rules/enforce-hook-naming.ts
|
|
596
529
|
var import_path = __toESM(require("path"), 1);
|
|
597
|
-
var
|
|
598
|
-
var
|
|
530
|
+
var import_utils6 = require("@typescript-eslint/utils");
|
|
531
|
+
var createRule4 = import_utils6.ESLintUtils.RuleCreator(
|
|
599
532
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
600
533
|
);
|
|
601
|
-
var enforceHookNaming =
|
|
534
|
+
var enforceHookNaming = createRule4({
|
|
602
535
|
name: "enforce-hook-naming",
|
|
603
536
|
meta: {
|
|
604
537
|
type: "suggestion",
|
|
@@ -637,22 +570,22 @@ var enforceHookNaming = createRule5({
|
|
|
637
570
|
};
|
|
638
571
|
return {
|
|
639
572
|
ExportNamedDeclaration(node) {
|
|
640
|
-
if (node.declaration?.type ===
|
|
573
|
+
if (node.declaration?.type === import_utils6.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
641
574
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "missingUsePrefix");
|
|
642
575
|
}
|
|
643
|
-
if (node.declaration?.type ===
|
|
576
|
+
if (node.declaration?.type === import_utils6.AST_NODE_TYPES.VariableDeclaration) {
|
|
644
577
|
node.declaration.declarations.forEach((declarator) => {
|
|
645
|
-
if (declarator.id.type ===
|
|
578
|
+
if (declarator.id.type === import_utils6.AST_NODE_TYPES.Identifier) {
|
|
646
579
|
checkFunctionName(declarator.id.name, declarator.id, "missingUsePrefix");
|
|
647
580
|
}
|
|
648
581
|
});
|
|
649
582
|
}
|
|
650
583
|
},
|
|
651
584
|
ExportDefaultDeclaration(node) {
|
|
652
|
-
if (node.declaration.type ===
|
|
585
|
+
if (node.declaration.type === import_utils6.AST_NODE_TYPES.Identifier) {
|
|
653
586
|
checkFunctionName(node.declaration.name, node.declaration, "defaultExportMissingUsePrefix");
|
|
654
587
|
}
|
|
655
|
-
if (node.declaration.type ===
|
|
588
|
+
if (node.declaration.type === import_utils6.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
656
589
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "defaultExportMissingUsePrefix");
|
|
657
590
|
}
|
|
658
591
|
}
|
|
@@ -662,26 +595,26 @@ var enforceHookNaming = createRule5({
|
|
|
662
595
|
var enforce_hook_naming_default = enforceHookNaming;
|
|
663
596
|
|
|
664
597
|
// src/rules/enforce-property-case.ts
|
|
665
|
-
var
|
|
666
|
-
var
|
|
598
|
+
var import_utils7 = require("@typescript-eslint/utils");
|
|
599
|
+
var createRule5 = import_utils7.ESLintUtils.RuleCreator(
|
|
667
600
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
668
601
|
);
|
|
669
602
|
var SNAKE_CASE_REGEX3 = /^[a-z]+_[a-z0-9_]*$/;
|
|
670
603
|
var SCREAMING_SNAKE_CASE_REGEX2 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
671
604
|
var isInsideAsConst = (node) => {
|
|
672
605
|
const { parent } = node;
|
|
673
|
-
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") {
|
|
674
607
|
return true;
|
|
675
608
|
}
|
|
676
|
-
if (parent.type ===
|
|
609
|
+
if (parent.type === import_utils7.AST_NODE_TYPES.ArrayExpression) {
|
|
677
610
|
const grandparent = parent.parent;
|
|
678
|
-
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") {
|
|
679
612
|
return true;
|
|
680
613
|
}
|
|
681
614
|
}
|
|
682
615
|
return false;
|
|
683
616
|
};
|
|
684
|
-
var enforcePropertyCase =
|
|
617
|
+
var enforcePropertyCase = createRule5({
|
|
685
618
|
name: "enforce-property-case",
|
|
686
619
|
meta: {
|
|
687
620
|
type: "suggestion",
|
|
@@ -697,7 +630,7 @@ var enforcePropertyCase = createRule6({
|
|
|
697
630
|
create(context) {
|
|
698
631
|
return {
|
|
699
632
|
Property(node) {
|
|
700
|
-
if (node.parent.type !==
|
|
633
|
+
if (node.parent.type !== import_utils7.AST_NODE_TYPES.ObjectExpression) {
|
|
701
634
|
return;
|
|
702
635
|
}
|
|
703
636
|
if (isInsideAsConst(node.parent)) {
|
|
@@ -706,7 +639,7 @@ var enforcePropertyCase = createRule6({
|
|
|
706
639
|
if (node.computed) {
|
|
707
640
|
return;
|
|
708
641
|
}
|
|
709
|
-
if (node.key.type !==
|
|
642
|
+
if (node.key.type !== import_utils7.AST_NODE_TYPES.Identifier) {
|
|
710
643
|
return;
|
|
711
644
|
}
|
|
712
645
|
const { name } = node.key;
|
|
@@ -725,11 +658,11 @@ var enforce_property_case_default = enforcePropertyCase;
|
|
|
725
658
|
|
|
726
659
|
// src/rules/enforce-props-suffix.ts
|
|
727
660
|
var import_path2 = __toESM(require("path"), 1);
|
|
728
|
-
var
|
|
729
|
-
var
|
|
661
|
+
var import_utils8 = require("@typescript-eslint/utils");
|
|
662
|
+
var createRule6 = import_utils8.ESLintUtils.RuleCreator(
|
|
730
663
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
731
664
|
);
|
|
732
|
-
var enforcePropsSuffix =
|
|
665
|
+
var enforcePropsSuffix = createRule6({
|
|
733
666
|
name: "enforce-props-suffix",
|
|
734
667
|
meta: {
|
|
735
668
|
type: "suggestion",
|
|
@@ -763,13 +696,13 @@ var enforcePropsSuffix = createRule7({
|
|
|
763
696
|
};
|
|
764
697
|
return {
|
|
765
698
|
TSInterfaceDeclaration(node) {
|
|
766
|
-
if (node.id.type ===
|
|
699
|
+
if (node.id.type === import_utils8.AST_NODE_TYPES.Identifier) {
|
|
767
700
|
checkTypeName(node.id.name, node.id);
|
|
768
701
|
}
|
|
769
702
|
},
|
|
770
703
|
TSTypeAliasDeclaration(node) {
|
|
771
|
-
if (node.id.type ===
|
|
772
|
-
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) {
|
|
773
706
|
checkTypeName(node.id.name, node.id);
|
|
774
707
|
}
|
|
775
708
|
}
|
|
@@ -780,11 +713,11 @@ var enforcePropsSuffix = createRule7({
|
|
|
780
713
|
var enforce_props_suffix_default = enforcePropsSuffix;
|
|
781
714
|
|
|
782
715
|
// src/rules/enforce-readonly-component-props.ts
|
|
783
|
-
var
|
|
784
|
-
var
|
|
716
|
+
var import_utils9 = require("@typescript-eslint/utils");
|
|
717
|
+
var createRule7 = import_utils9.ESLintUtils.RuleCreator(
|
|
785
718
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
786
719
|
);
|
|
787
|
-
var enforceReadonlyComponentProps =
|
|
720
|
+
var enforceReadonlyComponentProps = createRule7({
|
|
788
721
|
name: "enforce-readonly-component-props",
|
|
789
722
|
meta: {
|
|
790
723
|
type: "suggestion",
|
|
@@ -800,40 +733,40 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
800
733
|
defaultOptions: [],
|
|
801
734
|
create(context) {
|
|
802
735
|
function hasJSXInConditional(node) {
|
|
803
|
-
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;
|
|
804
737
|
}
|
|
805
738
|
function hasJSXInLogical(node) {
|
|
806
|
-
return node.right.type ===
|
|
739
|
+
return node.right.type === import_utils9.AST_NODE_TYPES.JSXElement || node.right.type === import_utils9.AST_NODE_TYPES.JSXFragment;
|
|
807
740
|
}
|
|
808
741
|
function hasJSXReturn(block) {
|
|
809
742
|
return block.body.some((stmt) => {
|
|
810
|
-
if (stmt.type ===
|
|
811
|
-
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);
|
|
812
745
|
}
|
|
813
746
|
return false;
|
|
814
747
|
});
|
|
815
748
|
}
|
|
816
749
|
function isReactComponent2(node) {
|
|
817
|
-
if (node.type ===
|
|
818
|
-
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) {
|
|
819
752
|
return true;
|
|
820
753
|
}
|
|
821
|
-
if (node.body.type ===
|
|
754
|
+
if (node.body.type === import_utils9.AST_NODE_TYPES.BlockStatement) {
|
|
822
755
|
return hasJSXReturn(node.body);
|
|
823
756
|
}
|
|
824
|
-
} else if (node.type ===
|
|
825
|
-
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) {
|
|
826
759
|
return hasJSXReturn(node.body);
|
|
827
760
|
}
|
|
828
761
|
}
|
|
829
762
|
return false;
|
|
830
763
|
}
|
|
831
764
|
function isNamedType(node) {
|
|
832
|
-
return node.type ===
|
|
765
|
+
return node.type === import_utils9.AST_NODE_TYPES.TSTypeReference;
|
|
833
766
|
}
|
|
834
767
|
function isAlreadyReadonly(node) {
|
|
835
|
-
if (node.type ===
|
|
836
|
-
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") {
|
|
837
770
|
return true;
|
|
838
771
|
}
|
|
839
772
|
}
|
|
@@ -847,7 +780,7 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
847
780
|
return;
|
|
848
781
|
}
|
|
849
782
|
const param = node.params[0];
|
|
850
|
-
if (param.type ===
|
|
783
|
+
if (param.type === import_utils9.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
851
784
|
const { typeAnnotation } = param.typeAnnotation;
|
|
852
785
|
if (isNamedType(typeAnnotation) && !isAlreadyReadonly(typeAnnotation)) {
|
|
853
786
|
const { sourceCode } = context;
|
|
@@ -872,8 +805,8 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
872
805
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
873
806
|
|
|
874
807
|
// src/rules/enforce-service-naming.ts
|
|
875
|
-
var
|
|
876
|
-
var
|
|
808
|
+
var import_utils10 = require("@typescript-eslint/utils");
|
|
809
|
+
var createRule8 = import_utils10.ESLintUtils.RuleCreator(
|
|
877
810
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
878
811
|
);
|
|
879
812
|
var BANNED_PREFIXES = {
|
|
@@ -882,7 +815,7 @@ var BANNED_PREFIXES = {
|
|
|
882
815
|
handle: ["create", "verify"],
|
|
883
816
|
set: ["update", "save", "patch"]
|
|
884
817
|
};
|
|
885
|
-
var enforceServiceNaming =
|
|
818
|
+
var enforceServiceNaming = createRule8({
|
|
886
819
|
name: "enforce-service-naming",
|
|
887
820
|
meta: {
|
|
888
821
|
type: "suggestion",
|
|
@@ -925,12 +858,12 @@ var enforceServiceNaming = createRule9({
|
|
|
925
858
|
};
|
|
926
859
|
return {
|
|
927
860
|
ExportNamedDeclaration(node) {
|
|
928
|
-
if (node.declaration?.type ===
|
|
861
|
+
if (node.declaration?.type === import_utils10.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
929
862
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
930
863
|
}
|
|
931
|
-
if (node.declaration?.type ===
|
|
864
|
+
if (node.declaration?.type === import_utils10.AST_NODE_TYPES.VariableDeclaration) {
|
|
932
865
|
node.declaration.declarations.forEach((declarator) => {
|
|
933
|
-
if (declarator.id.type ===
|
|
866
|
+
if (declarator.id.type === import_utils10.AST_NODE_TYPES.Identifier && declarator.init?.type === import_utils10.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
934
867
|
checkExportedFunction(declarator.init, declarator.id);
|
|
935
868
|
}
|
|
936
869
|
});
|
|
@@ -942,11 +875,11 @@ var enforceServiceNaming = createRule9({
|
|
|
942
875
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
943
876
|
|
|
944
877
|
// src/rules/enforce-sorted-destructuring.ts
|
|
945
|
-
var
|
|
946
|
-
var
|
|
878
|
+
var import_utils11 = require("@typescript-eslint/utils");
|
|
879
|
+
var createRule9 = import_utils11.ESLintUtils.RuleCreator(
|
|
947
880
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
948
881
|
);
|
|
949
|
-
var enforceSortedDestructuring =
|
|
882
|
+
var enforceSortedDestructuring = createRule9({
|
|
950
883
|
name: "enforce-sorted-destructuring",
|
|
951
884
|
meta: {
|
|
952
885
|
type: "suggestion",
|
|
@@ -962,19 +895,19 @@ var enforceSortedDestructuring = createRule10({
|
|
|
962
895
|
defaultOptions: [],
|
|
963
896
|
create(context) {
|
|
964
897
|
function getPropertyName(property) {
|
|
965
|
-
if (property.type ===
|
|
898
|
+
if (property.type === import_utils11.AST_NODE_TYPES.RestElement) {
|
|
966
899
|
return null;
|
|
967
900
|
}
|
|
968
|
-
if (property.key.type ===
|
|
901
|
+
if (property.key.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
969
902
|
return property.key.name;
|
|
970
903
|
}
|
|
971
904
|
return null;
|
|
972
905
|
}
|
|
973
906
|
function hasDefaultValue(property) {
|
|
974
|
-
return property.value.type ===
|
|
907
|
+
return property.value.type === import_utils11.AST_NODE_TYPES.AssignmentPattern && Boolean(property.value.right);
|
|
975
908
|
}
|
|
976
909
|
function checkVariableDeclarator(node) {
|
|
977
|
-
if (node.id.type !==
|
|
910
|
+
if (node.id.type !== import_utils11.AST_NODE_TYPES.ObjectPattern) {
|
|
978
911
|
return;
|
|
979
912
|
}
|
|
980
913
|
const { properties } = node.id;
|
|
@@ -982,7 +915,7 @@ var enforceSortedDestructuring = createRule10({
|
|
|
982
915
|
return;
|
|
983
916
|
}
|
|
984
917
|
const propertyInfo = properties.map((prop) => {
|
|
985
|
-
if (prop.type ===
|
|
918
|
+
if (prop.type === import_utils11.AST_NODE_TYPES.RestElement) {
|
|
986
919
|
return null;
|
|
987
920
|
}
|
|
988
921
|
return {
|
|
@@ -1021,20 +954,20 @@ var enforceSortedDestructuring = createRule10({
|
|
|
1021
954
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
1022
955
|
|
|
1023
956
|
// src/rules/enforce-type-declaration-order.ts
|
|
1024
|
-
var
|
|
1025
|
-
var
|
|
957
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
958
|
+
var createRule10 = import_utils12.ESLintUtils.RuleCreator(
|
|
1026
959
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1027
960
|
);
|
|
1028
961
|
function getTypeDeclarationName(node) {
|
|
1029
|
-
if (node.type ===
|
|
962
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSInterfaceDeclaration && node.id.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1030
963
|
return { name: node.id.name, position: node.range[0] };
|
|
1031
964
|
}
|
|
1032
|
-
if (node.type ===
|
|
965
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSTypeAliasDeclaration && node.id.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1033
966
|
return { name: node.id.name, position: node.range[0] };
|
|
1034
967
|
}
|
|
1035
968
|
return null;
|
|
1036
969
|
}
|
|
1037
|
-
var enforceTypeDeclarationOrder =
|
|
970
|
+
var enforceTypeDeclarationOrder = createRule10({
|
|
1038
971
|
name: "enforce-type-declaration-order",
|
|
1039
972
|
meta: {
|
|
1040
973
|
type: "suggestion",
|
|
@@ -1065,7 +998,7 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1065
998
|
}
|
|
1066
999
|
},
|
|
1067
1000
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
1068
|
-
if (node.typeName.type !==
|
|
1001
|
+
if (node.typeName.type !== import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1069
1002
|
return;
|
|
1070
1003
|
}
|
|
1071
1004
|
const referencedName = node.typeName.name;
|
|
@@ -1101,55 +1034,9 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1101
1034
|
});
|
|
1102
1035
|
var enforce_type_declaration_order_default = enforceTypeDeclarationOrder;
|
|
1103
1036
|
|
|
1104
|
-
// src/rules/file-kebab-case.ts
|
|
1105
|
-
var import_path3 = __toESM(require("path"), 1);
|
|
1106
|
-
var import_utils14 = require("@typescript-eslint/utils");
|
|
1107
|
-
var createRule12 = import_utils14.ESLintUtils.RuleCreator(
|
|
1108
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1109
|
-
);
|
|
1110
|
-
var isKebabCase = (str) => {
|
|
1111
|
-
if (/\.(config|rc|setup|spec|test)$/.test(str) || /^[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*$/.test(str)) {
|
|
1112
|
-
return /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)*$/.test(str);
|
|
1113
|
-
}
|
|
1114
|
-
return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(str);
|
|
1115
|
-
};
|
|
1116
|
-
var fileKebabCase = createRule12({
|
|
1117
|
-
name: "file-kebab-case",
|
|
1118
|
-
meta: {
|
|
1119
|
-
type: "problem",
|
|
1120
|
-
docs: {
|
|
1121
|
-
description: "Enforce kebab-case filenames for .ts and .js files"
|
|
1122
|
-
},
|
|
1123
|
-
messages: {
|
|
1124
|
-
fileKebabCase: "File names must be kebab-case"
|
|
1125
|
-
},
|
|
1126
|
-
schema: []
|
|
1127
|
-
},
|
|
1128
|
-
defaultOptions: [],
|
|
1129
|
-
create(context) {
|
|
1130
|
-
return {
|
|
1131
|
-
Program() {
|
|
1132
|
-
const { filename } = context;
|
|
1133
|
-
const ext = import_path3.default.extname(filename);
|
|
1134
|
-
if (ext !== ".ts" && ext !== ".js") {
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
const basename2 = import_path3.default.basename(filename, ext);
|
|
1138
|
-
if (!isKebabCase(basename2)) {
|
|
1139
|
-
context.report({
|
|
1140
|
-
loc: { line: 1, column: 0 },
|
|
1141
|
-
messageId: "fileKebabCase"
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
});
|
|
1148
|
-
var file_kebab_case_default = fileKebabCase;
|
|
1149
|
-
|
|
1150
1037
|
// src/rules/index-export-only.ts
|
|
1151
|
-
var
|
|
1152
|
-
var
|
|
1038
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
1039
|
+
var createRule11 = import_utils13.ESLintUtils.RuleCreator(
|
|
1153
1040
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1154
1041
|
);
|
|
1155
1042
|
var isIndexFile = (filename) => getBaseName(filename) === "index";
|
|
@@ -1157,26 +1044,26 @@ var isAllowedExportNamed = (node) => {
|
|
|
1157
1044
|
if (!node.declaration) {
|
|
1158
1045
|
return true;
|
|
1159
1046
|
}
|
|
1160
|
-
return node.declaration.type ===
|
|
1047
|
+
return node.declaration.type === import_utils13.AST_NODE_TYPES.TSTypeAliasDeclaration || node.declaration.type === import_utils13.AST_NODE_TYPES.TSInterfaceDeclaration;
|
|
1161
1048
|
};
|
|
1162
|
-
var isAllowedExportDefault = (node) => node.declaration.type ===
|
|
1049
|
+
var isAllowedExportDefault = (node) => node.declaration.type === import_utils13.AST_NODE_TYPES.Identifier;
|
|
1163
1050
|
var isAllowedTopLevel = (node) => {
|
|
1164
1051
|
switch (node.type) {
|
|
1165
|
-
case
|
|
1166
|
-
case
|
|
1167
|
-
case
|
|
1168
|
-
case
|
|
1169
|
-
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:
|
|
1170
1057
|
return true;
|
|
1171
|
-
case
|
|
1058
|
+
case import_utils13.AST_NODE_TYPES.ExportNamedDeclaration:
|
|
1172
1059
|
return isAllowedExportNamed(node);
|
|
1173
|
-
case
|
|
1060
|
+
case import_utils13.AST_NODE_TYPES.ExportDefaultDeclaration:
|
|
1174
1061
|
return isAllowedExportDefault(node);
|
|
1175
1062
|
default:
|
|
1176
1063
|
return false;
|
|
1177
1064
|
}
|
|
1178
1065
|
};
|
|
1179
|
-
var indexExportOnly =
|
|
1066
|
+
var indexExportOnly = createRule11({
|
|
1180
1067
|
name: "index-export-only",
|
|
1181
1068
|
meta: {
|
|
1182
1069
|
type: "suggestion",
|
|
@@ -1210,11 +1097,11 @@ var indexExportOnly = createRule13({
|
|
|
1210
1097
|
var index_export_only_default = indexExportOnly;
|
|
1211
1098
|
|
|
1212
1099
|
// src/rules/jsx-newline-between-elements.ts
|
|
1213
|
-
var
|
|
1214
|
-
var
|
|
1100
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
1101
|
+
var createRule12 = import_utils15.ESLintUtils.RuleCreator(
|
|
1215
1102
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1216
1103
|
);
|
|
1217
|
-
var jsxNewlineBetweenElements =
|
|
1104
|
+
var jsxNewlineBetweenElements = createRule12({
|
|
1218
1105
|
name: "jsx-newline-between-elements",
|
|
1219
1106
|
meta: {
|
|
1220
1107
|
type: "layout",
|
|
@@ -1232,7 +1119,7 @@ var jsxNewlineBetweenElements = createRule14({
|
|
|
1232
1119
|
create(context) {
|
|
1233
1120
|
const { sourceCode } = context;
|
|
1234
1121
|
function isSignificantJSXChild(node) {
|
|
1235
|
-
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;
|
|
1236
1123
|
}
|
|
1237
1124
|
function isMultiLine(node) {
|
|
1238
1125
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1282,11 +1169,11 @@ var jsxNewlineBetweenElements = createRule14({
|
|
|
1282
1169
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1283
1170
|
|
|
1284
1171
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1285
|
-
var
|
|
1286
|
-
var
|
|
1172
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
1173
|
+
var createRule13 = import_utils16.ESLintUtils.RuleCreator(
|
|
1287
1174
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1288
1175
|
);
|
|
1289
|
-
var jsxNoInlineObjectProp =
|
|
1176
|
+
var jsxNoInlineObjectProp = createRule13({
|
|
1290
1177
|
name: "jsx-no-inline-object-prop",
|
|
1291
1178
|
meta: {
|
|
1292
1179
|
type: "suggestion",
|
|
@@ -1302,7 +1189,7 @@ var jsxNoInlineObjectProp = createRule15({
|
|
|
1302
1189
|
create(context) {
|
|
1303
1190
|
return {
|
|
1304
1191
|
JSXAttribute(node) {
|
|
1305
|
-
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) {
|
|
1306
1193
|
context.report({
|
|
1307
1194
|
node: node.value,
|
|
1308
1195
|
messageId: "noInlineObject"
|
|
@@ -1315,17 +1202,17 @@ var jsxNoInlineObjectProp = createRule15({
|
|
|
1315
1202
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1316
1203
|
|
|
1317
1204
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1318
|
-
var
|
|
1319
|
-
var
|
|
1205
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
1206
|
+
var createRule14 = import_utils17.ESLintUtils.RuleCreator(
|
|
1320
1207
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1321
1208
|
);
|
|
1322
1209
|
function isJSXElementOrFragment(node) {
|
|
1323
|
-
return node.type ===
|
|
1210
|
+
return node.type === import_utils17.AST_NODE_TYPES.JSXElement || node.type === import_utils17.AST_NODE_TYPES.JSXFragment;
|
|
1324
1211
|
}
|
|
1325
1212
|
function isSingleLine(node) {
|
|
1326
1213
|
return node.loc.start.line === node.loc.end.line;
|
|
1327
1214
|
}
|
|
1328
|
-
var jsxNoNewlineSingleLineElements =
|
|
1215
|
+
var jsxNoNewlineSingleLineElements = createRule14({
|
|
1329
1216
|
name: "jsx-no-newline-single-line-elements",
|
|
1330
1217
|
meta: {
|
|
1331
1218
|
type: "layout",
|
|
@@ -1343,7 +1230,7 @@ var jsxNoNewlineSingleLineElements = createRule16({
|
|
|
1343
1230
|
const { sourceCode } = context;
|
|
1344
1231
|
function checkSiblings(children) {
|
|
1345
1232
|
const nonWhitespace = children.filter(
|
|
1346
|
-
(child) => !(child.type ===
|
|
1233
|
+
(child) => !(child.type === import_utils17.AST_NODE_TYPES.JSXText && child.value.trim() === "")
|
|
1347
1234
|
);
|
|
1348
1235
|
nonWhitespace.forEach((next, index) => {
|
|
1349
1236
|
if (index === 0) {
|
|
@@ -1394,11 +1281,11 @@ ${indent}`);
|
|
|
1394
1281
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1395
1282
|
|
|
1396
1283
|
// src/rules/jsx-no-non-component-function.ts
|
|
1397
|
-
var
|
|
1398
|
-
var
|
|
1284
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
1285
|
+
var createRule15 = import_utils18.ESLintUtils.RuleCreator(
|
|
1399
1286
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1400
1287
|
);
|
|
1401
|
-
var jsxNoNonComponentFunction =
|
|
1288
|
+
var jsxNoNonComponentFunction = createRule15({
|
|
1402
1289
|
name: "jsx-no-non-component-function",
|
|
1403
1290
|
meta: {
|
|
1404
1291
|
type: "problem",
|
|
@@ -1418,13 +1305,13 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1418
1305
|
return {};
|
|
1419
1306
|
}
|
|
1420
1307
|
function isReactComponent2(node) {
|
|
1421
|
-
const functionName = node.type ===
|
|
1308
|
+
const functionName = node.type === import_utils18.AST_NODE_TYPES.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1422
1309
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1423
1310
|
return true;
|
|
1424
1311
|
}
|
|
1425
1312
|
if (node.returnType?.typeAnnotation) {
|
|
1426
1313
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1427
|
-
if (returnTypeNode.type ===
|
|
1314
|
+
if (returnTypeNode.type === import_utils18.AST_NODE_TYPES.TSTypeReference && returnTypeNode.typeName.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1428
1315
|
const typeName = returnTypeNode.typeName.name;
|
|
1429
1316
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1430
1317
|
return true;
|
|
@@ -1441,13 +1328,13 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1441
1328
|
if (!parent) {
|
|
1442
1329
|
return;
|
|
1443
1330
|
}
|
|
1444
|
-
if (parent.type ===
|
|
1331
|
+
if (parent.type === import_utils18.AST_NODE_TYPES.ExportDefaultDeclaration || parent.type === import_utils18.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1445
1332
|
return;
|
|
1446
1333
|
}
|
|
1447
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1334
|
+
if (declaratorNode?.parent?.parent?.type === import_utils18.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1448
1335
|
return;
|
|
1449
1336
|
}
|
|
1450
|
-
if (declaratorNode?.id.type ===
|
|
1337
|
+
if (declaratorNode?.id.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1451
1338
|
const varName = declaratorNode.id.name;
|
|
1452
1339
|
if (/^[A-Z]/.test(varName)) {
|
|
1453
1340
|
return;
|
|
@@ -1472,20 +1359,20 @@ var jsxNoNonComponentFunction = createRule17({
|
|
|
1472
1359
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1473
1360
|
|
|
1474
1361
|
// src/rules/jsx-no-ternary-null.ts
|
|
1475
|
-
var
|
|
1476
|
-
var
|
|
1362
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
1363
|
+
var createRule16 = import_utils20.ESLintUtils.RuleCreator(
|
|
1477
1364
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1478
1365
|
);
|
|
1479
1366
|
function isNullOrUndefined(node) {
|
|
1480
|
-
if (node.type ===
|
|
1367
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Literal && node.value === null) {
|
|
1481
1368
|
return true;
|
|
1482
1369
|
}
|
|
1483
|
-
if (node.type ===
|
|
1370
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Identifier && node.name === "undefined") {
|
|
1484
1371
|
return true;
|
|
1485
1372
|
}
|
|
1486
1373
|
return false;
|
|
1487
1374
|
}
|
|
1488
|
-
var jsxNoTernaryNull =
|
|
1375
|
+
var jsxNoTernaryNull = createRule16({
|
|
1489
1376
|
name: "jsx-no-ternary-null",
|
|
1490
1377
|
meta: {
|
|
1491
1378
|
type: "suggestion",
|
|
@@ -1503,7 +1390,7 @@ var jsxNoTernaryNull = createRule18({
|
|
|
1503
1390
|
return {
|
|
1504
1391
|
JSXExpressionContainer(node) {
|
|
1505
1392
|
const { expression } = node;
|
|
1506
|
-
if (expression.type !==
|
|
1393
|
+
if (expression.type !== import_utils20.AST_NODE_TYPES.ConditionalExpression) {
|
|
1507
1394
|
return;
|
|
1508
1395
|
}
|
|
1509
1396
|
const { test, consequent, alternate } = expression;
|
|
@@ -1535,11 +1422,11 @@ var jsxNoTernaryNull = createRule18({
|
|
|
1535
1422
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1536
1423
|
|
|
1537
1424
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1538
|
-
var
|
|
1539
|
-
var
|
|
1425
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
1426
|
+
var createRule17 = import_utils21.ESLintUtils.RuleCreator(
|
|
1540
1427
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1541
1428
|
);
|
|
1542
|
-
var jsxNoVariableInCallback =
|
|
1429
|
+
var jsxNoVariableInCallback = createRule17({
|
|
1543
1430
|
name: "jsx-no-variable-in-callback",
|
|
1544
1431
|
meta: {
|
|
1545
1432
|
type: "suggestion",
|
|
@@ -1556,7 +1443,7 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1556
1443
|
function isInsideJSX(node) {
|
|
1557
1444
|
let current = node.parent;
|
|
1558
1445
|
while (current) {
|
|
1559
|
-
if (current.type ===
|
|
1446
|
+
if (current.type === import_utils21.AST_NODE_TYPES.JSXElement || current.type === import_utils21.AST_NODE_TYPES.JSXFragment) {
|
|
1560
1447
|
return true;
|
|
1561
1448
|
}
|
|
1562
1449
|
current = current.parent;
|
|
@@ -1570,11 +1457,11 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1570
1457
|
if (!isInsideJSX(node)) {
|
|
1571
1458
|
return false;
|
|
1572
1459
|
}
|
|
1573
|
-
if (node.parent.type ===
|
|
1460
|
+
if (node.parent.type === import_utils21.AST_NODE_TYPES.CallExpression || node.parent.type === import_utils21.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1574
1461
|
return true;
|
|
1575
1462
|
}
|
|
1576
|
-
if (node.parent.type ===
|
|
1577
|
-
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) {
|
|
1578
1465
|
return true;
|
|
1579
1466
|
}
|
|
1580
1467
|
}
|
|
@@ -1585,11 +1472,11 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1585
1472
|
return;
|
|
1586
1473
|
}
|
|
1587
1474
|
const { body } = node;
|
|
1588
|
-
if (body.type !==
|
|
1475
|
+
if (body.type !== import_utils21.AST_NODE_TYPES.BlockStatement) {
|
|
1589
1476
|
return;
|
|
1590
1477
|
}
|
|
1591
1478
|
body.body.forEach((statement) => {
|
|
1592
|
-
if (statement.type ===
|
|
1479
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.VariableDeclaration) {
|
|
1593
1480
|
context.report({
|
|
1594
1481
|
node: statement,
|
|
1595
1482
|
messageId: "noVariableInCallback"
|
|
@@ -1605,53 +1492,12 @@ var jsxNoVariableInCallback = createRule19({
|
|
|
1605
1492
|
});
|
|
1606
1493
|
var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
1607
1494
|
|
|
1608
|
-
// src/rules/jsx-pascal-case.ts
|
|
1609
|
-
var import_path4 = __toESM(require("path"), 1);
|
|
1610
|
-
var import_utils24 = require("@typescript-eslint/utils");
|
|
1611
|
-
var createRule20 = import_utils24.ESLintUtils.RuleCreator(
|
|
1612
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1613
|
-
);
|
|
1614
|
-
var isPascalCase = (str) => /^[A-Z][a-zA-Z0-9]*$/.test(str) && !/^[A-Z]+$/.test(str);
|
|
1615
|
-
var jsxPascalCase = createRule20({
|
|
1616
|
-
name: "jsx-pascal-case",
|
|
1617
|
-
meta: {
|
|
1618
|
-
type: "problem",
|
|
1619
|
-
docs: {
|
|
1620
|
-
description: "Enforce PascalCase filenames for .jsx and .tsx files"
|
|
1621
|
-
},
|
|
1622
|
-
messages: {
|
|
1623
|
-
jsxPascalCase: "JSX/TSX file names must be PascalCase"
|
|
1624
|
-
},
|
|
1625
|
-
schema: []
|
|
1626
|
-
},
|
|
1627
|
-
defaultOptions: [],
|
|
1628
|
-
create(context) {
|
|
1629
|
-
return {
|
|
1630
|
-
Program() {
|
|
1631
|
-
const { filename } = context;
|
|
1632
|
-
const ext = import_path4.default.extname(filename);
|
|
1633
|
-
if (ext !== ".jsx" && ext !== ".tsx") {
|
|
1634
|
-
return;
|
|
1635
|
-
}
|
|
1636
|
-
const basename2 = import_path4.default.basename(filename, ext);
|
|
1637
|
-
if (!isPascalCase(basename2)) {
|
|
1638
|
-
context.report({
|
|
1639
|
-
loc: { line: 1, column: 0 },
|
|
1640
|
-
messageId: "jsxPascalCase"
|
|
1641
|
-
});
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
});
|
|
1647
|
-
var jsx_pascal_case_default = jsxPascalCase;
|
|
1648
|
-
|
|
1649
1495
|
// src/rules/jsx-require-suspense.ts
|
|
1650
|
-
var
|
|
1651
|
-
var
|
|
1496
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
1497
|
+
var createRule18 = import_utils22.ESLintUtils.RuleCreator(
|
|
1652
1498
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1653
1499
|
);
|
|
1654
|
-
var jsxRequireSuspense =
|
|
1500
|
+
var jsxRequireSuspense = createRule18({
|
|
1655
1501
|
name: "jsx-require-suspense",
|
|
1656
1502
|
meta: {
|
|
1657
1503
|
type: "problem",
|
|
@@ -1669,7 +1515,7 @@ var jsxRequireSuspense = createRule21({
|
|
|
1669
1515
|
const isInsideSuspense = (node) => {
|
|
1670
1516
|
let current = node.parent;
|
|
1671
1517
|
while (current) {
|
|
1672
|
-
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") {
|
|
1673
1519
|
return true;
|
|
1674
1520
|
}
|
|
1675
1521
|
current = current.parent;
|
|
@@ -1678,16 +1524,16 @@ var jsxRequireSuspense = createRule21({
|
|
|
1678
1524
|
};
|
|
1679
1525
|
return {
|
|
1680
1526
|
VariableDeclarator(node) {
|
|
1681
|
-
if (node.id.type ===
|
|
1527
|
+
if (node.id.type === import_utils22.AST_NODE_TYPES.Identifier && node.init?.type === import_utils22.AST_NODE_TYPES.CallExpression) {
|
|
1682
1528
|
const { callee } = node.init;
|
|
1683
|
-
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";
|
|
1684
1530
|
if (isLazyCall) {
|
|
1685
1531
|
lazyComponents.add(node.id.name);
|
|
1686
1532
|
}
|
|
1687
1533
|
}
|
|
1688
1534
|
},
|
|
1689
1535
|
JSXOpeningElement(node) {
|
|
1690
|
-
if (node.name.type ===
|
|
1536
|
+
if (node.name.type === import_utils22.AST_NODE_TYPES.JSXIdentifier) {
|
|
1691
1537
|
const componentName = node.name.name;
|
|
1692
1538
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1693
1539
|
context.report({
|
|
@@ -1706,11 +1552,11 @@ var jsxRequireSuspense = createRule21({
|
|
|
1706
1552
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1707
1553
|
|
|
1708
1554
|
// src/rules/jsx-simple-props.ts
|
|
1709
|
-
var
|
|
1710
|
-
var
|
|
1555
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
1556
|
+
var createRule19 = import_utils23.ESLintUtils.RuleCreator(
|
|
1711
1557
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1712
1558
|
);
|
|
1713
|
-
var jsxSimpleProps =
|
|
1559
|
+
var jsxSimpleProps = createRule19({
|
|
1714
1560
|
name: "jsx-simple-props",
|
|
1715
1561
|
meta: {
|
|
1716
1562
|
type: "suggestion",
|
|
@@ -1725,25 +1571,25 @@ var jsxSimpleProps = createRule22({
|
|
|
1725
1571
|
defaultOptions: [],
|
|
1726
1572
|
create(context) {
|
|
1727
1573
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
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
|
|
1735
1581
|
]);
|
|
1736
1582
|
return {
|
|
1737
1583
|
JSXAttribute(node) {
|
|
1738
1584
|
if (!node.value) {
|
|
1739
1585
|
return;
|
|
1740
1586
|
}
|
|
1741
|
-
if (node.value.type ===
|
|
1587
|
+
if (node.value.type === import_utils23.AST_NODE_TYPES.Literal) {
|
|
1742
1588
|
return;
|
|
1743
1589
|
}
|
|
1744
|
-
if (node.value.type ===
|
|
1590
|
+
if (node.value.type === import_utils23.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1745
1591
|
const { expression } = node.value;
|
|
1746
|
-
if (expression.type ===
|
|
1592
|
+
if (expression.type === import_utils23.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1747
1593
|
return;
|
|
1748
1594
|
}
|
|
1749
1595
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1760,8 +1606,8 @@ var jsxSimpleProps = createRule22({
|
|
|
1760
1606
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1761
1607
|
|
|
1762
1608
|
// src/rules/jsx-sort-props.ts
|
|
1763
|
-
var
|
|
1764
|
-
var
|
|
1609
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
1610
|
+
var createRule20 = import_utils24.ESLintUtils.RuleCreator(
|
|
1765
1611
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1766
1612
|
);
|
|
1767
1613
|
var TYPE_GROUP = {
|
|
@@ -1775,15 +1621,15 @@ var TYPE_GROUP = {
|
|
|
1775
1621
|
SHORTHAND: 8
|
|
1776
1622
|
};
|
|
1777
1623
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1778
|
-
[
|
|
1779
|
-
[
|
|
1780
|
-
[
|
|
1781
|
-
[
|
|
1782
|
-
[
|
|
1783
|
-
[
|
|
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]
|
|
1784
1630
|
]);
|
|
1785
1631
|
function isHyphenatedName(node) {
|
|
1786
|
-
return node.name.type ===
|
|
1632
|
+
return node.name.type === import_utils24.AST_NODE_TYPES.JSXIdentifier && node.name.name.includes("-");
|
|
1787
1633
|
}
|
|
1788
1634
|
function getStringGroup(node) {
|
|
1789
1635
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1795,13 +1641,13 @@ function getLiteralValueGroup(value) {
|
|
|
1795
1641
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1796
1642
|
}
|
|
1797
1643
|
function getExpressionGroup(expression) {
|
|
1798
|
-
if (expression.type ===
|
|
1644
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.Literal) {
|
|
1799
1645
|
return getLiteralValueGroup(expression.value);
|
|
1800
1646
|
}
|
|
1801
|
-
if (expression.type ===
|
|
1647
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.TemplateLiteral) {
|
|
1802
1648
|
return null;
|
|
1803
1649
|
}
|
|
1804
|
-
if (expression.type ===
|
|
1650
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.Identifier && expression.name === "undefined") {
|
|
1805
1651
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1806
1652
|
}
|
|
1807
1653
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1810,17 +1656,17 @@ function getTypeGroup(node) {
|
|
|
1810
1656
|
if (node.value === null) {
|
|
1811
1657
|
return TYPE_GROUP.SHORTHAND;
|
|
1812
1658
|
}
|
|
1813
|
-
if (node.value.type ===
|
|
1659
|
+
if (node.value.type === import_utils24.AST_NODE_TYPES.Literal) {
|
|
1814
1660
|
if (typeof node.value.value === "string") {
|
|
1815
1661
|
return getStringGroup(node);
|
|
1816
1662
|
}
|
|
1817
1663
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1818
1664
|
}
|
|
1819
|
-
if (node.value.type !==
|
|
1665
|
+
if (node.value.type !== import_utils24.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1820
1666
|
return null;
|
|
1821
1667
|
}
|
|
1822
1668
|
const { expression } = node.value;
|
|
1823
|
-
if (expression.type ===
|
|
1669
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1824
1670
|
return null;
|
|
1825
1671
|
}
|
|
1826
1672
|
const group = getExpressionGroup(expression);
|
|
@@ -1832,7 +1678,7 @@ function getTypeGroup(node) {
|
|
|
1832
1678
|
function hasUnsortedProps(attributes) {
|
|
1833
1679
|
let lastGroup = 0;
|
|
1834
1680
|
return attributes.some((attribute) => {
|
|
1835
|
-
if (attribute.type ===
|
|
1681
|
+
if (attribute.type === import_utils24.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1836
1682
|
lastGroup = 0;
|
|
1837
1683
|
return false;
|
|
1838
1684
|
}
|
|
@@ -1856,7 +1702,7 @@ function getSegments(attributes) {
|
|
|
1856
1702
|
const result = [];
|
|
1857
1703
|
let current = [];
|
|
1858
1704
|
attributes.forEach((attr) => {
|
|
1859
|
-
if (attr.type ===
|
|
1705
|
+
if (attr.type === import_utils24.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1860
1706
|
if (current.length > 0) {
|
|
1861
1707
|
result.push(current);
|
|
1862
1708
|
current = [];
|
|
@@ -1870,7 +1716,7 @@ function getSegments(attributes) {
|
|
|
1870
1716
|
}
|
|
1871
1717
|
return result;
|
|
1872
1718
|
}
|
|
1873
|
-
var jsxSortProps =
|
|
1719
|
+
var jsxSortProps = createRule20({
|
|
1874
1720
|
name: "jsx-sort-props",
|
|
1875
1721
|
meta: {
|
|
1876
1722
|
type: "suggestion",
|
|
@@ -1905,11 +1751,11 @@ var jsxSortProps = createRule23({
|
|
|
1905
1751
|
var jsx_sort_props_default = jsxSortProps;
|
|
1906
1752
|
|
|
1907
1753
|
// src/rules/jsx-spread-props-last.ts
|
|
1908
|
-
var
|
|
1909
|
-
var
|
|
1754
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
1755
|
+
var createRule21 = import_utils25.ESLintUtils.RuleCreator(
|
|
1910
1756
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1911
1757
|
);
|
|
1912
|
-
var jsxSpreadPropsLast =
|
|
1758
|
+
var jsxSpreadPropsLast = createRule21({
|
|
1913
1759
|
name: "jsx-spread-props-last",
|
|
1914
1760
|
meta: {
|
|
1915
1761
|
type: "suggestion",
|
|
@@ -1928,12 +1774,12 @@ var jsxSpreadPropsLast = createRule24({
|
|
|
1928
1774
|
const { attributes } = node;
|
|
1929
1775
|
let lastNonSpreadIndex = -1;
|
|
1930
1776
|
attributes.forEach((attribute, index) => {
|
|
1931
|
-
if (attribute.type !==
|
|
1777
|
+
if (attribute.type !== import_utils25.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1932
1778
|
lastNonSpreadIndex = index;
|
|
1933
1779
|
}
|
|
1934
1780
|
});
|
|
1935
1781
|
attributes.forEach((attribute, index) => {
|
|
1936
|
-
if (attribute.type ===
|
|
1782
|
+
if (attribute.type === import_utils25.AST_NODE_TYPES.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1937
1783
|
context.report({
|
|
1938
1784
|
node: attribute,
|
|
1939
1785
|
messageId: "spreadNotLast"
|
|
@@ -1947,12 +1793,12 @@ var jsxSpreadPropsLast = createRule24({
|
|
|
1947
1793
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1948
1794
|
|
|
1949
1795
|
// src/rules/newline-after-multiline-block.ts
|
|
1950
|
-
var
|
|
1951
|
-
var
|
|
1796
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
1797
|
+
var createRule22 = import_utils26.ESLintUtils.RuleCreator(
|
|
1952
1798
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1953
1799
|
);
|
|
1954
1800
|
function isImportDeclaration(node) {
|
|
1955
|
-
return node.type ===
|
|
1801
|
+
return node.type === import_utils26.AST_NODE_TYPES.ImportDeclaration;
|
|
1956
1802
|
}
|
|
1957
1803
|
function checkStatements(statements, context) {
|
|
1958
1804
|
const { sourceCode } = context;
|
|
@@ -1987,7 +1833,7 @@ function checkStatements(statements, context) {
|
|
|
1987
1833
|
}
|
|
1988
1834
|
});
|
|
1989
1835
|
}
|
|
1990
|
-
var newlineAfterMultilineBlock =
|
|
1836
|
+
var newlineAfterMultilineBlock = createRule22({
|
|
1991
1837
|
name: "newline-after-multiline-block",
|
|
1992
1838
|
meta: {
|
|
1993
1839
|
type: "layout",
|
|
@@ -2015,11 +1861,11 @@ var newlineAfterMultilineBlock = createRule25({
|
|
|
2015
1861
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
2016
1862
|
|
|
2017
1863
|
// src/rules/newline-before-return.ts
|
|
2018
|
-
var
|
|
2019
|
-
var
|
|
1864
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
1865
|
+
var createRule23 = import_utils27.ESLintUtils.RuleCreator(
|
|
2020
1866
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2021
1867
|
);
|
|
2022
|
-
var newlineBeforeReturn =
|
|
1868
|
+
var newlineBeforeReturn = createRule23({
|
|
2023
1869
|
name: "newline-before-return",
|
|
2024
1870
|
meta: {
|
|
2025
1871
|
type: "layout",
|
|
@@ -2037,7 +1883,7 @@ var newlineBeforeReturn = createRule26({
|
|
|
2037
1883
|
const { sourceCode } = context;
|
|
2038
1884
|
function checkReturnStatement(node) {
|
|
2039
1885
|
const { parent } = node;
|
|
2040
|
-
if (!parent || parent.type !==
|
|
1886
|
+
if (!parent || parent.type !== import_utils27.AST_NODE_TYPES.BlockStatement) {
|
|
2041
1887
|
return;
|
|
2042
1888
|
}
|
|
2043
1889
|
const { body: statements } = parent;
|
|
@@ -2073,61 +1919,12 @@ var newlineBeforeReturn = createRule26({
|
|
|
2073
1919
|
});
|
|
2074
1920
|
var newline_before_return_default = newlineBeforeReturn;
|
|
2075
1921
|
|
|
2076
|
-
// src/rules/nextjs-require-public-env.ts
|
|
2077
|
-
var import_utils31 = require("@typescript-eslint/utils");
|
|
2078
|
-
var createRule27 = import_utils31.ESLintUtils.RuleCreator(
|
|
2079
|
-
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2080
|
-
);
|
|
2081
|
-
var nextjsRequirePublicEnv = createRule27({
|
|
2082
|
-
name: "nextjs-require-public-env",
|
|
2083
|
-
meta: {
|
|
2084
|
-
type: "problem",
|
|
2085
|
-
docs: {
|
|
2086
|
-
description: "Require NEXT_PUBLIC_ prefix for environment variables in client components"
|
|
2087
|
-
},
|
|
2088
|
-
messages: {
|
|
2089
|
-
requirePublicPrefix: "Environment variable '{{ name }}' must use NEXT_PUBLIC_ prefix in client components. Use 'NEXT_PUBLIC_{{ name }}' instead."
|
|
2090
|
-
},
|
|
2091
|
-
schema: []
|
|
2092
|
-
},
|
|
2093
|
-
defaultOptions: [],
|
|
2094
|
-
create(context) {
|
|
2095
|
-
let isClientComponent = false;
|
|
2096
|
-
return {
|
|
2097
|
-
Program(node) {
|
|
2098
|
-
const firstStatement = node.body[0];
|
|
2099
|
-
if (firstStatement?.type === import_utils31.AST_NODE_TYPES.ExpressionStatement && firstStatement.expression.type === import_utils31.AST_NODE_TYPES.Literal && firstStatement.expression.value === "use client") {
|
|
2100
|
-
isClientComponent = true;
|
|
2101
|
-
}
|
|
2102
|
-
},
|
|
2103
|
-
MemberExpression(node) {
|
|
2104
|
-
if (!isClientComponent) {
|
|
2105
|
-
return;
|
|
2106
|
-
}
|
|
2107
|
-
if (node.object.type === import_utils31.AST_NODE_TYPES.MemberExpression && node.object.object.type === import_utils31.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === import_utils31.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === import_utils31.AST_NODE_TYPES.Identifier) {
|
|
2108
|
-
const envVarName = node.property.name;
|
|
2109
|
-
if (!envVarName.startsWith("NEXT_PUBLIC_") && envVarName !== "NODE_ENV") {
|
|
2110
|
-
context.report({
|
|
2111
|
-
node: node.property,
|
|
2112
|
-
messageId: "requirePublicPrefix",
|
|
2113
|
-
data: {
|
|
2114
|
-
name: envVarName
|
|
2115
|
-
}
|
|
2116
|
-
});
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
}
|
|
2122
|
-
});
|
|
2123
|
-
var nextjs_require_public_env_default = nextjsRequirePublicEnv;
|
|
2124
|
-
|
|
2125
1922
|
// src/rules/no-complex-inline-return.ts
|
|
2126
|
-
var
|
|
2127
|
-
var
|
|
1923
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
1924
|
+
var createRule24 = import_utils28.ESLintUtils.RuleCreator(
|
|
2128
1925
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2129
1926
|
);
|
|
2130
|
-
var noComplexInlineReturn =
|
|
1927
|
+
var noComplexInlineReturn = createRule24({
|
|
2131
1928
|
name: "no-complex-inline-return",
|
|
2132
1929
|
meta: {
|
|
2133
1930
|
type: "suggestion",
|
|
@@ -2143,13 +1940,13 @@ var noComplexInlineReturn = createRule28({
|
|
|
2143
1940
|
create(context) {
|
|
2144
1941
|
const isComplexExpression = (node) => {
|
|
2145
1942
|
if (!node) return false;
|
|
2146
|
-
if (node.type ===
|
|
1943
|
+
if (node.type === import_utils28.AST_NODE_TYPES.ConditionalExpression) {
|
|
2147
1944
|
return true;
|
|
2148
1945
|
}
|
|
2149
|
-
if (node.type ===
|
|
1946
|
+
if (node.type === import_utils28.AST_NODE_TYPES.LogicalExpression) {
|
|
2150
1947
|
return true;
|
|
2151
1948
|
}
|
|
2152
|
-
if (node.type ===
|
|
1949
|
+
if (node.type === import_utils28.AST_NODE_TYPES.NewExpression) {
|
|
2153
1950
|
return true;
|
|
2154
1951
|
}
|
|
2155
1952
|
return false;
|
|
@@ -2169,11 +1966,11 @@ var noComplexInlineReturn = createRule28({
|
|
|
2169
1966
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
2170
1967
|
|
|
2171
1968
|
// src/rules/no-direct-date.ts
|
|
2172
|
-
var
|
|
2173
|
-
var
|
|
1969
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
1970
|
+
var createRule25 = import_utils29.ESLintUtils.RuleCreator(
|
|
2174
1971
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2175
1972
|
);
|
|
2176
|
-
var noDirectDate =
|
|
1973
|
+
var noDirectDate = createRule25({
|
|
2177
1974
|
name: "no-direct-date",
|
|
2178
1975
|
meta: {
|
|
2179
1976
|
type: "problem",
|
|
@@ -2191,7 +1988,7 @@ var noDirectDate = createRule29({
|
|
|
2191
1988
|
create(context) {
|
|
2192
1989
|
return {
|
|
2193
1990
|
NewExpression(node) {
|
|
2194
|
-
if (node.callee.type ===
|
|
1991
|
+
if (node.callee.type === import_utils29.AST_NODE_TYPES.Identifier && node.callee.name === "Date") {
|
|
2195
1992
|
context.report({
|
|
2196
1993
|
node,
|
|
2197
1994
|
messageId: "noNewDate"
|
|
@@ -2199,7 +1996,7 @@ var noDirectDate = createRule29({
|
|
|
2199
1996
|
}
|
|
2200
1997
|
},
|
|
2201
1998
|
CallExpression(node) {
|
|
2202
|
-
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) {
|
|
2203
2000
|
const methodName = node.callee.property.name;
|
|
2204
2001
|
if (methodName === "now") {
|
|
2205
2002
|
context.report({
|
|
@@ -2222,11 +2019,11 @@ var no_direct_date_default = noDirectDate;
|
|
|
2222
2019
|
|
|
2223
2020
|
// src/rules/no-emoji.ts
|
|
2224
2021
|
var import_emoji_regex = __toESM(require("emoji-regex"), 1);
|
|
2225
|
-
var
|
|
2226
|
-
var
|
|
2022
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
2023
|
+
var createRule26 = import_utils30.ESLintUtils.RuleCreator(
|
|
2227
2024
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2228
2025
|
);
|
|
2229
|
-
var noEmoji =
|
|
2026
|
+
var noEmoji = createRule26({
|
|
2230
2027
|
name: "no-emoji",
|
|
2231
2028
|
meta: {
|
|
2232
2029
|
type: "problem",
|
|
@@ -2260,11 +2057,11 @@ var noEmoji = createRule30({
|
|
|
2260
2057
|
var no_emoji_default = noEmoji;
|
|
2261
2058
|
|
|
2262
2059
|
// src/rules/no-env-fallback.ts
|
|
2263
|
-
var
|
|
2264
|
-
var
|
|
2060
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
2061
|
+
var createRule27 = import_utils31.ESLintUtils.RuleCreator(
|
|
2265
2062
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2266
2063
|
);
|
|
2267
|
-
var noEnvFallback =
|
|
2064
|
+
var noEnvFallback = createRule27({
|
|
2268
2065
|
name: "no-env-fallback",
|
|
2269
2066
|
meta: {
|
|
2270
2067
|
type: "problem",
|
|
@@ -2279,16 +2076,16 @@ var noEnvFallback = createRule31({
|
|
|
2279
2076
|
defaultOptions: [],
|
|
2280
2077
|
create(context) {
|
|
2281
2078
|
const isProcessEnvAccess = (node) => {
|
|
2282
|
-
if (node.type !==
|
|
2079
|
+
if (node.type !== import_utils31.AST_NODE_TYPES.MemberExpression) {
|
|
2283
2080
|
return false;
|
|
2284
2081
|
}
|
|
2285
2082
|
const { object } = node;
|
|
2286
|
-
if (object.type !==
|
|
2083
|
+
if (object.type !== import_utils31.AST_NODE_TYPES.MemberExpression) {
|
|
2287
2084
|
return false;
|
|
2288
2085
|
}
|
|
2289
2086
|
const processNode = object.object;
|
|
2290
2087
|
const envNode = object.property;
|
|
2291
|
-
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";
|
|
2292
2089
|
};
|
|
2293
2090
|
return {
|
|
2294
2091
|
LogicalExpression(node) {
|
|
@@ -2313,11 +2110,11 @@ var noEnvFallback = createRule31({
|
|
|
2313
2110
|
var no_env_fallback_default = noEnvFallback;
|
|
2314
2111
|
|
|
2315
2112
|
// src/rules/no-inline-default-export.ts
|
|
2316
|
-
var
|
|
2317
|
-
var
|
|
2113
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2114
|
+
var createRule28 = import_utils32.ESLintUtils.RuleCreator(
|
|
2318
2115
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2319
2116
|
);
|
|
2320
|
-
var noInlineDefaultExport =
|
|
2117
|
+
var noInlineDefaultExport = createRule28({
|
|
2321
2118
|
name: "no-inline-default-export",
|
|
2322
2119
|
meta: {
|
|
2323
2120
|
type: "suggestion",
|
|
@@ -2336,7 +2133,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2336
2133
|
return {
|
|
2337
2134
|
ExportDefaultDeclaration(node) {
|
|
2338
2135
|
const { declaration } = node;
|
|
2339
|
-
if (declaration.type ===
|
|
2136
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2340
2137
|
if (declaration.id) {
|
|
2341
2138
|
context.report({
|
|
2342
2139
|
node,
|
|
@@ -2351,7 +2148,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2351
2148
|
});
|
|
2352
2149
|
}
|
|
2353
2150
|
}
|
|
2354
|
-
if (declaration.type ===
|
|
2151
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.ClassDeclaration) {
|
|
2355
2152
|
if (declaration.id) {
|
|
2356
2153
|
context.report({
|
|
2357
2154
|
node,
|
|
@@ -2366,7 +2163,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2366
2163
|
});
|
|
2367
2164
|
}
|
|
2368
2165
|
}
|
|
2369
|
-
if (declaration.type ===
|
|
2166
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils32.AST_NODE_TYPES.FunctionExpression) {
|
|
2370
2167
|
context.report({
|
|
2371
2168
|
node,
|
|
2372
2169
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2379,14 +2176,14 @@ var noInlineDefaultExport = createRule32({
|
|
|
2379
2176
|
if (!declaration) {
|
|
2380
2177
|
return;
|
|
2381
2178
|
}
|
|
2382
|
-
if (declaration.type ===
|
|
2179
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2383
2180
|
context.report({
|
|
2384
2181
|
node,
|
|
2385
2182
|
messageId: "noInlineNamedExport",
|
|
2386
2183
|
data: { type: "function", name: declaration.id.name }
|
|
2387
2184
|
});
|
|
2388
2185
|
}
|
|
2389
|
-
if (declaration.type ===
|
|
2186
|
+
if (declaration.type === import_utils32.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2390
2187
|
context.report({
|
|
2391
2188
|
node,
|
|
2392
2189
|
messageId: "noInlineNamedExport",
|
|
@@ -2400,36 +2197,45 @@ var noInlineDefaultExport = createRule32({
|
|
|
2400
2197
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2401
2198
|
|
|
2402
2199
|
// src/rules/no-inline-nested-object.ts
|
|
2403
|
-
var
|
|
2404
|
-
var
|
|
2200
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2201
|
+
var createRule29 = import_utils33.ESLintUtils.RuleCreator(
|
|
2405
2202
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2406
2203
|
);
|
|
2407
2204
|
function isObjectOrArray(node) {
|
|
2408
|
-
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;
|
|
2409
2206
|
}
|
|
2410
2207
|
function getInnerExpression(node) {
|
|
2411
|
-
if (node.type ===
|
|
2208
|
+
if (node.type === import_utils33.AST_NODE_TYPES.TSAsExpression) {
|
|
2412
2209
|
return getInnerExpression(node.expression);
|
|
2413
2210
|
}
|
|
2414
2211
|
return node;
|
|
2415
2212
|
}
|
|
2416
|
-
function
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
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);
|
|
2421
2227
|
});
|
|
2422
2228
|
}
|
|
2423
|
-
var noInlineNestedObject =
|
|
2229
|
+
var noInlineNestedObject = createRule29({
|
|
2424
2230
|
name: "no-inline-nested-object",
|
|
2425
2231
|
meta: {
|
|
2426
2232
|
type: "layout",
|
|
2427
2233
|
docs: {
|
|
2428
|
-
description: "Require nested objects
|
|
2234
|
+
description: "Require object or array values that contain further nested objects or arrays to span multiple lines"
|
|
2429
2235
|
},
|
|
2430
2236
|
fixable: "whitespace",
|
|
2431
2237
|
messages: {
|
|
2432
|
-
requireMultiline: "
|
|
2238
|
+
requireMultiline: "Inline collections containing nested objects or arrays should span multiple lines"
|
|
2433
2239
|
},
|
|
2434
2240
|
schema: []
|
|
2435
2241
|
},
|
|
@@ -2442,23 +2248,20 @@ var noInlineNestedObject = createRule33({
|
|
|
2442
2248
|
return;
|
|
2443
2249
|
}
|
|
2444
2250
|
const valueNode = getInnerExpression(node.value);
|
|
2445
|
-
if (valueNode.type !==
|
|
2251
|
+
if (valueNode.type !== import_utils33.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils33.AST_NODE_TYPES.ArrayExpression) {
|
|
2446
2252
|
return;
|
|
2447
2253
|
}
|
|
2448
2254
|
if (!valueNode.loc) {
|
|
2449
2255
|
return;
|
|
2450
2256
|
}
|
|
2451
|
-
const elements = valueNode.type === import_utils37.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2452
|
-
if (elements.length <= 1) {
|
|
2453
|
-
return;
|
|
2454
|
-
}
|
|
2455
|
-
if (valueNode.type === import_utils37.AST_NODE_TYPES.ArrayExpression && arrayContainsOnlyPrimitives(valueNode)) {
|
|
2456
|
-
return;
|
|
2457
|
-
}
|
|
2458
2257
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
2459
2258
|
if (isMultiline) {
|
|
2460
2259
|
return;
|
|
2461
2260
|
}
|
|
2261
|
+
if (!containsNestedStructure(valueNode)) {
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
const elements = valueNode.type === import_utils33.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2462
2265
|
context.report({
|
|
2463
2266
|
node: valueNode,
|
|
2464
2267
|
messageId: "requireMultiline",
|
|
@@ -2471,7 +2274,7 @@ var noInlineNestedObject = createRule33({
|
|
|
2471
2274
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2472
2275
|
const innerIndent = `${indent} `;
|
|
2473
2276
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2474
|
-
const isObject = valueNode.type ===
|
|
2277
|
+
const isObject = valueNode.type === import_utils33.AST_NODE_TYPES.ObjectExpression;
|
|
2475
2278
|
const openChar = isObject ? "{" : "[";
|
|
2476
2279
|
const closeChar = isObject ? "}" : "]";
|
|
2477
2280
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2488,20 +2291,20 @@ ${indent}${closeChar}`;
|
|
|
2488
2291
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2489
2292
|
|
|
2490
2293
|
// src/rules/no-inline-return-properties.ts
|
|
2491
|
-
var
|
|
2492
|
-
var
|
|
2294
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2295
|
+
var createRule30 = import_utils34.ESLintUtils.RuleCreator(
|
|
2493
2296
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2494
2297
|
);
|
|
2495
2298
|
var isShorthandProperty = (property) => {
|
|
2496
|
-
if (property.type ===
|
|
2299
|
+
if (property.type === import_utils34.AST_NODE_TYPES.SpreadElement) {
|
|
2497
2300
|
return true;
|
|
2498
2301
|
}
|
|
2499
|
-
if (property.type !==
|
|
2302
|
+
if (property.type !== import_utils34.AST_NODE_TYPES.Property) {
|
|
2500
2303
|
return false;
|
|
2501
2304
|
}
|
|
2502
2305
|
return property.shorthand;
|
|
2503
2306
|
};
|
|
2504
|
-
var noInlineReturnProperties =
|
|
2307
|
+
var noInlineReturnProperties = createRule30({
|
|
2505
2308
|
name: "no-inline-return-properties",
|
|
2506
2309
|
meta: {
|
|
2507
2310
|
type: "suggestion",
|
|
@@ -2517,20 +2320,20 @@ var noInlineReturnProperties = createRule34({
|
|
|
2517
2320
|
create(context) {
|
|
2518
2321
|
return {
|
|
2519
2322
|
ReturnStatement(node) {
|
|
2520
|
-
if (!node.argument || node.argument.type !==
|
|
2323
|
+
if (!node.argument || node.argument.type !== import_utils34.AST_NODE_TYPES.ObjectExpression) {
|
|
2521
2324
|
return;
|
|
2522
2325
|
}
|
|
2523
2326
|
node.argument.properties.forEach((property) => {
|
|
2524
2327
|
if (isShorthandProperty(property)) {
|
|
2525
2328
|
return;
|
|
2526
2329
|
}
|
|
2527
|
-
if (property.type !==
|
|
2330
|
+
if (property.type !== import_utils34.AST_NODE_TYPES.Property) {
|
|
2528
2331
|
return;
|
|
2529
2332
|
}
|
|
2530
2333
|
let keyName = null;
|
|
2531
|
-
if (property.key.type ===
|
|
2334
|
+
if (property.key.type === import_utils34.AST_NODE_TYPES.Identifier) {
|
|
2532
2335
|
keyName = property.key.name;
|
|
2533
|
-
} else if (property.key.type ===
|
|
2336
|
+
} else if (property.key.type === import_utils34.AST_NODE_TYPES.Literal) {
|
|
2534
2337
|
keyName = String(property.key.value);
|
|
2535
2338
|
}
|
|
2536
2339
|
context.report({
|
|
@@ -2546,12 +2349,12 @@ var noInlineReturnProperties = createRule34({
|
|
|
2546
2349
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2547
2350
|
|
|
2548
2351
|
// src/rules/no-inline-type-import.ts
|
|
2549
|
-
var
|
|
2550
|
-
var
|
|
2352
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2353
|
+
var createRule31 = import_utils35.ESLintUtils.RuleCreator(
|
|
2551
2354
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2552
2355
|
);
|
|
2553
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2554
|
-
var noInlineTypeImport =
|
|
2356
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === import_utils35.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2357
|
+
var noInlineTypeImport = createRule31({
|
|
2555
2358
|
name: "no-inline-type-import",
|
|
2556
2359
|
meta: {
|
|
2557
2360
|
type: "suggestion",
|
|
@@ -2588,7 +2391,7 @@ var noInlineTypeImport = createRule35({
|
|
|
2588
2391
|
);
|
|
2589
2392
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2590
2393
|
const valueSpecifiers = node.specifiers.filter(
|
|
2591
|
-
(specifier) => !(specifier.type ===
|
|
2394
|
+
(specifier) => !(specifier.type === import_utils35.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type")
|
|
2592
2395
|
);
|
|
2593
2396
|
if (valueSpecifiers.length === 0) {
|
|
2594
2397
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2596,11 +2399,11 @@ var noInlineTypeImport = createRule35({
|
|
|
2596
2399
|
const parts = [];
|
|
2597
2400
|
const namedValueSpecifiers = [];
|
|
2598
2401
|
for (const specifier of valueSpecifiers) {
|
|
2599
|
-
if (specifier.type ===
|
|
2402
|
+
if (specifier.type === import_utils35.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
2600
2403
|
parts.push(specifier.local.name);
|
|
2601
|
-
} else if (specifier.type ===
|
|
2404
|
+
} else if (specifier.type === import_utils35.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
2602
2405
|
parts.push(`* as ${specifier.local.name}`);
|
|
2603
|
-
} else if (specifier.type ===
|
|
2406
|
+
} else if (specifier.type === import_utils35.AST_NODE_TYPES.ImportSpecifier) {
|
|
2604
2407
|
namedValueSpecifiers.push(specifier);
|
|
2605
2408
|
}
|
|
2606
2409
|
}
|
|
@@ -2620,8 +2423,8 @@ ${typeImport}`);
|
|
|
2620
2423
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2621
2424
|
|
|
2622
2425
|
// src/rules/no-lazy-identifiers.ts
|
|
2623
|
-
var
|
|
2624
|
-
var
|
|
2426
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2427
|
+
var createRule32 = import_utils36.ESLintUtils.RuleCreator(
|
|
2625
2428
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2626
2429
|
);
|
|
2627
2430
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2662,7 +2465,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2662
2465
|
}
|
|
2663
2466
|
return false;
|
|
2664
2467
|
};
|
|
2665
|
-
var noLazyIdentifiers =
|
|
2468
|
+
var noLazyIdentifiers = createRule32({
|
|
2666
2469
|
name: "no-lazy-identifiers",
|
|
2667
2470
|
meta: {
|
|
2668
2471
|
type: "problem",
|
|
@@ -2688,27 +2491,27 @@ var noLazyIdentifiers = createRule36({
|
|
|
2688
2491
|
});
|
|
2689
2492
|
};
|
|
2690
2493
|
const checkPattern = (pattern) => {
|
|
2691
|
-
if (pattern.type ===
|
|
2494
|
+
if (pattern.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2692
2495
|
checkIdentifier(pattern);
|
|
2693
|
-
} else if (pattern.type ===
|
|
2496
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.ObjectPattern) {
|
|
2694
2497
|
pattern.properties.forEach((prop) => {
|
|
2695
|
-
if (prop.type ===
|
|
2498
|
+
if (prop.type === import_utils36.AST_NODE_TYPES.Property && prop.value.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2696
2499
|
checkIdentifier(prop.value);
|
|
2697
|
-
} else if (prop.type ===
|
|
2500
|
+
} else if (prop.type === import_utils36.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2698
2501
|
checkIdentifier(prop.argument);
|
|
2699
2502
|
}
|
|
2700
2503
|
});
|
|
2701
|
-
} else if (pattern.type ===
|
|
2504
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.ArrayPattern) {
|
|
2702
2505
|
pattern.elements.forEach((element) => {
|
|
2703
|
-
if (element?.type ===
|
|
2506
|
+
if (element?.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2704
2507
|
checkIdentifier(element);
|
|
2705
|
-
} else if (element?.type ===
|
|
2508
|
+
} else if (element?.type === import_utils36.AST_NODE_TYPES.RestElement && element.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2706
2509
|
checkIdentifier(element.argument);
|
|
2707
2510
|
}
|
|
2708
2511
|
});
|
|
2709
|
-
} else if (pattern.type ===
|
|
2512
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2710
2513
|
checkIdentifier(pattern.left);
|
|
2711
|
-
} else if (pattern.type ===
|
|
2514
|
+
} else if (pattern.type === import_utils36.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2712
2515
|
checkIdentifier(pattern.argument);
|
|
2713
2516
|
}
|
|
2714
2517
|
};
|
|
@@ -2753,11 +2556,11 @@ var noLazyIdentifiers = createRule36({
|
|
|
2753
2556
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2754
2557
|
|
|
2755
2558
|
// src/rules/no-logic-in-params.ts
|
|
2756
|
-
var
|
|
2757
|
-
var
|
|
2559
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2560
|
+
var createRule33 = import_utils37.ESLintUtils.RuleCreator(
|
|
2758
2561
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2759
2562
|
);
|
|
2760
|
-
var noLogicInParams =
|
|
2563
|
+
var noLogicInParams = createRule33({
|
|
2761
2564
|
name: "no-logic-in-params",
|
|
2762
2565
|
meta: {
|
|
2763
2566
|
type: "suggestion",
|
|
@@ -2772,20 +2575,20 @@ var noLogicInParams = createRule37({
|
|
|
2772
2575
|
defaultOptions: [],
|
|
2773
2576
|
create(context) {
|
|
2774
2577
|
const isComplexExpression = (node) => {
|
|
2775
|
-
if (node.type ===
|
|
2578
|
+
if (node.type === import_utils37.AST_NODE_TYPES.SpreadElement) {
|
|
2776
2579
|
return false;
|
|
2777
2580
|
}
|
|
2778
|
-
if (node.type ===
|
|
2581
|
+
if (node.type === import_utils37.AST_NODE_TYPES.ConditionalExpression) {
|
|
2779
2582
|
return true;
|
|
2780
2583
|
}
|
|
2781
|
-
if (node.type ===
|
|
2584
|
+
if (node.type === import_utils37.AST_NODE_TYPES.LogicalExpression) {
|
|
2782
2585
|
return true;
|
|
2783
2586
|
}
|
|
2784
|
-
if (node.type ===
|
|
2587
|
+
if (node.type === import_utils37.AST_NODE_TYPES.BinaryExpression) {
|
|
2785
2588
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2786
2589
|
return logicalOperators.includes(node.operator);
|
|
2787
2590
|
}
|
|
2788
|
-
if (node.type ===
|
|
2591
|
+
if (node.type === import_utils37.AST_NODE_TYPES.UnaryExpression) {
|
|
2789
2592
|
return node.operator === "!";
|
|
2790
2593
|
}
|
|
2791
2594
|
return false;
|
|
@@ -2798,7 +2601,7 @@ var noLogicInParams = createRule37({
|
|
|
2798
2601
|
messageId: "noLogicInParams"
|
|
2799
2602
|
});
|
|
2800
2603
|
}
|
|
2801
|
-
if (arg.type ===
|
|
2604
|
+
if (arg.type === import_utils37.AST_NODE_TYPES.ArrayExpression) {
|
|
2802
2605
|
arg.elements.forEach((element) => {
|
|
2803
2606
|
if (element && isComplexExpression(element)) {
|
|
2804
2607
|
context.report({
|
|
@@ -2823,46 +2626,46 @@ var noLogicInParams = createRule37({
|
|
|
2823
2626
|
var no_logic_in_params_default = noLogicInParams;
|
|
2824
2627
|
|
|
2825
2628
|
// src/rules/no-misleading-constant-case.ts
|
|
2826
|
-
var
|
|
2827
|
-
var
|
|
2629
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2630
|
+
var createRule34 = import_utils38.ESLintUtils.RuleCreator(
|
|
2828
2631
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2829
2632
|
);
|
|
2830
2633
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2831
|
-
var isAsConstAssertion = (node) => node.type ===
|
|
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";
|
|
2832
2635
|
var isStaticValue2 = (init) => {
|
|
2833
2636
|
if (isAsConstAssertion(init)) {
|
|
2834
2637
|
return true;
|
|
2835
2638
|
}
|
|
2836
|
-
if (init.type ===
|
|
2639
|
+
if (init.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2837
2640
|
return true;
|
|
2838
2641
|
}
|
|
2839
|
-
if (init.type ===
|
|
2642
|
+
if (init.type === import_utils38.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils38.AST_NODE_TYPES.Literal) {
|
|
2840
2643
|
return true;
|
|
2841
2644
|
}
|
|
2842
|
-
if (init.type ===
|
|
2645
|
+
if (init.type === import_utils38.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2843
2646
|
return true;
|
|
2844
2647
|
}
|
|
2845
|
-
if (init.type ===
|
|
2846
|
-
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));
|
|
2847
2650
|
}
|
|
2848
|
-
if (init.type ===
|
|
2651
|
+
if (init.type === import_utils38.AST_NODE_TYPES.ObjectExpression) {
|
|
2849
2652
|
return init.properties.every(
|
|
2850
|
-
(prop) => prop.type ===
|
|
2653
|
+
(prop) => prop.type === import_utils38.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
2851
2654
|
);
|
|
2852
2655
|
}
|
|
2853
2656
|
return false;
|
|
2854
2657
|
};
|
|
2855
2658
|
var isGlobalScope3 = (node) => {
|
|
2856
2659
|
const { parent } = node;
|
|
2857
|
-
if (parent.type ===
|
|
2660
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.Program) {
|
|
2858
2661
|
return true;
|
|
2859
2662
|
}
|
|
2860
|
-
if (parent.type ===
|
|
2663
|
+
if (parent.type === import_utils38.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils38.AST_NODE_TYPES.Program) {
|
|
2861
2664
|
return true;
|
|
2862
2665
|
}
|
|
2863
2666
|
return false;
|
|
2864
2667
|
};
|
|
2865
|
-
var noMisleadingConstantCase =
|
|
2668
|
+
var noMisleadingConstantCase = createRule34({
|
|
2866
2669
|
name: "no-misleading-constant-case",
|
|
2867
2670
|
meta: {
|
|
2868
2671
|
type: "suggestion",
|
|
@@ -2881,7 +2684,7 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2881
2684
|
return {
|
|
2882
2685
|
VariableDeclaration(node) {
|
|
2883
2686
|
node.declarations.forEach((declarator) => {
|
|
2884
|
-
if (declarator.id.type !==
|
|
2687
|
+
if (declarator.id.type !== import_utils38.AST_NODE_TYPES.Identifier) {
|
|
2885
2688
|
return;
|
|
2886
2689
|
}
|
|
2887
2690
|
const { name } = declarator.id;
|
|
@@ -2922,11 +2725,11 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2922
2725
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2923
2726
|
|
|
2924
2727
|
// src/rules/no-nested-interface-declaration.ts
|
|
2925
|
-
var
|
|
2926
|
-
var
|
|
2728
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2729
|
+
var createRule35 = import_utils39.ESLintUtils.RuleCreator(
|
|
2927
2730
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2928
2731
|
);
|
|
2929
|
-
var noNestedInterfaceDeclaration =
|
|
2732
|
+
var noNestedInterfaceDeclaration = createRule35({
|
|
2930
2733
|
name: "no-nested-interface-declaration",
|
|
2931
2734
|
meta: {
|
|
2932
2735
|
type: "suggestion",
|
|
@@ -2947,15 +2750,15 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2947
2750
|
return;
|
|
2948
2751
|
}
|
|
2949
2752
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2950
|
-
if (typeAnnotation.type ===
|
|
2753
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2951
2754
|
context.report({
|
|
2952
2755
|
node: typeAnnotation,
|
|
2953
2756
|
messageId: "noNestedInterface"
|
|
2954
2757
|
});
|
|
2955
2758
|
return;
|
|
2956
2759
|
}
|
|
2957
|
-
if (typeAnnotation.type ===
|
|
2958
|
-
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) {
|
|
2959
2762
|
context.report({
|
|
2960
2763
|
node: typeAnnotation.elementType,
|
|
2961
2764
|
messageId: "noNestedInterface"
|
|
@@ -2963,9 +2766,9 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2963
2766
|
}
|
|
2964
2767
|
return;
|
|
2965
2768
|
}
|
|
2966
|
-
if (typeAnnotation.type ===
|
|
2769
|
+
if (typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2967
2770
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2968
|
-
if (param.type ===
|
|
2771
|
+
if (param.type === import_utils39.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2969
2772
|
context.report({
|
|
2970
2773
|
node: param,
|
|
2971
2774
|
messageId: "noNestedInterface"
|
|
@@ -2980,11 +2783,11 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2980
2783
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2981
2784
|
|
|
2982
2785
|
// src/rules/no-nested-ternary.ts
|
|
2983
|
-
var
|
|
2984
|
-
var
|
|
2786
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2787
|
+
var createRule36 = import_utils40.ESLintUtils.RuleCreator(
|
|
2985
2788
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2986
2789
|
);
|
|
2987
|
-
var noNestedTernary =
|
|
2790
|
+
var noNestedTernary = createRule36({
|
|
2988
2791
|
name: "no-nested-ternary",
|
|
2989
2792
|
meta: {
|
|
2990
2793
|
type: "suggestion",
|
|
@@ -3001,13 +2804,13 @@ var noNestedTernary = createRule40({
|
|
|
3001
2804
|
return {
|
|
3002
2805
|
ConditionalExpression(node) {
|
|
3003
2806
|
const { consequent, alternate } = node;
|
|
3004
|
-
if (consequent.type ===
|
|
2807
|
+
if (consequent.type === import_utils40.AST_NODE_TYPES.ConditionalExpression) {
|
|
3005
2808
|
context.report({
|
|
3006
2809
|
node: consequent,
|
|
3007
2810
|
messageId: "noNestedTernary"
|
|
3008
2811
|
});
|
|
3009
2812
|
}
|
|
3010
|
-
if (alternate.type ===
|
|
2813
|
+
if (alternate.type === import_utils40.AST_NODE_TYPES.ConditionalExpression) {
|
|
3011
2814
|
context.report({
|
|
3012
2815
|
node: alternate,
|
|
3013
2816
|
messageId: "noNestedTernary"
|
|
@@ -3020,11 +2823,11 @@ var noNestedTernary = createRule40({
|
|
|
3020
2823
|
var no_nested_ternary_default = noNestedTernary;
|
|
3021
2824
|
|
|
3022
2825
|
// src/rules/no-relative-imports.ts
|
|
3023
|
-
var
|
|
3024
|
-
var
|
|
2826
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2827
|
+
var createRule37 = import_utils41.ESLintUtils.RuleCreator(
|
|
3025
2828
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3026
2829
|
);
|
|
3027
|
-
var noRelativeImports =
|
|
2830
|
+
var noRelativeImports = createRule37({
|
|
3028
2831
|
name: "no-relative-imports",
|
|
3029
2832
|
meta: {
|
|
3030
2833
|
type: "suggestion",
|
|
@@ -3048,22 +2851,22 @@ var noRelativeImports = createRule41({
|
|
|
3048
2851
|
};
|
|
3049
2852
|
return {
|
|
3050
2853
|
ImportDeclaration(node) {
|
|
3051
|
-
if (node.source.type ===
|
|
2854
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3052
2855
|
checkImportPath(node.source.value, node);
|
|
3053
2856
|
}
|
|
3054
2857
|
},
|
|
3055
2858
|
ImportExpression(node) {
|
|
3056
|
-
if (node.source.type ===
|
|
2859
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3057
2860
|
checkImportPath(node.source.value, node);
|
|
3058
2861
|
}
|
|
3059
2862
|
},
|
|
3060
2863
|
ExportNamedDeclaration(node) {
|
|
3061
|
-
if (node.source?.type ===
|
|
2864
|
+
if (node.source?.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3062
2865
|
checkImportPath(node.source.value, node);
|
|
3063
2866
|
}
|
|
3064
2867
|
},
|
|
3065
2868
|
ExportAllDeclaration(node) {
|
|
3066
|
-
if (node.source.type ===
|
|
2869
|
+
if (node.source.type === import_utils41.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3067
2870
|
checkImportPath(node.source.value, node);
|
|
3068
2871
|
}
|
|
3069
2872
|
}
|
|
@@ -3073,8 +2876,8 @@ var noRelativeImports = createRule41({
|
|
|
3073
2876
|
var no_relative_imports_default = noRelativeImports;
|
|
3074
2877
|
|
|
3075
2878
|
// src/rules/no-single-char-variables.ts
|
|
3076
|
-
var
|
|
3077
|
-
var
|
|
2879
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2880
|
+
var createRule38 = import_utils42.ESLintUtils.RuleCreator(
|
|
3078
2881
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3079
2882
|
);
|
|
3080
2883
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -3086,7 +2889,7 @@ var isForLoopInit = (node) => {
|
|
|
3086
2889
|
if (!parentNode) {
|
|
3087
2890
|
return false;
|
|
3088
2891
|
}
|
|
3089
|
-
if (parentNode.type ===
|
|
2892
|
+
if (parentNode.type === import_utils42.AST_NODE_TYPES.ForStatement) {
|
|
3090
2893
|
const { init } = parentNode;
|
|
3091
2894
|
if (init && init === current) {
|
|
3092
2895
|
return true;
|
|
@@ -3105,7 +2908,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
3105
2908
|
}
|
|
3106
2909
|
return false;
|
|
3107
2910
|
};
|
|
3108
|
-
var noSingleCharVariables =
|
|
2911
|
+
var noSingleCharVariables = createRule38({
|
|
3109
2912
|
name: "no-single-char-variables",
|
|
3110
2913
|
meta: {
|
|
3111
2914
|
type: "suggestion",
|
|
@@ -3134,27 +2937,27 @@ var noSingleCharVariables = createRule42({
|
|
|
3134
2937
|
});
|
|
3135
2938
|
};
|
|
3136
2939
|
const checkPattern = (pattern, declarationNode) => {
|
|
3137
|
-
if (pattern.type ===
|
|
2940
|
+
if (pattern.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3138
2941
|
checkIdentifier(pattern, declarationNode);
|
|
3139
|
-
} else if (pattern.type ===
|
|
2942
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.ObjectPattern) {
|
|
3140
2943
|
pattern.properties.forEach((prop) => {
|
|
3141
|
-
if (prop.type ===
|
|
2944
|
+
if (prop.type === import_utils42.AST_NODE_TYPES.Property && prop.value.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3142
2945
|
checkIdentifier(prop.value, declarationNode);
|
|
3143
|
-
} else if (prop.type ===
|
|
2946
|
+
} else if (prop.type === import_utils42.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3144
2947
|
checkIdentifier(prop.argument, declarationNode);
|
|
3145
2948
|
}
|
|
3146
2949
|
});
|
|
3147
|
-
} else if (pattern.type ===
|
|
2950
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.ArrayPattern) {
|
|
3148
2951
|
pattern.elements.forEach((element) => {
|
|
3149
|
-
if (element?.type ===
|
|
2952
|
+
if (element?.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3150
2953
|
checkIdentifier(element, declarationNode);
|
|
3151
|
-
} else if (element?.type ===
|
|
2954
|
+
} else if (element?.type === import_utils42.AST_NODE_TYPES.RestElement && element.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3152
2955
|
checkIdentifier(element.argument, declarationNode);
|
|
3153
2956
|
}
|
|
3154
2957
|
});
|
|
3155
|
-
} else if (pattern.type ===
|
|
2958
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3156
2959
|
checkIdentifier(pattern.left, declarationNode);
|
|
3157
|
-
} else if (pattern.type ===
|
|
2960
|
+
} else if (pattern.type === import_utils42.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils42.AST_NODE_TYPES.Identifier) {
|
|
3158
2961
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3159
2962
|
}
|
|
3160
2963
|
};
|
|
@@ -3188,11 +2991,11 @@ var noSingleCharVariables = createRule42({
|
|
|
3188
2991
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3189
2992
|
|
|
3190
2993
|
// src/rules/prefer-async-await.ts
|
|
3191
|
-
var
|
|
3192
|
-
var
|
|
2994
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2995
|
+
var createRule39 = import_utils43.ESLintUtils.RuleCreator(
|
|
3193
2996
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3194
2997
|
);
|
|
3195
|
-
var preferAsyncAwait =
|
|
2998
|
+
var preferAsyncAwait = createRule39({
|
|
3196
2999
|
name: "prefer-async-await",
|
|
3197
3000
|
meta: {
|
|
3198
3001
|
type: "suggestion",
|
|
@@ -3208,7 +3011,7 @@ var preferAsyncAwait = createRule43({
|
|
|
3208
3011
|
create(context) {
|
|
3209
3012
|
return {
|
|
3210
3013
|
CallExpression(node) {
|
|
3211
|
-
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") {
|
|
3212
3015
|
context.report({
|
|
3213
3016
|
node: node.callee.property,
|
|
3214
3017
|
messageId: "preferAsyncAwait"
|
|
@@ -3221,11 +3024,11 @@ var preferAsyncAwait = createRule43({
|
|
|
3221
3024
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3222
3025
|
|
|
3223
3026
|
// src/rules/prefer-destructuring-params.ts
|
|
3224
|
-
var
|
|
3225
|
-
var
|
|
3027
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
3028
|
+
var createRule40 = import_utils44.ESLintUtils.RuleCreator(
|
|
3226
3029
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3227
3030
|
);
|
|
3228
|
-
var preferDestructuringParams =
|
|
3031
|
+
var preferDestructuringParams = createRule40({
|
|
3229
3032
|
name: "prefer-destructuring-params",
|
|
3230
3033
|
meta: {
|
|
3231
3034
|
type: "suggestion",
|
|
@@ -3241,18 +3044,18 @@ var preferDestructuringParams = createRule44({
|
|
|
3241
3044
|
create(context) {
|
|
3242
3045
|
const isCallbackFunction2 = (node) => {
|
|
3243
3046
|
const { parent } = node;
|
|
3244
|
-
return parent?.type ===
|
|
3047
|
+
return parent?.type === import_utils44.AST_NODE_TYPES.CallExpression;
|
|
3245
3048
|
};
|
|
3246
3049
|
const isDeveloperFunction = (node) => {
|
|
3247
|
-
if (node.type ===
|
|
3050
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3248
3051
|
return true;
|
|
3249
3052
|
}
|
|
3250
|
-
if (node.type ===
|
|
3053
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionExpression || node.type === import_utils44.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3251
3054
|
if (isCallbackFunction2(node)) {
|
|
3252
3055
|
return false;
|
|
3253
3056
|
}
|
|
3254
3057
|
const { parent } = node;
|
|
3255
|
-
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;
|
|
3256
3059
|
}
|
|
3257
3060
|
return false;
|
|
3258
3061
|
};
|
|
@@ -3264,7 +3067,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3264
3067
|
if (!isDeveloperFunction(node)) {
|
|
3265
3068
|
return;
|
|
3266
3069
|
}
|
|
3267
|
-
if (node.type ===
|
|
3070
|
+
if (node.type === import_utils44.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3268
3071
|
const functionName = node.id.name;
|
|
3269
3072
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3270
3073
|
return;
|
|
@@ -3274,7 +3077,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3274
3077
|
return;
|
|
3275
3078
|
}
|
|
3276
3079
|
const hasNonDestructuredParams = node.params.some(
|
|
3277
|
-
(param) => param.type !==
|
|
3080
|
+
(param) => param.type !== import_utils44.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils44.AST_NODE_TYPES.RestElement
|
|
3278
3081
|
);
|
|
3279
3082
|
if (hasNonDestructuredParams) {
|
|
3280
3083
|
context.report({
|
|
@@ -3293,8 +3096,8 @@ var preferDestructuringParams = createRule44({
|
|
|
3293
3096
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3294
3097
|
|
|
3295
3098
|
// src/rules/prefer-function-declaration.ts
|
|
3296
|
-
var
|
|
3297
|
-
var
|
|
3099
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
3100
|
+
var createRule41 = import_utils45.ESLintUtils.RuleCreator(
|
|
3298
3101
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3299
3102
|
);
|
|
3300
3103
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3303,33 +3106,33 @@ var isCallbackContext = (node) => {
|
|
|
3303
3106
|
if (!parent) {
|
|
3304
3107
|
return false;
|
|
3305
3108
|
}
|
|
3306
|
-
if (parent.type ===
|
|
3109
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3307
3110
|
return true;
|
|
3308
3111
|
}
|
|
3309
|
-
if (parent.type ===
|
|
3112
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3310
3113
|
return true;
|
|
3311
3114
|
}
|
|
3312
|
-
if (parent.type ===
|
|
3115
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ReturnStatement) {
|
|
3313
3116
|
return true;
|
|
3314
3117
|
}
|
|
3315
|
-
if (parent.type ===
|
|
3118
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.Property) {
|
|
3316
3119
|
return true;
|
|
3317
3120
|
}
|
|
3318
|
-
if (parent.type ===
|
|
3121
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
3319
3122
|
return true;
|
|
3320
3123
|
}
|
|
3321
|
-
if (parent.type ===
|
|
3124
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.ConditionalExpression) {
|
|
3322
3125
|
return true;
|
|
3323
3126
|
}
|
|
3324
|
-
if (parent.type ===
|
|
3127
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.LogicalExpression) {
|
|
3325
3128
|
return true;
|
|
3326
3129
|
}
|
|
3327
|
-
if (parent.type ===
|
|
3130
|
+
if (parent.type === import_utils45.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3328
3131
|
return true;
|
|
3329
3132
|
}
|
|
3330
3133
|
return false;
|
|
3331
3134
|
};
|
|
3332
|
-
var preferFunctionDeclaration =
|
|
3135
|
+
var preferFunctionDeclaration = createRule41({
|
|
3333
3136
|
name: "prefer-function-declaration",
|
|
3334
3137
|
meta: {
|
|
3335
3138
|
type: "suggestion",
|
|
@@ -3350,14 +3153,14 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3350
3153
|
}
|
|
3351
3154
|
return {
|
|
3352
3155
|
VariableDeclarator(node) {
|
|
3353
|
-
if (node.id.type !==
|
|
3156
|
+
if (node.id.type !== import_utils45.AST_NODE_TYPES.Identifier) {
|
|
3354
3157
|
return;
|
|
3355
3158
|
}
|
|
3356
3159
|
const { init } = node;
|
|
3357
3160
|
if (!init) {
|
|
3358
3161
|
return;
|
|
3359
3162
|
}
|
|
3360
|
-
if (init.type ===
|
|
3163
|
+
if (init.type === import_utils45.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3361
3164
|
if (isCallbackContext(init)) {
|
|
3362
3165
|
return;
|
|
3363
3166
|
}
|
|
@@ -3367,7 +3170,7 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3367
3170
|
data: { name: node.id.name }
|
|
3368
3171
|
});
|
|
3369
3172
|
}
|
|
3370
|
-
if (init.type ===
|
|
3173
|
+
if (init.type === import_utils45.AST_NODE_TYPES.FunctionExpression) {
|
|
3371
3174
|
if (isCallbackContext(init)) {
|
|
3372
3175
|
return;
|
|
3373
3176
|
}
|
|
@@ -3384,11 +3187,11 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3384
3187
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3385
3188
|
|
|
3386
3189
|
// src/rules/prefer-guard-clause.ts
|
|
3387
|
-
var
|
|
3388
|
-
var
|
|
3190
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3191
|
+
var createRule42 = import_utils46.ESLintUtils.RuleCreator(
|
|
3389
3192
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3390
3193
|
);
|
|
3391
|
-
var preferGuardClause =
|
|
3194
|
+
var preferGuardClause = createRule42({
|
|
3392
3195
|
name: "prefer-guard-clause",
|
|
3393
3196
|
meta: {
|
|
3394
3197
|
type: "suggestion",
|
|
@@ -3405,8 +3208,8 @@ var preferGuardClause = createRule46({
|
|
|
3405
3208
|
return {
|
|
3406
3209
|
IfStatement(node) {
|
|
3407
3210
|
const { consequent } = node;
|
|
3408
|
-
if (consequent.type ===
|
|
3409
|
-
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);
|
|
3410
3213
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3411
3214
|
context.report({
|
|
3412
3215
|
node,
|
|
@@ -3414,7 +3217,7 @@ var preferGuardClause = createRule46({
|
|
|
3414
3217
|
});
|
|
3415
3218
|
}
|
|
3416
3219
|
}
|
|
3417
|
-
if (consequent.type ===
|
|
3220
|
+
if (consequent.type === import_utils46.AST_NODE_TYPES.IfStatement) {
|
|
3418
3221
|
context.report({
|
|
3419
3222
|
node,
|
|
3420
3223
|
messageId: "preferGuardClause"
|
|
@@ -3427,11 +3230,11 @@ var preferGuardClause = createRule46({
|
|
|
3427
3230
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3428
3231
|
|
|
3429
3232
|
// src/rules/prefer-import-type.ts
|
|
3430
|
-
var
|
|
3431
|
-
var
|
|
3233
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3234
|
+
var createRule43 = import_utils47.ESLintUtils.RuleCreator(
|
|
3432
3235
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3433
3236
|
);
|
|
3434
|
-
var preferImportType =
|
|
3237
|
+
var preferImportType = createRule43({
|
|
3435
3238
|
name: "prefer-import-type",
|
|
3436
3239
|
meta: {
|
|
3437
3240
|
type: "suggestion",
|
|
@@ -3450,22 +3253,22 @@ var preferImportType = createRule47({
|
|
|
3450
3253
|
let current = node;
|
|
3451
3254
|
while (current) {
|
|
3452
3255
|
switch (current.type) {
|
|
3453
|
-
case
|
|
3454
|
-
case
|
|
3455
|
-
case
|
|
3456
|
-
case
|
|
3457
|
-
case
|
|
3458
|
-
case
|
|
3459
|
-
case
|
|
3460
|
-
case
|
|
3461
|
-
case
|
|
3462
|
-
case
|
|
3463
|
-
case
|
|
3464
|
-
case
|
|
3465
|
-
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:
|
|
3466
3269
|
return true;
|
|
3467
|
-
case
|
|
3468
|
-
case
|
|
3270
|
+
case import_utils47.AST_NODE_TYPES.MemberExpression:
|
|
3271
|
+
case import_utils47.AST_NODE_TYPES.Identifier:
|
|
3469
3272
|
current = current.parent;
|
|
3470
3273
|
break;
|
|
3471
3274
|
default:
|
|
@@ -3495,27 +3298,27 @@ var preferImportType = createRule47({
|
|
|
3495
3298
|
return false;
|
|
3496
3299
|
}
|
|
3497
3300
|
switch (parent.type) {
|
|
3498
|
-
case
|
|
3499
|
-
case
|
|
3500
|
-
case
|
|
3501
|
-
case
|
|
3502
|
-
case
|
|
3503
|
-
case
|
|
3504
|
-
case
|
|
3505
|
-
case
|
|
3506
|
-
case
|
|
3507
|
-
case
|
|
3508
|
-
case
|
|
3509
|
-
case
|
|
3510
|
-
case
|
|
3511
|
-
case
|
|
3512
|
-
case
|
|
3513
|
-
case
|
|
3514
|
-
case
|
|
3515
|
-
case
|
|
3516
|
-
case
|
|
3517
|
-
case
|
|
3518
|
-
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:
|
|
3519
3322
|
return true;
|
|
3520
3323
|
default:
|
|
3521
3324
|
return false;
|
|
@@ -3526,6 +3329,12 @@ var preferImportType = createRule47({
|
|
|
3526
3329
|
if (node.importKind === "type") {
|
|
3527
3330
|
return;
|
|
3528
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
|
+
}
|
|
3529
3338
|
if (context.filename.includes(".test.") || context.filename.includes(".spec.") || context.filename.includes("__tests__")) {
|
|
3530
3339
|
return;
|
|
3531
3340
|
}
|
|
@@ -3539,13 +3348,13 @@ var preferImportType = createRule47({
|
|
|
3539
3348
|
}
|
|
3540
3349
|
const scope = context.sourceCode.getScope(node);
|
|
3541
3350
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3542
|
-
if (specifier.type ===
|
|
3351
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3543
3352
|
return false;
|
|
3544
3353
|
}
|
|
3545
|
-
if (specifier.type ===
|
|
3354
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3546
3355
|
return false;
|
|
3547
3356
|
}
|
|
3548
|
-
if (specifier.type ===
|
|
3357
|
+
if (specifier.type === import_utils47.AST_NODE_TYPES.ImportSpecifier) {
|
|
3549
3358
|
const localName = specifier.local.name;
|
|
3550
3359
|
return !isUsedAsValue(localName, scope);
|
|
3551
3360
|
}
|
|
@@ -3571,19 +3380,19 @@ var preferImportType = createRule47({
|
|
|
3571
3380
|
var prefer_import_type_default = preferImportType;
|
|
3572
3381
|
|
|
3573
3382
|
// src/rules/prefer-inline-literal-union.ts
|
|
3574
|
-
var
|
|
3575
|
-
var
|
|
3383
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3384
|
+
var createRule44 = import_utils48.ESLintUtils.RuleCreator(
|
|
3576
3385
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3577
3386
|
);
|
|
3578
3387
|
function isLiteralUnionType(node) {
|
|
3579
|
-
if (node.type !==
|
|
3388
|
+
if (node.type !== import_utils48.AST_NODE_TYPES.TSUnionType) {
|
|
3580
3389
|
return false;
|
|
3581
3390
|
}
|
|
3582
3391
|
return node.types.every(
|
|
3583
|
-
(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
|
|
3584
3393
|
);
|
|
3585
3394
|
}
|
|
3586
|
-
var preferInlineLiteralUnion =
|
|
3395
|
+
var preferInlineLiteralUnion = createRule44({
|
|
3587
3396
|
name: "prefer-inline-literal-union",
|
|
3588
3397
|
meta: {
|
|
3589
3398
|
type: "suggestion",
|
|
@@ -3610,10 +3419,10 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3610
3419
|
return;
|
|
3611
3420
|
}
|
|
3612
3421
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3613
|
-
if (typeAnnotation.type !==
|
|
3422
|
+
if (typeAnnotation.type !== import_utils48.AST_NODE_TYPES.TSTypeReference) {
|
|
3614
3423
|
return;
|
|
3615
3424
|
}
|
|
3616
|
-
if (typeAnnotation.typeName.type !==
|
|
3425
|
+
if (typeAnnotation.typeName.type !== import_utils48.AST_NODE_TYPES.Identifier) {
|
|
3617
3426
|
return;
|
|
3618
3427
|
}
|
|
3619
3428
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3637,12 +3446,12 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3637
3446
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3638
3447
|
|
|
3639
3448
|
// src/rules/prefer-inline-type-export.ts
|
|
3640
|
-
var
|
|
3641
|
-
var
|
|
3449
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3450
|
+
var createRule45 = import_utils49.ESLintUtils.RuleCreator(
|
|
3642
3451
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3643
3452
|
);
|
|
3644
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3645
|
-
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({
|
|
3646
3455
|
name: "prefer-inline-type-export",
|
|
3647
3456
|
meta: {
|
|
3648
3457
|
type: "suggestion",
|
|
@@ -3659,12 +3468,12 @@ var preferInlineTypeExport = createRule49({
|
|
|
3659
3468
|
create(context) {
|
|
3660
3469
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3661
3470
|
function collectDeclaration(node) {
|
|
3662
|
-
if (node.parent.type !==
|
|
3471
|
+
if (node.parent.type !== import_utils49.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3663
3472
|
typeDeclarations.set(node.id.name, node);
|
|
3664
3473
|
}
|
|
3665
3474
|
}
|
|
3666
3475
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3667
|
-
if (specifier.local.type !==
|
|
3476
|
+
if (specifier.local.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3668
3477
|
return;
|
|
3669
3478
|
}
|
|
3670
3479
|
const { name } = specifier.local;
|
|
@@ -3697,16 +3506,16 @@ var preferInlineTypeExport = createRule49({
|
|
|
3697
3506
|
return {
|
|
3698
3507
|
Program(node) {
|
|
3699
3508
|
node.body.forEach((statement) => {
|
|
3700
|
-
if (statement.type ===
|
|
3509
|
+
if (statement.type === import_utils49.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils49.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3701
3510
|
collectDeclaration(statement);
|
|
3702
3511
|
}
|
|
3703
3512
|
});
|
|
3704
3513
|
node.body.forEach((statement) => {
|
|
3705
|
-
if (statement.type !==
|
|
3514
|
+
if (statement.type !== import_utils49.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3706
3515
|
return;
|
|
3707
3516
|
}
|
|
3708
3517
|
statement.specifiers.forEach((specifier) => {
|
|
3709
|
-
if (specifier.local.type !==
|
|
3518
|
+
if (specifier.local.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3710
3519
|
return;
|
|
3711
3520
|
}
|
|
3712
3521
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3722,12 +3531,69 @@ var preferInlineTypeExport = createRule49({
|
|
|
3722
3531
|
});
|
|
3723
3532
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3724
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
|
+
|
|
3725
3591
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3726
|
-
var
|
|
3727
|
-
var
|
|
3592
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3593
|
+
var createRule47 = import_utils52.ESLintUtils.RuleCreator(
|
|
3728
3594
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3729
3595
|
);
|
|
3730
|
-
var preferInterfaceOverInlineTypes =
|
|
3596
|
+
var preferInterfaceOverInlineTypes = createRule47({
|
|
3731
3597
|
name: "prefer-interface-over-inline-types",
|
|
3732
3598
|
meta: {
|
|
3733
3599
|
type: "suggestion",
|
|
@@ -3743,54 +3609,54 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3743
3609
|
defaultOptions: [],
|
|
3744
3610
|
create(context) {
|
|
3745
3611
|
function hasJSXInConditional(node) {
|
|
3746
|
-
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;
|
|
3747
3613
|
}
|
|
3748
3614
|
function hasJSXInLogical(node) {
|
|
3749
|
-
return node.right.type ===
|
|
3615
|
+
return node.right.type === import_utils52.AST_NODE_TYPES.JSXElement || node.right.type === import_utils52.AST_NODE_TYPES.JSXFragment;
|
|
3750
3616
|
}
|
|
3751
3617
|
function hasJSXReturn(block) {
|
|
3752
3618
|
return block.body.some((stmt) => {
|
|
3753
|
-
if (stmt.type ===
|
|
3754
|
-
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);
|
|
3755
3621
|
}
|
|
3756
3622
|
return false;
|
|
3757
3623
|
});
|
|
3758
3624
|
}
|
|
3759
3625
|
function isReactComponent2(node) {
|
|
3760
|
-
if (node.type ===
|
|
3761
|
-
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) {
|
|
3762
3628
|
return true;
|
|
3763
3629
|
}
|
|
3764
|
-
if (node.body.type ===
|
|
3630
|
+
if (node.body.type === import_utils52.AST_NODE_TYPES.BlockStatement) {
|
|
3765
3631
|
return hasJSXReturn(node.body);
|
|
3766
3632
|
}
|
|
3767
|
-
} else if (node.type ===
|
|
3768
|
-
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) {
|
|
3769
3635
|
return hasJSXReturn(node.body);
|
|
3770
3636
|
}
|
|
3771
3637
|
}
|
|
3772
3638
|
return false;
|
|
3773
3639
|
}
|
|
3774
3640
|
function isInlineTypeAnnotation(node) {
|
|
3775
|
-
if (node.type ===
|
|
3641
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3776
3642
|
return true;
|
|
3777
3643
|
}
|
|
3778
|
-
if (node.type ===
|
|
3779
|
-
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);
|
|
3780
3646
|
}
|
|
3781
|
-
if (node.type ===
|
|
3647
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
3782
3648
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3783
3649
|
}
|
|
3784
3650
|
return false;
|
|
3785
3651
|
}
|
|
3786
3652
|
function hasInlineObjectType(node) {
|
|
3787
|
-
if (node.type ===
|
|
3653
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3788
3654
|
return true;
|
|
3789
3655
|
}
|
|
3790
|
-
if (node.type ===
|
|
3791
|
-
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);
|
|
3792
3658
|
}
|
|
3793
|
-
if (node.type ===
|
|
3659
|
+
if (node.type === import_utils52.AST_NODE_TYPES.TSUnionType) {
|
|
3794
3660
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3795
3661
|
}
|
|
3796
3662
|
return false;
|
|
@@ -3803,7 +3669,7 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3803
3669
|
return;
|
|
3804
3670
|
}
|
|
3805
3671
|
const param = node.params[0];
|
|
3806
|
-
if (param.type ===
|
|
3672
|
+
if (param.type === import_utils52.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3807
3673
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3808
3674
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3809
3675
|
context.report({
|
|
@@ -3823,11 +3689,11 @@ var preferInterfaceOverInlineTypes = createRule50({
|
|
|
3823
3689
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3824
3690
|
|
|
3825
3691
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3826
|
-
var
|
|
3827
|
-
var
|
|
3692
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3693
|
+
var createRule48 = import_utils53.ESLintUtils.RuleCreator(
|
|
3828
3694
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3829
3695
|
);
|
|
3830
|
-
var preferJSXTemplateLiterals =
|
|
3696
|
+
var preferJSXTemplateLiterals = createRule48({
|
|
3831
3697
|
name: "prefer-jsx-template-literals",
|
|
3832
3698
|
meta: {
|
|
3833
3699
|
type: "suggestion",
|
|
@@ -3896,9 +3762,9 @@ var preferJSXTemplateLiterals = createRule51({
|
|
|
3896
3762
|
if (!child || !nextChild) {
|
|
3897
3763
|
return;
|
|
3898
3764
|
}
|
|
3899
|
-
if (child.type ===
|
|
3765
|
+
if (child.type === import_utils53.AST_NODE_TYPES.JSXText && nextChild.type === import_utils53.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3900
3766
|
handleTextBeforeExpression(child, nextChild);
|
|
3901
|
-
} else if (child.type ===
|
|
3767
|
+
} else if (child.type === import_utils53.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils53.AST_NODE_TYPES.JSXText) {
|
|
3902
3768
|
handleExpressionBeforeText(child, nextChild);
|
|
3903
3769
|
}
|
|
3904
3770
|
}
|
|
@@ -3911,11 +3777,32 @@ var preferJSXTemplateLiterals = createRule51({
|
|
|
3911
3777
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3912
3778
|
|
|
3913
3779
|
// src/rules/prefer-named-param-types.ts
|
|
3914
|
-
var
|
|
3915
|
-
var
|
|
3780
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3781
|
+
var createRule49 = import_utils54.ESLintUtils.RuleCreator(
|
|
3916
3782
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3917
3783
|
);
|
|
3918
|
-
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({
|
|
3919
3806
|
name: "prefer-named-param-types",
|
|
3920
3807
|
meta: {
|
|
3921
3808
|
type: "suggestion",
|
|
@@ -3930,16 +3817,16 @@ var preferNamedParamTypes = createRule52({
|
|
|
3930
3817
|
defaultOptions: [],
|
|
3931
3818
|
create(context) {
|
|
3932
3819
|
function hasInlineObjectType(param) {
|
|
3933
|
-
if (param.type ===
|
|
3820
|
+
if (param.type === import_utils54.AST_NODE_TYPES.AssignmentPattern) {
|
|
3934
3821
|
return hasInlineObjectType(param.left);
|
|
3935
3822
|
}
|
|
3936
|
-
if (param.type ===
|
|
3937
|
-
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) {
|
|
3938
3825
|
return true;
|
|
3939
3826
|
}
|
|
3940
3827
|
}
|
|
3941
|
-
if (param.type ===
|
|
3942
|
-
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) {
|
|
3943
3830
|
return true;
|
|
3944
3831
|
}
|
|
3945
3832
|
}
|
|
@@ -3952,6 +3839,9 @@ var preferNamedParamTypes = createRule52({
|
|
|
3952
3839
|
} else if ("value" in node && node.value) {
|
|
3953
3840
|
params = node.value.params;
|
|
3954
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
|
+
}
|
|
3955
3845
|
params.forEach((param) => {
|
|
3956
3846
|
if (hasInlineObjectType(param)) {
|
|
3957
3847
|
context.report({
|
|
@@ -3972,12 +3862,91 @@ var preferNamedParamTypes = createRule52({
|
|
|
3972
3862
|
});
|
|
3973
3863
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3974
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
|
+
|
|
3975
3944
|
// src/rules/prefer-react-import-types.ts
|
|
3976
|
-
var
|
|
3977
|
-
var
|
|
3945
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
3946
|
+
var createRule51 = import_utils56.ESLintUtils.RuleCreator(
|
|
3978
3947
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3979
3948
|
);
|
|
3980
|
-
var preferReactImportTypes =
|
|
3949
|
+
var preferReactImportTypes = createRule51({
|
|
3981
3950
|
name: "prefer-react-import-types",
|
|
3982
3951
|
meta: {
|
|
3983
3952
|
type: "suggestion",
|
|
@@ -4053,7 +4022,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4053
4022
|
]);
|
|
4054
4023
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
4055
4024
|
function checkMemberExpression(node) {
|
|
4056
|
-
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)) {
|
|
4057
4026
|
const typeName = node.property.name;
|
|
4058
4027
|
const isType = reactTypes.has(typeName);
|
|
4059
4028
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4070,7 +4039,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4070
4039
|
return {
|
|
4071
4040
|
MemberExpression: checkMemberExpression,
|
|
4072
4041
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
4073
|
-
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)) {
|
|
4074
4043
|
const typeName = node.right.name;
|
|
4075
4044
|
const isType = reactTypes.has(typeName);
|
|
4076
4045
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4090,11 +4059,11 @@ var preferReactImportTypes = createRule53({
|
|
|
4090
4059
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4091
4060
|
|
|
4092
4061
|
// src/rules/react-props-destructure.ts
|
|
4093
|
-
var
|
|
4094
|
-
var
|
|
4062
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
4063
|
+
var createRule52 = import_utils57.ESLintUtils.RuleCreator(
|
|
4095
4064
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4096
4065
|
);
|
|
4097
|
-
var reactPropsDestructure =
|
|
4066
|
+
var reactPropsDestructure = createRule52({
|
|
4098
4067
|
name: "react-props-destructure",
|
|
4099
4068
|
meta: {
|
|
4100
4069
|
type: "suggestion",
|
|
@@ -4110,29 +4079,29 @@ var reactPropsDestructure = createRule54({
|
|
|
4110
4079
|
defaultOptions: [],
|
|
4111
4080
|
create(context) {
|
|
4112
4081
|
function hasJSXInConditional(node) {
|
|
4113
|
-
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;
|
|
4114
4083
|
}
|
|
4115
4084
|
function hasJSXInLogical(node) {
|
|
4116
|
-
return node.right.type ===
|
|
4085
|
+
return node.right.type === import_utils57.AST_NODE_TYPES.JSXElement || node.right.type === import_utils57.AST_NODE_TYPES.JSXFragment;
|
|
4117
4086
|
}
|
|
4118
4087
|
function hasJSXReturn(block) {
|
|
4119
4088
|
return block.body.some((stmt) => {
|
|
4120
|
-
if (stmt.type ===
|
|
4121
|
-
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);
|
|
4122
4091
|
}
|
|
4123
4092
|
return false;
|
|
4124
4093
|
});
|
|
4125
4094
|
}
|
|
4126
4095
|
function isReactComponent2(node) {
|
|
4127
|
-
if (node.type ===
|
|
4128
|
-
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) {
|
|
4129
4098
|
return true;
|
|
4130
4099
|
}
|
|
4131
|
-
if (node.body.type ===
|
|
4100
|
+
if (node.body.type === import_utils57.AST_NODE_TYPES.BlockStatement) {
|
|
4132
4101
|
return hasJSXReturn(node.body);
|
|
4133
4102
|
}
|
|
4134
|
-
} else if (node.type ===
|
|
4135
|
-
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) {
|
|
4136
4105
|
return hasJSXReturn(node.body);
|
|
4137
4106
|
}
|
|
4138
4107
|
}
|
|
@@ -4146,9 +4115,9 @@ var reactPropsDestructure = createRule54({
|
|
|
4146
4115
|
return;
|
|
4147
4116
|
}
|
|
4148
4117
|
const param = node.params[0];
|
|
4149
|
-
if (param.type ===
|
|
4150
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4151
|
-
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) {
|
|
4152
4121
|
return prop.key.name;
|
|
4153
4122
|
}
|
|
4154
4123
|
return null;
|
|
@@ -4175,57 +4144,57 @@ var reactPropsDestructure = createRule54({
|
|
|
4175
4144
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4176
4145
|
|
|
4177
4146
|
// src/rules/require-explicit-return-type.ts
|
|
4178
|
-
var
|
|
4179
|
-
var
|
|
4147
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
4148
|
+
var createRule53 = import_utils58.ESLintUtils.RuleCreator(
|
|
4180
4149
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4181
4150
|
);
|
|
4182
4151
|
var isReactComponent = (node) => {
|
|
4183
|
-
if (node.type ===
|
|
4152
|
+
if (node.type === import_utils58.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4184
4153
|
const { parent } = node;
|
|
4185
|
-
if (parent?.type ===
|
|
4154
|
+
if (parent?.type === import_utils58.AST_NODE_TYPES.VariableDeclarator) {
|
|
4186
4155
|
const { id } = parent;
|
|
4187
|
-
if (id.type ===
|
|
4156
|
+
if (id.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
4188
4157
|
return /^[A-Z]/.test(id.name);
|
|
4189
4158
|
}
|
|
4190
4159
|
}
|
|
4191
4160
|
}
|
|
4192
|
-
if (node.type ===
|
|
4161
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4193
4162
|
return /^[A-Z]/.test(node.id.name);
|
|
4194
4163
|
}
|
|
4195
4164
|
return false;
|
|
4196
4165
|
};
|
|
4197
4166
|
var isCallbackFunction = (node) => {
|
|
4198
|
-
if (node.type ===
|
|
4167
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4199
4168
|
return false;
|
|
4200
4169
|
}
|
|
4201
4170
|
const { parent } = node;
|
|
4202
4171
|
if (!parent) {
|
|
4203
4172
|
return false;
|
|
4204
4173
|
}
|
|
4205
|
-
if (parent.type ===
|
|
4174
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4206
4175
|
return true;
|
|
4207
4176
|
}
|
|
4208
|
-
if (parent.type ===
|
|
4177
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.Property) {
|
|
4209
4178
|
return true;
|
|
4210
4179
|
}
|
|
4211
|
-
if (parent.type ===
|
|
4180
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.ArrayExpression) {
|
|
4212
4181
|
return true;
|
|
4213
4182
|
}
|
|
4214
4183
|
return false;
|
|
4215
4184
|
};
|
|
4216
4185
|
var getFunctionName = (node) => {
|
|
4217
|
-
if (node.type ===
|
|
4186
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4218
4187
|
return node.id.name;
|
|
4219
4188
|
}
|
|
4220
|
-
if (node.type ===
|
|
4189
|
+
if (node.type === import_utils58.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4221
4190
|
return node.id.name;
|
|
4222
4191
|
}
|
|
4223
|
-
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) {
|
|
4224
4193
|
return node.parent.id.name;
|
|
4225
4194
|
}
|
|
4226
4195
|
return null;
|
|
4227
4196
|
};
|
|
4228
|
-
var requireExplicitReturnType =
|
|
4197
|
+
var requireExplicitReturnType = createRule53({
|
|
4229
4198
|
name: "require-explicit-return-type",
|
|
4230
4199
|
meta: {
|
|
4231
4200
|
type: "suggestion",
|
|
@@ -4274,8 +4243,8 @@ var requireExplicitReturnType = createRule55({
|
|
|
4274
4243
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4275
4244
|
|
|
4276
4245
|
// src/rules/sort-exports.ts
|
|
4277
|
-
var
|
|
4278
|
-
var
|
|
4246
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4247
|
+
var createRule54 = import_utils59.ESLintUtils.RuleCreator(
|
|
4279
4248
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4280
4249
|
);
|
|
4281
4250
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4289,7 +4258,7 @@ function getExportGroup(node) {
|
|
|
4289
4258
|
}
|
|
4290
4259
|
return 1;
|
|
4291
4260
|
}
|
|
4292
|
-
var sortExports =
|
|
4261
|
+
var sortExports = createRule54({
|
|
4293
4262
|
name: "sort-exports",
|
|
4294
4263
|
meta: {
|
|
4295
4264
|
type: "suggestion",
|
|
@@ -4329,7 +4298,7 @@ var sortExports = createRule56({
|
|
|
4329
4298
|
Program(node) {
|
|
4330
4299
|
const exportGroups = [];
|
|
4331
4300
|
node.body.forEach((statement) => {
|
|
4332
|
-
if (statement.type !==
|
|
4301
|
+
if (statement.type !== import_utils59.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4333
4302
|
if (exportGroups.length > 0) {
|
|
4334
4303
|
checkOrder(exportGroups);
|
|
4335
4304
|
exportGroups.length = 0;
|
|
@@ -4348,8 +4317,8 @@ var sortExports = createRule56({
|
|
|
4348
4317
|
var sort_exports_default = sortExports;
|
|
4349
4318
|
|
|
4350
4319
|
// src/rules/sort-imports.ts
|
|
4351
|
-
var
|
|
4352
|
-
var
|
|
4320
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4321
|
+
var createRule55 = import_utils60.ESLintUtils.RuleCreator(
|
|
4353
4322
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4354
4323
|
);
|
|
4355
4324
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4416,7 +4385,7 @@ function getImportGroup(node) {
|
|
|
4416
4385
|
function isTypeOnlyImport(node) {
|
|
4417
4386
|
return node.importKind === "type" && node.specifiers.length > 0;
|
|
4418
4387
|
}
|
|
4419
|
-
var sortImports =
|
|
4388
|
+
var sortImports = createRule55({
|
|
4420
4389
|
name: "sort-imports",
|
|
4421
4390
|
meta: {
|
|
4422
4391
|
type: "suggestion",
|
|
@@ -4460,7 +4429,7 @@ var sortImports = createRule57({
|
|
|
4460
4429
|
Program(node) {
|
|
4461
4430
|
const importGroups = [];
|
|
4462
4431
|
node.body.forEach((statement) => {
|
|
4463
|
-
if (statement.type !==
|
|
4432
|
+
if (statement.type !== import_utils60.AST_NODE_TYPES.ImportDeclaration) {
|
|
4464
4433
|
if (importGroups.length > 0) {
|
|
4465
4434
|
checkOrder(importGroups);
|
|
4466
4435
|
importGroups.length = 0;
|
|
@@ -4482,13 +4451,13 @@ var sortImports = createRule57({
|
|
|
4482
4451
|
var sort_imports_default = sortImports;
|
|
4483
4452
|
|
|
4484
4453
|
// src/rules/sort-type-alphabetically.ts
|
|
4485
|
-
var
|
|
4486
|
-
var
|
|
4454
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
4455
|
+
var createRule56 = import_utils61.ESLintUtils.RuleCreator(
|
|
4487
4456
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4488
4457
|
);
|
|
4489
4458
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4490
4459
|
const properties = members.filter(
|
|
4491
|
-
(member) => member.type ===
|
|
4460
|
+
(member) => member.type === import_utils61.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils61.AST_NODE_TYPES.Identifier
|
|
4492
4461
|
);
|
|
4493
4462
|
if (properties.length < 2) {
|
|
4494
4463
|
return true;
|
|
@@ -4499,7 +4468,7 @@ function isAlphabeticallySortedWithinGroups(members) {
|
|
|
4499
4468
|
const isOptionalSorted = optional.every((name, index) => index === 0 || optional[index - 1].localeCompare(name) <= 0);
|
|
4500
4469
|
return isRequiredSorted && isOptionalSorted;
|
|
4501
4470
|
}
|
|
4502
|
-
var sortTypeAlphabetically =
|
|
4471
|
+
var sortTypeAlphabetically = createRule56({
|
|
4503
4472
|
name: "sort-type-alphabetically",
|
|
4504
4473
|
meta: {
|
|
4505
4474
|
type: "suggestion",
|
|
@@ -4517,7 +4486,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4517
4486
|
function fixMembers(fixer, members) {
|
|
4518
4487
|
const { sourceCode } = context;
|
|
4519
4488
|
const properties = members.filter(
|
|
4520
|
-
(member) => member.type ===
|
|
4489
|
+
(member) => member.type === import_utils61.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils61.AST_NODE_TYPES.Identifier
|
|
4521
4490
|
);
|
|
4522
4491
|
const required = properties.filter((prop) => !prop.optional);
|
|
4523
4492
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4554,7 +4523,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4554
4523
|
}
|
|
4555
4524
|
},
|
|
4556
4525
|
TSTypeAliasDeclaration(node) {
|
|
4557
|
-
if (node.typeAnnotation.type !==
|
|
4526
|
+
if (node.typeAnnotation.type !== import_utils61.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4558
4527
|
return;
|
|
4559
4528
|
}
|
|
4560
4529
|
const { members } = node.typeAnnotation;
|
|
@@ -4574,13 +4543,13 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4574
4543
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4575
4544
|
|
|
4576
4545
|
// src/rules/sort-type-required-first.ts
|
|
4577
|
-
var
|
|
4578
|
-
var
|
|
4546
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
4547
|
+
var createRule57 = import_utils62.ESLintUtils.RuleCreator(
|
|
4579
4548
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4580
4549
|
);
|
|
4581
4550
|
function isRequiredBeforeOptional(members) {
|
|
4582
4551
|
const properties = members.filter(
|
|
4583
|
-
(member) => member.type ===
|
|
4552
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4584
4553
|
);
|
|
4585
4554
|
if (properties.length < 2) {
|
|
4586
4555
|
return true;
|
|
@@ -4591,7 +4560,7 @@ function isRequiredBeforeOptional(members) {
|
|
|
4591
4560
|
}
|
|
4592
4561
|
return properties.slice(firstOptionalIndex).every((prop) => prop.optional);
|
|
4593
4562
|
}
|
|
4594
|
-
var sortTypeRequiredFirst =
|
|
4563
|
+
var sortTypeRequiredFirst = createRule57({
|
|
4595
4564
|
name: "sort-type-required-first",
|
|
4596
4565
|
meta: {
|
|
4597
4566
|
type: "suggestion",
|
|
@@ -4609,7 +4578,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4609
4578
|
function fixMembers(fixer, members) {
|
|
4610
4579
|
const { sourceCode } = context;
|
|
4611
4580
|
const properties = members.filter(
|
|
4612
|
-
(member) => member.type ===
|
|
4581
|
+
(member) => member.type === import_utils62.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils62.AST_NODE_TYPES.Identifier
|
|
4613
4582
|
);
|
|
4614
4583
|
const required = properties.filter((prop) => !prop.optional);
|
|
4615
4584
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4630,7 +4599,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4630
4599
|
}
|
|
4631
4600
|
},
|
|
4632
4601
|
TSTypeAliasDeclaration(node) {
|
|
4633
|
-
if (node.typeAnnotation.type !==
|
|
4602
|
+
if (node.typeAnnotation.type !== import_utils62.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4634
4603
|
return;
|
|
4635
4604
|
}
|
|
4636
4605
|
const { members } = node.typeAnnotation;
|
|
@@ -4658,7 +4627,6 @@ var rules = {
|
|
|
4658
4627
|
"boolean-naming-prefix": boolean_naming_prefix_default,
|
|
4659
4628
|
"enforce-camel-case": enforce_camel_case_default,
|
|
4660
4629
|
"enforce-constant-case": enforce_constant_case_default,
|
|
4661
|
-
"enforce-curly-newline": enforce_curly_newline_default,
|
|
4662
4630
|
"enforce-hook-naming": enforce_hook_naming_default,
|
|
4663
4631
|
"enforce-property-case": enforce_property_case_default,
|
|
4664
4632
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
@@ -4666,7 +4634,6 @@ var rules = {
|
|
|
4666
4634
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4667
4635
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4668
4636
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4669
|
-
"file-kebab-case": file_kebab_case_default,
|
|
4670
4637
|
"index-export-only": index_export_only_default,
|
|
4671
4638
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
4672
4639
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
@@ -4674,14 +4641,12 @@ var rules = {
|
|
|
4674
4641
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
4675
4642
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4676
4643
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4677
|
-
"jsx-pascal-case": jsx_pascal_case_default,
|
|
4678
4644
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
4679
4645
|
"jsx-simple-props": jsx_simple_props_default,
|
|
4680
4646
|
"jsx-sort-props": jsx_sort_props_default,
|
|
4681
4647
|
"jsx-spread-props-last": jsx_spread_props_last_default,
|
|
4682
4648
|
"newline-after-multiline-block": newline_after_multiline_block_default,
|
|
4683
4649
|
"newline-before-return": newline_before_return_default,
|
|
4684
|
-
"nextjs-require-public-env": nextjs_require_public_env_default,
|
|
4685
4650
|
"no-complex-inline-return": no_complex_inline_return_default,
|
|
4686
4651
|
"no-direct-date": no_direct_date_default,
|
|
4687
4652
|
"no-emoji": no_emoji_default,
|
|
@@ -4704,9 +4669,11 @@ var rules = {
|
|
|
4704
4669
|
"prefer-import-type": prefer_import_type_default,
|
|
4705
4670
|
"prefer-inline-literal-union": prefer_inline_literal_union_default,
|
|
4706
4671
|
"prefer-inline-type-export": prefer_inline_type_export_default,
|
|
4672
|
+
"prefer-interface-for-component-props": prefer_interface_for_component_props_default,
|
|
4707
4673
|
"prefer-interface-over-inline-types": prefer_interface_over_inline_types_default,
|
|
4708
4674
|
"prefer-jsx-template-literals": prefer_jsx_template_literals_default,
|
|
4709
4675
|
"prefer-named-param-types": prefer_named_param_types_default,
|
|
4676
|
+
"prefer-props-with-children": prefer_props_with_children_default,
|
|
4710
4677
|
"prefer-react-import-types": prefer_react_import_types_default,
|
|
4711
4678
|
"react-props-destructure": react_props_destructure_default,
|
|
4712
4679
|
"require-explicit-return-type": require_explicit_return_type_default,
|
|
@@ -4723,13 +4690,11 @@ var baseRules = {
|
|
|
4723
4690
|
"nextfriday/boolean-naming-prefix": "warn",
|
|
4724
4691
|
"nextfriday/enforce-camel-case": "warn",
|
|
4725
4692
|
"nextfriday/enforce-constant-case": "warn",
|
|
4726
|
-
"nextfriday/enforce-curly-newline": "warn",
|
|
4727
4693
|
"nextfriday/enforce-hook-naming": "warn",
|
|
4728
4694
|
"nextfriday/enforce-property-case": "warn",
|
|
4729
4695
|
"nextfriday/enforce-service-naming": "warn",
|
|
4730
4696
|
"nextfriday/enforce-sorted-destructuring": "warn",
|
|
4731
4697
|
"nextfriday/enforce-type-declaration-order": "warn",
|
|
4732
|
-
"nextfriday/file-kebab-case": "warn",
|
|
4733
4698
|
"nextfriday/index-export-only": "warn",
|
|
4734
4699
|
"nextfriday/newline-after-multiline-block": "warn",
|
|
4735
4700
|
"nextfriday/newline-before-return": "warn",
|
|
@@ -4767,13 +4732,11 @@ var baseRecommendedRules = {
|
|
|
4767
4732
|
"nextfriday/boolean-naming-prefix": "error",
|
|
4768
4733
|
"nextfriday/enforce-camel-case": "error",
|
|
4769
4734
|
"nextfriday/enforce-constant-case": "error",
|
|
4770
|
-
"nextfriday/enforce-curly-newline": "error",
|
|
4771
4735
|
"nextfriday/enforce-hook-naming": "error",
|
|
4772
4736
|
"nextfriday/enforce-property-case": "error",
|
|
4773
4737
|
"nextfriday/enforce-service-naming": "error",
|
|
4774
4738
|
"nextfriday/enforce-sorted-destructuring": "error",
|
|
4775
4739
|
"nextfriday/enforce-type-declaration-order": "error",
|
|
4776
|
-
"nextfriday/file-kebab-case": "error",
|
|
4777
4740
|
"nextfriday/index-export-only": "error",
|
|
4778
4741
|
"nextfriday/newline-after-multiline-block": "error",
|
|
4779
4742
|
"nextfriday/newline-before-return": "error",
|
|
@@ -4816,13 +4779,14 @@ var jsxRules = {
|
|
|
4816
4779
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
4817
4780
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4818
4781
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4819
|
-
"nextfriday/jsx-pascal-case": "warn",
|
|
4820
4782
|
"nextfriday/jsx-require-suspense": "warn",
|
|
4821
4783
|
"nextfriday/jsx-simple-props": "warn",
|
|
4822
4784
|
"nextfriday/jsx-sort-props": "warn",
|
|
4823
4785
|
"nextfriday/jsx-spread-props-last": "warn",
|
|
4786
|
+
"nextfriday/prefer-interface-for-component-props": "warn",
|
|
4824
4787
|
"nextfriday/prefer-interface-over-inline-types": "warn",
|
|
4825
4788
|
"nextfriday/prefer-jsx-template-literals": "warn",
|
|
4789
|
+
"nextfriday/prefer-props-with-children": "warn",
|
|
4826
4790
|
"nextfriday/react-props-destructure": "warn"
|
|
4827
4791
|
};
|
|
4828
4792
|
var jsxRecommendedRules = {
|
|
@@ -4834,41 +4798,22 @@ var jsxRecommendedRules = {
|
|
|
4834
4798
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
4835
4799
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4836
4800
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4837
|
-
"nextfriday/jsx-pascal-case": "error",
|
|
4838
4801
|
"nextfriday/jsx-require-suspense": "error",
|
|
4839
4802
|
"nextfriday/jsx-simple-props": "error",
|
|
4840
4803
|
"nextfriday/jsx-sort-props": "error",
|
|
4841
4804
|
"nextfriday/jsx-spread-props-last": "error",
|
|
4805
|
+
"nextfriday/prefer-interface-for-component-props": "error",
|
|
4842
4806
|
"nextfriday/prefer-interface-over-inline-types": "error",
|
|
4843
4807
|
"nextfriday/prefer-jsx-template-literals": "error",
|
|
4808
|
+
"nextfriday/prefer-props-with-children": "error",
|
|
4844
4809
|
"nextfriday/react-props-destructure": "error"
|
|
4845
4810
|
};
|
|
4846
|
-
var nextjsOnlyRules = {
|
|
4847
|
-
"nextfriday/nextjs-require-public-env": "warn"
|
|
4848
|
-
};
|
|
4849
|
-
var nextjsOnlyRecommendedRules = {
|
|
4850
|
-
"nextfriday/nextjs-require-public-env": "error"
|
|
4851
|
-
};
|
|
4852
4811
|
var createConfig = (configRules) => ({
|
|
4853
4812
|
plugins: {
|
|
4854
4813
|
nextfriday: plugin
|
|
4855
4814
|
},
|
|
4856
4815
|
rules: configRules
|
|
4857
4816
|
});
|
|
4858
|
-
var NEXTJS_ROUTING_GLOBS = [
|
|
4859
|
-
"app/**/*.{js,jsx,ts,tsx}",
|
|
4860
|
-
"src/app/**/*.{js,jsx,ts,tsx}",
|
|
4861
|
-
"pages/**/*.{js,jsx,ts,tsx}",
|
|
4862
|
-
"src/pages/**/*.{js,jsx,ts,tsx}"
|
|
4863
|
-
];
|
|
4864
|
-
var nextjsRoutingOverride = {
|
|
4865
|
-
files: NEXTJS_ROUTING_GLOBS,
|
|
4866
|
-
rules: {
|
|
4867
|
-
"nextfriday/file-kebab-case": "off",
|
|
4868
|
-
"nextfriday/jsx-pascal-case": "off"
|
|
4869
|
-
}
|
|
4870
|
-
};
|
|
4871
|
-
var createNextjsConfig = (configRules) => [createConfig(configRules), nextjsRoutingOverride];
|
|
4872
4817
|
var configs = {
|
|
4873
4818
|
base: createConfig(baseRules),
|
|
4874
4819
|
"base/recommended": createConfig(baseRecommendedRules),
|
|
@@ -4880,15 +4825,13 @@ var configs = {
|
|
|
4880
4825
|
...baseRecommendedRules,
|
|
4881
4826
|
...jsxRecommendedRules
|
|
4882
4827
|
}),
|
|
4883
|
-
nextjs:
|
|
4828
|
+
nextjs: createConfig({
|
|
4884
4829
|
...baseRules,
|
|
4885
|
-
...jsxRules
|
|
4886
|
-
...nextjsOnlyRules
|
|
4830
|
+
...jsxRules
|
|
4887
4831
|
}),
|
|
4888
|
-
"nextjs/recommended":
|
|
4832
|
+
"nextjs/recommended": createConfig({
|
|
4889
4833
|
...baseRecommendedRules,
|
|
4890
|
-
...jsxRecommendedRules
|
|
4891
|
-
...nextjsOnlyRecommendedRules
|
|
4834
|
+
...jsxRecommendedRules
|
|
4892
4835
|
})
|
|
4893
4836
|
};
|
|
4894
4837
|
var nextfridayPlugin = {
|