eslint-plugin-nextfriday 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +134 -8
- package/docs/rules/BOOLEAN_NAMING_PREFIX.md +13 -0
- package/docs/rules/ENFORCE_CONSTANT_CASE.md +31 -0
- package/docs/rules/FILE_KEBAB_CASE.md +31 -0
- package/docs/rules/JSX_PASCAL_CASE.md +30 -0
- package/lib/index.cjs +447 -468
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +26 -62
- package/lib/index.d.ts +26 -62
- package/lib/index.js +100 -123
- package/lib/index.js.map +1 -1
- package/package.json +2 -3
package/lib/index.cjs
CHANGED
|
@@ -36,13 +36,11 @@ __export(index_exports, {
|
|
|
36
36
|
rules: () => rules
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var import_eslint_plugin_sonarjs = __toESM(require("eslint-plugin-sonarjs"), 1);
|
|
40
|
-
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
41
39
|
|
|
42
40
|
// package.json
|
|
43
41
|
var package_default = {
|
|
44
42
|
name: "eslint-plugin-nextfriday",
|
|
45
|
-
version: "
|
|
43
|
+
version: "3.0.0",
|
|
46
44
|
description: "A comprehensive ESLint plugin providing custom rules and configurations for Next Friday development workflows.",
|
|
47
45
|
keywords: [
|
|
48
46
|
"eslint",
|
|
@@ -87,6 +85,7 @@ var package_default = {
|
|
|
87
85
|
"lib"
|
|
88
86
|
],
|
|
89
87
|
scripts: {
|
|
88
|
+
audit: "pnpm audit --prod --audit-level high",
|
|
90
89
|
build: "tsup",
|
|
91
90
|
changeset: "changeset",
|
|
92
91
|
"changeset:publish": "npm publish --provenance --access public",
|
|
@@ -108,8 +107,6 @@ var package_default = {
|
|
|
108
107
|
dependencies: {
|
|
109
108
|
"@typescript-eslint/utils": "^8.59.1",
|
|
110
109
|
"emoji-regex": "^10.6.0",
|
|
111
|
-
"eslint-plugin-sonarjs": "^4.0.3",
|
|
112
|
-
"eslint-plugin-unicorn": "^64.0.0",
|
|
113
110
|
tsup: "^8.5.1"
|
|
114
111
|
},
|
|
115
112
|
devDependencies: {
|
|
@@ -432,8 +429,20 @@ var enforceCamelCase = createRule2({
|
|
|
432
429
|
var enforce_camel_case_default = enforceCamelCase;
|
|
433
430
|
|
|
434
431
|
// src/rules/enforce-constant-case.ts
|
|
432
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
433
|
+
|
|
434
|
+
// src/utils.ts
|
|
435
|
+
var import_node_path = require("path");
|
|
435
436
|
var import_utils3 = require("@typescript-eslint/utils");
|
|
436
|
-
var
|
|
437
|
+
var getFileExtension = (filename) => (0, import_node_path.extname)(filename).slice(1);
|
|
438
|
+
var getBaseName = (filename) => (0, import_node_path.basename)(filename, (0, import_node_path.extname)(filename));
|
|
439
|
+
var isConfigFile = (filename) => {
|
|
440
|
+
const baseName = getBaseName(filename);
|
|
441
|
+
return /\.(config|rc|setup|spec|test)$/.test(baseName) || /\.(config|rc|setup|spec|test)\./.test(filename) || /^\.(eslintrc|babelrc|prettierrc)/.test(filename);
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
// src/rules/enforce-constant-case.ts
|
|
445
|
+
var createRule3 = import_utils4.ESLintUtils.RuleCreator(
|
|
437
446
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
438
447
|
);
|
|
439
448
|
var SCREAMING_SNAKE_CASE_REGEX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
@@ -450,42 +459,42 @@ var startsWithBooleanPrefix2 = (name) => BOOLEAN_PREFIXES2.some((prefix) => {
|
|
|
450
459
|
const nextChar = name.charAt(prefix.length);
|
|
451
460
|
return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
|
|
452
461
|
});
|
|
453
|
-
var isBooleanLiteral2 = (init) => init.type ===
|
|
454
|
-
var isAsConstAssertion = (node) => node.type ===
|
|
462
|
+
var isBooleanLiteral2 = (init) => init.type === import_utils4.AST_NODE_TYPES.Literal && typeof init.value === "boolean";
|
|
463
|
+
var isAsConstAssertion = (node) => node.type === import_utils4.AST_NODE_TYPES.TSAsExpression && node.typeAnnotation.type === import_utils4.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils4.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "const";
|
|
455
464
|
var isStaticValue2 = (init) => {
|
|
456
465
|
if (isAsConstAssertion(init)) {
|
|
457
466
|
return true;
|
|
458
467
|
}
|
|
459
|
-
if (init.type ===
|
|
468
|
+
if (init.type === import_utils4.AST_NODE_TYPES.Literal) {
|
|
460
469
|
return true;
|
|
461
470
|
}
|
|
462
|
-
if (init.type ===
|
|
471
|
+
if (init.type === import_utils4.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils4.AST_NODE_TYPES.Literal) {
|
|
463
472
|
return true;
|
|
464
473
|
}
|
|
465
|
-
if (init.type ===
|
|
474
|
+
if (init.type === import_utils4.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
466
475
|
return true;
|
|
467
476
|
}
|
|
468
|
-
if (init.type ===
|
|
469
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
477
|
+
if (init.type === import_utils4.AST_NODE_TYPES.ArrayExpression) {
|
|
478
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils4.AST_NODE_TYPES.SpreadElement && isStaticValue2(el));
|
|
470
479
|
}
|
|
471
|
-
if (init.type ===
|
|
480
|
+
if (init.type === import_utils4.AST_NODE_TYPES.ObjectExpression) {
|
|
472
481
|
return init.properties.every(
|
|
473
|
-
(prop) => prop.type ===
|
|
482
|
+
(prop) => prop.type === import_utils4.AST_NODE_TYPES.Property && isStaticValue2(prop.value)
|
|
474
483
|
);
|
|
475
484
|
}
|
|
476
485
|
return false;
|
|
477
486
|
};
|
|
478
487
|
var isGlobalScope2 = (node) => {
|
|
479
488
|
const { parent } = node;
|
|
480
|
-
if (parent.type ===
|
|
489
|
+
if (parent.type === import_utils4.AST_NODE_TYPES.Program) {
|
|
481
490
|
return true;
|
|
482
491
|
}
|
|
483
|
-
if (parent.type ===
|
|
492
|
+
if (parent.type === import_utils4.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils4.AST_NODE_TYPES.Program) {
|
|
484
493
|
return true;
|
|
485
494
|
}
|
|
486
495
|
return false;
|
|
487
496
|
};
|
|
488
|
-
var isFunctionOrComponent = (init) => init.type ===
|
|
497
|
+
var isFunctionOrComponent = (init) => init.type === import_utils4.AST_NODE_TYPES.ArrowFunctionExpression || init.type === import_utils4.AST_NODE_TYPES.FunctionExpression;
|
|
489
498
|
var enforceConstantCase = createRule3({
|
|
490
499
|
name: "enforce-constant-case",
|
|
491
500
|
meta: {
|
|
@@ -501,13 +510,16 @@ var enforceConstantCase = createRule3({
|
|
|
501
510
|
},
|
|
502
511
|
defaultOptions: [],
|
|
503
512
|
create(context) {
|
|
513
|
+
if (isConfigFile(context.filename)) {
|
|
514
|
+
return {};
|
|
515
|
+
}
|
|
504
516
|
return {
|
|
505
517
|
VariableDeclaration(node) {
|
|
506
518
|
if (node.kind !== "const" || !isGlobalScope2(node)) {
|
|
507
519
|
return;
|
|
508
520
|
}
|
|
509
521
|
node.declarations.forEach((declarator) => {
|
|
510
|
-
if (declarator.id.type !==
|
|
522
|
+
if (declarator.id.type !== import_utils4.AST_NODE_TYPES.Identifier || !declarator.init) {
|
|
511
523
|
return;
|
|
512
524
|
}
|
|
513
525
|
if (isFunctionOrComponent(declarator.init)) {
|
|
@@ -543,8 +555,8 @@ var enforceConstantCase = createRule3({
|
|
|
543
555
|
var enforce_constant_case_default = enforceConstantCase;
|
|
544
556
|
|
|
545
557
|
// src/rules/enforce-curly-newline.ts
|
|
546
|
-
var
|
|
547
|
-
var createRule4 =
|
|
558
|
+
var import_utils6 = require("@typescript-eslint/utils");
|
|
559
|
+
var createRule4 = import_utils6.ESLintUtils.RuleCreator(
|
|
548
560
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
549
561
|
);
|
|
550
562
|
var enforceCurlyNewline = createRule4({
|
|
@@ -570,7 +582,7 @@ var enforceCurlyNewline = createRule4({
|
|
|
570
582
|
const startLine = node.loc.start.line;
|
|
571
583
|
const endLine = node.loc.end.line;
|
|
572
584
|
const isSingleLine2 = startLine === endLine;
|
|
573
|
-
const hasBraces = consequent.type ===
|
|
585
|
+
const hasBraces = consequent.type === import_utils6.AST_NODE_TYPES.BlockStatement;
|
|
574
586
|
if (isSingleLine2 && hasBraces) {
|
|
575
587
|
if (consequent.body.length !== 1) {
|
|
576
588
|
return;
|
|
@@ -615,8 +627,8 @@ var enforce_curly_newline_default = enforceCurlyNewline;
|
|
|
615
627
|
|
|
616
628
|
// src/rules/enforce-hook-naming.ts
|
|
617
629
|
var import_path = __toESM(require("path"), 1);
|
|
618
|
-
var
|
|
619
|
-
var createRule5 =
|
|
630
|
+
var import_utils7 = require("@typescript-eslint/utils");
|
|
631
|
+
var createRule5 = import_utils7.ESLintUtils.RuleCreator(
|
|
620
632
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
621
633
|
);
|
|
622
634
|
var enforceHookNaming = createRule5({
|
|
@@ -658,22 +670,22 @@ var enforceHookNaming = createRule5({
|
|
|
658
670
|
};
|
|
659
671
|
return {
|
|
660
672
|
ExportNamedDeclaration(node) {
|
|
661
|
-
if (node.declaration?.type ===
|
|
673
|
+
if (node.declaration?.type === import_utils7.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
662
674
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "missingUsePrefix");
|
|
663
675
|
}
|
|
664
|
-
if (node.declaration?.type ===
|
|
676
|
+
if (node.declaration?.type === import_utils7.AST_NODE_TYPES.VariableDeclaration) {
|
|
665
677
|
node.declaration.declarations.forEach((declarator) => {
|
|
666
|
-
if (declarator.id.type ===
|
|
678
|
+
if (declarator.id.type === import_utils7.AST_NODE_TYPES.Identifier) {
|
|
667
679
|
checkFunctionName(declarator.id.name, declarator.id, "missingUsePrefix");
|
|
668
680
|
}
|
|
669
681
|
});
|
|
670
682
|
}
|
|
671
683
|
},
|
|
672
684
|
ExportDefaultDeclaration(node) {
|
|
673
|
-
if (node.declaration.type ===
|
|
685
|
+
if (node.declaration.type === import_utils7.AST_NODE_TYPES.Identifier) {
|
|
674
686
|
checkFunctionName(node.declaration.name, node.declaration, "defaultExportMissingUsePrefix");
|
|
675
687
|
}
|
|
676
|
-
if (node.declaration.type ===
|
|
688
|
+
if (node.declaration.type === import_utils7.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
677
689
|
checkFunctionName(node.declaration.id.name, node.declaration.id, "defaultExportMissingUsePrefix");
|
|
678
690
|
}
|
|
679
691
|
}
|
|
@@ -683,20 +695,20 @@ var enforceHookNaming = createRule5({
|
|
|
683
695
|
var enforce_hook_naming_default = enforceHookNaming;
|
|
684
696
|
|
|
685
697
|
// src/rules/enforce-property-case.ts
|
|
686
|
-
var
|
|
687
|
-
var createRule6 =
|
|
698
|
+
var import_utils8 = require("@typescript-eslint/utils");
|
|
699
|
+
var createRule6 = import_utils8.ESLintUtils.RuleCreator(
|
|
688
700
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
689
701
|
);
|
|
690
702
|
var SNAKE_CASE_REGEX3 = /^[a-z]+_[a-z0-9_]*$/;
|
|
691
703
|
var SCREAMING_SNAKE_CASE_REGEX2 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
692
704
|
var isInsideAsConst = (node) => {
|
|
693
705
|
const { parent } = node;
|
|
694
|
-
if (parent.type ===
|
|
706
|
+
if (parent.type === import_utils8.AST_NODE_TYPES.TSAsExpression && parent.typeAnnotation.type === import_utils8.AST_NODE_TYPES.TSTypeReference && parent.typeAnnotation.typeName.type === import_utils8.AST_NODE_TYPES.Identifier && parent.typeAnnotation.typeName.name === "const") {
|
|
695
707
|
return true;
|
|
696
708
|
}
|
|
697
|
-
if (parent.type ===
|
|
709
|
+
if (parent.type === import_utils8.AST_NODE_TYPES.ArrayExpression) {
|
|
698
710
|
const grandparent = parent.parent;
|
|
699
|
-
if (grandparent?.type ===
|
|
711
|
+
if (grandparent?.type === import_utils8.AST_NODE_TYPES.TSAsExpression && grandparent.typeAnnotation.type === import_utils8.AST_NODE_TYPES.TSTypeReference && grandparent.typeAnnotation.typeName.type === import_utils8.AST_NODE_TYPES.Identifier && grandparent.typeAnnotation.typeName.name === "const") {
|
|
700
712
|
return true;
|
|
701
713
|
}
|
|
702
714
|
}
|
|
@@ -718,7 +730,7 @@ var enforcePropertyCase = createRule6({
|
|
|
718
730
|
create(context) {
|
|
719
731
|
return {
|
|
720
732
|
Property(node) {
|
|
721
|
-
if (node.parent.type !==
|
|
733
|
+
if (node.parent.type !== import_utils8.AST_NODE_TYPES.ObjectExpression) {
|
|
722
734
|
return;
|
|
723
735
|
}
|
|
724
736
|
if (isInsideAsConst(node.parent)) {
|
|
@@ -727,7 +739,7 @@ var enforcePropertyCase = createRule6({
|
|
|
727
739
|
if (node.computed) {
|
|
728
740
|
return;
|
|
729
741
|
}
|
|
730
|
-
if (node.key.type !==
|
|
742
|
+
if (node.key.type !== import_utils8.AST_NODE_TYPES.Identifier) {
|
|
731
743
|
return;
|
|
732
744
|
}
|
|
733
745
|
const { name } = node.key;
|
|
@@ -746,8 +758,8 @@ var enforce_property_case_default = enforcePropertyCase;
|
|
|
746
758
|
|
|
747
759
|
// src/rules/enforce-props-suffix.ts
|
|
748
760
|
var import_path2 = __toESM(require("path"), 1);
|
|
749
|
-
var
|
|
750
|
-
var createRule7 =
|
|
761
|
+
var import_utils9 = require("@typescript-eslint/utils");
|
|
762
|
+
var createRule7 = import_utils9.ESLintUtils.RuleCreator(
|
|
751
763
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
752
764
|
);
|
|
753
765
|
var enforcePropsSuffix = createRule7({
|
|
@@ -784,13 +796,13 @@ var enforcePropsSuffix = createRule7({
|
|
|
784
796
|
};
|
|
785
797
|
return {
|
|
786
798
|
TSInterfaceDeclaration(node) {
|
|
787
|
-
if (node.id.type ===
|
|
799
|
+
if (node.id.type === import_utils9.AST_NODE_TYPES.Identifier) {
|
|
788
800
|
checkTypeName(node.id.name, node.id);
|
|
789
801
|
}
|
|
790
802
|
},
|
|
791
803
|
TSTypeAliasDeclaration(node) {
|
|
792
|
-
if (node.id.type ===
|
|
793
|
-
if (node.typeAnnotation.type ===
|
|
804
|
+
if (node.id.type === import_utils9.AST_NODE_TYPES.Identifier) {
|
|
805
|
+
if (node.typeAnnotation.type === import_utils9.AST_NODE_TYPES.TSTypeLiteral) {
|
|
794
806
|
checkTypeName(node.id.name, node.id);
|
|
795
807
|
}
|
|
796
808
|
}
|
|
@@ -801,8 +813,8 @@ var enforcePropsSuffix = createRule7({
|
|
|
801
813
|
var enforce_props_suffix_default = enforcePropsSuffix;
|
|
802
814
|
|
|
803
815
|
// src/rules/enforce-readonly-component-props.ts
|
|
804
|
-
var
|
|
805
|
-
var createRule8 =
|
|
816
|
+
var import_utils10 = require("@typescript-eslint/utils");
|
|
817
|
+
var createRule8 = import_utils10.ESLintUtils.RuleCreator(
|
|
806
818
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
807
819
|
);
|
|
808
820
|
var enforceReadonlyComponentProps = createRule8({
|
|
@@ -821,40 +833,40 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
821
833
|
defaultOptions: [],
|
|
822
834
|
create(context) {
|
|
823
835
|
function hasJSXInConditional(node) {
|
|
824
|
-
return node.consequent.type ===
|
|
836
|
+
return node.consequent.type === import_utils10.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils10.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils10.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils10.AST_NODE_TYPES.JSXFragment;
|
|
825
837
|
}
|
|
826
838
|
function hasJSXInLogical(node) {
|
|
827
|
-
return node.right.type ===
|
|
839
|
+
return node.right.type === import_utils10.AST_NODE_TYPES.JSXElement || node.right.type === import_utils10.AST_NODE_TYPES.JSXFragment;
|
|
828
840
|
}
|
|
829
841
|
function hasJSXReturn(block) {
|
|
830
842
|
return block.body.some((stmt) => {
|
|
831
|
-
if (stmt.type ===
|
|
832
|
-
return stmt.argument.type ===
|
|
843
|
+
if (stmt.type === import_utils10.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
844
|
+
return stmt.argument.type === import_utils10.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils10.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils10.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils10.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
833
845
|
}
|
|
834
846
|
return false;
|
|
835
847
|
});
|
|
836
848
|
}
|
|
837
849
|
function isReactComponent2(node) {
|
|
838
|
-
if (node.type ===
|
|
839
|
-
if (node.body.type ===
|
|
850
|
+
if (node.type === import_utils10.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
851
|
+
if (node.body.type === import_utils10.AST_NODE_TYPES.JSXElement || node.body.type === import_utils10.AST_NODE_TYPES.JSXFragment) {
|
|
840
852
|
return true;
|
|
841
853
|
}
|
|
842
|
-
if (node.body.type ===
|
|
854
|
+
if (node.body.type === import_utils10.AST_NODE_TYPES.BlockStatement) {
|
|
843
855
|
return hasJSXReturn(node.body);
|
|
844
856
|
}
|
|
845
|
-
} else if (node.type ===
|
|
846
|
-
if (node.body && node.body.type ===
|
|
857
|
+
} else if (node.type === import_utils10.AST_NODE_TYPES.FunctionExpression || node.type === import_utils10.AST_NODE_TYPES.FunctionDeclaration) {
|
|
858
|
+
if (node.body && node.body.type === import_utils10.AST_NODE_TYPES.BlockStatement) {
|
|
847
859
|
return hasJSXReturn(node.body);
|
|
848
860
|
}
|
|
849
861
|
}
|
|
850
862
|
return false;
|
|
851
863
|
}
|
|
852
864
|
function isNamedType(node) {
|
|
853
|
-
return node.type ===
|
|
865
|
+
return node.type === import_utils10.AST_NODE_TYPES.TSTypeReference;
|
|
854
866
|
}
|
|
855
867
|
function isAlreadyReadonly(node) {
|
|
856
|
-
if (node.type ===
|
|
857
|
-
if (node.typeName.type ===
|
|
868
|
+
if (node.type === import_utils10.AST_NODE_TYPES.TSTypeReference && node.typeName) {
|
|
869
|
+
if (node.typeName.type === import_utils10.AST_NODE_TYPES.Identifier && node.typeName.name === "Readonly") {
|
|
858
870
|
return true;
|
|
859
871
|
}
|
|
860
872
|
}
|
|
@@ -868,7 +880,7 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
868
880
|
return;
|
|
869
881
|
}
|
|
870
882
|
const param = node.params[0];
|
|
871
|
-
if (param.type ===
|
|
883
|
+
if (param.type === import_utils10.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
872
884
|
const { typeAnnotation } = param.typeAnnotation;
|
|
873
885
|
if (isNamedType(typeAnnotation) && !isAlreadyReadonly(typeAnnotation)) {
|
|
874
886
|
const { sourceCode } = context;
|
|
@@ -893,8 +905,8 @@ var enforceReadonlyComponentProps = createRule8({
|
|
|
893
905
|
var enforce_readonly_component_props_default = enforceReadonlyComponentProps;
|
|
894
906
|
|
|
895
907
|
// src/rules/enforce-service-naming.ts
|
|
896
|
-
var
|
|
897
|
-
var createRule9 =
|
|
908
|
+
var import_utils11 = require("@typescript-eslint/utils");
|
|
909
|
+
var createRule9 = import_utils11.ESLintUtils.RuleCreator(
|
|
898
910
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
899
911
|
);
|
|
900
912
|
var BANNED_PREFIXES = {
|
|
@@ -946,12 +958,12 @@ var enforceServiceNaming = createRule9({
|
|
|
946
958
|
};
|
|
947
959
|
return {
|
|
948
960
|
ExportNamedDeclaration(node) {
|
|
949
|
-
if (node.declaration?.type ===
|
|
961
|
+
if (node.declaration?.type === import_utils11.AST_NODE_TYPES.FunctionDeclaration && node.declaration.id) {
|
|
950
962
|
checkExportedFunction(node.declaration, node.declaration.id);
|
|
951
963
|
}
|
|
952
|
-
if (node.declaration?.type ===
|
|
964
|
+
if (node.declaration?.type === import_utils11.AST_NODE_TYPES.VariableDeclaration) {
|
|
953
965
|
node.declaration.declarations.forEach((declarator) => {
|
|
954
|
-
if (declarator.id.type ===
|
|
966
|
+
if (declarator.id.type === import_utils11.AST_NODE_TYPES.Identifier && declarator.init?.type === import_utils11.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
955
967
|
checkExportedFunction(declarator.init, declarator.id);
|
|
956
968
|
}
|
|
957
969
|
});
|
|
@@ -963,8 +975,8 @@ var enforceServiceNaming = createRule9({
|
|
|
963
975
|
var enforce_service_naming_default = enforceServiceNaming;
|
|
964
976
|
|
|
965
977
|
// src/rules/enforce-sorted-destructuring.ts
|
|
966
|
-
var
|
|
967
|
-
var createRule10 =
|
|
978
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
979
|
+
var createRule10 = import_utils12.ESLintUtils.RuleCreator(
|
|
968
980
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
969
981
|
);
|
|
970
982
|
var enforceSortedDestructuring = createRule10({
|
|
@@ -983,19 +995,19 @@ var enforceSortedDestructuring = createRule10({
|
|
|
983
995
|
defaultOptions: [],
|
|
984
996
|
create(context) {
|
|
985
997
|
function getPropertyName(property) {
|
|
986
|
-
if (property.type ===
|
|
998
|
+
if (property.type === import_utils12.AST_NODE_TYPES.RestElement) {
|
|
987
999
|
return null;
|
|
988
1000
|
}
|
|
989
|
-
if (property.key.type ===
|
|
1001
|
+
if (property.key.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
990
1002
|
return property.key.name;
|
|
991
1003
|
}
|
|
992
1004
|
return null;
|
|
993
1005
|
}
|
|
994
1006
|
function hasDefaultValue(property) {
|
|
995
|
-
return property.value.type ===
|
|
1007
|
+
return property.value.type === import_utils12.AST_NODE_TYPES.AssignmentPattern && Boolean(property.value.right);
|
|
996
1008
|
}
|
|
997
1009
|
function checkVariableDeclarator(node) {
|
|
998
|
-
if (node.id.type !==
|
|
1010
|
+
if (node.id.type !== import_utils12.AST_NODE_TYPES.ObjectPattern) {
|
|
999
1011
|
return;
|
|
1000
1012
|
}
|
|
1001
1013
|
const { properties } = node.id;
|
|
@@ -1003,7 +1015,7 @@ var enforceSortedDestructuring = createRule10({
|
|
|
1003
1015
|
return;
|
|
1004
1016
|
}
|
|
1005
1017
|
const propertyInfo = properties.map((prop) => {
|
|
1006
|
-
if (prop.type ===
|
|
1018
|
+
if (prop.type === import_utils12.AST_NODE_TYPES.RestElement) {
|
|
1007
1019
|
return null;
|
|
1008
1020
|
}
|
|
1009
1021
|
return {
|
|
@@ -1042,15 +1054,15 @@ var enforceSortedDestructuring = createRule10({
|
|
|
1042
1054
|
var enforce_sorted_destructuring_default = enforceSortedDestructuring;
|
|
1043
1055
|
|
|
1044
1056
|
// src/rules/enforce-type-declaration-order.ts
|
|
1045
|
-
var
|
|
1046
|
-
var createRule11 =
|
|
1057
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
1058
|
+
var createRule11 = import_utils13.ESLintUtils.RuleCreator(
|
|
1047
1059
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1048
1060
|
);
|
|
1049
1061
|
function getTypeDeclarationName(node) {
|
|
1050
|
-
if (node.type ===
|
|
1062
|
+
if (node.type === import_utils13.AST_NODE_TYPES.TSInterfaceDeclaration && node.id.type === import_utils13.AST_NODE_TYPES.Identifier) {
|
|
1051
1063
|
return { name: node.id.name, position: node.range[0] };
|
|
1052
1064
|
}
|
|
1053
|
-
if (node.type ===
|
|
1065
|
+
if (node.type === import_utils13.AST_NODE_TYPES.TSTypeAliasDeclaration && node.id.type === import_utils13.AST_NODE_TYPES.Identifier) {
|
|
1054
1066
|
return { name: node.id.name, position: node.range[0] };
|
|
1055
1067
|
}
|
|
1056
1068
|
return null;
|
|
@@ -1086,7 +1098,7 @@ var enforceTypeDeclarationOrder = createRule11({
|
|
|
1086
1098
|
}
|
|
1087
1099
|
},
|
|
1088
1100
|
"TSPropertySignature TSTypeReference": function checkTypeReference(node) {
|
|
1089
|
-
if (node.typeName.type !==
|
|
1101
|
+
if (node.typeName.type !== import_utils13.AST_NODE_TYPES.Identifier) {
|
|
1090
1102
|
return;
|
|
1091
1103
|
}
|
|
1092
1104
|
const referencedName = node.typeName.name;
|
|
@@ -1124,8 +1136,8 @@ var enforce_type_declaration_order_default = enforceTypeDeclarationOrder;
|
|
|
1124
1136
|
|
|
1125
1137
|
// src/rules/file-kebab-case.ts
|
|
1126
1138
|
var import_path3 = __toESM(require("path"), 1);
|
|
1127
|
-
var
|
|
1128
|
-
var createRule12 =
|
|
1139
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
1140
|
+
var createRule12 = import_utils14.ESLintUtils.RuleCreator(
|
|
1129
1141
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1130
1142
|
);
|
|
1131
1143
|
var isKebabCase = (str) => {
|
|
@@ -1169,8 +1181,8 @@ var fileKebabCase = createRule12({
|
|
|
1169
1181
|
var file_kebab_case_default = fileKebabCase;
|
|
1170
1182
|
|
|
1171
1183
|
// src/rules/jsx-newline-between-elements.ts
|
|
1172
|
-
var
|
|
1173
|
-
var createRule13 =
|
|
1184
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
1185
|
+
var createRule13 = import_utils15.ESLintUtils.RuleCreator(
|
|
1174
1186
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1175
1187
|
);
|
|
1176
1188
|
var jsxNewlineBetweenElements = createRule13({
|
|
@@ -1191,7 +1203,7 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1191
1203
|
create(context) {
|
|
1192
1204
|
const { sourceCode } = context;
|
|
1193
1205
|
function isSignificantJSXChild(node) {
|
|
1194
|
-
return node.type ===
|
|
1206
|
+
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;
|
|
1195
1207
|
}
|
|
1196
1208
|
function isMultiLine(node) {
|
|
1197
1209
|
return node.loc.start.line !== node.loc.end.line;
|
|
@@ -1241,8 +1253,8 @@ var jsxNewlineBetweenElements = createRule13({
|
|
|
1241
1253
|
var jsx_newline_between_elements_default = jsxNewlineBetweenElements;
|
|
1242
1254
|
|
|
1243
1255
|
// src/rules/jsx-no-inline-object-prop.ts
|
|
1244
|
-
var
|
|
1245
|
-
var createRule14 =
|
|
1256
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
1257
|
+
var createRule14 = import_utils16.ESLintUtils.RuleCreator(
|
|
1246
1258
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1247
1259
|
);
|
|
1248
1260
|
var jsxNoInlineObjectProp = createRule14({
|
|
@@ -1261,7 +1273,7 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1261
1273
|
create(context) {
|
|
1262
1274
|
return {
|
|
1263
1275
|
JSXAttribute(node) {
|
|
1264
|
-
if (node.value?.type ===
|
|
1276
|
+
if (node.value?.type === import_utils16.AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === import_utils16.AST_NODE_TYPES.ObjectExpression) {
|
|
1265
1277
|
context.report({
|
|
1266
1278
|
node: node.value,
|
|
1267
1279
|
messageId: "noInlineObject"
|
|
@@ -1274,12 +1286,12 @@ var jsxNoInlineObjectProp = createRule14({
|
|
|
1274
1286
|
var jsx_no_inline_object_prop_default = jsxNoInlineObjectProp;
|
|
1275
1287
|
|
|
1276
1288
|
// src/rules/jsx-no-newline-single-line-elements.ts
|
|
1277
|
-
var
|
|
1278
|
-
var createRule15 =
|
|
1289
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
1290
|
+
var createRule15 = import_utils17.ESLintUtils.RuleCreator(
|
|
1279
1291
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1280
1292
|
);
|
|
1281
1293
|
function isJSXElementOrFragment(node) {
|
|
1282
|
-
return node.type ===
|
|
1294
|
+
return node.type === import_utils17.AST_NODE_TYPES.JSXElement || node.type === import_utils17.AST_NODE_TYPES.JSXFragment;
|
|
1283
1295
|
}
|
|
1284
1296
|
function isSingleLine(node) {
|
|
1285
1297
|
return node.loc.start.line === node.loc.end.line;
|
|
@@ -1302,7 +1314,7 @@ var jsxNoNewlineSingleLineElements = createRule15({
|
|
|
1302
1314
|
const { sourceCode } = context;
|
|
1303
1315
|
function checkSiblings(children) {
|
|
1304
1316
|
const nonWhitespace = children.filter(
|
|
1305
|
-
(child) => !(child.type ===
|
|
1317
|
+
(child) => !(child.type === import_utils17.AST_NODE_TYPES.JSXText && child.value.trim() === "")
|
|
1306
1318
|
);
|
|
1307
1319
|
nonWhitespace.forEach((next, index) => {
|
|
1308
1320
|
if (index === 0) {
|
|
@@ -1353,15 +1365,8 @@ ${indent}`);
|
|
|
1353
1365
|
var jsx_no_newline_single_line_elements_default = jsxNoNewlineSingleLineElements;
|
|
1354
1366
|
|
|
1355
1367
|
// src/rules/jsx-no-non-component-function.ts
|
|
1356
|
-
var
|
|
1357
|
-
|
|
1358
|
-
// src/utils.ts
|
|
1359
|
-
var import_node_path = require("path");
|
|
1360
|
-
var import_utils16 = require("@typescript-eslint/utils");
|
|
1361
|
-
var getFileExtension = (filename) => (0, import_node_path.extname)(filename).slice(1);
|
|
1362
|
-
|
|
1363
|
-
// src/rules/jsx-no-non-component-function.ts
|
|
1364
|
-
var createRule16 = import_utils17.ESLintUtils.RuleCreator(
|
|
1368
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
1369
|
+
var createRule16 = import_utils18.ESLintUtils.RuleCreator(
|
|
1365
1370
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1366
1371
|
);
|
|
1367
1372
|
var jsxNoNonComponentFunction = createRule16({
|
|
@@ -1384,13 +1389,13 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1384
1389
|
return {};
|
|
1385
1390
|
}
|
|
1386
1391
|
function isReactComponent2(node) {
|
|
1387
|
-
const functionName = node.type ===
|
|
1392
|
+
const functionName = node.type === import_utils18.AST_NODE_TYPES.FunctionDeclaration && node.id ? node.id.name : null;
|
|
1388
1393
|
if (functionName && /^[A-Z]/.test(functionName)) {
|
|
1389
1394
|
return true;
|
|
1390
1395
|
}
|
|
1391
1396
|
if (node.returnType?.typeAnnotation) {
|
|
1392
1397
|
const returnTypeNode = node.returnType.typeAnnotation;
|
|
1393
|
-
if (returnTypeNode.type ===
|
|
1398
|
+
if (returnTypeNode.type === import_utils18.AST_NODE_TYPES.TSTypeReference && returnTypeNode.typeName.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1394
1399
|
const typeName = returnTypeNode.typeName.name;
|
|
1395
1400
|
if (typeName === "JSX" || typeName === "ReactElement" || typeName === "ReactNode") {
|
|
1396
1401
|
return true;
|
|
@@ -1407,13 +1412,13 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1407
1412
|
if (!parent) {
|
|
1408
1413
|
return;
|
|
1409
1414
|
}
|
|
1410
|
-
if (parent.type ===
|
|
1415
|
+
if (parent.type === import_utils18.AST_NODE_TYPES.ExportDefaultDeclaration || parent.type === import_utils18.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1411
1416
|
return;
|
|
1412
1417
|
}
|
|
1413
|
-
if (declaratorNode?.parent?.parent?.type ===
|
|
1418
|
+
if (declaratorNode?.parent?.parent?.type === import_utils18.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
1414
1419
|
return;
|
|
1415
1420
|
}
|
|
1416
|
-
if (declaratorNode?.id.type ===
|
|
1421
|
+
if (declaratorNode?.id.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
1417
1422
|
const varName = declaratorNode.id.name;
|
|
1418
1423
|
if (/^[A-Z]/.test(varName)) {
|
|
1419
1424
|
return;
|
|
@@ -1438,15 +1443,15 @@ var jsxNoNonComponentFunction = createRule16({
|
|
|
1438
1443
|
var jsx_no_non_component_function_default = jsxNoNonComponentFunction;
|
|
1439
1444
|
|
|
1440
1445
|
// src/rules/jsx-no-ternary-null.ts
|
|
1441
|
-
var
|
|
1442
|
-
var createRule17 =
|
|
1446
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
1447
|
+
var createRule17 = import_utils20.ESLintUtils.RuleCreator(
|
|
1443
1448
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1444
1449
|
);
|
|
1445
1450
|
function isNullOrUndefined(node) {
|
|
1446
|
-
if (node.type ===
|
|
1451
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Literal && node.value === null) {
|
|
1447
1452
|
return true;
|
|
1448
1453
|
}
|
|
1449
|
-
if (node.type ===
|
|
1454
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Identifier && node.name === "undefined") {
|
|
1450
1455
|
return true;
|
|
1451
1456
|
}
|
|
1452
1457
|
return false;
|
|
@@ -1469,7 +1474,7 @@ var jsxNoTernaryNull = createRule17({
|
|
|
1469
1474
|
return {
|
|
1470
1475
|
JSXExpressionContainer(node) {
|
|
1471
1476
|
const { expression } = node;
|
|
1472
|
-
if (expression.type !==
|
|
1477
|
+
if (expression.type !== import_utils20.AST_NODE_TYPES.ConditionalExpression) {
|
|
1473
1478
|
return;
|
|
1474
1479
|
}
|
|
1475
1480
|
const { test, consequent, alternate } = expression;
|
|
@@ -1501,8 +1506,8 @@ var jsxNoTernaryNull = createRule17({
|
|
|
1501
1506
|
var jsx_no_ternary_null_default = jsxNoTernaryNull;
|
|
1502
1507
|
|
|
1503
1508
|
// src/rules/jsx-no-variable-in-callback.ts
|
|
1504
|
-
var
|
|
1505
|
-
var createRule18 =
|
|
1509
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
1510
|
+
var createRule18 = import_utils21.ESLintUtils.RuleCreator(
|
|
1506
1511
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1507
1512
|
);
|
|
1508
1513
|
var jsxNoVariableInCallback = createRule18({
|
|
@@ -1522,7 +1527,7 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1522
1527
|
function isInsideJSX(node) {
|
|
1523
1528
|
let current = node.parent;
|
|
1524
1529
|
while (current) {
|
|
1525
|
-
if (current.type ===
|
|
1530
|
+
if (current.type === import_utils21.AST_NODE_TYPES.JSXElement || current.type === import_utils21.AST_NODE_TYPES.JSXFragment) {
|
|
1526
1531
|
return true;
|
|
1527
1532
|
}
|
|
1528
1533
|
current = current.parent;
|
|
@@ -1536,11 +1541,11 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1536
1541
|
if (!isInsideJSX(node)) {
|
|
1537
1542
|
return false;
|
|
1538
1543
|
}
|
|
1539
|
-
if (node.parent.type ===
|
|
1544
|
+
if (node.parent.type === import_utils21.AST_NODE_TYPES.CallExpression || node.parent.type === import_utils21.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1540
1545
|
return true;
|
|
1541
1546
|
}
|
|
1542
|
-
if (node.parent.type ===
|
|
1543
|
-
if (node.parent.parent.type ===
|
|
1547
|
+
if (node.parent.type === import_utils21.AST_NODE_TYPES.ArrayExpression && node.parent.parent) {
|
|
1548
|
+
if (node.parent.parent.type === import_utils21.AST_NODE_TYPES.CallExpression || node.parent.parent.type === import_utils21.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1544
1549
|
return true;
|
|
1545
1550
|
}
|
|
1546
1551
|
}
|
|
@@ -1551,11 +1556,11 @@ var jsxNoVariableInCallback = createRule18({
|
|
|
1551
1556
|
return;
|
|
1552
1557
|
}
|
|
1553
1558
|
const { body } = node;
|
|
1554
|
-
if (body.type !==
|
|
1559
|
+
if (body.type !== import_utils21.AST_NODE_TYPES.BlockStatement) {
|
|
1555
1560
|
return;
|
|
1556
1561
|
}
|
|
1557
1562
|
body.body.forEach((statement) => {
|
|
1558
|
-
if (statement.type ===
|
|
1563
|
+
if (statement.type === import_utils21.AST_NODE_TYPES.VariableDeclaration) {
|
|
1559
1564
|
context.report({
|
|
1560
1565
|
node: statement,
|
|
1561
1566
|
messageId: "noVariableInCallback"
|
|
@@ -1573,8 +1578,8 @@ var jsx_no_variable_in_callback_default = jsxNoVariableInCallback;
|
|
|
1573
1578
|
|
|
1574
1579
|
// src/rules/jsx-pascal-case.ts
|
|
1575
1580
|
var import_path4 = __toESM(require("path"), 1);
|
|
1576
|
-
var
|
|
1577
|
-
var createRule19 =
|
|
1581
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
1582
|
+
var createRule19 = import_utils22.ESLintUtils.RuleCreator(
|
|
1578
1583
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1579
1584
|
);
|
|
1580
1585
|
var isPascalCase = (str) => /^[A-Z][a-zA-Z0-9]*$/.test(str) && !/^[A-Z]+$/.test(str);
|
|
@@ -1613,8 +1618,8 @@ var jsxPascalCase = createRule19({
|
|
|
1613
1618
|
var jsx_pascal_case_default = jsxPascalCase;
|
|
1614
1619
|
|
|
1615
1620
|
// src/rules/jsx-require-suspense.ts
|
|
1616
|
-
var
|
|
1617
|
-
var createRule20 =
|
|
1621
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
1622
|
+
var createRule20 = import_utils23.ESLintUtils.RuleCreator(
|
|
1618
1623
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1619
1624
|
);
|
|
1620
1625
|
var jsxRequireSuspense = createRule20({
|
|
@@ -1635,7 +1640,7 @@ var jsxRequireSuspense = createRule20({
|
|
|
1635
1640
|
const isInsideSuspense = (node) => {
|
|
1636
1641
|
let current = node.parent;
|
|
1637
1642
|
while (current) {
|
|
1638
|
-
if (current.type ===
|
|
1643
|
+
if (current.type === import_utils23.AST_NODE_TYPES.JSXElement && current.openingElement.name.type === import_utils23.AST_NODE_TYPES.JSXIdentifier && current.openingElement.name.name === "Suspense") {
|
|
1639
1644
|
return true;
|
|
1640
1645
|
}
|
|
1641
1646
|
current = current.parent;
|
|
@@ -1644,16 +1649,16 @@ var jsxRequireSuspense = createRule20({
|
|
|
1644
1649
|
};
|
|
1645
1650
|
return {
|
|
1646
1651
|
VariableDeclarator(node) {
|
|
1647
|
-
if (node.id.type ===
|
|
1652
|
+
if (node.id.type === import_utils23.AST_NODE_TYPES.Identifier && node.init?.type === import_utils23.AST_NODE_TYPES.CallExpression) {
|
|
1648
1653
|
const { callee } = node.init;
|
|
1649
|
-
const isLazyCall = callee.type ===
|
|
1654
|
+
const isLazyCall = callee.type === import_utils23.AST_NODE_TYPES.Identifier && callee.name === "lazy" || callee.type === import_utils23.AST_NODE_TYPES.MemberExpression && callee.object.type === import_utils23.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === import_utils23.AST_NODE_TYPES.Identifier && callee.property.name === "lazy";
|
|
1650
1655
|
if (isLazyCall) {
|
|
1651
1656
|
lazyComponents.add(node.id.name);
|
|
1652
1657
|
}
|
|
1653
1658
|
}
|
|
1654
1659
|
},
|
|
1655
1660
|
JSXOpeningElement(node) {
|
|
1656
|
-
if (node.name.type ===
|
|
1661
|
+
if (node.name.type === import_utils23.AST_NODE_TYPES.JSXIdentifier) {
|
|
1657
1662
|
const componentName = node.name.name;
|
|
1658
1663
|
if (lazyComponents.has(componentName) && !isInsideSuspense(node)) {
|
|
1659
1664
|
context.report({
|
|
@@ -1672,8 +1677,8 @@ var jsxRequireSuspense = createRule20({
|
|
|
1672
1677
|
var jsx_require_suspense_default = jsxRequireSuspense;
|
|
1673
1678
|
|
|
1674
1679
|
// src/rules/jsx-simple-props.ts
|
|
1675
|
-
var
|
|
1676
|
-
var createRule21 =
|
|
1680
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
1681
|
+
var createRule21 = import_utils24.ESLintUtils.RuleCreator(
|
|
1677
1682
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1678
1683
|
);
|
|
1679
1684
|
var jsxSimpleProps = createRule21({
|
|
@@ -1691,25 +1696,25 @@ var jsxSimpleProps = createRule21({
|
|
|
1691
1696
|
defaultOptions: [],
|
|
1692
1697
|
create(context) {
|
|
1693
1698
|
const allowedExpressionTypes = /* @__PURE__ */ new Set([
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1699
|
+
import_utils24.AST_NODE_TYPES.Identifier,
|
|
1700
|
+
import_utils24.AST_NODE_TYPES.Literal,
|
|
1701
|
+
import_utils24.AST_NODE_TYPES.JSXElement,
|
|
1702
|
+
import_utils24.AST_NODE_TYPES.JSXFragment,
|
|
1703
|
+
import_utils24.AST_NODE_TYPES.MemberExpression,
|
|
1704
|
+
import_utils24.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
1705
|
+
import_utils24.AST_NODE_TYPES.FunctionExpression
|
|
1701
1706
|
]);
|
|
1702
1707
|
return {
|
|
1703
1708
|
JSXAttribute(node) {
|
|
1704
1709
|
if (!node.value) {
|
|
1705
1710
|
return;
|
|
1706
1711
|
}
|
|
1707
|
-
if (node.value.type ===
|
|
1712
|
+
if (node.value.type === import_utils24.AST_NODE_TYPES.Literal) {
|
|
1708
1713
|
return;
|
|
1709
1714
|
}
|
|
1710
|
-
if (node.value.type ===
|
|
1715
|
+
if (node.value.type === import_utils24.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1711
1716
|
const { expression } = node.value;
|
|
1712
|
-
if (expression.type ===
|
|
1717
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1713
1718
|
return;
|
|
1714
1719
|
}
|
|
1715
1720
|
if (!allowedExpressionTypes.has(expression.type)) {
|
|
@@ -1726,8 +1731,8 @@ var jsxSimpleProps = createRule21({
|
|
|
1726
1731
|
var jsx_simple_props_default = jsxSimpleProps;
|
|
1727
1732
|
|
|
1728
1733
|
// src/rules/jsx-sort-props.ts
|
|
1729
|
-
var
|
|
1730
|
-
var createRule22 =
|
|
1734
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
1735
|
+
var createRule22 = import_utils25.ESLintUtils.RuleCreator(
|
|
1731
1736
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1732
1737
|
);
|
|
1733
1738
|
var TYPE_GROUP = {
|
|
@@ -1741,15 +1746,15 @@ var TYPE_GROUP = {
|
|
|
1741
1746
|
SHORTHAND: 8
|
|
1742
1747
|
};
|
|
1743
1748
|
var EXPRESSION_TYPE_TO_GROUP = /* @__PURE__ */ new Map([
|
|
1744
|
-
[
|
|
1745
|
-
[
|
|
1746
|
-
[
|
|
1747
|
-
[
|
|
1748
|
-
[
|
|
1749
|
-
[
|
|
1749
|
+
[import_utils25.AST_NODE_TYPES.ObjectExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1750
|
+
[import_utils25.AST_NODE_TYPES.ArrayExpression, TYPE_GROUP.OBJECT_ARRAY],
|
|
1751
|
+
[import_utils25.AST_NODE_TYPES.ArrowFunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1752
|
+
[import_utils25.AST_NODE_TYPES.FunctionExpression, TYPE_GROUP.FUNCTION],
|
|
1753
|
+
[import_utils25.AST_NODE_TYPES.JSXElement, TYPE_GROUP.JSX],
|
|
1754
|
+
[import_utils25.AST_NODE_TYPES.JSXFragment, TYPE_GROUP.JSX]
|
|
1750
1755
|
]);
|
|
1751
1756
|
function isHyphenatedName(node) {
|
|
1752
|
-
return node.name.type ===
|
|
1757
|
+
return node.name.type === import_utils25.AST_NODE_TYPES.JSXIdentifier && node.name.name.includes("-");
|
|
1753
1758
|
}
|
|
1754
1759
|
function getStringGroup(node) {
|
|
1755
1760
|
return isHyphenatedName(node) ? TYPE_GROUP.HYPHENATED_STRING : TYPE_GROUP.STRING;
|
|
@@ -1761,13 +1766,13 @@ function getLiteralValueGroup(value) {
|
|
|
1761
1766
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1762
1767
|
}
|
|
1763
1768
|
function getExpressionGroup(expression) {
|
|
1764
|
-
if (expression.type ===
|
|
1769
|
+
if (expression.type === import_utils25.AST_NODE_TYPES.Literal) {
|
|
1765
1770
|
return getLiteralValueGroup(expression.value);
|
|
1766
1771
|
}
|
|
1767
|
-
if (expression.type ===
|
|
1772
|
+
if (expression.type === import_utils25.AST_NODE_TYPES.TemplateLiteral) {
|
|
1768
1773
|
return null;
|
|
1769
1774
|
}
|
|
1770
|
-
if (expression.type ===
|
|
1775
|
+
if (expression.type === import_utils25.AST_NODE_TYPES.Identifier && expression.name === "undefined") {
|
|
1771
1776
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1772
1777
|
}
|
|
1773
1778
|
return EXPRESSION_TYPE_TO_GROUP.get(expression.type) ?? TYPE_GROUP.EXPRESSION;
|
|
@@ -1776,17 +1781,17 @@ function getTypeGroup(node) {
|
|
|
1776
1781
|
if (node.value === null) {
|
|
1777
1782
|
return TYPE_GROUP.SHORTHAND;
|
|
1778
1783
|
}
|
|
1779
|
-
if (node.value.type ===
|
|
1784
|
+
if (node.value.type === import_utils25.AST_NODE_TYPES.Literal) {
|
|
1780
1785
|
if (typeof node.value.value === "string") {
|
|
1781
1786
|
return getStringGroup(node);
|
|
1782
1787
|
}
|
|
1783
1788
|
return TYPE_GROUP.NUMBER_BOOLEAN_NULL;
|
|
1784
1789
|
}
|
|
1785
|
-
if (node.value.type !==
|
|
1790
|
+
if (node.value.type !== import_utils25.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
1786
1791
|
return null;
|
|
1787
1792
|
}
|
|
1788
1793
|
const { expression } = node.value;
|
|
1789
|
-
if (expression.type ===
|
|
1794
|
+
if (expression.type === import_utils25.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
1790
1795
|
return null;
|
|
1791
1796
|
}
|
|
1792
1797
|
const group = getExpressionGroup(expression);
|
|
@@ -1798,7 +1803,7 @@ function getTypeGroup(node) {
|
|
|
1798
1803
|
function hasUnsortedProps(attributes) {
|
|
1799
1804
|
let lastGroup = 0;
|
|
1800
1805
|
return attributes.some((attribute) => {
|
|
1801
|
-
if (attribute.type ===
|
|
1806
|
+
if (attribute.type === import_utils25.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1802
1807
|
lastGroup = 0;
|
|
1803
1808
|
return false;
|
|
1804
1809
|
}
|
|
@@ -1822,7 +1827,7 @@ function getSegments(attributes) {
|
|
|
1822
1827
|
const result = [];
|
|
1823
1828
|
let current = [];
|
|
1824
1829
|
attributes.forEach((attr) => {
|
|
1825
|
-
if (attr.type ===
|
|
1830
|
+
if (attr.type === import_utils25.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1826
1831
|
if (current.length > 0) {
|
|
1827
1832
|
result.push(current);
|
|
1828
1833
|
current = [];
|
|
@@ -1871,8 +1876,8 @@ var jsxSortProps = createRule22({
|
|
|
1871
1876
|
var jsx_sort_props_default = jsxSortProps;
|
|
1872
1877
|
|
|
1873
1878
|
// src/rules/jsx-spread-props-last.ts
|
|
1874
|
-
var
|
|
1875
|
-
var createRule23 =
|
|
1879
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
1880
|
+
var createRule23 = import_utils26.ESLintUtils.RuleCreator(
|
|
1876
1881
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1877
1882
|
);
|
|
1878
1883
|
var jsxSpreadPropsLast = createRule23({
|
|
@@ -1894,12 +1899,12 @@ var jsxSpreadPropsLast = createRule23({
|
|
|
1894
1899
|
const { attributes } = node;
|
|
1895
1900
|
let lastNonSpreadIndex = -1;
|
|
1896
1901
|
attributes.forEach((attribute, index) => {
|
|
1897
|
-
if (attribute.type !==
|
|
1902
|
+
if (attribute.type !== import_utils26.AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
1898
1903
|
lastNonSpreadIndex = index;
|
|
1899
1904
|
}
|
|
1900
1905
|
});
|
|
1901
1906
|
attributes.forEach((attribute, index) => {
|
|
1902
|
-
if (attribute.type ===
|
|
1907
|
+
if (attribute.type === import_utils26.AST_NODE_TYPES.JSXSpreadAttribute && index < lastNonSpreadIndex) {
|
|
1903
1908
|
context.report({
|
|
1904
1909
|
node: attribute,
|
|
1905
1910
|
messageId: "spreadNotLast"
|
|
@@ -1913,12 +1918,12 @@ var jsxSpreadPropsLast = createRule23({
|
|
|
1913
1918
|
var jsx_spread_props_last_default = jsxSpreadPropsLast;
|
|
1914
1919
|
|
|
1915
1920
|
// src/rules/newline-after-multiline-block.ts
|
|
1916
|
-
var
|
|
1917
|
-
var createRule24 =
|
|
1921
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
1922
|
+
var createRule24 = import_utils27.ESLintUtils.RuleCreator(
|
|
1918
1923
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1919
1924
|
);
|
|
1920
1925
|
function isImportDeclaration(node) {
|
|
1921
|
-
return node.type ===
|
|
1926
|
+
return node.type === import_utils27.AST_NODE_TYPES.ImportDeclaration;
|
|
1922
1927
|
}
|
|
1923
1928
|
function checkStatements(statements, context) {
|
|
1924
1929
|
const { sourceCode } = context;
|
|
@@ -1981,8 +1986,8 @@ var newlineAfterMultilineBlock = createRule24({
|
|
|
1981
1986
|
var newline_after_multiline_block_default = newlineAfterMultilineBlock;
|
|
1982
1987
|
|
|
1983
1988
|
// src/rules/newline-before-return.ts
|
|
1984
|
-
var
|
|
1985
|
-
var createRule25 =
|
|
1989
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
1990
|
+
var createRule25 = import_utils28.ESLintUtils.RuleCreator(
|
|
1986
1991
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
1987
1992
|
);
|
|
1988
1993
|
var newlineBeforeReturn = createRule25({
|
|
@@ -2003,7 +2008,7 @@ var newlineBeforeReturn = createRule25({
|
|
|
2003
2008
|
const { sourceCode } = context;
|
|
2004
2009
|
function checkReturnStatement(node) {
|
|
2005
2010
|
const { parent } = node;
|
|
2006
|
-
if (!parent || parent.type !==
|
|
2011
|
+
if (!parent || parent.type !== import_utils28.AST_NODE_TYPES.BlockStatement) {
|
|
2007
2012
|
return;
|
|
2008
2013
|
}
|
|
2009
2014
|
const { body: statements } = parent;
|
|
@@ -2040,8 +2045,8 @@ var newlineBeforeReturn = createRule25({
|
|
|
2040
2045
|
var newline_before_return_default = newlineBeforeReturn;
|
|
2041
2046
|
|
|
2042
2047
|
// src/rules/nextjs-require-public-env.ts
|
|
2043
|
-
var
|
|
2044
|
-
var createRule26 =
|
|
2048
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
2049
|
+
var createRule26 = import_utils29.ESLintUtils.RuleCreator(
|
|
2045
2050
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2046
2051
|
);
|
|
2047
2052
|
var nextjsRequirePublicEnv = createRule26({
|
|
@@ -2062,7 +2067,7 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2062
2067
|
return {
|
|
2063
2068
|
Program(node) {
|
|
2064
2069
|
const firstStatement = node.body[0];
|
|
2065
|
-
if (firstStatement?.type ===
|
|
2070
|
+
if (firstStatement?.type === import_utils29.AST_NODE_TYPES.ExpressionStatement && firstStatement.expression.type === import_utils29.AST_NODE_TYPES.Literal && firstStatement.expression.value === "use client") {
|
|
2066
2071
|
isClientComponent = true;
|
|
2067
2072
|
}
|
|
2068
2073
|
},
|
|
@@ -2070,7 +2075,7 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2070
2075
|
if (!isClientComponent) {
|
|
2071
2076
|
return;
|
|
2072
2077
|
}
|
|
2073
|
-
if (node.object.type ===
|
|
2078
|
+
if (node.object.type === import_utils29.AST_NODE_TYPES.MemberExpression && node.object.object.type === import_utils29.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === import_utils29.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === import_utils29.AST_NODE_TYPES.Identifier) {
|
|
2074
2079
|
const envVarName = node.property.name;
|
|
2075
2080
|
if (!envVarName.startsWith("NEXT_PUBLIC_") && envVarName !== "NODE_ENV") {
|
|
2076
2081
|
context.report({
|
|
@@ -2089,8 +2094,8 @@ var nextjsRequirePublicEnv = createRule26({
|
|
|
2089
2094
|
var nextjs_require_public_env_default = nextjsRequirePublicEnv;
|
|
2090
2095
|
|
|
2091
2096
|
// src/rules/no-complex-inline-return.ts
|
|
2092
|
-
var
|
|
2093
|
-
var createRule27 =
|
|
2097
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
2098
|
+
var createRule27 = import_utils30.ESLintUtils.RuleCreator(
|
|
2094
2099
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2095
2100
|
);
|
|
2096
2101
|
var noComplexInlineReturn = createRule27({
|
|
@@ -2109,13 +2114,13 @@ var noComplexInlineReturn = createRule27({
|
|
|
2109
2114
|
create(context) {
|
|
2110
2115
|
const isComplexExpression = (node) => {
|
|
2111
2116
|
if (!node) return false;
|
|
2112
|
-
if (node.type ===
|
|
2117
|
+
if (node.type === import_utils30.AST_NODE_TYPES.ConditionalExpression) {
|
|
2113
2118
|
return true;
|
|
2114
2119
|
}
|
|
2115
|
-
if (node.type ===
|
|
2120
|
+
if (node.type === import_utils30.AST_NODE_TYPES.LogicalExpression) {
|
|
2116
2121
|
return true;
|
|
2117
2122
|
}
|
|
2118
|
-
if (node.type ===
|
|
2123
|
+
if (node.type === import_utils30.AST_NODE_TYPES.NewExpression) {
|
|
2119
2124
|
return true;
|
|
2120
2125
|
}
|
|
2121
2126
|
return false;
|
|
@@ -2135,8 +2140,8 @@ var noComplexInlineReturn = createRule27({
|
|
|
2135
2140
|
var no_complex_inline_return_default = noComplexInlineReturn;
|
|
2136
2141
|
|
|
2137
2142
|
// src/rules/no-direct-date.ts
|
|
2138
|
-
var
|
|
2139
|
-
var createRule28 =
|
|
2143
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
2144
|
+
var createRule28 = import_utils31.ESLintUtils.RuleCreator(
|
|
2140
2145
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2141
2146
|
);
|
|
2142
2147
|
var noDirectDate = createRule28({
|
|
@@ -2157,7 +2162,7 @@ var noDirectDate = createRule28({
|
|
|
2157
2162
|
create(context) {
|
|
2158
2163
|
return {
|
|
2159
2164
|
NewExpression(node) {
|
|
2160
|
-
if (node.callee.type ===
|
|
2165
|
+
if (node.callee.type === import_utils31.AST_NODE_TYPES.Identifier && node.callee.name === "Date") {
|
|
2161
2166
|
context.report({
|
|
2162
2167
|
node,
|
|
2163
2168
|
messageId: "noNewDate"
|
|
@@ -2165,7 +2170,7 @@ var noDirectDate = createRule28({
|
|
|
2165
2170
|
}
|
|
2166
2171
|
},
|
|
2167
2172
|
CallExpression(node) {
|
|
2168
|
-
if (node.callee.type ===
|
|
2173
|
+
if (node.callee.type === import_utils31.AST_NODE_TYPES.MemberExpression && node.callee.object.type === import_utils31.AST_NODE_TYPES.Identifier && node.callee.object.name === "Date" && node.callee.property.type === import_utils31.AST_NODE_TYPES.Identifier) {
|
|
2169
2174
|
const methodName = node.callee.property.name;
|
|
2170
2175
|
if (methodName === "now") {
|
|
2171
2176
|
context.report({
|
|
@@ -2188,8 +2193,8 @@ var no_direct_date_default = noDirectDate;
|
|
|
2188
2193
|
|
|
2189
2194
|
// src/rules/no-emoji.ts
|
|
2190
2195
|
var import_emoji_regex = __toESM(require("emoji-regex"), 1);
|
|
2191
|
-
var
|
|
2192
|
-
var createRule29 =
|
|
2196
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
2197
|
+
var createRule29 = import_utils32.ESLintUtils.RuleCreator(
|
|
2193
2198
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2194
2199
|
);
|
|
2195
2200
|
var noEmoji = createRule29({
|
|
@@ -2226,8 +2231,8 @@ var noEmoji = createRule29({
|
|
|
2226
2231
|
var no_emoji_default = noEmoji;
|
|
2227
2232
|
|
|
2228
2233
|
// src/rules/no-env-fallback.ts
|
|
2229
|
-
var
|
|
2230
|
-
var createRule30 =
|
|
2234
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
2235
|
+
var createRule30 = import_utils33.ESLintUtils.RuleCreator(
|
|
2231
2236
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2232
2237
|
);
|
|
2233
2238
|
var noEnvFallback = createRule30({
|
|
@@ -2245,16 +2250,16 @@ var noEnvFallback = createRule30({
|
|
|
2245
2250
|
defaultOptions: [],
|
|
2246
2251
|
create(context) {
|
|
2247
2252
|
const isProcessEnvAccess = (node) => {
|
|
2248
|
-
if (node.type !==
|
|
2253
|
+
if (node.type !== import_utils33.AST_NODE_TYPES.MemberExpression) {
|
|
2249
2254
|
return false;
|
|
2250
2255
|
}
|
|
2251
2256
|
const { object } = node;
|
|
2252
|
-
if (object.type !==
|
|
2257
|
+
if (object.type !== import_utils33.AST_NODE_TYPES.MemberExpression) {
|
|
2253
2258
|
return false;
|
|
2254
2259
|
}
|
|
2255
2260
|
const processNode = object.object;
|
|
2256
2261
|
const envNode = object.property;
|
|
2257
|
-
return processNode.type ===
|
|
2262
|
+
return processNode.type === import_utils33.AST_NODE_TYPES.Identifier && processNode.name === "process" && envNode.type === import_utils33.AST_NODE_TYPES.Identifier && envNode.name === "env";
|
|
2258
2263
|
};
|
|
2259
2264
|
return {
|
|
2260
2265
|
LogicalExpression(node) {
|
|
@@ -2279,8 +2284,8 @@ var noEnvFallback = createRule30({
|
|
|
2279
2284
|
var no_env_fallback_default = noEnvFallback;
|
|
2280
2285
|
|
|
2281
2286
|
// src/rules/no-inline-default-export.ts
|
|
2282
|
-
var
|
|
2283
|
-
var createRule31 =
|
|
2287
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
2288
|
+
var createRule31 = import_utils34.ESLintUtils.RuleCreator(
|
|
2284
2289
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2285
2290
|
);
|
|
2286
2291
|
var noInlineDefaultExport = createRule31({
|
|
@@ -2302,7 +2307,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2302
2307
|
return {
|
|
2303
2308
|
ExportDefaultDeclaration(node) {
|
|
2304
2309
|
const { declaration } = node;
|
|
2305
|
-
if (declaration.type ===
|
|
2310
|
+
if (declaration.type === import_utils34.AST_NODE_TYPES.FunctionDeclaration) {
|
|
2306
2311
|
if (declaration.id) {
|
|
2307
2312
|
context.report({
|
|
2308
2313
|
node,
|
|
@@ -2317,7 +2322,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2317
2322
|
});
|
|
2318
2323
|
}
|
|
2319
2324
|
}
|
|
2320
|
-
if (declaration.type ===
|
|
2325
|
+
if (declaration.type === import_utils34.AST_NODE_TYPES.ClassDeclaration) {
|
|
2321
2326
|
if (declaration.id) {
|
|
2322
2327
|
context.report({
|
|
2323
2328
|
node,
|
|
@@ -2332,7 +2337,7 @@ var noInlineDefaultExport = createRule31({
|
|
|
2332
2337
|
});
|
|
2333
2338
|
}
|
|
2334
2339
|
}
|
|
2335
|
-
if (declaration.type ===
|
|
2340
|
+
if (declaration.type === import_utils34.AST_NODE_TYPES.ArrowFunctionExpression || declaration.type === import_utils34.AST_NODE_TYPES.FunctionExpression) {
|
|
2336
2341
|
context.report({
|
|
2337
2342
|
node,
|
|
2338
2343
|
messageId: "noAnonymousDefaultExport",
|
|
@@ -2345,14 +2350,14 @@ var noInlineDefaultExport = createRule31({
|
|
|
2345
2350
|
if (!declaration) {
|
|
2346
2351
|
return;
|
|
2347
2352
|
}
|
|
2348
|
-
if (declaration.type ===
|
|
2353
|
+
if (declaration.type === import_utils34.AST_NODE_TYPES.FunctionDeclaration && declaration.id) {
|
|
2349
2354
|
context.report({
|
|
2350
2355
|
node,
|
|
2351
2356
|
messageId: "noInlineNamedExport",
|
|
2352
2357
|
data: { type: "function", name: declaration.id.name }
|
|
2353
2358
|
});
|
|
2354
2359
|
}
|
|
2355
|
-
if (declaration.type ===
|
|
2360
|
+
if (declaration.type === import_utils34.AST_NODE_TYPES.ClassDeclaration && declaration.id) {
|
|
2356
2361
|
context.report({
|
|
2357
2362
|
node,
|
|
2358
2363
|
messageId: "noInlineNamedExport",
|
|
@@ -2366,15 +2371,15 @@ var noInlineDefaultExport = createRule31({
|
|
|
2366
2371
|
var no_inline_default_export_default = noInlineDefaultExport;
|
|
2367
2372
|
|
|
2368
2373
|
// src/rules/no-inline-nested-object.ts
|
|
2369
|
-
var
|
|
2370
|
-
var createRule32 =
|
|
2374
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
2375
|
+
var createRule32 = import_utils35.ESLintUtils.RuleCreator(
|
|
2371
2376
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2372
2377
|
);
|
|
2373
2378
|
function isObjectOrArray(node) {
|
|
2374
|
-
return node.type ===
|
|
2379
|
+
return node.type === import_utils35.AST_NODE_TYPES.ObjectExpression || node.type === import_utils35.AST_NODE_TYPES.ArrayExpression || node.type === import_utils35.AST_NODE_TYPES.TSAsExpression;
|
|
2375
2380
|
}
|
|
2376
2381
|
function getInnerExpression(node) {
|
|
2377
|
-
if (node.type ===
|
|
2382
|
+
if (node.type === import_utils35.AST_NODE_TYPES.TSAsExpression) {
|
|
2378
2383
|
return getInnerExpression(node.expression);
|
|
2379
2384
|
}
|
|
2380
2385
|
return node;
|
|
@@ -2383,7 +2388,7 @@ function arrayContainsOnlyPrimitives(node) {
|
|
|
2383
2388
|
return node.elements.every((el) => {
|
|
2384
2389
|
if (el === null) return true;
|
|
2385
2390
|
const inner = getInnerExpression(el);
|
|
2386
|
-
return inner.type ===
|
|
2391
|
+
return inner.type === import_utils35.AST_NODE_TYPES.Literal || inner.type === import_utils35.AST_NODE_TYPES.Identifier || inner.type === import_utils35.AST_NODE_TYPES.TemplateLiteral || inner.type === import_utils35.AST_NODE_TYPES.UnaryExpression;
|
|
2387
2392
|
});
|
|
2388
2393
|
}
|
|
2389
2394
|
var noInlineNestedObject = createRule32({
|
|
@@ -2408,17 +2413,17 @@ var noInlineNestedObject = createRule32({
|
|
|
2408
2413
|
return;
|
|
2409
2414
|
}
|
|
2410
2415
|
const valueNode = getInnerExpression(node.value);
|
|
2411
|
-
if (valueNode.type !==
|
|
2416
|
+
if (valueNode.type !== import_utils35.AST_NODE_TYPES.ObjectExpression && valueNode.type !== import_utils35.AST_NODE_TYPES.ArrayExpression) {
|
|
2412
2417
|
return;
|
|
2413
2418
|
}
|
|
2414
2419
|
if (!valueNode.loc) {
|
|
2415
2420
|
return;
|
|
2416
2421
|
}
|
|
2417
|
-
const elements = valueNode.type ===
|
|
2422
|
+
const elements = valueNode.type === import_utils35.AST_NODE_TYPES.ObjectExpression ? valueNode.properties : valueNode.elements;
|
|
2418
2423
|
if (elements.length <= 1) {
|
|
2419
2424
|
return;
|
|
2420
2425
|
}
|
|
2421
|
-
if (valueNode.type ===
|
|
2426
|
+
if (valueNode.type === import_utils35.AST_NODE_TYPES.ArrayExpression && arrayContainsOnlyPrimitives(valueNode)) {
|
|
2422
2427
|
return;
|
|
2423
2428
|
}
|
|
2424
2429
|
const isMultiline = valueNode.loc.start.line !== valueNode.loc.end.line;
|
|
@@ -2437,7 +2442,7 @@ var noInlineNestedObject = createRule32({
|
|
|
2437
2442
|
const indent = " ".repeat(node.loc?.start.column ?? 0);
|
|
2438
2443
|
const innerIndent = `${indent} `;
|
|
2439
2444
|
const elementTexts = elements.filter((el) => el !== null).map((el) => sourceCode.getText(el));
|
|
2440
|
-
const isObject = valueNode.type ===
|
|
2445
|
+
const isObject = valueNode.type === import_utils35.AST_NODE_TYPES.ObjectExpression;
|
|
2441
2446
|
const openChar = isObject ? "{" : "[";
|
|
2442
2447
|
const closeChar = isObject ? "}" : "]";
|
|
2443
2448
|
const formattedElements = elementTexts.map((text) => `${innerIndent}${text},`).join("\n");
|
|
@@ -2454,15 +2459,15 @@ ${indent}${closeChar}`;
|
|
|
2454
2459
|
var no_inline_nested_object_default = noInlineNestedObject;
|
|
2455
2460
|
|
|
2456
2461
|
// src/rules/no-inline-return-properties.ts
|
|
2457
|
-
var
|
|
2458
|
-
var createRule33 =
|
|
2462
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
2463
|
+
var createRule33 = import_utils36.ESLintUtils.RuleCreator(
|
|
2459
2464
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2460
2465
|
);
|
|
2461
2466
|
var isShorthandProperty = (property) => {
|
|
2462
|
-
if (property.type ===
|
|
2467
|
+
if (property.type === import_utils36.AST_NODE_TYPES.SpreadElement) {
|
|
2463
2468
|
return true;
|
|
2464
2469
|
}
|
|
2465
|
-
if (property.type !==
|
|
2470
|
+
if (property.type !== import_utils36.AST_NODE_TYPES.Property) {
|
|
2466
2471
|
return false;
|
|
2467
2472
|
}
|
|
2468
2473
|
return property.shorthand;
|
|
@@ -2483,20 +2488,20 @@ var noInlineReturnProperties = createRule33({
|
|
|
2483
2488
|
create(context) {
|
|
2484
2489
|
return {
|
|
2485
2490
|
ReturnStatement(node) {
|
|
2486
|
-
if (!node.argument || node.argument.type !==
|
|
2491
|
+
if (!node.argument || node.argument.type !== import_utils36.AST_NODE_TYPES.ObjectExpression) {
|
|
2487
2492
|
return;
|
|
2488
2493
|
}
|
|
2489
2494
|
node.argument.properties.forEach((property) => {
|
|
2490
2495
|
if (isShorthandProperty(property)) {
|
|
2491
2496
|
return;
|
|
2492
2497
|
}
|
|
2493
|
-
if (property.type !==
|
|
2498
|
+
if (property.type !== import_utils36.AST_NODE_TYPES.Property) {
|
|
2494
2499
|
return;
|
|
2495
2500
|
}
|
|
2496
2501
|
let keyName = null;
|
|
2497
|
-
if (property.key.type ===
|
|
2502
|
+
if (property.key.type === import_utils36.AST_NODE_TYPES.Identifier) {
|
|
2498
2503
|
keyName = property.key.name;
|
|
2499
|
-
} else if (property.key.type ===
|
|
2504
|
+
} else if (property.key.type === import_utils36.AST_NODE_TYPES.Literal) {
|
|
2500
2505
|
keyName = String(property.key.value);
|
|
2501
2506
|
}
|
|
2502
2507
|
context.report({
|
|
@@ -2512,8 +2517,8 @@ var noInlineReturnProperties = createRule33({
|
|
|
2512
2517
|
var no_inline_return_properties_default = noInlineReturnProperties;
|
|
2513
2518
|
|
|
2514
2519
|
// src/rules/no-lazy-identifiers.ts
|
|
2515
|
-
var
|
|
2516
|
-
var createRule34 =
|
|
2520
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
2521
|
+
var createRule34 = import_utils37.ESLintUtils.RuleCreator(
|
|
2517
2522
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2518
2523
|
);
|
|
2519
2524
|
var KEYBOARD_ROWS = ["qwertyuiop", "asdfghjkl", "zxcvbnm", "1234567890"];
|
|
@@ -2580,27 +2585,27 @@ var noLazyIdentifiers = createRule34({
|
|
|
2580
2585
|
});
|
|
2581
2586
|
};
|
|
2582
2587
|
const checkPattern = (pattern) => {
|
|
2583
|
-
if (pattern.type ===
|
|
2588
|
+
if (pattern.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2584
2589
|
checkIdentifier(pattern);
|
|
2585
|
-
} else if (pattern.type ===
|
|
2590
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.ObjectPattern) {
|
|
2586
2591
|
pattern.properties.forEach((prop) => {
|
|
2587
|
-
if (prop.type ===
|
|
2592
|
+
if (prop.type === import_utils37.AST_NODE_TYPES.Property && prop.value.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2588
2593
|
checkIdentifier(prop.value);
|
|
2589
|
-
} else if (prop.type ===
|
|
2594
|
+
} else if (prop.type === import_utils37.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2590
2595
|
checkIdentifier(prop.argument);
|
|
2591
2596
|
}
|
|
2592
2597
|
});
|
|
2593
|
-
} else if (pattern.type ===
|
|
2598
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.ArrayPattern) {
|
|
2594
2599
|
pattern.elements.forEach((element) => {
|
|
2595
|
-
if (element?.type ===
|
|
2600
|
+
if (element?.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2596
2601
|
checkIdentifier(element);
|
|
2597
|
-
} else if (element?.type ===
|
|
2602
|
+
} else if (element?.type === import_utils37.AST_NODE_TYPES.RestElement && element.argument.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2598
2603
|
checkIdentifier(element.argument);
|
|
2599
2604
|
}
|
|
2600
2605
|
});
|
|
2601
|
-
} else if (pattern.type ===
|
|
2606
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2602
2607
|
checkIdentifier(pattern.left);
|
|
2603
|
-
} else if (pattern.type ===
|
|
2608
|
+
} else if (pattern.type === import_utils37.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils37.AST_NODE_TYPES.Identifier) {
|
|
2604
2609
|
checkIdentifier(pattern.argument);
|
|
2605
2610
|
}
|
|
2606
2611
|
};
|
|
@@ -2645,8 +2650,8 @@ var noLazyIdentifiers = createRule34({
|
|
|
2645
2650
|
var no_lazy_identifiers_default = noLazyIdentifiers;
|
|
2646
2651
|
|
|
2647
2652
|
// src/rules/no-logic-in-params.ts
|
|
2648
|
-
var
|
|
2649
|
-
var createRule35 =
|
|
2653
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
2654
|
+
var createRule35 = import_utils38.ESLintUtils.RuleCreator(
|
|
2650
2655
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2651
2656
|
);
|
|
2652
2657
|
var noLogicInParams = createRule35({
|
|
@@ -2664,20 +2669,20 @@ var noLogicInParams = createRule35({
|
|
|
2664
2669
|
defaultOptions: [],
|
|
2665
2670
|
create(context) {
|
|
2666
2671
|
const isComplexExpression = (node) => {
|
|
2667
|
-
if (node.type ===
|
|
2672
|
+
if (node.type === import_utils38.AST_NODE_TYPES.SpreadElement) {
|
|
2668
2673
|
return false;
|
|
2669
2674
|
}
|
|
2670
|
-
if (node.type ===
|
|
2675
|
+
if (node.type === import_utils38.AST_NODE_TYPES.ConditionalExpression) {
|
|
2671
2676
|
return true;
|
|
2672
2677
|
}
|
|
2673
|
-
if (node.type ===
|
|
2678
|
+
if (node.type === import_utils38.AST_NODE_TYPES.LogicalExpression) {
|
|
2674
2679
|
return true;
|
|
2675
2680
|
}
|
|
2676
|
-
if (node.type ===
|
|
2681
|
+
if (node.type === import_utils38.AST_NODE_TYPES.BinaryExpression) {
|
|
2677
2682
|
const logicalOperators = ["==", "===", "!=", "!==", "<", ">", "<=", ">=", "in", "instanceof"];
|
|
2678
2683
|
return logicalOperators.includes(node.operator);
|
|
2679
2684
|
}
|
|
2680
|
-
if (node.type ===
|
|
2685
|
+
if (node.type === import_utils38.AST_NODE_TYPES.UnaryExpression) {
|
|
2681
2686
|
return node.operator === "!";
|
|
2682
2687
|
}
|
|
2683
2688
|
return false;
|
|
@@ -2690,7 +2695,7 @@ var noLogicInParams = createRule35({
|
|
|
2690
2695
|
messageId: "noLogicInParams"
|
|
2691
2696
|
});
|
|
2692
2697
|
}
|
|
2693
|
-
if (arg.type ===
|
|
2698
|
+
if (arg.type === import_utils38.AST_NODE_TYPES.ArrayExpression) {
|
|
2694
2699
|
arg.elements.forEach((element) => {
|
|
2695
2700
|
if (element && isComplexExpression(element)) {
|
|
2696
2701
|
context.report({
|
|
@@ -2715,41 +2720,41 @@ var noLogicInParams = createRule35({
|
|
|
2715
2720
|
var no_logic_in_params_default = noLogicInParams;
|
|
2716
2721
|
|
|
2717
2722
|
// src/rules/no-misleading-constant-case.ts
|
|
2718
|
-
var
|
|
2719
|
-
var createRule36 =
|
|
2723
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
2724
|
+
var createRule36 = import_utils39.ESLintUtils.RuleCreator(
|
|
2720
2725
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2721
2726
|
);
|
|
2722
2727
|
var SCREAMING_SNAKE_CASE_REGEX3 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
|
|
2723
|
-
var isAsConstAssertion2 = (node) => node.type ===
|
|
2728
|
+
var isAsConstAssertion2 = (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";
|
|
2724
2729
|
var isStaticValue3 = (init) => {
|
|
2725
2730
|
if (isAsConstAssertion2(init)) {
|
|
2726
2731
|
return true;
|
|
2727
2732
|
}
|
|
2728
|
-
if (init.type ===
|
|
2733
|
+
if (init.type === import_utils39.AST_NODE_TYPES.Literal) {
|
|
2729
2734
|
return true;
|
|
2730
2735
|
}
|
|
2731
|
-
if (init.type ===
|
|
2736
|
+
if (init.type === import_utils39.AST_NODE_TYPES.UnaryExpression && init.argument.type === import_utils39.AST_NODE_TYPES.Literal) {
|
|
2732
2737
|
return true;
|
|
2733
2738
|
}
|
|
2734
|
-
if (init.type ===
|
|
2739
|
+
if (init.type === import_utils39.AST_NODE_TYPES.TemplateLiteral && init.expressions.length === 0) {
|
|
2735
2740
|
return true;
|
|
2736
2741
|
}
|
|
2737
|
-
if (init.type ===
|
|
2738
|
-
return init.elements.every((el) => el !== null && el.type !==
|
|
2742
|
+
if (init.type === import_utils39.AST_NODE_TYPES.ArrayExpression) {
|
|
2743
|
+
return init.elements.every((el) => el !== null && el.type !== import_utils39.AST_NODE_TYPES.SpreadElement && isStaticValue3(el));
|
|
2739
2744
|
}
|
|
2740
|
-
if (init.type ===
|
|
2745
|
+
if (init.type === import_utils39.AST_NODE_TYPES.ObjectExpression) {
|
|
2741
2746
|
return init.properties.every(
|
|
2742
|
-
(prop) => prop.type ===
|
|
2747
|
+
(prop) => prop.type === import_utils39.AST_NODE_TYPES.Property && isStaticValue3(prop.value)
|
|
2743
2748
|
);
|
|
2744
2749
|
}
|
|
2745
2750
|
return false;
|
|
2746
2751
|
};
|
|
2747
2752
|
var isGlobalScope3 = (node) => {
|
|
2748
2753
|
const { parent } = node;
|
|
2749
|
-
if (parent.type ===
|
|
2754
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.Program) {
|
|
2750
2755
|
return true;
|
|
2751
2756
|
}
|
|
2752
|
-
if (parent.type ===
|
|
2757
|
+
if (parent.type === import_utils39.AST_NODE_TYPES.ExportNamedDeclaration && parent.parent?.type === import_utils39.AST_NODE_TYPES.Program) {
|
|
2753
2758
|
return true;
|
|
2754
2759
|
}
|
|
2755
2760
|
return false;
|
|
@@ -2773,7 +2778,7 @@ var noMisleadingConstantCase = createRule36({
|
|
|
2773
2778
|
return {
|
|
2774
2779
|
VariableDeclaration(node) {
|
|
2775
2780
|
node.declarations.forEach((declarator) => {
|
|
2776
|
-
if (declarator.id.type !==
|
|
2781
|
+
if (declarator.id.type !== import_utils39.AST_NODE_TYPES.Identifier) {
|
|
2777
2782
|
return;
|
|
2778
2783
|
}
|
|
2779
2784
|
const { name } = declarator.id;
|
|
@@ -2814,8 +2819,8 @@ var noMisleadingConstantCase = createRule36({
|
|
|
2814
2819
|
var no_misleading_constant_case_default = noMisleadingConstantCase;
|
|
2815
2820
|
|
|
2816
2821
|
// src/rules/no-nested-interface-declaration.ts
|
|
2817
|
-
var
|
|
2818
|
-
var createRule37 =
|
|
2822
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
2823
|
+
var createRule37 = import_utils40.ESLintUtils.RuleCreator(
|
|
2819
2824
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2820
2825
|
);
|
|
2821
2826
|
var noNestedInterfaceDeclaration = createRule37({
|
|
@@ -2839,15 +2844,15 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2839
2844
|
return;
|
|
2840
2845
|
}
|
|
2841
2846
|
const { typeAnnotation } = node.typeAnnotation;
|
|
2842
|
-
if (typeAnnotation.type ===
|
|
2847
|
+
if (typeAnnotation.type === import_utils40.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2843
2848
|
context.report({
|
|
2844
2849
|
node: typeAnnotation,
|
|
2845
2850
|
messageId: "noNestedInterface"
|
|
2846
2851
|
});
|
|
2847
2852
|
return;
|
|
2848
2853
|
}
|
|
2849
|
-
if (typeAnnotation.type ===
|
|
2850
|
-
if (typeAnnotation.elementType.type ===
|
|
2854
|
+
if (typeAnnotation.type === import_utils40.AST_NODE_TYPES.TSArrayType) {
|
|
2855
|
+
if (typeAnnotation.elementType.type === import_utils40.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2851
2856
|
context.report({
|
|
2852
2857
|
node: typeAnnotation.elementType,
|
|
2853
2858
|
messageId: "noNestedInterface"
|
|
@@ -2855,9 +2860,9 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2855
2860
|
}
|
|
2856
2861
|
return;
|
|
2857
2862
|
}
|
|
2858
|
-
if (typeAnnotation.type ===
|
|
2863
|
+
if (typeAnnotation.type === import_utils40.AST_NODE_TYPES.TSTypeReference && typeAnnotation.typeArguments) {
|
|
2859
2864
|
typeAnnotation.typeArguments.params.forEach((param) => {
|
|
2860
|
-
if (param.type ===
|
|
2865
|
+
if (param.type === import_utils40.AST_NODE_TYPES.TSTypeLiteral) {
|
|
2861
2866
|
context.report({
|
|
2862
2867
|
node: param,
|
|
2863
2868
|
messageId: "noNestedInterface"
|
|
@@ -2872,8 +2877,8 @@ var noNestedInterfaceDeclaration = createRule37({
|
|
|
2872
2877
|
var no_nested_interface_declaration_default = noNestedInterfaceDeclaration;
|
|
2873
2878
|
|
|
2874
2879
|
// src/rules/no-nested-ternary.ts
|
|
2875
|
-
var
|
|
2876
|
-
var createRule38 =
|
|
2880
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
2881
|
+
var createRule38 = import_utils41.ESLintUtils.RuleCreator(
|
|
2877
2882
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2878
2883
|
);
|
|
2879
2884
|
var noNestedTernary = createRule38({
|
|
@@ -2893,13 +2898,13 @@ var noNestedTernary = createRule38({
|
|
|
2893
2898
|
return {
|
|
2894
2899
|
ConditionalExpression(node) {
|
|
2895
2900
|
const { consequent, alternate } = node;
|
|
2896
|
-
if (consequent.type ===
|
|
2901
|
+
if (consequent.type === import_utils41.AST_NODE_TYPES.ConditionalExpression) {
|
|
2897
2902
|
context.report({
|
|
2898
2903
|
node: consequent,
|
|
2899
2904
|
messageId: "noNestedTernary"
|
|
2900
2905
|
});
|
|
2901
2906
|
}
|
|
2902
|
-
if (alternate.type ===
|
|
2907
|
+
if (alternate.type === import_utils41.AST_NODE_TYPES.ConditionalExpression) {
|
|
2903
2908
|
context.report({
|
|
2904
2909
|
node: alternate,
|
|
2905
2910
|
messageId: "noNestedTernary"
|
|
@@ -2912,8 +2917,8 @@ var noNestedTernary = createRule38({
|
|
|
2912
2917
|
var no_nested_ternary_default = noNestedTernary;
|
|
2913
2918
|
|
|
2914
2919
|
// src/rules/no-relative-imports.ts
|
|
2915
|
-
var
|
|
2916
|
-
var createRule39 =
|
|
2920
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
2921
|
+
var createRule39 = import_utils42.ESLintUtils.RuleCreator(
|
|
2917
2922
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2918
2923
|
);
|
|
2919
2924
|
var noRelativeImports = createRule39({
|
|
@@ -2940,22 +2945,22 @@ var noRelativeImports = createRule39({
|
|
|
2940
2945
|
};
|
|
2941
2946
|
return {
|
|
2942
2947
|
ImportDeclaration(node) {
|
|
2943
|
-
if (node.source.type ===
|
|
2948
|
+
if (node.source.type === import_utils42.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2944
2949
|
checkImportPath(node.source.value, node);
|
|
2945
2950
|
}
|
|
2946
2951
|
},
|
|
2947
2952
|
ImportExpression(node) {
|
|
2948
|
-
if (node.source.type ===
|
|
2953
|
+
if (node.source.type === import_utils42.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2949
2954
|
checkImportPath(node.source.value, node);
|
|
2950
2955
|
}
|
|
2951
2956
|
},
|
|
2952
2957
|
ExportNamedDeclaration(node) {
|
|
2953
|
-
if (node.source?.type ===
|
|
2958
|
+
if (node.source?.type === import_utils42.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2954
2959
|
checkImportPath(node.source.value, node);
|
|
2955
2960
|
}
|
|
2956
2961
|
},
|
|
2957
2962
|
ExportAllDeclaration(node) {
|
|
2958
|
-
if (node.source.type ===
|
|
2963
|
+
if (node.source.type === import_utils42.AST_NODE_TYPES.Literal && typeof node.source.value === "string") {
|
|
2959
2964
|
checkImportPath(node.source.value, node);
|
|
2960
2965
|
}
|
|
2961
2966
|
}
|
|
@@ -2965,8 +2970,8 @@ var noRelativeImports = createRule39({
|
|
|
2965
2970
|
var no_relative_imports_default = noRelativeImports;
|
|
2966
2971
|
|
|
2967
2972
|
// src/rules/no-single-char-variables.ts
|
|
2968
|
-
var
|
|
2969
|
-
var createRule40 =
|
|
2973
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
2974
|
+
var createRule40 = import_utils43.ESLintUtils.RuleCreator(
|
|
2970
2975
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
2971
2976
|
);
|
|
2972
2977
|
var ALLOWED_IN_FOR_LOOPS = /* @__PURE__ */ new Set(["i", "j", "k", "n"]);
|
|
@@ -2978,7 +2983,7 @@ var isForLoopInit = (node) => {
|
|
|
2978
2983
|
if (!parentNode) {
|
|
2979
2984
|
return false;
|
|
2980
2985
|
}
|
|
2981
|
-
if (parentNode.type ===
|
|
2986
|
+
if (parentNode.type === import_utils43.AST_NODE_TYPES.ForStatement) {
|
|
2982
2987
|
const { init } = parentNode;
|
|
2983
2988
|
if (init && init === current) {
|
|
2984
2989
|
return true;
|
|
@@ -3026,27 +3031,27 @@ var noSingleCharVariables = createRule40({
|
|
|
3026
3031
|
});
|
|
3027
3032
|
};
|
|
3028
3033
|
const checkPattern = (pattern, declarationNode) => {
|
|
3029
|
-
if (pattern.type ===
|
|
3034
|
+
if (pattern.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
3030
3035
|
checkIdentifier(pattern, declarationNode);
|
|
3031
|
-
} else if (pattern.type ===
|
|
3036
|
+
} else if (pattern.type === import_utils43.AST_NODE_TYPES.ObjectPattern) {
|
|
3032
3037
|
pattern.properties.forEach((prop) => {
|
|
3033
|
-
if (prop.type ===
|
|
3038
|
+
if (prop.type === import_utils43.AST_NODE_TYPES.Property && prop.value.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
3034
3039
|
checkIdentifier(prop.value, declarationNode);
|
|
3035
|
-
} else if (prop.type ===
|
|
3040
|
+
} else if (prop.type === import_utils43.AST_NODE_TYPES.RestElement && prop.argument.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
3036
3041
|
checkIdentifier(prop.argument, declarationNode);
|
|
3037
3042
|
}
|
|
3038
3043
|
});
|
|
3039
|
-
} else if (pattern.type ===
|
|
3044
|
+
} else if (pattern.type === import_utils43.AST_NODE_TYPES.ArrayPattern) {
|
|
3040
3045
|
pattern.elements.forEach((element) => {
|
|
3041
|
-
if (element?.type ===
|
|
3046
|
+
if (element?.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
3042
3047
|
checkIdentifier(element, declarationNode);
|
|
3043
|
-
} else if (element?.type ===
|
|
3048
|
+
} else if (element?.type === import_utils43.AST_NODE_TYPES.RestElement && element.argument.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
3044
3049
|
checkIdentifier(element.argument, declarationNode);
|
|
3045
3050
|
}
|
|
3046
3051
|
});
|
|
3047
|
-
} else if (pattern.type ===
|
|
3052
|
+
} else if (pattern.type === import_utils43.AST_NODE_TYPES.AssignmentPattern && pattern.left.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
3048
3053
|
checkIdentifier(pattern.left, declarationNode);
|
|
3049
|
-
} else if (pattern.type ===
|
|
3054
|
+
} else if (pattern.type === import_utils43.AST_NODE_TYPES.RestElement && pattern.argument.type === import_utils43.AST_NODE_TYPES.Identifier) {
|
|
3050
3055
|
checkIdentifier(pattern.argument, declarationNode);
|
|
3051
3056
|
}
|
|
3052
3057
|
};
|
|
@@ -3080,8 +3085,8 @@ var noSingleCharVariables = createRule40({
|
|
|
3080
3085
|
var no_single_char_variables_default = noSingleCharVariables;
|
|
3081
3086
|
|
|
3082
3087
|
// src/rules/prefer-async-await.ts
|
|
3083
|
-
var
|
|
3084
|
-
var createRule41 =
|
|
3088
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
3089
|
+
var createRule41 = import_utils44.ESLintUtils.RuleCreator(
|
|
3085
3090
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3086
3091
|
);
|
|
3087
3092
|
var preferAsyncAwait = createRule41({
|
|
@@ -3100,7 +3105,7 @@ var preferAsyncAwait = createRule41({
|
|
|
3100
3105
|
create(context) {
|
|
3101
3106
|
return {
|
|
3102
3107
|
CallExpression(node) {
|
|
3103
|
-
if (node.callee.type ===
|
|
3108
|
+
if (node.callee.type === import_utils44.AST_NODE_TYPES.MemberExpression && node.callee.property.type === import_utils44.AST_NODE_TYPES.Identifier && node.callee.property.name === "then") {
|
|
3104
3109
|
context.report({
|
|
3105
3110
|
node: node.callee.property,
|
|
3106
3111
|
messageId: "preferAsyncAwait"
|
|
@@ -3113,8 +3118,8 @@ var preferAsyncAwait = createRule41({
|
|
|
3113
3118
|
var prefer_async_await_default = preferAsyncAwait;
|
|
3114
3119
|
|
|
3115
3120
|
// src/rules/prefer-destructuring-params.ts
|
|
3116
|
-
var
|
|
3117
|
-
var createRule42 =
|
|
3121
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
3122
|
+
var createRule42 = import_utils45.ESLintUtils.RuleCreator(
|
|
3118
3123
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3119
3124
|
);
|
|
3120
3125
|
var preferDestructuringParams = createRule42({
|
|
@@ -3133,18 +3138,18 @@ var preferDestructuringParams = createRule42({
|
|
|
3133
3138
|
create(context) {
|
|
3134
3139
|
const isCallbackFunction2 = (node) => {
|
|
3135
3140
|
const { parent } = node;
|
|
3136
|
-
return parent?.type ===
|
|
3141
|
+
return parent?.type === import_utils45.AST_NODE_TYPES.CallExpression;
|
|
3137
3142
|
};
|
|
3138
3143
|
const isDeveloperFunction = (node) => {
|
|
3139
|
-
if (node.type ===
|
|
3144
|
+
if (node.type === import_utils45.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3140
3145
|
return true;
|
|
3141
3146
|
}
|
|
3142
|
-
if (node.type ===
|
|
3147
|
+
if (node.type === import_utils45.AST_NODE_TYPES.FunctionExpression || node.type === import_utils45.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3143
3148
|
if (isCallbackFunction2(node)) {
|
|
3144
3149
|
return false;
|
|
3145
3150
|
}
|
|
3146
3151
|
const { parent } = node;
|
|
3147
|
-
return parent?.type ===
|
|
3152
|
+
return parent?.type === import_utils45.AST_NODE_TYPES.VariableDeclarator || parent?.type === import_utils45.AST_NODE_TYPES.AssignmentExpression || parent?.type === import_utils45.AST_NODE_TYPES.Property || parent?.type === import_utils45.AST_NODE_TYPES.MethodDefinition;
|
|
3148
3153
|
}
|
|
3149
3154
|
return false;
|
|
3150
3155
|
};
|
|
@@ -3156,7 +3161,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3156
3161
|
if (!isDeveloperFunction(node)) {
|
|
3157
3162
|
return;
|
|
3158
3163
|
}
|
|
3159
|
-
if (node.type ===
|
|
3164
|
+
if (node.type === import_utils45.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
3160
3165
|
const functionName = node.id.name;
|
|
3161
3166
|
if (functionName.startsWith("_") || functionName.includes("$") || /^[A-Z][a-zA-Z]*$/.test(functionName)) {
|
|
3162
3167
|
return;
|
|
@@ -3166,7 +3171,7 @@ var preferDestructuringParams = createRule42({
|
|
|
3166
3171
|
return;
|
|
3167
3172
|
}
|
|
3168
3173
|
const hasNonDestructuredParams = node.params.some(
|
|
3169
|
-
(param) => param.type !==
|
|
3174
|
+
(param) => param.type !== import_utils45.AST_NODE_TYPES.ObjectPattern && param.type !== import_utils45.AST_NODE_TYPES.RestElement
|
|
3170
3175
|
);
|
|
3171
3176
|
if (hasNonDestructuredParams) {
|
|
3172
3177
|
context.report({
|
|
@@ -3185,8 +3190,8 @@ var preferDestructuringParams = createRule42({
|
|
|
3185
3190
|
var prefer_destructuring_params_default = preferDestructuringParams;
|
|
3186
3191
|
|
|
3187
3192
|
// src/rules/prefer-function-declaration.ts
|
|
3188
|
-
var
|
|
3189
|
-
var createRule43 =
|
|
3193
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
3194
|
+
var createRule43 = import_utils46.ESLintUtils.RuleCreator(
|
|
3190
3195
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3191
3196
|
);
|
|
3192
3197
|
var isTsFile = (filename) => filename.endsWith(".ts") && !filename.endsWith(".d.ts");
|
|
@@ -3195,28 +3200,28 @@ var isCallbackContext = (node) => {
|
|
|
3195
3200
|
if (!parent) {
|
|
3196
3201
|
return false;
|
|
3197
3202
|
}
|
|
3198
|
-
if (parent.type ===
|
|
3203
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
3199
3204
|
return true;
|
|
3200
3205
|
}
|
|
3201
|
-
if (parent.type ===
|
|
3206
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.NewExpression && parent.arguments.includes(node)) {
|
|
3202
3207
|
return true;
|
|
3203
3208
|
}
|
|
3204
|
-
if (parent.type ===
|
|
3209
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.ReturnStatement) {
|
|
3205
3210
|
return true;
|
|
3206
3211
|
}
|
|
3207
|
-
if (parent.type ===
|
|
3212
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.Property) {
|
|
3208
3213
|
return true;
|
|
3209
3214
|
}
|
|
3210
|
-
if (parent.type ===
|
|
3215
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
3211
3216
|
return true;
|
|
3212
3217
|
}
|
|
3213
|
-
if (parent.type ===
|
|
3218
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.ConditionalExpression) {
|
|
3214
3219
|
return true;
|
|
3215
3220
|
}
|
|
3216
|
-
if (parent.type ===
|
|
3221
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.LogicalExpression) {
|
|
3217
3222
|
return true;
|
|
3218
3223
|
}
|
|
3219
|
-
if (parent.type ===
|
|
3224
|
+
if (parent.type === import_utils46.AST_NODE_TYPES.AssignmentExpression && parent.left !== node) {
|
|
3220
3225
|
return true;
|
|
3221
3226
|
}
|
|
3222
3227
|
return false;
|
|
@@ -3242,14 +3247,14 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3242
3247
|
}
|
|
3243
3248
|
return {
|
|
3244
3249
|
VariableDeclarator(node) {
|
|
3245
|
-
if (node.id.type !==
|
|
3250
|
+
if (node.id.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
3246
3251
|
return;
|
|
3247
3252
|
}
|
|
3248
3253
|
const { init } = node;
|
|
3249
3254
|
if (!init) {
|
|
3250
3255
|
return;
|
|
3251
3256
|
}
|
|
3252
|
-
if (init.type ===
|
|
3257
|
+
if (init.type === import_utils46.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3253
3258
|
if (isCallbackContext(init)) {
|
|
3254
3259
|
return;
|
|
3255
3260
|
}
|
|
@@ -3259,7 +3264,7 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3259
3264
|
data: { name: node.id.name }
|
|
3260
3265
|
});
|
|
3261
3266
|
}
|
|
3262
|
-
if (init.type ===
|
|
3267
|
+
if (init.type === import_utils46.AST_NODE_TYPES.FunctionExpression) {
|
|
3263
3268
|
if (isCallbackContext(init)) {
|
|
3264
3269
|
return;
|
|
3265
3270
|
}
|
|
@@ -3276,8 +3281,8 @@ var preferFunctionDeclaration = createRule43({
|
|
|
3276
3281
|
var prefer_function_declaration_default = preferFunctionDeclaration;
|
|
3277
3282
|
|
|
3278
3283
|
// src/rules/prefer-guard-clause.ts
|
|
3279
|
-
var
|
|
3280
|
-
var createRule44 =
|
|
3284
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
3285
|
+
var createRule44 = import_utils47.ESLintUtils.RuleCreator(
|
|
3281
3286
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3282
3287
|
);
|
|
3283
3288
|
var preferGuardClause = createRule44({
|
|
@@ -3297,8 +3302,8 @@ var preferGuardClause = createRule44({
|
|
|
3297
3302
|
return {
|
|
3298
3303
|
IfStatement(node) {
|
|
3299
3304
|
const { consequent } = node;
|
|
3300
|
-
if (consequent.type ===
|
|
3301
|
-
const hasNestedIf = consequent.body.some((statement) => statement.type ===
|
|
3305
|
+
if (consequent.type === import_utils47.AST_NODE_TYPES.BlockStatement) {
|
|
3306
|
+
const hasNestedIf = consequent.body.some((statement) => statement.type === import_utils47.AST_NODE_TYPES.IfStatement);
|
|
3302
3307
|
if (hasNestedIf && consequent.body.length === 1) {
|
|
3303
3308
|
context.report({
|
|
3304
3309
|
node,
|
|
@@ -3306,7 +3311,7 @@ var preferGuardClause = createRule44({
|
|
|
3306
3311
|
});
|
|
3307
3312
|
}
|
|
3308
3313
|
}
|
|
3309
|
-
if (consequent.type ===
|
|
3314
|
+
if (consequent.type === import_utils47.AST_NODE_TYPES.IfStatement) {
|
|
3310
3315
|
context.report({
|
|
3311
3316
|
node,
|
|
3312
3317
|
messageId: "preferGuardClause"
|
|
@@ -3319,8 +3324,8 @@ var preferGuardClause = createRule44({
|
|
|
3319
3324
|
var prefer_guard_clause_default = preferGuardClause;
|
|
3320
3325
|
|
|
3321
3326
|
// src/rules/prefer-import-type.ts
|
|
3322
|
-
var
|
|
3323
|
-
var createRule45 =
|
|
3327
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
3328
|
+
var createRule45 = import_utils48.ESLintUtils.RuleCreator(
|
|
3324
3329
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3325
3330
|
);
|
|
3326
3331
|
var preferImportType = createRule45({
|
|
@@ -3342,22 +3347,22 @@ var preferImportType = createRule45({
|
|
|
3342
3347
|
let current = node;
|
|
3343
3348
|
while (current) {
|
|
3344
3349
|
switch (current.type) {
|
|
3345
|
-
case
|
|
3346
|
-
case
|
|
3347
|
-
case
|
|
3348
|
-
case
|
|
3349
|
-
case
|
|
3350
|
-
case
|
|
3351
|
-
case
|
|
3352
|
-
case
|
|
3353
|
-
case
|
|
3354
|
-
case
|
|
3355
|
-
case
|
|
3356
|
-
case
|
|
3357
|
-
case
|
|
3350
|
+
case import_utils48.AST_NODE_TYPES.TSTypeReference:
|
|
3351
|
+
case import_utils48.AST_NODE_TYPES.TSTypeAnnotation:
|
|
3352
|
+
case import_utils48.AST_NODE_TYPES.TSTypeParameterInstantiation:
|
|
3353
|
+
case import_utils48.AST_NODE_TYPES.TSInterfaceHeritage:
|
|
3354
|
+
case import_utils48.AST_NODE_TYPES.TSClassImplements:
|
|
3355
|
+
case import_utils48.AST_NODE_TYPES.TSTypeQuery:
|
|
3356
|
+
case import_utils48.AST_NODE_TYPES.TSTypeAssertion:
|
|
3357
|
+
case import_utils48.AST_NODE_TYPES.TSAsExpression:
|
|
3358
|
+
case import_utils48.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
3359
|
+
case import_utils48.AST_NODE_TYPES.TSTypeAliasDeclaration:
|
|
3360
|
+
case import_utils48.AST_NODE_TYPES.TSInterfaceDeclaration:
|
|
3361
|
+
case import_utils48.AST_NODE_TYPES.TSTypeParameter:
|
|
3362
|
+
case import_utils48.AST_NODE_TYPES.TSQualifiedName:
|
|
3358
3363
|
return true;
|
|
3359
|
-
case
|
|
3360
|
-
case
|
|
3364
|
+
case import_utils48.AST_NODE_TYPES.MemberExpression:
|
|
3365
|
+
case import_utils48.AST_NODE_TYPES.Identifier:
|
|
3361
3366
|
current = current.parent;
|
|
3362
3367
|
break;
|
|
3363
3368
|
default:
|
|
@@ -3387,27 +3392,27 @@ var preferImportType = createRule45({
|
|
|
3387
3392
|
return false;
|
|
3388
3393
|
}
|
|
3389
3394
|
switch (parent.type) {
|
|
3390
|
-
case
|
|
3391
|
-
case
|
|
3392
|
-
case
|
|
3393
|
-
case
|
|
3394
|
-
case
|
|
3395
|
-
case
|
|
3396
|
-
case
|
|
3397
|
-
case
|
|
3398
|
-
case
|
|
3399
|
-
case
|
|
3400
|
-
case
|
|
3401
|
-
case
|
|
3402
|
-
case
|
|
3403
|
-
case
|
|
3404
|
-
case
|
|
3405
|
-
case
|
|
3406
|
-
case
|
|
3407
|
-
case
|
|
3408
|
-
case
|
|
3409
|
-
case
|
|
3410
|
-
case
|
|
3395
|
+
case import_utils48.AST_NODE_TYPES.CallExpression:
|
|
3396
|
+
case import_utils48.AST_NODE_TYPES.NewExpression:
|
|
3397
|
+
case import_utils48.AST_NODE_TYPES.JSXOpeningElement:
|
|
3398
|
+
case import_utils48.AST_NODE_TYPES.JSXClosingElement:
|
|
3399
|
+
case import_utils48.AST_NODE_TYPES.MemberExpression:
|
|
3400
|
+
case import_utils48.AST_NODE_TYPES.VariableDeclarator:
|
|
3401
|
+
case import_utils48.AST_NODE_TYPES.TaggedTemplateExpression:
|
|
3402
|
+
case import_utils48.AST_NODE_TYPES.SpreadElement:
|
|
3403
|
+
case import_utils48.AST_NODE_TYPES.ExportSpecifier:
|
|
3404
|
+
case import_utils48.AST_NODE_TYPES.ArrayExpression:
|
|
3405
|
+
case import_utils48.AST_NODE_TYPES.ObjectExpression:
|
|
3406
|
+
case import_utils48.AST_NODE_TYPES.BinaryExpression:
|
|
3407
|
+
case import_utils48.AST_NODE_TYPES.LogicalExpression:
|
|
3408
|
+
case import_utils48.AST_NODE_TYPES.UnaryExpression:
|
|
3409
|
+
case import_utils48.AST_NODE_TYPES.ReturnStatement:
|
|
3410
|
+
case import_utils48.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
3411
|
+
case import_utils48.AST_NODE_TYPES.ConditionalExpression:
|
|
3412
|
+
case import_utils48.AST_NODE_TYPES.AwaitExpression:
|
|
3413
|
+
case import_utils48.AST_NODE_TYPES.YieldExpression:
|
|
3414
|
+
case import_utils48.AST_NODE_TYPES.Property:
|
|
3415
|
+
case import_utils48.AST_NODE_TYPES.JSXExpressionContainer:
|
|
3411
3416
|
return true;
|
|
3412
3417
|
default:
|
|
3413
3418
|
return false;
|
|
@@ -3431,13 +3436,13 @@ var preferImportType = createRule45({
|
|
|
3431
3436
|
}
|
|
3432
3437
|
const scope = context.sourceCode.getScope(node);
|
|
3433
3438
|
const isTypeOnlyImport2 = node.specifiers.every((specifier) => {
|
|
3434
|
-
if (specifier.type ===
|
|
3439
|
+
if (specifier.type === import_utils48.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
|
3435
3440
|
return false;
|
|
3436
3441
|
}
|
|
3437
|
-
if (specifier.type ===
|
|
3442
|
+
if (specifier.type === import_utils48.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
3438
3443
|
return false;
|
|
3439
3444
|
}
|
|
3440
|
-
if (specifier.type ===
|
|
3445
|
+
if (specifier.type === import_utils48.AST_NODE_TYPES.ImportSpecifier) {
|
|
3441
3446
|
const localName = specifier.local.name;
|
|
3442
3447
|
return !isUsedAsValue(localName, scope);
|
|
3443
3448
|
}
|
|
@@ -3463,16 +3468,16 @@ var preferImportType = createRule45({
|
|
|
3463
3468
|
var prefer_import_type_default = preferImportType;
|
|
3464
3469
|
|
|
3465
3470
|
// src/rules/prefer-inline-literal-union.ts
|
|
3466
|
-
var
|
|
3467
|
-
var createRule46 =
|
|
3471
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
3472
|
+
var createRule46 = import_utils49.ESLintUtils.RuleCreator(
|
|
3468
3473
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3469
3474
|
);
|
|
3470
3475
|
function isLiteralUnionType(node) {
|
|
3471
|
-
if (node.type !==
|
|
3476
|
+
if (node.type !== import_utils49.AST_NODE_TYPES.TSUnionType) {
|
|
3472
3477
|
return false;
|
|
3473
3478
|
}
|
|
3474
3479
|
return node.types.every(
|
|
3475
|
-
(member) => member.type ===
|
|
3480
|
+
(member) => member.type === import_utils49.AST_NODE_TYPES.TSLiteralType || member.type === import_utils49.AST_NODE_TYPES.TSNullKeyword || member.type === import_utils49.AST_NODE_TYPES.TSUndefinedKeyword
|
|
3476
3481
|
);
|
|
3477
3482
|
}
|
|
3478
3483
|
var preferInlineLiteralUnion = createRule46({
|
|
@@ -3502,10 +3507,10 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3502
3507
|
return;
|
|
3503
3508
|
}
|
|
3504
3509
|
const { typeAnnotation } = node.typeAnnotation;
|
|
3505
|
-
if (typeAnnotation.type !==
|
|
3510
|
+
if (typeAnnotation.type !== import_utils49.AST_NODE_TYPES.TSTypeReference) {
|
|
3506
3511
|
return;
|
|
3507
3512
|
}
|
|
3508
|
-
if (typeAnnotation.typeName.type !==
|
|
3513
|
+
if (typeAnnotation.typeName.type !== import_utils49.AST_NODE_TYPES.Identifier) {
|
|
3509
3514
|
return;
|
|
3510
3515
|
}
|
|
3511
3516
|
const aliasName = typeAnnotation.typeName.name;
|
|
@@ -3529,11 +3534,11 @@ var preferInlineLiteralUnion = createRule46({
|
|
|
3529
3534
|
var prefer_inline_literal_union_default = preferInlineLiteralUnion;
|
|
3530
3535
|
|
|
3531
3536
|
// src/rules/prefer-inline-type-export.ts
|
|
3532
|
-
var
|
|
3533
|
-
var createRule47 =
|
|
3537
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
3538
|
+
var createRule47 = import_utils50.ESLintUtils.RuleCreator(
|
|
3534
3539
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3535
3540
|
);
|
|
3536
|
-
var isTypeDeclaration = (node) => node.type ===
|
|
3541
|
+
var isTypeDeclaration = (node) => node.type === import_utils50.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils50.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
3537
3542
|
var preferInlineTypeExport = createRule47({
|
|
3538
3543
|
name: "prefer-inline-type-export",
|
|
3539
3544
|
meta: {
|
|
@@ -3551,12 +3556,12 @@ var preferInlineTypeExport = createRule47({
|
|
|
3551
3556
|
create(context) {
|
|
3552
3557
|
const typeDeclarations = /* @__PURE__ */ new Map();
|
|
3553
3558
|
function collectDeclaration(node) {
|
|
3554
|
-
if (node.parent.type !==
|
|
3559
|
+
if (node.parent.type !== import_utils50.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
3555
3560
|
typeDeclarations.set(node.id.name, node);
|
|
3556
3561
|
}
|
|
3557
3562
|
}
|
|
3558
3563
|
function reportSpecifier(specifier, statement, declarationNode) {
|
|
3559
|
-
if (specifier.local.type !==
|
|
3564
|
+
if (specifier.local.type !== import_utils50.AST_NODE_TYPES.Identifier) {
|
|
3560
3565
|
return;
|
|
3561
3566
|
}
|
|
3562
3567
|
const { name } = specifier.local;
|
|
@@ -3589,16 +3594,16 @@ var preferInlineTypeExport = createRule47({
|
|
|
3589
3594
|
return {
|
|
3590
3595
|
Program(node) {
|
|
3591
3596
|
node.body.forEach((statement) => {
|
|
3592
|
-
if (statement.type ===
|
|
3597
|
+
if (statement.type === import_utils50.AST_NODE_TYPES.TSInterfaceDeclaration || statement.type === import_utils50.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
3593
3598
|
collectDeclaration(statement);
|
|
3594
3599
|
}
|
|
3595
3600
|
});
|
|
3596
3601
|
node.body.forEach((statement) => {
|
|
3597
|
-
if (statement.type !==
|
|
3602
|
+
if (statement.type !== import_utils50.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
3598
3603
|
return;
|
|
3599
3604
|
}
|
|
3600
3605
|
statement.specifiers.forEach((specifier) => {
|
|
3601
|
-
if (specifier.local.type !==
|
|
3606
|
+
if (specifier.local.type !== import_utils50.AST_NODE_TYPES.Identifier) {
|
|
3602
3607
|
return;
|
|
3603
3608
|
}
|
|
3604
3609
|
const declarationNode = typeDeclarations.get(specifier.local.name);
|
|
@@ -3615,8 +3620,8 @@ var preferInlineTypeExport = createRule47({
|
|
|
3615
3620
|
var prefer_inline_type_export_default = preferInlineTypeExport;
|
|
3616
3621
|
|
|
3617
3622
|
// src/rules/prefer-interface-over-inline-types.ts
|
|
3618
|
-
var
|
|
3619
|
-
var createRule48 =
|
|
3623
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
3624
|
+
var createRule48 = import_utils51.ESLintUtils.RuleCreator(
|
|
3620
3625
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3621
3626
|
);
|
|
3622
3627
|
var preferInterfaceOverInlineTypes = createRule48({
|
|
@@ -3635,54 +3640,54 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3635
3640
|
defaultOptions: [],
|
|
3636
3641
|
create(context) {
|
|
3637
3642
|
function hasJSXInConditional(node) {
|
|
3638
|
-
return node.consequent.type ===
|
|
3643
|
+
return node.consequent.type === import_utils51.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils51.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils51.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils51.AST_NODE_TYPES.JSXFragment;
|
|
3639
3644
|
}
|
|
3640
3645
|
function hasJSXInLogical(node) {
|
|
3641
|
-
return node.right.type ===
|
|
3646
|
+
return node.right.type === import_utils51.AST_NODE_TYPES.JSXElement || node.right.type === import_utils51.AST_NODE_TYPES.JSXFragment;
|
|
3642
3647
|
}
|
|
3643
3648
|
function hasJSXReturn(block) {
|
|
3644
3649
|
return block.body.some((stmt) => {
|
|
3645
|
-
if (stmt.type ===
|
|
3646
|
-
return stmt.argument.type ===
|
|
3650
|
+
if (stmt.type === import_utils51.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
3651
|
+
return stmt.argument.type === import_utils51.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils51.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils51.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils51.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
3647
3652
|
}
|
|
3648
3653
|
return false;
|
|
3649
3654
|
});
|
|
3650
3655
|
}
|
|
3651
3656
|
function isReactComponent2(node) {
|
|
3652
|
-
if (node.type ===
|
|
3653
|
-
if (node.body.type ===
|
|
3657
|
+
if (node.type === import_utils51.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
3658
|
+
if (node.body.type === import_utils51.AST_NODE_TYPES.JSXElement || node.body.type === import_utils51.AST_NODE_TYPES.JSXFragment) {
|
|
3654
3659
|
return true;
|
|
3655
3660
|
}
|
|
3656
|
-
if (node.body.type ===
|
|
3661
|
+
if (node.body.type === import_utils51.AST_NODE_TYPES.BlockStatement) {
|
|
3657
3662
|
return hasJSXReturn(node.body);
|
|
3658
3663
|
}
|
|
3659
|
-
} else if (node.type ===
|
|
3660
|
-
if (node.body && node.body.type ===
|
|
3664
|
+
} else if (node.type === import_utils51.AST_NODE_TYPES.FunctionExpression || node.type === import_utils51.AST_NODE_TYPES.FunctionDeclaration) {
|
|
3665
|
+
if (node.body && node.body.type === import_utils51.AST_NODE_TYPES.BlockStatement) {
|
|
3661
3666
|
return hasJSXReturn(node.body);
|
|
3662
3667
|
}
|
|
3663
3668
|
}
|
|
3664
3669
|
return false;
|
|
3665
3670
|
}
|
|
3666
3671
|
function isInlineTypeAnnotation(node) {
|
|
3667
|
-
if (node.type ===
|
|
3672
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3668
3673
|
return true;
|
|
3669
3674
|
}
|
|
3670
|
-
if (node.type ===
|
|
3671
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3675
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3676
|
+
return node.typeArguments.params.some((param) => param.type === import_utils51.AST_NODE_TYPES.TSTypeLiteral);
|
|
3672
3677
|
}
|
|
3673
|
-
if (node.type ===
|
|
3678
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSUnionType) {
|
|
3674
3679
|
return node.types.some((type) => isInlineTypeAnnotation(type));
|
|
3675
3680
|
}
|
|
3676
3681
|
return false;
|
|
3677
3682
|
}
|
|
3678
3683
|
function hasInlineObjectType(node) {
|
|
3679
|
-
if (node.type ===
|
|
3684
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3680
3685
|
return true;
|
|
3681
3686
|
}
|
|
3682
|
-
if (node.type ===
|
|
3683
|
-
return node.typeArguments.params.some((param) => param.type ===
|
|
3687
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSTypeReference && node.typeArguments) {
|
|
3688
|
+
return node.typeArguments.params.some((param) => param.type === import_utils51.AST_NODE_TYPES.TSTypeLiteral);
|
|
3684
3689
|
}
|
|
3685
|
-
if (node.type ===
|
|
3690
|
+
if (node.type === import_utils51.AST_NODE_TYPES.TSUnionType) {
|
|
3686
3691
|
return node.types.some((type) => hasInlineObjectType(type));
|
|
3687
3692
|
}
|
|
3688
3693
|
return false;
|
|
@@ -3695,7 +3700,7 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3695
3700
|
return;
|
|
3696
3701
|
}
|
|
3697
3702
|
const param = node.params[0];
|
|
3698
|
-
if (param.type ===
|
|
3703
|
+
if (param.type === import_utils51.AST_NODE_TYPES.Identifier && param.typeAnnotation) {
|
|
3699
3704
|
const { typeAnnotation } = param.typeAnnotation;
|
|
3700
3705
|
if (isInlineTypeAnnotation(typeAnnotation) && hasInlineObjectType(typeAnnotation)) {
|
|
3701
3706
|
context.report({
|
|
@@ -3715,8 +3720,8 @@ var preferInterfaceOverInlineTypes = createRule48({
|
|
|
3715
3720
|
var prefer_interface_over_inline_types_default = preferInterfaceOverInlineTypes;
|
|
3716
3721
|
|
|
3717
3722
|
// src/rules/prefer-jsx-template-literals.ts
|
|
3718
|
-
var
|
|
3719
|
-
var createRule49 =
|
|
3723
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
3724
|
+
var createRule49 = import_utils52.ESLintUtils.RuleCreator(
|
|
3720
3725
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3721
3726
|
);
|
|
3722
3727
|
var preferJSXTemplateLiterals = createRule49({
|
|
@@ -3788,9 +3793,9 @@ var preferJSXTemplateLiterals = createRule49({
|
|
|
3788
3793
|
if (!child || !nextChild) {
|
|
3789
3794
|
return;
|
|
3790
3795
|
}
|
|
3791
|
-
if (child.type ===
|
|
3796
|
+
if (child.type === import_utils52.AST_NODE_TYPES.JSXText && nextChild.type === import_utils52.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
3792
3797
|
handleTextBeforeExpression(child, nextChild);
|
|
3793
|
-
} else if (child.type ===
|
|
3798
|
+
} else if (child.type === import_utils52.AST_NODE_TYPES.JSXExpressionContainer && nextChild.type === import_utils52.AST_NODE_TYPES.JSXText) {
|
|
3794
3799
|
handleExpressionBeforeText(child, nextChild);
|
|
3795
3800
|
}
|
|
3796
3801
|
}
|
|
@@ -3803,8 +3808,8 @@ var preferJSXTemplateLiterals = createRule49({
|
|
|
3803
3808
|
var prefer_jsx_template_literals_default = preferJSXTemplateLiterals;
|
|
3804
3809
|
|
|
3805
3810
|
// src/rules/prefer-named-param-types.ts
|
|
3806
|
-
var
|
|
3807
|
-
var createRule50 =
|
|
3811
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
3812
|
+
var createRule50 = import_utils53.ESLintUtils.RuleCreator(
|
|
3808
3813
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3809
3814
|
);
|
|
3810
3815
|
var preferNamedParamTypes = createRule50({
|
|
@@ -3822,16 +3827,16 @@ var preferNamedParamTypes = createRule50({
|
|
|
3822
3827
|
defaultOptions: [],
|
|
3823
3828
|
create(context) {
|
|
3824
3829
|
function hasInlineObjectType(param) {
|
|
3825
|
-
if (param.type ===
|
|
3830
|
+
if (param.type === import_utils53.AST_NODE_TYPES.AssignmentPattern) {
|
|
3826
3831
|
return hasInlineObjectType(param.left);
|
|
3827
3832
|
}
|
|
3828
|
-
if (param.type ===
|
|
3829
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3833
|
+
if (param.type === import_utils53.AST_NODE_TYPES.ObjectPattern) {
|
|
3834
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils53.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3830
3835
|
return true;
|
|
3831
3836
|
}
|
|
3832
3837
|
}
|
|
3833
|
-
if (param.type ===
|
|
3834
|
-
if (param.typeAnnotation?.typeAnnotation.type ===
|
|
3838
|
+
if (param.type === import_utils53.AST_NODE_TYPES.Identifier) {
|
|
3839
|
+
if (param.typeAnnotation?.typeAnnotation.type === import_utils53.AST_NODE_TYPES.TSTypeLiteral) {
|
|
3835
3840
|
return true;
|
|
3836
3841
|
}
|
|
3837
3842
|
}
|
|
@@ -3865,8 +3870,8 @@ var preferNamedParamTypes = createRule50({
|
|
|
3865
3870
|
var prefer_named_param_types_default = preferNamedParamTypes;
|
|
3866
3871
|
|
|
3867
3872
|
// src/rules/prefer-react-import-types.ts
|
|
3868
|
-
var
|
|
3869
|
-
var createRule51 =
|
|
3873
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
3874
|
+
var createRule51 = import_utils54.ESLintUtils.RuleCreator(
|
|
3870
3875
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3871
3876
|
);
|
|
3872
3877
|
var preferReactImportTypes = createRule51({
|
|
@@ -3945,7 +3950,7 @@ var preferReactImportTypes = createRule51({
|
|
|
3945
3950
|
]);
|
|
3946
3951
|
const allReactExports = /* @__PURE__ */ new Set([...reactTypes, ...reactRuntimeExports]);
|
|
3947
3952
|
function checkMemberExpression(node) {
|
|
3948
|
-
if (node.object.type ===
|
|
3953
|
+
if (node.object.type === import_utils54.AST_NODE_TYPES.Identifier && node.object.name === "React" && node.property.type === import_utils54.AST_NODE_TYPES.Identifier && allReactExports.has(node.property.name)) {
|
|
3949
3954
|
const typeName = node.property.name;
|
|
3950
3955
|
const isType = reactTypes.has(typeName);
|
|
3951
3956
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3962,7 +3967,7 @@ var preferReactImportTypes = createRule51({
|
|
|
3962
3967
|
return {
|
|
3963
3968
|
MemberExpression: checkMemberExpression,
|
|
3964
3969
|
"TSTypeReference > TSQualifiedName": (node) => {
|
|
3965
|
-
if (node.left.type ===
|
|
3970
|
+
if (node.left.type === import_utils54.AST_NODE_TYPES.Identifier && node.left.name === "React" && node.right.type === import_utils54.AST_NODE_TYPES.Identifier && allReactExports.has(node.right.name)) {
|
|
3966
3971
|
const typeName = node.right.name;
|
|
3967
3972
|
const isType = reactTypes.has(typeName);
|
|
3968
3973
|
const importStatement = isType ? `import type { ${typeName} } from "react"` : `import { ${typeName} } from "react"`;
|
|
@@ -3982,8 +3987,8 @@ var preferReactImportTypes = createRule51({
|
|
|
3982
3987
|
var prefer_react_import_types_default = preferReactImportTypes;
|
|
3983
3988
|
|
|
3984
3989
|
// src/rules/react-props-destructure.ts
|
|
3985
|
-
var
|
|
3986
|
-
var createRule52 =
|
|
3990
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
3991
|
+
var createRule52 = import_utils55.ESLintUtils.RuleCreator(
|
|
3987
3992
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
3988
3993
|
);
|
|
3989
3994
|
var reactPropsDestructure = createRule52({
|
|
@@ -4002,29 +4007,29 @@ var reactPropsDestructure = createRule52({
|
|
|
4002
4007
|
defaultOptions: [],
|
|
4003
4008
|
create(context) {
|
|
4004
4009
|
function hasJSXInConditional(node) {
|
|
4005
|
-
return node.consequent.type ===
|
|
4010
|
+
return node.consequent.type === import_utils55.AST_NODE_TYPES.JSXElement || node.consequent.type === import_utils55.AST_NODE_TYPES.JSXFragment || node.alternate.type === import_utils55.AST_NODE_TYPES.JSXElement || node.alternate.type === import_utils55.AST_NODE_TYPES.JSXFragment;
|
|
4006
4011
|
}
|
|
4007
4012
|
function hasJSXInLogical(node) {
|
|
4008
|
-
return node.right.type ===
|
|
4013
|
+
return node.right.type === import_utils55.AST_NODE_TYPES.JSXElement || node.right.type === import_utils55.AST_NODE_TYPES.JSXFragment;
|
|
4009
4014
|
}
|
|
4010
4015
|
function hasJSXReturn(block) {
|
|
4011
4016
|
return block.body.some((stmt) => {
|
|
4012
|
-
if (stmt.type ===
|
|
4013
|
-
return stmt.argument.type ===
|
|
4017
|
+
if (stmt.type === import_utils55.AST_NODE_TYPES.ReturnStatement && stmt.argument) {
|
|
4018
|
+
return stmt.argument.type === import_utils55.AST_NODE_TYPES.JSXElement || stmt.argument.type === import_utils55.AST_NODE_TYPES.JSXFragment || stmt.argument.type === import_utils55.AST_NODE_TYPES.ConditionalExpression && hasJSXInConditional(stmt.argument) || stmt.argument.type === import_utils55.AST_NODE_TYPES.LogicalExpression && hasJSXInLogical(stmt.argument);
|
|
4014
4019
|
}
|
|
4015
4020
|
return false;
|
|
4016
4021
|
});
|
|
4017
4022
|
}
|
|
4018
4023
|
function isReactComponent2(node) {
|
|
4019
|
-
if (node.type ===
|
|
4020
|
-
if (node.body.type ===
|
|
4024
|
+
if (node.type === import_utils55.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4025
|
+
if (node.body.type === import_utils55.AST_NODE_TYPES.JSXElement || node.body.type === import_utils55.AST_NODE_TYPES.JSXFragment) {
|
|
4021
4026
|
return true;
|
|
4022
4027
|
}
|
|
4023
|
-
if (node.body.type ===
|
|
4028
|
+
if (node.body.type === import_utils55.AST_NODE_TYPES.BlockStatement) {
|
|
4024
4029
|
return hasJSXReturn(node.body);
|
|
4025
4030
|
}
|
|
4026
|
-
} else if (node.type ===
|
|
4027
|
-
if (node.body && node.body.type ===
|
|
4031
|
+
} else if (node.type === import_utils55.AST_NODE_TYPES.FunctionExpression || node.type === import_utils55.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4032
|
+
if (node.body && node.body.type === import_utils55.AST_NODE_TYPES.BlockStatement) {
|
|
4028
4033
|
return hasJSXReturn(node.body);
|
|
4029
4034
|
}
|
|
4030
4035
|
}
|
|
@@ -4038,9 +4043,9 @@ var reactPropsDestructure = createRule52({
|
|
|
4038
4043
|
return;
|
|
4039
4044
|
}
|
|
4040
4045
|
const param = node.params[0];
|
|
4041
|
-
if (param.type ===
|
|
4042
|
-
const properties = param.properties.filter((prop) => prop.type ===
|
|
4043
|
-
if (prop.key.type ===
|
|
4046
|
+
if (param.type === import_utils55.AST_NODE_TYPES.ObjectPattern) {
|
|
4047
|
+
const properties = param.properties.filter((prop) => prop.type === import_utils55.AST_NODE_TYPES.Property).map((prop) => {
|
|
4048
|
+
if (prop.key.type === import_utils55.AST_NODE_TYPES.Identifier) {
|
|
4044
4049
|
return prop.key.name;
|
|
4045
4050
|
}
|
|
4046
4051
|
return null;
|
|
@@ -4067,52 +4072,52 @@ var reactPropsDestructure = createRule52({
|
|
|
4067
4072
|
var react_props_destructure_default = reactPropsDestructure;
|
|
4068
4073
|
|
|
4069
4074
|
// src/rules/require-explicit-return-type.ts
|
|
4070
|
-
var
|
|
4071
|
-
var createRule53 =
|
|
4075
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
4076
|
+
var createRule53 = import_utils56.ESLintUtils.RuleCreator(
|
|
4072
4077
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4073
4078
|
);
|
|
4074
4079
|
var isReactComponent = (node) => {
|
|
4075
|
-
if (node.type ===
|
|
4080
|
+
if (node.type === import_utils56.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
4076
4081
|
const { parent } = node;
|
|
4077
|
-
if (parent?.type ===
|
|
4082
|
+
if (parent?.type === import_utils56.AST_NODE_TYPES.VariableDeclarator) {
|
|
4078
4083
|
const { id } = parent;
|
|
4079
|
-
if (id.type ===
|
|
4084
|
+
if (id.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
4080
4085
|
return /^[A-Z]/.test(id.name);
|
|
4081
4086
|
}
|
|
4082
4087
|
}
|
|
4083
4088
|
}
|
|
4084
|
-
if (node.type ===
|
|
4089
|
+
if (node.type === import_utils56.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4085
4090
|
return /^[A-Z]/.test(node.id.name);
|
|
4086
4091
|
}
|
|
4087
4092
|
return false;
|
|
4088
4093
|
};
|
|
4089
4094
|
var isCallbackFunction = (node) => {
|
|
4090
|
-
if (node.type ===
|
|
4095
|
+
if (node.type === import_utils56.AST_NODE_TYPES.FunctionDeclaration) {
|
|
4091
4096
|
return false;
|
|
4092
4097
|
}
|
|
4093
4098
|
const { parent } = node;
|
|
4094
4099
|
if (!parent) {
|
|
4095
4100
|
return false;
|
|
4096
4101
|
}
|
|
4097
|
-
if (parent.type ===
|
|
4102
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.CallExpression && parent.arguments.includes(node)) {
|
|
4098
4103
|
return true;
|
|
4099
4104
|
}
|
|
4100
|
-
if (parent.type ===
|
|
4105
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.Property) {
|
|
4101
4106
|
return true;
|
|
4102
4107
|
}
|
|
4103
|
-
if (parent.type ===
|
|
4108
|
+
if (parent.type === import_utils56.AST_NODE_TYPES.ArrayExpression) {
|
|
4104
4109
|
return true;
|
|
4105
4110
|
}
|
|
4106
4111
|
return false;
|
|
4107
4112
|
};
|
|
4108
4113
|
var getFunctionName = (node) => {
|
|
4109
|
-
if (node.type ===
|
|
4114
|
+
if (node.type === import_utils56.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
4110
4115
|
return node.id.name;
|
|
4111
4116
|
}
|
|
4112
|
-
if (node.type ===
|
|
4117
|
+
if (node.type === import_utils56.AST_NODE_TYPES.FunctionExpression && node.id) {
|
|
4113
4118
|
return node.id.name;
|
|
4114
4119
|
}
|
|
4115
|
-
if ((node.type ===
|
|
4120
|
+
if ((node.type === import_utils56.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils56.AST_NODE_TYPES.FunctionExpression) && node.parent?.type === import_utils56.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === import_utils56.AST_NODE_TYPES.Identifier) {
|
|
4116
4121
|
return node.parent.id.name;
|
|
4117
4122
|
}
|
|
4118
4123
|
return null;
|
|
@@ -4166,8 +4171,8 @@ var requireExplicitReturnType = createRule53({
|
|
|
4166
4171
|
var require_explicit_return_type_default = requireExplicitReturnType;
|
|
4167
4172
|
|
|
4168
4173
|
// src/rules/sort-exports.ts
|
|
4169
|
-
var
|
|
4170
|
-
var createRule54 =
|
|
4174
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
4175
|
+
var createRule54 = import_utils57.ESLintUtils.RuleCreator(
|
|
4171
4176
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4172
4177
|
);
|
|
4173
4178
|
var GROUP_NAMES = ["", "external/alias re-export", "relative re-export", "local export"];
|
|
@@ -4221,7 +4226,7 @@ var sortExports = createRule54({
|
|
|
4221
4226
|
Program(node) {
|
|
4222
4227
|
const exportGroups = [];
|
|
4223
4228
|
node.body.forEach((statement) => {
|
|
4224
|
-
if (statement.type !==
|
|
4229
|
+
if (statement.type !== import_utils57.AST_NODE_TYPES.ExportNamedDeclaration || statement.declaration !== null) {
|
|
4225
4230
|
if (exportGroups.length > 0) {
|
|
4226
4231
|
checkOrder(exportGroups);
|
|
4227
4232
|
exportGroups.length = 0;
|
|
@@ -4240,8 +4245,8 @@ var sortExports = createRule54({
|
|
|
4240
4245
|
var sort_exports_default = sortExports;
|
|
4241
4246
|
|
|
4242
4247
|
// src/rules/sort-imports.ts
|
|
4243
|
-
var
|
|
4244
|
-
var createRule55 =
|
|
4248
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
4249
|
+
var createRule55 = import_utils58.ESLintUtils.RuleCreator(
|
|
4245
4250
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4246
4251
|
);
|
|
4247
4252
|
var NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
@@ -4352,7 +4357,7 @@ var sortImports = createRule55({
|
|
|
4352
4357
|
Program(node) {
|
|
4353
4358
|
const importGroups = [];
|
|
4354
4359
|
node.body.forEach((statement) => {
|
|
4355
|
-
if (statement.type !==
|
|
4360
|
+
if (statement.type !== import_utils58.AST_NODE_TYPES.ImportDeclaration) {
|
|
4356
4361
|
if (importGroups.length > 0) {
|
|
4357
4362
|
checkOrder(importGroups);
|
|
4358
4363
|
importGroups.length = 0;
|
|
@@ -4374,13 +4379,13 @@ var sortImports = createRule55({
|
|
|
4374
4379
|
var sort_imports_default = sortImports;
|
|
4375
4380
|
|
|
4376
4381
|
// src/rules/sort-type-alphabetically.ts
|
|
4377
|
-
var
|
|
4378
|
-
var createRule56 =
|
|
4382
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
4383
|
+
var createRule56 = import_utils59.ESLintUtils.RuleCreator(
|
|
4379
4384
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4380
4385
|
);
|
|
4381
4386
|
function isAlphabeticallySortedWithinGroups(members) {
|
|
4382
4387
|
const properties = members.filter(
|
|
4383
|
-
(member) => member.type ===
|
|
4388
|
+
(member) => member.type === import_utils59.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils59.AST_NODE_TYPES.Identifier
|
|
4384
4389
|
);
|
|
4385
4390
|
if (properties.length < 2) {
|
|
4386
4391
|
return true;
|
|
@@ -4409,7 +4414,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4409
4414
|
function fixMembers(fixer, members) {
|
|
4410
4415
|
const { sourceCode } = context;
|
|
4411
4416
|
const properties = members.filter(
|
|
4412
|
-
(member) => member.type ===
|
|
4417
|
+
(member) => member.type === import_utils59.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils59.AST_NODE_TYPES.Identifier
|
|
4413
4418
|
);
|
|
4414
4419
|
const required = properties.filter((prop) => !prop.optional);
|
|
4415
4420
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4446,7 +4451,7 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4446
4451
|
}
|
|
4447
4452
|
},
|
|
4448
4453
|
TSTypeAliasDeclaration(node) {
|
|
4449
|
-
if (node.typeAnnotation.type !==
|
|
4454
|
+
if (node.typeAnnotation.type !== import_utils59.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4450
4455
|
return;
|
|
4451
4456
|
}
|
|
4452
4457
|
const { members } = node.typeAnnotation;
|
|
@@ -4466,13 +4471,13 @@ var sortTypeAlphabetically = createRule56({
|
|
|
4466
4471
|
var sort_type_alphabetically_default = sortTypeAlphabetically;
|
|
4467
4472
|
|
|
4468
4473
|
// src/rules/sort-type-required-first.ts
|
|
4469
|
-
var
|
|
4470
|
-
var createRule57 =
|
|
4474
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
4475
|
+
var createRule57 = import_utils60.ESLintUtils.RuleCreator(
|
|
4471
4476
|
(name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`
|
|
4472
4477
|
);
|
|
4473
4478
|
function isRequiredBeforeOptional(members) {
|
|
4474
4479
|
const properties = members.filter(
|
|
4475
|
-
(member) => member.type ===
|
|
4480
|
+
(member) => member.type === import_utils60.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils60.AST_NODE_TYPES.Identifier
|
|
4476
4481
|
);
|
|
4477
4482
|
if (properties.length < 2) {
|
|
4478
4483
|
return true;
|
|
@@ -4501,7 +4506,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4501
4506
|
function fixMembers(fixer, members) {
|
|
4502
4507
|
const { sourceCode } = context;
|
|
4503
4508
|
const properties = members.filter(
|
|
4504
|
-
(member) => member.type ===
|
|
4509
|
+
(member) => member.type === import_utils60.AST_NODE_TYPES.TSPropertySignature && member.key.type === import_utils60.AST_NODE_TYPES.Identifier
|
|
4505
4510
|
);
|
|
4506
4511
|
const required = properties.filter((prop) => !prop.optional);
|
|
4507
4512
|
const optional = properties.filter((prop) => prop.optional);
|
|
@@ -4522,7 +4527,7 @@ var sortTypeRequiredFirst = createRule57({
|
|
|
4522
4527
|
}
|
|
4523
4528
|
},
|
|
4524
4529
|
TSTypeAliasDeclaration(node) {
|
|
4525
|
-
if (node.typeAnnotation.type !==
|
|
4530
|
+
if (node.typeAnnotation.type !== import_utils60.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4526
4531
|
return;
|
|
4527
4532
|
}
|
|
4528
4533
|
const { members } = node.typeAnnotation;
|
|
@@ -4741,6 +4746,19 @@ var createConfig = (configRules) => ({
|
|
|
4741
4746
|
},
|
|
4742
4747
|
rules: configRules
|
|
4743
4748
|
});
|
|
4749
|
+
var NEXTJS_ROUTING_GLOBS = [
|
|
4750
|
+
"app/**/*.{jsx,tsx}",
|
|
4751
|
+
"src/app/**/*.{jsx,tsx}",
|
|
4752
|
+
"pages/**/*.{jsx,tsx}",
|
|
4753
|
+
"src/pages/**/*.{jsx,tsx}"
|
|
4754
|
+
];
|
|
4755
|
+
var nextjsRoutingOverride = {
|
|
4756
|
+
files: NEXTJS_ROUTING_GLOBS,
|
|
4757
|
+
rules: {
|
|
4758
|
+
"nextfriday/jsx-pascal-case": "off"
|
|
4759
|
+
}
|
|
4760
|
+
};
|
|
4761
|
+
var createNextjsConfig = (configRules) => [createConfig(configRules), nextjsRoutingOverride];
|
|
4744
4762
|
var configs = {
|
|
4745
4763
|
base: createConfig(baseRules),
|
|
4746
4764
|
"base/recommended": createConfig(baseRecommendedRules),
|
|
@@ -4752,55 +4770,16 @@ var configs = {
|
|
|
4752
4770
|
...baseRecommendedRules,
|
|
4753
4771
|
...jsxRecommendedRules
|
|
4754
4772
|
}),
|
|
4755
|
-
nextjs:
|
|
4773
|
+
nextjs: createNextjsConfig({
|
|
4756
4774
|
...baseRules,
|
|
4757
4775
|
...jsxRules,
|
|
4758
4776
|
...nextjsOnlyRules
|
|
4759
4777
|
}),
|
|
4760
|
-
"nextjs/recommended":
|
|
4778
|
+
"nextjs/recommended": createNextjsConfig({
|
|
4761
4779
|
...baseRecommendedRules,
|
|
4762
4780
|
...jsxRecommendedRules,
|
|
4763
4781
|
...nextjsOnlyRecommendedRules
|
|
4764
|
-
})
|
|
4765
|
-
get sonarjs() {
|
|
4766
|
-
const pluginSonarjs = import_eslint_plugin_sonarjs.default.default ?? import_eslint_plugin_sonarjs.default;
|
|
4767
|
-
const sonarjsRules = pluginSonarjs.configs.recommended.rules;
|
|
4768
|
-
return [
|
|
4769
|
-
{
|
|
4770
|
-
name: "sonarjs/config",
|
|
4771
|
-
plugins: {
|
|
4772
|
-
sonarjs: pluginSonarjs
|
|
4773
|
-
},
|
|
4774
|
-
rules: {
|
|
4775
|
-
...sonarjsRules
|
|
4776
|
-
}
|
|
4777
|
-
}
|
|
4778
|
-
];
|
|
4779
|
-
},
|
|
4780
|
-
get unicorn() {
|
|
4781
|
-
const pluginUnicorn = import_eslint_plugin_unicorn.default.default ?? import_eslint_plugin_unicorn.default;
|
|
4782
|
-
const unicornRules = pluginUnicorn.configs.recommended.rules;
|
|
4783
|
-
return [
|
|
4784
|
-
{
|
|
4785
|
-
name: "unicorn/config",
|
|
4786
|
-
plugins: {
|
|
4787
|
-
unicorn: pluginUnicorn
|
|
4788
|
-
},
|
|
4789
|
-
rules: {
|
|
4790
|
-
...unicornRules,
|
|
4791
|
-
"unicorn/filename-case": "off",
|
|
4792
|
-
"unicorn/prevent-abbreviations": "off"
|
|
4793
|
-
}
|
|
4794
|
-
},
|
|
4795
|
-
{
|
|
4796
|
-
name: "unicorn/jsx-tsx-exceptions",
|
|
4797
|
-
files: ["**/*.jsx", "**/*.tsx"],
|
|
4798
|
-
rules: {
|
|
4799
|
-
"unicorn/no-null": "off"
|
|
4800
|
-
}
|
|
4801
|
-
}
|
|
4802
|
-
];
|
|
4803
|
-
}
|
|
4782
|
+
})
|
|
4804
4783
|
};
|
|
4805
4784
|
var nextfridayPlugin = {
|
|
4806
4785
|
meta,
|