eslint-plugin-nextfriday 3.2.1 → 4.1.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 +26 -0
- package/README.md +36 -70
- 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_GHOST_WRAPPER.md +75 -0
- package/docs/rules/NO_INLINE_NESTED_OBJECT.md +45 -27
- package/docs/rules/NO_REDUNDANT_FRAGMENT.md +56 -0
- 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 +748 -679
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +176 -200
- package/lib/index.d.ts +176 -200
- package/lib/index.js +685 -616
- 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.1.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) {
|
|
@@ -2312,12 +2109,58 @@ var noEnvFallback = createRule31({
|
|
|
2312
2109
|
});
|
|
2313
2110
|
var no_env_fallback_default = noEnvFallback;
|
|
2314
2111
|
|
|
2112
|
+
// src/rules/no-ghost-wrapper.ts
|
|
2113
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2114
|
+
var createRule28 = import_utils32.ESLintUtils.RuleCreator(
|
|
2115
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2116
|
+
);
|
|
2117
|
+
var GHOST_TAGS = /* @__PURE__ */ new Set(["div", "span"]);
|
|
2118
|
+
function isKeyAttribute(attribute) {
|
|
2119
|
+
return attribute.type === import_utils32.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils32.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "key";
|
|
2120
|
+
}
|
|
2121
|
+
var noGhostWrapper = createRule28({
|
|
2122
|
+
name: "no-ghost-wrapper",
|
|
2123
|
+
meta: {
|
|
2124
|
+
type: "problem",
|
|
2125
|
+
docs: {
|
|
2126
|
+
description: "Disallow bare <div> and <span> elements that have no meaningful attributes (Divitis / ghost wrappers)"
|
|
2127
|
+
},
|
|
2128
|
+
schema: [],
|
|
2129
|
+
messages: {
|
|
2130
|
+
noGhostWrapper: "Ghost <{{ tag }}> has no meaningful attributes. Use a Fragment (<>...</>), a semantic element (section, article, header, etc.), or add a meaningful attribute (className, role, data-*, ref, etc.). Note: 'key' alone does not count as meaningful."
|
|
2131
|
+
}
|
|
2132
|
+
},
|
|
2133
|
+
defaultOptions: [],
|
|
2134
|
+
create(context) {
|
|
2135
|
+
return {
|
|
2136
|
+
JSXOpeningElement(node) {
|
|
2137
|
+
if (node.name.type !== import_utils32.AST_NODE_TYPES.JSXIdentifier) {
|
|
2138
|
+
return;
|
|
2139
|
+
}
|
|
2140
|
+
const tagName = node.name.name;
|
|
2141
|
+
if (!GHOST_TAGS.has(tagName)) {
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
const meaningfulAttributes = node.attributes.filter((attribute) => !isKeyAttribute(attribute));
|
|
2145
|
+
if (meaningfulAttributes.length === 0) {
|
|
2146
|
+
context.report({
|
|
2147
|
+
node,
|
|
2148
|
+
messageId: "noGhostWrapper",
|
|
2149
|
+
data: { tag: tagName }
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
}
|
|
2155
|
+
});
|
|
2156
|
+
var no_ghost_wrapper_default = noGhostWrapper;
|
|
2157
|
+
|
|
2315
2158
|
// src/rules/no-inline-default-export.ts
|
|
2316
|
-
var
|
|
2317
|
-
var
|
|
2159
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2160
|
+
var createRule29 = import_utils33.ESLintUtils.RuleCreator(
|
|
2318
2161
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2319
2162
|
);
|
|
2320
|
-
var noInlineDefaultExport =
|
|
2163
|
+
var noInlineDefaultExport = createRule29({
|
|
2321
2164
|
name: "no-inline-default-export",
|
|
2322
2165
|
meta: {
|
|
2323
2166
|
type: "suggestion",
|
|
@@ -2336,7 +2179,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2336
2179
|
return {
|
|
2337
2180
|
ExportDefaultDeclaration(node) {
|
|
2338
2181
|
const { declaration } = node;
|
|
2339
|
-
if (declaration.type ===
|
|
2182
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2340
2183
|
if (declaration.id) {
|
|
2341
2184
|
context.report({
|
|
2342
2185
|
node,
|
|
@@ -2351,7 +2194,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2351
2194
|
});
|
|
2352
2195
|
}
|
|
2353
2196
|
}
|
|
2354
|
-
if (declaration.type ===
|
|
2197
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.ClassDeclaration) {
|
|
2355
2198
|
if (declaration.id) {
|
|
2356
2199
|
context.report({
|
|
2357
2200
|
node,
|
|
@@ -2366,7 +2209,7 @@ var noInlineDefaultExport = createRule32({
|
|
|
2366
2209
|
});
|
|
2367
2210
|
}
|
|
2368
2211
|
}
|
|
2369
|
-
if (declaration.type ===
|
|
2212
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils33.AST_NODE_TYPES.FunctionExpression) {
|
|
2370
2213
|
context.report({
|
|
2371
2214
|
node,
|
|
2372
2215
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2379,14 +2222,14 @@ var noInlineDefaultExport = createRule32({
|
|
|
2379
2222
|
if (!declaration) {
|
|
2380
2223
|
return;
|
|
2381
2224
|
}
|
|
2382
|
-
if (declaration.type ===
|
|
2225
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2383
2226
|
context.report({
|
|
2384
2227
|
node,
|
|
2385
2228
|
messageId: "noInlineNamedExport",
|
|
2386
2229
|
data: { type: "function", name: declaration.id.name }
|
|
2387
2230
|
});
|
|
2388
2231
|
}
|
|
2389
|
-
if (declaration.type ===
|
|
2232
|
+
if (declaration.type === import_utils33.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2390
2233
|
context.report({
|
|
2391
2234
|
node,
|
|
2392
2235
|
messageId: "noInlineNamedExport",
|
|
@@ -2400,36 +2243,45 @@ var noInlineDefaultExport = createRule32({
|
|
|
2400
2243
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2401
2244
|
|
|
2402
2245
|
// src/rules/no-inline-nested-object.ts
|
|
2403
|
-
var
|
|
2404
|
-
var
|
|
2246
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2247
|
+
var createRule30 = import_utils34.ESLintUtils.RuleCreator(
|
|
2405
2248
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2406
2249
|
);
|
|
2407
2250
|
function isObjectOrArray(node) {
|
|
2408
|
-
return node.type ===
|
|
2251
|
+
return node.type === import_utils34.AST_NODE_TYPES.ObjectExpression || node.type === import_utils34.AST_NODE_TYPES.ArrayExpression || node.type === import_utils34.AST_NODE_TYPES.TSAsExpression;
|
|
2409
2252
|
}
|
|
2410
2253
|
function getInnerExpression(node) {
|
|
2411
|
-
if (node.type ===
|
|
2254
|
+
if (node.type === import_utils34.AST_NODE_TYPES.TSAsExpression) {
|
|
2412
2255
|
return getInnerExpression(node.expression);
|
|
2413
2256
|
}
|
|
2414
2257
|
return node;
|
|
2415
2258
|
}
|
|
2416
|
-
function
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2259
|
+
function isNestedStructure(node) {
|
|
2260
|
+
const inner = getInnerExpression(node);
|
|
2261
|
+
return inner.type === import_utils34.AST_NODE_TYPES.ObjectExpression || inner.type === import_utils34.AST_NODE_TYPES.ArrayExpression;
|
|
2262
|
+
}
|
|
2263
|
+
function containsNestedStructure(node) {
|
|
2264
|
+
if (node.type === import_utils34.AST_NODE_TYPES.ObjectExpression) {
|
|
2265
|
+
return node.properties.some((prop) => {
|
|
2266
|
+
if (prop.type !== import_utils34.AST_NODE_TYPES.Property) return false;
|
|
2267
|
+
return isNestedStructure(prop.value);
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
return node.elements.some((el) => {
|
|
2271
|
+
if (el === null) return false;
|
|
2272
|
+
return isNestedStructure(el);
|
|
2421
2273
|
});
|
|
2422
2274
|
}
|
|
2423
|
-
var noInlineNestedObject =
|
|
2275
|
+
var noInlineNestedObject = createRule30({
|
|
2424
2276
|
name: "no-inline-nested-object",
|
|
2425
2277
|
meta: {
|
|
2426
2278
|
type: "layout",
|
|
2427
2279
|
docs: {
|
|
2428
|
-
description: "Require nested objects
|
|
2280
|
+
description: "Require object or array values that contain further nested objects or arrays to span multiple lines"
|
|
2429
2281
|
},
|
|
2430
2282
|
fixable: "whitespace",
|
|
2431
2283
|
messages: {
|
|
2432
|
-
requireMultiline: "
|
|
2284
|
+
requireMultiline: "Inline collections containing nested objects or arrays should span multiple lines"
|
|
2433
2285
|
},
|
|
2434
2286
|
schema: []
|
|
2435
2287
|
},
|
|
@@ -2442,23 +2294,20 @@ var noInlineNestedObject = createRule33({
|
|
|
2442
2294
|
return;
|
|
2443
2295
|
}
|
|
2444
2296
|
const valueNode = getInnerExpression(node.value);
|
|
2445
|
-
if (valueNode.type !==
|
|
2297
|
+
if (valueNode.type !== import_utils34.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils34.AST_NODE_TYPES.ArrayExpression) {
|
|
2446
2298
|
return;
|
|
2447
2299
|
}
|
|
2448
2300
|
if (!valueNode.loc) {
|
|
2449
2301
|
return;
|
|
2450
2302
|
}
|
|
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
2303
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
2459
2304
|
if (isMultiline) {
|
|
2460
2305
|
return;
|
|
2461
2306
|
}
|
|
2307
|
+
if (!containsNestedStructure(valueNode)) {
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
const elements = valueNode.type === import_utils34.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2462
2311
|
context.report({
|
|
2463
2312
|
node: valueNode,
|
|
2464
2313
|
messageId: "requireMultiline",
|
|
@@ -2471,7 +2320,7 @@ var noInlineNestedObject = createRule33({
|
|
|
2471
2320
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2472
2321
|
const innerIndent = `${indent} `;
|
|
2473
2322
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2474
|
-
const isObject = valueNode.type ===
|
|
2323
|
+
const isObject = valueNode.type === import_utils34.AST_NODE_TYPES.ObjectExpression;
|
|
2475
2324
|
const openChar = isObject ? "{" : "[";
|
|
2476
2325
|
const closeChar = isObject ? "}" : "]";
|
|
2477
2326
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2488,20 +2337,20 @@ ${indent}${closeChar}`;
|
|
|
2488
2337
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2489
2338
|
|
|
2490
2339
|
// src/rules/no-inline-return-properties.ts
|
|
2491
|
-
var
|
|
2492
|
-
var
|
|
2340
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2341
|
+
var createRule31 = import_utils35.ESLintUtils.RuleCreator(
|
|
2493
2342
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2494
2343
|
);
|
|
2495
2344
|
var isShorthandProperty = (property) => {
|
|
2496
|
-
if (property.type ===
|
|
2345
|
+
if (property.type === import_utils35.AST_NODE_TYPES.SpreadElement) {
|
|
2497
2346
|
return true;
|
|
2498
2347
|
}
|
|
2499
|
-
if (property.type !==
|
|
2348
|
+
if (property.type !== import_utils35.AST_NODE_TYPES.Property) {
|
|
2500
2349
|
return false;
|
|
2501
2350
|
}
|
|
2502
2351
|
return property.shorthand;
|
|
2503
2352
|
};
|
|
2504
|
-
var noInlineReturnProperties =
|
|
2353
|
+
var noInlineReturnProperties = createRule31({
|
|
2505
2354
|
name: "no-inline-return-properties",
|
|
2506
2355
|
meta: {
|
|
2507
2356
|
type: "suggestion",
|
|
@@ -2517,20 +2366,20 @@ var noInlineReturnProperties = createRule34({
|
|
|
2517
2366
|
create(context) {
|
|
2518
2367
|
return {
|
|
2519
2368
|
ReturnStatement(node) {
|
|
2520
|
-
if (!node.argument || node.argument.type !==
|
|
2369
|
+
if (!node.argument || node.argument.type !== import_utils35.AST_NODE_TYPES.ObjectExpression) {
|
|
2521
2370
|
return;
|
|
2522
2371
|
}
|
|
2523
2372
|
node.argument.properties.forEach((property) => {
|
|
2524
2373
|
if (isShorthandProperty(property)) {
|
|
2525
2374
|
return;
|
|
2526
2375
|
}
|
|
2527
|
-
if (property.type !==
|
|
2376
|
+
if (property.type !== import_utils35.AST_NODE_TYPES.Property) {
|
|
2528
2377
|
return;
|
|
2529
2378
|
}
|
|
2530
2379
|
let keyName = null;
|
|
2531
|
-
if (property.key.type ===
|
|
2380
|
+
if (property.key.type === import_utils35.AST_NODE_TYPES.Identifier) {
|
|
2532
2381
|
keyName = property.key.name;
|
|
2533
|
-
} else if (property.key.type ===
|
|
2382
|
+
} else if (property.key.type === import_utils35.AST_NODE_TYPES.Literal) {
|
|
2534
2383
|
keyName = String(property.key.value);
|
|
2535
2384
|
}
|
|
2536
2385
|
context.report({
|
|
@@ -2546,12 +2395,12 @@ var noInlineReturnProperties = createRule34({
|
|
|
2546
2395
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2547
2396
|
|
|
2548
2397
|
// src/rules/no-inline-type-import.ts
|
|
2549
|
-
var
|
|
2550
|
-
var
|
|
2398
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2399
|
+
var createRule32 = import_utils36.ESLintUtils.RuleCreator(
|
|
2551
2400
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2552
2401
|
);
|
|
2553
|
-
var isInlineTypeSpecifier = (specifier) => specifier.type ===
|
|
2554
|
-
var noInlineTypeImport =
|
|
2402
|
+
var isInlineTypeSpecifier = (specifier) => specifier.type === import_utils36.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type";
|
|
2403
|
+
var noInlineTypeImport = createRule32({
|
|
2555
2404
|
name: "no-inline-type-import",
|
|
2556
2405
|
meta: {
|
|
2557
2406
|
type: "suggestion",
|
|
@@ -2588,7 +2437,7 @@ var noInlineTypeImport = createRule35({
|
|
|
2588
2437
|
);
|
|
2589
2438
|
const typeImport = `import type { ${typeSpecifierTexts.join(", ")} } from ${sourceText};`;
|
|
2590
2439
|
const valueSpecifiers = node.specifiers.filter(
|
|
2591
|
-
(specifier) => !(specifier.type ===
|
|
2440
|
+
(specifier) => !(specifier.type === import_utils36.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type")
|
|
2592
2441
|
);
|
|
2593
2442
|
if (valueSpecifiers.length === 0) {
|
|
2594
2443
|
return fixer.replaceText(node, typeImport);
|
|
@@ -2596,11 +2445,11 @@ var noInlineTypeImport = createRule35({
|
|
|
2596
2445
|
const parts = [];
|
|
2597
2446
|
const namedValueSpecifiers = [];
|
|
2598
2447
|
for (const specifier of valueSpecifiers) {
|
|
2599
|
-
if (specifier.type ===
|
|
2448
|
+
if (specifier.type === import_utils36.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
2600
2449
|
parts.push(specifier.local.name);
|
|
2601
|
-
} else if (specifier.type ===
|
|
2450
|
+
} else if (specifier.type === import_utils36.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
2602
2451
|
parts.push(`* as ${specifier.local.name}`);
|
|
2603
|
-
} else if (specifier.type ===
|
|
2452
|
+
} else if (specifier.type === import_utils36.AST_NODE_TYPES.ImportSpecifier) {
|
|
2604
2453
|
namedValueSpecifiers.push(specifier);
|
|
2605
2454
|
}
|
|
2606
2455
|
}
|
|
@@ -2620,8 +2469,8 @@ ${typeImport}`);
|
|
|
2620
2469
|
var no_inline_type_import_default = noInlineTypeImport;
|
|
2621
2470
|
|
|
2622
2471
|
// src/rules/no-lazy-identifiers.ts
|
|
2623
|
-
var
|
|
2624
|
-
var
|
|
2472
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2473
|
+
var createRule33 = import_utils37.ESLintUtils.RuleCreator(
|
|
2625
2474
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2626
2475
|
);
|
|
2627
2476
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2662,7 +2511,7 @@ var isLazyIdentifier = (name) => {
|
|
|
2662
2511
|
}
|
|
2663
2512
|
return false;
|
|
2664
2513
|
};
|
|
2665
|
-
var noLazyIdentifiers =
|
|
2514
|
+
var noLazyIdentifiers = createRule33({
|
|
2666
2515
|
name: "no-lazy-identifiers",
|
|
2667
2516
|
meta: {
|
|
2668
2517
|
type: "problem",
|
|
@@ -2688,27 +2537,27 @@ var noLazyIdentifiers = createRule36({
|
|
|
2688
2537
|
});
|
|
2689
2538
|
};
|
|
2690
2539
|
const checkPattern = (pattern) => {
|
|
2691
|
-
if (pattern.type ===
|
|
2540
|
+
if (pattern.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2692
2541
|
checkIdentifier(pattern);
|
|
2693
|
-
} else if (pattern.type ===
|
|
2542
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.ObjectPattern) {
|
|
2694
2543
|
pattern.properties.forEach((prop) => {
|
|
2695
|
-
if (prop.type ===
|
|
2544
|
+
if (prop.type === import_utils37.AST_NODE_TYPES.Property && prop.value.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2696
2545
|
checkIdentifier(prop.value);
|
|
2697
|
-
} else if (prop.type ===
|
|
2546
|
+
} else if (prop.type === import_utils37.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2698
2547
|
checkIdentifier(prop.argument);
|
|
2699
2548
|
}
|
|
2700
2549
|
});
|
|
2701
|
-
} else if (pattern.type ===
|
|
2550
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.ArrayPattern) {
|
|
2702
2551
|
pattern.elements.forEach((element) => {
|
|
2703
|
-
if (element?.type ===
|
|
2552
|
+
if (element?.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2704
2553
|
checkIdentifier(element);
|
|
2705
|
-
} else if (element?.type ===
|
|
2554
|
+
} else if (element?.type === import_utils37.AST_NODE_TYPES.RestElement && element.argument.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2706
2555
|
checkIdentifier(element.argument);
|
|
2707
2556
|
}
|
|
2708
2557
|
});
|
|
2709
|
-
} else if (pattern.type ===
|
|
2558
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2710
2559
|
checkIdentifier(pattern.left);
|
|
2711
|
-
} else if (pattern.type ===
|
|
2560
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2712
2561
|
checkIdentifier(pattern.argument);
|
|
2713
2562
|
}
|
|
2714
2563
|
};
|
|
@@ -2753,11 +2602,11 @@ var noLazyIdentifiers = createRule36({
|
|
|
2753
2602
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2754
2603
|
|
|
2755
2604
|
// src/rules/no-logic-in-params.ts
|
|
2756
|
-
var
|
|
2757
|
-
var
|
|
2605
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2606
|
+
var createRule34 = import_utils38.ESLintUtils.RuleCreator(
|
|
2758
2607
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2759
2608
|
);
|
|
2760
|
-
var noLogicInParams =
|
|
2609
|
+
var noLogicInParams = createRule34({
|
|
2761
2610
|
name: "no-logic-in-params",
|
|
2762
2611
|
meta: {
|
|
2763
2612
|
type: "suggestion",
|
|
@@ -2772,20 +2621,20 @@ var noLogicInParams = createRule37({
|
|
|
2772
2621
|
defaultOptions: [],
|
|
2773
2622
|
create(context) {
|
|
2774
2623
|
const isComplexExpression = (node) => {
|
|
2775
|
-
if (node.type ===
|
|
2624
|
+
if (node.type === import_utils38.AST_NODE_TYPES.SpreadElement) {
|
|
2776
2625
|
return false;
|
|
2777
2626
|
}
|
|
2778
|
-
if (node.type ===
|
|
2627
|
+
if (node.type === import_utils38.AST_NODE_TYPES.ConditionalExpression) {
|
|
2779
2628
|
return true;
|
|
2780
2629
|
}
|
|
2781
|
-
if (node.type ===
|
|
2630
|
+
if (node.type === import_utils38.AST_NODE_TYPES.LogicalExpression) {
|
|
2782
2631
|
return true;
|
|
2783
2632
|
}
|
|
2784
|
-
if (node.type ===
|
|
2633
|
+
if (node.type === import_utils38.AST_NODE_TYPES.BinaryExpression) {
|
|
2785
2634
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2786
2635
|
return logicalOperators.includes(node.operator);
|
|
2787
2636
|
}
|
|
2788
|
-
if (node.type ===
|
|
2637
|
+
if (node.type === import_utils38.AST_NODE_TYPES.UnaryExpression) {
|
|
2789
2638
|
return node.operator === "!";
|
|
2790
2639
|
}
|
|
2791
2640
|
return false;
|
|
@@ -2798,7 +2647,7 @@ var noLogicInParams = createRule37({
|
|
|
2798
2647
|
messageId: "noLogicInParams"
|
|
2799
2648
|
});
|
|
2800
2649
|
}
|
|
2801
|
-
if (arg.type ===
|
|
2650
|
+
if (arg.type === import_utils38.AST_NODE_TYPES.ArrayExpression) {
|
|
2802
2651
|
arg.elements.forEach((element) => {
|
|
2803
2652
|
if (element && isComplexExpression(element)) {
|
|
2804
2653
|
context.report({
|
|
@@ -2823,46 +2672,46 @@ var noLogicInParams = createRule37({
|
|
|
2823
2672
|
var no_logic_in_params_default = noLogicInParams;
|
|
2824
2673
|
|
|
2825
2674
|
// src/rules/no-misleading-constant-case.ts
|
|
2826
|
-
var
|
|
2827
|
-
var
|
|
2675
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2676
|
+
var createRule35 = import_utils39.ESLintUtils.RuleCreator(
|
|
2828
2677
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2829
2678
|
);
|
|
2830
2679
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2831
|
-
var isAsConstAssertion = (node) => node.type ===
|
|
2680
|
+
var isAsConstAssertion = (node) => node.type === import_utils39.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === import_utils39.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils39.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
2832
2681
|
var isStaticValue2 = (init) => {
|
|
2833
2682
|
if (isAsConstAssertion(init)) {
|
|
2834
2683
|
return true;
|
|
2835
2684
|
}
|
|
2836
|
-
if (init.type ===
|
|
2685
|
+
if (init.type === import_utils39.AST_NODE_TYPES.Literal) {
|
|
2837
2686
|
return true;
|
|
2838
2687
|
}
|
|
2839
|
-
if (init.type ===
|
|
2688
|
+
if (init.type === import_utils39.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils39.AST_NODE_TYPES.Literal) {
|
|
2840
2689
|
return true;
|
|
2841
2690
|
}
|
|
2842
|
-
if (init.type ===
|
|
2691
|
+
if (init.type === import_utils39.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2843
2692
|
return true;
|
|
2844
2693
|
}
|
|
2845
|
-
if (init.type ===
|
|
2846
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
2694
|
+
if (init.type === import_utils39.AST_NODE_TYPES.ArrayExpression) {
|
|
2695
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils39.AST_NODE_TYPES.SpreadElement && isStaticValue2(el));
|
|
2847
2696
|
}
|
|
2848
|
-
if (init.type ===
|
|
2697
|
+
if (init.type === import_utils39.AST_NODE_TYPES.ObjectExpression) {
|
|
2849
2698
|
return init.properties.every(
|
|
2850
|
-
(prop) => prop.type ===
|
|
2699
|
+
(prop) => prop.type === import_utils39.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
2851
2700
|
);
|
|
2852
2701
|
}
|
|
2853
2702
|
return false;
|
|
2854
2703
|
};
|
|
2855
2704
|
var isGlobalScope3 = (node) => {
|
|
2856
2705
|
const { parent } = node;
|
|
2857
|
-
if (parent.type ===
|
|
2706
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.Program) {
|
|
2858
2707
|
return true;
|
|
2859
2708
|
}
|
|
2860
|
-
if (parent.type ===
|
|
2709
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils39.AST_NODE_TYPES.Program) {
|
|
2861
2710
|
return true;
|
|
2862
2711
|
}
|
|
2863
2712
|
return false;
|
|
2864
2713
|
};
|
|
2865
|
-
var noMisleadingConstantCase =
|
|
2714
|
+
var noMisleadingConstantCase = createRule35({
|
|
2866
2715
|
name: "no-misleading-constant-case",
|
|
2867
2716
|
meta: {
|
|
2868
2717
|
type: "suggestion",
|
|
@@ -2881,7 +2730,7 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2881
2730
|
return {
|
|
2882
2731
|
VariableDeclaration(node) {
|
|
2883
2732
|
node.declarations.forEach((declarator) => {
|
|
2884
|
-
if (declarator.id.type !==
|
|
2733
|
+
if (declarator.id.type !== import_utils39.AST_NODE_TYPES.Identifier) {
|
|
2885
2734
|
return;
|
|
2886
2735
|
}
|
|
2887
2736
|
const { name } = declarator.id;
|
|
@@ -2922,11 +2771,11 @@ var noMisleadingConstantCase = createRule38({
|
|
|
2922
2771
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2923
2772
|
|
|
2924
2773
|
// src/rules/no-nested-interface-declaration.ts
|
|
2925
|
-
var
|
|
2926
|
-
var
|
|
2774
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2775
|
+
var createRule36 = import_utils40.ESLintUtils.RuleCreator(
|
|
2927
2776
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2928
2777
|
);
|
|
2929
|
-
var noNestedInterfaceDeclaration =
|
|
2778
|
+
var noNestedInterfaceDeclaration = createRule36({
|
|
2930
2779
|
name: "no-nested-interface-declaration",
|
|
2931
2780
|
meta: {
|
|
2932
2781
|
type: "suggestion",
|
|
@@ -2947,15 +2796,15 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2947
2796
|
return;
|
|
2948
2797
|
}
|
|
2949
2798
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2950
|
-
if (typeAnnotation.type ===
|
|
2799
|
+
if (typeAnnotation.type === import_utils40.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2951
2800
|
context.report({
|
|
2952
2801
|
node: typeAnnotation,
|
|
2953
2802
|
messageId: "noNestedInterface"
|
|
2954
2803
|
});
|
|
2955
2804
|
return;
|
|
2956
2805
|
}
|
|
2957
|
-
if (typeAnnotation.type ===
|
|
2958
|
-
if (typeAnnotation.elementType.type ===
|
|
2806
|
+
if (typeAnnotation.type === import_utils40.AST_NODE_TYPES.TSArrayType) {
|
|
2807
|
+
if (typeAnnotation.elementType.type === import_utils40.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2959
2808
|
context.report({
|
|
2960
2809
|
node: typeAnnotation.elementType,
|
|
2961
2810
|
messageId: "noNestedInterface"
|
|
@@ -2963,9 +2812,9 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2963
2812
|
}
|
|
2964
2813
|
return;
|
|
2965
2814
|
}
|
|
2966
|
-
if (typeAnnotation.type ===
|
|
2815
|
+
if (typeAnnotation.type === import_utils40.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2967
2816
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2968
|
-
if (param.type ===
|
|
2817
|
+
if (param.type === import_utils40.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2969
2818
|
context.report({
|
|
2970
2819
|
node: param,
|
|
2971
2820
|
messageId: "noNestedInterface"
|
|
@@ -2980,11 +2829,11 @@ var noNestedInterfaceDeclaration = createRule39({
|
|
|
2980
2829
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2981
2830
|
|
|
2982
2831
|
// src/rules/no-nested-ternary.ts
|
|
2983
|
-
var
|
|
2984
|
-
var
|
|
2832
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2833
|
+
var createRule37 = import_utils41.ESLintUtils.RuleCreator(
|
|
2985
2834
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2986
2835
|
);
|
|
2987
|
-
var noNestedTernary =
|
|
2836
|
+
var noNestedTernary = createRule37({
|
|
2988
2837
|
name: "no-nested-ternary",
|
|
2989
2838
|
meta: {
|
|
2990
2839
|
type: "suggestion",
|
|
@@ -3001,13 +2850,13 @@ var noNestedTernary = createRule40({
|
|
|
3001
2850
|
return {
|
|
3002
2851
|
ConditionalExpression(node) {
|
|
3003
2852
|
const { consequent, alternate } = node;
|
|
3004
|
-
if (consequent.type ===
|
|
2853
|
+
if (consequent.type === import_utils41.AST_NODE_TYPES.ConditionalExpression) {
|
|
3005
2854
|
context.report({
|
|
3006
2855
|
node: consequent,
|
|
3007
2856
|
messageId: "noNestedTernary"
|
|
3008
2857
|
});
|
|
3009
2858
|
}
|
|
3010
|
-
if (alternate.type ===
|
|
2859
|
+
if (alternate.type === import_utils41.AST_NODE_TYPES.ConditionalExpression) {
|
|
3011
2860
|
context.report({
|
|
3012
2861
|
node: alternate,
|
|
3013
2862
|
messageId: "noNestedTernary"
|
|
@@ -3019,12 +2868,86 @@ var noNestedTernary = createRule40({
|
|
|
3019
2868
|
});
|
|
3020
2869
|
var no_nested_ternary_default = noNestedTernary;
|
|
3021
2870
|
|
|
2871
|
+
// src/rules/no-redundant-fragment.ts
|
|
2872
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2873
|
+
var createRule38 = import_utils42.ESLintUtils.RuleCreator(
|
|
2874
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2875
|
+
);
|
|
2876
|
+
function isFragmentName(name) {
|
|
2877
|
+
if (name.type === import_utils42.AST_NODE_TYPES.JSXIdentifier && name.name === "Fragment") {
|
|
2878
|
+
return true;
|
|
2879
|
+
}
|
|
2880
|
+
if (name.type === import_utils42.AST_NODE_TYPES.JSXMemberExpression && name.object.type === import_utils42.AST_NODE_TYPES.JSXIdentifier && name.object.name === "React" && name.property.type === import_utils42.AST_NODE_TYPES.JSXIdentifier && name.property.name === "Fragment") {
|
|
2881
|
+
return true;
|
|
2882
|
+
}
|
|
2883
|
+
return false;
|
|
2884
|
+
}
|
|
2885
|
+
function hasKeyAttribute(attributes) {
|
|
2886
|
+
return attributes.some(
|
|
2887
|
+
(attribute) => attribute.type === import_utils42.AST_NODE_TYPES.JSXAttribute && attribute.name.type === import_utils42.AST_NODE_TYPES.JSXIdentifier && attribute.name.name === "key"
|
|
2888
|
+
);
|
|
2889
|
+
}
|
|
2890
|
+
function countMeaningfulChildren(children) {
|
|
2891
|
+
return children.filter((child) => {
|
|
2892
|
+
if (child.type === import_utils42.AST_NODE_TYPES.JSXText) {
|
|
2893
|
+
return child.value.trim() !== "";
|
|
2894
|
+
}
|
|
2895
|
+
return true;
|
|
2896
|
+
}).length;
|
|
2897
|
+
}
|
|
2898
|
+
var noRedundantFragment = createRule38({
|
|
2899
|
+
name: "no-redundant-fragment",
|
|
2900
|
+
meta: {
|
|
2901
|
+
type: "problem",
|
|
2902
|
+
docs: {
|
|
2903
|
+
description: "Disallow Fragments that wrap zero or one child (unless a key prop is needed)"
|
|
2904
|
+
},
|
|
2905
|
+
schema: [],
|
|
2906
|
+
messages: {
|
|
2907
|
+
redundantFragment: "Fragment is redundant when wrapping {{ count }} child. Remove the Fragment or replace it with the child directly."
|
|
2908
|
+
}
|
|
2909
|
+
},
|
|
2910
|
+
defaultOptions: [],
|
|
2911
|
+
create(context) {
|
|
2912
|
+
return {
|
|
2913
|
+
JSXFragment(node) {
|
|
2914
|
+
const count = countMeaningfulChildren(node.children);
|
|
2915
|
+
if (count <= 1) {
|
|
2916
|
+
context.report({
|
|
2917
|
+
node,
|
|
2918
|
+
messageId: "redundantFragment",
|
|
2919
|
+
data: { count: String(count) }
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
},
|
|
2923
|
+
JSXElement(node) {
|
|
2924
|
+
const opening = node.openingElement;
|
|
2925
|
+
if (!isFragmentName(opening.name)) {
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
if (hasKeyAttribute(opening.attributes)) {
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
const count = countMeaningfulChildren(node.children);
|
|
2932
|
+
if (count <= 1) {
|
|
2933
|
+
context.report({
|
|
2934
|
+
node,
|
|
2935
|
+
messageId: "redundantFragment",
|
|
2936
|
+
data: { count: String(count) }
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
}
|
|
2942
|
+
});
|
|
2943
|
+
var no_redundant_fragment_default = noRedundantFragment;
|
|
2944
|
+
|
|
3022
2945
|
// src/rules/no-relative-imports.ts
|
|
3023
|
-
var
|
|
3024
|
-
var
|
|
2946
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2947
|
+
var createRule39 = import_utils43.ESLintUtils.RuleCreator(
|
|
3025
2948
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3026
2949
|
);
|
|
3027
|
-
var noRelativeImports =
|
|
2950
|
+
var noRelativeImports = createRule39({
|
|
3028
2951
|
name: "no-relative-imports",
|
|
3029
2952
|
meta: {
|
|
3030
2953
|
type: "suggestion",
|
|
@@ -3048,22 +2971,22 @@ var noRelativeImports = createRule41({
|
|
|
3048
2971
|
};
|
|
3049
2972
|
return {
|
|
3050
2973
|
ImportDeclaration(node) {
|
|
3051
|
-
if (node.source.type ===
|
|
2974
|
+
if (node.source.type === import_utils43.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3052
2975
|
checkImportPath(node.source.value, node);
|
|
3053
2976
|
}
|
|
3054
2977
|
},
|
|
3055
2978
|
ImportExpression(node) {
|
|
3056
|
-
if (node.source.type ===
|
|
2979
|
+
if (node.source.type === import_utils43.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3057
2980
|
checkImportPath(node.source.value, node);
|
|
3058
2981
|
}
|
|
3059
2982
|
},
|
|
3060
2983
|
ExportNamedDeclaration(node) {
|
|
3061
|
-
if (node.source?.type ===
|
|
2984
|
+
if (node.source?.type === import_utils43.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3062
2985
|
checkImportPath(node.source.value, node);
|
|
3063
2986
|
}
|
|
3064
2987
|
},
|
|
3065
2988
|
ExportAllDeclaration(node) {
|
|
3066
|
-
if (node.source.type ===
|
|
2989
|
+
if (node.source.type === import_utils43.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
3067
2990
|
checkImportPath(node.source.value, node);
|
|
3068
2991
|
}
|
|
3069
2992
|
}
|
|
@@ -3073,8 +2996,8 @@ var noRelativeImports = createRule41({
|
|
|
3073
2996
|
var no_relative_imports_default = noRelativeImports;
|
|
3074
2997
|
|
|
3075
2998
|
// src/rules/no-single-char-variables.ts
|
|
3076
|
-
var
|
|
3077
|
-
var
|
|
2999
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
3000
|
+
var createRule40 = import_utils44.ESLintUtils.RuleCreator(
|
|
3078
3001
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3079
3002
|
);
|
|
3080
3003
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -3086,7 +3009,7 @@ var isForLoopInit = (node) => {
|
|
|
3086
3009
|
if (!parentNode) {
|
|
3087
3010
|
return false;
|
|
3088
3011
|
}
|
|
3089
|
-
if (parentNode.type ===
|
|
3012
|
+
if (parentNode.type === import_utils44.AST_NODE_TYPES.ForStatement) {
|
|
3090
3013
|
const { init } = parentNode;
|
|
3091
3014
|
if (init && init === current) {
|
|
3092
3015
|
return true;
|
|
@@ -3105,7 +3028,7 @@ var isAllowedInContext = (name, node) => {
|
|
|
3105
3028
|
}
|
|
3106
3029
|
return false;
|
|
3107
3030
|
};
|
|
3108
|
-
var noSingleCharVariables =
|
|
3031
|
+
var noSingleCharVariables = createRule40({
|
|
3109
3032
|
name: "no-single-char-variables",
|
|
3110
3033
|
meta: {
|
|
3111
3034
|
type: "suggestion",
|
|
@@ -3134,27 +3057,27 @@ var noSingleCharVariables = createRule42({
|
|
|
3134
3057
|
});
|
|
3135
3058
|
};
|
|
3136
3059
|
const checkPattern = (pattern, declarationNode) => {
|
|
3137
|
-
if (pattern.type ===
|
|
3060
|
+
if (pattern.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
3138
3061
|
checkIdentifier(pattern, declarationNode);
|
|
3139
|
-
} else if (pattern.type ===
|
|
3062
|
+
} else if (pattern.type === import_utils44.AST_NODE_TYPES.ObjectPattern) {
|
|
3140
3063
|
pattern.properties.forEach((prop) => {
|
|
3141
|
-
if (prop.type ===
|
|
3064
|
+
if (prop.type === import_utils44.AST_NODE_TYPES.Property && prop.value.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
3142
3065
|
checkIdentifier(prop.value, declarationNode);
|
|
3143
|
-
} else if (prop.type ===
|
|
3066
|
+
} else if (prop.type === import_utils44.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
3144
3067
|
checkIdentifier(prop.argument, declarationNode);
|
|
3145
3068
|
}
|
|
3146
3069
|
});
|
|
3147
|
-
} else if (pattern.type ===
|
|
3070
|
+
} else if (pattern.type === import_utils44.AST_NODE_TYPES.ArrayPattern) {
|
|
3148
3071
|
pattern.elements.forEach((element) => {
|
|
3149
|
-
if (element?.type ===
|
|
3072
|
+
if (element?.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
3150
3073
|
checkIdentifier(element, declarationNode);
|
|
3151
|
-
} else if (element?.type ===
|
|
3074
|
+
} else if (element?.type === import_utils44.AST_NODE_TYPES.RestElement && element.argument.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
3152
3075
|
checkIdentifier(element.argument, declarationNode);
|
|
3153
3076
|
}
|
|
3154
3077
|
});
|
|
3155
|
-
} else if (pattern.type ===
|
|
3078
|
+
} else if (pattern.type === import_utils44.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
3156
3079
|
checkIdentifier(pattern.left, declarationNode);
|
|
3157
|
-
} else if (pattern.type ===
|
|
3080
|
+
} else if (pattern.type === import_utils44.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils44.AST_NODE_TYPES.Identifier) {
|
|
3158
3081
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3159
3082
|
}
|
|
3160
3083
|
};
|
|
@@ -3188,11 +3111,11 @@ var noSingleCharVariables = createRule42({
|
|
|
3188
3111
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3189
3112
|
|
|
3190
3113
|
// src/rules/prefer-async-await.ts
|
|
3191
|
-
var
|
|
3192
|
-
var
|
|
3114
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
3115
|
+
var createRule41 = import_utils45.ESLintUtils.RuleCreator(
|
|
3193
3116
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3194
3117
|
);
|
|
3195
|
-
var preferAsyncAwait =
|
|
3118
|
+
var preferAsyncAwait = createRule41({
|
|
3196
3119
|
name: "prefer-async-await",
|
|
3197
3120
|
meta: {
|
|
3198
3121
|
type: "suggestion",
|
|
@@ -3208,7 +3131,7 @@ var preferAsyncAwait = createRule43({
|
|
|
3208
3131
|
create(context) {
|
|
3209
3132
|
return {
|
|
3210
3133
|
CallExpression(node) {
|
|
3211
|
-
if (node.callee.type ===
|
|
3134
|
+
if (node.callee.type === import_utils45.AST_NODE_TYPES.MemberExpression && node.callee.property.type === import_utils45.AST_NODE_TYPES.Identifier && node.callee.property.name === "then") {
|
|
3212
3135
|
context.report({
|
|
3213
3136
|
node: node.callee.property,
|
|
3214
3137
|
messageId: "preferAsyncAwait"
|
|
@@ -3221,11 +3144,11 @@ var preferAsyncAwait = createRule43({
|
|
|
3221
3144
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3222
3145
|
|
|
3223
3146
|
// src/rules/prefer-destructuring-params.ts
|
|
3224
|
-
var
|
|
3225
|
-
var
|
|
3147
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3148
|
+
var createRule42 = import_utils46.ESLintUtils.RuleCreator(
|
|
3226
3149
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3227
3150
|
);
|
|
3228
|
-
var preferDestructuringParams =
|
|
3151
|
+
var preferDestructuringParams = createRule42({
|
|
3229
3152
|
name: "prefer-destructuring-params",
|
|
3230
3153
|
meta: {
|
|
3231
3154
|
type: "suggestion",
|
|
@@ -3241,18 +3164,18 @@ var preferDestructuringParams = createRule44({
|
|
|
3241
3164
|
create(context) {
|
|
3242
3165
|
const isCallbackFunction2 = (node) => {
|
|
3243
3166
|
const { parent } = node;
|
|
3244
|
-
return parent?.type ===
|
|
3167
|
+
return parent?.type === import_utils46.AST_NODE_TYPES.CallExpression;
|
|
3245
3168
|
};
|
|
3246
3169
|
const isDeveloperFunction = (node) => {
|
|
3247
|
-
if (node.type ===
|
|
3170
|
+
if (node.type === import_utils46.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3248
3171
|
return true;
|
|
3249
3172
|
}
|
|
3250
|
-
if (node.type ===
|
|
3173
|
+
if (node.type === import_utils46.AST_NODE_TYPES.FunctionExpression || node.type === import_utils46.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3251
3174
|
if (isCallbackFunction2(node)) {
|
|
3252
3175
|
return false;
|
|
3253
3176
|
}
|
|
3254
3177
|
const { parent } = node;
|
|
3255
|
-
return parent?.type ===
|
|
3178
|
+
return parent?.type === import_utils46.AST_NODE_TYPES.VariableDeclarator || parent?.type === import_utils46.AST_NODE_TYPES.AssignmentExpression || parent?.type === import_utils46.AST_NODE_TYPES.Property || parent?.type === import_utils46.AST_NODE_TYPES.MethodDefinition;
|
|
3256
3179
|
}
|
|
3257
3180
|
return false;
|
|
3258
3181
|
};
|
|
@@ -3264,7 +3187,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3264
3187
|
if (!isDeveloperFunction(node)) {
|
|
3265
3188
|
return;
|
|
3266
3189
|
}
|
|
3267
|
-
if (node.type ===
|
|
3190
|
+
if (node.type === import_utils46.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3268
3191
|
const functionName = node.id.name;
|
|
3269
3192
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3270
3193
|
return;
|
|
@@ -3274,7 +3197,7 @@ var preferDestructuringParams = createRule44({
|
|
|
3274
3197
|
return;
|
|
3275
3198
|
}
|
|
3276
3199
|
const hasNonDestructuredParams = node.params.some(
|
|
3277
|
-
(param) => param.type !==
|
|
3200
|
+
(param) => param.type !== import_utils46.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils46.AST_NODE_TYPES.RestElement
|
|
3278
3201
|
);
|
|
3279
3202
|
if (hasNonDestructuredParams) {
|
|
3280
3203
|
context.report({
|
|
@@ -3293,8 +3216,8 @@ var preferDestructuringParams = createRule44({
|
|
|
3293
3216
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3294
3217
|
|
|
3295
3218
|
// src/rules/prefer-function-declaration.ts
|
|
3296
|
-
var
|
|
3297
|
-
var
|
|
3219
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3220
|
+
var createRule43 = import_utils47.ESLintUtils.RuleCreator(
|
|
3298
3221
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3299
3222
|
);
|
|
3300
3223
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3303,33 +3226,33 @@ var isCallbackContext = (node) => {
|
|
|
3303
3226
|
if (!parent) {
|
|
3304
3227
|
return false;
|
|
3305
3228
|
}
|
|
3306
|
-
if (parent.type ===
|
|
3229
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3307
3230
|
return true;
|
|
3308
3231
|
}
|
|
3309
|
-
if (parent.type ===
|
|
3232
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3310
3233
|
return true;
|
|
3311
3234
|
}
|
|
3312
|
-
if (parent.type ===
|
|
3235
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.ReturnStatement) {
|
|
3313
3236
|
return true;
|
|
3314
3237
|
}
|
|
3315
|
-
if (parent.type ===
|
|
3238
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.Property) {
|
|
3316
3239
|
return true;
|
|
3317
3240
|
}
|
|
3318
|
-
if (parent.type ===
|
|
3241
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.ArrayExpression) {
|
|
3319
3242
|
return true;
|
|
3320
3243
|
}
|
|
3321
|
-
if (parent.type ===
|
|
3244
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.ConditionalExpression) {
|
|
3322
3245
|
return true;
|
|
3323
3246
|
}
|
|
3324
|
-
if (parent.type ===
|
|
3247
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.LogicalExpression) {
|
|
3325
3248
|
return true;
|
|
3326
3249
|
}
|
|
3327
|
-
if (parent.type ===
|
|
3250
|
+
if (parent.type === import_utils47.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3328
3251
|
return true;
|
|
3329
3252
|
}
|
|
3330
3253
|
return false;
|
|
3331
3254
|
};
|
|
3332
|
-
var preferFunctionDeclaration =
|
|
3255
|
+
var preferFunctionDeclaration = createRule43({
|
|
3333
3256
|
name: "prefer-function-declaration",
|
|
3334
3257
|
meta: {
|
|
3335
3258
|
type: "suggestion",
|
|
@@ -3350,14 +3273,14 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3350
3273
|
}
|
|
3351
3274
|
return {
|
|
3352
3275
|
VariableDeclarator(node) {
|
|
3353
|
-
if (node.id.type !==
|
|
3276
|
+
if (node.id.type !== import_utils47.AST_NODE_TYPES.Identifier) {
|
|
3354
3277
|
return;
|
|
3355
3278
|
}
|
|
3356
3279
|
const { init } = node;
|
|
3357
3280
|
if (!init) {
|
|
3358
3281
|
return;
|
|
3359
3282
|
}
|
|
3360
|
-
if (init.type ===
|
|
3283
|
+
if (init.type === import_utils47.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3361
3284
|
if (isCallbackContext(init)) {
|
|
3362
3285
|
return;
|
|
3363
3286
|
}
|
|
@@ -3367,7 +3290,7 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3367
3290
|
data: { name: node.id.name }
|
|
3368
3291
|
});
|
|
3369
3292
|
}
|
|
3370
|
-
if (init.type ===
|
|
3293
|
+
if (init.type === import_utils47.AST_NODE_TYPES.FunctionExpression) {
|
|
3371
3294
|
if (isCallbackContext(init)) {
|
|
3372
3295
|
return;
|
|
3373
3296
|
}
|
|
@@ -3384,11 +3307,11 @@ var preferFunctionDeclaration = createRule45({
|
|
|
3384
3307
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3385
3308
|
|
|
3386
3309
|
// src/rules/prefer-guard-clause.ts
|
|
3387
|
-
var
|
|
3388
|
-
var
|
|
3310
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3311
|
+
var createRule44 = import_utils48.ESLintUtils.RuleCreator(
|
|
3389
3312
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3390
3313
|
);
|
|
3391
|
-
var preferGuardClause =
|
|
3314
|
+
var preferGuardClause = createRule44({
|
|
3392
3315
|
name: "prefer-guard-clause",
|
|
3393
3316
|
meta: {
|
|
3394
3317
|
type: "suggestion",
|
|
@@ -3405,8 +3328,8 @@ var preferGuardClause = createRule46({
|
|
|
3405
3328
|
return {
|
|
3406
3329
|
IfStatement(node) {
|
|
3407
3330
|
const { consequent } = node;
|
|
3408
|
-
if (consequent.type ===
|
|
3409
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3331
|
+
if (consequent.type === import_utils48.AST_NODE_TYPES.BlockStatement) {
|
|
3332
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === import_utils48.AST_NODE_TYPES.IfStatement);
|
|
3410
3333
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3411
3334
|
context.report({
|
|
3412
3335
|
node,
|
|
@@ -3414,7 +3337,7 @@ var preferGuardClause = createRule46({
|
|
|
3414
3337
|
});
|
|
3415
3338
|
}
|
|
3416
3339
|
}
|
|
3417
|
-
if (consequent.type ===
|
|
3340
|
+
if (consequent.type === import_utils48.AST_NODE_TYPES.IfStatement) {
|
|
3418
3341
|
context.report({
|
|
3419
3342
|
node,
|
|
3420
3343
|
messageId: "preferGuardClause"
|
|
@@ -3427,11 +3350,11 @@ var preferGuardClause = createRule46({
|
|
|
3427
3350
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3428
3351
|
|
|
3429
3352
|
// src/rules/prefer-import-type.ts
|
|
3430
|
-
var
|
|
3431
|
-
var
|
|
3353
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3354
|
+
var createRule45 = import_utils49.ESLintUtils.RuleCreator(
|
|
3432
3355
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3433
3356
|
);
|
|
3434
|
-
var preferImportType =
|
|
3357
|
+
var preferImportType = createRule45({
|
|
3435
3358
|
name: "prefer-import-type",
|
|
3436
3359
|
meta: {
|
|
3437
3360
|
type: "suggestion",
|
|
@@ -3450,22 +3373,22 @@ var preferImportType = createRule47({
|
|
|
3450
3373
|
let current = node;
|
|
3451
3374
|
while (current) {
|
|
3452
3375
|
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
|
|
3376
|
+
case import_utils49.AST_NODE_TYPES.TSTypeReference:
|
|
3377
|
+
case import_utils49.AST_NODE_TYPES.TSTypeAnnotation:
|
|
3378
|
+
case import_utils49.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
3379
|
+
case import_utils49.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
3380
|
+
case import_utils49.AST_NODE_TYPES.TSClassImplements:
|
|
3381
|
+
case import_utils49.AST_NODE_TYPES.TSTypeQuery:
|
|
3382
|
+
case import_utils49.AST_NODE_TYPES.TSTypeAssertion:
|
|
3383
|
+
case import_utils49.AST_NODE_TYPES.TSAsExpression:
|
|
3384
|
+
case import_utils49.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
3385
|
+
case import_utils49.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3386
|
+
case import_utils49.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3387
|
+
case import_utils49.AST_NODE_TYPES.TSTypeParameter:
|
|
3388
|
+
case import_utils49.AST_NODE_TYPES.TSQualifiedName:
|
|
3466
3389
|
return true;
|
|
3467
|
-
case
|
|
3468
|
-
case
|
|
3390
|
+
case import_utils49.AST_NODE_TYPES.MemberExpression:
|
|
3391
|
+
case import_utils49.AST_NODE_TYPES.Identifier:
|
|
3469
3392
|
current = current.parent;
|
|
3470
3393
|
break;
|
|
3471
3394
|
default:
|
|
@@ -3495,27 +3418,27 @@ var preferImportType = createRule47({
|
|
|
3495
3418
|
return false;
|
|
3496
3419
|
}
|
|
3497
3420
|
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
|
|
3421
|
+
case import_utils49.AST_NODE_TYPES.CallExpression:
|
|
3422
|
+
case import_utils49.AST_NODE_TYPES.NewExpression:
|
|
3423
|
+
case import_utils49.AST_NODE_TYPES.JSXOpeningElement:
|
|
3424
|
+
case import_utils49.AST_NODE_TYPES.JSXClosingElement:
|
|
3425
|
+
case import_utils49.AST_NODE_TYPES.MemberExpression:
|
|
3426
|
+
case import_utils49.AST_NODE_TYPES.VariableDeclarator:
|
|
3427
|
+
case import_utils49.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
3428
|
+
case import_utils49.AST_NODE_TYPES.SpreadElement:
|
|
3429
|
+
case import_utils49.AST_NODE_TYPES.ExportSpecifier:
|
|
3430
|
+
case import_utils49.AST_NODE_TYPES.ArrayExpression:
|
|
3431
|
+
case import_utils49.AST_NODE_TYPES.ObjectExpression:
|
|
3432
|
+
case import_utils49.AST_NODE_TYPES.BinaryExpression:
|
|
3433
|
+
case import_utils49.AST_NODE_TYPES.LogicalExpression:
|
|
3434
|
+
case import_utils49.AST_NODE_TYPES.UnaryExpression:
|
|
3435
|
+
case import_utils49.AST_NODE_TYPES.ReturnStatement:
|
|
3436
|
+
case import_utils49.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
3437
|
+
case import_utils49.AST_NODE_TYPES.ConditionalExpression:
|
|
3438
|
+
case import_utils49.AST_NODE_TYPES.AwaitExpression:
|
|
3439
|
+
case import_utils49.AST_NODE_TYPES.YieldExpression:
|
|
3440
|
+
case import_utils49.AST_NODE_TYPES.Property:
|
|
3441
|
+
case import_utils49.AST_NODE_TYPES.JSXExpressionContainer:
|
|
3519
3442
|
return true;
|
|
3520
3443
|
default:
|
|
3521
3444
|
return false;
|
|
@@ -3526,6 +3449,12 @@ var preferImportType = createRule47({
|
|
|
3526
3449
|
if (node.importKind === "type") {
|
|
3527
3450
|
return;
|
|
3528
3451
|
}
|
|
3452
|
+
const hasInlineTypeSpecifier = node.specifiers.some(
|
|
3453
|
+
(specifier) => specifier.type === import_utils49.AST_NODE_TYPES.ImportSpecifier && specifier.importKind === "type"
|
|
3454
|
+
);
|
|
3455
|
+
if (hasInlineTypeSpecifier) {
|
|
3456
|
+
return;
|
|
3457
|
+
}
|
|
3529
3458
|
if (context.filename.includes(".test.") || context.filename.includes(".spec.") || context.filename.includes("__tests__")) {
|
|
3530
3459
|
return;
|
|
3531
3460
|
}
|
|
@@ -3539,13 +3468,13 @@ var preferImportType = createRule47({
|
|
|
3539
3468
|
}
|
|
3540
3469
|
const scope = context.sourceCode.getScope(node);
|
|
3541
3470
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3542
|
-
if (specifier.type ===
|
|
3471
|
+
if (specifier.type === import_utils49.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3543
3472
|
return false;
|
|
3544
3473
|
}
|
|
3545
|
-
if (specifier.type ===
|
|
3474
|
+
if (specifier.type === import_utils49.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3546
3475
|
return false;
|
|
3547
3476
|
}
|
|
3548
|
-
if (specifier.type ===
|
|
3477
|
+
if (specifier.type === import_utils49.AST_NODE_TYPES.ImportSpecifier) {
|
|
3549
3478
|
const localName = specifier.local.name;
|
|
3550
3479
|
return !isUsedAsValue(localName, scope);
|
|
3551
3480
|
}
|
|
@@ -3571,19 +3500,19 @@ var preferImportType = createRule47({
|
|
|
3571
3500
|
var prefer_import_type_default = preferImportType;
|
|
3572
3501
|
|
|
3573
3502
|
// src/rules/prefer-inline-literal-union.ts
|
|
3574
|
-
var
|
|
3575
|
-
var
|
|
3503
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3504
|
+
var createRule46 = import_utils50.ESLintUtils.RuleCreator(
|
|
3576
3505
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3577
3506
|
);
|
|
3578
3507
|
function isLiteralUnionType(node) {
|
|
3579
|
-
if (node.type !==
|
|
3508
|
+
if (node.type !== import_utils50.AST_NODE_TYPES.TSUnionType) {
|
|
3580
3509
|
return false;
|
|
3581
3510
|
}
|
|
3582
3511
|
return node.types.every(
|
|
3583
|
-
(member) => member.type ===
|
|
3512
|
+
(member) => member.type === import_utils50.AST_NODE_TYPES.TSLiteralType || member.type === import_utils50.AST_NODE_TYPES.TSNullKeyword || member.type === import_utils50.AST_NODE_TYPES.TSUndefinedKeyword
|
|
3584
3513
|
);
|
|
3585
3514
|
}
|
|
3586
|
-
var preferInlineLiteralUnion =
|
|
3515
|
+
var preferInlineLiteralUnion = createRule46({
|
|
3587
3516
|
name: "prefer-inline-literal-union",
|
|
3588
3517
|
meta: {
|
|
3589
3518
|
type: "suggestion",
|
|
@@ -3610,10 +3539,10 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3610
3539
|
return;
|
|
3611
3540
|
}
|
|
3612
3541
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3613
|
-
if (typeAnnotation.type !==
|
|
3542
|
+
if (typeAnnotation.type !== import_utils50.AST_NODE_TYPES.TSTypeReference) {
|
|
3614
3543
|
return;
|
|
3615
3544
|
}
|
|
3616
|
-
if (typeAnnotation.typeName.type !==
|
|
3545
|
+
if (typeAnnotation.typeName.type !== import_utils50.AST_NODE_TYPES.Identifier) {
|
|
3617
3546
|
return;
|
|
3618
3547
|
}
|
|
3619
3548
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3637,12 +3566,12 @@ var preferInlineLiteralUnion = createRule48({
|
|
|
3637
3566
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3638
3567
|
|
|
3639
3568
|
// src/rules/prefer-inline-type-export.ts
|
|
3640
|
-
var
|
|
3641
|
-
var
|
|
3569
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
3570
|
+
var createRule47 = import_utils51.ESLintUtils.RuleCreator(
|
|
3642
3571
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3643
3572
|
);
|
|
3644
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3645
|
-
var preferInlineTypeExport =
|
|
3573
|
+
var isTypeDeclaration = (node) => node.type === import_utils51.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils51.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
3574
|
+
var preferInlineTypeExport = createRule47({
|
|
3646
3575
|
name: "prefer-inline-type-export",
|
|
3647
3576
|
meta: {
|
|
3648
3577
|
type: "suggestion",
|
|
@@ -3659,12 +3588,12 @@ var preferInlineTypeExport = createRule49({
|
|
|
3659
3588
|
create(context) {
|
|
3660
3589
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3661
3590
|
function collectDeclaration(node) {
|
|
3662
|
-
if (node.parent.type !==
|
|
3591
|
+
if (node.parent.type !== import_utils51.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3663
3592
|
typeDeclarations.set(node.id.name, node);
|
|
3664
3593
|
}
|
|
3665
3594
|
}
|
|
3666
3595
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3667
|
-
if (specifier.local.type !==
|
|
3596
|
+
if (specifier.local.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
3668
3597
|
return;
|
|
3669
3598
|
}
|
|
3670
3599
|
const { name } = specifier.local;
|
|
@@ -3697,16 +3626,16 @@ var preferInlineTypeExport = createRule49({
|
|
|
3697
3626
|
return {
|
|
3698
3627
|
Program(node) {
|
|
3699
3628
|
node.body.forEach((statement) => {
|
|
3700
|
-
if (statement.type ===
|
|
3629
|
+
if (statement.type === import_utils51.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils51.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3701
3630
|
collectDeclaration(statement);
|
|
3702
3631
|
}
|
|
3703
3632
|
});
|
|
3704
3633
|
node.body.forEach((statement) => {
|
|
3705
|
-
if (statement.type !==
|
|
3634
|
+
if (statement.type !== import_utils51.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3706
3635
|
return;
|
|
3707
3636
|
}
|
|
3708
3637
|
statement.specifiers.forEach((specifier) => {
|
|
3709
|
-
if (specifier.local.type !==
|
|
3638
|
+
if (specifier.local.type !== import_utils51.AST_NODE_TYPES.Identifier) {
|
|
3710
3639
|
return;
|
|
3711
3640
|
}
|
|
3712
3641
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3722,12 +3651,69 @@ var preferInlineTypeExport = createRule49({
|
|
|
3722
3651
|
});
|
|
3723
3652
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3724
3653
|
|
|
3654
|
+
// src/rules/prefer-interface-for-component-props.ts
|
|
3655
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3656
|
+
var createRule48 = import_utils52.ESLintUtils.RuleCreator(
|
|
3657
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3658
|
+
);
|
|
3659
|
+
var preferInterfaceForComponentProps = createRule48({
|
|
3660
|
+
name: "prefer-interface-for-component-props",
|
|
3661
|
+
meta: {
|
|
3662
|
+
type: "suggestion",
|
|
3663
|
+
docs: {
|
|
3664
|
+
description: "Enforce 'interface' over 'type' alias for component prop declarations in component files (*.tsx, *.jsx)"
|
|
3665
|
+
},
|
|
3666
|
+
fixable: "code",
|
|
3667
|
+
schema: [],
|
|
3668
|
+
messages: {
|
|
3669
|
+
preferInterface: "Component props '{{ name }}' should use 'interface' instead of 'type' alias."
|
|
3670
|
+
}
|
|
3671
|
+
},
|
|
3672
|
+
defaultOptions: [],
|
|
3673
|
+
create(context) {
|
|
3674
|
+
if (!isJsxFile(context.filename)) {
|
|
3675
|
+
return {};
|
|
3676
|
+
}
|
|
3677
|
+
return {
|
|
3678
|
+
TSTypeAliasDeclaration(node) {
|
|
3679
|
+
if (node.id.type !== import_utils52.AST_NODE_TYPES.Identifier) {
|
|
3680
|
+
return;
|
|
3681
|
+
}
|
|
3682
|
+
if (!node.id.name.endsWith("Props")) {
|
|
3683
|
+
return;
|
|
3684
|
+
}
|
|
3685
|
+
if (node.typeAnnotation.type !== import_utils52.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3686
|
+
return;
|
|
3687
|
+
}
|
|
3688
|
+
const { name } = node.id;
|
|
3689
|
+
context.report({
|
|
3690
|
+
node: node.id,
|
|
3691
|
+
messageId: "preferInterface",
|
|
3692
|
+
data: { name },
|
|
3693
|
+
fix(fixer) {
|
|
3694
|
+
const { sourceCode } = context;
|
|
3695
|
+
const typeText = sourceCode.getText(node.typeAnnotation);
|
|
3696
|
+
const typeParamsText = node.typeParameters ? sourceCode.getText(node.typeParameters) : "";
|
|
3697
|
+
const newText = `interface ${name}${typeParamsText} ${typeText}`;
|
|
3698
|
+
const tokenAfter = sourceCode.getTokenAfter(node);
|
|
3699
|
+
if (tokenAfter && tokenAfter.value === ";") {
|
|
3700
|
+
return fixer.replaceTextRange([node.range[0], tokenAfter.range[1]], newText);
|
|
3701
|
+
}
|
|
3702
|
+
return fixer.replaceText(node, newText);
|
|
3703
|
+
}
|
|
3704
|
+
});
|
|
3705
|
+
}
|
|
3706
|
+
};
|
|
3707
|
+
}
|
|
3708
|
+
});
|
|
3709
|
+
var prefer_interface_for_component_props_default = preferInterfaceForComponentProps;
|
|
3710
|
+
|
|
3725
3711
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3726
3712
|
var import_utils54 = require("@typescript-eslint/utils");
|
|
3727
|
-
var
|
|
3713
|
+
var createRule49 = import_utils54.ESLintUtils.RuleCreator(
|
|
3728
3714
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3729
3715
|
);
|
|
3730
|
-
var preferInterfaceOverInlineTypes =
|
|
3716
|
+
var preferInterfaceOverInlineTypes = createRule49({
|
|
3731
3717
|
name: "prefer-interface-over-inline-types",
|
|
3732
3718
|
meta: {
|
|
3733
3719
|
type: "suggestion",
|
|
@@ -3824,10 +3810,10 @@ var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
|
3824
3810
|
|
|
3825
3811
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3826
3812
|
var import_utils55 = require("@typescript-eslint/utils");
|
|
3827
|
-
var
|
|
3813
|
+
var createRule50 = import_utils55.ESLintUtils.RuleCreator(
|
|
3828
3814
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3829
3815
|
);
|
|
3830
|
-
var preferJSXTemplateLiterals =
|
|
3816
|
+
var preferJSXTemplateLiterals = createRule50({
|
|
3831
3817
|
name: "prefer-jsx-template-literals",
|
|
3832
3818
|
meta: {
|
|
3833
3819
|
type: "suggestion",
|
|
@@ -3912,10 +3898,31 @@ var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
|
3912
3898
|
|
|
3913
3899
|
// src/rules/prefer-named-param-types.ts
|
|
3914
3900
|
var import_utils56 = require("@typescript-eslint/utils");
|
|
3915
|
-
var
|
|
3901
|
+
var createRule51 = import_utils56.ESLintUtils.RuleCreator(
|
|
3916
3902
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3917
3903
|
);
|
|
3918
|
-
var
|
|
3904
|
+
var returnsJsx2 = (node) => {
|
|
3905
|
+
if (node.type === import_utils56.AST_NODE_TYPES.JSXElement || node.type === import_utils56.AST_NODE_TYPES.JSXFragment) {
|
|
3906
|
+
return true;
|
|
3907
|
+
}
|
|
3908
|
+
if (node.type === import_utils56.AST_NODE_TYPES.ConditionalExpression) {
|
|
3909
|
+
return returnsJsx2(node.consequent) || returnsJsx2(node.alternate);
|
|
3910
|
+
}
|
|
3911
|
+
if (node.type === import_utils56.AST_NODE_TYPES.LogicalExpression) {
|
|
3912
|
+
return returnsJsx2(node.left) || returnsJsx2(node.right);
|
|
3913
|
+
}
|
|
3914
|
+
return false;
|
|
3915
|
+
};
|
|
3916
|
+
var bodyReturnsJsx2 = (body) => {
|
|
3917
|
+
if (body.type !== import_utils56.AST_NODE_TYPES.BlockStatement) {
|
|
3918
|
+
return returnsJsx2(body);
|
|
3919
|
+
}
|
|
3920
|
+
return body.body.some(
|
|
3921
|
+
(stmt) => stmt.type === import_utils56.AST_NODE_TYPES.ReturnStatement && stmt.argument !== null && returnsJsx2(stmt.argument)
|
|
3922
|
+
);
|
|
3923
|
+
};
|
|
3924
|
+
var isReactComponentFunction = (node) => bodyReturnsJsx2(node.body);
|
|
3925
|
+
var preferNamedParamTypes = createRule51({
|
|
3919
3926
|
name: "prefer-named-param-types",
|
|
3920
3927
|
meta: {
|
|
3921
3928
|
type: "suggestion",
|
|
@@ -3952,6 +3959,9 @@ var preferNamedParamTypes = createRule52({
|
|
|
3952
3959
|
} else if ("value" in node && node.value) {
|
|
3953
3960
|
params = node.value.params;
|
|
3954
3961
|
}
|
|
3962
|
+
if ((node.type === import_utils56.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils56.AST_NODE_TYPES.FunctionExpression || node.type === import_utils56.AST_NODE_TYPES.ArrowFunctionExpression) && params.length === 1 && params[0].type === import_utils56.AST_NODE_TYPES.Identifier && isReactComponentFunction(node)) {
|
|
3963
|
+
return;
|
|
3964
|
+
}
|
|
3955
3965
|
params.forEach((param) => {
|
|
3956
3966
|
if (hasInlineObjectType(param)) {
|
|
3957
3967
|
context.report({
|
|
@@ -3972,9 +3982,88 @@ var preferNamedParamTypes = createRule52({
|
|
|
3972
3982
|
});
|
|
3973
3983
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3974
3984
|
|
|
3975
|
-
// src/rules/prefer-
|
|
3985
|
+
// src/rules/prefer-props-with-children.ts
|
|
3976
3986
|
var import_utils57 = require("@typescript-eslint/utils");
|
|
3977
|
-
var
|
|
3987
|
+
var createRule52 = import_utils57.ESLintUtils.RuleCreator(
|
|
3988
|
+
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3989
|
+
);
|
|
3990
|
+
var preferPropsWithChildren = createRule52({
|
|
3991
|
+
name: "prefer-props-with-children",
|
|
3992
|
+
meta: {
|
|
3993
|
+
type: "suggestion",
|
|
3994
|
+
docs: {
|
|
3995
|
+
description: "Prefer PropsWithChildren<T> over manually declaring children: ReactNode in component props"
|
|
3996
|
+
},
|
|
3997
|
+
schema: [],
|
|
3998
|
+
messages: {
|
|
3999
|
+
usePropsWithChildren: "Use 'PropsWithChildren<T>' instead of manually declaring 'children: ReactNode'."
|
|
4000
|
+
}
|
|
4001
|
+
},
|
|
4002
|
+
defaultOptions: [],
|
|
4003
|
+
create(context) {
|
|
4004
|
+
function isReactNodeType(typeNode) {
|
|
4005
|
+
if (!typeNode) {
|
|
4006
|
+
return false;
|
|
4007
|
+
}
|
|
4008
|
+
if (typeNode.type !== import_utils57.AST_NODE_TYPES.TSTypeReference) {
|
|
4009
|
+
return false;
|
|
4010
|
+
}
|
|
4011
|
+
const { typeName } = typeNode;
|
|
4012
|
+
if (typeName.type === import_utils57.AST_NODE_TYPES.Identifier) {
|
|
4013
|
+
return typeName.name === "ReactNode";
|
|
4014
|
+
}
|
|
4015
|
+
if (typeName.type === import_utils57.AST_NODE_TYPES.TSQualifiedName && typeName.left.type === import_utils57.AST_NODE_TYPES.Identifier && typeName.left.name === "React" && typeName.right.type === import_utils57.AST_NODE_TYPES.Identifier && typeName.right.name === "ReactNode") {
|
|
4016
|
+
return true;
|
|
4017
|
+
}
|
|
4018
|
+
return false;
|
|
4019
|
+
}
|
|
4020
|
+
function findChildrenReactNode(members) {
|
|
4021
|
+
for (const member of members) {
|
|
4022
|
+
if (member.type !== import_utils57.AST_NODE_TYPES.TSPropertySignature) {
|
|
4023
|
+
continue;
|
|
4024
|
+
}
|
|
4025
|
+
if (member.key.type !== import_utils57.AST_NODE_TYPES.Identifier) {
|
|
4026
|
+
continue;
|
|
4027
|
+
}
|
|
4028
|
+
if (member.key.name !== "children") {
|
|
4029
|
+
continue;
|
|
4030
|
+
}
|
|
4031
|
+
if (!member.typeAnnotation) {
|
|
4032
|
+
continue;
|
|
4033
|
+
}
|
|
4034
|
+
if (isReactNodeType(member.typeAnnotation.typeAnnotation)) {
|
|
4035
|
+
return member;
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
return void 0;
|
|
4039
|
+
}
|
|
4040
|
+
return {
|
|
4041
|
+
TSInterfaceDeclaration(node) {
|
|
4042
|
+
const childrenMember = findChildrenReactNode(node.body.body);
|
|
4043
|
+
if (childrenMember) {
|
|
4044
|
+
context.report({
|
|
4045
|
+
node: childrenMember,
|
|
4046
|
+
messageId: "usePropsWithChildren"
|
|
4047
|
+
});
|
|
4048
|
+
}
|
|
4049
|
+
},
|
|
4050
|
+
TSTypeLiteral(node) {
|
|
4051
|
+
const childrenMember = findChildrenReactNode(node.members);
|
|
4052
|
+
if (childrenMember) {
|
|
4053
|
+
context.report({
|
|
4054
|
+
node: childrenMember,
|
|
4055
|
+
messageId: "usePropsWithChildren"
|
|
4056
|
+
});
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
};
|
|
4060
|
+
}
|
|
4061
|
+
});
|
|
4062
|
+
var prefer_props_with_children_default = preferPropsWithChildren;
|
|
4063
|
+
|
|
4064
|
+
// src/rules/prefer-react-import-types.ts
|
|
4065
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
4066
|
+
var createRule53 = import_utils58.ESLintUtils.RuleCreator(
|
|
3978
4067
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3979
4068
|
);
|
|
3980
4069
|
var preferReactImportTypes = createRule53({
|
|
@@ -4053,7 +4142,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4053
4142
|
]);
|
|
4054
4143
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
4055
4144
|
function checkMemberExpression(node) {
|
|
4056
|
-
if (node.object.type ===
|
|
4145
|
+
if (node.object.type === import_utils58.AST_NODE_TYPES.Identifier && node.object.name === "React" && node.property.type === import_utils58.AST_NODE_TYPES.Identifier && allReactExports.has(node.property.name)) {
|
|
4057
4146
|
const typeName = node.property.name;
|
|
4058
4147
|
const isType = reactTypes.has(typeName);
|
|
4059
4148
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4070,7 +4159,7 @@ var preferReactImportTypes = createRule53({
|
|
|
4070
4159
|
return {
|
|
4071
4160
|
MemberExpression: checkMemberExpression,
|
|
4072
4161
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
4073
|
-
if (node.left.type ===
|
|
4162
|
+
if (node.left.type === import_utils58.AST_NODE_TYPES.Identifier && node.left.name === "React" && node.right.type === import_utils58.AST_NODE_TYPES.Identifier && allReactExports.has(node.right.name)) {
|
|
4074
4163
|
const typeName = node.right.name;
|
|
4075
4164
|
const isType = reactTypes.has(typeName);
|
|
4076
4165
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -4090,8 +4179,8 @@ var preferReactImportTypes = createRule53({
|
|
|
4090
4179
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
4091
4180
|
|
|
4092
4181
|
// src/rules/react-props-destructure.ts
|
|
4093
|
-
var
|
|
4094
|
-
var createRule54 =
|
|
4182
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4183
|
+
var createRule54 = import_utils59.ESLintUtils.RuleCreator(
|
|
4095
4184
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4096
4185
|
);
|
|
4097
4186
|
var reactPropsDestructure = createRule54({
|
|
@@ -4110,29 +4199,29 @@ var reactPropsDestructure = createRule54({
|
|
|
4110
4199
|
defaultOptions: [],
|
|
4111
4200
|
create(context) {
|
|
4112
4201
|
function hasJSXInConditional(node) {
|
|
4113
|
-
return node.consequent.type ===
|
|
4202
|
+
return node.consequent.type === import_utils59.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils59.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils59.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils59.AST_NODE_TYPES.JSXFragment;
|
|
4114
4203
|
}
|
|
4115
4204
|
function hasJSXInLogical(node) {
|
|
4116
|
-
return node.right.type ===
|
|
4205
|
+
return node.right.type === import_utils59.AST_NODE_TYPES.JSXElement || node.right.type === import_utils59.AST_NODE_TYPES.JSXFragment;
|
|
4117
4206
|
}
|
|
4118
4207
|
function hasJSXReturn(block) {
|
|
4119
4208
|
return block.body.some((stmt) => {
|
|
4120
|
-
if (stmt.type ===
|
|
4121
|
-
return stmt.argument.type ===
|
|
4209
|
+
if (stmt.type === import_utils59.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4210
|
+
return stmt.argument.type === import_utils59.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils59.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils59.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils59.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
4122
4211
|
}
|
|
4123
4212
|
return false;
|
|
4124
4213
|
});
|
|
4125
4214
|
}
|
|
4126
4215
|
function isReactComponent2(node) {
|
|
4127
|
-
if (node.type ===
|
|
4128
|
-
if (node.body.type ===
|
|
4216
|
+
if (node.type === import_utils59.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4217
|
+
if (node.body.type === import_utils59.AST_NODE_TYPES.JSXElement || node.body.type === import_utils59.AST_NODE_TYPES.JSXFragment) {
|
|
4129
4218
|
return true;
|
|
4130
4219
|
}
|
|
4131
|
-
if (node.body.type ===
|
|
4220
|
+
if (node.body.type === import_utils59.AST_NODE_TYPES.BlockStatement) {
|
|
4132
4221
|
return hasJSXReturn(node.body);
|
|
4133
4222
|
}
|
|
4134
|
-
} else if (node.type ===
|
|
4135
|
-
if (node.body && node.body.type ===
|
|
4223
|
+
} else if (node.type === import_utils59.AST_NODE_TYPES.FunctionExpression || node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4224
|
+
if (node.body && node.body.type === import_utils59.AST_NODE_TYPES.BlockStatement) {
|
|
4136
4225
|
return hasJSXReturn(node.body);
|
|
4137
4226
|
}
|
|
4138
4227
|
}
|
|
@@ -4146,9 +4235,9 @@ var reactPropsDestructure = createRule54({
|
|
|
4146
4235
|
return;
|
|
4147
4236
|
}
|
|
4148
4237
|
const param = node.params[0];
|
|
4149
|
-
if (param.type ===
|
|
4150
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4151
|
-
if (prop.key.type ===
|
|
4238
|
+
if (param.type === import_utils59.AST_NODE_TYPES.ObjectPattern) {
|
|
4239
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils59.AST_NODE_TYPES.Property).map((prop) => {
|
|
4240
|
+
if (prop.key.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
4152
4241
|
return prop.key.name;
|
|
4153
4242
|
}
|
|
4154
4243
|
return null;
|
|
@@ -4175,52 +4264,52 @@ var reactPropsDestructure = createRule54({
|
|
|
4175
4264
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4176
4265
|
|
|
4177
4266
|
// src/rules/require-explicit-return-type.ts
|
|
4178
|
-
var
|
|
4179
|
-
var createRule55 =
|
|
4267
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4268
|
+
var createRule55 = import_utils60.ESLintUtils.RuleCreator(
|
|
4180
4269
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4181
4270
|
);
|
|
4182
4271
|
var isReactComponent = (node) => {
|
|
4183
|
-
if (node.type ===
|
|
4272
|
+
if (node.type === import_utils60.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4184
4273
|
const { parent } = node;
|
|
4185
|
-
if (parent?.type ===
|
|
4274
|
+
if (parent?.type === import_utils60.AST_NODE_TYPES.VariableDeclarator) {
|
|
4186
4275
|
const { id } = parent;
|
|
4187
|
-
if (id.type ===
|
|
4276
|
+
if (id.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
4188
4277
|
return /^[A-Z]/.test(id.name);
|
|
4189
4278
|
}
|
|
4190
4279
|
}
|
|
4191
4280
|
}
|
|
4192
|
-
if (node.type ===
|
|
4281
|
+
if (node.type === import_utils60.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4193
4282
|
return /^[A-Z]/.test(node.id.name);
|
|
4194
4283
|
}
|
|
4195
4284
|
return false;
|
|
4196
4285
|
};
|
|
4197
4286
|
var isCallbackFunction = (node) => {
|
|
4198
|
-
if (node.type ===
|
|
4287
|
+
if (node.type === import_utils60.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4199
4288
|
return false;
|
|
4200
4289
|
}
|
|
4201
4290
|
const { parent } = node;
|
|
4202
4291
|
if (!parent) {
|
|
4203
4292
|
return false;
|
|
4204
4293
|
}
|
|
4205
|
-
if (parent.type ===
|
|
4294
|
+
if (parent.type === import_utils60.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4206
4295
|
return true;
|
|
4207
4296
|
}
|
|
4208
|
-
if (parent.type ===
|
|
4297
|
+
if (parent.type === import_utils60.AST_NODE_TYPES.Property) {
|
|
4209
4298
|
return true;
|
|
4210
4299
|
}
|
|
4211
|
-
if (parent.type ===
|
|
4300
|
+
if (parent.type === import_utils60.AST_NODE_TYPES.ArrayExpression) {
|
|
4212
4301
|
return true;
|
|
4213
4302
|
}
|
|
4214
4303
|
return false;
|
|
4215
4304
|
};
|
|
4216
4305
|
var getFunctionName = (node) => {
|
|
4217
|
-
if (node.type ===
|
|
4306
|
+
if (node.type === import_utils60.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4218
4307
|
return node.id.name;
|
|
4219
4308
|
}
|
|
4220
|
-
if (node.type ===
|
|
4309
|
+
if (node.type === import_utils60.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4221
4310
|
return node.id.name;
|
|
4222
4311
|
}
|
|
4223
|
-
if ((node.type ===
|
|
4312
|
+
if ((node.type === import_utils60.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils60.AST_NODE_TYPES.FunctionExpression) && node.parent?.type === import_utils60.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
4224
4313
|
return node.parent.id.name;
|
|
4225
4314
|
}
|
|
4226
4315
|
return null;
|
|
@@ -4274,8 +4363,8 @@ var requireExplicitReturnType = createRule55({
|
|
|
4274
4363
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4275
4364
|
|
|
4276
4365
|
// src/rules/sort-exports.ts
|
|
4277
|
-
var
|
|
4278
|
-
var createRule56 =
|
|
4366
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
4367
|
+
var createRule56 = import_utils61.ESLintUtils.RuleCreator(
|
|
4279
4368
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4280
4369
|
);
|
|
4281
4370
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4329,7 +4418,7 @@ var sortExports = createRule56({
|
|
|
4329
4418
|
Program(node) {
|
|
4330
4419
|
const exportGroups = [];
|
|
4331
4420
|
node.body.forEach((statement) => {
|
|
4332
|
-
if (statement.type !==
|
|
4421
|
+
if (statement.type !== import_utils61.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4333
4422
|
if (exportGroups.length > 0) {
|
|
4334
4423
|
checkOrder(exportGroups);
|
|
4335
4424
|
exportGroups.length = 0;
|
|
@@ -4348,8 +4437,8 @@ var sortExports = createRule56({
|
|
|
4348
4437
|
var sort_exports_default = sortExports;
|
|
4349
4438
|
|
|
4350
4439
|
// src/rules/sort-imports.ts
|
|
4351
|
-
var
|
|
4352
|
-
var createRule57 =
|
|
4440
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
4441
|
+
var createRule57 = import_utils62.ESLintUtils.RuleCreator(
|
|
4353
4442
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4354
4443
|
);
|
|
4355
4444
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4460,7 +4549,7 @@ var sortImports = createRule57({
|
|
|
4460
4549
|
Program(node) {
|
|
4461
4550
|
const importGroups = [];
|
|
4462
4551
|
node.body.forEach((statement) => {
|
|
4463
|
-
if (statement.type !==
|
|
4552
|
+
if (statement.type !== import_utils62.AST_NODE_TYPES.ImportDeclaration) {
|
|
4464
4553
|
if (importGroups.length > 0) {
|
|
4465
4554
|
checkOrder(importGroups);
|
|
4466
4555
|
importGroups.length = 0;
|
|
@@ -4482,13 +4571,13 @@ var sortImports = createRule57({
|
|
|
4482
4571
|
var sort_imports_default = sortImports;
|
|
4483
4572
|
|
|
4484
4573
|
// src/rules/sort-type-alphabetically.ts
|
|
4485
|
-
var
|
|
4486
|
-
var createRule58 =
|
|
4574
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
4575
|
+
var createRule58 = import_utils63.ESLintUtils.RuleCreator(
|
|
4487
4576
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4488
4577
|
);
|
|
4489
4578
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4490
4579
|
const properties = members.filter(
|
|
4491
|
-
(member) => member.type ===
|
|
4580
|
+
(member) => member.type === import_utils63.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils63.AST_NODE_TYPES.Identifier
|
|
4492
4581
|
);
|
|
4493
4582
|
if (properties.length < 2) {
|
|
4494
4583
|
return true;
|
|
@@ -4517,7 +4606,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4517
4606
|
function fixMembers(fixer, members) {
|
|
4518
4607
|
const { sourceCode } = context;
|
|
4519
4608
|
const properties = members.filter(
|
|
4520
|
-
(member) => member.type ===
|
|
4609
|
+
(member) => member.type === import_utils63.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils63.AST_NODE_TYPES.Identifier
|
|
4521
4610
|
);
|
|
4522
4611
|
const required = properties.filter((prop) => !prop.optional);
|
|
4523
4612
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4554,7 +4643,7 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4554
4643
|
}
|
|
4555
4644
|
},
|
|
4556
4645
|
TSTypeAliasDeclaration(node) {
|
|
4557
|
-
if (node.typeAnnotation.type !==
|
|
4646
|
+
if (node.typeAnnotation.type !== import_utils63.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4558
4647
|
return;
|
|
4559
4648
|
}
|
|
4560
4649
|
const { members } = node.typeAnnotation;
|
|
@@ -4574,13 +4663,13 @@ var sortTypeAlphabetically = createRule58({
|
|
|
4574
4663
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4575
4664
|
|
|
4576
4665
|
// src/rules/sort-type-required-first.ts
|
|
4577
|
-
var
|
|
4578
|
-
var createRule59 =
|
|
4666
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
4667
|
+
var createRule59 = import_utils64.ESLintUtils.RuleCreator(
|
|
4579
4668
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4580
4669
|
);
|
|
4581
4670
|
function isRequiredBeforeOptional(members) {
|
|
4582
4671
|
const properties = members.filter(
|
|
4583
|
-
(member) => member.type ===
|
|
4672
|
+
(member) => member.type === import_utils64.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils64.AST_NODE_TYPES.Identifier
|
|
4584
4673
|
);
|
|
4585
4674
|
if (properties.length < 2) {
|
|
4586
4675
|
return true;
|
|
@@ -4609,7 +4698,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4609
4698
|
function fixMembers(fixer, members) {
|
|
4610
4699
|
const { sourceCode } = context;
|
|
4611
4700
|
const properties = members.filter(
|
|
4612
|
-
(member) => member.type ===
|
|
4701
|
+
(member) => member.type === import_utils64.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils64.AST_NODE_TYPES.Identifier
|
|
4613
4702
|
);
|
|
4614
4703
|
const required = properties.filter((prop) => !prop.optional);
|
|
4615
4704
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4630,7 +4719,7 @@ var sortTypeRequiredFirst = createRule59({
|
|
|
4630
4719
|
}
|
|
4631
4720
|
},
|
|
4632
4721
|
TSTypeAliasDeclaration(node) {
|
|
4633
|
-
if (node.typeAnnotation.type !==
|
|
4722
|
+
if (node.typeAnnotation.type !== import_utils64.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4634
4723
|
return;
|
|
4635
4724
|
}
|
|
4636
4725
|
const { members } = node.typeAnnotation;
|
|
@@ -4658,7 +4747,6 @@ var rules = {
|
|
|
4658
4747
|
"boolean-naming-prefix": boolean_naming_prefix_default,
|
|
4659
4748
|
"enforce-camel-case": enforce_camel_case_default,
|
|
4660
4749
|
"enforce-constant-case": enforce_constant_case_default,
|
|
4661
|
-
"enforce-curly-newline": enforce_curly_newline_default,
|
|
4662
4750
|
"enforce-hook-naming": enforce_hook_naming_default,
|
|
4663
4751
|
"enforce-property-case": enforce_property_case_default,
|
|
4664
4752
|
"enforce-props-suffix": enforce_props_suffix_default,
|
|
@@ -4666,7 +4754,6 @@ var rules = {
|
|
|
4666
4754
|
"enforce-service-naming": enforce_service_naming_default,
|
|
4667
4755
|
"enforce-sorted-destructuring": enforce_sorted_destructuring_default,
|
|
4668
4756
|
"enforce-type-declaration-order": enforce_type_declaration_order_default,
|
|
4669
|
-
"file-kebab-case": file_kebab_case_default,
|
|
4670
4757
|
"index-export-only": index_export_only_default,
|
|
4671
4758
|
"jsx-newline-between-elements": jsx_newline_between_elements_default,
|
|
4672
4759
|
"jsx-no-inline-object-prop": jsx_no_inline_object_prop_default,
|
|
@@ -4674,18 +4761,17 @@ var rules = {
|
|
|
4674
4761
|
"jsx-no-non-component-function": jsx_no_non_component_function_default,
|
|
4675
4762
|
"jsx-no-ternary-null": jsx_no_ternary_null_default,
|
|
4676
4763
|
"jsx-no-variable-in-callback": jsx_no_variable_in_callback_default,
|
|
4677
|
-
"jsx-pascal-case": jsx_pascal_case_default,
|
|
4678
4764
|
"jsx-require-suspense": jsx_require_suspense_default,
|
|
4679
4765
|
"jsx-simple-props": jsx_simple_props_default,
|
|
4680
4766
|
"jsx-sort-props": jsx_sort_props_default,
|
|
4681
4767
|
"jsx-spread-props-last": jsx_spread_props_last_default,
|
|
4682
4768
|
"newline-after-multiline-block": newline_after_multiline_block_default,
|
|
4683
4769
|
"newline-before-return": newline_before_return_default,
|
|
4684
|
-
"nextjs-require-public-env": nextjs_require_public_env_default,
|
|
4685
4770
|
"no-complex-inline-return": no_complex_inline_return_default,
|
|
4686
4771
|
"no-direct-date": no_direct_date_default,
|
|
4687
4772
|
"no-emoji": no_emoji_default,
|
|
4688
4773
|
"no-env-fallback": no_env_fallback_default,
|
|
4774
|
+
"no-ghost-wrapper": no_ghost_wrapper_default,
|
|
4689
4775
|
"no-inline-default-export": no_inline_default_export_default,
|
|
4690
4776
|
"no-inline-nested-object": no_inline_nested_object_default,
|
|
4691
4777
|
"no-inline-return-properties": no_inline_return_properties_default,
|
|
@@ -4695,6 +4781,7 @@ var rules = {
|
|
|
4695
4781
|
"no-misleading-constant-case": no_misleading_constant_case_default,
|
|
4696
4782
|
"no-nested-interface-declaration": no_nested_interface_declaration_default,
|
|
4697
4783
|
"no-nested-ternary": no_nested_ternary_default,
|
|
4784
|
+
"no-redundant-fragment": no_redundant_fragment_default,
|
|
4698
4785
|
"no-relative-imports": no_relative_imports_default,
|
|
4699
4786
|
"no-single-char-variables": no_single_char_variables_default,
|
|
4700
4787
|
"prefer-async-await": prefer_async_await_default,
|
|
@@ -4704,9 +4791,11 @@ var rules = {
|
|
|
4704
4791
|
"prefer-import-type": prefer_import_type_default,
|
|
4705
4792
|
"prefer-inline-literal-union": prefer_inline_literal_union_default,
|
|
4706
4793
|
"prefer-inline-type-export": prefer_inline_type_export_default,
|
|
4794
|
+
"prefer-interface-for-component-props": prefer_interface_for_component_props_default,
|
|
4707
4795
|
"prefer-interface-over-inline-types": prefer_interface_over_inline_types_default,
|
|
4708
4796
|
"prefer-jsx-template-literals": prefer_jsx_template_literals_default,
|
|
4709
4797
|
"prefer-named-param-types": prefer_named_param_types_default,
|
|
4798
|
+
"prefer-props-with-children": prefer_props_with_children_default,
|
|
4710
4799
|
"prefer-react-import-types": prefer_react_import_types_default,
|
|
4711
4800
|
"react-props-destructure": react_props_destructure_default,
|
|
4712
4801
|
"require-explicit-return-type": require_explicit_return_type_default,
|
|
@@ -4723,13 +4812,11 @@ var baseRules = {
|
|
|
4723
4812
|
"nextfriday/boolean-naming-prefix": "warn",
|
|
4724
4813
|
"nextfriday/enforce-camel-case": "warn",
|
|
4725
4814
|
"nextfriday/enforce-constant-case": "warn",
|
|
4726
|
-
"nextfriday/enforce-curly-newline": "warn",
|
|
4727
4815
|
"nextfriday/enforce-hook-naming": "warn",
|
|
4728
4816
|
"nextfriday/enforce-property-case": "warn",
|
|
4729
4817
|
"nextfriday/enforce-service-naming": "warn",
|
|
4730
4818
|
"nextfriday/enforce-sorted-destructuring": "warn",
|
|
4731
4819
|
"nextfriday/enforce-type-declaration-order": "warn",
|
|
4732
|
-
"nextfriday/file-kebab-case": "warn",
|
|
4733
4820
|
"nextfriday/index-export-only": "warn",
|
|
4734
4821
|
"nextfriday/newline-after-multiline-block": "warn",
|
|
4735
4822
|
"nextfriday/newline-before-return": "warn",
|
|
@@ -4767,13 +4854,11 @@ var baseRecommendedRules = {
|
|
|
4767
4854
|
"nextfriday/boolean-naming-prefix": "error",
|
|
4768
4855
|
"nextfriday/enforce-camel-case": "error",
|
|
4769
4856
|
"nextfriday/enforce-constant-case": "error",
|
|
4770
|
-
"nextfriday/enforce-curly-newline": "error",
|
|
4771
4857
|
"nextfriday/enforce-hook-naming": "error",
|
|
4772
4858
|
"nextfriday/enforce-property-case": "error",
|
|
4773
4859
|
"nextfriday/enforce-service-naming": "error",
|
|
4774
4860
|
"nextfriday/enforce-sorted-destructuring": "error",
|
|
4775
4861
|
"nextfriday/enforce-type-declaration-order": "error",
|
|
4776
|
-
"nextfriday/file-kebab-case": "error",
|
|
4777
4862
|
"nextfriday/index-export-only": "error",
|
|
4778
4863
|
"nextfriday/newline-after-multiline-block": "error",
|
|
4779
4864
|
"nextfriday/newline-before-return": "error",
|
|
@@ -4816,13 +4901,16 @@ var jsxRules = {
|
|
|
4816
4901
|
"nextfriday/jsx-no-non-component-function": "warn",
|
|
4817
4902
|
"nextfriday/jsx-no-ternary-null": "warn",
|
|
4818
4903
|
"nextfriday/jsx-no-variable-in-callback": "warn",
|
|
4819
|
-
"nextfriday/jsx-pascal-case": "warn",
|
|
4820
4904
|
"nextfriday/jsx-require-suspense": "warn",
|
|
4821
4905
|
"nextfriday/jsx-simple-props": "warn",
|
|
4822
4906
|
"nextfriday/jsx-sort-props": "warn",
|
|
4823
4907
|
"nextfriday/jsx-spread-props-last": "warn",
|
|
4908
|
+
"nextfriday/no-ghost-wrapper": "warn",
|
|
4909
|
+
"nextfriday/no-redundant-fragment": "warn",
|
|
4910
|
+
"nextfriday/prefer-interface-for-component-props": "warn",
|
|
4824
4911
|
"nextfriday/prefer-interface-over-inline-types": "warn",
|
|
4825
4912
|
"nextfriday/prefer-jsx-template-literals": "warn",
|
|
4913
|
+
"nextfriday/prefer-props-with-children": "warn",
|
|
4826
4914
|
"nextfriday/react-props-destructure": "warn"
|
|
4827
4915
|
};
|
|
4828
4916
|
var jsxRecommendedRules = {
|
|
@@ -4834,41 +4922,24 @@ var jsxRecommendedRules = {
|
|
|
4834
4922
|
"nextfriday/jsx-no-non-component-function": "error",
|
|
4835
4923
|
"nextfriday/jsx-no-ternary-null": "error",
|
|
4836
4924
|
"nextfriday/jsx-no-variable-in-callback": "error",
|
|
4837
|
-
"nextfriday/jsx-pascal-case": "error",
|
|
4838
4925
|
"nextfriday/jsx-require-suspense": "error",
|
|
4839
4926
|
"nextfriday/jsx-simple-props": "error",
|
|
4840
4927
|
"nextfriday/jsx-sort-props": "error",
|
|
4841
4928
|
"nextfriday/jsx-spread-props-last": "error",
|
|
4929
|
+
"nextfriday/no-ghost-wrapper": "error",
|
|
4930
|
+
"nextfriday/no-redundant-fragment": "error",
|
|
4931
|
+
"nextfriday/prefer-interface-for-component-props": "error",
|
|
4842
4932
|
"nextfriday/prefer-interface-over-inline-types": "error",
|
|
4843
4933
|
"nextfriday/prefer-jsx-template-literals": "error",
|
|
4934
|
+
"nextfriday/prefer-props-with-children": "error",
|
|
4844
4935
|
"nextfriday/react-props-destructure": "error"
|
|
4845
4936
|
};
|
|
4846
|
-
var nextjsOnlyRules = {
|
|
4847
|
-
"nextfriday/nextjs-require-public-env": "warn"
|
|
4848
|
-
};
|
|
4849
|
-
var nextjsOnlyRecommendedRules = {
|
|
4850
|
-
"nextfriday/nextjs-require-public-env": "error"
|
|
4851
|
-
};
|
|
4852
4937
|
var createConfig = (configRules) => ({
|
|
4853
4938
|
plugins: {
|
|
4854
4939
|
nextfriday: plugin
|
|
4855
4940
|
},
|
|
4856
4941
|
rules: configRules
|
|
4857
4942
|
});
|
|
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
4943
|
var configs = {
|
|
4873
4944
|
base: createConfig(baseRules),
|
|
4874
4945
|
"base/recommended": createConfig(baseRecommendedRules),
|
|
@@ -4880,15 +4951,13 @@ var configs = {
|
|
|
4880
4951
|
...baseRecommendedRules,
|
|
4881
4952
|
...jsxRecommendedRules
|
|
4882
4953
|
}),
|
|
4883
|
-
nextjs:
|
|
4954
|
+
nextjs: createConfig({
|
|
4884
4955
|
...baseRules,
|
|
4885
|
-
...jsxRules
|
|
4886
|
-
...nextjsOnlyRules
|
|
4956
|
+
...jsxRules
|
|
4887
4957
|
}),
|
|
4888
|
-
"nextjs/recommended":
|
|
4958
|
+
"nextjs/recommended": createConfig({
|
|
4889
4959
|
...baseRecommendedRules,
|
|
4890
|
-
...jsxRecommendedRules
|
|
4891
|
-
...nextjsOnlyRecommendedRules
|
|
4960
|
+
...jsxRecommendedRules
|
|
4892
4961
|
})
|
|
4893
4962
|
};
|
|
4894
4963
|
var nextfridayPlugin = {
|