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